#include "main.hpp"
#define I2C_MASTER_SCL_IO 9 /*!< gpio number for I2C master clock */
#define I2C_MASTER_SDA_IO 8 /*!< gpio number for I2C master data */
#define I2C_MASTER_NUM I2C_NUM_0 /*!< I2C port number for master dev */
#define I2C_MASTER_FREQ_HZ 100000 /*!< I2C master clock frequency */
static ssd1306_handle_t ssd1306_dev = NULL;
RTClibWrapper rtc;
static const char TAG[] = "MAIN";
void idf_app()
{
i2c_config_t conf;
conf.mode = I2C_MODE_MASTER;
conf.sda_io_num = (gpio_num_t)I2C_MASTER_SDA_IO;
conf.sda_pullup_en = GPIO_PULLUP_ENABLE;
conf.scl_io_num = (gpio_num_t)I2C_MASTER_SCL_IO;
conf.scl_pullup_en = GPIO_PULLUP_ENABLE;
conf.master.clk_speed = I2C_MASTER_FREQ_HZ;
conf.clk_flags = 0; //I2C_SCLK_SRC_FLAG_FOR_NOMAL;
i2c_param_config(I2C_MASTER_NUM, &conf);
i2c_driver_install(I2C_MASTER_NUM, conf.mode, 0, 0, 0);
ssd1306_dev = ssd1306_create(I2C_MASTER_NUM, SSD1306_I2C_ADDRESS);
ssd1306_refresh_gram(ssd1306_dev);
ssd1306_clear_screen(ssd1306_dev, 0x00);
char data_str[10] = {0};
//sprintf(data_str, "C STR");
sprintf(data_str, "OSVALDO");
ssd1306_draw_string(ssd1306_dev, 70, 16, (const uint8_t *)data_str, 16, 1);
ssd1306_refresh_gram(ssd1306_dev);
rtc.begin();
Led led1(led1gpio);
Led led2(led2gpio);
LedTask task1(led1, 1000);
LedTask task2(led2, 200);
task1.start();
task2.start();
uint16_t year;
uint8_t month, day;
uint8_t hours, minutes, seconds;
// Configurar data
rtc.setDate(2023, 5, 19);
rtc.setTime(23, 59, 54);
while (true)
{
rtc.getDate(year, month, day);
rtc.getTime(hours, minutes, seconds);
printf("Data: %02d/%02d/%02d\n", day, month, year);
printf("Hora: %02d:%02d:%02d\n", hours, minutes, seconds);
vTaskDelay(3000 / portTICK_PERIOD_MS);
vTaskDelay(portMAX_DELAY);
}
}
void setup() {
idf_app();
}
void loop() {
}
Loading
esp32-c3-devkitm-1
esp32-c3-devkitm-1