Distanz-/Tiefenmesser mit JSN-SR40T
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

Display.h 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * Display.h
  3. *
  4. * Wrapper class for Adafruit OLED display.
  5. *
  6. * Created on: 05.01.2026
  7. * Author: FSmilari
  8. */
  9. #ifndef DISPLAY_H_
  10. #define DISPLAY_H_
  11. #include <Adafruit_ST7735.h>
  12. #include "images/SFToolsLogo.h"
  13. #include "Status.h"
  14. #define SCREEN_WIDTH 160
  15. #define SCREEN_HEIGHT 128
  16. #define SCREEN_ADDRESS 0x3C
  17. class Display {
  18. private:
  19. Adafruit_ST7735 tft; // @suppress("Abstract class cannot be instantiated")
  20. String configValue;
  21. String configOption;
  22. String configUnit;
  23. bool refreshScreen;
  24. bool doMeasureAnimation;
  25. unsigned long starttime;
  26. float airTemp;
  27. float waterTemp;
  28. float sonicSpeedAir;
  29. uint8_t saltPromilleWater;
  30. int environment;
  31. uint16_t distance;
  32. void drawBitmap(int x, int y, int w, int h, const uint8_t bitmap[], uint16_t col);
  33. void drawRGBBitmap(int x, int y, int w, int h, const uint16_t bitmap[]);
  34. void redrawFrame();
  35. void redrawGrid(bool cfg = false);
  36. void redrawIdleStatus();
  37. void redrawConfigStatus();
  38. void redrawEnvIcon();
  39. void redrawTempIcon();
  40. void redrawDistance();
  41. void redrawConfigValue();
  42. void redrawConfigOption();
  43. void redrawConfigUnit();
  44. public:
  45. Display();
  46. void init(void);
  47. void display(void);
  48. void clearDisplay(void);
  49. void setRefreshScreen();
  50. void showBrand(int16_t x, int16_t y);
  51. void showInitialization(void);
  52. void showFrame(Status status);
  53. void drawXCenteredText(String txt, const GFXfont *font, uint8_t s, uint16_t c, int16_t y);
  54. void drawRightAlignedText(String txt, const GFXfont *font, uint8_t s, uint16_t c, int16_t xOffset, int16_t y);
  55. void drawText(String txt, const GFXfont *font, uint8_t s, uint16_t c, int16_t x, int16_t y);
  56. void drawCircle(int16_t x0, int16_t y0, int16_t r, uint16_t color);
  57. void setStatusValues(float airTemp, float waterTemp, float sonicSpeedAir, uint8_t saltPromilleWater);
  58. void setEnvironment(int environment);
  59. void setDistance(uint32_t distance);
  60. void runMeasureAnimation(bool run);
  61. void setConfigOption(String configOption);
  62. void setConfigText(String configText);
  63. void setConfigUnit(String configUnit);
  64. };
  65. #endif /* DISPLAY_H_ */