Overlord i2c LCD with LEDs and buzzer (#14801)
This commit is contained in:
		
				
					committed by
					
						
						Scott Lahteine
					
				
			
			
				
	
			
			
			
						parent
						
							e1942715ce
						
					
				
				
					commit
					940c59d9da
				
			@@ -2014,6 +2014,11 @@
 | 
			
		||||
//
 | 
			
		||||
//#define U8GLIB_SH1106_EINSTART
 | 
			
		||||
 | 
			
		||||
//
 | 
			
		||||
// Overlord OLED display/controller with i2c buzzer and LEDs
 | 
			
		||||
//
 | 
			
		||||
//#define OVERLORD_OLED
 | 
			
		||||
 | 
			
		||||
//=============================================================================
 | 
			
		||||
//========================== Extensible UI Displays ===========================
 | 
			
		||||
//=============================================================================
 | 
			
		||||
 
 | 
			
		||||
@@ -58,12 +58,21 @@
 | 
			
		||||
#define PCA9632_AUTOGLO     0xC0
 | 
			
		||||
#define PCA9632_AUTOGI      0xE0
 | 
			
		||||
 | 
			
		||||
// Red   LED0
 | 
			
		||||
// Green LED1
 | 
			
		||||
// Blue  LED2
 | 
			
		||||
#define PCA9632_RED     0x00
 | 
			
		||||
#define PCA9632_GRN     0x02
 | 
			
		||||
#define PCA9632_BLU     0x04
 | 
			
		||||
// Red=LED0   Green=LED1   Blue=LED2
 | 
			
		||||
#ifndef PCA9632_RED
 | 
			
		||||
  #define PCA9632_RED 0x00
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef PCA9632_GRN
 | 
			
		||||
  #define PCA9632_GRN 0x02
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef PCA9632_BLU
 | 
			
		||||
  #define PCA9632_BLU 0x04
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
// If any of the color indexes are greater than 0x04 they can't use auto increment
 | 
			
		||||
#if !defined(PCA9632_NO_AUTO_INC) && (PCA9632_RED > 0x04 || PCA9632_GRN > 0x04 || PCA9632_BLU > 0x04)
 | 
			
		||||
  #define PCA9632_NO_AUTO_INC
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#define LED_OFF   0x00
 | 
			
		||||
#define LED_ON    0x01
 | 
			
		||||
@@ -80,12 +89,24 @@ static void PCA9632_WriteRegister(const byte addr, const byte regadd, const byte
 | 
			
		||||
  Wire.endTransmission();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void PCA9632_WriteAllRegisters(const byte addr, const byte regadd, const byte value1, const byte value2, const byte value3) {
 | 
			
		||||
static void PCA9632_WriteAllRegisters(const byte addr, const byte regadd, const byte vr, const byte vg, const byte vb) {
 | 
			
		||||
  #if DISABLED(PCA9632_NO_AUTO_INC)
 | 
			
		||||
    uint8_t data[4], len = 4;
 | 
			
		||||
    data[0] = PCA9632_AUTO_IND | regadd;
 | 
			
		||||
    data[1 + (PCA9632_RED >> 1)] = vr;
 | 
			
		||||
    data[1 + (PCA9632_GRN >> 1)] = vg;
 | 
			
		||||
    data[1 + (PCA9632_BLU >> 1)] = vb;
 | 
			
		||||
  #else
 | 
			
		||||
    uint8_t data[6], len = 6;
 | 
			
		||||
    data[0] = regadd + (PCA9632_RED >> 1);
 | 
			
		||||
    data[1] = vr;
 | 
			
		||||
    data[2] = regadd + (PCA9632_GRN >> 1);
 | 
			
		||||
    data[3] = vg;
 | 
			
		||||
    data[4] = regadd + (PCA9632_BLU >> 1);
 | 
			
		||||
    data[5] = vb;
 | 
			
		||||
  #endif
 | 
			
		||||
  Wire.beginTransmission(I2C_ADDRESS(addr));
 | 
			
		||||
  Wire.write(PCA9632_AUTO_IND | regadd);
 | 
			
		||||
  Wire.write(value1);
 | 
			
		||||
  Wire.write(value2);
 | 
			
		||||
  Wire.write(value3);
 | 
			
		||||
  Wire.write(data, len);
 | 
			
		||||
  Wire.endTransmission();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -115,4 +136,14 @@ void pca9632_set_led_color(const LEDColor &color) {
 | 
			
		||||
  PCA9632_WriteRegister(PCA9632_ADDRESS,PCA9632_LEDOUT, LEDOUT);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#if ENABLED(PCA9632_BUZZER)
 | 
			
		||||
  void pca9632_buzz(uint16_t const f, uint16_t d) {
 | 
			
		||||
    UNUSED(f); UNUSED(d);
 | 
			
		||||
    uint8_t data[] = PCA9632_BUZZER_DATA;
 | 
			
		||||
    Wire.beginTransmission(I2C_ADDRESS(PCA9632_ADDRESS));
 | 
			
		||||
    Wire.write(data, sizeof(data));
 | 
			
		||||
    Wire.endTransmission();
 | 
			
		||||
  }
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#endif // PCA9632
 | 
			
		||||
 
 | 
			
		||||
@@ -30,3 +30,7 @@ struct LEDColor;
 | 
			
		||||
typedef LEDColor LEDColor;
 | 
			
		||||
 | 
			
		||||
void pca9632_set_led_color(const LEDColor &color);
 | 
			
		||||
 | 
			
		||||
#if ENABLED(PCA9632_BUZZER)
 | 
			
		||||
  void pca9632_buzz(uint16_t const, uint16_t);
 | 
			
		||||
#endif
 | 
			
		||||
 
 | 
			
		||||
@@ -163,6 +163,7 @@
 | 
			
		||||
 | 
			
		||||
#elif ENABLED(ULTI_CONTROLLER)
 | 
			
		||||
 | 
			
		||||
  #define IS_ULTIPANEL
 | 
			
		||||
  #define U8GLIB_SSD1309
 | 
			
		||||
  #define LCD_RESET_PIN LCD_PINS_D6 //  This controller need a reset pin
 | 
			
		||||
  #define LCD_CONTRAST_MIN 0
 | 
			
		||||
@@ -198,6 +199,24 @@
 | 
			
		||||
  #define U8GLIB_SSD1306
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#if ENABLED(OVERLORD_OLED)
 | 
			
		||||
  #define IS_ULTIPANEL
 | 
			
		||||
  #define U8GLIB_SH1106
 | 
			
		||||
  /**
 | 
			
		||||
   * PCA9632 for buzzer and LEDs via i2c
 | 
			
		||||
   * No auto-inc, red and green leds switched, buzzer
 | 
			
		||||
   */
 | 
			
		||||
  #define PCA9632
 | 
			
		||||
  #define PCA9632_NO_AUTO_INC
 | 
			
		||||
  #define PCA9632_GRN         0x00
 | 
			
		||||
  #define PCA9632_RED         0x02
 | 
			
		||||
  #define PCA9632_BUZZER
 | 
			
		||||
  #define PCA9632_BUZZER_DATA { 0x09, 0x02 }
 | 
			
		||||
 | 
			
		||||
  #define ENCODER_PULSES_PER_STEP     1 // Overlord uses buttons
 | 
			
		||||
  #define ENCODER_STEPS_PER_MENU_ITEM 1
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
// 128x64 I2C OLED LCDs - SSD1306/SSD1309/SH1106
 | 
			
		||||
#define HAS_SSD1306_OLED_I2C ANY(U8GLIB_SSD1306, U8GLIB_SSD1309, U8GLIB_SH1106)
 | 
			
		||||
#if HAS_SSD1306_OLED_I2C
 | 
			
		||||
@@ -205,41 +224,42 @@
 | 
			
		||||
  #define DOGLCD
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
// ST7920-based graphical displays
 | 
			
		||||
#if ANY(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER, LCD_FOR_MELZI, SILVER_GATE_GLCD_CONTROLLER)
 | 
			
		||||
  #define DOGLCD
 | 
			
		||||
  #define U8GLIB_ST7920
 | 
			
		||||
  #define IS_RRD_SC
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
// RepRapDiscount LCD or Graphical LCD with rotary click encoder
 | 
			
		||||
#if ENABLED(IS_RRD_SC)
 | 
			
		||||
  #define REPRAP_DISCOUNT_SMART_CONTROLLER
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#if ANY(ULTIMAKERCONTROLLER, REPRAP_DISCOUNT_SMART_CONTROLLER, G3D_PANEL, RIGIDBOT_PANEL, ULTI_CONTROLLER, PANEL_ONE, U8GLIB_SH1106)
 | 
			
		||||
/**
 | 
			
		||||
 * SPI Ultipanels
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
// Basic Ultipanel-like displays
 | 
			
		||||
#if ANY(ULTIMAKERCONTROLLER, REPRAP_DISCOUNT_SMART_CONTROLLER, G3D_PANEL, RIGIDBOT_PANEL, PANEL_ONE, U8GLIB_SH1106)
 | 
			
		||||
  #define IS_ULTIPANEL
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * SPI PANELS
 | 
			
		||||
 */
 | 
			
		||||
// Einstart OLED has Cardinal nav via pins defined in pins_EINSTART-S.h
 | 
			
		||||
#if ENABLED(U8GLIB_SH1106_EINSTART)
 | 
			
		||||
  #define DOGLCD
 | 
			
		||||
  #define IS_ULTIPANEL
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
 // Einstart OLED has Cardinal nav via pins defined in pins_EINSTART-S.h
 | 
			
		||||
 #if ENABLED(U8GLIB_SH1106_EINSTART)
 | 
			
		||||
   #define DOGLCD
 | 
			
		||||
   #define IS_ULTIPANEL
 | 
			
		||||
 #endif
 | 
			
		||||
 | 
			
		||||
 /**
 | 
			
		||||
  * FSMC/SPI TFT PANELS
 | 
			
		||||
  */
 | 
			
		||||
 #if ENABLED(FSMC_GRAPHICAL_TFT)
 | 
			
		||||
   #define DOGLCD
 | 
			
		||||
   #define IS_ULTIPANEL
 | 
			
		||||
   #define DELAYED_BACKLIGHT_INIT
 | 
			
		||||
 #endif
 | 
			
		||||
// FSMC/SPI TFT Panels
 | 
			
		||||
#if ENABLED(FSMC_GRAPHICAL_TFT)
 | 
			
		||||
  #define DOGLCD
 | 
			
		||||
  #define IS_ULTIPANEL
 | 
			
		||||
  #define DELAYED_BACKLIGHT_INIT
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * I2C PANELS
 | 
			
		||||
 * I2C Panels
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#if EITHER(LCD_SAINSMART_I2C_1602, LCD_SAINSMART_I2C_2004)
 | 
			
		||||
 
 | 
			
		||||
@@ -1024,7 +1024,7 @@
 | 
			
		||||
#define HAS_KILL        (PIN_EXISTS(KILL))
 | 
			
		||||
#define HAS_SUICIDE     (PIN_EXISTS(SUICIDE))
 | 
			
		||||
#define HAS_PHOTOGRAPH  (PIN_EXISTS(PHOTOGRAPH))
 | 
			
		||||
#define HAS_BUZZER      (PIN_EXISTS(BEEPER) || ENABLED(LCD_USE_I2C_BUZZER))
 | 
			
		||||
#define HAS_BUZZER      (PIN_EXISTS(BEEPER) || ENABLED(LCD_USE_I2C_BUZZER) || ENABLED(PCA9632_BUZZER))
 | 
			
		||||
#define HAS_CASE_LIGHT  (PIN_EXISTS(CASE_LIGHT) && ENABLED(CASE_LIGHT_ENABLE))
 | 
			
		||||
 | 
			
		||||
// Digital control
 | 
			
		||||
 
 | 
			
		||||
@@ -1889,6 +1889,7 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS
 | 
			
		||||
  + ENABLED(MKS_12864OLED) \
 | 
			
		||||
  + ENABLED(MKS_12864OLED_SSD1306) \
 | 
			
		||||
  + ENABLED(U8GLIB_SH1106_EINSTART) \
 | 
			
		||||
  + ENABLED(OVERLORD_OLED) \
 | 
			
		||||
  + ENABLED(DGUS_LCD) \
 | 
			
		||||
  + ENABLED(MALYAN_LCD) \
 | 
			
		||||
  + ENABLED(FSMC_GRAPHICAL_TFT)
 | 
			
		||||
 
 | 
			
		||||
@@ -264,6 +264,8 @@ public:
 | 
			
		||||
        lcd.buzz(duration, freq);
 | 
			
		||||
      #elif PIN_EXISTS(BEEPER)
 | 
			
		||||
        buzzer.tone(duration, freq);
 | 
			
		||||
      #elif ENABLED(PCA9632_BUZZER)
 | 
			
		||||
        pca9632_buzz(duration, freq);
 | 
			
		||||
      #endif
 | 
			
		||||
    }
 | 
			
		||||
  #endif
 | 
			
		||||
 
 | 
			
		||||
@@ -119,19 +119,23 @@
 | 
			
		||||
//
 | 
			
		||||
// LCD / Controller
 | 
			
		||||
//
 | 
			
		||||
#define BTN_ENC            16   // Enter Pin
 | 
			
		||||
#define BTN_UP             19   // Button UP Pin
 | 
			
		||||
#define BTN_DWN            17   // Button DOWN Pin
 | 
			
		||||
#if HAS_GRAPHICAL_LCD
 | 
			
		||||
  // OVERLORD OLED pins
 | 
			
		||||
  #define LCD_PINS_RS      20
 | 
			
		||||
  #define LCD_PINS_D5      21
 | 
			
		||||
  #define LCD_PINS_ENABLE  15
 | 
			
		||||
  #define LCD_PINS_D4      14
 | 
			
		||||
  #define LCD_PINS_D6       5
 | 
			
		||||
  #define LCD_PINS_D7       6
 | 
			
		||||
  #ifndef LCD_RESET_PIN
 | 
			
		||||
    #define LCD_RESET_PIN   5   // LCD_PINS_D6
 | 
			
		||||
  #endif
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
// OVERLORD OLED PINS
 | 
			
		||||
#define LCD_PINS_RS        20
 | 
			
		||||
#define LCD_PINS_D5        21
 | 
			
		||||
#define LCD_PINS_ENABLE    15
 | 
			
		||||
#define LCD_PINS_D4        14
 | 
			
		||||
#define LCD_PINS_D6         5
 | 
			
		||||
#define LCD_PINS_D7         6
 | 
			
		||||
#ifndef LCD_RESET_PIN
 | 
			
		||||
  #define LCD_RESET_PIN     5   // LCD_PINS_D6
 | 
			
		||||
#if ENABLED(NEWPANEL)
 | 
			
		||||
  #define BTN_ENC          16   // Enter Pin
 | 
			
		||||
  #define BTN_UP           19   // Button UP Pin
 | 
			
		||||
  #define BTN_DWN          17   // Button DOWN Pin
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
// Additional connectors/pins on the Overlord V1.X board
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user