Display SSD1306 for ESP32
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.

70 lines
1.4 KiB

  1. class Modifier{ //ContentType (2)
  2. private:
  3. String title;
  4. int *value;
  5. int max;
  6. int min;
  7. int step;
  8. int previousScreen = 0;
  9. int previousContentType = 0;
  10. public:
  11. void configure(String title, int *value, int max, int min, int step){
  12. this->title = title;
  13. this->value = value;
  14. this->max = max;
  15. this->min = min;
  16. this->step = step;
  17. }
  18. void drawModifier(){
  19. display.clearDisplay();
  20. display.fillRect(0, 0, 127 , 16, SSD1306_WHITE);
  21. display.setTextColor(SSD1306_BLACK, SSD1306_WHITE);
  22. display.setTextSize(1);
  23. display.setCursor(2, 4);
  24. display.println(this->title);
  25. display.setTextColor(SSD1306_WHITE);
  26. display.setTextSize(3);
  27. display.setCursor(2, ((DISP_HEIGHT - 16 - 15)/2) + 16);
  28. display.println(*this->value);
  29. display.display();
  30. display.setTextSize(1);
  31. }
  32. void increaseValue(){
  33. if((*this->value + this->step) <= this->max){
  34. *this->value += this->step;
  35. }
  36. }
  37. void decreaseValue(){
  38. if((*this->value - this->step) >= this->min){
  39. *this->value -= this->step;
  40. }
  41. }
  42. void setPreviousScreen(int prev){
  43. this->previousScreen = prev;
  44. }
  45. void setPreviousContentType(int prev){
  46. this->previousContentType = prev;
  47. }
  48. int getPreviousScreen(){
  49. int prev = this->previousScreen;
  50. return prev;
  51. }
  52. int getPreviousContentType(){
  53. int prev = this->previousContentType;
  54. return prev;
  55. }
  56. };