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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596
  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. // CHANGE_DE begin ***
  32. #include <U8glib.h> // DE_U8glib
  33. #include "DOGMbitmaps.h"
  34. #include "dogm_font_data_marlin.h"
  35. #include "ultralcd.h"
  36. /* Russian language not supported yet, needs custom font
  37. #if LANGUAGE_CHOICE == 6
  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_BEDTEMP "\xFE"
  53. #define LCD_STR_DEGREE "\xB0"
  54. #define LCD_STR_THERMOMETER "\xFF"
  55. #define LCD_STR_UPLEVEL "\xFB"
  56. #define LCD_STR_REFRESH "\xF8"
  57. #define LCD_STR_FOLDER "\xF9"
  58. #define LCD_STR_FEEDRATE "\xFD"
  59. #define LCD_STR_CLOCK "\xFC"
  60. #define LCD_STR_ARROW_RIGHT "\xFA"
  61. #define FONT_STATUSMENU u8g_font_6x9
  62. // LCD selection
  63. #ifdef U8GLIB_ST7920
  64. // SPI Com: SCK = en = (D4), MOSI = rw = (RS), CS = di = (ENABLE)
  65. U8GLIB_ST7920_128X64_1X u8g(LCD_PINS_D4, LCD_PINS_ENABLE, LCD_PINS_RS);
  66. #else
  67. U8GLIB_DOGM128 u8g(DOGLCD_CS, DOGLCD_A0); // HW-SPI Com: CS, A0
  68. #endif
  69. static void lcd_implementation_init()
  70. {
  71. // Uncomment this if you have the first generation (V1.10) of STBs board
  72. // pinMode(17, OUTPUT); // Enable LCD backlight
  73. // digitalWrite(17, HIGH);
  74. u8g.firstPage();
  75. do {
  76. u8g.setFont(u8g_font_6x10_marlin);
  77. u8g.setColorIndex(1);
  78. u8g.drawBox (0, 0, u8g.getWidth(), u8g.getHeight());
  79. u8g.setColorIndex(1);
  80. } while( u8g.nextPage() );
  81. #ifdef LCD_SCREEN_ROT_90
  82. u8g.setRot90(); // Rotate screen by 90°
  83. #endif
  84. #ifdef LCD_SCREEN_ROT_180;
  85. u8g.setRot180(); // Rotate screen by 180°
  86. #endif
  87. #ifdef LCD_SCREEN_ROT_270;
  88. u8g.setRot270(); // Rotate screen by 270°
  89. #endif
  90. u8g.firstPage();
  91. do {
  92. // RepRap init bmp
  93. u8g.drawBitmapP(0,0,START_BMPBYTEWIDTH,START_BMPHEIGHT,start_bmp);
  94. // Welcome message
  95. u8g.setFont(u8g_font_6x10_marlin);
  96. u8g.drawStr(62,10,"MARLIN");
  97. u8g.setFont(u8g_font_5x8);
  98. u8g.drawStr(62,19,"V1.0.0 RC2");
  99. u8g.setFont(u8g_font_6x10_marlin);
  100. u8g.drawStr(62,28,"by ErikZalm");
  101. u8g.drawStr(62,41,"DOGM128 LCD");
  102. u8g.setFont(u8g_font_5x8);
  103. u8g.drawStr(62,48,"enhancements");
  104. u8g.setFont(u8g_font_5x8);
  105. u8g.drawStr(62,55,"by STB");
  106. u8g.drawStr(62,61,"uses u");
  107. u8g.drawStr90(92,57,"8");
  108. u8g.drawStr(100,61,"glib");
  109. } while( u8g.nextPage() );
  110. }
  111. static void lcd_implementation_clear()
  112. {
  113. // NO NEED TO IMPLEMENT LIKE SO. Picture loop automatically clears the display.
  114. //
  115. // Check this article: http://arduino.cc/forum/index.php?topic=91395.25;wap2
  116. //
  117. // u8g.firstPage();
  118. // do {
  119. // u8g.setColorIndex(0);
  120. // u8g.drawBox (0, 0, u8g.getWidth(), u8g.getHeight());
  121. // u8g.setColorIndex(1);
  122. // } while( u8g.nextPage() );
  123. }
  124. /* Arduino < 1.0.0 is missing a function to print PROGMEM strings, so we need to implement our own */
  125. static void lcd_printPGM(const char* str)
  126. {
  127. char c;
  128. while((c = pgm_read_byte(str++)) != '\0')
  129. {
  130. u8g.print(c);
  131. }
  132. }
  133. static void lcd_implementation_status_screen()
  134. {
  135. static unsigned char fan_rot = 0;
  136. u8g.setColorIndex(1); // black on white
  137. // Symbols menu graphics, animated fan
  138. if ((blink % 2) && fanSpeed ) u8g.drawBitmapP(9,1,STATUS_SCREENBYTEWIDTH,STATUS_SCREENHEIGHT,status_screen0_bmp);
  139. else u8g.drawBitmapP(9,1,STATUS_SCREENBYTEWIDTH,STATUS_SCREENHEIGHT,status_screen1_bmp);
  140. #ifdef SDSUPPORT
  141. //SD Card Symbol
  142. u8g.drawBox(42,42,8,7);
  143. u8g.drawBox(50,44,2,5);
  144. u8g.drawFrame(42,49,10,4);
  145. u8g.drawPixel(50,43);
  146. // Progress bar
  147. u8g.drawFrame(54,49,73,4);
  148. // SD Card Progress bar and clock
  149. u8g.setFont(FONT_STATUSMENU);
  150. if (IS_SD_PRINTING)
  151. {
  152. // Progress bar
  153. u8g.drawBox(55,50, (unsigned int)( (71 * card.percentDone())/100) ,2);
  154. }
  155. else {
  156. // do nothing
  157. }
  158. u8g.setPrintPos(80,47);
  159. if(starttime != 0)
  160. {
  161. uint16_t time = millis()/60000 - starttime/60000;
  162. u8g.print(itostr2(time/60));
  163. u8g.print(':');
  164. u8g.print(itostr2(time%60));
  165. }else{
  166. lcd_printPGM(PSTR("--:--"));
  167. }
  168. #endif
  169. // Extruder 1
  170. u8g.setFont(FONT_STATUSMENU);
  171. u8g.setPrintPos(6,6);
  172. u8g.print(itostr3(int(degTargetHotend(0) + 0.5)));
  173. lcd_printPGM(PSTR(LCD_STR_DEGREE " "));
  174. u8g.setPrintPos(6,27);
  175. u8g.print(itostr3(int(degHotend(0) + 0.5)));
  176. lcd_printPGM(PSTR(LCD_STR_DEGREE " "));
  177. if (!isHeatingHotend(0)) u8g.drawBox(13,17,2,2);
  178. else
  179. {
  180. u8g.setColorIndex(0); // white on black
  181. u8g.drawBox(13,17,2,2);
  182. u8g.setColorIndex(1); // black on white
  183. }
  184. // Extruder 2
  185. u8g.setFont(FONT_STATUSMENU);
  186. #if EXTRUDERS > 1
  187. u8g.setPrintPos(31,6);
  188. u8g.print(itostr3(int(degTargetHotend(1) + 0.5)));
  189. lcd_printPGM(PSTR(LCD_STR_DEGREE " "));
  190. u8g.setPrintPos(31,27);
  191. u8g.print(itostr3(int(degHotend(1) + 0.5)));
  192. lcd_printPGM(PSTR(LCD_STR_DEGREE " "));
  193. if (!isHeatingHotend(1)) u8g.drawBox(38,17,2,2);
  194. else
  195. {
  196. u8g.setColorIndex(0); // white on black
  197. u8g.drawBox(38,17,2,2);
  198. u8g.setColorIndex(1); // black on white
  199. }
  200. #else
  201. u8g.setPrintPos(31,27);
  202. u8g.print("---");
  203. #endif
  204. // Extruder 3
  205. u8g.setFont(FONT_STATUSMENU);
  206. # if EXTRUDERS > 2
  207. u8g.setPrintPos(55,6);
  208. u8g.print(itostr3(int(degTargetHotend(2) + 0.5)));
  209. lcd_printPGM(PSTR(LCD_STR_DEGREE " "));
  210. u8g.setPrintPos(55,27);
  211. u8g.print(itostr3(int(degHotend(2) + 0.5)));
  212. lcd_printPGM(PSTR(LCD_STR_DEGREE " "));
  213. if (!isHeatingHotend(2)) u8g.drawBox(62,17,2,2);
  214. else
  215. {
  216. u8g.setColorIndex(0); // white on black
  217. u8g.drawBox(62,17,2,2);
  218. u8g.setColorIndex(1); // black on white
  219. }
  220. #else
  221. u8g.setPrintPos(55,27);
  222. u8g.print("---");
  223. #endif
  224. // Heatbed
  225. u8g.setFont(FONT_STATUSMENU);
  226. u8g.setPrintPos(81,6);
  227. u8g.print(itostr3(int(degTargetBed() + 0.5)));
  228. lcd_printPGM(PSTR(LCD_STR_DEGREE " "));
  229. u8g.setPrintPos(81,27);
  230. u8g.print(itostr3(int(degBed() + 0.5)));
  231. lcd_printPGM(PSTR(LCD_STR_DEGREE " "));
  232. if (!isHeatingBed()) u8g.drawBox(88,18,2,2);
  233. else
  234. {
  235. u8g.setColorIndex(0); // white on black
  236. u8g.drawBox(88,18,2,2);
  237. u8g.setColorIndex(1); // black on white
  238. }
  239. // Fan
  240. u8g.setFont(FONT_STATUSMENU);
  241. u8g.setPrintPos(104,27);
  242. #if defined(FAN_PIN) && FAN_PIN > -1
  243. u8g.print(itostr3(int((fanSpeed*100)/256 + 1)));
  244. u8g.print("%");
  245. #else
  246. u8g.print("---");
  247. #endif
  248. // X, Y, Z-Coordinates
  249. u8g.setFont(FONT_STATUSMENU);
  250. u8g.drawBox(0,29,128,10);
  251. u8g.setColorIndex(0); // white on black
  252. u8g.setPrintPos(2,37);
  253. u8g.print("X");
  254. u8g.drawPixel(8,33);
  255. u8g.drawPixel(8,35);
  256. u8g.setPrintPos(10,37);
  257. u8g.print(ftostr31ns(current_position[X_AXIS]));
  258. u8g.setPrintPos(43,37);
  259. lcd_printPGM(PSTR("Y"));
  260. u8g.drawPixel(49,33);
  261. u8g.drawPixel(49,35);
  262. u8g.setPrintPos(51,37);
  263. u8g.print(ftostr31ns(current_position[Y_AXIS]));
  264. u8g.setPrintPos(83,37);
  265. u8g.print("Z");
  266. u8g.drawPixel(89,33);
  267. u8g.drawPixel(89,35);
  268. u8g.setPrintPos(91,37);
  269. u8g.print(ftostr31(current_position[Z_AXIS]));
  270. u8g.setColorIndex(1); // black on white
  271. // Feedrate
  272. u8g.setFont(u8g_font_6x10_marlin);
  273. u8g.setPrintPos(3,49);
  274. u8g.print(LCD_STR_FEEDRATE[0]);
  275. u8g.setFont(FONT_STATUSMENU);
  276. u8g.setPrintPos(12,48);
  277. u8g.print(itostr3(feedmultiply));
  278. u8g.print('%');
  279. // Status line
  280. u8g.setFont(FONT_STATUSMENU);
  281. u8g.setPrintPos(0,61);
  282. u8g.print(lcd_status_message);
  283. }
  284. static void lcd_implementation_drawmenu_generic(uint8_t row, const char* pstr, char pre_char, char post_char)
  285. {
  286. char c;
  287. uint8_t n = LCD_WIDTH - 1 - 2;
  288. if ((pre_char == '>') || (pre_char == LCD_STR_UPLEVEL[0] ))
  289. {
  290. u8g.setColorIndex(1); // black on white
  291. u8g.drawBox (0, row*DOG_CHAR_HEIGHT + 3, 128, DOG_CHAR_HEIGHT);
  292. u8g.setColorIndex(0); // following text must be white on black
  293. } else u8g.setColorIndex(1); // unmarked text is black on white
  294. u8g.setPrintPos(0 * DOG_CHAR_WIDTH, (row + 1) * DOG_CHAR_HEIGHT);
  295. if (pre_char != '>') u8g.print(pre_char); else u8g.print(' '); // Row selector is obsolete
  296. while( (c = pgm_read_byte(pstr)) != '\0' )
  297. {
  298. u8g.print(c);
  299. pstr++;
  300. n--;
  301. }
  302. while(n--){
  303. u8g.print(' ');
  304. }
  305. u8g.print(post_char);
  306. u8g.print(' ');
  307. u8g.setColorIndex(1); // restore settings to black on white
  308. }
  309. static void lcd_implementation_drawmenu_setting_edit_generic(uint8_t row, const char* pstr, char pre_char, char* data)
  310. {
  311. static unsigned int fkt_cnt = 0;
  312. char c;
  313. uint8_t n = LCD_WIDTH - 1 - 2 - strlen(data);
  314. u8g.setPrintPos(0 * DOG_CHAR_WIDTH, (row + 1) * DOG_CHAR_HEIGHT);
  315. u8g.print(pre_char);
  316. while( (c = pgm_read_byte(pstr)) != '\0' )
  317. {
  318. u8g.print(c);
  319. pstr++;
  320. n--;
  321. }
  322. u8g.print(':');
  323. while(n--){
  324. u8g.print(' ');
  325. }
  326. u8g.print(data);
  327. }
  328. static void lcd_implementation_drawmenu_setting_edit_generic_P(uint8_t row, const char* pstr, char pre_char, const char* data)
  329. {
  330. char c;
  331. uint8_t n= LCD_WIDTH - 1 - 2 - strlen_P(data);
  332. u8g.setPrintPos(0 * DOG_CHAR_WIDTH, (row + 1) * DOG_CHAR_HEIGHT);
  333. u8g.print(pre_char);
  334. while( (c = pgm_read_byte(pstr)) != '\0' )
  335. {
  336. u8g.print(c);
  337. pstr++;
  338. n--;
  339. }
  340. u8g.print(':');
  341. while(n--){
  342. u8g.print(' ');
  343. }
  344. lcd_printPGM(data);
  345. }
  346. #define lcd_implementation_drawmenu_setting_edit_int3_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', itostr3(*(data)))
  347. #define lcd_implementation_drawmenu_setting_edit_int3(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', itostr3(*(data)))
  348. #define lcd_implementation_drawmenu_setting_edit_float3_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr3(*(data)))
  349. #define lcd_implementation_drawmenu_setting_edit_float3(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr3(*(data)))
  350. #define lcd_implementation_drawmenu_setting_edit_float32_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr32(*(data)))
  351. #define lcd_implementation_drawmenu_setting_edit_float32(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr32(*(data)))
  352. #define lcd_implementation_drawmenu_setting_edit_float5_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr5(*(data)))
  353. #define lcd_implementation_drawmenu_setting_edit_float5(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr5(*(data)))
  354. #define lcd_implementation_drawmenu_setting_edit_float52_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr52(*(data)))
  355. #define lcd_implementation_drawmenu_setting_edit_float52(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr52(*(data)))
  356. #define lcd_implementation_drawmenu_setting_edit_float51_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr51(*(data)))
  357. #define lcd_implementation_drawmenu_setting_edit_float51(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr51(*(data)))
  358. #define lcd_implementation_drawmenu_setting_edit_long5_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr5(*(data)))
  359. #define lcd_implementation_drawmenu_setting_edit_long5(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr5(*(data)))
  360. #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))
  361. #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))
  362. //Add version for callback functions
  363. #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)))
  364. #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)))
  365. #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)))
  366. #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)))
  367. #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)))
  368. #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)))
  369. #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)))
  370. #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)))
  371. #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)))
  372. #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)))
  373. #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)))
  374. #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)))
  375. #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)))
  376. #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)))
  377. #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))
  378. #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))
  379. void lcd_implementation_drawedit(const char* pstr, char* value)
  380. {
  381. u8g.setPrintPos(0 * DOG_CHAR_WIDTH_LARGE, (u8g.getHeight() - 1 - DOG_CHAR_HEIGHT_LARGE) - (1 * DOG_CHAR_HEIGHT_LARGE) - START_ROW );
  382. u8g.setFont(u8g_font_9x18);
  383. lcd_printPGM(pstr);
  384. u8g.print(':');
  385. u8g.setPrintPos((14 - strlen(value)) * DOG_CHAR_WIDTH_LARGE, (u8g.getHeight() - 1 - DOG_CHAR_HEIGHT_LARGE) - (1 * DOG_CHAR_HEIGHT_LARGE) - START_ROW );
  386. u8g.print(value);
  387. }
  388. static void lcd_implementation_drawmenu_sdfile_selected(uint8_t row, const char* pstr, const char* filename, char* longFilename)
  389. {
  390. char c;
  391. uint8_t n = LCD_WIDTH - 1;
  392. if (longFilename[0] != '\0')
  393. {
  394. filename = longFilename;
  395. longFilename[LCD_WIDTH-1] = '\0';
  396. }
  397. u8g.setColorIndex(1); // black on white
  398. u8g.drawBox (0, row*DOG_CHAR_HEIGHT + 3, 128, DOG_CHAR_HEIGHT);
  399. u8g.setColorIndex(0); // following text must be white on black
  400. u8g.setPrintPos(0 * DOG_CHAR_WIDTH, (row + 1) * DOG_CHAR_HEIGHT);
  401. u8g.print(' '); // Indent by 1 char
  402. while((c = *filename) != '\0')
  403. {
  404. u8g.print(c);
  405. filename++;
  406. n--;
  407. }
  408. while(n--){
  409. u8g.print(' ');
  410. }
  411. u8g.setColorIndex(1); // black on white
  412. }
  413. static void lcd_implementation_drawmenu_sdfile(uint8_t row, const char* pstr, const char* filename, char* longFilename)
  414. {
  415. char c;
  416. uint8_t n = LCD_WIDTH - 1;
  417. if (longFilename[0] != '\0')
  418. {
  419. filename = longFilename;
  420. longFilename[LCD_WIDTH-1] = '\0';
  421. }
  422. u8g.setPrintPos(0 * DOG_CHAR_WIDTH, (row + 1) * DOG_CHAR_HEIGHT);
  423. u8g.print(' ');
  424. while((c = *filename) != '\0')
  425. {
  426. u8g.print(c);
  427. filename++;
  428. n--;
  429. }
  430. while(n--){
  431. u8g.print(' ');
  432. }
  433. }
  434. static void lcd_implementation_drawmenu_sddirectory_selected(uint8_t row, const char* pstr, const char* filename, char* longFilename)
  435. {
  436. char c;
  437. uint8_t n = LCD_WIDTH - 2;
  438. if (longFilename[0] != '\0')
  439. {
  440. filename = longFilename;
  441. longFilename[LCD_WIDTH-2] = '\0';
  442. }
  443. u8g.setColorIndex(1); // black on white
  444. u8g.drawBox (0, row*DOG_CHAR_HEIGHT + 3, 128, DOG_CHAR_HEIGHT);
  445. u8g.setColorIndex(0); // following text must be white on black
  446. u8g.setPrintPos(0 * DOG_CHAR_WIDTH, (row + 1) * DOG_CHAR_HEIGHT);
  447. u8g.print(' '); // Indent by 1 char
  448. u8g.print(LCD_STR_FOLDER[0]);
  449. while((c = *filename) != '\0')
  450. {
  451. u8g.print(c);
  452. filename++;
  453. n--;
  454. }
  455. while(n--){
  456. u8g.print(' ');
  457. }
  458. u8g.setColorIndex(1); // black on white
  459. }
  460. static void lcd_implementation_drawmenu_sddirectory(uint8_t row, const char* pstr, const char* filename, char* longFilename)
  461. {
  462. char c;
  463. uint8_t n = LCD_WIDTH - 2;
  464. if (longFilename[0] != '\0')
  465. {
  466. filename = longFilename;
  467. longFilename[LCD_WIDTH-2] = '\0';
  468. }
  469. u8g.setPrintPos(0 * DOG_CHAR_WIDTH, (row + 1) * DOG_CHAR_HEIGHT);
  470. u8g.print(' ');
  471. u8g.print(LCD_STR_FOLDER[0]);
  472. while((c = *filename) != '\0')
  473. {
  474. u8g.print(c);
  475. filename++;
  476. n--;
  477. }
  478. while(n--){
  479. u8g.print(' ');
  480. }
  481. }
  482. #define lcd_implementation_drawmenu_back_selected(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, LCD_STR_UPLEVEL[0], LCD_STR_UPLEVEL[0])
  483. #define lcd_implementation_drawmenu_back(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, ' ', LCD_STR_UPLEVEL[0])
  484. #define lcd_implementation_drawmenu_submenu_selected(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, '>', LCD_STR_ARROW_RIGHT[0])
  485. #define lcd_implementation_drawmenu_submenu(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, ' ', LCD_STR_ARROW_RIGHT[0])
  486. #define lcd_implementation_drawmenu_gcode_selected(row, pstr, gcode) lcd_implementation_drawmenu_generic(row, pstr, '>', ' ')
  487. #define lcd_implementation_drawmenu_gcode(row, pstr, gcode) lcd_implementation_drawmenu_generic(row, pstr, ' ', ' ')
  488. #define lcd_implementation_drawmenu_function_selected(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, '>', ' ')
  489. #define lcd_implementation_drawmenu_function(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, ' ', ' ')
  490. static void lcd_implementation_quick_feedback()
  491. {
  492. #if BEEPER > -1
  493. SET_OUTPUT(BEEPER);
  494. for(int8_t i=0;i<10;i++)
  495. {
  496. WRITE(BEEPER,HIGH);
  497. delay(3);
  498. WRITE(BEEPER,LOW);
  499. delay(3);
  500. }
  501. #endif
  502. }
  503. #endif//ULTRA_LCD_IMPLEMENTATION_DOGM_H