From a05d13cf771be08b110a4eb9402f364bab64bc48 Mon Sep 17 00:00:00 2001 From: Brian Alano <111384732+Bad-Assumptions@users.noreply.github.com> Date: Mon, 5 Jun 2023 15:34:45 -0400 Subject: [PATCH 1/4] checkpoint copied from unit_test_menu for 99-0000200 --- DFRobot_RGBLCD1602.cpp | 114 ++++++++++++++++++++++------------------- DFRobot_RGBLCD1602.h | 92 ++++++++++++++++++--------------- LiquidCrystal_I2C.h | 79 ++++++++++++++++++++++++++++ LiquidCrystal_i2C.cpp | 17 ++++++ 4 files changed, 206 insertions(+), 96 deletions(-) create mode 100644 LiquidCrystal_I2C.h create mode 100644 LiquidCrystal_i2C.cpp diff --git a/DFRobot_RGBLCD1602.cpp b/DFRobot_RGBLCD1602.cpp index 6b9d325..ab1842b 100644 --- a/DFRobot_RGBLCD1602.cpp +++ b/DFRobot_RGBLCD1602.cpp @@ -54,7 +54,7 @@ esp_err_t DFRobot_RGBLCD1602::i2c_scan(const uint8_t addr) i2c_master_start(cmd); i2c_master_write_byte(cmd, (addr << 1) | I2C_MASTER_WRITE, 1); i2c_master_stop(cmd); - ret = i2c_master_cmd_begin(_i2c_num, cmd, RGBLCD1602_COMMAND_DELAY_MS / portTICK_PERIOD_MS); + ret = i2c_master_cmd_begin(_i2c_num, cmd, LCD_COMMAND_DELAY_MS / portTICK_PERIOD_MS); i2c_cmd_link_delete(cmd); ESP_LOGD(_TAG, "i2c_scan(0x%2x) returning:%i", addr, (int)ret); return ret; @@ -63,29 +63,29 @@ esp_err_t DFRobot_RGBLCD1602::i2c_scan(const uint8_t addr) /** * @brief test communication to device. * @note i2c_driver_install must be done before init() by the calling program - * @return esp_err_t returns the return value is i2c_master_cmd_begin() + * @return esp_err_t returns the return value of i2c_scan() **/ // TODO change LOGI to LOGD esp_err_t DFRobot_RGBLCD1602::init() { esp_err_t ret; // find the LCD - ESP_RETURN_ON_ERROR(i2c_scan(RGBLCD1602_LCD_ADDRESS), _TAG, "lcd not found"); + ESP_RETURN_ON_ERROR(i2c_scan(LCD_LCD_ADDRESS), _TAG, "lcd not found"); // find the RGB device and set the color PWM registers - ret = i2c_scan(RGBLCD1602_RGB_ADDRESS); + ret = i2c_scan(LCD_RGB_ADDRESS); if (ret == ESP_OK) // found it { - _RGBAddr = RGBLCD1602_RGB_ADDRESS; + _RGBAddr = LCD_RGB_ADDRESS; REG_RED = 0x04; REG_GREEN = 0x03; REG_BLUE = 0x02; } else { - ret = i2c_scan(RGBLCD1602_RGB_ADDRESS_ALT); + ret = i2c_scan(LCD_RGB_ADDRESS_ALT); if (ret == ESP_OK) // found it { - _RGBAddr = RGBLCD1602_RGB_ADDRESS_ALT; + _RGBAddr = LCD_RGB_ADDRESS_ALT; REG_RED = 0x06; // pwm2 REG_GREEN = 0x07; // pwm1 REG_BLUE = 0x08; // pwm0 @@ -93,99 +93,100 @@ esp_err_t DFRobot_RGBLCD1602::init() } - _showFunction = RGBLCD1602_4BITMODE | RGBLCD1602_1LINE | RGBLCD1602_5x8DOTS; + _showFunction = LCD_4BITMODE | LCD_1LINE | LCD_5x8DOTS; begin(_rows); return ret; } esp_err_t DFRobot_RGBLCD1602::clear() { - esp_err_t ret = command(RGBLCD1602_CLEARDISPLAY); // clear display, set cursor position to zero - vTaskDelay(pdMS_TO_TICKS(2)); // this command takes a long time! + esp_err_t ret = command(LCD_CLEARDISPLAY); // clear display, set cursor position to zero + vTaskDelay(pdMS_TO_TICKS(12)); // this command takes a long time! + home(); return ret; } esp_err_t DFRobot_RGBLCD1602::home() { - esp_err_t ret = command(RGBLCD1602_RETURNHOME); // set cursor position to zero - vTaskDelay(pdMS_TO_TICKS(2)); // this command takes a long time! + esp_err_t ret = command(LCD_RETURNHOME); // set cursor position to zero + vTaskDelay(pdMS_TO_TICKS(12)); // this command takes a long time! return ret; } esp_err_t DFRobot_RGBLCD1602::noDisplay() { - _showControl &= ~RGBLCD1602_DISPLAYON; - return command(RGBLCD1602_DISPLAYCONTROL | _showControl); + _showControl &= ~LCD_DISPLAYON; + return command(LCD_DISPLAYCONTROL | _showControl); } esp_err_t DFRobot_RGBLCD1602::display() { - _showControl |= RGBLCD1602_DISPLAYON; - return command(RGBLCD1602_DISPLAYCONTROL | _showControl); + _showControl |= LCD_DISPLAYON; + return command(LCD_DISPLAYCONTROL | _showControl); } esp_err_t DFRobot_RGBLCD1602::stopBlink() { - _showControl &= ~RGBLCD1602_BLINKON; - return command(RGBLCD1602_DISPLAYCONTROL | _showControl); + _showControl &= ~LCD_BLINKON; + return command(LCD_DISPLAYCONTROL | _showControl); } esp_err_t DFRobot_RGBLCD1602::blink() { - _showControl |= RGBLCD1602_BLINKON; - return command(RGBLCD1602_DISPLAYCONTROL | _showControl); + _showControl |= LCD_BLINKON; + return command(LCD_DISPLAYCONTROL | _showControl); } esp_err_t DFRobot_RGBLCD1602::noCursor() { - _showControl &= ~RGBLCD1602_CURSORON; - return command(RGBLCD1602_DISPLAYCONTROL | _showControl); + _showControl &= ~LCD_CURSORON; + return command(LCD_DISPLAYCONTROL | _showControl); } esp_err_t DFRobot_RGBLCD1602::cursor() { - _showControl |= RGBLCD1602_CURSORON; - return command(RGBLCD1602_DISPLAYCONTROL | _showControl); + _showControl |= LCD_CURSORON; + return command(LCD_DISPLAYCONTROL | _showControl); } // void DFRobot_RGBLCD1602::scrollDisplayLeft(void) // { -// command(RGBLCD1602_CURSORSHIFT | RGBLCD1602_DISPLAYMOVE | RGBLCD1602_MOVELEFT); +// command(LCD_CURSORSHIFT | LCD_DISPLAYMOVE | LCD_MOVELEFT); // } // void DFRobot_RGBLCD1602::scrollDisplayRight(void) // { -// command(RGBLCD1602_CURSORSHIFT | RGBLCD1602_DISPLAYMOVE | RGBLCD1602_MOVERIGHT); +// command(LCD_CURSORSHIFT | LCD_DISPLAYMOVE | LCD_MOVERIGHT); // } // void DFRobot_RGBLCD1602::leftToRight(void) // { -// _showMode |= RGBLCD1602_ENTRYLEFT; -// command(RGBLCD1602_ENTRYMODESET | _showMode); +// _showMode |= LCD_ENTRYLEFT; +// command(LCD_ENTRYMODESET | _showMode); // } // void DFRobot_RGBLCD1602::rightToLeft(void) // { -// _showMode &= ~RGBLCD1602_ENTRYLEFT; -// command(RGBLCD1602_ENTRYMODESET | _showMode); +// _showMode &= ~LCD_ENTRYLEFT; +// command(LCD_ENTRYMODESET | _showMode); // } esp_err_t DFRobot_RGBLCD1602::noAutoscroll(void) { - _showMode &= ~RGBLCD1602_ENTRYSHIFTINCREMENT; - return command(RGBLCD1602_ENTRYMODESET | _showMode); + _showMode &= ~LCD_ENTRYSHIFTINCREMENT; + return command(LCD_ENTRYMODESET | _showMode); } esp_err_t DFRobot_RGBLCD1602::autoscroll(void) { - _showMode |= RGBLCD1602_ENTRYSHIFTINCREMENT; - return command(RGBLCD1602_ENTRYMODESET | _showMode); + _showMode |= LCD_ENTRYSHIFTINCREMENT; + return command(LCD_ENTRYMODESET | _showMode); } esp_err_t DFRobot_RGBLCD1602::customSymbol(uint8_t location, uint8_t charmap[]) { location &= 0x7; // we only have 8 locations 0-7 - esp_err_t ret = command(RGBLCD1602_SETCGRAMADDR | (location << 3)); + esp_err_t ret = command(LCD_SETCGRAMADDR | (location << 3)); if (ret != ESP_OK) return ret; @@ -199,7 +200,6 @@ esp_err_t DFRobot_RGBLCD1602::customSymbol(uint8_t location, uint8_t charmap[]) data, 9, 5 / portTICK_PERIOD_MS); } - esp_err_t DFRobot_RGBLCD1602::setCursor(uint8_t col, uint8_t row) { @@ -207,7 +207,7 @@ esp_err_t DFRobot_RGBLCD1602::setCursor(uint8_t col, uint8_t row) const uint8_t data[] = {0x80, col}; return i2c_master_write_to_device(_i2c_num, _lcdAddr, data, 2, - RGBLCD1602_COMMAND_DELAY_MS / portTICK_PERIOD_MS); + LCD_COMMAND_DELAY_MS / portTICK_PERIOD_MS); } esp_err_t DFRobot_RGBLCD1602::setRGB(uint8_t r, uint8_t g, uint8_t b) @@ -245,7 +245,7 @@ inline size_t DFRobot_RGBLCD1602::write(uint8_t value) const uint8_t data[] = {0x40, value}; esp_err_t ret = i2c_master_write_to_device(_i2c_num, _lcdAddr, data, 2, - RGBLCD1602_COMMAND_DELAY_MS / portTICK_PERIOD_MS); + LCD_COMMAND_DELAY_MS / portTICK_PERIOD_MS); if (ret == ESP_OK) { return 1; @@ -261,7 +261,7 @@ inline esp_err_t DFRobot_RGBLCD1602::command(uint8_t value) const uint8_t data[] = {0x80, value}; return i2c_master_write_to_device(_i2c_num, _lcdAddr, data, 2, - RGBLCD1602_COMMAND_DELAY_MS / portTICK_PERIOD_MS); + LCD_COMMAND_DELAY_MS / portTICK_PERIOD_MS); } void DFRobot_RGBLCD1602::print(const char *str) @@ -277,6 +277,12 @@ void DFRobot_RGBLCD1602::print(const int i) sprintf(str, "%i", i); print(str); } +void DFRobot_RGBLCD1602::print(const float f, uint8_t decimalPlaces) +{ + char str[16]; + sprintf(str, "%.2f", f); + print(str); +} // void DFRobot_RGBLCD1602::setBacklight(bool mode){ // if(mode){ @@ -290,54 +296,54 @@ void DFRobot_RGBLCD1602::print(const int i) esp_err_t DFRobot_RGBLCD1602::begin( uint8_t rows, uint8_t charSize) { if (rows > 1) { - _showFunction |= RGBLCD1602_2LINE; + _showFunction |= LCD_2LINE; } _numLines = rows; _currLine = 0; ///< for some 1 line displays you can select a 10 pixel high font if ((charSize != 0) && (rows == 1)) { - _showFunction |= RGBLCD1602_5x10DOTS; + _showFunction |= LCD_5x10DOTS; } ///< SEE PAGE 45/46 FOR INITIALIZATION SPECIFICATION! ///< according to datasheet, we need at least 40ms after power rises above 2.7V ///< before sending commands. Arduino can turn on way befer 4.5V so we'll wait 50 - vTaskDelay(pdMS_TO_TICKS(50)); + vTaskDelay(pdMS_TO_TICKS(100)); ///< this is according to the hitachi HD44780 datasheet ///< page 45 figure 23 ///< Send function set command sequence - command(RGBLCD1602_FUNCTIONSET | _showFunction); + command(LCD_FUNCTIONSET | _showFunction); vTaskDelay(pdMS_TO_TICKS(5)); // wait more than 4.1ms ///< second try - command(RGBLCD1602_FUNCTIONSET | _showFunction); + command(LCD_FUNCTIONSET | _showFunction); vTaskDelay(pdMS_TO_TICKS(5)); ///< third go - ESP_ERROR_CHECK(command(RGBLCD1602_FUNCTIONSET | _showFunction)); + ESP_ERROR_CHECK(command(LCD_FUNCTIONSET | _showFunction)); ///< turn the display on with no cursor or blinking default - _showControl = RGBLCD1602_DISPLAYON | RGBLCD1602_CURSOROFF | RGBLCD1602_BLINKOFF; + _showControl = LCD_DISPLAYON | LCD_CURSOROFF | LCD_BLINKOFF; display(); ///< clear it off clear(); ///< Initialize to default text direction (for romance languages) - _showMode = RGBLCD1602_ENTRYLEFT | RGBLCD1602_ENTRYSHIFTDECREMENT; + _showMode = LCD_ENTRYLEFT | LCD_ENTRYSHIFTDECREMENT; ///< set the entry mode - command(RGBLCD1602_ENTRYMODESET | _showMode); + command(LCD_ENTRYMODESET | _showMode); - if(_RGBAddr == RGBLCD1602_RGB_ADDRESS){ + if(_RGBAddr == LCD_RGB_ADDRESS){ ///< backlight init - setReg(RGBLCD1602_REG_MODE1, 0); + setReg(LCD_REG_MODE1, 0); ///< set LEDs controllable by both PWM and GRPPWM registers - setReg(RGBLCD1602_REG_OUTPUT, 0xFF); + setReg(LCD_REG_OUTPUT, 0xFF); ///< set MODE2 values ///< 0010 0000 -> 0x20 (DMBLNK to 1, ie blinky mode) - setReg(RGBLCD1602_REG_MODE2, 0x20); + setReg(LCD_REG_MODE2, 0x20); }else{ setReg(0x04, 0x15); } @@ -355,7 +361,7 @@ esp_err_t DFRobot_RGBLCD1602::begin( uint8_t rows, uint8_t charSize) // // _pWire->endTransmission(); // stop transmitting // return i2c_master_write_to_device(_i2c_num, _lcdAddr, // data, len, -// RGBLCD1602_COMMAND_DELAY_MS / portTICK_PERIOD_MS); +// LCD_COMMAND_DELAY_MS / portTICK_PERIOD_MS); // } esp_err_t DFRobot_RGBLCD1602::setReg(uint8_t addr, uint8_t data) @@ -364,5 +370,5 @@ esp_err_t DFRobot_RGBLCD1602::setReg(uint8_t addr, uint8_t data) const uint8_t write_buffer[] = {addr, data}; return i2c_master_write_to_device(_i2c_num, _RGBAddr, write_buffer, 2, - RGBLCD1602_COMMAND_DELAY_MS / portTICK_PERIOD_MS); + LCD_COMMAND_DELAY_MS / portTICK_PERIOD_MS); } diff --git a/DFRobot_RGBLCD1602.h b/DFRobot_RGBLCD1602.h index 06e8b39..78e1d00 100644 --- a/DFRobot_RGBLCD1602.h +++ b/DFRobot_RGBLCD1602.h @@ -22,70 +22,70 @@ /*! * @brief default Device I2C Addresses */ -#define RGBLCD1602_LCD_ADDRESS (0x7c >> 1) -#define RGBLCD1602_RGB_ADDRESS_ALT (0x60 >> 1) -#define RGBLCD1602_RGB_ADDRESS (0xc0 >> 1) +#define LCD_LCD_ADDRESS (0x7c >> 1) +#define LCD_RGB_ADDRESS_ALT (0x60 >> 1) +#define LCD_RGB_ADDRESS (0xc0 >> 1) /*! * @brief color define */ -#define RGBLCD1602_WHITE 0 -#define RGBLCD1602_RED 1 -#define RGBLCD1602_GREEN 2 -#define RGBLCD1602_BLUE 3 +#define LCD_WHITE 0 +#define LCD_RED 1 +#define LCD_GREEN 2 +#define LCD_BLUE 3 -#define RGBLCD1602_REG_MODE1 0x00 -#define RGBLCD1602_REG_MODE2 0x01 -#define RGBLCD1602_REG_OUTPUT 0x08 +#define LCD_REG_MODE1 0x00 +#define LCD_REG_MODE2 0x01 +#define LCD_REG_OUTPUT 0x08 /*! * @brief commands */ -#define RGBLCD1602_CLEARDISPLAY 0x01 -#define RGBLCD1602_RETURNHOME 0x02 -#define RGBLCD1602_ENTRYMODESET 0x04 -#define RGBLCD1602_DISPLAYCONTROL 0x08 -#define RGBLCD1602_CURSORSHIFT 0x10 -#define RGBLCD1602_FUNCTIONSET 0x20 -#define RGBLCD1602_SETCGRAMADDR 0x40 -#define RGBLCD1602_SETDDRAMADDR 0x80 -#define RGBLCD1602_COMMAND_DELAY_MS 5 +#define LCD_CLEARDISPLAY 0x01 +#define LCD_RETURNHOME 0x02 +#define LCD_ENTRYMODESET 0x04 +#define LCD_DISPLAYCONTROL 0x08 +#define LCD_CURSORSHIFT 0x10 +#define LCD_FUNCTIONSET 0x20 +#define LCD_SETCGRAMADDR 0x40 +#define LCD_SETDDRAMADDR 0x80 +#define LCD_COMMAND_DELAY_MS 5 /*! * @brief flags for display entry mode */ -#define RGBLCD1602_ENTRYRIGHT 0x00 -#define RGBLCD1602_ENTRYLEFT 0x02 -#define RGBLCD1602_ENTRYSHIFTINCREMENT 0x01 -#define RGBLCD1602_ENTRYSHIFTDECREMENT 0x00 +#define LCD_ENTRYRIGHT 0x00 +#define LCD_ENTRYLEFT 0x02 +#define LCD_ENTRYSHIFTINCREMENT 0x01 +#define LCD_ENTRYSHIFTDECREMENT 0x00 /*! * @brief flags for display on/off control */ -#define RGBLCD1602_DISPLAYON 0x04 -#define RGBLCD1602_DISPLAYOFF 0x00 -#define RGBLCD1602_CURSORON 0x02 -#define RGBLCD1602_CURSOROFF 0x00 -#define RGBLCD1602_BLINKON 0x01 -#define RGBLCD1602_BLINKOFF 0x00 +#define LCD_DISPLAYON 0x04 +#define LCD_DISPLAYOFF 0x00 +#define LCD_CURSORON 0x02 +#define LCD_CURSOROFF 0x00 +#define LCD_BLINKON 0x01 +#define LCD_BLINKOFF 0x00 /*! * @brief flags for display/cursor shift */ -#define RGBLCD1602_DISPLAYMOVE 0x08 -#define RGBLCD1602_CURSORMOVE 0x00 -#define RGBLCD1602_MOVERIGHT 0x04 -#define RGBLCD1602_MOVELEFT 0x00 +#define LCD_DISPLAYMOVE 0x08 +#define LCD_CURSORMOVE 0x00 +#define LCD_MOVERIGHT 0x04 +#define LCD_MOVELEFT 0x00 /*! * @brief flags for function set */ -#define RGBLCD1602_8BITMODE 0x10 -#define RGBLCD1602_4BITMODE 0x00 -#define RGBLCD1602_2LINE 0x08 -#define RGBLCD1602_1LINE 0x00 -#define RGBLCD1602_5x10DOTS 0x04 -#define RGBLCD1602_5x8DOTS 0x00 +#define LCD_8BITMODE 0x10 +#define LCD_4BITMODE 0x00 +#define LCD_2LINE 0x08 +#define LCD_1LINE 0x00 +#define LCD_5x10DOTS 0x04 +#define LCD_5x8DOTS 0x00 class DFRobot_RGBLCD1602 // : public Print --yeah don't know if I'll be able to extend Arduino's print { @@ -119,7 +119,7 @@ class DFRobot_RGBLCD1602 // : public Print --yeah don't know if I'll be able to // Constructor // ----------------------------------------------------------------------------- DFRobot_RGBLCD1602(uint8_t lcdCols, uint8_t lcdRows, i2c_port_t i2c_num = I2C_NUM_0, - uint8_t lcdAddr = RGBLCD1602_LCD_ADDRESS, uint8_t RGBAddr = RGBLCD1602_RGB_ADDRESS); + uint8_t lcdAddr = LCD_LCD_ADDRESS, uint8_t RGBAddr = LCD_RGB_ADDRESS); // ----------------------------------------------------------------------------- // init() @@ -203,6 +203,9 @@ class DFRobot_RGBLCD1602 // : public Print --yeah don't know if I'll be able to * @param charmap character array the size is 8 bytes */ esp_err_t customSymbol(uint8_t location, uint8_t charmap[]); + inline void createChar(uint8_t location, uint8_t charmap[]) { + customSymbol(location, charmap); + } /** * @brief set cursor position @@ -281,14 +284,19 @@ class DFRobot_RGBLCD1602 // : public Print --yeah don't know if I'll be able to * */ void print(const int i); + /** + * @brief write a float to the specified number of decimal places + * + */ + void print(const float f, uint8_t decimalPlaces); private: /** * @brief the initialization function * @param row rows optional range 0-1,0 is the first row, 1 is the second row - * @param charSize character size RGBLCD1602_5x8DOTS\RGBLCD1602_5x10DOTS + * @param charSize character size LCD_5x8DOTS\LCD_5x10DOTS */ - esp_err_t begin(uint8_t rows, uint8_t charSize = RGBLCD1602_5x8DOTS); + esp_err_t begin(uint8_t rows, uint8_t charSize = LCD_5x8DOTS); /** * @brief set the backlight register diff --git a/LiquidCrystal_I2C.h b/LiquidCrystal_I2C.h new file mode 100644 index 0000000..207ede7 --- /dev/null +++ b/LiquidCrystal_I2C.h @@ -0,0 +1,79 @@ +#pragma once +#include "DFRobot_RGBLCD1602.h" + +#ifdef __cplusplus +extern "C" { +#endif +class LiquidCrystal_I2C : public DFRobot_RGBLCD1602 +{ +public: + LiquidCrystal_I2C(uint8_t lcd_Addr, uint8_t lcd_cols, uint8_t lcd_rows): DFRobot_RGBLCD1602(lcd_cols, lcd_rows, I2C_NUM_0, lcd_Addr, LCD_RGB_ADDRESS) {} +// void begin(uint8_t cols = 16, uint8_t rows = 2, uint8_t charsize = RGBLCD1602_5x8DOTS); +// void clear(); +// void home(); +// void noDisplay(); +// void display(); +// void noBlink(); +// void blink(); +// void noCursor(); +// void cursor(); +// void scrollDisplayLeft(); +// void scrollDisplayRight(); +// void printLeft(); +// void printRight(); +// void leftToRight(); +// void rightToLeft(); +// void shiftIncrement(); +// void shiftDecrement(); +// void noBacklight(); +// void backlight(); +// void autoscroll(); +// void noAutoscroll(); +// void createChar(uint8_t location, const char *charmap); +// // Example: const char bell[8] PROGMEM = {B00100,B01110,B01110,B01110,B11111,B00000,B00100,B00000}; + +// void setCursor(uint8_t, uint8_t); +// virtual size_t write(uint8_t); +// void command(uint8_t); +// void init(); +// void oled_init(); + +// ////compatibility API function aliases +// void blink_on(); // alias for blink() +// void blink_off(); // alias for noBlink() +// void cursor_on(); // alias for cursor() +// void cursor_off(); // alias for noCursor() +// void setBacklight(uint8_t new_val); // alias for backlight() and nobacklight() +// void load_custom_character(uint8_t char_num, uint8_t *rows); // alias for createChar() +// void printstr(const char[]); + +// ////Unsupported API functions (not implemented in this library) +// uint8_t status(); +// void setContrast(uint8_t new_val); +// uint8_t keypad(); +// void setDelay(int, int); +// void on(); +// void off(); +// uint8_t init_bargraph(uint8_t graphtype); +// void draw_horizontal_graph(uint8_t row, uint8_t column, uint8_t len, uint8_t pixel_col_end); +// void draw_vertical_graph(uint8_t row, uint8_t column, uint8_t len, uint8_t pixel_col_end); + +// private: +// void init_priv(); +// void send(uint8_t, uint8_t); +// void write4bits(uint8_t); +// void expanderWrite(uint8_t); +// void pulseEnable(uint8_t); +// uint8_t _Addr; +// uint8_t _displayfunction; +// uint8_t _displaycontrol; +// uint8_t _displaymode; +// uint8_t _numlines; +// bool _oled = false; +// uint8_t _cols; +// uint8_t _rows; +// uint8_t _backlightval; +}; +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/LiquidCrystal_i2C.cpp b/LiquidCrystal_i2C.cpp new file mode 100644 index 0000000..e460c97 --- /dev/null +++ b/LiquidCrystal_i2C.cpp @@ -0,0 +1,17 @@ +#include "LiquidCrystal_I2C.h" + + +// LiquidCrystal_I2C::LiquidCrystal_I2C(uint8_t lcd_Addr, uint8_t lcd_cols, uint8_t lcd_rows) +// { +// DFRobot_RGBLCD1602(lcd_cols, lcd_rows, I2C_NUM_0, lcd_Addr, RGBLCD1602_RGB_ADDRESS); +// } + +// inline void LiquidCrystal_I2C::begin(uint8_t cols, uint8_t rows, uint8_t charsize) +// { +// DFRobot_RGBLCD1602::begin(rows, charsize); +// }// Allows us to fill the first 8 CGRAM locations +// // with custom characters +// inline void LiquidCrystal_I2C::createChar(uint8_t location, uint8_t charmap[]) +// { +// DFRobot_RGBLCD1602::customSymbol(location, charmap); +// } \ No newline at end of file From 6e3c54fd375557bbea3d3429f49c7dfbc59a8a7d Mon Sep 17 00:00:00 2001 From: Brian Alano <111384732+Bad-Assumptions@users.noreply.github.com> Date: Thu, 8 Jun 2023 07:49:45 -0400 Subject: [PATCH 2/4] add LiquidCrystal wrapper --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 34bf758..e02e647 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ idf_component_register( - SRCS DFRobot_RGBLCD1602.cpp + SRCS DFRobot_RGBLCD1602.cpp LiquidCrystal_I2C.cpp INCLUDE_DIRS . REQUIRES driver ) \ No newline at end of file From 7e03c52c95711ead033a915a629ef79cc76375b2 Mon Sep 17 00:00:00 2001 From: Brian Alano <111384732+Bad-Assumptions@users.noreply.github.com> Date: Thu, 8 Jun 2023 14:31:55 -0400 Subject: [PATCH 3/4] v1.0.0 --- DFRobot_RGBLCD1602.cpp | 5 +++++ DFRobot_RGBLCD1602.h | 8 +++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/DFRobot_RGBLCD1602.cpp b/DFRobot_RGBLCD1602.cpp index ab1842b..e58c9e6 100644 --- a/DFRobot_RGBLCD1602.cpp +++ b/DFRobot_RGBLCD1602.cpp @@ -264,6 +264,11 @@ inline esp_err_t DFRobot_RGBLCD1602::command(uint8_t value) LCD_COMMAND_DELAY_MS / portTICK_PERIOD_MS); } +void DFRobot_RGBLCD1602::print(const char chr) +{ + write(chr); +} + void DFRobot_RGBLCD1602::print(const char *str) { while (*str) diff --git a/DFRobot_RGBLCD1602.h b/DFRobot_RGBLCD1602.h index 78e1d00..d69addd 100644 --- a/DFRobot_RGBLCD1602.h +++ b/DFRobot_RGBLCD1602.h @@ -273,9 +273,15 @@ class DFRobot_RGBLCD1602 // : public Print --yeah don't know if I'll be able to */ esp_err_t setBacklight(bool mode); + /** + * @brief write a single char + * + */ + void print(const char chr); + /** * @brief write a string - * + * */ void print(const char *str); From 63525e038275f497b5b7fdd2884e4e0d98636b25 Mon Sep 17 00:00:00 2001 From: Brian Alano <39705360+GreenEllipsis@users.noreply.github.com> Date: Thu, 8 Jun 2023 14:47:21 -0400 Subject: [PATCH 4/4] Create README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..3875bad --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +# DFRobot_RGBLCD1602 +ESP-IDF version of the namesake Arduino library