Fix dependencies for each component.
Add ability to clear LCD screen, and write at a label position.
This commit is contained in:
@@ -2,4 +2,4 @@ version: "0.0.1"
|
||||
description: ESP I2C helper component
|
||||
url: https://git.shaunreed.com/shaunrd0/klips/tree/master/esp/cpp/components/i2c
|
||||
dependencies:
|
||||
idf: ">=5.3"
|
||||
idf: ">=5.3"
|
||||
|
||||
@@ -9,13 +9,23 @@
|
||||
#define I2C_H
|
||||
|
||||
#define I2C_BUS_PORT 0
|
||||
|
||||
#define I2C_DEFAULT_PIN_RST (-1)
|
||||
#include <driver/i2c_master.h>
|
||||
#include <esp_log.h>
|
||||
|
||||
/// Tag used for ESP logging.
|
||||
static const char* I2C_TAG = "I2C component";
|
||||
|
||||
/**
|
||||
* ESP I2C master bus handle getter.
|
||||
*/
|
||||
static i2c_master_bus_handle_t I2C_get()
|
||||
{
|
||||
i2c_master_bus_handle_t i2c = NULL;
|
||||
ESP_ERROR_CHECK(i2c_master_get_bus_handle(0, &i2c));
|
||||
return i2c;
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct an ESP I2C master bus given a specific ESP I2C configuration.
|
||||
* An I2C constructor may only be called one time in any application.
|
||||
@@ -24,7 +34,7 @@ static const char* I2C_TAG = "I2C component";
|
||||
*/
|
||||
static void I2C_config_init(const i2c_master_bus_config_t config)
|
||||
{
|
||||
i2c_master_bus_handle_t i2c;
|
||||
i2c_master_bus_handle_t i2c = NULL;
|
||||
ESP_LOGI(I2C_TAG, "Initializing new master I2C bus");
|
||||
ESP_ERROR_CHECK(i2c_new_master_bus(&config, &i2c));
|
||||
}
|
||||
@@ -38,7 +48,7 @@ static void I2C_config_init(const i2c_master_bus_config_t config)
|
||||
*/
|
||||
static void I2C_init(gpio_num_t sda, gpio_num_t scl)
|
||||
{
|
||||
return I2C_config_init((i2c_master_bus_config_t){
|
||||
I2C_config_init((i2c_master_bus_config_t){
|
||||
.i2c_port = I2C_BUS_PORT,
|
||||
.sda_io_num = sda,
|
||||
.scl_io_num = scl,
|
||||
@@ -51,15 +61,4 @@ static void I2C_init(gpio_num_t sda, gpio_num_t scl)
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* ESP I2C master bus handle getter.
|
||||
* This will fail if an I2C instance was never constructed.
|
||||
*/
|
||||
static i2c_master_bus_handle_t I2C_get()
|
||||
{
|
||||
i2c_master_bus_handle_t i2c = NULL;
|
||||
ESP_ERROR_CHECK(i2c_master_get_bus_handle(0, &i2c));
|
||||
return i2c;
|
||||
}
|
||||
|
||||
#endif // I2C_H
|
||||
|
||||
Reference in New Issue
Block a user