display.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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_UPDATE 0x02
  21. #define SCROLL 0x04 // scroll value is in ... >0 is right, < 0 is left
  22. enum display_pos_e { DISPLAY_LEFT, DISPLAY_RIGHT, DISPLAY_TOP_LEFT, DISPLAY_MIDDLE_LEFT, DISPLAY_BOTTOM_LEFT, DISPLAY_CENTER };
  23. enum display_font_e { DISPLAY_FONT_DEFAULT, DISPLAY_FONT_SEGMENT, DISPLAY_FONT_TINY,
  24. DISPLAY_FONT_SMALL, DISPLAY_FONT_MEDIUM, DISPLAY_FONT_LARGE, DISPLAY_FONT_HUGE };
  25. enum displayer_cmd_e { DISPLAYER_SHUTDOWN, DISPLAYER_ACTIVATE, DISPLAYER_SUSPEND } ;
  26. // don't change anything there w/o changing all drivers init code
  27. extern struct display_s {
  28. int width, height;
  29. bool (*init)(char *config, char *welcome);
  30. void (*clear)(void);
  31. bool (*set_font)(int num, enum display_font_e font, int space);
  32. void (*on)(bool state);
  33. void (*brightness)(u8_t level);
  34. void (*text)(enum display_font_e font, enum display_pos_e pos, int attribute, char *msg, ...);
  35. bool (*line)(int num, enum display_pos_e pos, int offset, int attribute, char *text);
  36. int (*stretch)(int num, char *string, int max);
  37. void (*update)(void);
  38. void (*draw)(int x1, int y1, int x2, int y2, bool by_column, u8_t *data);
  39. void (*draw_cbr)(u8_t *data, int height); // height is the # of columns in data, as oppoosed to display height (0 = display height)
  40. } *display;
  41. void displayer_scroll(char *string, int speed);
  42. void displayer_control(enum displayer_cmd_e cmd);
  43. void displayer_metadata(char *artist, char *album, char *title);