display.cpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #include "display.h"
  2. #include "config.h"
  3. #include "logo.h"
  4. // ---------------------------------------------------------------------------
  5. // Helpers
  6. // ---------------------------------------------------------------------------
  7. static void drawStatusScreen(TFT_eSPI &tft,
  8. uint16_t bgColour,
  9. uint16_t letterColour,
  10. const char *letter) {
  11. TFT_eSprite spr = TFT_eSprite(&tft);
  12. spr.createSprite(DISPLAY_W, DISPLAY_H);
  13. spr.fillSprite(bgColour);
  14. // Outer ring
  15. spr.drawCircle(DISPLAY_CX, DISPLAY_CY, DISPLAY_RADIUS, COL_RING);
  16. spr.drawCircle(DISPLAY_CX, DISPLAY_CY, DISPLAY_RADIUS - 1, COL_RING);
  17. // "SYSTEM" label
  18. spr.setTextDatum(MC_DATUM);
  19. spr.setTextFont(2);
  20. spr.setTextColor(COL_LABEL, bgColour);
  21. spr.drawString("SYSTEM", DISPLAY_CX, 72);
  22. // Separator line under label
  23. spr.drawFastHLine(DISPLAY_CX - 55, 88, 110, COL_LABEL);
  24. // Large system letter (A or B)
  25. spr.setTextFont(8); // large built-in font
  26. spr.setTextColor(letterColour, bgColour);
  27. spr.setTextDatum(MC_DATUM);
  28. spr.drawString(letter, DISPLAY_CX, 138);
  29. // Separator line above ACTIVE
  30. spr.drawFastHLine(DISPLAY_CX - 55, 164, 110, COL_LABEL);
  31. // "ACTIVE" label
  32. spr.setTextFont(2);
  33. spr.setTextColor(COL_LABEL, bgColour);
  34. spr.drawString("ACTIVE", DISPLAY_CX, 180);
  35. spr.pushSprite(0, 0);
  36. spr.deleteSprite();
  37. }
  38. // ---------------------------------------------------------------------------
  39. // Public API
  40. // ---------------------------------------------------------------------------
  41. void displayInit(TFT_eSPI &tft) {
  42. tft.init();
  43. tft.setRotation(0);
  44. tft.fillScreen(TFT_BLACK);
  45. }
  46. void displayShowLogo(TFT_eSPI &tft) {
  47. drawLogo(tft);
  48. }
  49. void displayShowSystemA(TFT_eSPI &tft) {
  50. drawStatusScreen(tft, COL_BG_SYS_A, COL_LETTER_A, "A");
  51. }
  52. void displayShowSystemB(TFT_eSPI &tft) {
  53. drawStatusScreen(tft, COL_BG_SYS_B, COL_LETTER_B, "B");
  54. }