My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

dogm_lcd_implementation.h 20KB

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