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.

110 lines
2.7 KiB

10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
  1. with Ada.Text_IO;
  2. with bcm2835_h;
  3. with st7565lcd;
  4. with Interfaces;
  5. use Interfaces;
  6. with Ada.Text_IO;
  7. use Ada.Text_IO;
  8. with Ada.Streams.Stream_IO;
  9. with Ada.Command_Line;
  10. use Ada.Command_Line;
  11. procedure raspilcd is
  12. -- shorter names for packages
  13. package IO renames Ada.Text_IO;
  14. package LCD renames st7565lcd;
  15. package IOS renames Ada.Streams.Stream_IO;
  16. -- stream.io definitions
  17. My_File : IOS.FILE_TYPE;
  18. My_File_Access : IOS.STREAM_ACCESS;
  19. -- picture data
  20. bmp_picture : LCD.t_bmp_picture;
  21. -- lcd pixel array
  22. lcd_data : LCD.t_lcd_array;
  23. -- exception handling
  24. cli_exception : exception;
  25. begin
  26. -- no picture given
  27. if Argument_Count /= 1 then
  28. raise cli_exception;
  29. end if;
  30. -- open picture file
  31. declare
  32. filename : string := Argument(1);
  33. begin
  34. IOS.Open(My_File, IOS.In_File, filename);
  35. My_File_Access := IOS.Stream(My_File);
  36. end;
  37. -- read in picture
  38. LCD.read_bmp(file => My_File, file_access => My_File_Access, bmp_picture => bmp_picture);
  39. --Put_Line("Width: " & Integer'Image(picture_header.biWidth));
  40. --Put_Line("Height: " & Integer'Image(picture_header.biHeight));
  41. --Put_Line("Color Depth: " & Integer'Image(Integer(picture_header.biBitCount)));
  42. --Put_Line("Compression: " & Integer'Image(Integer(picture_header.biCompression)));
  43. -- close picture file
  44. Ada.Streams.Stream_IO.Close(My_File);
  45. -- convert bmp to lcd matrix
  46. lcd_data := LCD.bmp_to_lcd(bmp_picture);
  47. -- load bcm2835 lib
  48. -- print picture and some text on lcd
  49. if integer(bcm2835_h.bcm2835_init) = 0 then
  50. IO.Put_Line("Error while initializing BCM2835 library");
  51. else
  52. LCD.io_init;
  53. LCD.lcd_init;
  54. LCD.lcd_picture(xpos => 0, ypos => 0, picture => lcd_data);
  55. --bcm2835_h.bcm2835_delay(5000);
  56. --LCD.lcd_clear;
  57. --LCD.lcd_ascii57_string(xpos => 0, ypos => 0, data => "raspiFPGA 0.1");
  58. --LCD.lcd_ascii57_string(xpos => 0, ypos => 1, data => "(c) raspiDEV 2013");
  59. -- close library
  60. if integer(bcm2835_h.bcm2835_close) = 0 then
  61. IO.Put_Line("Error while closing BCM2835 library");
  62. end if;
  63. end if;
  64. -- exception handling
  65. exception
  66. when cli_exception =>
  67. put_line(LCD.exception_head);
  68. put_line("usage: ./raspitest BMP-FILE (as root)");
  69. when LCD.bmp_exception =>
  70. put_line(LCD.exception_head);
  71. put_line("error: malformed BMP-FILE (valid: 128x64, no compression, 32bpp)");
  72. when LCD.mask_exception =>
  73. put_line(LCD.exception_head);
  74. put_line("error: malformed BMP color mask");
  75. end raspilcd;