Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Bad-Assumptions committed Sep 28, 2023
2 parents 79009bc + fe7c2a3 commit c30e599
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 68 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
idf_component_register(
SRCS DFRobot_RGBLCD1602.cpp LiquidCrystal_I2C.cpp
INCLUDE_DIRS .
REQUIRES driver
REQUIRES driver arduino
)
3 changes: 2 additions & 1 deletion DFRobot_RGBLCD1602.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ inline esp_err_t DFRobot_RGBLCD1602::command(uint8_t value)
LCD_COMMAND_DELAY_MS / portTICK_PERIOD_MS);
}

#ifndef ARDUINO // roll our own print functions
void DFRobot_RGBLCD1602::print(const char chr)
{
write(chr);
Expand All @@ -313,7 +314,7 @@ void DFRobot_RGBLCD1602::print(const float f, uint8_t decimalPlaces)
sprintf(str, "%.2f", f);
print(str);
}

#endif //ARDUINO
// void DFRobot_RGBLCD1602::setBacklight(bool mode){
// if(mode){
// setColorWhite(); // turn backlight on
Expand Down
18 changes: 16 additions & 2 deletions DFRobot_RGBLCD1602.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@
*/

#pragma once
#ifdef ARDUINO
// #warning ARDIUNO defined
#if (ARDUINO >= 100)
// #warning ARDIUNO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif
#endif

// /*
// #include <inttypes.h>
Expand Down Expand Up @@ -88,7 +97,11 @@
#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
#ifdef ARDUINO
class DFRobot_RGBLCD1602 : public Print // TODO instead of this conditional , put my print() in it's own class
#else
class DFRobot_RGBLCD1602 // : public Print print implemented internally to class
#endif
{
private:
static constexpr const char *_TAG = "DFRobot_RGBLCD1602";
Expand Down Expand Up @@ -282,6 +295,7 @@ class DFRobot_RGBLCD1602 // : public Print --yeah don't know if I'll be able to
*/
esp_err_t setBacklight(bool mode);

#ifndef ARDUINO // roll our own print()
/**
* @brief write a single char
*
Expand All @@ -304,6 +318,7 @@ class DFRobot_RGBLCD1602 // : public Print --yeah don't know if I'll be able to
*
*/
void print(const float f, uint8_t decimalPlaces);
#endif // ARDUINO

private:
/**
Expand All @@ -328,5 +343,4 @@ class DFRobot_RGBLCD1602 // : public Print --yeah don't know if I'll be able to
uint8_t _RGBAddr;
uint8_t _cols;
uint8_t _rows;

};
Empty file added LiquidCrystal.h
Empty file.
73 changes: 9 additions & 64 deletions LiquidCrystal_I2C.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
#pragma once
#include "DFRobot_RGBLCD1602.h"
// #ifdef ARDUINO
// #warning LC ARDIUNO defined
// #if (ARDUINO >= 100)
// #warning LC ARDIUNO >= 100
// #include "Arduino.h"
// #else
// #include "WProgram.h"
// #endif
// #endif

#ifdef __cplusplus
extern "C" {
Expand All @@ -8,71 +17,7 @@ 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
}
Expand Down
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,13 @@
# DFRobot_RGBLCD1602
ESP-IDF version of the namesake Arduino library

| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-S2 | ESP32-S3 |
| ----------------- | ----- | -------- | -------- | -------- | -------- |

- Also works with related monochrome backlit products.
- Should work for most AiP31068-based LCD displays, except for the backlight control.
- [DFRobot Arduino library](https://github.com/DFRobot/DFRobot_RGBLCD1602)
- DFRobot Gravity I2C LCD1602 with RGB Backlight Display can display 2x16 characters and support functions like scrolling-displaying, cursor movement and backlight color adjustment [Product Link (SKU:DFR0464)](https://www.dfrobot.com/product-1609.html)

# Usage
For building with CMake in ESP-IDF without the Arduino-ESP32 component, remove REQUIRED arduino from CMakeLists.txt. To build with the Arduino-ESP32 component, add REQUIRED arduino to CMakeList.txt.

0 comments on commit c30e599

Please sign in to comment.