display.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * (c) Philippe G. 2019, philippe_44@outlook.com
  3. *
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation, either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. *
  17. */
  18. #pragma once
  19. #define DISPLAY_CLEAR 0x01
  20. #define DISPLAY_ONLY_EOL 0x02
  21. #define DISPLAY_UPDATE 0x04
  22. #define DISPLAY_MONOSPACE 0x08
  23. // these ones are for 'x' parameter of line() function
  24. #define DISPLAY_LEFT 0
  25. #define DISPLAY_RIGHT 0xff00
  26. #define DISPLAY_CENTER 0xff01
  27. enum display_pos_e { DISPLAY_TOP_LEFT, DISPLAY_MIDDLE_LEFT, DISPLAY_BOTTOM_LEFT, DISPLAY_CENTERED };
  28. enum display_font_e { DISPLAY_FONT_DEFAULT,
  29. DISPLAY_FONT_LINE1, DISPLAY_FONT_LINE2, DISPLAY_FONT_SEGMENT,
  30. DISPLAY_FONT_TINY, DISPLAY_FONT_SMALL, DISPLAY_FONT_MEDIUM, DISPLAY_FONT_LARGE, DISPLAY_FONT_HUGE };
  31. enum displayer_cmd_e { DISPLAYER_SHUTDOWN, DISPLAYER_ACTIVATE, DISPLAYER_DISABLE, DISPLAYER_TIMER_PAUSE, DISPLAYER_TIMER_RESUME };
  32. enum displayer_time_e { DISPLAYER_ELAPSED, DISPLAYER_REMAINING };
  33. // don't change anything there w/o changing all drivers init code
  34. extern struct display_s {
  35. int width, height;
  36. bool (*init)(char *config, char *welcome);
  37. void (*clear)(void);
  38. bool (*set_font)(int num, enum display_font_e font, int space);
  39. void (*on)(bool state);
  40. void (*brightness)(uint8_t level);
  41. void (*text)(enum display_font_e font, enum display_pos_e pos, int attribute, char *msg, ...);
  42. bool (*line)(int num, int x, int attribute, char *text);
  43. int (*stretch)(int num, char *string, int max);
  44. void (*update)(void);
  45. void (*draw)(int x1, int y1, int x2, int y2, bool by_column, uint8_t *data);
  46. void (*draw_cbr)(uint8_t *data, int height); // height is the # of columns in data, as oppoosed to display height (0 = display height)
  47. } *display;
  48. void displayer_scroll(char *string, int speed);
  49. void displayer_control(enum displayer_cmd_e cmd, ...);
  50. void displayer_metadata(char *artist, char *album, char *title);
  51. void displayer_timer(enum displayer_time_e mode, uint32_t elapsed, uint32_t duration);