diff --git a/k3ng_rotator_controller/k3ng_rotator_controller.ino b/k3ng_rotator_controller/k3ng_rotator_controller.ino index 4b7367e..c2cd28f 100644 --- a/k3ng_rotator_controller/k3ng_rotator_controller.ino +++ b/k3ng_rotator_controller/k3ng_rotator_controller.ino @@ -1136,6 +1136,8 @@ using https://github.com/adafruit/Adafruit_SSD1306 #include "rotator_dependencies.h" +#include + #ifdef FEATURE_4_BIT_LCD_DISPLAY #include // required for classic 4 bit interface LCD display (FEATURE_4_BIT_LCD_DISPLAY) #endif @@ -11029,8 +11031,13 @@ void initialize_peripherals(){ control_port->flush(); #endif // DEBUG_LOOP + Wire.setSDA(20); + Wire.setSCL(21); + #ifdef FEATURE_WIRE_SUPPORT - Wire.begin(); + + + // Wire.begin(); #endif #ifdef FEATURE_AZ_POSITION_HMC5883L diff --git a/k3ng_rotator_controller/rotator_features.h b/k3ng_rotator_controller/rotator_features.h old mode 100755 new mode 100644 index 72d2106..d357c5a --- a/k3ng_rotator_controller/rotator_features.h +++ b/k3ng_rotator_controller/rotator_features.h @@ -77,7 +77,7 @@ // #define FEATURE_EL_POSITION_A2_ABSOLUTE_ENCODER // And if you are using any display other than a 4 bit LCD, you must also change the feature setting in rotator_k3ngdisplay.h!!!! -// #define FEATURE_4_BIT_LCD_DISPLAY // Uncomment for classic 4 bit LCD display (most common) +#define FEATURE_4_BIT_LCD_DISPLAY // Uncomment for classic 4 bit LCD display (most common) // #define FEATURE_ADAFRUIT_I2C_LCD // #define FEATURE_ADAFRUIT_BUTTONS // Uncomment this to use Adafruit I2C LCD buttons for manual AZ/EL instead of normal buttons (also set this feature in rotator_k3ngdisplay.h) // #define FEATURE_YOURDUINO_I2C_LCD @@ -195,4 +195,4 @@ // #define OPTION_DEPRECATED_NEXTION_INIT_CODE_1 // use only with VK4GHZ Nextion firmware versions previous to 2021-10-23 // #define OPTION_DEPRECATED_NEXTION_INIT_CODE_2 // use only with VK4GHZ Nextion firmware versions previous to 2021-10-23 -// #define OPTION_SEND_NEXTION_RESET_AT_BOOTUP // not for use with OPTION_DEPRECATED_NEXTION_INIT_CODE_1 or OPTION_DEPRECATED_NEXTION_INIT_CODE_2 above \ No newline at end of file +// #define OPTION_SEND_NEXTION_RESET_AT_BOOTUP // not for use with OPTION_DEPRECATED_NEXTION_INIT_CODE_1 or OPTION_DEPRECATED_NEXTION_INIT_CODE_2 above diff --git a/k3ng_rotator_controller/rotator_k3ngdisplay.cpp b/k3ng_rotator_controller/rotator_k3ngdisplay.cpp index 171b60b..875ce59 100644 --- a/k3ng_rotator_controller/rotator_k3ngdisplay.cpp +++ b/k3ng_rotator_controller/rotator_k3ngdisplay.cpp @@ -13,8 +13,8 @@ #include "rotator_k3ngdisplay.h" #ifdef FEATURE_4_BIT_LCD_DISPLAY - #include - LiquidCrystal lcd(lcd_4_bit_rs_pin, lcd_4_bit_enable_pin, lcd_4_bit_d4_pin, lcd_4_bit_d5_pin, lcd_4_bit_d6_pin, lcd_4_bit_d7_pin); + //#include + //LiquidCrystal lcd(lcd_4_bit_rs_pin, lcd_4_bit_enable_pin, lcd_4_bit_d4_pin, lcd_4_bit_d5_pin, lcd_4_bit_d6_pin, lcd_4_bit_d7_pin); #endif // FEATURE_4_BIT_LCD_DISPLAY #ifdef FEATURE_WIRE_SUPPORT @@ -44,6 +44,10 @@ #include // i2c expander i/o class header #endif +#include + +#include + #if defined(FEATURE_YOURDUINO_I2C_LCD) #define I2C_ADDR 0x20 @@ -126,8 +130,37 @@ K3NGdisplay::K3NGdisplay(int _display_columns, int _display_rows, int _update_ti //----------------------------------------------------------------------------------------------------- + +#define SCREEN_WIDTH 128 // OLED display width, in pixels +#define SCREEN_HEIGHT 64 // OLED display height, in pixels + +// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins) +// The pins for I2C are defined by the Wire-library. +// On an arduino UNO: A4(SDA), A5(SCL) +// On an arduino MEGA 2560: 20(SDA), 21(SCL) +// On an arduino LEONARDO: 2(SDA), 3(SCL), ... +#define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin) +#define SCREEN_ADDRESS 0x3C ///< See datasheet for Address; 0x3D for 128x64, 0x3C for 128x32 +Adafruit_SSD1306 lcd(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET); + void K3NGdisplay::initialize(){ + //Serial.begin(9600); + + + // SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally + if(!lcd.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) { + Serial.println(F("SSD1306 allocation failed")); + for(;;); // Don't proceed, loop forever + } else { + + Serial.println(F("SSD1306 OK")); + + + } + +/* + #if !defined(FEATURE_MIDAS_I2C_DISPLAY) lcd.begin(display_columns, display_rows); // if you are getting an error on this line and do not have // any of the LCD display features enabled, remove @@ -165,13 +198,47 @@ void K3NGdisplay::initialize(){ clear(); + */ + + lcd.display(); + delay(2000); // Pause for 2 seconds + + + Serial.println("Display 2()"); + Serial.flush(); + + // Clear the buffer + lcd.clearDisplay(); + + // Draw a single pixel in white + lcd.drawPixel(10, 10, SSD1306_WHITE); + + // Show the display buffer on the screen. You MUST call display() after + // drawing commands to make them visible on screen! + lcd.display(); + delay(2000); + // display.display() is NOT necessary after every single drawing command, + // unless that's what you want...rather, you can batch up a bunch of + // drawing operations and then update the screen all at once by calling + // display.display(). These examples demonstrate both approaches... + +// testdrawline(); // Draw many lines + + + lcd.setTextSize(1); // Normal 1:1 pixel scale + lcd.setTextColor(SSD1306_WHITE); // Draw white text + lcd.setCursor(0,0); // Start at top-left corner + lcd.println(F("Hello, world!")); + lcd.display(); } //----------------------------------------------------------------------------------------------------- void K3NGdisplay::service(uint8_t force_update_flag = 0){ - + + return; + // force_update_flag = 1 : force a screen update regardless of update_time_ms, but not if there is a timed message (i.e. revert_screen_flag = 1) // force_update_flag = 2 : force a screen update regardless of update_time_ms and revert_screen_flag @@ -254,10 +321,12 @@ void K3NGdisplay::clear(){ } - lcd.clear(); + // TODO + // lcd.clear(); #ifdef FEATURE_4_BIT_LCD_DISPLAY - lcd.noCursor(); + // TODO + // lcd.noCursor(); #endif current_print_row = 0; @@ -303,7 +372,8 @@ void K3NGdisplay::update(){ byte wrote_to_lcd_last_loop = 0; - lcd.noCursor(); + // TODO + //lcd.noCursor(); lcd.setCursor(0,0); for (int x = 0;x < (display_columns*display_rows);x++){ @@ -356,7 +426,8 @@ void K3NGdisplay::redraw(){ // redraw the screen with the current screen_buffer_live - lcd.noCursor(); + // TODO + //lcd.noCursor(); lcd.setCursor(0,0); for (int x = 0;x < (display_columns*display_rows);x++){ @@ -814,4 +885,3 @@ uint8_t K3NGdisplay::readButtons(){ #endif //K3NG_DISPLAY_H -