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 19KB

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