Skip to content

Commit

Permalink
arduino as component updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Bad-Assumptions committed Jun 15, 2023
1 parent 8e970c0 commit 986f623
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 4 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 @@ -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);
Expand All @@ -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
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 @@ -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";
Expand Down Expand Up @@ -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
*
Expand All @@ -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:
/**
Expand All @@ -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;

};
9 changes: 9 additions & 0 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 Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.

0 comments on commit 986f623

Please sign in to comment.