dogm_lcd_implementation.h 22 KB

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