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.

ultralcd_implementation_hitachi_HD44780.h 20KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530
  1. #ifndef ULTRA_LCD_IMPLEMENTATION_HITACHI_HD44780_H
  2. #define ULTRA_LCD_IMPLEMENTATION_HITACHI_HD44780_H
  3. /**
  4. * Implementation of the LCD display routines for a hitachi HD44780 display. These are common LCD character displays.
  5. * When selecting the rusian language, a slightly different LCD implementation is used to handle UTF8 characters.
  6. **/
  7. #if LANGUAGE_CHOICE == 6
  8. #include "LiquidCrystalRus.h"
  9. #define LCD_CLASS LiquidCrystalRus
  10. #else
  11. #ifdef LCD_I2C_TYPE_PCA8574
  12. #include <LiquidCrystal_I2C.h>
  13. #define LCD_CLASS LiquidCrystal_I2C
  14. #else
  15. #include <LiquidCrystal.h>
  16. #define LCD_CLASS LiquidCrystal
  17. #endif
  18. #endif
  19. /* Custom characters defined in the first 8 characters of the LCD */
  20. #define LCD_STR_BEDTEMP "\x00"
  21. #define LCD_STR_DEGREE "\x01"
  22. #define LCD_STR_THERMOMETER "\x02"
  23. #define LCD_STR_UPLEVEL "\x03"
  24. #define LCD_STR_REFRESH "\x04"
  25. #define LCD_STR_FOLDER "\x05"
  26. #define LCD_STR_FEEDRATE "\x06"
  27. #define LCD_STR_CLOCK "\x07"
  28. #define LCD_STR_ARROW_RIGHT "\x7E" /* from the default character set */
  29. #ifdef LCD_I2C_TYPE_PCA8574
  30. LCD_CLASS lcd(LCD_I2C_ADDRESS, LCD_WIDTH, LCD_HEIGHT);
  31. #else
  32. LCD_CLASS lcd(LCD_PINS_RS, LCD_PINS_ENABLE, LCD_PINS_D4, LCD_PINS_D5,LCD_PINS_D6,LCD_PINS_D7); //RS,Enable,D4,D5,D6,D7
  33. #endif
  34. static void lcd_implementation_init()
  35. {
  36. byte bedTemp[8] =
  37. {
  38. B00000,
  39. B11111,
  40. B10101,
  41. B10001,
  42. B10101,
  43. B11111,
  44. B00000,
  45. B00000
  46. }; //thanks Sonny Mounicou
  47. byte degree[8] =
  48. {
  49. B01100,
  50. B10010,
  51. B10010,
  52. B01100,
  53. B00000,
  54. B00000,
  55. B00000,
  56. B00000
  57. };
  58. byte thermometer[8] =
  59. {
  60. B00100,
  61. B01010,
  62. B01010,
  63. B01010,
  64. B01010,
  65. B10001,
  66. B10001,
  67. B01110
  68. };
  69. byte uplevel[8]={
  70. B00100,
  71. B01110,
  72. B11111,
  73. B00100,
  74. B11100,
  75. B00000,
  76. B00000,
  77. B00000
  78. }; //thanks joris
  79. byte refresh[8]={
  80. B00000,
  81. B00110,
  82. B11001,
  83. B11000,
  84. B00011,
  85. B10011,
  86. B01100,
  87. B00000,
  88. }; //thanks joris
  89. byte folder [8]={
  90. B00000,
  91. B11100,
  92. B11111,
  93. B10001,
  94. B10001,
  95. B11111,
  96. B00000,
  97. B00000
  98. }; //thanks joris
  99. byte feedrate [8]={
  100. B11100,
  101. B10000,
  102. B11000,
  103. B10111,
  104. B00101,
  105. B00110,
  106. B00101,
  107. B00000
  108. }; //thanks Sonny Mounicou
  109. byte clock [8]={
  110. B00000,
  111. B01110,
  112. B10011,
  113. B10101,
  114. B10001,
  115. B01110,
  116. B00000,
  117. B00000
  118. }; //thanks Sonny Mounicou
  119. #ifdef LCD_I2C_TYPE_PCA8574
  120. lcd.init();
  121. lcd.backlight();
  122. #else
  123. lcd.begin(LCD_WIDTH, LCD_HEIGHT);
  124. #endif
  125. lcd.createChar(LCD_STR_BEDTEMP[0], bedTemp);
  126. lcd.createChar(LCD_STR_DEGREE[0], degree);
  127. lcd.createChar(LCD_STR_THERMOMETER[0], thermometer);
  128. lcd.createChar(LCD_STR_UPLEVEL[0], uplevel);
  129. lcd.createChar(LCD_STR_REFRESH[0], refresh);
  130. lcd.createChar(LCD_STR_FOLDER[0], folder);
  131. lcd.createChar(LCD_STR_FEEDRATE[0], feedrate);
  132. lcd.createChar(LCD_STR_CLOCK[0], clock);
  133. lcd.clear();
  134. }
  135. static void lcd_implementation_clear()
  136. {
  137. lcd.clear();
  138. }
  139. /* Arduino < 1.0.0 is missing a function to print PROGMEM strings, so we need to implement our own */
  140. static void lcd_printPGM(const char* str)
  141. {
  142. char c;
  143. while((c = pgm_read_byte(str++)) != '\0')
  144. {
  145. lcd.write(c);
  146. }
  147. }
  148. /*
  149. Possible status screens:
  150. 16x2 |0123456789012345|
  151. |000/000 B000/000|
  152. |Status line.....|
  153. 16x4 |0123456789012345|
  154. |000/000 B000/000|
  155. |SD100% Z000.0|
  156. |F100% T--:--|
  157. |Status line.....|
  158. 20x2 |01234567890123456789|
  159. |T000/000D B000/000D |
  160. |Status line.........|
  161. 20x4 |01234567890123456789|
  162. |T000/000D B000/000D |
  163. |X+000.0 Y+000.0 Z+000.0|
  164. |F100% SD100% T--:--|
  165. |Status line.........|
  166. 20x4 |01234567890123456789|
  167. |T000/000D B000/000D |
  168. |T000/000D Z000.0|
  169. |F100% SD100% T--:--|
  170. |Status line.........|
  171. */
  172. static void lcd_implementation_status_screen()
  173. {
  174. int tHotend=int(degHotend(0) + 0.5);
  175. int tTarget=int(degTargetHotend(0) + 0.5);
  176. #if LCD_WIDTH < 20
  177. lcd.setCursor(0, 0);
  178. lcd.print(itostr3(tHotend));
  179. lcd.print('/');
  180. lcd.print(itostr3left(tTarget));
  181. # if EXTRUDERS > 1 || TEMP_SENSOR_BED != 0
  182. //If we have an 2nd extruder or heated bed, show that in the top right corner
  183. lcd.setCursor(8, 0);
  184. # if EXTRUDERS > 1
  185. tHotend = int(degHotend(1) + 0.5);
  186. tTarget = int(degTargetHotend(1) + 0.5);
  187. lcd.print(LCD_STR_THERMOMETER[0]);
  188. # else//Heated bed
  189. tHotend=int(degBed() + 0.5);
  190. tTarget=int(degTargetBed() + 0.5);
  191. lcd.print(LCD_STR_BEDTEMP[0]);
  192. # endif
  193. lcd.print(itostr3(tHotend));
  194. lcd.print('/');
  195. lcd.print(itostr3left(tTarget));
  196. # endif//EXTRUDERS > 1 || TEMP_SENSOR_BED != 0
  197. #else//LCD_WIDTH > 19
  198. lcd.setCursor(0, 0);
  199. lcd.print(LCD_STR_THERMOMETER[0]);
  200. lcd.print(itostr3(tHotend));
  201. lcd.print('/');
  202. lcd.print(itostr3left(tTarget));
  203. lcd_printPGM(PSTR(LCD_STR_DEGREE " "));
  204. if (tTarget < 10)
  205. lcd.print(' ');
  206. # if EXTRUDERS > 1 || TEMP_SENSOR_BED != 0
  207. //If we have an 2nd extruder or heated bed, show that in the top right corner
  208. lcd.setCursor(10, 0);
  209. # if EXTRUDERS > 1
  210. tHotend = int(degHotend(1) + 0.5);
  211. tTarget = int(degTargetHotend(1) + 0.5);
  212. lcd.print(LCD_STR_THERMOMETER[0]);
  213. # else//Heated bed
  214. tHotend=int(degBed() + 0.5);
  215. tTarget=int(degTargetBed() + 0.5);
  216. lcd.print(LCD_STR_BEDTEMP[0]);
  217. # endif
  218. lcd.print(itostr3(tHotend));
  219. lcd.print('/');
  220. lcd.print(itostr3left(tTarget));
  221. lcd_printPGM(PSTR(LCD_STR_DEGREE " "));
  222. if (tTarget < 10)
  223. lcd.print(' ');
  224. # endif//EXTRUDERS > 1 || TEMP_SENSOR_BED != 0
  225. #endif//LCD_WIDTH > 19
  226. #if LCD_HEIGHT > 2
  227. //Lines 2 for 4 line LCD
  228. # if LCD_WIDTH < 20
  229. # ifdef SDSUPPORT
  230. lcd.setCursor(0, 2);
  231. lcd_printPGM(PSTR("SD"));
  232. if (IS_SD_PRINTING)
  233. lcd.print(itostr3(card.percentDone()));
  234. else
  235. lcd_printPGM(PSTR("---"));
  236. lcd.print('%');
  237. # endif//SDSUPPORT
  238. # else//LCD_WIDTH > 19
  239. # if EXTRUDERS > 1 && TEMP_SENSOR_BED != 0
  240. //If we both have a 2nd extruder and a heated bed, show the heated bed temp on the 2nd line on the left, as the first line is filled with extruder temps
  241. tHotend=int(degBed() + 0.5);
  242. tTarget=int(degTargetBed() + 0.5);
  243. lcd.setCursor(0, 1);
  244. lcd.print(LCD_STR_BEDTEMP[0]);
  245. lcd.print(itostr3(tHotend));
  246. lcd.print('/');
  247. lcd.print(itostr3left(tTarget));
  248. lcd_printPGM(PSTR(LCD_STR_DEGREE " "));
  249. if (tTarget < 10)
  250. lcd.print(' ');
  251. # else
  252. lcd.setCursor(0,1);
  253. lcd.print('X');
  254. lcd.print(ftostr3(current_position[X_AXIS]));
  255. lcd_printPGM(PSTR(" Y"));
  256. lcd.print(ftostr3(current_position[Y_AXIS]));
  257. # endif//EXTRUDERS > 1 || TEMP_SENSOR_BED != 0
  258. # endif//LCD_WIDTH > 19
  259. lcd.setCursor(LCD_WIDTH - 8, 1);
  260. lcd.print('Z');
  261. lcd.print(ftostr32(current_position[Z_AXIS]));
  262. #endif//LCD_HEIGHT > 2
  263. #if LCD_HEIGHT > 3
  264. lcd.setCursor(0, 2);
  265. lcd.print(LCD_STR_FEEDRATE[0]);
  266. lcd.print(itostr3(feedmultiply));
  267. lcd.print('%');
  268. # if LCD_WIDTH > 19
  269. # ifdef SDSUPPORT
  270. lcd.setCursor(7, 2);
  271. lcd_printPGM(PSTR("SD"));
  272. if (IS_SD_PRINTING)
  273. lcd.print(itostr3(card.percentDone()));
  274. else
  275. lcd_printPGM(PSTR("---"));
  276. lcd.print('%');
  277. # endif//SDSUPPORT
  278. # endif//LCD_WIDTH > 19
  279. lcd.setCursor(LCD_WIDTH - 6, 2);
  280. lcd.print(LCD_STR_CLOCK[0]);
  281. if(starttime != 0)
  282. {
  283. uint16_t time = millis()/60000 - starttime/60000;
  284. lcd.print(itostr2(time/60));
  285. lcd.print(':');
  286. lcd.print(itostr2(time%60));
  287. }else{
  288. lcd_printPGM(PSTR("--:--"));
  289. }
  290. #endif
  291. //Status message line on the last line
  292. lcd.setCursor(0, LCD_HEIGHT - 1);
  293. lcd.print(lcd_status_message);
  294. }
  295. static void lcd_implementation_drawmenu_generic(uint8_t row, const char* pstr, char pre_char, char post_char)
  296. {
  297. char c;
  298. //Use all characters in narrow LCDs
  299. #if LCD_WIDTH < 20
  300. uint8_t n = LCD_WIDTH - 1 - 1;
  301. #else
  302. uint8_t n = LCD_WIDTH - 1 - 2;
  303. #endif
  304. lcd.setCursor(0, row);
  305. lcd.print(pre_char);
  306. while((c = pgm_read_byte(pstr)) != '\0')
  307. {
  308. lcd.print(c);
  309. pstr++;
  310. n--;
  311. }
  312. while(n--)
  313. lcd.print(' ');
  314. lcd.print(post_char);
  315. lcd.print(' ');
  316. }
  317. static void lcd_implementation_drawmenu_setting_edit_generic(uint8_t row, const char* pstr, char pre_char, char* data)
  318. {
  319. char c;
  320. //Use all characters in narrow LCDs
  321. #if LCD_WIDTH < 20
  322. uint8_t n = LCD_WIDTH - 1 - 1 - strlen(data);
  323. #else
  324. uint8_t n = LCD_WIDTH - 1 - 2 - strlen(data);
  325. #endif
  326. lcd.setCursor(0, row);
  327. lcd.print(pre_char);
  328. while((c = pgm_read_byte(pstr)) != '\0')
  329. {
  330. lcd.print(c);
  331. pstr++;
  332. n--;
  333. }
  334. lcd.print(':');
  335. while(n--)
  336. lcd.print(' ');
  337. lcd.print(data);
  338. }
  339. static void lcd_implementation_drawmenu_setting_edit_generic_P(uint8_t row, const char* pstr, char pre_char, const char* data)
  340. {
  341. char c;
  342. //Use all characters in narrow LCDs
  343. #if LCD_WIDTH < 20
  344. uint8_t n = LCD_WIDTH - 1 - 1 - strlen_P(data);
  345. #else
  346. uint8_t n = LCD_WIDTH - 1 - 2 - strlen_P(data);
  347. #endif
  348. lcd.setCursor(0, row);
  349. lcd.print(pre_char);
  350. while((c = pgm_read_byte(pstr)) != '\0')
  351. {
  352. lcd.print(c);
  353. pstr++;
  354. n--;
  355. }
  356. lcd.print(':');
  357. while(n--)
  358. lcd.print(' ');
  359. lcd_printPGM(data);
  360. }
  361. #define lcd_implementation_drawmenu_setting_edit_int3_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', itostr3(*(data)))
  362. #define lcd_implementation_drawmenu_setting_edit_int3(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', itostr3(*(data)))
  363. #define lcd_implementation_drawmenu_setting_edit_float3_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr3(*(data)))
  364. #define lcd_implementation_drawmenu_setting_edit_float3(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr3(*(data)))
  365. #define lcd_implementation_drawmenu_setting_edit_float32_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr32(*(data)))
  366. #define lcd_implementation_drawmenu_setting_edit_float32(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr32(*(data)))
  367. #define lcd_implementation_drawmenu_setting_edit_float5_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr5(*(data)))
  368. #define lcd_implementation_drawmenu_setting_edit_float5(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr5(*(data)))
  369. #define lcd_implementation_drawmenu_setting_edit_float52_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr52(*(data)))
  370. #define lcd_implementation_drawmenu_setting_edit_float52(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr52(*(data)))
  371. #define lcd_implementation_drawmenu_setting_edit_float51_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr51(*(data)))
  372. #define lcd_implementation_drawmenu_setting_edit_float51(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr51(*(data)))
  373. #define lcd_implementation_drawmenu_setting_edit_long5_selected(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, '>', ftostr5(*(data)))
  374. #define lcd_implementation_drawmenu_setting_edit_long5(row, pstr, pstr2, data, minValue, maxValue) lcd_implementation_drawmenu_setting_edit_generic(row, pstr, ' ', ftostr5(*(data)))
  375. #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))
  376. #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))
  377. //Add version for callback functions
  378. #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)))
  379. #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)))
  380. #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)))
  381. #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)))
  382. #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)))
  383. #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)))
  384. #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)))
  385. #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)))
  386. #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)))
  387. #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)))
  388. #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)))
  389. #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)))
  390. #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)))
  391. #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)))
  392. #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))
  393. #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))
  394. void lcd_implementation_drawedit(const char* pstr, char* value)
  395. {
  396. lcd.setCursor(1, 1);
  397. lcd_printPGM(pstr);
  398. lcd.print(':');
  399. #if LCD_WIDTH < 20
  400. lcd.setCursor(LCD_WIDTH - strlen(value), 1);
  401. #else
  402. lcd.setCursor(LCD_WIDTH -1 - strlen(value), 1);
  403. #endif
  404. lcd.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. lcd.setCursor(0, row);
  411. lcd.print('>');
  412. if (longFilename[0] != '\0')
  413. {
  414. filename = longFilename;
  415. longFilename[LCD_WIDTH-1] = '\0';
  416. }
  417. while((c = *filename) != '\0')
  418. {
  419. lcd.print(c);
  420. filename++;
  421. n--;
  422. }
  423. while(n--)
  424. lcd.print(' ');
  425. }
  426. static void lcd_implementation_drawmenu_sdfile(uint8_t row, const char* pstr, const char* filename, char* longFilename)
  427. {
  428. char c;
  429. uint8_t n = LCD_WIDTH - 1;
  430. lcd.setCursor(0, row);
  431. lcd.print(' ');
  432. if (longFilename[0] != '\0')
  433. {
  434. filename = longFilename;
  435. longFilename[LCD_WIDTH-1] = '\0';
  436. }
  437. while((c = *filename) != '\0')
  438. {
  439. lcd.print(c);
  440. filename++;
  441. n--;
  442. }
  443. while(n--)
  444. lcd.print(' ');
  445. }
  446. static void lcd_implementation_drawmenu_sddirectory_selected(uint8_t row, const char* pstr, const char* filename, char* longFilename)
  447. {
  448. char c;
  449. uint8_t n = LCD_WIDTH - 2;
  450. lcd.setCursor(0, row);
  451. lcd.print('>');
  452. lcd.print(LCD_STR_FOLDER[0]);
  453. if (longFilename[0] != '\0')
  454. {
  455. filename = longFilename;
  456. longFilename[LCD_WIDTH-2] = '\0';
  457. }
  458. while((c = *filename) != '\0')
  459. {
  460. lcd.print(c);
  461. filename++;
  462. n--;
  463. }
  464. while(n--)
  465. lcd.print(' ');
  466. }
  467. static void lcd_implementation_drawmenu_sddirectory(uint8_t row, const char* pstr, const char* filename, char* longFilename)
  468. {
  469. char c;
  470. uint8_t n = LCD_WIDTH - 2;
  471. lcd.setCursor(0, row);
  472. lcd.print(' ');
  473. lcd.print(LCD_STR_FOLDER[0]);
  474. if (longFilename[0] != '\0')
  475. {
  476. filename = longFilename;
  477. longFilename[LCD_WIDTH-2] = '\0';
  478. }
  479. while((c = *filename) != '\0')
  480. {
  481. lcd.print(c);
  482. filename++;
  483. n--;
  484. }
  485. while(n--)
  486. lcd.print(' ');
  487. }
  488. #define lcd_implementation_drawmenu_back_selected(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, LCD_STR_UPLEVEL[0], LCD_STR_UPLEVEL[0])
  489. #define lcd_implementation_drawmenu_back(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, ' ', LCD_STR_UPLEVEL[0])
  490. #define lcd_implementation_drawmenu_submenu_selected(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, '>', LCD_STR_ARROW_RIGHT[0])
  491. #define lcd_implementation_drawmenu_submenu(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, ' ', LCD_STR_ARROW_RIGHT[0])
  492. #define lcd_implementation_drawmenu_gcode_selected(row, pstr, gcode) lcd_implementation_drawmenu_generic(row, pstr, '>', ' ')
  493. #define lcd_implementation_drawmenu_gcode(row, pstr, gcode) lcd_implementation_drawmenu_generic(row, pstr, ' ', ' ')
  494. #define lcd_implementation_drawmenu_function_selected(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, '>', ' ')
  495. #define lcd_implementation_drawmenu_function(row, pstr, data) lcd_implementation_drawmenu_generic(row, pstr, ' ', ' ')
  496. static void lcd_implementation_quick_feedback()
  497. {
  498. #if BEEPER > -1
  499. SET_OUTPUT(BEEPER);
  500. for(int8_t i=0;i<10;i++)
  501. {
  502. WRITE(BEEPER,HIGH);
  503. delay(3);
  504. WRITE(BEEPER,LOW);
  505. delay(3);
  506. }
  507. #endif
  508. }
  509. #endif//ULTRA_LCD_IMPLEMENTATION_HITACHI_HD44780_H