Added the Matrix handling and clock/day wordmaps
Time and day display is functional again
This commit is contained in:
+86
-40
@@ -35,12 +35,36 @@
|
||||
// Platform includes
|
||||
#include "isl29125.h"
|
||||
#include "logger.h"
|
||||
#include "prgm_ledstrip.h"
|
||||
#include "ledmatrix.h"
|
||||
#include "Wifi.h"
|
||||
|
||||
// Application includes
|
||||
#include "clock.h"
|
||||
#include "clockwordmap.h"
|
||||
#include "daywordmap.h"
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// Constant and macro definitions
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
#define ESP32C3_01M_KIT
|
||||
//#define ESP32C3_DEVKIT_M1
|
||||
|
||||
#if defined(ESP32C3_DEVKIT_M1)
|
||||
#define GPIO_I2C_SCK ((uint32_t)3)
|
||||
#define GPIO_I2C_SDA ((uint32_t)2)
|
||||
#define GPIO_LED_ONBOARD ((uint32_t)8)
|
||||
#define GPIO_LED_STRIP ((uint32_t)9)
|
||||
#elif defined(ESP32C3_01M_KIT)
|
||||
#define GPIO_I2C_SCK ((uint32_t)8)
|
||||
#define GPIO_I2C_SDA ((uint32_t)9)
|
||||
#define GPIO_LED_STRIP ((uint32_t)0)
|
||||
#else
|
||||
#error "No supported target platform defined"
|
||||
#endif
|
||||
|
||||
|
||||
#define MATRIX_NMBR_ROWS ((uint32_t)13)
|
||||
#define MATRIX_NMBR_COLUMS ((uint32_t)20)
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
// Type definitions
|
||||
@@ -103,7 +127,7 @@ extern "C" void app_main(void)
|
||||
|
||||
logger debugLogger = logger(16, uartDebug);
|
||||
// Call the logger executable within a dedicated task and forget about it afterwards
|
||||
xTaskCreate(loggerTask, (const char*)"loggerTask", 3072, &debugLogger, 3, &loggerTaskHandle);
|
||||
xTaskCreate(loggerTask, (const char*)"loggerTask", 4000, &debugLogger, 3, &loggerTaskHandle);
|
||||
|
||||
LOGGER_PRINT("\n\r-----------------------------------------------------------------------\n\r");
|
||||
LOGGER_PRINT("System Start\n\r");
|
||||
@@ -112,41 +136,39 @@ extern "C" void app_main(void)
|
||||
LOGGER_PRINT("Release: %d.%d \n\r", MAJORRELEASE, MINORRELEASE);
|
||||
LOGGER_PRINT("Compiled on %s at %s\n\r\n\r\n\r", __DATE__, __TIME__);
|
||||
|
||||
// -----------------------------------------------------------------------------------------------------------------
|
||||
// I2C Masterbus for sensoring peripherals
|
||||
//
|
||||
i2c_port_t i2c_master_port = I2C_NUM_0;
|
||||
|
||||
i2c_config_t i2cConfig = {
|
||||
.mode = I2C_MODE_MASTER,
|
||||
.sda_io_num = (int)2,
|
||||
.scl_io_num = (int)3,
|
||||
.sda_pullup_en = GPIO_PULLUP_ENABLE,
|
||||
.scl_pullup_en = GPIO_PULLUP_ENABLE,
|
||||
.master = 400000,
|
||||
.clk_flags = 0
|
||||
};
|
||||
|
||||
ESP_ERROR_CHECK(i2c_param_config(i2c_master_port, &i2cConfig));
|
||||
ESP_ERROR_CHECK(i2c_driver_install(i2c_master_port, i2cConfig.mode, 0, 0, 0));
|
||||
|
||||
i2c i2cSensor = i2c(&i2c_master_port);
|
||||
i2cSensor.open();
|
||||
|
||||
// -----------------------------------------------------------------------------------------------------------------
|
||||
// I2C RGB Sensor on I2C MasterBus for sensors
|
||||
//
|
||||
isl29125 rgbSensor = isl29125(0x44, i2cSensor);
|
||||
rgbSensor.initialize();
|
||||
vTaskDelay(100);
|
||||
rgbSensor.setMode(isl29125::RGB);
|
||||
rgbSensor.setRange(isl29125::HIGH);
|
||||
rgbSensor.setResolution(isl29125::RES_16BIT);
|
||||
vTaskDelay(100);
|
||||
struct isl29125::rgb_t rgbValue;
|
||||
rgbSensor.getRGB(&rgbValue);
|
||||
|
||||
// gpio debugIO = gpio(19, gpio::Direction_t::GPIO_DIRECTION_OUTPUT, gpio::Value_t::GPIO_VALUE_LOW);
|
||||
// // -----------------------------------------------------------------------------------------------------------------
|
||||
// // I2C Masterbus for sensoring peripherals
|
||||
// //
|
||||
// i2c_port_t i2c_master_port = I2C_NUM_0;
|
||||
//
|
||||
// i2c_config_t i2cConfig = {
|
||||
// .mode = I2C_MODE_MASTER,
|
||||
// .sda_io_num = (int)2,
|
||||
// .scl_io_num = (int)3,
|
||||
// .sda_pullup_en = GPIO_PULLUP_ENABLE,
|
||||
// .scl_pullup_en = GPIO_PULLUP_ENABLE,
|
||||
// .master = 400000,
|
||||
// .clk_flags = 0
|
||||
// };
|
||||
//
|
||||
// ESP_ERROR_CHECK(i2c_param_config(i2c_master_port, &i2cConfig));
|
||||
// ESP_ERROR_CHECK(i2c_driver_install(i2c_master_port, i2cConfig.mode, 0, 0, 0));
|
||||
//
|
||||
// i2c i2cSensor = i2c(&i2c_master_port);
|
||||
// i2cSensor.open();
|
||||
//
|
||||
// // -----------------------------------------------------------------------------------------------------------------
|
||||
// // I2C RGB Sensor on I2C MasterBus for sensors
|
||||
// //
|
||||
// isl29125 rgbSensor = isl29125(0x44, i2cSensor);
|
||||
// rgbSensor.initialize();
|
||||
// vTaskDelay(100);
|
||||
// rgbSensor.setMode(isl29125::RGB);
|
||||
// rgbSensor.setRange(isl29125::HIGH);
|
||||
// rgbSensor.setResolution(isl29125::RES_16BIT);
|
||||
// vTaskDelay(100);
|
||||
// struct isl29125::rgb_t rgbValue;
|
||||
// rgbSensor.getRGB(&rgbValue);
|
||||
|
||||
// -----------------------------------------------------------------------------------------------------------------
|
||||
// Wifi create and connect
|
||||
@@ -157,12 +179,36 @@ extern "C" void app_main(void)
|
||||
// -----------------------------------------------------------------------------------------------------------------
|
||||
// Programmable LEDs in a strip
|
||||
//
|
||||
prgm_ledstrip ledstrip = prgm_ledstrip(1, 8);
|
||||
|
||||
ledmatrix matrix = ledmatrix(MATRIX_NMBR_ROWS, MATRIX_NMBR_COLUMS, GPIO_LED_STRIP);
|
||||
// Set the matrix orientation to ROW-based, from left to right, beginning on the upside
|
||||
matrix.setOrientation(ledmatrix::ORIENTATION_ROW_LEFT_UP);
|
||||
|
||||
ClockWordmap clockwords = ClockWordmap(&matrix);
|
||||
clockwords.setColour(0x80, 0x40, 0xFF);
|
||||
|
||||
DayWordmap daywords = DayWordmap(&matrix);
|
||||
daywords.setColour(0xFF, 0x00, 0x80);
|
||||
|
||||
Clock clk = Clock(Clock::Mode_t::TEN_BEFORE_HALF);
|
||||
|
||||
std::list<std::string> clockWordlist;
|
||||
|
||||
|
||||
while(1)
|
||||
while(1)
|
||||
{
|
||||
vTaskDelay(1000);
|
||||
matrix.clearAll();
|
||||
clk.generateWordlist(&clockWordlist);
|
||||
|
||||
std::list<std::string>::iterator it;
|
||||
for(it = clockWordlist.begin(); it != clockWordlist.end(); it++)
|
||||
{
|
||||
clockwords.setWord(wordmap::Language_t::NL, *it, true);
|
||||
daywords.setWord(wordmap::Language_t::NL, *it, true);
|
||||
}
|
||||
|
||||
matrix.update();
|
||||
vTaskDelay(1000);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user