|
@@ -15,8 +15,8 @@
|
15
|
15
|
////////////////////////////////////
|
16
|
16
|
// Setup button and encode mappings for each panel (into 'buttons' variable
|
17
|
17
|
//
|
18
|
|
-// This is just to map common functions (across different panels) onto the same
|
19
|
|
-// macro name. The mapping is independent of whether the button is directly connected or
|
|
18
|
+// This is just to map common functions (across different panels) onto the same
|
|
19
|
+// macro name. The mapping is independent of whether the button is directly connected or
|
20
|
20
|
// via a shift/i2c register.
|
21
|
21
|
|
22
|
22
|
#ifdef ULTIPANEL
|
|
@@ -38,7 +38,7 @@
|
38
|
38
|
//
|
39
|
39
|
#if defined(LCD_I2C_VIKI)
|
40
|
40
|
#define B_I2C_BTN_OFFSET 3 // (the first three bit positions reserved for EN_A, EN_B, EN_C)
|
41
|
|
-
|
|
41
|
+
|
42
|
42
|
// button and encoder bit positions within 'buttons'
|
43
|
43
|
#define B_LE (BUTTON_LEFT<<B_I2C_BTN_OFFSET) // The remaining normalized buttons are all read via I2C
|
44
|
44
|
#define B_UP (BUTTON_UP<<B_I2C_BTN_OFFSET)
|
|
@@ -46,22 +46,22 @@
|
46
|
46
|
#define B_DW (BUTTON_DOWN<<B_I2C_BTN_OFFSET)
|
47
|
47
|
#define B_RI (BUTTON_RIGHT<<B_I2C_BTN_OFFSET)
|
48
|
48
|
|
49
|
|
- #if defined(BTN_ENC) && BTN_ENC > -1
|
|
49
|
+ #if defined(BTN_ENC) && BTN_ENC > -1
|
50
|
50
|
// the pause/stop/restart button is connected to BTN_ENC when used
|
51
|
|
- #define B_ST (EN_C) // Map the pause/stop/resume button into its normalized functional name
|
|
51
|
+ #define B_ST (EN_C) // Map the pause/stop/resume button into its normalized functional name
|
52
|
52
|
#define LCD_CLICKED (buttons&(B_MI|B_RI|B_ST)) // pause/stop button also acts as click until we implement proper pause/stop.
|
53
|
53
|
#else
|
54
|
54
|
#define LCD_CLICKED (buttons&(B_MI|B_RI))
|
55
|
|
- #endif
|
|
55
|
+ #endif
|
56
|
56
|
|
57
|
57
|
// I2C buttons take too long to read inside an interrupt context and so we read them during lcd_update
|
58
|
58
|
#define LCD_HAS_SLOW_BUTTONS
|
59
|
59
|
|
60
|
60
|
#elif defined(LCD_I2C_PANELOLU2)
|
61
|
61
|
// encoder click can be read through I2C if not directly connected
|
62
|
|
- #if BTN_ENC <= 0
|
|
62
|
+ #if BTN_ENC <= 0
|
63
|
63
|
#define B_I2C_BTN_OFFSET 3 // (the first three bit positions reserved for EN_A, EN_B, EN_C)
|
64
|
|
-
|
|
64
|
+
|
65
|
65
|
#define B_MI (PANELOLU2_ENCODER_C<<B_I2C_BTN_OFFSET) // requires LiquidTWI2 library v1.2.3 or later
|
66
|
66
|
|
67
|
67
|
#define LCD_CLICKED (buttons&B_MI)
|
|
@@ -69,7 +69,7 @@
|
69
|
69
|
// I2C buttons take too long to read inside an interrupt context and so we read them during lcd_update
|
70
|
70
|
#define LCD_HAS_SLOW_BUTTONS
|
71
|
71
|
#else
|
72
|
|
- #define LCD_CLICKED (buttons&EN_C)
|
|
72
|
+ #define LCD_CLICKED (buttons&EN_C)
|
73
|
73
|
#endif
|
74
|
74
|
|
75
|
75
|
#elif defined(REPRAPWORLD_KEYPAD)
|
|
@@ -101,7 +101,7 @@
|
101
|
101
|
|
102
|
102
|
#elif defined(NEWPANEL)
|
103
|
103
|
#define LCD_CLICKED (buttons&EN_C)
|
104
|
|
-
|
|
104
|
+
|
105
|
105
|
#else // old style ULTIPANEL
|
106
|
106
|
//bits in the shift register that carry the buttons for:
|
107
|
107
|
// left up center down right red(stop)
|
|
@@ -143,7 +143,7 @@
|
143
|
143
|
#include <LiquidCrystal_I2C.h>
|
144
|
144
|
#define LCD_CLASS LiquidCrystal_I2C
|
145
|
145
|
LCD_CLASS lcd(LCD_I2C_ADDRESS,LCD_I2C_PIN_EN,LCD_I2C_PIN_RW,LCD_I2C_PIN_RS,LCD_I2C_PIN_D4,LCD_I2C_PIN_D5,LCD_I2C_PIN_D6,LCD_I2C_PIN_D7);
|
146
|
|
-
|
|
146
|
+
|
147
|
147
|
#elif defined(LCD_I2C_TYPE_MCP23017)
|
148
|
148
|
//for the LED indicators (which maybe mapped to different things in lcd_implementation_update_indicators())
|
149
|
149
|
#define LED_A 0x04 //100
|
|
@@ -156,28 +156,28 @@
|
156
|
156
|
#include <LiquidTWI2.h>
|
157
|
157
|
#define LCD_CLASS LiquidTWI2
|
158
|
158
|
#if defined(DETECT_DEVICE)
|
159
|
|
- LCD_CLASS lcd(LCD_I2C_ADDRESS, 1);
|
|
159
|
+ LCD_CLASS lcd(LCD_I2C_ADDRESS, 1);
|
160
|
160
|
#else
|
161
|
|
- LCD_CLASS lcd(LCD_I2C_ADDRESS);
|
|
161
|
+ LCD_CLASS lcd(LCD_I2C_ADDRESS);
|
162
|
162
|
#endif
|
163
|
|
-
|
|
163
|
+
|
164
|
164
|
#elif defined(LCD_I2C_TYPE_MCP23008)
|
165
|
165
|
#include <Wire.h>
|
166
|
166
|
#include <LiquidTWI2.h>
|
167
|
167
|
#define LCD_CLASS LiquidTWI2
|
168
|
168
|
#if defined(DETECT_DEVICE)
|
169
|
|
- LCD_CLASS lcd(LCD_I2C_ADDRESS, 1);
|
|
169
|
+ LCD_CLASS lcd(LCD_I2C_ADDRESS, 1);
|
170
|
170
|
#else
|
171
|
|
- LCD_CLASS lcd(LCD_I2C_ADDRESS);
|
|
171
|
+ LCD_CLASS lcd(LCD_I2C_ADDRESS);
|
172
|
172
|
#endif
|
173
|
173
|
|
174
|
174
|
#elif defined(LCD_I2C_TYPE_PCA8574)
|
175
|
175
|
#include <LiquidCrystal_I2C.h>
|
176
|
176
|
#define LCD_CLASS LiquidCrystal_I2C
|
177
|
177
|
LCD_CLASS lcd(LCD_I2C_ADDRESS, LCD_WIDTH, LCD_HEIGHT);
|
178
|
|
-
|
|
178
|
+
|
179
|
179
|
// 2 wire Non-latching LCD SR from:
|
180
|
|
-// https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/schematics#!shiftregister-connection
|
|
180
|
+// https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/schematics#!shiftregister-connection
|
181
|
181
|
#elif defined(SR_LCD_2W_NL)
|
182
|
182
|
extern "C" void __cxa_pure_virtual() { while (1); }
|
183
|
183
|
#include <LCD.h>
|
|
@@ -353,65 +353,56 @@ static void lcd_implementation_init(
|
353
|
353
|
#endif
|
354
|
354
|
) {
|
355
|
355
|
|
356
|
|
-#if defined(LCD_I2C_TYPE_PCF8575)
|
|
356
|
+ #if defined(LCD_I2C_TYPE_PCF8575)
|
357
|
357
|
lcd.begin(LCD_WIDTH, LCD_HEIGHT);
|
358
|
|
- #ifdef LCD_I2C_PIN_BL
|
359
|
|
- lcd.setBacklightPin(LCD_I2C_PIN_BL,POSITIVE);
|
360
|
|
- lcd.setBacklight(HIGH);
|
361
|
|
- #endif
|
362
|
|
-
|
363
|
|
-#elif defined(LCD_I2C_TYPE_MCP23017)
|
|
358
|
+ #ifdef LCD_I2C_PIN_BL
|
|
359
|
+ lcd.setBacklightPin(LCD_I2C_PIN_BL, POSITIVE);
|
|
360
|
+ lcd.setBacklight(HIGH);
|
|
361
|
+ #endif
|
|
362
|
+
|
|
363
|
+ #elif defined(LCD_I2C_TYPE_MCP23017)
|
364
|
364
|
lcd.setMCPType(LTI_TYPE_MCP23017);
|
365
|
365
|
lcd.begin(LCD_WIDTH, LCD_HEIGHT);
|
366
|
366
|
lcd.setBacklight(0); //set all the LEDs off to begin with
|
367
|
|
-
|
368
|
|
-#elif defined(LCD_I2C_TYPE_MCP23008)
|
|
367
|
+
|
|
368
|
+ #elif defined(LCD_I2C_TYPE_MCP23008)
|
369
|
369
|
lcd.setMCPType(LTI_TYPE_MCP23008);
|
370
|
370
|
lcd.begin(LCD_WIDTH, LCD_HEIGHT);
|
371
|
371
|
|
372
|
|
-#elif defined(LCD_I2C_TYPE_PCA8574)
|
373
|
|
- lcd.init();
|
374
|
|
- lcd.backlight();
|
375
|
|
-
|
376
|
|
-#else
|
|
372
|
+ #elif defined(LCD_I2C_TYPE_PCA8574)
|
|
373
|
+ lcd.init();
|
|
374
|
+ lcd.backlight();
|
|
375
|
+
|
|
376
|
+ #else
|
377
|
377
|
lcd.begin(LCD_WIDTH, LCD_HEIGHT);
|
378
|
|
-#endif
|
|
378
|
+ #endif
|
379
|
379
|
|
380
|
|
- lcd_set_custom_characters(
|
381
|
|
- #ifdef LCD_PROGRESS_BAR
|
382
|
|
- progress_bar_set
|
383
|
|
- #endif
|
384
|
|
- );
|
|
380
|
+ lcd_set_custom_characters(
|
|
381
|
+ #ifdef LCD_PROGRESS_BAR
|
|
382
|
+ progress_bar_set
|
|
383
|
+ #endif
|
|
384
|
+ );
|
385
|
385
|
|
386
|
|
- lcd.clear();
|
387
|
|
-}
|
388
|
|
-static void lcd_implementation_clear()
|
389
|
|
-{
|
390
|
|
- lcd.clear();
|
|
386
|
+ lcd.clear();
|
391
|
387
|
}
|
392
|
388
|
|
|
389
|
+static void lcd_implementation_clear() { lcd.clear(); }
|
|
390
|
+
|
393
|
391
|
/* Arduino < 1.0.0 is missing a function to print PROGMEM strings, so we need to implement our own */
|
394
|
392
|
char lcd_printPGM(const char* str) {
|
395
|
|
- char c;
|
396
|
|
- char n = 0;
|
397
|
|
- while((c = pgm_read_byte(str++))) {
|
398
|
|
- n += charset_mapper(c);
|
399
|
|
- }
|
|
393
|
+ char c, n = 0;
|
|
394
|
+ while ((c = pgm_read_byte(str++))) n += charset_mapper(c);
|
400
|
395
|
return n;
|
401
|
396
|
}
|
402
|
397
|
|
403
|
398
|
char lcd_print(char* str) {
|
404
|
399
|
char c, n = 0;;
|
405
|
400
|
unsigned char i = 0;
|
406
|
|
- while((c = str[i++])) {
|
407
|
|
- n += charset_mapper(c);
|
408
|
|
- }
|
|
401
|
+ while ((c = str[i++])) n += charset_mapper(c);
|
409
|
402
|
return n;
|
410
|
403
|
}
|
411
|
404
|
|
412
|
|
-unsigned lcd_print(char c) {
|
413
|
|
- return charset_mapper(c);
|
414
|
|
-}
|
|
405
|
+unsigned lcd_print(char c) { return charset_mapper(c); }
|
415
|
406
|
|
416
|
407
|
/*
|
417
|
408
|
Possible status screens:
|
|
@@ -437,7 +428,7 @@ Possible status screens:
|
437
|
428
|
|
438
|
429
|
20x4 |01234567890123456789|
|
439
|
430
|
|T000/000D B000/000D |
|
440
|
|
- |T000/000D Z000.0|
|
|
431
|
+ |T000/000D Z000.00 |
|
441
|
432
|
|F100% SD100% T--:--|
|
442
|
433
|
|Status line.........|
|
443
|
434
|
*/
|
|
@@ -728,13 +719,13 @@ static void lcd_implementation_drawmenu_sddirectory(bool sel, uint8_t row, const
|
728
|
719
|
|
729
|
720
|
static void lcd_implementation_update_indicators() {
|
730
|
721
|
#if defined(LCD_I2C_PANELOLU2) || defined(LCD_I2C_VIKI)
|
731
|
|
- //set the LEDS - referred to as backlights by the LiquidTWI2 library
|
|
722
|
+ // Set the LEDS - referred to as backlights by the LiquidTWI2 library
|
732
|
723
|
static uint8_t ledsprev = 0;
|
733
|
724
|
uint8_t leds = 0;
|
734
|
725
|
if (target_temperature_bed > 0) leds |= LED_A;
|
735
|
726
|
if (target_temperature[0] > 0) leds |= LED_B;
|
736
|
727
|
if (fanSpeed) leds |= LED_C;
|
737
|
|
- #if EXTRUDERS > 1
|
|
728
|
+ #if EXTRUDERS > 1
|
738
|
729
|
if (target_temperature[1] > 0) leds |= LED_C;
|
739
|
730
|
#endif
|
740
|
731
|
if (leds != ledsprev) {
|
|
@@ -766,4 +757,4 @@ static void lcd_implementation_drawmenu_sddirectory(bool sel, uint8_t row, const
|
766
|
757
|
|
767
|
758
|
#endif // LCD_HAS_SLOW_BUTTONS
|
768
|
759
|
|
769
|
|
-#endif //__ULTRALCD_IMPLEMENTATION_HITACHI_HD44780_H
|
|
760
|
+#endif // ULTRALCD_IMPLEMENTATION_HITACHI_HD44780_H
|