My Marlin configs for Fabrikator Mini and CTC i3 Pro B
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.

status_screen_lite_ST7920.h 4.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /**
  2. * Lightweight Status Screen for the RepRapDiscount Full
  3. * Graphics Smart Controller (ST7920-based 128x64 LCD)
  4. *
  5. * (c) 2017 Aleph Objects, Inc.
  6. *
  7. * The code in this page is free software: you can
  8. * redistribute it and/or modify it under the terms of the GNU
  9. * General Public License (GNU GPL) as published by the Free Software
  10. * Foundation, either version 3 of the License, or (at your option)
  11. * any later version. The code is distributed WITHOUT ANY WARRANTY;
  12. * without even the implied warranty of MERCHANTABILITY or FITNESS
  13. * FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
  14. */
  15. #pragma once
  16. #include "../../HAL/shared/HAL_ST7920.h"
  17. #include "../../core/types.h"
  18. #include "../../core/macros.h"
  19. #include "../../libs/duration_t.h"
  20. class ST7920_Lite_Status_Screen {
  21. private:
  22. static struct st7920_state_t {
  23. uint8_t synced : 1; // Whether a sync has been sent
  24. uint8_t cmd : 1; // Whether the sync was cmd or data
  25. uint8_t extended : 1;
  26. uint8_t graphics : 1;
  27. uint8_t sa : 1;
  28. } current_bits;
  29. static void cs() { ST7920_cs(); current_bits.synced = false; }
  30. static void ncs() { ST7920_cs(); current_bits.synced = false; }
  31. static void sync_cmd() { ST7920_set_cmd(); }
  32. static void sync_dat() { ST7920_set_dat(); }
  33. static void write_byte(const uint8_t w) { ST7920_write_byte(w); }
  34. FORCE_INLINE static void write_word(const uint16_t w) {
  35. write_byte((w >> 8) & 0xFF);
  36. write_byte((w >> 0) & 0xFF);
  37. }
  38. static void cmd(const uint8_t cmd);
  39. static void begin_data();
  40. static void write_str(const char *str);
  41. static void write_str(const char *str, const uint8_t len);
  42. static void write_str(FSTR_P const fstr);
  43. static void write_number(const int16_t value, const uint8_t digits=3);
  44. static void _extended_function_set(const bool extended, const bool graphics);
  45. static void _scroll_or_addr_select(const bool sa);
  46. static void reset_state_from_unknown();
  47. static void home();
  48. static void display_status(const bool display_on, const bool cursor_on, const bool blink_on);
  49. static void extended_function_set(const bool extended);
  50. static void graphics(const bool graphics);
  51. static void entry_mode_select(const bool ac_increase, const bool shift);
  52. static void scroll_or_addr_select(const bool sa);
  53. static void set_ddram_address(const uint8_t addr);
  54. static void set_cgram_address(const uint8_t addr);
  55. static void set_gdram_address(const uint8_t x, const uint8_t y);
  56. static void clear();
  57. static void clear_ddram();
  58. static void clear_gdram();
  59. static void load_cgram_icon(const uint16_t addr, const void *data);
  60. static void draw_gdram_icon(uint8_t x, uint8_t y, const void *data);
  61. static uint8_t string_checksum(const char *str);
  62. protected:
  63. static void draw_degree_symbol(uint8_t x, uint8_t y, const bool draw);
  64. static void draw_static_elements();
  65. static void draw_fan_icon(const bool whichIcon);
  66. static void draw_heat_icon(const bool whichIcon, const bool heating);
  67. static void draw_temps(uint8_t line, const int16_t temp, const int16_t target, bool showTarget, bool targetStateChange);
  68. static void draw_extruder_1_temp(const int16_t temp, const int16_t target, bool forceUpdate=false);
  69. static void draw_extruder_2_temp(const int16_t temp, const int16_t target, bool forceUpdate=false);
  70. static void draw_bed_temp(const int16_t temp, const int16_t target, bool forceUpdate=false);
  71. static void draw_fan_speed(const uint8_t value);
  72. #if HAS_PRINT_PROGRESS
  73. static void draw_progress_bar(const uint8_t value);
  74. static char* prepare_time_string(const duration_t &time, char prefix=' ');
  75. static void draw_progress_string(uint8_t addr, const char *str);
  76. static void update_progress(const bool forceUpdate);
  77. #endif
  78. static void draw_feedrate_percentage(const uint16_t percentage);
  79. static void draw_status_message();
  80. static void draw_position(const xyze_pos_t &pos, bool position_known=true);
  81. static bool indicators_changed();
  82. static bool position_changed();
  83. static bool blink_changed();
  84. static bool status_changed();
  85. static void update_indicators(const bool forceUpdate);
  86. static void update_position(const bool forceUpdate, bool resetChecksum);
  87. static void update_status_or_position(bool forceUpdate);
  88. public:
  89. static void update(const bool forceUpdate);
  90. static void on_entry();
  91. static void on_exit();
  92. static void clear_text_buffer();
  93. #if HAS_PRINT_PROGRESS
  94. static void drawPercent();
  95. static void drawRemain();
  96. static void drawInter();
  97. static void drawElapsed();
  98. #endif
  99. };
  100. extern ST7920_Lite_Status_Screen lightUI;