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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615
  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. #endif
  211. // Extruder 3
  212. u8g.setFont(FONT_STATUSMENU);
  213. # if EXTRUDERS > 2
  214. u8g.setPrintPos(55,6);
  215. u8g.print(itostr3(int(degTargetHotend(2) + 0.5)));
  216. lcd_printPGM(PSTR(LCD_STR_DEGREE " "));
  217. u8g.setPrintPos(55,27);
  218. u8g.print(itostr3(int(degHotend(2) + 0.5)));
  219. lcd_printPGM(PSTR(LCD_STR_DEGREE " "));
  220. if (!isHeatingHotend(2)) u8g.drawBox(62,17,2,2);
  221. else
  222. {
  223. u8g.setColorIndex(0); // white on black
  224. u8g.drawBox(62,17,2,2);
  225. u8g.setColorIndex(1); // black on white
  226. }
  227. #endif
  228. // Heatbed
  229. u8g.setFont(FONT_STATUSMENU);
  230. u8g.setPrintPos(81,6);
  231. u8g.print(itostr3(int(degTargetBed() + 0.5)));
  232. lcd_printPGM(PSTR(LCD_STR_DEGREE " "));
  233. u8g.setPrintPos(81,27);
  234. u8g.print(itostr3(int(degBed() + 0.5)));
  235. lcd_printPGM(PSTR(LCD_STR_DEGREE " "));
  236. if (!isHeatingBed()) u8g.drawBox(88,18,2,2);
  237. else
  238. {
  239. u8g.setColorIndex(0); // white on black
  240. u8g.drawBox(88,18,2,2);
  241. u8g.setColorIndex(1); // black on white
  242. }
  243. // Fan
  244. u8g.setFont(FONT_STATUSMENU);
  245. u8g.setPrintPos(104,27);
  246. #if defined(FAN_PIN) && FAN_PIN > -1
  247. u8g.print(itostr3(int((fanSpeed*100)/256 + 1)));
  248. u8g.print("%");
  249. #else
  250. u8g.print("---");
  251. #endif
  252. // X, Y, Z-Coordinates
  253. u8g.setFont(FONT_STATUSMENU);
  254. u8g.drawBox(0,29,128,10);
  255. u8g.setColorIndex(0); // white on black
  256. u8g.setPrintPos(2,37);
  257. u8g.print("X");
  258. u8g.drawPixel(8,33);
  259. u8g.drawPixel(8,35);
  260. u8g.setPrintPos(10,37);
  261. u8g.print(ftostr31ns(current_position[X_AXIS]));
  262. u8g.setPrintPos(43,37);
  263. lcd_printPGM(PSTR("Y"));
  264. u8g.drawPixel(49,33);
  265. u8g.drawPixel(49,35);
  266. u8g.setPrintPos(51,37);
  267. u8g.print(ftostr31ns(current_position[Y_AXIS]));
  268. u8g.setPrintPos(83,37);
  269. u8g.print("Z");
  270. u8g.drawPixel(89,33);
  271. u8g.drawPixel(89,35);
  272. u8g.setPrintPos(91,37);
  273. u8g.print(ftostr31(current_position[Z_AXIS]));
  274. u8g.setColorIndex(1); // black on white
  275. // Feedrate
  276. u8g.setFont(u8g_font_6x10_marlin);
  277. u8g.setPrintPos(3,49);
  278. u8g.print(LCD_STR_FEEDRATE[0]);
  279. u8g.setFont(FONT_STATUSMENU);
  280. u8g.setPrintPos(12,48);
  281. u8g.print(itostr3(feedmultiply));
  282. u8g.print('%');
  283. // Status line
  284. u8g.setFont(FONT_STATUSMENU);
  285. u8g.setPrintPos(0,61);
  286. #ifndef FILAMENT_LCD_DISPLAY
  287. u8g.print(lcd_status_message);
  288. #else
  289. if(message_millis+5000>millis()){ //Display both Status message line and Filament display on the last line
  290. u8g.print(lcd_status_message);
  291. }
  292. else
  293. {
  294. lcd_printPGM(PSTR("dia:"));
  295. u8g.print(ftostr12ns(filament_width_meas));
  296. lcd_printPGM(PSTR(" factor:"));
  297. u8g.print(itostr3(extrudemultiply));
  298. u8g.print('%');
  299. }
  300. #endif
  301. }
  302. static void lcd_implementation_drawmenu_generic(uint8_t row, const char* pstr, char pre_char, char post_char)
  303. {
  304. char c;
  305. uint8_t n = LCD_WIDTH - 1 - 2;
  306. if ((pre_char == '>') || (pre_char == LCD_STR_UPLEVEL[0] ))
  307. {
  308. u8g.setColorIndex(1); // black on white
  309. u8g.drawBox (0, row*DOG_CHAR_HEIGHT + 3, 128, DOG_CHAR_HEIGHT);
  310. u8g.setColorIndex(0); // following text must be white on black
  311. } else u8g.setColorIndex(1); // unmarked text is black on white
  312. u8g.setPrintPos(0 * DOG_CHAR_WIDTH, (row + 1) * DOG_CHAR_HEIGHT);
  313. if (pre_char != '>') u8g.print(pre_char); else u8g.print(' '); // Row selector is obsolete
  314. while( (c = pgm_read_byte(pstr)) != '\0' )
  315. {
  316. u8g.print(c);
  317. pstr++;
  318. n--;
  319. }
  320. while(n--){
  321. u8g.print(' ');
  322. }
  323. u8g.print(post_char);
  324. u8g.print(' ');
  325. u8g.setColorIndex(1); // restore settings to black on white
  326. }
  327. static void lcd_implementation_drawmenu_setting_edit_generic(uint8_t row, const char* pstr, char pre_char, char* data)
  328. {
  329. static unsigned int fkt_cnt = 0;
  330. char c;
  331. uint8_t n = LCD_WIDTH - 1 - 2 - strlen(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. u8g.print(data);
  345. }
  346. static void lcd_implementation_drawmenu_setting_edit_generic_P(uint8_t row, const char* pstr, char pre_char, const char* data)
  347. {
  348. char c;
  349. uint8_t n= LCD_WIDTH - 1 - 2 - strlen_P(data);
  350. u8g.setPrintPos(0 * DOG_CHAR_WIDTH, (row + 1) * DOG_CHAR_HEIGHT);
  351. u8g.print(pre_char);
  352. while( (c = pgm_read_byte(pstr)) != '\0' )
  353. {
  354. u8g.print(c);
  355. pstr++;
  356. n--;
  357. }
  358. u8g.print(':');
  359. while(n--){
  360. u8g.print(' ');
  361. }
  362. lcd_printPGM(data);
  363. }
  364. #define lcd_implementation_drawmenu_setting_edit_int3_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', itostr3(*(data)))
  365. #define lcd_implementation_drawmenu_setting_edit_int3(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', itostr3(*(data)))
  366. #define lcd_implementation_drawmenu_setting_edit_float3_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr3(*(data)))
  367. #define lcd_implementation_drawmenu_setting_edit_float3(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr3(*(data)))
  368. #define lcd_implementation_drawmenu_setting_edit_float32_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr32(*(data)))
  369. #define lcd_implementation_drawmenu_setting_edit_float32(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr32(*(data)))
  370. #define lcd_implementation_drawmenu_setting_edit_float5_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr5(*(data)))
  371. #define lcd_implementation_drawmenu_setting_edit_float5(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr5(*(data)))
  372. #define lcd_implementation_drawmenu_setting_edit_float52_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr52(*(data)))
  373. #define lcd_implementation_drawmenu_setting_edit_float52(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr52(*(data)))
  374. #define lcd_implementation_drawmenu_setting_edit_float51_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr51(*(data)))
  375. #define lcd_implementation_drawmenu_setting_edit_float51(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr51(*(data)))
  376. #define lcd_implementation_drawmenu_setting_edit_long5_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr5(*(data)))
  377. #define lcd_implementation_drawmenu_setting_edit_long5(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr5(*(data)))
  378. #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))
  379. #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))
  380. //Add version for callback functions
  381. #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)))
  382. #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)))
  383. #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)))
  384. #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)))
  385. #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)))
  386. #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)))
  387. #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)))
  388. #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)))
  389. #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)))
  390. #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)))
  391. #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)))
  392. #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)))
  393. #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)))
  394. #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)))
  395. #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))
  396. #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))
  397. void lcd_implementation_drawedit(const char* pstr, char* value)
  398. {
  399. u8g.setPrintPos(0 * DOG_CHAR_WIDTH_LARGE, (u8g.getHeight() - 1 - DOG_CHAR_HEIGHT_LARGE) - (1 * DOG_CHAR_HEIGHT_LARGE) - START_ROW );
  400. u8g.setFont(u8g_font_9x18);
  401. lcd_printPGM(pstr);
  402. u8g.print(':');
  403. u8g.setPrintPos((14 - strlen(value)) * DOG_CHAR_WIDTH_LARGE, (u8g.getHeight() - 1 - DOG_CHAR_HEIGHT_LARGE) - (1 * DOG_CHAR_HEIGHT_LARGE) - START_ROW );
  404. u8g.print(value);
  405. }
  406. static void lcd_implementation_drawmenu_sdfile_selected(uint8_t row, const char* pstr, const char* filename, char* longFilename)
  407. {
  408. char c;
  409. uint8_t n = LCD_WIDTH - 1;
  410. if (longFilename[0] != '\0')
  411. {
  412. filename = longFilename;
  413. longFilename[LCD_WIDTH-1] = '\0';
  414. }
  415. u8g.setColorIndex(1); // black on white
  416. u8g.drawBox (0, row*DOG_CHAR_HEIGHT + 3, 128, DOG_CHAR_HEIGHT);
  417. u8g.setColorIndex(0); // following text must be white on black
  418. u8g.setPrintPos(0 * DOG_CHAR_WIDTH, (row + 1) * DOG_CHAR_HEIGHT);
  419. u8g.print(' '); // Indent by 1 char
  420. while((c = *filename) != '\0')
  421. {
  422. u8g.print(c);
  423. filename++;
  424. n--;
  425. }
  426. while(n--){
  427. u8g.print(' ');
  428. }
  429. u8g.setColorIndex(1); // black on white
  430. }
  431. static void lcd_implementation_drawmenu_sdfile(uint8_t row, const char* pstr, const char* filename, char* longFilename)
  432. {
  433. char c;
  434. uint8_t n = LCD_WIDTH - 1;
  435. if (longFilename[0] != '\0')
  436. {
  437. filename = longFilename;
  438. longFilename[LCD_WIDTH-1] = '\0';
  439. }
  440. u8g.setPrintPos(0 * DOG_CHAR_WIDTH, (row + 1) * DOG_CHAR_HEIGHT);
  441. u8g.print(' ');
  442. while((c = *filename) != '\0')
  443. {
  444. u8g.print(c);
  445. filename++;
  446. n--;
  447. }
  448. while(n--){
  449. u8g.print(' ');
  450. }
  451. }
  452. static void lcd_implementation_drawmenu_sddirectory_selected(uint8_t row, const char* pstr, const char* filename, char* longFilename)
  453. {
  454. char c;
  455. uint8_t n = LCD_WIDTH - 2;
  456. if (longFilename[0] != '\0')
  457. {
  458. filename = longFilename;
  459. longFilename[LCD_WIDTH-2] = '\0';
  460. }
  461. u8g.setColorIndex(1); // black on white
  462. u8g.drawBox (0, row*DOG_CHAR_HEIGHT + 3, 128, DOG_CHAR_HEIGHT);
  463. u8g.setColorIndex(0); // following text must be white on black
  464. u8g.setPrintPos(0 * DOG_CHAR_WIDTH, (row + 1) * DOG_CHAR_HEIGHT);
  465. u8g.print(' '); // Indent by 1 char
  466. u8g.print(LCD_STR_FOLDER[0]);
  467. while((c = *filename) != '\0')
  468. {
  469. u8g.print(c);
  470. filename++;
  471. n--;
  472. }
  473. while(n--){
  474. u8g.print(' ');
  475. }
  476. u8g.setColorIndex(1); // black on white
  477. }
  478. static void lcd_implementation_drawmenu_sddirectory(uint8_t row, const char* pstr, const char* filename, char* longFilename)
  479. {
  480. char c;
  481. uint8_t n = LCD_WIDTH - 2;
  482. if (longFilename[0] != '\0')
  483. {
  484. filename = longFilename;
  485. longFilename[LCD_WIDTH-2] = '\0';
  486. }
  487. u8g.setPrintPos(0 * DOG_CHAR_WIDTH, (row + 1) * DOG_CHAR_HEIGHT);
  488. u8g.print(' ');
  489. u8g.print(LCD_STR_FOLDER[0]);
  490. while((c = *filename) != '\0')
  491. {
  492. u8g.print(c);
  493. filename++;
  494. n--;
  495. }
  496. while(n--){
  497. u8g.print(' ');
  498. }
  499. }
  500. #define lcd_implementation_drawmenu_back_selected(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, LCD_STR_UPLEVEL[0], LCD_STR_UPLEVEL[0])
  501. #define lcd_implementation_drawmenu_back(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, ' ', LCD_STR_UPLEVEL[0])
  502. #define lcd_implementation_drawmenu_submenu_selected(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, '>', LCD_STR_ARROW_RIGHT[0])
  503. #define lcd_implementation_drawmenu_submenu(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, ' ', LCD_STR_ARROW_RIGHT[0])
  504. #define lcd_implementation_drawmenu_gcode_selected(row, pstr, gcode) lcd_implementation_drawmenu_generic(row, pstr, '>', ' ')
  505. #define lcd_implementation_drawmenu_gcode(row, pstr, gcode) lcd_implementation_drawmenu_generic(row, pstr, ' ', ' ')
  506. #define lcd_implementation_drawmenu_function_selected(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, '>', ' ')
  507. #define lcd_implementation_drawmenu_function(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, ' ', ' ')
  508. static void lcd_implementation_quick_feedback()
  509. {
  510. #if BEEPER > -1
  511. SET_OUTPUT(BEEPER);
  512. for(int8_t i=0;i<10;i++)
  513. {
  514. WRITE(BEEPER,HIGH);
  515. delay(3);
  516. WRITE(BEEPER,LOW);
  517. delay(3);
  518. }
  519. #endif
  520. }
  521. #endif//ULTRA_LCD_IMPLEMENTATION_DOGM_H