From 986f6232b8ff404b2ad608dfcc60054e33edbe8b Mon Sep 17 00:00:00 2001 From: Brian Alano <111384732+Bad-Assumptions@users.noreply.github.com> Date: Thu, 15 Jun 2023 14:12:31 -0400 Subject: [PATCH] arduino as component updates --- CMakeLists.txt | 2 +- DFRobot_RGBLCD1602.cpp | 3 ++- DFRobot_RGBLCD1602.h | 18 ++++++++++++++++-- LiquidCrystal_I2C.h | 9 +++++++++ README.md | 3 +++ 5 files changed, 31 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e02e647..6d303d7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ idf_component_register( SRCS DFRobot_RGBLCD1602.cpp LiquidCrystal_I2C.cpp INCLUDE_DIRS . - REQUIRES driver + REQUIRES driver arduino ) \ No newline at end of file diff --git a/DFRobot_RGBLCD1602.cpp b/DFRobot_RGBLCD1602.cpp index e58c9e6..db7ea90 100644 --- a/DFRobot_RGBLCD1602.cpp +++ b/DFRobot_RGBLCD1602.cpp @@ -264,6 +264,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); @@ -288,7 +289,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 diff --git a/DFRobot_RGBLCD1602.h b/DFRobot_RGBLCD1602.h index d69addd..b755743 100644 --- a/DFRobot_RGBLCD1602.h +++ b/DFRobot_RGBLCD1602.h @@ -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 @@ -87,7 +96,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"; @@ -273,6 +286,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 * @@ -295,6 +309,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: /** @@ -319,5 +334,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; - }; diff --git a/LiquidCrystal_I2C.h b/LiquidCrystal_I2C.h index 207ede7..0c13a7b 100644 --- a/LiquidCrystal_I2C.h +++ b/LiquidCrystal_I2C.h @@ -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" { diff --git a/README.md b/README.md index 3875bad..5ae8436 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,5 @@ # DFRobot_RGBLCD1602 ESP-IDF version of the namesake Arduino library + +# 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. \ No newline at end of file