Various projects using Raspberry Pi
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

128 lines
3.4 KiB

11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
  1. -- raspilcd, a simple tool to display bmp pictures & text on a ST7565 LCD
  2. -- Copyright (C) 2014 Torsten Meissner
  3. --
  4. -- This program is free software: you can redistribute it and/or modify
  5. -- it under the terms of the GNU General Public License as published by
  6. -- the Free Software Foundation, either version 3 of the License, or
  7. -- (at your option) any later version.
  8. --
  9. -- This program is distributed in the hope that it will be useful,
  10. -- but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. -- GNU General Public License for more details.
  13. --
  14. -- You should have received a copy of the GNU General Public License
  15. -- along with this program. If not, see http://www.gnu.org/licenses/.
  16. with Ada.Text_IO;
  17. with bcm2835_h;
  18. with st7565lcd;
  19. with Interfaces;
  20. use Interfaces;
  21. with Ada.Text_IO;
  22. use Ada.Text_IO;
  23. with Ada.Streams.Stream_IO;
  24. with Ada.Command_Line;
  25. use Ada.Command_Line;
  26. procedure raspilcd is
  27. -- shorter names for packages
  28. package IO renames Ada.Text_IO;
  29. package LCD renames st7565lcd;
  30. package IOS renames Ada.Streams.Stream_IO;
  31. -- stream.io definitions
  32. My_File : IOS.FILE_TYPE;
  33. My_File_Access : IOS.STREAM_ACCESS;
  34. -- picture data
  35. bmp_picture : LCD.t_bmp_picture;
  36. -- lcd pixel array
  37. lcd_data : LCD.t_lcd_array;
  38. -- exception handling
  39. cli_exception : exception;
  40. begin
  41. -- no picture given
  42. if Argument_Count /= 1 then
  43. raise cli_exception;
  44. end if;
  45. -- open picture file
  46. declare
  47. filename : string := Argument(1);
  48. begin
  49. IOS.Open(My_File, IOS.In_File, filename);
  50. My_File_Access := IOS.Stream(My_File);
  51. end;
  52. -- read in picture
  53. LCD.read_bmp(file => My_File, file_access => My_File_Access, bmp_picture => bmp_picture);
  54. --Put_Line("Width: " & Integer'Image(picture_header.biWidth));
  55. --Put_Line("Height: " & Integer'Image(picture_header.biHeight));
  56. --Put_Line("Color Depth: " & Integer'Image(Integer(picture_header.biBitCount)));
  57. --Put_Line("Compression: " & Integer'Image(Integer(picture_header.biCompression)));
  58. -- close picture file
  59. Ada.Streams.Stream_IO.Close(My_File);
  60. -- convert bmp to lcd matrix
  61. lcd_data := LCD.bmp_to_lcd(bmp_picture);
  62. -- load bcm2835 lib
  63. -- print picture and some text on lcd
  64. if integer(bcm2835_h.bcm2835_init) = 0 then
  65. IO.Put_Line("Error while initializing BCM2835 library");
  66. else
  67. LCD.io_init;
  68. LCD.lcd_init;
  69. LCD.lcd_picture(xpos => 0, ypos => 0, picture => lcd_data);
  70. --bcm2835_h.bcm2835_delay(5000);
  71. --LCD.lcd_clear;
  72. --LCD.lcd_ascii57_string(xpos => 0, ypos => 0, data => "raspiFPGA 0.1");
  73. --LCD.lcd_ascii57_string(xpos => 0, ypos => 1, data => "(c) raspiDEV 2013");
  74. -- close library
  75. if integer(bcm2835_h.bcm2835_close) = 0 then
  76. IO.Put_Line("Error while closing BCM2835 library");
  77. end if;
  78. end if;
  79. -- exception handling
  80. exception
  81. when cli_exception =>
  82. put_line(LCD.exception_head);
  83. put_line("usage: ./raspitest BMP-FILE (as root)");
  84. when LCD.bmp_exception =>
  85. put_line(LCD.exception_head);
  86. put_line("error: malformed BMP-FILE (valid: 128x64, no compression, 32bpp)");
  87. when LCD.mask_exception =>
  88. put_line(LCD.exception_head);
  89. put_line("error: malformed BMP color mask");
  90. end raspilcd;