My Marlin configs for Fabrikator Mini and CTC i3 Pro B
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

dogm_lcd_implementation.h 21KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607
  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. u8g.print(lcd_status_message);
  293. }
  294. static void lcd_implementation_drawmenu_generic(uint8_t row, const char* pstr, char pre_char, char post_char)
  295. {
  296. char c;
  297. uint8_t n = LCD_WIDTH - 1 - 2;
  298. if ((pre_char == '>') || (pre_char == LCD_STR_UPLEVEL[0] ))
  299. {
  300. u8g.setColorIndex(1); // black on white
  301. u8g.drawBox (0, row*DOG_CHAR_HEIGHT + 3, 128, DOG_CHAR_HEIGHT);
  302. u8g.setColorIndex(0); // following text must be white on black
  303. } else u8g.setColorIndex(1); // unmarked text is black on white
  304. u8g.setPrintPos(0 * DOG_CHAR_WIDTH, (row + 1) * DOG_CHAR_HEIGHT);
  305. if (pre_char != '>') u8g.print(pre_char); else u8g.print(' '); // Row selector is obsolete
  306. while( (c = pgm_read_byte(pstr)) != '\0' )
  307. {
  308. u8g.print(c);
  309. pstr++;
  310. n--;
  311. }
  312. while(n--){
  313. u8g.print(' ');
  314. }
  315. u8g.print(post_char);
  316. u8g.print(' ');
  317. u8g.setColorIndex(1); // restore settings to black on white
  318. }
  319. static void lcd_implementation_drawmenu_setting_edit_generic(uint8_t row, const char* pstr, char pre_char, char* data)
  320. {
  321. static unsigned int fkt_cnt = 0;
  322. char c;
  323. uint8_t n = LCD_WIDTH - 1 - 2 - strlen(data);
  324. u8g.setPrintPos(0 * DOG_CHAR_WIDTH, (row + 1) * DOG_CHAR_HEIGHT);
  325. u8g.print(pre_char);
  326. while( (c = pgm_read_byte(pstr)) != '\0' )
  327. {
  328. u8g.print(c);
  329. pstr++;
  330. n--;
  331. }
  332. u8g.print(':');
  333. while(n--){
  334. u8g.print(' ');
  335. }
  336. u8g.print(data);
  337. }
  338. static void lcd_implementation_drawmenu_setting_edit_generic_P(uint8_t row, const char* pstr, char pre_char, const char* data)
  339. {
  340. char c;
  341. uint8_t n= LCD_WIDTH - 1 - 2 - strlen_P(data);
  342. u8g.setPrintPos(0 * DOG_CHAR_WIDTH, (row + 1) * DOG_CHAR_HEIGHT);
  343. u8g.print(pre_char);
  344. while( (c = pgm_read_byte(pstr)) != '\0' )
  345. {
  346. u8g.print(c);
  347. pstr++;
  348. n--;
  349. }
  350. u8g.print(':');
  351. while(n--){
  352. u8g.print(' ');
  353. }
  354. lcd_printPGM(data);
  355. }
  356. #define lcd_implementation_drawmenu_setting_edit_int3_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', itostr3(*(data)))
  357. #define lcd_implementation_drawmenu_setting_edit_int3(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', itostr3(*(data)))
  358. #define lcd_implementation_drawmenu_setting_edit_float3_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr3(*(data)))
  359. #define lcd_implementation_drawmenu_setting_edit_float3(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr3(*(data)))
  360. #define lcd_implementation_drawmenu_setting_edit_float32_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr32(*(data)))
  361. #define lcd_implementation_drawmenu_setting_edit_float32(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr32(*(data)))
  362. #define lcd_implementation_drawmenu_setting_edit_float5_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr5(*(data)))
  363. #define lcd_implementation_drawmenu_setting_edit_float5(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr5(*(data)))
  364. #define lcd_implementation_drawmenu_setting_edit_float52_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr52(*(data)))
  365. #define lcd_implementation_drawmenu_setting_edit_float52(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr52(*(data)))
  366. #define lcd_implementation_drawmenu_setting_edit_float51_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr51(*(data)))
  367. #define lcd_implementation_drawmenu_setting_edit_float51(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr51(*(data)))
  368. #define lcd_implementation_drawmenu_setting_edit_long5_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr5(*(data)))
  369. #define lcd_implementation_drawmenu_setting_edit_long5(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr5(*(data)))
  370. #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))
  371. #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))
  372. //Add version for callback functions
  373. #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)))
  374. #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)))
  375. #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)))
  376. #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)))
  377. #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)))
  378. #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)))
  379. #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)))
  380. #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)))
  381. #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)))
  382. #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)))
  383. #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)))
  384. #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)))
  385. #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)))
  386. #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)))
  387. #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))
  388. #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))
  389. void lcd_implementation_drawedit(const char* pstr, char* value)
  390. {
  391. u8g.setPrintPos(0 * DOG_CHAR_WIDTH_LARGE, (u8g.getHeight() - 1 - DOG_CHAR_HEIGHT_LARGE) - (1 * DOG_CHAR_HEIGHT_LARGE) - START_ROW );
  392. u8g.setFont(u8g_font_9x18);
  393. lcd_printPGM(pstr);
  394. u8g.print(':');
  395. u8g.setPrintPos((14 - strlen(value)) * DOG_CHAR_WIDTH_LARGE, (u8g.getHeight() - 1 - DOG_CHAR_HEIGHT_LARGE) - (1 * DOG_CHAR_HEIGHT_LARGE) - START_ROW );
  396. u8g.print(value);
  397. }
  398. static void lcd_implementation_drawmenu_sdfile_selected(uint8_t row, const char* pstr, const char* filename, char* longFilename)
  399. {
  400. char c;
  401. uint8_t n = LCD_WIDTH - 1;
  402. if (longFilename[0] != '\0')
  403. {
  404. filename = longFilename;
  405. longFilename[LCD_WIDTH-1] = '\0';
  406. }
  407. u8g.setColorIndex(1); // black on white
  408. u8g.drawBox (0, row*DOG_CHAR_HEIGHT + 3, 128, DOG_CHAR_HEIGHT);
  409. u8g.setColorIndex(0); // following text must be white on black
  410. u8g.setPrintPos(0 * DOG_CHAR_WIDTH, (row + 1) * DOG_CHAR_HEIGHT);
  411. u8g.print(' '); // Indent by 1 char
  412. while((c = *filename) != '\0')
  413. {
  414. u8g.print(c);
  415. filename++;
  416. n--;
  417. }
  418. while(n--){
  419. u8g.print(' ');
  420. }
  421. u8g.setColorIndex(1); // black on white
  422. }
  423. static void lcd_implementation_drawmenu_sdfile(uint8_t row, const char* pstr, const char* filename, char* longFilename)
  424. {
  425. char c;
  426. uint8_t n = LCD_WIDTH - 1;
  427. if (longFilename[0] != '\0')
  428. {
  429. filename = longFilename;
  430. longFilename[LCD_WIDTH-1] = '\0';
  431. }
  432. u8g.setPrintPos(0 * DOG_CHAR_WIDTH, (row + 1) * DOG_CHAR_HEIGHT);
  433. u8g.print(' ');
  434. while((c = *filename) != '\0')
  435. {
  436. u8g.print(c);
  437. filename++;
  438. n--;
  439. }
  440. while(n--){
  441. u8g.print(' ');
  442. }
  443. }
  444. static void lcd_implementation_drawmenu_sddirectory_selected(uint8_t row, const char* pstr, const char* filename, char* longFilename)
  445. {
  446. char c;
  447. uint8_t n = LCD_WIDTH - 2;
  448. if (longFilename[0] != '\0')
  449. {
  450. filename = longFilename;
  451. longFilename[LCD_WIDTH-2] = '\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. u8g.print(LCD_STR_FOLDER[0]);
  459. while((c = *filename) != '\0')
  460. {
  461. u8g.print(c);
  462. filename++;
  463. n--;
  464. }
  465. while(n--){
  466. u8g.print(' ');
  467. }
  468. u8g.setColorIndex(1); // black on white
  469. }
  470. static void lcd_implementation_drawmenu_sddirectory(uint8_t row, const char* pstr, const char* filename, char* longFilename)
  471. {
  472. char c;
  473. uint8_t n = LCD_WIDTH - 2;
  474. if (longFilename[0] != '\0')
  475. {
  476. filename = longFilename;
  477. longFilename[LCD_WIDTH-2] = '\0';
  478. }
  479. u8g.setPrintPos(0 * DOG_CHAR_WIDTH, (row + 1) * DOG_CHAR_HEIGHT);
  480. u8g.print(' ');
  481. u8g.print(LCD_STR_FOLDER[0]);
  482. while((c = *filename) != '\0')
  483. {
  484. u8g.print(c);
  485. filename++;
  486. n--;
  487. }
  488. while(n--){
  489. u8g.print(' ');
  490. }
  491. }
  492. #define lcd_implementation_drawmenu_back_selected(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, LCD_STR_UPLEVEL[0], LCD_STR_UPLEVEL[0])
  493. #define lcd_implementation_drawmenu_back(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, ' ', LCD_STR_UPLEVEL[0])
  494. #define lcd_implementation_drawmenu_submenu_selected(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, '>', LCD_STR_ARROW_RIGHT[0])
  495. #define lcd_implementation_drawmenu_submenu(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, ' ', LCD_STR_ARROW_RIGHT[0])
  496. #define lcd_implementation_drawmenu_gcode_selected(row, pstr, gcode) lcd_implementation_drawmenu_generic(row, pstr, '>', ' ')
  497. #define lcd_implementation_drawmenu_gcode(row, pstr, gcode) lcd_implementation_drawmenu_generic(row, pstr, ' ', ' ')
  498. #define lcd_implementation_drawmenu_function_selected(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, '>', ' ')
  499. #define lcd_implementation_drawmenu_function(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, ' ', ' ')
  500. static void lcd_implementation_quick_feedback()
  501. {
  502. #if BEEPER > -1
  503. SET_OUTPUT(BEEPER);
  504. for(int8_t i=0;i<10;i++)
  505. {
  506. WRITE(BEEPER,HIGH);
  507. delay(3);
  508. WRITE(BEEPER,LOW);
  509. delay(3);
  510. }
  511. #endif
  512. }
  513. #endif//ULTRA_LCD_IMPLEMENTATION_DOGM_H