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

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