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. #include "gds.h"
  20. /*
  21. The displayer is not thread-safe and the caller must ensure use its own
  22. mutexes if it wants something better. Especially, text() line() and draw()
  23. are not protected against each other.
  24. In text mode (text/line) when using DISPLAY_SUSPEND, the displayer will
  25. refreshed line 2 one last time before suspending itself. As a result if it
  26. is in a long sleep (scrolling pause), the refresh will happen after wakeup.
  27. So it can conflict with other display direct writes that have been made during
  28. sleep. Note that if DISPLAY_SHUTDOWN has been called meanwhile, it (almost)
  29. never happens
  30. The display_bus() shall be subscribed by other displayers so that at least
  31. when this one (the main) wants to take control over display, it can signal
  32. that to others
  33. */
  34. extern struct GDS_Device *display;
  35. enum displayer_cmd_e { DISPLAYER_SHUTDOWN, DISPLAYER_ACTIVATE, DISPLAYER_SUSPEND, DISPLAYER_TIMER_PAUSE, DISPLAYER_TIMER_RUN };
  36. enum displayer_time_e { DISPLAYER_ELAPSED, DISPLAYER_REMAINING };
  37. enum display_bus_cmd_e { DISPLAY_BUS_TAKE, DISPLAY_BUS_GIVE };
  38. bool (*display_bus)(void *from, enum display_bus_cmd_e cmd);
  39. void displayer_scroll(char *string, int speed);
  40. void displayer_control(enum displayer_cmd_e cmd, ...);
  41. void displayer_metadata(char *artist, char *album, char *title);
  42. void displayer_timer(enum displayer_time_e mode, int elapsed, int duration);