Download the file
  1. #ifndef SCREEN_H
  2. #define SCREEN_H
  3.  
  4. #include "hsphoto.h"
  5.  
  6. class Screen {
  7. public:
  8. Screen():
  9. enabled(1),
  10. initialized(0)
  11. {}
  12. virtual void refresh() = 0;
  13. virtual void hide() { initialized = 0; }
  14. virtual uint8_t click() = 0;
  15. virtual uint8_t clockwise() = 0;
  16. virtual uint8_t counter_clockwise() = 0;
  17. void enable() { enabled = 1; }
  18. void disable() { enabled = 0; }
  19. uint8_t is_enabled() { return enabled; }
  20.  
  21. protected:
  22. uint8_t enabled;
  23. uint8_t initialized;
  24. };
  25.  
  26. class ConfigScreen: public Screen {
  27. public:
  28. ConfigScreen(const char * title, const char * unit, uint8_t format_width):
  29. Screen(),
  30. title(title),
  31. unit(unit),
  32. selected(0),
  33. format_width(format_width) {}
  34.  
  35. virtual void refresh();
  36. virtual uint8_t click();
  37. virtual uint8_t is_selected() { return selected; }
  38. virtual uint8_t clockwise() { return selected ? on_clockwise() : 0; }
  39. virtual uint8_t counter_clockwise() { return selected ? on_counter_clockwise() : 0; }
  40. virtual uint8_t on_selected() { return 1; }
  41. virtual uint8_t on_deselected() { return 1; }
  42.  
  43. private:
  44. void show_static();
  45.  
  46. const char * title;
  47. const char * unit;
  48. uint8_t selected;
  49.  
  50. protected:
  51. virtual char * format_value() = 0;
  52. virtual uint8_t on_clockwise() = 0;
  53. virtual uint8_t on_counter_clockwise() = 0;
  54.  
  55. uint8_t format_width;
  56. };
  57.  
  58. #endif
  59. // vim:ft=arduino
  60.