|
|
|
@ -6,12 +6,191 @@
|
|
|
|
|
* When selecting the rusian language, a slightly different LCD implementation is used to handle UTF8 characters.
|
|
|
|
|
**/
|
|
|
|
|
|
|
|
|
|
#if LANGUAGE_CHOICE == 6
|
|
|
|
|
#include "LiquidCrystalRus.h"
|
|
|
|
|
#define LCD_CLASS LiquidCrystalRus
|
|
|
|
|
#ifndef REPRAPWORLD_KEYPAD
|
|
|
|
|
extern volatile uint8_t buttons; //the last checked buttons in a bit array.
|
|
|
|
|
#else
|
|
|
|
|
#include <LiquidCrystal.h>
|
|
|
|
|
#define LCD_CLASS LiquidCrystal
|
|
|
|
|
extern volatile uint16_t buttons; //an extended version of the last checked buttons in a bit array.
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////
|
|
|
|
|
// Setup button and encode mappings for each panel (into 'buttons' variable)
|
|
|
|
|
//
|
|
|
|
|
// This is just to map common functions (across different panels) onto the same
|
|
|
|
|
// macro name. The mapping is independent of whether the button is directly connected or
|
|
|
|
|
// via a shift/i2c register.
|
|
|
|
|
|
|
|
|
|
#ifdef ULTIPANEL
|
|
|
|
|
// All Ultipanels might have an encoder - so this is always be mapped onto first two bits
|
|
|
|
|
#define BLEN_B 1
|
|
|
|
|
#define BLEN_A 0
|
|
|
|
|
|
|
|
|
|
#define EN_B (1<<BLEN_B) // The two encoder pins are connected through BTN_EN1 and BTN_EN2
|
|
|
|
|
#define EN_A (1<<BLEN_A)
|
|
|
|
|
|
|
|
|
|
#if defined(BTN_ENC) && BTN_ENC > -1
|
|
|
|
|
// encoder click is directly connected
|
|
|
|
|
#define BLEN_C 2
|
|
|
|
|
#define EN_C (1<<BLEN_C)
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Setup other button mappings of each panel
|
|
|
|
|
//
|
|
|
|
|
#if defined(LCD_I2C_VIKI)
|
|
|
|
|
#define B_I2C_BTN_OFFSET 3 // (the first three bit positions reserved for EN_A, EN_B, EN_C)
|
|
|
|
|
|
|
|
|
|
// button and encoder bit positions within 'buttons'
|
|
|
|
|
#define B_LE (BUTTON_LEFT<<B_I2C_BTN_OFFSET) // The remaining normalized buttons are all read via I2C
|
|
|
|
|
#define B_UP (BUTTON_UP<<B_I2C_BTN_OFFSET)
|
|
|
|
|
#define B_MI (BUTTON_SELECT<<B_I2C_BTN_OFFSET)
|
|
|
|
|
#define B_DW (BUTTON_DOWN<<B_I2C_BTN_OFFSET)
|
|
|
|
|
#define B_RI (BUTTON_RIGHT<<B_I2C_BTN_OFFSET)
|
|
|
|
|
|
|
|
|
|
#if defined(BTN_ENC) && BTN_ENC > -1
|
|
|
|
|
// the pause/stop/restart button is connected to BTN_ENC when used
|
|
|
|
|
#define B_ST (EN_C) // Map the pause/stop/resume button into its normalized functional name
|
|
|
|
|
#define LCD_CLICKED (buttons&(B_MI|B_RI|B_ST)) // pause/stop button also acts as click until we implement proper pause/stop.
|
|
|
|
|
#else
|
|
|
|
|
#define LCD_CLICKED (buttons&(B_MI|B_RI))
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
// I2C buttons take too long to read inside an interrupt context and so we read them during lcd_update
|
|
|
|
|
#define LCD_HAS_SLOW_BUTTONS
|
|
|
|
|
|
|
|
|
|
#elif defined(LCD_I2C_PANELOLU2)
|
|
|
|
|
// encoder click can be read through I2C if not directly connected
|
|
|
|
|
#if BTN_ENC <= 0
|
|
|
|
|
#define B_I2C_BTN_OFFSET 3 // (the first three bit positions reserved for EN_A, EN_B, EN_C)
|
|
|
|
|
|
|
|
|
|
#define B_MI (PANELOLU2_ENCODER_C<<B_I2C_BTN_OFFSET) // requires LiquidTWI2 library v1.2.3 or later
|
|
|
|
|
|
|
|
|
|
#define LCD_CLICKED (buttons&B_MI)
|
|
|
|
|
|
|
|
|
|
// I2C buttons take too long to read inside an interrupt context and so we read them during lcd_update
|
|
|
|
|
#define LCD_HAS_SLOW_BUTTONS
|
|
|
|
|
#else
|
|
|
|
|
#define LCD_CLICKED (buttons&EN_C)
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#elif defined(REPRAPWORLD_KEYPAD)
|
|
|
|
|
// define register bit values, don't change it
|
|
|
|
|
#define BLEN_REPRAPWORLD_KEYPAD_F3 0
|
|
|
|
|
#define BLEN_REPRAPWORLD_KEYPAD_F2 1
|
|
|
|
|
#define BLEN_REPRAPWORLD_KEYPAD_F1 2
|
|
|
|
|
#define BLEN_REPRAPWORLD_KEYPAD_UP 3
|
|
|
|
|
#define BLEN_REPRAPWORLD_KEYPAD_RIGHT 4
|
|
|
|
|
#define BLEN_REPRAPWORLD_KEYPAD_MIDDLE 5
|
|
|
|
|
#define BLEN_REPRAPWORLD_KEYPAD_DOWN 6
|
|
|
|
|
#define BLEN_REPRAPWORLD_KEYPAD_LEFT 7
|
|
|
|
|
|
|
|
|
|
#define REPRAPWORLD_BTN_OFFSET 3 // bit offset into buttons for shift register values
|
|
|
|
|
|
|
|
|
|
#define EN_REPRAPWORLD_KEYPAD_F3 (1<<(BLEN_REPRAPWORLD_KEYPAD_F3+REPRAPWORLD_BTN_OFFSET))
|
|
|
|
|
#define EN_REPRAPWORLD_KEYPAD_F2 (1<<(BLEN_REPRAPWORLD_KEYPAD_F2+REPRAPWORLD_BTN_OFFSET))
|
|
|
|
|
#define EN_REPRAPWORLD_KEYPAD_F1 (1<<(BLEN_REPRAPWORLD_KEYPAD_F1+REPRAPWORLD_BTN_OFFSET))
|
|
|
|
|
#define EN_REPRAPWORLD_KEYPAD_UP (1<<(BLEN_REPRAPWORLD_KEYPAD_UP+REPRAPWORLD_BTN_OFFSET))
|
|
|
|
|
#define EN_REPRAPWORLD_KEYPAD_RIGHT (1<<(BLEN_REPRAPWORLD_KEYPAD_RIGHT+REPRAPWORLD_BTN_OFFSET))
|
|
|
|
|
#define EN_REPRAPWORLD_KEYPAD_MIDDLE (1<<(BLEN_REPRAPWORLD_KEYPAD_MIDDLE+REPRAPWORLD_BTN_OFFSET))
|
|
|
|
|
#define EN_REPRAPWORLD_KEYPAD_DOWN (1<<(BLEN_REPRAPWORLD_KEYPAD_DOWN+REPRAPWORLD_BTN_OFFSET))
|
|
|
|
|
#define EN_REPRAPWORLD_KEYPAD_LEFT (1<<(BLEN_REPRAPWORLD_KEYPAD_LEFT+REPRAPWORLD_BTN_OFFSET))
|
|
|
|
|
|
|
|
|
|
#define LCD_CLICKED ((buttons&EN_C) || (buttons&EN_REPRAPWORLD_KEYPAD_F1))
|
|
|
|
|
#define REPRAPWORLD_KEYPAD_MOVE_Y_DOWN (buttons&EN_REPRAPWORLD_KEYPAD_DOWN)
|
|
|
|
|
#define REPRAPWORLD_KEYPAD_MOVE_Y_UP (buttons&EN_REPRAPWORLD_KEYPAD_UP)
|
|
|
|
|
#define REPRAPWORLD_KEYPAD_MOVE_HOME (buttons&EN_REPRAPWORLD_KEYPAD_MIDDLE)
|
|
|
|
|
|
|
|
|
|
#elif defined(NEWPANEL)
|
|
|
|
|
#define LCD_CLICKED (buttons&EN_C)
|
|
|
|
|
|
|
|
|
|
#else // old style ULTIPANEL
|
|
|
|
|
//bits in the shift register that carry the buttons for:
|
|
|
|
|
// left up center down right red(stop)
|
|
|
|
|
#define BL_LE 7
|
|
|
|
|
#define BL_UP 6
|
|
|
|
|
#define BL_MI 5
|
|
|
|
|
#define BL_DW 4
|
|
|
|
|
#define BL_RI 3
|
|
|
|
|
#define BL_ST 2
|
|
|
|
|
|
|
|
|
|
//automatic, do not change
|
|
|
|
|
#define B_LE (1<<BL_LE)
|
|
|
|
|
#define B_UP (1<<BL_UP)
|
|
|
|
|
#define B_MI (1<<BL_MI)
|
|
|
|
|
#define B_DW (1<<BL_DW)
|
|
|
|
|
#define B_RI (1<<BL_RI)
|
|
|
|
|
#define B_ST (1<<BL_ST)
|
|
|
|
|
|
|
|
|
|
#define LCD_CLICKED (buttons&(B_MI|B_ST))
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
////////////////////////
|
|
|
|
|
// Setup Rotary Encoder Bit Values (for two pin encoders to indicate movement)
|
|
|
|
|
// These values are independent of which pins are used for EN_A and EN_B indications
|
|
|
|
|
// The rotary encoder part is also independent to the chipset used for the LCD
|
|
|
|
|
#if defined(EN_A) && defined(EN_B)
|
|
|
|
|
#ifndef ULTIMAKERCONTROLLER
|
|
|
|
|
#define encrot0 0
|
|
|
|
|
#define encrot1 2
|
|
|
|
|
#define encrot2 3
|
|
|
|
|
#define encrot3 1
|
|
|
|
|
#else
|
|
|
|
|
#define encrot0 0
|
|
|
|
|
#define encrot1 1
|
|
|
|
|
#define encrot2 3
|
|
|
|
|
#define encrot3 2
|
|
|
|
|
#endif
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#endif //ULTIPANEL
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////
|
|
|
|
|
// Create LCD class instance and chipset-specific information
|
|
|
|
|
#if defined(LCD_I2C_TYPE_PCF8575)
|
|
|
|
|
// note: these are register mapped pins on the PCF8575 controller not Arduino pins
|
|
|
|
|
#define LCD_I2C_PIN_BL 3
|
|
|
|
|
#define LCD_I2C_PIN_EN 2
|
|
|
|
|
#define LCD_I2C_PIN_RW 1
|
|
|
|
|
#define LCD_I2C_PIN_RS 0
|
|
|
|
|
#define LCD_I2C_PIN_D4 4
|
|
|
|
|
#define LCD_I2C_PIN_D5 5
|
|
|
|
|
#define LCD_I2C_PIN_D6 6
|
|
|
|
|
#define LCD_I2C_PIN_D7 7
|
|
|
|
|
|
|
|
|
|
#include <Wire.h>
|
|
|
|
|
#include <LCD.h>
|
|
|
|
|
#include <LiquidCrystal_I2C.h>
|
|
|
|
|
#define LCD_CLASS LiquidCrystal_I2C
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
#elif defined(LCD_I2C_TYPE_MCP23017)
|
|
|
|
|
//for the LED indicators (which maybe mapped to different things in lcd_implementation_update_indicators())
|
|
|
|
|
#define LED_A 0x04 //100
|
|
|
|
|
#define LED_B 0x02 //010
|
|
|
|
|
#define LED_C 0x01 //001
|
|
|
|
|
|
|
|
|
|
#define LCD_HAS_STATUS_INDICATORS
|
|
|
|
|
|
|
|
|
|
#include <Wire.h>
|
|
|
|
|
#include <LiquidTWI2.h>
|
|
|
|
|
#define LCD_CLASS LiquidTWI2
|
|
|
|
|
LCD_CLASS lcd(LCD_I2C_ADDRESS);
|
|
|
|
|
|
|
|
|
|
#elif defined(LCD_I2C_TYPE_MCP23008)
|
|
|
|
|
#include <Wire.h>
|
|
|
|
|
#include <LiquidTWI2.h>
|
|
|
|
|
#define LCD_CLASS LiquidTWI2
|
|
|
|
|
LCD_CLASS lcd(LCD_I2C_ADDRESS);
|
|
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
// Standard directly connected LCD implementations
|
|
|
|
|
#if LANGUAGE_CHOICE == 6
|
|
|
|
|
#include "LiquidCrystalRus.h"
|
|
|
|
|
#define LCD_CLASS LiquidCrystalRus
|
|
|
|
|
#else
|
|
|
|
|
#include <LiquidCrystal.h>
|
|
|
|
|
#define LCD_CLASS LiquidCrystal
|
|
|
|
|
#endif
|
|
|
|
|
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
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/* Custom characters defined in the first 8 characters of the LCD */
|
|
|
|
@ -25,7 +204,6 @@
|
|
|
|
|
#define LCD_STR_CLOCK "\x07"
|
|
|
|
|
#define LCD_STR_ARROW_RIGHT "\x7E" /* from the default character set */
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
static void lcd_implementation_init()
|
|
|
|
|
{
|
|
|
|
|
byte bedTemp[8] =
|
|
|
|
@ -111,7 +289,27 @@ static void lcd_implementation_init()
|
|
|
|
|
B00000,
|
|
|
|
|
B00000
|
|
|
|
|
}; //thanks Sonny Mounicou
|
|
|
|
|
|
|
|
|
|
#if defined(LCDI2C_TYPE_PCF8575)
|
|
|
|
|
lcd.begin(LCD_WIDTH, LCD_HEIGHT);
|
|
|
|
|
#ifdef LCD_I2C_PIN_BL
|
|
|
|
|
lcd.setBacklightPin(LCD_I2C_PIN_BL,POSITIVE);
|
|
|
|
|
lcd.setBacklight(HIGH);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#elif defined(LCD_I2C_TYPE_MCP23017)
|
|
|
|
|
lcd.setMCPType(LTI_TYPE_MCP23017);
|
|
|
|
|
lcd.begin(LCD_WIDTH, LCD_HEIGHT);
|
|
|
|
|
lcd.setBacklight(0); //set all the LEDs off to begin with
|
|
|
|
|
|
|
|
|
|
#elif defined(LCD_I2C_TYPE_MCP23008)
|
|
|
|
|
lcd.setMCPType(LTI_TYPE_MCP23008);
|
|
|
|
|
lcd.begin(LCD_WIDTH, LCD_HEIGHT);
|
|
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
lcd.begin(LCD_WIDTH, LCD_HEIGHT);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
lcd.createChar(LCD_STR_BEDTEMP[0], bedTemp);
|
|
|
|
|
lcd.createChar(LCD_STR_DEGREE[0], degree);
|
|
|
|
|
lcd.createChar(LCD_STR_THERMOMETER[0], thermometer);
|
|
|
|
@ -501,7 +699,9 @@ static void lcd_implementation_drawmenu_sddirectory(uint8_t row, const char* pst
|
|
|
|
|
|
|
|
|
|
static void lcd_implementation_quick_feedback()
|
|
|
|
|
{
|
|
|
|
|
#if BEEPER > -1
|
|
|
|
|
#ifdef LCD_USE_I2C_BUZZER
|
|
|
|
|
lcd.buzz(60,1000/6);
|
|
|
|
|
#elif defined(BEEPER) && BEEPER > -1
|
|
|
|
|
SET_OUTPUT(BEEPER);
|
|
|
|
|
for(int8_t i=0;i<10;i++)
|
|
|
|
|
{
|
|
|
|
@ -512,4 +712,37 @@ static void lcd_implementation_quick_feedback()
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#ifdef LCD_HAS_STATUS_INDICATORS
|
|
|
|
|
static void lcd_implementation_update_indicators()
|
|
|
|
|
{
|
|
|
|
|
#if defined(LCD_I2C_PANELOLU2) || defined(LCD_I2C_VIKI)
|
|
|
|
|
//set the LEDS - referred to as backlights by the LiquidTWI2 library
|
|
|
|
|
static uint8_t ledsprev = 0;
|
|
|
|
|
uint8_t leds = 0;
|
|
|
|
|
if (target_temperature_bed > 0) leds |= LED_A;
|
|
|
|
|
if (target_temperature[0] > 0) leds |= LED_B;
|
|
|
|
|
if (fanSpeed) leds |= LED_C;
|
|
|
|
|
#if EXTRUDERS > 1
|
|
|
|
|
if (target_temperature[1] > 0) leds |= LED_C;
|
|
|
|
|
#endif
|
|
|
|
|
if (leds != ledsprev) {
|
|
|
|
|
lcd.setBacklight(leds);
|
|
|
|
|
ledsprev = leds;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef LCD_HAS_SLOW_BUTTONS
|
|
|
|
|
static uint8_t lcd_implementation_read_slow_buttons()
|
|
|
|
|
{
|
|
|
|
|
#ifdef LCD_I2C_TYPE_MCP23017
|
|
|
|
|
// Reading these buttons this is likely to be too slow to call inside interrupt context
|
|
|
|
|
// so they are called during normal lcd_update
|
|
|
|
|
return lcd.readButtons() << B_I2C_BTN_OFFSET;
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#endif//ULTRA_LCD_IMPLEMENTATION_HITACHI_HD44780_H
|
|
|
|
|