Nessuna descrizione

ssd1351.cxx 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #include "mraa.hpp"
  2. #include <iostream>
  3. #include <unistd.h>
  4. #include "ssd1351.h"
  5. #define BLACK 0x0000
  6. #define WHITE 0xFFFF
  7. #define INTEL_BLUE 0x0BF8
  8. int main(int argc, char **argv)
  9. {
  10. // Define colors (16-bit RGB on 5/6/5 bits)
  11. int colors[] = {0x0000, 0x000F, 0x03E0, 0x03EF,
  12. 0x7800, 0x780F, 0x7BE0, 0xC618,
  13. 0x7BEF, 0x001F, 0x07E0, 0x07FF,
  14. 0xF800, 0xF81F, 0xFFE0, 0xFFFF};
  15. //! [Interesting]
  16. // Initialize display with pins
  17. // oc = 0, dc = 1, r = 2, si = 11, cl = 13
  18. upm::SSD1351* display = new upm::SSD1351(0, 1, 2);
  19. // Test lines pixel by pixel
  20. for(int i = 0; i < SSD1351HEIGHT; i++) {
  21. for(int j = 0; j < SSD1351WIDTH; j++) {
  22. display->drawPixel(i, j, colors[i/8]);
  23. }
  24. }
  25. display->refresh();
  26. sleep(5);
  27. // Test rectangles
  28. for(int i = 0; i < SSD1351HEIGHT/32; i++) {
  29. for (int j = 0; j < SSD1351WIDTH/32; j++) {
  30. display->fillRect(i * 32, j * 32, 32, 32, colors[i * 4 + j]);
  31. }
  32. }
  33. display->refresh();
  34. sleep(5);
  35. // Test circles
  36. display->fillScreen(0x2104);
  37. for(int i = 0; i < SSD1351HEIGHT/32; i++) {
  38. for (int j = 0; j < SSD1351WIDTH/32; j++) {
  39. display->drawCircle(i * 32 + 15, j * 32 + 15, 15, colors[i * 4 + j]);
  40. }
  41. }
  42. display->refresh();
  43. sleep(5);
  44. // Test Text
  45. display->fillScreen(INTEL_BLUE);
  46. display->setTextColor(WHITE, INTEL_BLUE);
  47. display->setTextSize(4);
  48. display->setCursor(7, 30);
  49. display->print("Intel");
  50. display->setCursor(5, 70);
  51. display->print("IoTDK");
  52. display->refresh();
  53. //! [Interesting]
  54. }