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.

dogm_lcd_implementation.h 20KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445
  1. /**
  2. * dogm_lcd_implementation.h
  3. *
  4. * Graphics LCD implementation for 128x64 pixel LCDs by STB for ErikZalm/Marlin
  5. * Demonstrator: http://www.reprap.org/wiki/STB_Electronics
  6. * License: http://opensource.org/licenses/BSD-3-Clause
  7. *
  8. * With the use of:
  9. * u8glib by Oliver Kraus
  10. * http://code.google.com/p/u8glib/
  11. * License: http://opensource.org/licenses/BSD-3-Clause
  12. */
  13. #ifndef DOGM_LCD_IMPLEMENTATION_H
  14. #define DOGM_LCD_IMPLEMENTATION_H
  15. #define MARLIN_VERSION "1.0.2"
  16. /**
  17. * Implementation of the LCD display routines for a DOGM128 graphic display. These are common LCD 128x64 pixel graphic displays.
  18. **/
  19. #ifdef ULTIPANEL
  20. #define BLEN_A 0
  21. #define BLEN_B 1
  22. #define BLEN_C 2
  23. #define EN_A (1<<BLEN_A)
  24. #define EN_B (1<<BLEN_B)
  25. #define EN_C (1<<BLEN_C)
  26. #define LCD_CLICKED (buttons&EN_C)
  27. #endif
  28. #include <U8glib.h>
  29. #include "DOGMbitmaps.h"
  30. #include "dogm_font_data_marlin.h"
  31. #include "ultralcd.h"
  32. #include "ultralcd_st7920_u8glib_rrd.h"
  33. /* Russian language not supported yet, needs custom font
  34. #ifdef LANGUAGE_RU
  35. #include "LiquidCrystalRus.h"
  36. #define LCD_CLASS LiquidCrystalRus
  37. #else
  38. #include <LiquidCrystal.h>
  39. #define LCD_CLASS LiquidCrystal
  40. #endif
  41. */
  42. #define USE_BIG_EDIT_FONT // save 3120 bytes of PROGMEM by commenting out this line
  43. #define FONT_STATUSMENU u8g_font_6x9
  44. #define FONT_MENU u8g_font_6x10_marlin
  45. // DOGM parameters (size in pixels)
  46. #define DOG_CHAR_WIDTH 6
  47. #define DOG_CHAR_HEIGHT 12
  48. #ifdef USE_BIG_EDIT_FONT
  49. #define FONT_MENU_EDIT u8g_font_9x18
  50. #define DOG_CHAR_WIDTH_EDIT 9
  51. #define DOG_CHAR_HEIGHT_EDIT 18
  52. #define LCD_WIDTH_EDIT 14
  53. #else
  54. #define FONT_MENU_EDIT u8g_font_6x10_marlin
  55. #define DOG_CHAR_WIDTH_EDIT 6
  56. #define DOG_CHAR_HEIGHT_EDIT 12
  57. #define LCD_WIDTH_EDIT 22
  58. #endif
  59. #define START_ROW 0
  60. /* Custom characters defined in font font_6x10_marlin.c */
  61. #define LCD_STR_DEGREE "\xB0"
  62. #define LCD_STR_REFRESH "\xF8"
  63. #define LCD_STR_FOLDER "\xF9"
  64. #define LCD_STR_ARROW_RIGHT "\xFA"
  65. #define LCD_STR_UPLEVEL "\xFB"
  66. #define LCD_STR_CLOCK "\xFC"
  67. #define LCD_STR_FEEDRATE "\xFD"
  68. #define LCD_STR_BEDTEMP "\xFE"
  69. #define LCD_STR_THERMOMETER "\xFF"
  70. int lcd_contrast;
  71. // LCD selection
  72. #ifdef U8GLIB_ST7920
  73. //U8GLIB_ST7920_128X64_RRD u8g(0,0,0);
  74. U8GLIB_ST7920_128X64_RRD u8g(0);
  75. #elif defined(MAKRPANEL)
  76. // The MaKrPanel display, ST7565 controller as well
  77. U8GLIB_NHD_C12864 u8g(DOGLCD_CS, DOGLCD_A0);
  78. #elif defined(VIKI2) || defined(miniVIKI)
  79. // Mini Viki and Viki 2.0 LCD, ST7565 controller as well
  80. U8GLIB_NHD_C12864 u8g(DOGLCD_CS, DOGLCD_A0);
  81. #else
  82. // for regular DOGM128 display with HW-SPI
  83. U8GLIB_DOGM128 u8g(DOGLCD_CS, DOGLCD_A0); // HW-SPI Com: CS, A0
  84. #endif
  85. static void lcd_implementation_init()
  86. {
  87. #ifdef LCD_PIN_BL // Enable LCD backlight
  88. pinMode(LCD_PIN_BL, OUTPUT);
  89. digitalWrite(LCD_PIN_BL, HIGH);
  90. #endif
  91. u8g.setContrast(lcd_contrast);
  92. // FIXME: remove this workaround
  93. // Uncomment this if you have the first generation (V1.10) of STBs board
  94. // pinMode(17, OUTPUT); // Enable LCD backlight
  95. // digitalWrite(17, HIGH);
  96. #ifdef LCD_SCREEN_ROT_90
  97. u8g.setRot90(); // Rotate screen by 90°
  98. #elif defined(LCD_SCREEN_ROT_180)
  99. u8g.setRot180(); // Rotate screen by 180°
  100. #elif defined(LCD_SCREEN_ROT_270)
  101. u8g.setRot270(); // Rotate screen by 270°
  102. #endif
  103. // Show splashscreen
  104. int offx = (u8g.getWidth() - START_BMPWIDTH) / 2;
  105. #ifdef START_BMPHIGH
  106. int offy = 0;
  107. #else
  108. int offy = DOG_CHAR_HEIGHT;
  109. #endif
  110. int txt1X = (u8g.getWidth() - (sizeof(STRING_SPLASH_LINE1) - 1)*DOG_CHAR_WIDTH) / 2;
  111. u8g.firstPage();
  112. do {
  113. u8g.drawBitmapP(offx, offy, START_BMPBYTEWIDTH, START_BMPHEIGHT, start_bmp);
  114. u8g.setFont(FONT_MENU);
  115. #ifndef STRING_SPLASH_LINE2
  116. u8g.drawStr(txt1X, u8g.getHeight() - DOG_CHAR_HEIGHT, STRING_SPLASH_LINE1);
  117. #else
  118. int txt2X = (u8g.getWidth() - (sizeof(STRING_SPLASH_LINE2) - 1)*DOG_CHAR_WIDTH) / 2;
  119. u8g.drawStr(txt1X, u8g.getHeight() - DOG_CHAR_HEIGHT*3/2, STRING_SPLASH_LINE1);
  120. u8g.drawStr(txt2X, u8g.getHeight() - DOG_CHAR_HEIGHT*1/2, STRING_SPLASH_LINE2);
  121. #endif
  122. } while(u8g.nextPage());
  123. }
  124. static void lcd_implementation_clear() { } // Automatically cleared by Picture Loop
  125. /* Arduino < 1.0.0 is missing a function to print PROGMEM strings, so we need to implement our own */
  126. static void lcd_printPGM(const char* str) {
  127. char c;
  128. while ((c = pgm_read_byte(str++))) u8g.print(c);
  129. }
  130. static void _draw_heater_status(int x, int heater) {
  131. bool isBed = heater < 0;
  132. int y = 17 + (isBed ? 1 : 0);
  133. u8g.setFont(FONT_STATUSMENU);
  134. u8g.setPrintPos(x,6);
  135. u8g.print(itostr3(int((heater >= 0 ? degTargetHotend(heater) : degTargetBed()) + 0.5)));
  136. lcd_printPGM(PSTR(LCD_STR_DEGREE " "));
  137. u8g.setPrintPos(x,27);
  138. u8g.print(itostr3(int(heater >= 0 ? degHotend(heater) : degBed()) + 0.5));
  139. lcd_printPGM(PSTR(LCD_STR_DEGREE " "));
  140. if (!isHeatingHotend(0)) {
  141. u8g.drawBox(x+7,y,2,2);
  142. }
  143. else {
  144. u8g.setColorIndex(0); // white on black
  145. u8g.drawBox(x+7,y,2,2);
  146. u8g.setColorIndex(1); // black on white
  147. }
  148. }
  149. static void lcd_implementation_status_screen() {
  150. static unsigned char fan_rot = 0;
  151. u8g.setColorIndex(1); // black on white
  152. // Symbols menu graphics, animated fan
  153. u8g.drawBitmapP(9,1,STATUS_SCREENBYTEWIDTH,STATUS_SCREENHEIGHT, (blink % 2) && fanSpeed ? status_screen0_bmp : status_screen1_bmp);
  154. #ifdef SDSUPPORT
  155. // SD Card Symbol
  156. u8g.drawBox(42,42,8,7);
  157. u8g.drawBox(50,44,2,5);
  158. u8g.drawFrame(42,49,10,4);
  159. u8g.drawPixel(50,43);
  160. // Progress bar frame
  161. u8g.drawFrame(54,49,73,4);
  162. // SD Card Progress bar and clock
  163. u8g.setFont(FONT_STATUSMENU);
  164. if (IS_SD_PRINTING) {
  165. // Progress bar solid part
  166. u8g.drawBox(55, 50, (unsigned int)(71.f * card.percentDone() / 100.f), 2);
  167. }
  168. u8g.setPrintPos(80,47);
  169. if (starttime != 0) {
  170. uint16_t time = (millis() - starttime) / 60000;
  171. u8g.print(itostr2(time/60));
  172. u8g.print(':');
  173. u8g.print(itostr2(time%60));
  174. }
  175. else {
  176. lcd_printPGM(PSTR("--:--"));
  177. }
  178. #endif
  179. // Extruders
  180. for (int i=0; i<EXTRUDERS; i++) _draw_heater_status(6 + i * 25, i);
  181. // Heatbed
  182. if (EXTRUDERS < 4) _draw_heater_status(81, -1);
  183. // Fan
  184. u8g.setFont(FONT_STATUSMENU);
  185. u8g.setPrintPos(104,27);
  186. #if defined(FAN_PIN) && FAN_PIN > -1
  187. int per = ((fanSpeed + 1) * 100) / 256;
  188. if (per) {
  189. u8g.print(itostr3(per));
  190. u8g.print("%");
  191. }
  192. else
  193. #endif
  194. {
  195. u8g.print("---");
  196. }
  197. // X, Y, Z-Coordinates
  198. u8g.setFont(FONT_STATUSMENU);
  199. u8g.drawBox(0,29,128,10);
  200. u8g.setColorIndex(0); // white on black
  201. u8g.setPrintPos(2,37);
  202. u8g.print("X");
  203. u8g.drawPixel(8,33);
  204. u8g.drawPixel(8,35);
  205. u8g.setPrintPos(10,37);
  206. u8g.print(ftostr31ns(current_position[X_AXIS]));
  207. u8g.setPrintPos(43,37);
  208. lcd_printPGM(PSTR("Y"));
  209. u8g.drawPixel(49,33);
  210. u8g.drawPixel(49,35);
  211. u8g.setPrintPos(51,37);
  212. u8g.print(ftostr31ns(current_position[Y_AXIS]));
  213. u8g.setPrintPos(83,37);
  214. u8g.print("Z");
  215. u8g.drawPixel(89,33);
  216. u8g.drawPixel(89,35);
  217. u8g.setPrintPos(91,37);
  218. u8g.print(ftostr31(current_position[Z_AXIS]));
  219. u8g.setColorIndex(1); // black on white
  220. // Feedrate
  221. u8g.setFont(FONT_MENU);
  222. u8g.setPrintPos(3,49);
  223. u8g.print(LCD_STR_FEEDRATE[0]);
  224. u8g.setFont(FONT_STATUSMENU);
  225. u8g.setPrintPos(12,48);
  226. u8g.print(itostr3(feedmultiply));
  227. u8g.print('%');
  228. // Status line
  229. u8g.setFont(FONT_STATUSMENU);
  230. u8g.setPrintPos(0,61);
  231. #ifndef FILAMENT_LCD_DISPLAY
  232. u8g.print(lcd_status_message);
  233. #else
  234. if (millis() < message_millis + 5000) { //Display both Status message line and Filament display on the last line
  235. u8g.print(lcd_status_message);
  236. }
  237. else {
  238. lcd_printPGM(PSTR("dia:"));
  239. u8g.print(ftostr12ns(filament_width_meas));
  240. lcd_printPGM(PSTR(" factor:"));
  241. u8g.print(itostr3(extrudemultiply));
  242. u8g.print('%');
  243. }
  244. #endif
  245. }
  246. static void lcd_implementation_mark_as_selected(uint8_t row, char pr_char) {
  247. if ((pr_char == '>') || (pr_char == LCD_STR_UPLEVEL[0] )) {
  248. u8g.setColorIndex(1); // black on white
  249. u8g.drawBox (0, row*DOG_CHAR_HEIGHT + 3, 128, DOG_CHAR_HEIGHT);
  250. u8g.setColorIndex(0); // following text must be white on black
  251. }
  252. else {
  253. u8g.setColorIndex(1); // unmarked text is black on white
  254. }
  255. u8g.setPrintPos(START_ROW * DOG_CHAR_WIDTH, (row + 1) * DOG_CHAR_HEIGHT);
  256. }
  257. static void lcd_implementation_drawmenu_generic(uint8_t row, const char* pstr, char pre_char, char post_char) {
  258. char c;
  259. uint8_t n = LCD_WIDTH - 2;
  260. lcd_implementation_mark_as_selected(row, pre_char);
  261. while((c = pgm_read_byte(pstr))) {
  262. u8g.print(c);
  263. pstr++;
  264. n--;
  265. }
  266. while(n--) u8g.print(' ');
  267. u8g.print(post_char);
  268. u8g.print(' ');
  269. }
  270. static void _drawmenu_setting_edit_generic(uint8_t row, const char* pstr, char pre_char, const char* data, bool pgm) {
  271. char c;
  272. uint8_t n = LCD_WIDTH - 2 - (pgm ? lcd_strlen_P(data) : (lcd_strlen((char*)data)));
  273. lcd_implementation_mark_as_selected(row, pre_char);
  274. while( (c = pgm_read_byte(pstr))) {
  275. u8g.print(c);
  276. pstr++;
  277. n--;
  278. }
  279. u8g.print(':');
  280. while(n--) u8g.print(' ');
  281. if (pgm) { lcd_printPGM(data); } else { u8g.print(data); }
  282. }
  283. #define lcd_implementation_drawmenu_setting_edit_generic(row, pstr, pre_char, data) _drawmenu_setting_edit_generic(row, pstr, pre_char, data, false)
  284. #define lcd_implementation_drawmenu_setting_edit_generic_P(row, pstr, pre_char, data) _drawmenu_setting_edit_generic(row, pstr, pre_char, data, true)
  285. #define lcd_implementation_drawmenu_setting_edit_int3_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', itostr3(*(data)))
  286. #define lcd_implementation_drawmenu_setting_edit_int3(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', itostr3(*(data)))
  287. #define lcd_implementation_drawmenu_setting_edit_float3_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr3(*(data)))
  288. #define lcd_implementation_drawmenu_setting_edit_float3(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr3(*(data)))
  289. #define lcd_implementation_drawmenu_setting_edit_float32_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr32(*(data)))
  290. #define lcd_implementation_drawmenu_setting_edit_float32(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr32(*(data)))
  291. #define lcd_implementation_drawmenu_setting_edit_float43_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr43(*(data)))
  292. #define lcd_implementation_drawmenu_setting_edit_float43(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr43(*(data)))
  293. #define lcd_implementation_drawmenu_setting_edit_float5_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr5(*(data)))
  294. #define lcd_implementation_drawmenu_setting_edit_float5(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr5(*(data)))
  295. #define lcd_implementation_drawmenu_setting_edit_float52_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr52(*(data)))
  296. #define lcd_implementation_drawmenu_setting_edit_float52(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr52(*(data)))
  297. #define lcd_implementation_drawmenu_setting_edit_float51_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr51(*(data)))
  298. #define lcd_implementation_drawmenu_setting_edit_float51(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr51(*(data)))
  299. #define lcd_implementation_drawmenu_setting_edit_long5_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr5(*(data)))
  300. #define lcd_implementation_drawmenu_setting_edit_long5(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr5(*(data)))
  301. #define lcd_implementation_drawmenu_setting_edit_bool_selected(row, pstr, pstr2, data) lcd_implementation_drawmenu_setting_edit_generic_P(row, pstr, '>', (*(data))?PSTR(MSG_ON):PSTR(MSG_OFF))
  302. #define lcd_implementation_drawmenu_setting_edit_bool(row, pstr, pstr2, data) lcd_implementation_drawmenu_setting_edit_generic_P(row, pstr, ' ', (*(data))?PSTR(MSG_ON):PSTR(MSG_OFF))
  303. //Add version for callback functions
  304. #define lcd_implementation_drawmenu_setting_edit_callback_int3_selected(row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', itostr3(*(data)))
  305. #define lcd_implementation_drawmenu_setting_edit_callback_int3(row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', itostr3(*(data)))
  306. #define lcd_implementation_drawmenu_setting_edit_callback_float3_selected(row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr3(*(data)))
  307. #define lcd_implementation_drawmenu_setting_edit_callback_float3(row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr3(*(data)))
  308. #define lcd_implementation_drawmenu_setting_edit_callback_float32_selected(row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr32(*(data)))
  309. #define lcd_implementation_drawmenu_setting_edit_callback_float32(row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr32(*(data)))
  310. #define lcd_implementation_drawmenu_setting_edit_callback_float43_selected(row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr43(*(data)))
  311. #define lcd_implementation_drawmenu_setting_edit_callback_float43(row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr43(*(data)))
  312. #define lcd_implementation_drawmenu_setting_edit_callback_float5_selected(row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr5(*(data)))
  313. #define lcd_implementation_drawmenu_setting_edit_callback_float5(row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr5(*(data)))
  314. #define lcd_implementation_drawmenu_setting_edit_callback_float52_selected(row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr52(*(data)))
  315. #define lcd_implementation_drawmenu_setting_edit_callback_float52(row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr52(*(data)))
  316. #define lcd_implementation_drawmenu_setting_edit_callback_float51_selected(row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr51(*(data)))
  317. #define lcd_implementation_drawmenu_setting_edit_callback_float51(row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr51(*(data)))
  318. #define lcd_implementation_drawmenu_setting_edit_callback_long5_selected(row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr5(*(data)))
  319. #define lcd_implementation_drawmenu_setting_edit_callback_long5(row, pstr, pstr2, data, minValue, maxValue, callback) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr5(*(data)))
  320. #define lcd_implementation_drawmenu_setting_edit_callback_bool_selected(row, pstr, pstr2, data, callback) lcd_implementation_drawmenu_setting_edit_generic_P(row, pstr, '>', (*(data))?PSTR(MSG_ON):PSTR(MSG_OFF))
  321. #define lcd_implementation_drawmenu_setting_edit_callback_bool(row, pstr, pstr2, data, callback) lcd_implementation_drawmenu_setting_edit_generic_P(row, pstr, ' ', (*(data))?PSTR(MSG_ON):PSTR(MSG_OFF))
  322. void lcd_implementation_drawedit(const char* pstr, char* value) {
  323. uint8_t rows = 1;
  324. uint8_t lcd_width = LCD_WIDTH;
  325. uint8_t char_width = DOG_CHAR_WIDTH;
  326. #ifdef USE_BIG_EDIT_FONT
  327. if (lcd_strlen_P(pstr) <= LCD_WIDTH_EDIT - 1) {
  328. u8g.setFont(FONT_MENU_EDIT);
  329. lcd_width = LCD_WIDTH_EDIT + 1;
  330. char_width = DOG_CHAR_WIDTH_EDIT;
  331. if (lcd_strlen_P(pstr) >= LCD_WIDTH_EDIT - lcd_strlen(value)) rows = 2;
  332. }
  333. else {
  334. u8g.setFont(FONT_MENU);
  335. }
  336. #endif
  337. if (lcd_strlen_P(pstr) > LCD_WIDTH - 2 - lcd_strlen(value)) rows = 2;
  338. const float kHalfChar = DOG_CHAR_HEIGHT_EDIT / 2;
  339. float rowHeight = u8g.getHeight() / (rows + 1); // 1/(rows+1) = 1/2 or 1/3
  340. u8g.setPrintPos(0, rowHeight + kHalfChar);
  341. lcd_printPGM(pstr);
  342. u8g.print(':');
  343. u8g.setPrintPos((lcd_width-1-lcd_strlen(value)) * char_width, rows * rowHeight + kHalfChar);
  344. u8g.print(value);
  345. }
  346. static void _drawmenu_sd(uint8_t row, const char* pstr, const char* filename, char * const longFilename, bool isDir, bool isSelected) {
  347. char c;
  348. uint8_t n = LCD_WIDTH - 1;
  349. if (longFilename[0] != '\0') {
  350. filename = longFilename;
  351. longFilename[n] = '\0';
  352. }
  353. lcd_implementation_mark_as_selected(row, ((isSelected) ? '>' : ' '));
  354. if (isDir) u8g.print(LCD_STR_FOLDER[0]);
  355. while((c = *filename) != '\0') {
  356. u8g.print(c);
  357. filename++;
  358. n--;
  359. }
  360. while(n--) u8g.print(' ');
  361. }
  362. #define lcd_implementation_drawmenu_sdfile_selected(row, pstr, filename, longFilename) _drawmenu_sd(row, pstr, filename, longFilename, false, true)
  363. #define lcd_implementation_drawmenu_sdfile(row, pstr, filename, longFilename) _drawmenu_sd(row, pstr, filename, longFilename, false, false)
  364. #define lcd_implementation_drawmenu_sddirectory_selected(row, pstr, filename, longFilename) _drawmenu_sd(row, pstr, filename, longFilename, true, true)
  365. #define lcd_implementation_drawmenu_sddirectory(row, pstr, filename, longFilename) _drawmenu_sd(row, pstr, filename, longFilename, true, false)
  366. #define lcd_implementation_drawmenu_back_selected(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, LCD_STR_UPLEVEL[0], LCD_STR_UPLEVEL[0])
  367. #define lcd_implementation_drawmenu_back(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, ' ', LCD_STR_UPLEVEL[0])
  368. #define lcd_implementation_drawmenu_submenu_selected(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, '>', LCD_STR_ARROW_RIGHT[0])
  369. #define lcd_implementation_drawmenu_submenu(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, ' ', LCD_STR_ARROW_RIGHT[0])
  370. #define lcd_implementation_drawmenu_gcode_selected(row, pstr, gcode) lcd_implementation_drawmenu_generic(row, pstr, '>', ' ')
  371. #define lcd_implementation_drawmenu_gcode(row, pstr, gcode) lcd_implementation_drawmenu_generic(row, pstr, ' ', ' ')
  372. #define lcd_implementation_drawmenu_function_selected(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, '>', ' ')
  373. #define lcd_implementation_drawmenu_function(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, ' ', ' ')
  374. static void lcd_implementation_quick_feedback() {
  375. #if BEEPER > -1
  376. SET_OUTPUT(BEEPER);
  377. for(int8_t i=0; i<10; i++) {
  378. WRITE(BEEPER,HIGH);
  379. delay(3);
  380. WRITE(BEEPER,LOW);
  381. delay(3);
  382. }
  383. #endif
  384. }
  385. #endif //__DOGM_LCD_IMPLEMENTATION_H