Compare commits

15 Commits

Author SHA1 Message Date
Matthias Mitscherlich 9cbd2232a3 updated the clock to show special I LOVE YOU date messages
tweaked the LED strip for more stability
2024-03-29 10:42:33 +01:00
Matthias Mitscherlich 22cdad69fc Added the message wordmap and worked on the OTA. Basically functional, but only checks the difference in version, not the actual version number.
LED matrix got row and column write actions
2024-03-28 17:24:12 +01:00
Matthias Mitscherlich 39dcb7cf80 Added temperature handling and temperature wordmap. Also removed to old versions. Integrated and functional 2024-03-25 15:34:16 +01:00
matthias e7dd0ea1f6 Added and integrated bmp280 temperature sensor 2024-03-24 16:30:26 +01:00
matthias 9f63477aa3 removed sdkconfig files and updated the specific defconfig file 2024-03-23 12:34:34 +01:00
matthias ec05cfd9b6 Added ESP console logger as serial interface 2024-03-23 12:32:14 +01:00
Matthias Mitscherlich 55c3ebbbe4 started working on OTA but downloading files is not functional yet 2024-03-22 17:33:53 +01:00
Matthias Mitscherlich 0fcd60ff57 Added the Matrix handling and clock/day wordmaps
Time and day display is functional again
2024-03-21 16:39:20 +01:00
Matthias Mitscherlich ac8505a157 added a new LEDstrip module based on the espressif component 2024-03-20 16:57:08 +01:00
Matthias Mitscherlich 4b26e6080f Nothing special 2024-03-19 17:05:25 +01:00
Matthias Mitscherlich 62c088256f updated the logger for static use without a static interface
added the RGB sensor isl29125
added WIFI
2024-03-14 16:42:57 +01:00
Matthias Mitscherlich 58353a439c removed the old i2c files 2024-03-11 17:03:12 +01:00
Matthias Mitscherlich d5e389f1bd Fixed ISerialBus interface and added device and register address fields so that future i2c and SPI devices can be addressed, to. Added i2c HAL. Tested, working.
The update on the interface required FunctionStatus and the logger to be updated, too
2024-03-11 17:00:07 +01:00
Matthias Mitscherlich a0d13f08c1 Started with a blank main file
- Added GPIO handling
- Added a logger class with additional static debug log handling

Tested, functional
2024-03-11 15:45:48 +01:00
Matthias Mitscherlich 4b31b6c618 Started reorganizing the code. Put everything existing to OLD and began with a new main.cppy 2024-02-29 16:53:16 +01:00
55 changed files with 3801 additions and 7250 deletions
-3852
View File
File diff suppressed because it is too large Load Diff
+2
View File
@@ -5,4 +5,6 @@ cmake_minimum_required(VERSION 3.5)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
get_filename_component(ProjectId ${CMAKE_CURRENT_LIST_DIR} NAME)
string(REPLACE " " "_" ProjectId ${ProjectId})
set(PROJECT_VER "0.1")
project(${ProjectId})
+25 -15
View File
@@ -4,24 +4,34 @@
idf_component_register(
SRCS # list the source files of this component
"main.cpp"
"src/bmp280.cpp"
"src/gpio.cpp"
"src/i2c.cpp"
"src/wifi.cpp"
"src/logger.cpp"
"src/led_strip_encoder.c"
"src/ledmatrix.cpp"
"src/clock.cpp"
"src/wordmap.cpp"
"src/clockwordmap.cpp"
"src/daywordmap.cpp"
"src/temperaturewordmap.cpp"
"src/temperature.cpp"
"hal/src/esplog.cpp"
"hal/src/i2c.cpp"
"hal/src/gpio.cpp"
"hal/src/uart.cpp"
"platform/src/bmp280.cpp"
"platform/src/isl29125.cpp"
"platform/src/logger.cpp"
"platform/src/prgm_ledstrip.cpp"
"platform/src/wifi.cpp"
"platform/src/ledmatrix.cpp"
"application/src/clock.cpp"
"application/src/clockwordmap.cpp"
"application/src/daywordmap.cpp"
"application/src/messagewordmap.cpp"
"application/src/ota.cpp"
"application/src/temperaturewordmap.cpp"
"application/src/temperature.cpp"
"application/src/wordmap.cpp"
INCLUDE_DIRS # optional, add here public include directories
"inc"
"./"
"hal/inc"
"platform/inc"
"application/inc"
PRIV_INCLUDE_DIRS # optional, add here private include directories
REQUIRES # optional, list the public requirements (component names)
PRIV_REQUIRES # optional, list the private requirements
)
component_compile_definitions("ESP_LWIP_COMPONENT_BUILD" "RELEASE=\"0.1\"")
component_compile_definitions("ESP_LWIP_COMPONENT_BUILD" "MAJORRELEASE=0" "MINORRELEASE=1")
+79
View File
@@ -0,0 +1,79 @@
// --------------------------------------------------------------------------------------------------------------------
/// \file FunctionStatus.h
/// \brief File description
// --------------------------------------------------------------------------------------------------------------------
//
// vbchaos software design
//
// --------------------------------------------------------------------------------------------------------------------
/// $Revision: $
/// $Author: $
/// $Date: $
// (c) 2023 vbchaos
// --------------------------------------------------------------------------------------------------------------------
#ifndef MAIN_FUNCTIONSTATUS_H_
#define MAIN_FUNCTIONSTATUS_H_
/**
* FunctionStatus implementation
* \addtogroup Global
*
* The FunctionStatus enumeration is the global function status representation. The values defined here shall
* be used throughout the whole project.
* @{
*/
// --------------------------------------------------------------------------------------------------------------------
// Include files
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Constant and macro definitions
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Type definitions.
// --------------------------------------------------------------------------------------------------------------------
/**
* \enum FunctionStatus
* @{
*/
typedef enum
{
FUNCTION_STATUS_OK = 0, //!< The function execution was successful
FUNCTION_STATUS_ERROR = 1, //!< The function execution caused an unspecified error
FUNCTION_STATUS_NOT_INITIALIZED = 2, //!< The function execution was aborted because the module
//!< instance is not initialized
FUNCTION_STATUS_ALREADY_INITIALIZED = 3, //!< The function execution was aborted because the module
//!< instance is already initialized
FUNCTION_STATUS_UNDEFINED_VALUE = 4, //!< The function failed because an undefined value was used
//!< This most probably happened when checking an enum
FUNCTION_STATUS_NOT_IMPLEMENTED = 5, //!< The required functionality is not (yet) implemented
// Interfaces/Busses
FUNCTION_STATUS_NOT_OPEN = 10, //!< The Interface cannot be used because it has not been opened
FUNCTION_STATUS_ALREADY_OPEN = 11, //!< The interface cannot be opened because it is already open
FUNCTION_STATUS_ALREADY_CLOSE = 12, //!< The interface cannot be closed because it is already closed
} FunctionStatus;
// --------------------------------------------------------------------------------------------------------------------
// Function declarations
// --------------------------------------------------------------------------------------------------------------------
/** @} */
#endif /* MAIN_FUNCTIONSTATUS_H_ */
@@ -13,8 +13,8 @@
// --------------------------------------------------------------------------------------------------------------------
#ifndef MAIN_INC_CLOCK_H_
#define MAIN_INC_CLOCK_H_
#ifndef MAIN_APPLICATION_INC_CLOCK_H_
#define MAIN_APPLICATION_INC_CLOCK_H_
/**
* clock implementation
@@ -47,7 +47,6 @@
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Type definitions.
// --------------------------------------------------------------------------------------------------------------------
@@ -58,42 +57,54 @@
// Function declarations
// --------------------------------------------------------------------------------------------------------------------
using namespace std;
class Clock
{
// -----------------------------------------------------------------------------------------------------------------
// Public Section
// -----------------------------------------------------------------------------------------------------------------
public:
enum mode
typedef enum
{
TEN_BEFORE_HALF,
TWENTY_OVER
};
}Mode_t;
Clock(Clock::mode mode);
// Class Constructor
Clock(Mode_t mode);
void generateWordlist(list<string>* wordlist);
void generateWordlist(std::list<std::string>* wordlist);
time_t getTime(void);
private:
// -----------------------------------------------------------------------------------------------------------------
// Protected Section
// -----------------------------------------------------------------------------------------------------------------
protected:
Clock::mode clockmode;
// -----------------------------------------------------------------------------------------------------------------
// Private Section
// -----------------------------------------------------------------------------------------------------------------
private:
Mode_t clockmode;
time_t currentTime;
string toNumbers[20] {"zero", "one", "two", "three", "four",
std::string toNumbers[20] {"zero", "one", "two", "three", "four",
"five", "six", "seven", "eight",
"nine", "ten", "eleven", "twelve",
"thirteen", "fourteen", "fifteen",
"sixteen", "seventeen", "eighteen",
"nineteen"};
// void toString(TimeStructure* timestructure);
int calculateHours(struct tm time);
};
std::list<struct tm> loveulist;
};
/** @} */
#endif /* MAIN_INC_CLOCK_H_ */
#endif /* MAIN_APPLICATION_INC_CLOCK_H_ */
@@ -57,13 +57,14 @@
// Function declarations
// --------------------------------------------------------------------------------------------------------------------
class ClockWordmap: public Wordmap
class ClockWordmap: public wordmap
{
public:
ClockWordmap(LEDMatrix* matrix);
ClockWordmap(ledmatrix* matrix);
~ClockWordmap();
protected:
void createList_NL(void);
// void createList_EN(void);
void createList_EN(void);
};
@@ -13,8 +13,8 @@
// --------------------------------------------------------------------------------------------------------------------
#ifndef MAIN_INC_DAYWORDMAP_H_
#define MAIN_INC_DAYWORDMAP_H_
#ifndef MAIN_APPLICATION_INC_DAYWORDMAP_H_
#define MAIN_APPLICATION_INC_DAYWORDMAP_H_
/**
* daywordmap implementation
@@ -46,7 +46,6 @@
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Type definitions.
// --------------------------------------------------------------------------------------------------------------------
@@ -57,16 +56,31 @@
// Function declarations
// --------------------------------------------------------------------------------------------------------------------
class DayWordmap: public Wordmap
class DayWordmap : public wordmap
{
// -----------------------------------------------------------------------------------------------------------------
// Public Section
// -----------------------------------------------------------------------------------------------------------------
public:
DayWordmap(LEDMatrix* matrix);
// Class Constructor
DayWordmap(ledmatrix* matrix);
~DayWordmap();
// -----------------------------------------------------------------------------------------------------------------
// Protected Section
// -----------------------------------------------------------------------------------------------------------------
protected:
void createList_NL(void);
// void createList_EN(void);
};
void createList_EN(void);
// -----------------------------------------------------------------------------------------------------------------
// Private Section
// -----------------------------------------------------------------------------------------------------------------
private:
};
/** @} */
#endif /* MAIN_INC_DAYWORDMAP_H_ */
#endif /* MAIN_APPLICATION_INC_DAYWORDMAP_H_ */
@@ -1,5 +1,5 @@
// --------------------------------------------------------------------------------------------------------------------
/// \file wordmap.h
/// \file messagewordmap.h
/// \brief File description
// --------------------------------------------------------------------------------------------------------------------
//
@@ -13,12 +13,12 @@
// --------------------------------------------------------------------------------------------------------------------
#ifndef MAIN_INC_WORDMAP_H_
#define MAIN_INC_WORDMAP_H_
#ifndef MAIN_APPLICATION_INC_MESSAGEWORDMAP_H_
#define MAIN_APPLICATION_INC_MESSAGEWORDMAP_H_
/**
* wordmap implementation
* \defgroup wordmap
* messagewordmap implementation
* \defgroup messagewordmap
* \brief {group_description}
* \addtogroup {Layer}
*
@@ -34,20 +34,18 @@
// CompilerIncludes
// All include files that are provided by the compiler directly
#include <string>
#include <list>
// ProjectIncludes
// All include files that are provided by the project
#include "ledmatrix.h"
#include "wordmap.h"
// --------------------------------------------------------------------------------------------------------------------
// Constant and macro definitions
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Type definitions.
// --------------------------------------------------------------------------------------------------------------------
@@ -58,50 +56,31 @@
// Function declarations
// --------------------------------------------------------------------------------------------------------------------
using namespace std;
class Wordmap
class messagewordmap: public wordmap
{
// -----------------------------------------------------------------------------------------------------------------
// Public Section
// -----------------------------------------------------------------------------------------------------------------
public:
// Class Constructor
messagewordmap(ledmatrix* matrix);
~messagewordmap();
typedef enum language
{
NL = 0,
EN,
NumberOfLanguages
} Language_t;
Wordmap(LEDMatrix* matrix);
bool setColour(uint8_t red, uint8_t green, uint8_t blue);
bool setWord(Language_t lang, string identifier, bool value);
// -----------------------------------------------------------------------------------------------------------------
// Protected Section
// -----------------------------------------------------------------------------------------------------------------
protected:
struct word
{
string identifier;
list<LEDMatrix::coordinate> pixels;
// LEDMatrix::coordinate position;
// int length;
};
LEDMatrix* matrix;
language language;
list<struct word> wordlist[NumberOfLanguages];
void createList_NL(void);
void createList_EN(void);
uint8_t red;
uint8_t green;
uint8_t blue;
// -----------------------------------------------------------------------------------------------------------------
// Private Section
// -----------------------------------------------------------------------------------------------------------------
private:
};
/** @} */
#endif /* MAIN_INC_WORDMAP_H_ */
#endif /* MAIN_APPLICATION_INC_MESSAGEWORDMAP_H_ */
+113
View File
@@ -0,0 +1,113 @@
// --------------------------------------------------------------------------------------------------------------------
/// \file ota.h
/// \brief File description
// --------------------------------------------------------------------------------------------------------------------
//
// vbchaos software design
//
// --------------------------------------------------------------------------------------------------------------------
/// $Revision: $
/// $Author: $
/// $Date: $
// (c) 2023 vbchaos
// --------------------------------------------------------------------------------------------------------------------
#ifndef MAIN_APPLICATION_INC_OTA_H_
#define MAIN_APPLICATION_INC_OTA_H_
/**
* ota implementation
* \defgroup ota
* \brief {group_description}
* \addtogroup {Layer}
*
* Detailed description
* @{
*/
// --------------------------------------------------------------------------------------------------------------------
// Include files
// --------------------------------------------------------------------------------------------------------------------
// CompilerIncludes
// All include files that are provided by the compiler directly
#include <stdint.h>
// ProjectIncludes
// All include files that are provided by the project
#include "esp_event.h"
#include "esp_http_client.h"
// --------------------------------------------------------------------------------------------------------------------
// Constant and macro definitions
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Type definitions.
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Function declarations
// --------------------------------------------------------------------------------------------------------------------
class ota
{
// -----------------------------------------------------------------------------------------------------------------
// Public Section
// -----------------------------------------------------------------------------------------------------------------
public:
typedef enum
{
OTA_STATUS_IDLE = 0,
OTA_STATUS_DOWNLOAD,
OTA_STATUS_VERIFY,
OTA_STATUS_WRITE,
OTA_STATUS_UPDATE,
OTA_STATUS_SUCCESS,
OTA_STATUS_FAIL,
OTA_STATUS_RESTART
}UpdateStatus_t;
struct statusCallbackData
{
UpdateStatus_t status;
int percentage;
};
static const uint32_t checkInterval_ms = 60000;
typedef void (*updateStatusCallback)(struct statusCallbackData* status);
static updateStatusCallback usCallback;
// Class Constructor
ota();
void task(void);
// -----------------------------------------------------------------------------------------------------------------
// Protected Section
// -----------------------------------------------------------------------------------------------------------------
protected:
// -----------------------------------------------------------------------------------------------------------------
// Private Section
// -----------------------------------------------------------------------------------------------------------------
private:
static bool updateActive;
static int imageSize;
static void eventHandler(void* arg, esp_event_base_t event_base, int32_t event_id, void* event_data);
};
/** @} */
#endif /* MAIN_APPLICATION_INC_OTA_H_ */
@@ -13,8 +13,8 @@
// --------------------------------------------------------------------------------------------------------------------
#ifndef MAIN_INC_TEMPERATURE_H_
#define MAIN_INC_TEMPERATURE_H_
#ifndef MAIN_APPLICATION_INC_TEMPERATURE_H_
#define MAIN_APPLICATION_INC_TEMPERATURE_H_
/**
* temperature implementation
@@ -34,20 +34,20 @@
// CompilerIncludes
// All include files that are provided by the compiler directly
#include <stdint.h>
#include <string>
#include <list>
// ProjectIncludes
// All include files that are provided by the project
// --------------------------------------------------------------------------------------------------------------------
// Constant and macro definitions
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Type definitions.
// --------------------------------------------------------------------------------------------------------------------
@@ -58,23 +58,33 @@
// Function declarations
// --------------------------------------------------------------------------------------------------------------------
using namespace std;
class Temperature
class temperature
{
// -----------------------------------------------------------------------------------------------------------------
// Public Section
// -----------------------------------------------------------------------------------------------------------------
public:
Temperature(void);
// Class Constructor
temperature();
void generateWordlist(int temperature, list<string>* wordlist);
void generateWordlist(int temperature, std::list<std::string>* wordlist);
void calculateRGB(int temperature, uint8_t* red, uint8_t* green, uint8_t* blue);
// -----------------------------------------------------------------------------------------------------------------
// Protected Section
// -----------------------------------------------------------------------------------------------------------------
protected:
// -----------------------------------------------------------------------------------------------------------------
// Private Section
// -----------------------------------------------------------------------------------------------------------------
private:
int minTemperature;
int maxTemperature;
};
/** @} */
#endif /* MAIN_INC_TEMPERATURE_H_ */
#endif /* MAIN_APPLICATION_INC_TEMPERATURE_H_ */
@@ -1,5 +1,5 @@
// --------------------------------------------------------------------------------------------------------------------
/// \file TemperatureWordmap.h
/// \file temperaturewordmap.h
/// \brief File description
// --------------------------------------------------------------------------------------------------------------------
//
@@ -13,12 +13,12 @@
// --------------------------------------------------------------------------------------------------------------------
#ifndef MAIN_INC_TEMPERATUREWORDMAP_H_
#define MAIN_INC_TEMPERATUREWORDMAP_H_
#ifndef MAIN_APPLICATION_INC_TEMPERATUREWORDMAP_H_
#define MAIN_APPLICATION_INC_TEMPERATUREWORDMAP_H_
/**
* TemperatureWordmap implementation
* \defgroup TemperatureWordmap
* temperaturewordmap implementation
* \defgroup temperaturewordmap
* \brief {group_description}
* \addtogroup {Layer}
*
@@ -46,7 +46,6 @@
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Type definitions.
// --------------------------------------------------------------------------------------------------------------------
@@ -57,17 +56,32 @@
// Function declarations
// --------------------------------------------------------------------------------------------------------------------
class TemperatureWordmap: public Wordmap
class temperaturewordmap: public wordmap
{
public:
TemperatureWordmap(LEDMatrix* matrix);
// -----------------------------------------------------------------------------------------------------------------
// Public Section
// -----------------------------------------------------------------------------------------------------------------
public:
// Class Constructor
temperaturewordmap(ledmatrix* matrix);
~temperaturewordmap();
// -----------------------------------------------------------------------------------------------------------------
// Protected Section
// -----------------------------------------------------------------------------------------------------------------
protected:
void createList_NL(void);
// void createList_EN(void);
};
void createList_EN(void);
// -----------------------------------------------------------------------------------------------------------------
// Private Section
// -----------------------------------------------------------------------------------------------------------------
private:
};
/** @} */
#endif /* MAIN_INC_TEMPERATUREWORDMAP_H_ */
#endif /* MAIN_APPLICATION_INC_TEMPERATUREWORDMAP_H_ */
+112
View File
@@ -0,0 +1,112 @@
// --------------------------------------------------------------------------------------------------------------------
/// \file wordmap.h
/// \brief File description
// --------------------------------------------------------------------------------------------------------------------
//
// vbchaos software design
//
// --------------------------------------------------------------------------------------------------------------------
/// $Revision: $
/// $Author: $
/// $Date: $
// (c) 2023 vbchaos
// --------------------------------------------------------------------------------------------------------------------
#ifndef MAIN_APPLICATION_INC_WORDMAP_H_
#define MAIN_APPLICATION_INC_WORDMAP_H_
/**
* wordmap implementation
* \defgroup wordmap
* \brief {group_description}
* \addtogroup {Layer}
*
* Detailed description
* @{
*/
// --------------------------------------------------------------------------------------------------------------------
// Include files
// --------------------------------------------------------------------------------------------------------------------
// CompilerIncludes
// All include files that are provided by the compiler directly
#include <string>
#include <list>
// ProjectIncludes
// All include files that are provided by the project
#include "ledmatrix.h"
// --------------------------------------------------------------------------------------------------------------------
// Constant and macro definitions
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Type definitions.
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Function declarations
// --------------------------------------------------------------------------------------------------------------------
class wordmap
{
// -----------------------------------------------------------------------------------------------------------------
// Public Section
// -----------------------------------------------------------------------------------------------------------------
public:
// Class Constructor
typedef enum
{
NL = 0,
EN,
NumberOfLanguages
} Language_t;
wordmap(ledmatrix* matrix);
virtual ~wordmap() {}
bool setColour(uint8_t red, uint8_t green, uint8_t blue);
bool setWord(Language_t lang, std::string& identifier, bool value);
// -----------------------------------------------------------------------------------------------------------------
// Protected Section
// -----------------------------------------------------------------------------------------------------------------
protected:
struct word
{
std::string identifier;
std::list<struct ledmatrix::coordinate> pixels;
};
ledmatrix* matrix;
Language_t language;
std::list<struct word> wordlist[NumberOfLanguages];
virtual void createList_NL(void) = 0;
virtual void createList_EN(void) = 0;
uint8_t red;
uint8_t green;
uint8_t blue;
// -----------------------------------------------------------------------------------------------------------------
// Private Section
// -----------------------------------------------------------------------------------------------------------------
private:
};
/** @} */
#endif /* MAIN_APPLICATION_INC_WORDMAP_H_ */
@@ -17,7 +17,7 @@
// Include files
// --------------------------------------------------------------------------------------------------------------------
#include "clock.h"
#include <clock.h>
#include "esp_sntp.h"
#include "esp_wifi.h"
@@ -28,7 +28,6 @@
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Type definitions
// --------------------------------------------------------------------------------------------------------------------
@@ -51,12 +50,32 @@
// --------------------------------------------------------------------------------------------------------------------
Clock::Clock(Clock::mode mode)
Clock::Clock(Mode_t mode)
{
Clock::currentTime = 40000;
loveulist.clear();
Clock::clockmode = mode;
// Note: The MONTH field starts with 0, while the DAY field starts with 1
// Add weddingday as special day
struct tm weddingday;
weddingday.tm_mon = 5;
weddingday.tm_mday = 7;
loveulist.push_back(weddingday);
// Add aniversary as special day
struct tm anniversary;
anniversary.tm_mon = 7;
anniversary.tm_mday = 31;
loveulist.push_back(anniversary);
// Add Valentines day
struct tm valentine;
valentine.tm_mon = 1;
valentine.tm_mday = 14;
loveulist.push_back(valentine);
currentTime = 40000;
clockmode = mode;
// Start NTP
setenv("TZ", "CET-1CEST-2,M3.5.0/02:00:00,M10.5.0/03:00:00", 1);
@@ -66,17 +85,13 @@ Clock::Clock(Clock::mode mode)
esp_sntp_init();
}
void Clock::generateWordlist(list<string>* wordlist)
void Clock::generateWordlist(std::list<std::string>* wordlist)
{
struct tm tm;
time(&currentTime);
// currentTime += 100;
localtime_r(&currentTime, &tm);
// LOGGER_INFO("%lld\n\r", currentTime);
// LOGGER_INFO("%02i:%02i:%02i\n\r", tm.tm_hour, tm.tm_min, tm.tm_sec);
wordlist->clear();
wordlist->push_back("it");
wordlist->push_back("is");
@@ -182,12 +197,31 @@ void Clock::generateWordlist(list<string>* wordlist)
default:
wordlist->push_back("sunday");
}
// For special days, add the "i love you"
// The message should be shown the whole day over, every 10 minutes for 1 minute
std::list<struct tm>::iterator it;
for (it = loveulist.begin(); it != loveulist.end(); it++)
{
// The day and the month must be equal with todays date
if ((it->tm_mday == tm.tm_mday) && (it->tm_mon == tm.tm_mon))
{
// An entry matches todays date
// Enable the text only every 10 minutes
if ((tm.tm_min % 10) == 0)
{
wordlist->push_back("iloveyou");
// Break out of the loop, an entry has already been found, another one does not add anything
break;
}
}
}
}
time_t Clock::getTime(void)
{
// time(&currentTime);
return currentTime;
}
@@ -196,7 +230,7 @@ int Clock::calculateHours(struct tm time)
{
int hours = time.tm_hour;
// Add one hour in case the clock is heading towards half
if (time.tm_min > 19)
if (time.tm_min >= 19)
{
hours = hours + 1;
}
@@ -214,18 +248,3 @@ int Clock::calculateHours(struct tm time)
return hours;
}
//void Clock::toString(TimeStructure* timestructure)
//{
// LOGGER_SUCCESS("%s%s%s%s%d%s", timestructure->prefix ? "Het is " : "",
// timestructure->fifths == Five ? "Vijf " :
// timestructure->fifths == Ten ? "Tien " :
// timestructure->fifths == Quarter ? "kwart ": "",
// timestructure->beforeAfter == Before ? "voor " :
// timestructure->beforeAfter == After ? "over " : "",
// timestructure->half ? "half " : "",
// timestructure->hours,
// timestructure->hourPostfix ? " uur" : ""
// );
//}
@@ -49,12 +49,17 @@
// --------------------------------------------------------------------------------------------------------------------
ClockWordmap::ClockWordmap(LEDMatrix* matrix) : Wordmap(matrix)
ClockWordmap::ClockWordmap(ledmatrix* matrix) : wordmap(matrix)
{
createList_NL();
createList_EN();
}
ClockWordmap::~ClockWordmap()
{
}
void ClockWordmap::createList_NL(void)
{
// First, clear the list
@@ -93,3 +98,7 @@ void ClockWordmap::createList_NL(void)
}
void ClockWordmap::createList_EN(void)
{
}
@@ -17,16 +17,13 @@
// Include files
// --------------------------------------------------------------------------------------------------------------------
#include "daywordmap.h"
#include "logger.h"
#include <daywordmap.h>
// --------------------------------------------------------------------------------------------------------------------
// Constant and macro definitions
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Type definitions
// --------------------------------------------------------------------------------------------------------------------
@@ -49,12 +46,17 @@
// --------------------------------------------------------------------------------------------------------------------
DayWordmap::DayWordmap(LEDMatrix* matrix) : Wordmap(matrix)
DayWordmap::DayWordmap(ledmatrix* matrix) : wordmap(matrix)
{
createList_NL();
createList_EN();
}
DayWordmap::~DayWordmap()
{
}
void DayWordmap::createList_NL(void)
{
// First, clear the list
@@ -68,9 +70,9 @@ void DayWordmap::createList_NL(void)
wordlist[NL].push_back((struct word){"friday", {{12,11},{13,11},{14,11},{15,11},{16,11},{17,11},{18,11}}});
wordlist[NL].push_back((struct word){"saturday", {{0,10},{1,10},{2,10},{3,10},{4,10},{5,10},{6,10},{7,10}}});
wordlist[NL].push_back((struct word){"sunday", {{7,12},{8,12},{9,12},{10,12},{11,12},{12,12}}});
}
void DayWordmap::createList_EN(void)
{
}
@@ -0,0 +1,86 @@
// --------------------------------------------------------------------------------------------------------------------
/// \file messagewordmap.cpp
/// \brief Description
// --------------------------------------------------------------------------------------------------------------------
//
// vbchaos software design
//
// --------------------------------------------------------------------------------------------------------------------
/// $Revision: $
/// $Author: $
/// $Date: $
// (c) 2023 vbchaos
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Include files
// --------------------------------------------------------------------------------------------------------------------
#include <messagewordmap.h>
// --------------------------------------------------------------------------------------------------------------------
// Constant and macro definitions
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Type definitions
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// File-scope variables
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Function declarations
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Function definitions
// --------------------------------------------------------------------------------------------------------------------
messagewordmap::messagewordmap(ledmatrix* matrix) : wordmap(matrix)
{
createList_NL();
createList_EN();
}
messagewordmap::~messagewordmap()
{
}
void messagewordmap::createList_NL()
{
wordlist[NL].clear();
// The numbers 0 to 10 in digits
wordlist[NL].push_back((struct word){"0", {{3,0}}});
wordlist[NL].push_back((struct word){"1", {{6,0}}});
wordlist[NL].push_back((struct word){"2", {{0,1}}});
wordlist[NL].push_back((struct word){"3", {{5,1}}});
wordlist[NL].push_back((struct word){"4", {{0,3}}});
wordlist[NL].push_back((struct word){"5", {{5,3}}});
wordlist[NL].push_back((struct word){"6", {{10,3}}});
wordlist[NL].push_back((struct word){"7", {{0,5}}});
wordlist[NL].push_back((struct word){"8", {{10,5}}});
wordlist[NL].push_back((struct word){"9", {{5,7}}});
wordlist[NL].push_back((struct word){"10", {{0,11}, {1,11}}});
// The message "I love you"
wordlist[NL].push_back((struct word){"iloveyou", {{5,4}, {6,4},{6,9},{7,9},{8,9},{11,9},{12,9},{13,9},{8,10},{9,10},{10,10}}});
// The heart sign
wordlist[NL].push_back((struct word){"heart", {{11,11}}});
}
void messagewordmap::createList_EN()
{
}
+260
View File
@@ -0,0 +1,260 @@
// --------------------------------------------------------------------------------------------------------------------
/// \file ota.cpp
/// \brief Description
// --------------------------------------------------------------------------------------------------------------------
//
// vbchaos software design
//
// --------------------------------------------------------------------------------------------------------------------
/// $Revision: $
/// $Author: $
/// $Date: $
// (c) 2023 vbchaos
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Include files
// --------------------------------------------------------------------------------------------------------------------
#include <ota.h>
#include "esp_crt_bundle.h"
#include "esp_https_ota.h"
#include "esp_http_client.h"
#include "esp_app_desc.h"
#include "logger.h"
// --------------------------------------------------------------------------------------------------------------------
// Constant and macro definitions
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Type definitions
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// File-scope variables
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Function declarations
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Function definitions
// --------------------------------------------------------------------------------------------------------------------
ota::updateStatusCallback ota::usCallback = NULL;
int ota::imageSize = 0;
bool ota::updateActive = false;
ota::ota()
{
ESP_ERROR_CHECK(esp_event_handler_register(ESP_HTTPS_OTA_EVENT, ESP_EVENT_ANY_ID, &eventHandler, NULL));
struct statusCallbackData cbData;
cbData.status = OTA_STATUS_IDLE;
if (usCallback != NULL)
{
usCallback(&cbData);
}
}
void ota::eventHandler(void* arg, esp_event_base_t event_base, int32_t event_id, void* event_data)
{
if(event_base == ESP_HTTPS_OTA_EVENT)
{
struct statusCallbackData cbData;
cbData.percentage = 0;
switch(event_id)
{
case ESP_HTTPS_OTA_START:
cbData.status = OTA_STATUS_DOWNLOAD;
break;
case ESP_HTTPS_OTA_CONNECTED:
cbData.status = OTA_STATUS_DOWNLOAD;
break;
case ESP_HTTPS_OTA_GET_IMG_DESC:
cbData.status = OTA_STATUS_DOWNLOAD;
break;
case ESP_HTTPS_OTA_VERIFY_CHIP_ID:
cbData.status = OTA_STATUS_VERIFY;
break;
case ESP_HTTPS_OTA_DECRYPT_CB:
cbData.status = OTA_STATUS_VERIFY;
break;
case ESP_HTTPS_OTA_WRITE_FLASH:
{
cbData.percentage = (*(int *)event_data * 100) / imageSize;
cbData.status = OTA_STATUS_WRITE;
break;
}
case ESP_HTTPS_OTA_UPDATE_BOOT_PARTITION:
cbData.status = OTA_STATUS_UPDATE;
break;
case ESP_HTTPS_OTA_FINISH:
cbData.status = OTA_STATUS_SUCCESS;
break;
case ESP_HTTPS_OTA_ABORT:
cbData.status = OTA_STATUS_FAIL;
break;
}
if (usCallback != NULL)
{
usCallback(&cbData);
}
}
}
void ota::task(void)
{
esp_err_t err = ESP_OK;
esp_https_ota_handle_t https_ota_handle = NULL;
static esp_http_client_config_t config;
esp_app_desc_t app_desc;
config.timeout_ms = 60000;
config.keep_alive_enable = true;
config.crt_bundle_attach = esp_crt_bundle_attach;
esp_https_ota_config_t ota_config =
{
.http_config = &config,
.http_client_init_cb = NULL,
.bulk_flash_erase = true,
.partial_http_download = false,
.max_http_request_size = 0, };
LOGGER_INFO("OTA task executing");
// First try to download specific firmware
config.url = "https://esp.vbchaos.nl/code.bin";
LOGGER_INFO("Trying URL %s", config.url);
err = esp_https_ota_begin(&ota_config, &https_ota_handle);
if (err != ESP_OK)
updateActive = false;
{
LOGGER_ERROR("OTA connection failed");
esp_https_ota_abort(https_ota_handle);
// No specific firmware found, try generic firmware
config.url = "https://esp.vbchaos.nl/code.bin";
LOGGER_INFO("Trying URL %s", config.url);
err = esp_https_ota_begin(&ota_config, &https_ota_handle);
if (err != ESP_OK)
{
LOGGER_ERROR("OTA connection failed");
esp_https_ota_abort(https_ota_handle);
}
}
if (err == ESP_OK)
{
err = esp_https_ota_get_img_desc(https_ota_handle, &app_desc);
if (err != ESP_OK)
{
LOGGER_ERROR("Failed to read image header");
esp_https_ota_abort(https_ota_handle);
}
}
if (err == ESP_OK)
{
const esp_app_desc_t* description = esp_app_get_description();
LOGGER_INFO("App description: version: %s (current: %s)", app_desc.version, description->version);
LOGGER_INFO("App description: PrjctName: %s (current: %s)", app_desc.project_name, description->project_name);
LOGGER_INFO("App description: Time: %s (current: %s)", app_desc.time, description->time);
LOGGER_INFO("App description: Date: %s (current: %s)", app_desc.date, description->date);
LOGGER_INFO("App description: IDF Ver: %s (current: %s)", app_desc.idf_ver, description->idf_ver);
if(memcmp(description->version, app_desc.version, sizeof(description->version)) == 0)
{
LOGGER_INFO("OTA version and local version are equal - no OTA update to execute");
err = ESP_FAIL;
struct statusCallbackData cbData;
cbData.status = OTA_STATUS_IDLE;
if (usCallback != NULL)
{
usCallback(&cbData);
}
}
}
if (err == ESP_OK)
{
imageSize = esp_https_ota_get_image_size(https_ota_handle);
LOGGER_INFO("Image is %d bytes large", imageSize);
if (imageSize == -1)
{
err = ESP_FAIL;
esp_https_ota_abort(https_ota_handle);
}
}
if (err == ESP_OK)
{
esp_err_t otaStatus;
do
{
// esp_https_ota_perform returns after every read operation which gives user the ability to
// monitor the status of OTA upgrade by calling esp_https_ota_get_image_len_read, which gives length of image
// data read so far.
//Logger_log("Image bytes read: %d", esp_https_ota_get_image_len_read(https_ota_handle));
otaStatus = esp_https_ota_perform(https_ota_handle);
} while (otaStatus == ESP_ERR_HTTPS_OTA_IN_PROGRESS);
if (!esp_https_ota_is_complete_data_received(https_ota_handle))
{
// the OTA image was not completely received and user can customise the response to this situation.
LOGGER_ERROR("Complete data was not received.");
err = ESP_FAIL;
esp_https_ota_abort(https_ota_handle);
}
}
if (err == ESP_OK)
{
err = esp_https_ota_finish(https_ota_handle);
if (err != ESP_OK)
{
LOGGER_ERROR("Image validation failed, image is corrupted");
}
}
if (err == ESP_OK)
{
LOGGER_SUCCESS("OTA upgrade successful");
LOGGER_INFO("Rebooting");
vTaskDelay(100);
esp_restart();
}
}
@@ -17,7 +17,7 @@
// Include files
// --------------------------------------------------------------------------------------------------------------------
#include "temperature.h"
#include <temperature.h>
#include "logger.h"
@@ -26,7 +26,6 @@
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Type definitions
// --------------------------------------------------------------------------------------------------------------------
@@ -49,14 +48,14 @@
// --------------------------------------------------------------------------------------------------------------------
Temperature::Temperature()
temperature::temperature()
{
Temperature::minTemperature = 14;
Temperature::maxTemperature = 29;
this->minTemperature = 14;
this->maxTemperature = 29;
};
void Temperature::generateWordlist(int temperature, list<string>* wordlist)
void temperature::generateWordlist(int temperature, std::list<std::string>* wordlist)
{
// Clear the list
wordlist->clear();
@@ -68,17 +67,17 @@ void Temperature::generateWordlist(int temperature, list<string>* wordlist)
// Temperature value to string
if (temperature < minTemperature)
{
wordlist->push_back("below");
wordlist->push_back(to_string(minTemperature));
wordlist->push_back("below");
wordlist->push_back(std::to_string(minTemperature));
}
else if (temperature > maxTemperature)
{
wordlist->push_back("above");
wordlist->push_back(to_string(maxTemperature));
wordlist->push_back("above");
wordlist->push_back(std::to_string(maxTemperature));
}
else
{
wordlist->push_back(to_string(temperature));
wordlist->push_back(std::to_string(temperature));
}
// Add fixed postamble
@@ -86,38 +85,38 @@ void Temperature::generateWordlist(int temperature, list<string>* wordlist)
}
void Temperature::calculateRGB(int temperature, uint8_t* red, uint8_t* green, uint8_t* blue)
void temperature::calculateRGB(int temperature, uint8_t* red, uint8_t* green, uint8_t* blue)
{
int calcBlue = 0;
int calcRed = 0;
int calcBlue = 0;
int calcRed = 0;
int factor = 100 / (maxTemperature - minTemperature);
int factor = 100 / (maxTemperature - minTemperature);
LOGGER_INFO("Incoming Temperature is: %i (min: %i, max: %i", temperature, minTemperature, maxTemperature);
LOGGER_INFO("Incoming Temperature is: %i (min: %i, max: %i)", temperature, minTemperature, maxTemperature);
if (temperature < minTemperature)
{
calcBlue = 0xFF;
calcRed = 0x00;
}
else if (temperature > maxTemperature)
{
calcBlue = 0x00;
calcRed = 0xFF;
}
else
{
calcBlue = (((maxTemperature - temperature) * factor) * 0xFF) / 100;
calcRed = (((temperature - minTemperature) * factor) * 0xFF) / 100;
}
if (temperature < minTemperature)
{
calcBlue = 0xFF;
calcRed = 0x00;
}
else if (temperature > maxTemperature)
{
calcBlue = 0x00;
calcRed = 0xFF;
}
else
{
calcBlue = (((maxTemperature - temperature) * factor) * 0xFF) / 100;
calcRed = (((temperature - minTemperature) * factor) * 0xFF) / 100;
}
LOGGER_PRINT("\n\rRed %i %x (%i)", calcRed, calcRed, (temperature - minTemperature) * factor);
LOGGER_PRINT("\n\rGreen %i %x", 0, 0);
LOGGER_PRINT("\n\rBlue %i %x (%i)", calcBlue, calcBlue, (maxTemperature - temperature) * factor);
LOGGER_PRINT("\n\rRed %i %x (%i)", calcRed, calcRed, (temperature - minTemperature) * factor);
LOGGER_PRINT("\n\rGreen %i %x", 0, 0);
LOGGER_PRINT("\n\rBlue %i %x (%i)", calcBlue, calcBlue, (maxTemperature - temperature) * factor);
*red = calcRed & 0xFF;
*green = 0x00;
*blue = calcBlue & 0xFF;
*green = 0x00;
*blue = calcBlue & 0xFF;
}
@@ -17,16 +17,13 @@
// Include files
// --------------------------------------------------------------------------------------------------------------------
#include "temperaturewordmap.h"
#include "logger.h"
#include <temperaturewordmap.h>
// --------------------------------------------------------------------------------------------------------------------
// Constant and macro definitions
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Type definitions
// --------------------------------------------------------------------------------------------------------------------
@@ -49,13 +46,18 @@
// --------------------------------------------------------------------------------------------------------------------
TemperatureWordmap::TemperatureWordmap(LEDMatrix* matrix) : Wordmap(matrix)
temperaturewordmap::temperaturewordmap(ledmatrix* matrix) : wordmap(matrix)
{
createList_NL();
createList_EN();
}
void TemperatureWordmap::createList_NL(void)
temperaturewordmap::~temperaturewordmap()
{
}
void temperaturewordmap::createList_NL(void)
{
// First, clear the list
wordlist[NL].clear();
@@ -88,9 +90,12 @@ void TemperatureWordmap::createList_NL(void)
wordlist[NL].push_back((struct word){"29", {{15,6},{16,6},{17,6},{18,6},{19,6},{12,7},{13,7},{11,8},{12,8},{13,8},{14,8},{15,8},{16,8},{17,8}}});
wordlist[NL].push_back((struct word){"degrees", {{14,9},{15,9},{16,9},{17,9},{18,9},{19,9}}});
// Nice weather
wordlist[NL].push_back((struct word){"niceweather",{{16,0},{18,0},{19,0},{16,1},{17,1},{18,1},{19,1},{8,2},{9,2},{10,2},{11,2}}});
}
void temperaturewordmap::createList_EN(void)
{
}
@@ -17,9 +17,7 @@
// Include files
// --------------------------------------------------------------------------------------------------------------------
#include "wordmap.h"
#include "logger.h"
#include <wordmap.h>
#include <algorithm>
// --------------------------------------------------------------------------------------------------------------------
@@ -27,7 +25,6 @@
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Type definitions
// --------------------------------------------------------------------------------------------------------------------
@@ -50,16 +47,16 @@
// --------------------------------------------------------------------------------------------------------------------
Wordmap::Wordmap(LEDMatrix* matrix)
wordmap::wordmap(ledmatrix* matrix)
{
Wordmap::matrix = matrix;
Wordmap::language = NL;
Wordmap::red = 0xFF;
Wordmap::green = 0xFF;
Wordmap::blue = 0xFF;
wordmap::matrix = matrix;
wordmap::language = NL;
wordmap::red = 0xFF;
wordmap::green = 0xFF;
wordmap::blue = 0xFF;
}
bool Wordmap::setWord(Language_t lang, string identifier, bool value)
bool wordmap::setWord(Language_t lang, std::string& identifier, bool value)
{
bool returnValue;
@@ -92,11 +89,17 @@ bool Wordmap::setWord(Language_t lang, string identifier, bool value)
if (returnValue)
{
std::list<LEDMatrix::coordinate>::iterator pixel;
std::list<ledmatrix::coordinate>::iterator pixel;
for (pixel = it->pixels.begin(); pixel != it->pixels.end(); pixel++)
{
matrix->setPixelValue(pixel->x, pixel->y, value);
matrix->setPixelColour(pixel->x, pixel->y, Wordmap::red, Wordmap::green, Wordmap::blue);
if (value)
{
matrix->setPixel(pixel->y, pixel->x, wordmap::red, wordmap::green, wordmap::blue);
}
else
{
matrix->setPixel(pixel->y, pixel->x, 0, 0, 0);
}
}
}
@@ -104,28 +107,26 @@ bool Wordmap::setWord(Language_t lang, string identifier, bool value)
}
bool Wordmap::setColour(uint8_t red, uint8_t green, uint8_t blue)
bool wordmap::setColour(uint8_t red, uint8_t green, uint8_t blue)
{
bool returnValue = true;
Wordmap::red = red;
Wordmap::green = green;
Wordmap::blue = blue;
wordmap::red = red;
wordmap::green = green;
wordmap::blue = blue;
return returnValue;
}
void Wordmap::createList_NL(void)
void wordmap::createList_NL(void)
{
// First, clear the list
wordlist[NL].clear();
}
void Wordmap::createList_EN(void)
void wordmap::createList_EN(void)
{
// First, clear the list
wordlist[EN].clear();
}
+105
View File
@@ -0,0 +1,105 @@
// --------------------------------------------------------------------------------------------------------------------
/// \file ISerialBus.h
/// \brief File description
// --------------------------------------------------------------------------------------------------------------------
//
// vbchaos software design
//
// --------------------------------------------------------------------------------------------------------------------
/// $Revision: $
/// $Author: $
/// $Date: $
// (c) 2023 vbchaos
// --------------------------------------------------------------------------------------------------------------------
#ifndef MAIN_HAL_INC_ISERIALBUS_H_
#define MAIN_HAL_INC_ISERIALBUS_H_
/**
* ISerialBus implementation
* \defgroup ISerialBus
* \brief {group_description}
* \addtogroup {Layer}
*
* Detailed description
* @{
*/
// --------------------------------------------------------------------------------------------------------------------
// Include files
// --------------------------------------------------------------------------------------------------------------------
// CompilerIncludes
// All include files that are provided by the compiler directly
#include <stdint.h>
// ProjectIncludes
// All include files that are provided by the project
#include "FunctionStatus.h"
// --------------------------------------------------------------------------------------------------------------------
// Constant and macro definitions
// --------------------------------------------------------------------------------------------------------------------
#define NO_DEVICE_ADDRESS (255)
#define NO_REGISTER_ADDRESS (255)
// --------------------------------------------------------------------------------------------------------------------
// Type definitions.
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Function declarations
// --------------------------------------------------------------------------------------------------------------------
template<typename T>
class ISerialBus
{
// -----------------------------------------------------------------------------------------------------------------
// Public Section
// -----------------------------------------------------------------------------------------------------------------
public:
// Virtual Class Destructor (required for absolute virtual classes)
virtual ~ISerialBus() {}
FunctionStatus open() {status = OPEN; return FUNCTION_STATUS_OK;}
FunctionStatus close() {status = CLOSED; return FUNCTION_STATUS_OK;}
virtual FunctionStatus read(T deviceAddress, T registerAddress, T* buffer, uint32_t length, uint32_t* actualLength) = 0;
virtual FunctionStatus write(T deviceAddress, T registerAddress, T* buffer, uint32_t length) = 0;
// -----------------------------------------------------------------------------------------------------------------
// Protected Section
// -----------------------------------------------------------------------------------------------------------------
protected:
typedef enum
{
CLOSED = 0,
OPEN
} Status_t;
// The current open/close status of the interface
Status_t status;
// -----------------------------------------------------------------------------------------------------------------
// Private Section
// -----------------------------------------------------------------------------------------------------------------
private:
};
/** @} */
#endif /* MAIN_HAL_INC_ISERIALBUS_H_ */
+89
View File
@@ -0,0 +1,89 @@
// --------------------------------------------------------------------------------------------------------------------
/// \file esplog.h
/// \brief File description
// --------------------------------------------------------------------------------------------------------------------
//
// vbchaos software design
//
// --------------------------------------------------------------------------------------------------------------------
/// $Revision: $
/// $Author: $
/// $Date: $
// (c) 2023 vbchaos
// --------------------------------------------------------------------------------------------------------------------
#ifndef MAIN_HAL_INC_UART_H_
#define MAIN_HAL_INC_UART_H_
/**
* esplog implementation
* \defgroup esplog
* \brief {group_description}
* \addtogroup {Layer}
*
* Detailed description
* @{
*/
// --------------------------------------------------------------------------------------------------------------------
// Include files
// --------------------------------------------------------------------------------------------------------------------
// CompilerIncludes
// All include files that are provided by the compiler directly
#include <stdint.h>
// ProjectIncludes
// All include files that are provided by the project
#include "ISerialBus.h"
// --------------------------------------------------------------------------------------------------------------------
// Constant and macro definitions
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Type definitions.
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Function declarations
// --------------------------------------------------------------------------------------------------------------------
class esplog : public ISerialBus<uint8_t>
{
// -----------------------------------------------------------------------------------------------------------------
// Public Section
// -----------------------------------------------------------------------------------------------------------------
public:
// Class Constructor
esplog();
~esplog();
FunctionStatus read(uint8_t deviceAddress, uint8_t registerAddress, uint8_t* buffer, uint32_t length, uint32_t* actualLength);
FunctionStatus write(uint8_t deviceAddress, uint8_t registerAddress, uint8_t* buffer, uint32_t length);
// -----------------------------------------------------------------------------------------------------------------
// Protected Section
// -----------------------------------------------------------------------------------------------------------------
protected:
// -----------------------------------------------------------------------------------------------------------------
// Private Section
// -----------------------------------------------------------------------------------------------------------------
private:
};
/** @} */
#endif /* MAIN_HAL_INC_UART_H_ */
+122
View File
@@ -0,0 +1,122 @@
// --------------------------------------------------------------------------------------------------------------------
/// \file gpio.h
/// \brief File description
// --------------------------------------------------------------------------------------------------------------------
//
// vbchaos software design
//
// --------------------------------------------------------------------------------------------------------------------
/// $Revision: $
/// $Author: $
/// $Date: $
// (c) 2023 vbchaos
// --------------------------------------------------------------------------------------------------------------------
#ifndef MAIN_HAL_INC_GPIO_H_
#define MAIN_HAL_INC_GPIO_H_
/**
* gpio implementation
* \defgroup gpio
* \brief {group_description}
* \addtogroup {Layer}
*
* Detailed description
* @{
*/
// --------------------------------------------------------------------------------------------------------------------
// Include files
// --------------------------------------------------------------------------------------------------------------------
// CompilerIncludes
// All include files that are provided by the compiler directly
#include <stdbool.h>
#include <stdint.h>
// ProjectIncludes
// All include files that are provided by the project
#include "FunctionStatus.h" //!< Include to use the generic function status enumeration type
// --------------------------------------------------------------------------------------------------------------------
// Constant and macro definitions
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Type definitions.
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Function declarations
// --------------------------------------------------------------------------------------------------------------------
class gpio
{
// -----------------------------------------------------------------------------------------------------------------
// Public Section
// -----------------------------------------------------------------------------------------------------------------
public:
typedef enum
{
GPIO_DIRECTION_INPUT = 0,
GPIO_DIRECTION_OUTPUT = 1
} Direction_t;
typedef enum
{
GPIO_VALUE_LOW = 0,
GPIO_VALUE_HIGH = 1
} Value_t;
/** -------------------------------------------------------------------------------------------------------------
* GPIO
* \brief Constructs a new instance of GPIO
*
*
* @param number The IO instance given in as its unique GPIO number
* @param direction Direction of the GPIO.
* Default value: @arg GPIO_DIRECTION_INPUT
* @arg GPIO_DIRECTION_INPUT for incoming signal
* @arg GPIO_DIRECTION_OUTPUT for outgoing signal
* @param initialValue The initial value for this GPIO. For outputs the given value will be
* applied immediately after initialization. For inputs this value is only
* initial and is not the real representation of the input.
* Default value: @arg GPIO_VALUE_LOW
* @arg GPIO_VALUE_LOW the signal at the GPIO is equal to GND
* @arg GPIO_VALUE_HIGH the signal at the GPIO is equal to VCC
* --------------------------------------------------------------------------------------------------------------
*/
gpio(uint32_t number, Direction_t direction = GPIO_DIRECTION_INPUT, Value_t initialValue = GPIO_VALUE_LOW);
FunctionStatus set(Value_t value);
FunctionStatus get(Value_t* const value);
FunctionStatus toogle();
// -----------------------------------------------------------------------------------------------------------------
// Protected Section
// -----------------------------------------------------------------------------------------------------------------
protected:
uint32_t number;
Direction_t direction;
Value_t currentState;
// -----------------------------------------------------------------------------------------------------------------
// Private Section
// -----------------------------------------------------------------------------------------------------------------
private:
};
/** @} */
#endif /* MAIN_HAL_INC_GPIO_H_ */
+96
View File
@@ -0,0 +1,96 @@
// --------------------------------------------------------------------------------------------------------------------
/// \file i2c.h
/// \brief File description
// --------------------------------------------------------------------------------------------------------------------
//
// vbchaos software design
//
// --------------------------------------------------------------------------------------------------------------------
/// $Revision: $
/// $Author: $
/// $Date: $
// (c) 2023 vbchaos
// --------------------------------------------------------------------------------------------------------------------
#ifndef MAIN_HAL_INC_I2C_H_
#define MAIN_HAL_INC_I2C_H_
/**
* i2c implementation
* \defgroup i2c
* \brief {group_description}
* \addtogroup {Layer}
*
* Detailed description
* @{
*/
// --------------------------------------------------------------------------------------------------------------------
// Include files
// --------------------------------------------------------------------------------------------------------------------
// CompilerIncludes
// All include files that are provided by the compiler directly
// ProjectIncludes
// All include files that are provided by the project
#include "ISerialBus.h"
#include "driver/i2c.h"
// --------------------------------------------------------------------------------------------------------------------
// Constant and macro definitions
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Type definitions.
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Function declarations
// --------------------------------------------------------------------------------------------------------------------
class i2c : public ISerialBus<uint8_t>
{
// -----------------------------------------------------------------------------------------------------------------
// Public Section
// -----------------------------------------------------------------------------------------------------------------
public:
// Class Constructor
i2c(i2c_port_t* port);
~i2c();
FunctionStatus read(uint8_t deviceAddress, uint8_t registerAddress, uint8_t* buffer, uint32_t length, uint32_t* actualLength);
FunctionStatus write(uint8_t deviceAddress, uint8_t registerAddress, uint8_t* buffer, uint32_t length);
// -----------------------------------------------------------------------------------------------------------------
// Protected Section
// -----------------------------------------------------------------------------------------------------------------
protected:
// -----------------------------------------------------------------------------------------------------------------
// Private Section
// -----------------------------------------------------------------------------------------------------------------
private:
void intWrite(uint8_t slaveAddress, uint8_t registerAddress, uint8_t* data, uint8_t length);
void intRead(uint8_t slaveAddress, uint8_t registerAddress, uint8_t* data, uint8_t length);
i2c_port_t* port;
};
/** @} */
#endif /* MAIN_HAL_INC_I2C_H_ */
@@ -1,5 +1,5 @@
// --------------------------------------------------------------------------------------------------------------------
/// \file i2c.h
/// \file uart.h
/// \brief File description
// --------------------------------------------------------------------------------------------------------------------
//
@@ -13,12 +13,12 @@
// --------------------------------------------------------------------------------------------------------------------
#ifndef MAIN_INC_I2C_H_
#define MAIN_INC_I2C_H_
#ifndef MAIN_HAL_INC_UART_H_
#define MAIN_HAL_INC_UART_H_
/**
* i2c implementation
* \defgroup i2c
* uart implementation
* \defgroup uart
* \brief {group_description}
* \addtogroup {Layer}
*
@@ -34,18 +34,19 @@
// CompilerIncludes
// All include files that are provided by the compiler directly
#include "stdint.h"
#include <stdint.h>
// ProjectIncludes
// All include files that are provided by the project
#include "ISerialBus.h"
#include "driver/uart.h"
// --------------------------------------------------------------------------------------------------------------------
// Constant and macro definitions
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Type definitions.
// --------------------------------------------------------------------------------------------------------------------
@@ -56,31 +57,35 @@
// Function declarations
// --------------------------------------------------------------------------------------------------------------------
class I2C
class uart : public ISerialBus<uint8_t>
{
// -----------------------------------------------------------------------------------------------------------------
// Public Section
// -----------------------------------------------------------------------------------------------------------------
public:
// Class Constructor
uart(uart_port_t* uartPort);
~uart();
I2C(unsigned int SCL, unsigned int SDA);
FunctionStatus read(uint8_t deviceAddress, uint8_t registerAddress, uint8_t* buffer, uint32_t length, uint32_t* actualLength);
bool write_register(uint8_t slaveAddress, uint8_t registerAddress, uint8_t* const data, uint8_t length);
FunctionStatus write(uint8_t deviceAddress, uint8_t registerAddress, uint8_t* buffer, uint32_t length);
bool read_register(uint8_t slaveAddress, uint8_t registerAddress, uint8_t* data, uint8_t length);
// -----------------------------------------------------------------------------------------------------------------
// Protected Section
// -----------------------------------------------------------------------------------------------------------------
protected:
// -----------------------------------------------------------------------------------------------------------------
// Private Section
// -----------------------------------------------------------------------------------------------------------------
private:
uart_port_t* port;
static unsigned int number;
unsigned int thisNumber;
unsigned int SCL;
unsigned int SDA;
unsigned int frequency;
unsigned int timeout_ms;
void write(uint8_t slaveAddress, uint8_t registerAddress, uint8_t* const data, uint8_t length);
void read(uint8_t slaveAddress, uint8_t registerAddress, uint8_t* data, uint8_t length);
};
/** @} */
#endif /* MAIN_INC_I2C_H_ */
#endif /* MAIN_HAL_INC_UART_H_ */
@@ -1,10 +1,10 @@
// --------------------------------------------------------------------------------------------------------------------
/// \file gpio.h
/// \brief File description
/// \file esplog.cpp
/// \brief Description
// --------------------------------------------------------------------------------------------------------------------
//
// vbchaos software design
//
// vbchaos software design
//
// --------------------------------------------------------------------------------------------------------------------
/// $Revision: $
/// $Author: $
@@ -13,71 +13,78 @@
// --------------------------------------------------------------------------------------------------------------------
#ifndef MAIN_INC_GPIO_H_
#define MAIN_INC_GPIO_H_
// --------------------------------------------------------------------------------------------------------------------
// Include files
// --------------------------------------------------------------------------------------------------------------------
#include "esplog.h"
#include "esp_log.h"
// --------------------------------------------------------------------------------------------------------------------
// Constant and macro definitions
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Include files
// Type definitions
// --------------------------------------------------------------------------------------------------------------------
// CompilerIncludes
// All include files that are provided by the compiler directly
// ProjectIncludes
// All include files that are provided by the project
// --------------------------------------------------------------------------------------------------------------------
// Constant and macro definitions
// File-scope variables
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Type definitions.
// Function declarations
// --------------------------------------------------------------------------------------------------------------------
typedef enum
// --------------------------------------------------------------------------------------------------------------------
// Function definitions
// --------------------------------------------------------------------------------------------------------------------
esplog::esplog()
{
GPIO_DIRECTION_INPUT = 0,
GPIO_DIRECTION_OUTPUT = 1
} GPIO_Direction_t;
this->status = CLOSED;
}
typedef enum
esplog::~esplog()
{
GPIO_VALUE_LOW = 0,
GPIO_VALUE_HIGH = 1
} GPIO_Value_t;
// --------------------------------------------------------------------------------------------------------------------
// Function declarations
// --------------------------------------------------------------------------------------------------------------------
}
class GPIO
FunctionStatus esplog::write(uint8_t deviceAddress, uint8_t registerAddress, uint8_t* buffer, uint32_t length)
{
public:
FunctionStatus returnValue = FUNCTION_STATUS_OK;
GPIO(int number, GPIO_Direction_t direction);
if (status == OPEN)
{
ESP_LOGI("", "%s", buffer);
}
else
{
returnValue = FUNCTION_STATUS_NOT_OPEN;
}
bool SetOutput(GPIO_Value_t value);
return returnValue;
}
GPIO_Value_t GetInput(void);
FunctionStatus esplog::read(uint8_t deviceAddress, uint8_t registerAddress, uint8_t* buffer, uint32_t length, uint32_t* actualLength)
{
FunctionStatus returnValue = FUNCTION_STATUS_OK;
if (status == OPEN)
{
// Do Stuff
}
else
{
returnValue = FUNCTION_STATUS_NOT_OPEN;
}
private:
int number;
GPIO_Direction_t direction;
GPIO_Value_t value = GPIO_VALUE_LOW;
};
/** @} */
#endif /* MAIN_INC_GPIO_H_ */
return returnValue;
}
@@ -1,5 +1,5 @@
// --------------------------------------------------------------------------------------------------------------------
/// \file gpio.cpp
/// \file gpio.c
/// \brief Description
// --------------------------------------------------------------------------------------------------------------------
//
@@ -20,14 +20,11 @@
#include <gpio.h>
#include "driver/gpio.h"
// --------------------------------------------------------------------------------------------------------------------
// Constant and macro definitions
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Type definitions
// --------------------------------------------------------------------------------------------------------------------
@@ -49,7 +46,8 @@
// Function definitions
// --------------------------------------------------------------------------------------------------------------------
GPIO::GPIO(int number, GPIO_Direction_t direction)
gpio::gpio(uint32_t number, Direction_t direction, Value_t initialValue)
{
this->number = number;
this->direction = direction;
@@ -69,38 +67,61 @@ GPIO::GPIO(int number, GPIO_Direction_t direction)
//configure GPIO with the given settings
ESP_ERROR_CHECK(gpio_config(&io_conf));
this->currentState = GPIO_VALUE_LOW;
set(initialValue);
}
bool GPIO::SetOutput(GPIO_Value_t value)
FunctionStatus gpio::set(Value_t value)
{
bool returnValue = false;
FunctionStatus returnValue = FUNCTION_STATUS_ERROR;
if (this->direction == GPIO_DIRECTION_OUTPUT)
{
ESP_ERROR_CHECK(gpio_set_level((gpio_num_t)this->number, (uint32_t)value));
this->value = value;
returnValue = true;
}
else
{
returnValue = false;
this->currentState = value;
returnValue = FUNCTION_STATUS_OK;
}
return returnValue;
}
GPIO_Value_t GPIO::GetInput(void)
FunctionStatus gpio::get(Value_t* value)
{
FunctionStatus returnValue = FUNCTION_STATUS_OK;
if (gpio_get_level((gpio_num_t)this->number))
{
this->value = GPIO_VALUE_HIGH;
this->currentState = GPIO_VALUE_HIGH;
}
else
{
this->value = GPIO_VALUE_LOW;
this->currentState = GPIO_VALUE_LOW;
}
return this->value;
*value = this->currentState;
return returnValue;
}
FunctionStatus gpio::toogle()
{
FunctionStatus returnValue = FUNCTION_STATUS_ERROR;
if (this->currentState == GPIO_VALUE_LOW)
{
// Going to HIGH
set(GPIO_VALUE_HIGH);
}
else
{
// Going to LOW
set(GPIO_VALUE_LOW);
}
return returnValue;
}
@@ -17,17 +17,12 @@
// Include files
// --------------------------------------------------------------------------------------------------------------------
#include "i2c.h"
#include "driver/i2c.h"
#include <i2c.h>
// --------------------------------------------------------------------------------------------------------------------
// Constant and macro definitions
// --------------------------------------------------------------------------------------------------------------------
#define I2C_MASTER_FREQ_HZ 400000 /*!< I2C master clock frequency */
#define I2C_MASTER_TX_BUF_DISABLE 0 /*!< I2C master doesn't need buffer */
#define I2C_MASTER_RX_BUF_DISABLE 0 /*!< I2C master doesn't need buffer */
#define I2C_MASTER_TIMEOUT_MS 1000
// --------------------------------------------------------------------------------------------------------------------
@@ -51,58 +46,54 @@
// Function definitions
// --------------------------------------------------------------------------------------------------------------------
// Reset the class variable
unsigned int I2C::number = 0;
I2C::I2C(unsigned int SCL, unsigned int SDA)
i2c::i2c(i2c_port_t* port) : port {port}
{
I2C::thisNumber = number++;
I2C::SCL = SCL;
I2C::SDA = SDA;
I2C::frequency = I2C_MASTER_FREQ_HZ;
I2C::timeout_ms = I2C_MASTER_TIMEOUT_MS;
//
i2c_port_t i2c_master_port = (i2c_port_t)I2C::thisNumber;
}
i2c_config_t conf = {
.mode = I2C_MODE_MASTER,
.sda_io_num = (int)I2C::SDA,
.scl_io_num = (int)I2C::SCL,
.sda_pullup_en = GPIO_PULLUP_ENABLE,
.scl_pullup_en = GPIO_PULLUP_ENABLE,
.master = {I2C::frequency},
.clk_flags = 0
};
ESP_ERROR_CHECK(i2c_param_config(i2c_master_port, &conf));
ESP_ERROR_CHECK(i2c_driver_install(i2c_master_port, conf.mode, I2C_MASTER_RX_BUF_DISABLE, I2C_MASTER_TX_BUF_DISABLE, 0));
i2c::~i2c()
{
}
bool I2C::write_register(uint8_t slaveAddress, uint8_t registerAddress, uint8_t* const data, uint8_t length)
FunctionStatus i2c::write(uint8_t deviceAddress, uint8_t registerAddress, uint8_t* buffer, uint32_t length)
{
bool returnValue = true;
FunctionStatus returnValue = FUNCTION_STATUS_OK;
write(slaveAddress, registerAddress, data, length);
if (status == OPEN)
{
intWrite(deviceAddress, registerAddress, buffer, length);
}
else
{
returnValue = FUNCTION_STATUS_NOT_OPEN;
}
return returnValue;
}
bool I2C::read_register(uint8_t slaveAddress, uint8_t registerAddress, uint8_t* data, uint8_t length)
FunctionStatus i2c::read(uint8_t deviceAddress, uint8_t registerAddress, uint8_t* buffer, uint32_t length, uint32_t* actualLength)
{
bool returnValue = true;
FunctionStatus returnValue = FUNCTION_STATUS_OK;
read(slaveAddress, registerAddress, data, length);
if (status == OPEN)
{
intRead(deviceAddress, registerAddress, buffer, length);
*actualLength = length;
}
else
{
returnValue = FUNCTION_STATUS_NOT_OPEN;
}
return returnValue;
}
void I2C::write(uint8_t slaveAddress, uint8_t registerAddress, uint8_t* const data, uint8_t length)
void i2c::intWrite(uint8_t slaveAddress, uint8_t registerAddress, uint8_t* data, uint8_t length)
{
uint8_t buffer[length + 1];
@@ -112,11 +103,11 @@ void I2C::write(uint8_t slaveAddress, uint8_t registerAddress, uint8_t* const da
buffer[i+1] = data[i];
}
ESP_ERROR_CHECK(i2c_master_write_to_device((i2c_port_t)thisNumber, slaveAddress, buffer, sizeof(buffer), timeout_ms / portTICK_PERIOD_MS));
ESP_ERROR_CHECK(i2c_master_write_to_device(*port, slaveAddress, buffer, sizeof(buffer), I2C_MASTER_TIMEOUT_MS / portTICK_PERIOD_MS));
}
void I2C::read(uint8_t slaveAddress, uint8_t registerAddress, uint8_t* data, uint8_t length)
void i2c::intRead(uint8_t slaveAddress, uint8_t registerAddress, uint8_t* data, uint8_t length)
{
ESP_ERROR_CHECK(i2c_master_write_read_device((i2c_port_t)thisNumber, slaveAddress, &registerAddress, 1, data, length, timeout_ms / portTICK_PERIOD_MS));
ESP_ERROR_CHECK(i2c_master_write_read_device(*port, slaveAddress, &registerAddress, 1, data, length, I2C_MASTER_TIMEOUT_MS / portTICK_PERIOD_MS));
}
+100
View File
@@ -0,0 +1,100 @@
// --------------------------------------------------------------------------------------------------------------------
/// \file uart.cpp
/// \brief Description
// --------------------------------------------------------------------------------------------------------------------
//
// vbchaos software design
//
// --------------------------------------------------------------------------------------------------------------------
/// $Revision: $
/// $Author: $
/// $Date: $
// (c) 2023 vbchaos
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Include files
// --------------------------------------------------------------------------------------------------------------------
#include "uart.h"
// --------------------------------------------------------------------------------------------------------------------
// Constant and macro definitions
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Type definitions
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// File-scope variables
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Function declarations
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Function definitions
// --------------------------------------------------------------------------------------------------------------------
uart::uart(uart_port_t* uartPort)
{
this->port = uartPort;
this->status = CLOSED;
}
uart::~uart()
{
}
FunctionStatus uart::write(uint8_t deviceAddress, uint8_t registerAddress, uint8_t* buffer, uint32_t length)
{
FunctionStatus returnValue = FUNCTION_STATUS_OK;
if (status == OPEN)
{
// For UART devices it is allowed to ignore the device or register address if it is requested as such
// The common case is that both addresses are ignorable since UARTs are mostly not used this way, so this
// implementation contains a shortcut and will immediatly write the buffer to the bus
if ((deviceAddress == NO_DEVICE_ADDRESS) && (registerAddress == NO_REGISTER_ADDRESS))
{
uart_write_bytes(*this->port, (const void*)buffer, length);
}
else
{
returnValue = FUNCTION_STATUS_NOT_IMPLEMENTED;
}
}
else
{
returnValue = FUNCTION_STATUS_NOT_OPEN;
}
return returnValue;
}
FunctionStatus uart::read(uint8_t deviceAddress, uint8_t registerAddress, uint8_t* buffer, uint32_t length, uint32_t* actualLength)
{
FunctionStatus returnValue = FUNCTION_STATUS_OK;
if (status == OPEN)
{
// Do Stuff
}
else
{
returnValue = FUNCTION_STATUS_NOT_OPEN;
}
return returnValue;
}
+17
View File
@@ -0,0 +1,17 @@
## IDF Component Manager Manifest File
dependencies:
espressif/led_strip: "^2.5.3"
## Required IDF version
idf:
version: ">=4.1.0"
# # Put list of dependencies here
# # For components maintained by Espressif:
# component: "~1.0.0"
# # For 3rd party components:
# username/component: ">=1.0.0,<2.0.0"
# username2/component2:
# version: "~1.0.0"
# # For transient dependencies `public` flag can be set.
# # `public` flag doesn't have an effect dependencies of the `main` component.
# # All dependencies of `main` are public by default.
# public: true
-36
View File
@@ -1,36 +0,0 @@
/*
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#include <stdint.h>
#include "driver/rmt_encoder.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Type of led strip encoder configuration
*/
typedef struct {
uint32_t resolution; /*!< Encoder resolution, in Hz */
} led_strip_encoder_config_t;
/**
* @brief Create RMT encoder for encoding LED strip pixels into RMT symbols
*
* @param[in] config Encoder configuration
* @param[out] ret_encoder Returned encoder handle
* @return
* - ESP_ERR_INVALID_ARG for any invalid arguments
* - ESP_ERR_NO_MEM out of memory when creating led strip encoder
* - ESP_OK if creating encoder successfully
*/
esp_err_t rmt_new_led_strip_encoder(const led_strip_encoder_config_t *config, rmt_encoder_handle_t *ret_encoder);
#ifdef __cplusplus
}
#endif
-156
View File
@@ -1,156 +0,0 @@
// --------------------------------------------------------------------------------------------------------------------
/// \file ledmatrix.h
/// \brief File description
// --------------------------------------------------------------------------------------------------------------------
//
// vbchaos software design
//
// --------------------------------------------------------------------------------------------------------------------
/// $Revision: $
/// $Author: $
/// $Date: $
// (c) 2023 vbchaos
// --------------------------------------------------------------------------------------------------------------------
#ifndef MAIN_INC_LEDMATRIX_H_
#define MAIN_INC_LEDMATRIX_H_
/**
* ledmatrix implementation
* \defgroup ledmatrix
* \brief {group_description}
* \addtogroup {Layer}
*
* Detailed description
* @{
*/
// --------------------------------------------------------------------------------------------------------------------
// Include files
// --------------------------------------------------------------------------------------------------------------------
// CompilerIncludes
// All include files that are provided by the compiler directly
#include <stdint.h>
// ProjectIncludes
// All include files that are provided by the project
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/semphr.h"
#include "driver/rmt_tx.h"
// --------------------------------------------------------------------------------------------------------------------
// Constant and macro definitions
// --------------------------------------------------------------------------------------------------------------------
#define LEDMATRIX_RED_INDEX ((uint32_t)1)
#define LEDMATRIX_GREEN_INDEX ((uint32_t)0)
#define LEDMATRIX_BLUE_INDEX ((uint32_t)2)
// --------------------------------------------------------------------------------------------------------------------
// Type definitions.
// --------------------------------------------------------------------------------------------------------------------
typedef enum
{
LEDMATRIX_ORIENTATION_ROW_LEFT_RIGHT,
LEDMATRIX_ORIENTATION_ROW_RIGHT_LEFT
} LEDMatrix_Orientation_Row_t;
typedef enum
{
LEDMATRIX_ORIENTATION_COLUM_UP_DOWN,
LEDMATRIX_ORIENTATION_COLUM_DOWN_UP
} LEDMatrix_Orientation_Colum_t;
typedef enum
{
LEDMATRIX_ORIENTATION_ROW,
LEDMATRIX_ORIENTATION_COLUM
}LEDMatrix_Orientation_t;
typedef struct
{
LEDMatrix_Orientation_Row_t rowOrientation;
LEDMatrix_Orientation_Colum_t columOrientation;
LEDMatrix_Orientation_t matrixOrientation;
unsigned int width;
unsigned int height;
// RMT objects for transmission
rmt_channel_handle_t* rmtChannel;
rmt_encoder_handle_t* rmtEncoder;
rmt_transmit_config_t* rmtConfig;
} LEDMatrix_Parameters_t;
typedef struct
{
bool on;
uint8_t red;
uint8_t green;
uint8_t blue;
} LEDMatrix_Pixel_t;
// --------------------------------------------------------------------------------------------------------------------
// Function declarations
// --------------------------------------------------------------------------------------------------------------------
class LEDMatrix
{
public:
struct coordinate
{
int x;
int y;
};
LEDMatrix(LEDMatrix_Parameters_t* parameters);
bool setPixelValue(unsigned int colum, unsigned int row, bool value);
void setGlobalColour(uint8_t red, uint8_t green, uint8_t blue);
void setPixelColour(unsigned int colum, unsigned int row, uint8_t red, uint8_t green, uint8_t blue);
void clear(void);
BaseType_t tick(void);
protected:
unsigned int findPixelIndexFromCoordinates(unsigned int colum, unsigned int row);
private:
LEDMatrix_Parameters_t parameters;
LEDMatrix_Pixel_t* matrix;
uint8_t* tx_matrix;
unsigned int numberOfPixels;
static bool initialized;
static TaskHandle_t matrixTaskHandle;
static SemaphoreHandle_t taskSemaphore;
static void matrixTask(void* parameters);
};
inline BaseType_t LEDMatrix::tick(void)
{
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
if (LEDMatrix::initialized)
{
xSemaphoreGiveFromISR(LEDMatrix::taskSemaphore, &xHigherPriorityTaskWoken);
}
return xHigherPriorityTaskWoken;
}
/** @} */
#endif /* MAIN_INC_LEDMATRIX_H_ */
-196
View File
@@ -1,196 +0,0 @@
// --------------------------------------------------------------------------------------------------------------------
/// \file logger.h
/// \brief File description
// --------------------------------------------------------------------------------------------------------------------
//
// vbchaos software design
//
// --------------------------------------------------------------------------------------------------------------------
/// $Revision: $
/// $Author: $
/// $Date: $
// (c) 2023 vbchaos
// --------------------------------------------------------------------------------------------------------------------
#ifndef MAIN_INC_LOGGER_H_
#define MAIN_INC_LOGGER_H_
/**
* Logger implementation
* \defgroup Logger
* \brief Implementation of a non-blocking logger for debug purpose
* \ingroup Platform
*
* A non-blocking logger that implements its own task with very low (unimportant)
* priority
* @{
*/
// --------------------------------------------------------------------------------------------------------------------
// Include files
// --------------------------------------------------------------------------------------------------------------------
// CompilerIncludes
// All include files that are provided by the compiler directly
#include <stdbool.h>
#include <stdint.h>
// ProjectIncludes
// All include files that are provided by the project
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/queue.h"
#include "freertos/semphr.h"
#include "driver/uart_select.h"
// --------------------------------------------------------------------------------------------------------------------
// Constant and macro definitions
// --------------------------------------------------------------------------------------------------------------------
/**
* Logs an error
* \memberof Logger
*/
#define LOGGER_ERROR(...) \
Logger::Logger_log(__FILE__, __func__, __LINE__, LOGTYPE_ERROR, ##__VA_ARGS__)
/**
* Logs a success
* \memberof Logger
*/
#define LOGGER_SUCCESS(...) \
Logger::Logger_log(__FILE__, __func__, __LINE__, LOGTYPE_SUCCESS, ##__VA_ARGS__)
/**
* Logs an error
* \memberof Logger
*/
#define LOGGER_WARNING(...) \
Logger::Logger_log(__FILE__, __func__, __LINE__, LOGTYPE_WARNING, ##__VA_ARGS__)
/**
* Logs an error
* \memberof Logger
*/
#define LOGGER_INFO(...) \
Logger::Logger_log(__FILE__, __func__, __LINE__, LOGTYPE_INFO, ##__VA_ARGS__)
/**
* Logs an error
* \memberof Logger
*/
#define LOGGER_DEBUG(...) \
Logger::Logger_log(__FILE__, __func__, __LINE__, LOGTYPE_DEBUG, ##__VA_ARGS__)
/**
* Logs an error
* \memberof Logger
*/
#define LOGGER_PRINT(...) \
Logger::Logger_log("", "", 0, LOGTYPE_PRINT, ##__VA_ARGS__)
/**
* Logs an error
* \memberof Logger
*/
#define LOGGER_ERROR_ISR(...) \
Logger::Logger_logISR(__FILE__, __func__, __LINE__, LOGTYPE_ERROR, ##__VA_ARGS__)
/**
* Logs a success
* \memberof Logger
*/
#define LOGGER_SUCCESS_ISR(...) \
Logger::Logger_logISR(__FILE__, __func__, __LINE__, LOGTYPE_ERROR, ##__VA_ARGS__)
/**
* Logs an error
* \memberof Logger
*/
#define LOGGER_WARNING_ISR(...) \
Logger::Logger_logISR(__FILE__, __func__, __LINE__, LOGTYPE_WARNING, ##__VA_ARGS__)
/**
* Logs an error
* \memberof Logger
*/
#define LOGGER_INFO_ISR(...) \
Logger::Logger_logISR(__FILE__, __func__, __LINE__, LOGTYPE_INFO, ##__VA_ARGS__)
/**
* Logs an error
* \memberof Logger
*/
#define LOGGER_DEBUG_ISR(a, ...) \
Logger::Logger_logISR(a, __FILE__, __func__, __LINE__, LOGTYPE_DEBUG, ##__VA_ARGS__)
/**
* Logs an error
* \memberof Logger
*/
#define LOGGER_PRINT_ISR(a, ...) \
Logger::Logger_logISR(a, "", "", 0, LOGTYPE_PRINT, ##__VA_ARGS__)
// --------------------------------------------------------------------------------------------------------------------
// Type definitions.
// --------------------------------------------------------------------------------------------------------------------
typedef enum
{
LOGTYPE_PRINT, /**< Raw print */
LOGTYPE_DEBUG, /**< Debug information only; will not be stored on SD-card */
LOGTYPE_INFO, /**< Informational messages of important events */
LOGTYPE_WARNING, /**< Recoverable fault */
LOGTYPE_SUCCESS, /**< A specific success message */
LOGTYPE_ERROR /**< Unrecoverable fault */
} LogType;
struct LogQueueItem
{
char fileName[32];
char functionName[32];
char context[128];
int lineNumber;
LogType logType;
};
// --------------------------------------------------------------------------------------------------------------------
// Function declarations
// --------------------------------------------------------------------------------------------------------------------
class Logger
{
public:
static uart_port_t uartPort;
static int queuesize;
static QueueHandle_t logQueue;
Logger(int queuesize, uart_port_t uartPort);
static void Logger_log(const char* fileName, const char* functionName, int lineNumber, LogType logType, const char* format, ...);
static void Logger_logISR(struct Logger* self, const char* fileName, const char* functionName, int lineNumber, LogType logType, const char* context);
private:
static TaskHandle_t logTaskHandle;
static void loggerTask(void* parameters);
static void composeLogQueueItem(struct LogQueueItem* logQueueItem, const char* fileName, const char* functionName,
int lineNumber, LogType logType, const char* context);
};
/** @} */
#endif /* MAIN_INC_LOGGER_H_ */
+260 -291
View File
@@ -1,8 +1,8 @@
// --------------------------------------------------------------------------------------------------------------------
/// \file main
/// \file main.cpp
/// \brief Description
// --------------------------------------------------------------------------------------------------------------------
//
//
// vbchaos software design
//
// --------------------------------------------------------------------------------------------------------------------
@@ -17,104 +17,83 @@
// Include files
// --------------------------------------------------------------------------------------------------------------------
#include <string>
#include<cstring>
#include <string.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_event.h"
// ESP includes
#include "driver/uart.h"
#include "esp_log.h"
#include "esp_wifi.h"
#include "nvs_flash.h"
#include "driver/gpio.h"
#include "driver/rmt_tx.h"
#include "driver/uart_select.h"
#include "driver/gptimer.h"
// HAL includes
#include "esplog.h"
#include "gpio.h"
#include "i2c.h"
#include "uart.h"
#include "inc/bmp280.h"
#include "inc/gpio.h"
#include "inc/i2c.h"
#include "inc/led_strip_encoder.h"
#include "inc/ledmatrix.h"
#include "inc/logger.h"
#include "inc/wifi.h"
// Platform includes
#include "bmp280.h"
#include "isl29125.h"
#include "logger.h"
#include "ledmatrix.h"
#include "wifi.h"
// Application includes
#include "clock.h"
#include "clockwordmap.h"
#include "daywordmap.h"
#include "temperaturewordmap.h"
#include "messagewordmap.h"
#include "ota.h"
#include "temperature.h"
#include "temperaturewordmap.h"
// --------------------------------------------------------------------------------------------------------------------
// Constant and macro definitions
// --------------------------------------------------------------------------------------------------------------------
#define RMT_LED_STRIP_RESOLUTION_HZ 10000000 // 10MHz resolution, 1 tick = 0.1us (led strip needs a high resolution)
#define RMT_LED_STRIP_GPIO_NUM 0
#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
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// File-scope variables
// --------------------------------------------------------------------------------------------------------------------
static const uart_port_t uartPort = UART_NUM_0;
static TaskHandle_t devTaskHandle = NULL;
static TaskHandle_t colourMapTaskHandle = NULL;
// GPIOs
static GPIO led_rgb_red(3, GPIO_DIRECTION_OUTPUT);
static GPIO led_rgb_green(4, GPIO_DIRECTION_OUTPUT);
static GPIO led_rgb_blue(5, GPIO_DIRECTION_OUTPUT);
static GPIO led_orange(18, GPIO_DIRECTION_OUTPUT);
// -------------------------------------------------------
// LED Matrix components
static rmt_channel_handle_t led_chan = NULL;
static rmt_transmit_config_t tx_config;
static rmt_encoder_handle_t led_encoder = NULL;
static LEDMatrix_Parameters_t ledmatrix_parameters =
{
LEDMATRIX_ORIENTATION_ROW_LEFT_RIGHT,
LEDMATRIX_ORIENTATION_COLUM_UP_DOWN,
LEDMATRIX_ORIENTATION_ROW,
20,
13,
&led_chan,
&led_encoder,
&tx_config
};
static LEDMatrix matrix(&ledmatrix_parameters);
static ClockWordmap clockWordmap(&matrix);
static DayWordmap dayWordmap(&matrix);
static TemperatureWordmap tempWordmap(&matrix);
static gptimer_handle_t matrixRefreshTimer = NULL;
static TaskHandle_t loggerTaskHandle;
static TaskHandle_t otaTaskHandle;
static bool otaActive = false;
// --------------------------------------------------------------------------------------------------------------------
// Function declarations
// --------------------------------------------------------------------------------------------------------------------
// Simple countdown on display
static void countdown(int delay);
void loggerTask(void* parameters);
void otaTask(void* parameters);
// Timer Callback for the LEDMatrix refresh
static bool timerCallback(gptimer_handle_t timer, const gptimer_alarm_event_data_t *edata, void *user_data);
static void devTask(void* parameters);
static void colourMapTask(void* parameters);
static void otaCallback(struct ota::statusCallbackData* status);
// --------------------------------------------------------------------------------------------------------------------
// Function definitions
@@ -122,20 +101,20 @@ static void colourMapTask(void* parameters);
extern "C" void app_main(void)
{
esp_log_level_set("*", ESP_LOG_WARN);
esp_log_level_set("*", ESP_LOG_INFO);
esp_err_t ret = nvs_flash_init();
esp_err_t ret = nvs_flash_init();
if(ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND)
{
ESP_ERROR_CHECK(nvs_flash_erase());
ret = nvs_flash_init();
}
if (ret == ESP_ERR_NVS_NO_FREE_PAGES
|| ret == ESP_ERR_NVS_NEW_VERSION_FOUND) {
ESP_ERROR_CHECK(nvs_flash_erase());
ret = nvs_flash_init();
}
//--------------------------------------------
// -----------------------------------------------------------------------------------------------------------------
// UART
//
const uart_config_t uartConfig =
uart_config_t uartConfig =
{
.baud_rate = 115200,
.data_bits = UART_DATA_8_BITS,
@@ -145,271 +124,261 @@ extern "C" void app_main(void)
.rx_flow_ctrl_thresh = 0,
.source_clk = UART_SCLK_DEFAULT
};
ESP_ERROR_CHECK(uart_param_config(uartPort, &uartConfig));
ESP_ERROR_CHECK(uart_set_pin(uartPort, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE));
ESP_ERROR_CHECK(uart_driver_install(uartPort, 1024, 1024, 0, NULL, 0));
uart_port_t debugUart = UART_NUM_0;
ESP_ERROR_CHECK(uart_param_config(debugUart, &uartConfig));
ESP_ERROR_CHECK(uart_set_pin(debugUart, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE));
ESP_ERROR_CHECK(uart_driver_install(debugUart, 1024, 1024, 0, NULL, 0));
//--------------------------------------------
// LOGGER
//
Logger logger(10, uartPort);
// uart uartDebug = uart(&debugUart);
// uartDebug.open();
// uartDebug.write(255, 255, (uint8_t*)"START", 5);
esplog esplogger = esplog();
esplogger.open();
// -----------------------------------------------------------------------------------------------------------------
// System-wide Debug Logger
//
// logger debugLogger = logger(16, uartDebug);
logger debugLogger = logger(20, esplogger);
// Call the logger executable within a dedicated task and forget about it afterwards
xTaskCreate(loggerTask, (const char*)"loggerTask", 3000, &debugLogger, 3, &loggerTaskHandle);
LOGGER_PRINT("\n\r-----------------------------------------------------------------------\n\r");
LOGGER_PRINT("System Start\n\r");
LOGGER_PRINT("\n\r");
LOGGER_PRINT("WordClock\n\r");
LOGGER_PRINT("Release: %f\n\r", RELEASE);
LOGGER_PRINT("Compiled on %d %d\n\r\n\r\n\r", __TIME__, __DATE__);
LOGGER_PRINT("Release: %d.%d \n\r", MAJORRELEASE, MINORRELEASE);
LOGGER_PRINT("Compiled on %s at %s\n\r\n\r\n\r", __DATE__, __TIME__);
//--------------------------------------------
// RMT Channel
// -----------------------------------------------------------------------------------------------------------------
// I2C Masterbus for sensoring peripherals
//
LOGGER_INFO("Create RMT TX channel");
rmt_tx_channel_config_t tx_chan_config;
memset(&tx_chan_config, 0, sizeof(tx_chan_config));
i2c_port_t i2c_master_port = I2C_NUM_0;
tx_chan_config.clk_src = RMT_CLK_SRC_DEFAULT; // select source clock
tx_chan_config.gpio_num = (gpio_num_t)RMT_LED_STRIP_GPIO_NUM;
tx_chan_config.mem_block_symbols = 64; // increase the block size can make the LED less flickering
tx_chan_config.resolution_hz = RMT_LED_STRIP_RESOLUTION_HZ;
tx_chan_config.trans_queue_depth = 4;
i2c_config_t i2cConfig = {
.mode = I2C_MODE_MASTER,
.sda_io_num = (int)GPIO_I2C_SDA,
.scl_io_num = (int)GPIO_I2C_SCK,
.sda_pullup_en = GPIO_PULLUP_ENABLE,
.scl_pullup_en = GPIO_PULLUP_ENABLE,
.master = 400000,
.clk_flags = 0
};
ESP_ERROR_CHECK(rmt_new_tx_channel(&tx_chan_config, &led_chan));
ESP_ERROR_CHECK(i2c_param_config(i2c_master_port, &i2cConfig));
ESP_ERROR_CHECK(i2c_driver_install(i2c_master_port, i2cConfig.mode, 0, 0, 0));
LOGGER_INFO("Install led strip encoder");
led_strip_encoder_config_t encoder_config;
memset(&encoder_config, 0, sizeof(encoder_config));
encoder_config.resolution = RMT_LED_STRIP_RESOLUTION_HZ;
i2c i2cSensor = i2c(&i2c_master_port);
i2cSensor.open();
ESP_ERROR_CHECK(rmt_new_led_strip_encoder(&encoder_config, &led_encoder));
// // -----------------------------------------------------------------------------------------------------------------
// // 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);
LOGGER_INFO("Enable RMT TX channel");
ESP_ERROR_CHECK(rmt_enable(led_chan));
memset(&tx_config, 0, sizeof(tx_config));
tx_config.loop_count = 0;
//--------------------------------------------
// I2C
// -----------------------------------------------------------------------------------------------------------------
// I2C RGB Sensor on I2C MasterBus for sensors
//
// SourceClock: GPIO 8
// SourceData: GPIO 9
I2C i2c0(8, 9);
//--------------------------------------------
// BMP280
//
// Communicates on I2C i2c0
// Has slave address 0x76
BMP280 bmp280(&i2c0, 0x76);
bmp280 tempSensor = bmp280(0x76, i2cSensor);
// Reset the sensor
bmp280.resetSensor();
tempSensor.resetSensor();
// Make sure to apply a wait cycle between reset and continuous use - 2ms is advised as minimum
vTaskDelay(10);
// Initialize the BMP280
bmp280.initialize();
tempSensor.initialize();
// Set the temperature Oversampling
bmp280.setSensorTemperatureOversampling(BMP280::BMP280_Oversampling_t::X1);
tempSensor.setSensorTemperatureOversampling(bmp280::BMP280_Oversampling_t::X1);
// Set the sensor to NORMAL mode
bmp280.setSensorMode(BMP280::BMP280_Mode_t::NORMAL);
tempSensor.setSensorMode(bmp280::BMP280_Mode_t::NORMAL);
Temperature temperature;
//--------------------------------------------
// LED Matrix
// -----------------------------------------------------------------------------------------------------------------
// Wifi create and connect
//
matrix.setGlobalColour(0x10, 0, 0x04);
//--------------------------------------------
// GP Timer for automatic matrix re-draw trigger
//
gptimer_config_t timer_config = { };
gptimer_event_callbacks_t cbs = { };
gptimer_alarm_config_t alarm_config = { };
timer_config.clk_src = GPTIMER_CLK_SRC_DEFAULT;
timer_config.direction = GPTIMER_COUNT_UP;
timer_config.resolution_hz = 1000000; // 1 MHz
cbs.on_alarm = timerCallback;
alarm_config.reload_count = 0;
alarm_config.alarm_count = timer_config.resolution_hz / 60;
alarm_config.flags.auto_reload_on_alarm = true;
ESP_ERROR_CHECK(gptimer_new_timer(&timer_config, &matrixRefreshTimer));
ESP_ERROR_CHECK(gptimer_register_event_callbacks(matrixRefreshTimer, &cbs, NULL));
ESP_ERROR_CHECK(gptimer_enable(matrixRefreshTimer));
ESP_ERROR_CHECK(gptimer_set_alarm_action(matrixRefreshTimer, &alarm_config));
ESP_ERROR_CHECK(gptimer_start(matrixRefreshTimer));
// Create the development task
if(xTaskCreate(devTask, "DevTask", 2048, NULL, 3, &devTaskHandle) != pdPASS)
{
LOGGER_ERROR("Task not created");
}
// Create the colour Map task
if(xTaskCreate(colourMapTask, "ColourTask", 2048, NULL, 3, &colourMapTaskHandle) != pdPASS)
{
LOGGER_ERROR("Task not created");
}
Wifi wifi;
Wifi wifi = Wifi();
wifi.start_client();
Clock clock(Clock::mode::TEN_BEFORE_HALF);
// -----------------------------------------------------------------------------------------------------------------
// Programmable LEDs in a strip
//
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.setColour(0x00, 0xFF, 0xFF);
dayWordmap.setColour(0x20, 0xCC, 0x80);
// -----------------------------------------------------------------------------------------------------------------
// The clock which also handles the NTP
//
Clock clk = Clock(Clock::Mode_t::TEN_BEFORE_HALF);
// -----------------------------------------------------------------------------------------------------------------
// The Temperature class that calculates temperature string and colour
//
temperature temp = temperature();
// -----------------------------------------------------------------------------------------------------------------
// Wordmaps for clock(time), clock(day), temperature and one for other messages
//
ClockWordmap clockwords = ClockWordmap(&matrix);
clockwords.setColour(0xFF, 0xFF, 0x20);
DayWordmap daywords = DayWordmap(&matrix);
daywords.setColour(0x00, 0xFF, 0xFF);
temperaturewordmap tempwords = temperaturewordmap(&matrix);
tempwords.setColour(0xA0, 0x00, 0xA0);
messagewordmap messagewords = messagewordmap(&matrix);
messagewords.setColour(0xA0, 0x00, 0x00);
// countdown(1000);
for (int cnt = 0; cnt < 10; cnt++)
{
for (uint32_t i = 0; i < MATRIX_NMBR_ROWS; i++)
{
matrix.clearAll();
matrix.setRow(i, i * 20, i * 30, i * 40);
matrix.update();
vTaskDelay(2);
}
list<string> clockWordlist;
list<string> tempWordList;
for (uint32_t i = 0; i < MATRIX_NMBR_COLUMS; i++)
{
matrix.clearAll();
matrix.setColumn(i, i * 20, i * 30, i * 40);
matrix.update();
vTaskDelay(2);
}
}
// -----------------------------------------------------------------------------------------------------------------
// OTA handler
//
ota otaUpdater = ota();
otaUpdater.usCallback = otaCallback;
// Call the OTA executable within a dedicated task and forget about it afterwards
xTaskCreate(otaTask, (const char*)"OTATask", 4000, &otaUpdater, 3, &otaTaskHandle);
while (true)
{
std::list<std::string> clockWordlist;
std::list<std::string> tempWordList;
clock.generateWordlist(&clockWordlist);
uint32_t runninglightIndex = 0;
while(1)
{
if (!otaActive)
{
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);
messagewords.setWord(wordmap::Language_t::NL, *it, true);
}
matrix.clear();
std::list<string>::iterator it;
for(it = clockWordlist.begin(); it != clockWordlist.end(); it++)
{
clockWordmap.setWord(Wordmap::Language_t::NL, *it, true);
dayWordmap.setWord(Wordmap::Language_t::NL, *it, true);
}
// Get the temperature from sensor
int currentTemperature = tempSensor.getTemperature() / 100;
// Get the temperature from sensor
int currentTemperature = bmp280.getTemperature() / 100;
LOGGER_INFO("The current temperature is: %i (%s)", currentTemperature, std::to_string(21));
// Generate temperature wordlist
temp.generateWordlist(currentTemperature, &tempWordList);
for(it = tempWordList.begin(); it != tempWordList.end(); it++)
{
tempwords.setWord(wordmap::Language_t::NL, *it, true);
}
uint8_t tRed, tGreen, tBlue;
temp.calculateRGB(currentTemperature, &tRed, &tGreen, &tBlue);
tempwords.setColour(tRed, tGreen, tBlue);
LOGGER_INFO("The current temperature is: %i (%s)", currentTemperature, to_string(21));
// Generate temperature wordlist
temperature.generateWordlist(currentTemperature, &tempWordList);
for(it = tempWordList.begin(); it != tempWordList.end(); it++)
{
tempWordmap.setWord(Wordmap::Language_t::NL, *it, true);
}
uint8_t tRed, tGreen, tBlue;
temperature.calculateRGB(currentTemperature, &tRed, &tGreen, &tBlue);
tempWordmap.setColour(tRed, tGreen, tBlue);
matrix.update();
}
else
{
matrix.clearAll();
// Add a seconds indicator
matrix.setPixelValue(11, 11, clock.getTime() % 2);
// Update the matrix
matrix.tick();
// Update the clock every second (1000 ms)
vTaskDelay(1000);
}
while (otaActive)
{
// Create a running light on the lowest row
matrix.setPixel(MATRIX_NMBR_ROWS - 1, runninglightIndex, 0xFF - runninglightIndex * 10, runninglightIndex * 5, runninglightIndex * 10);
matrix.update();
vTaskDelay(10);
matrix.setPixel(MATRIX_NMBR_ROWS - 1, runninglightIndex, 0, 0, 0);
matrix.update();
runninglightIndex < (MATRIX_NMBR_COLUMS - 1) ? runninglightIndex++ : runninglightIndex = 0;
}
}
vTaskDelay(100);
}
}
static void devTask(void* parameters)
void loggerTask(void* parameters)
{
uint32_t counter = 0;
printf("DevTask created");
while (true)
logger* debugLogger = (logger*) parameters;
while (1)
{
(void)led_orange.SetOutput((GPIO_Value_t)(counter % 2));
counter++;
vTaskDelay(500);
debugLogger->task();
vTaskDelay(2);
}
}
static void colourMapTask(void* parameters)
void otaTask(void* parameters)
{
uint8_t red = 0xF0;
uint8_t green = 0x20;
uint8_t blue = 0xF0;
// uint8_t red = 0x00;
// uint8_t green = 0x00;
// uint8_t blue = 0x00;
uint32_t counter = 0;
while (true)
ota* otaHandler = (ota*) parameters;
while (1)
{
// red = 0;
// green = 0;
// blue = 0;
// if ((counter % 2) == 0)
// {
// red = 0xFF;
// }
// if ((counter % 5) == 0)
// {
// green = 0xFF;
// }
// if ((counter % 9) == 0)
// {
// blue = 0xFF;
// }
// matrix.setGlobalColour(red, green, blue);
// red = counter & 0xFF;
// green = (counter >> 8) & 0xFF;
// blue = (counter >> 16) & 0xFF;
counter++;
vTaskDelay(200);
otaHandler->task();
vTaskDelay(otaHandler->checkInterval_ms);
}
}
static void countdown(int delay)
void otaCallback(struct ota::statusCallbackData* status)
{
clockWordmap.setWord(Wordmap::Language_t::NL, "ten", true);
vTaskDelay(delay);
clockWordmap.setWord(Wordmap::Language_t::NL, "ten", false);
clockWordmap.setWord(Wordmap::Language_t::NL, "nine", true);
vTaskDelay(delay);
clockWordmap.setWord(Wordmap::Language_t::NL, "nine", false);
clockWordmap.setWord(Wordmap::Language_t::NL, "eight", true);
vTaskDelay(delay);
clockWordmap.setWord(Wordmap::Language_t::NL, "eight", false);
clockWordmap.setWord(Wordmap::Language_t::NL, "seven", true);
vTaskDelay(delay);
clockWordmap.setWord(Wordmap::Language_t::NL, "seven", false);
clockWordmap.setWord(Wordmap::Language_t::NL, "six", true);
vTaskDelay(delay);
clockWordmap.setWord(Wordmap::Language_t::NL, "six", false);
clockWordmap.setWord(Wordmap::Language_t::NL, "five", true);
vTaskDelay(delay);
clockWordmap.setWord(Wordmap::Language_t::NL, "five", false);
clockWordmap.setWord(Wordmap::Language_t::NL, "four", true);
vTaskDelay(delay);
clockWordmap.setWord(Wordmap::Language_t::NL, "four", false);
clockWordmap.setWord(Wordmap::Language_t::NL, "three", true);
vTaskDelay(delay);
clockWordmap.setWord(Wordmap::Language_t::NL, "three", false);
clockWordmap.setWord(Wordmap::Language_t::NL, "two", true);
vTaskDelay(delay);
clockWordmap.setWord(Wordmap::Language_t::NL, "two", false);
clockWordmap.setWord(Wordmap::Language_t::NL, "one", true);
vTaskDelay(delay);
clockWordmap.setWord(Wordmap::Language_t::NL, "one", false);
}
static bool IRAM_ATTR timerCallback(gptimer_handle_t timer, const gptimer_alarm_event_data_t *edata, void *user_data)
{
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
// xHigherPriorityTaskWoken = matrix.tick();
return xHigherPriorityTaskWoken == pdTRUE;
switch (status->status)
{
case ota::UpdateStatus_t::OTA_STATUS_IDLE:
otaActive = false;
break;
case ota::UpdateStatus_t::OTA_STATUS_DOWNLOAD:
LOGGER_INFO("Downloading OTA file from server");
otaActive = false;
break;
case ota::UpdateStatus_t::OTA_STATUS_VERIFY:
LOGGER_INFO("Verifying OTA firmware file");
otaActive = false;
break;
case ota::UpdateStatus_t::OTA_STATUS_WRITE:
// LOGGER_INFO("Writing OTA firmware file to FLASH - Current progress: %i \%", status->percentage);
otaActive = true;
break;
case ota::UpdateStatus_t::OTA_STATUS_UPDATE:
LOGGER_INFO("Updating the OTA partition");
otaActive = true;
break;
case ota::UpdateStatus_t::OTA_STATUS_SUCCESS:
LOGGER_SUCCESS("The OTA firmware update was finished successfully");
otaActive = true;
break;
case ota::UpdateStatus_t::OTA_STATUS_FAIL:
LOGGER_ERROR("The OTA firmware update failed");
otaActive = false;
break;
case ota::UpdateStatus_t::OTA_STATUS_RESTART:
LOGGER_INFO("Restarting the device after OTA finished");
otaActive = false;
break;
}
}
+415
View File
@@ -0,0 +1,415 @@
// --------------------------------------------------------------------------------------------------------------------
/// \file main
/// \brief Description
// --------------------------------------------------------------------------------------------------------------------
//
// vbchaos software design
//
// --------------------------------------------------------------------------------------------------------------------
/// $Revision: $
/// $Author: $
/// $Date: $
// (c) 2023 vbchaos
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Include files
// --------------------------------------------------------------------------------------------------------------------
#include <string>
#include<cstring>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_event.h"
#include "esp_log.h"
#include "esp_wifi.h"
#include "nvs_flash.h"
#include "driver/gpio.h"
#include "driver/rmt_tx.h"
#include "driver/uart_select.h"
#include "driver/gptimer.h"
#include "inc/bmp280.h"
#include "inc/gpio.h"
#include "inc/i2c.h"
#include "inc/led_strip_encoder.h"
#include "inc/ledmatrix.h"
#include "inc/logger.h"
#include "inc/wifi.h"
#include "clock.h"
#include "clockwordmap.h"
#include "daywordmap.h"
#include "temperaturewordmap.h"
#include "temperature.h"
// --------------------------------------------------------------------------------------------------------------------
// Constant and macro definitions
// --------------------------------------------------------------------------------------------------------------------
#define RMT_LED_STRIP_RESOLUTION_HZ 10000000 // 10MHz resolution, 1 tick = 0.1us (led strip needs a high resolution)
#define RMT_LED_STRIP_GPIO_NUM 0
// --------------------------------------------------------------------------------------------------------------------
// Type definitions
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// File-scope variables
// --------------------------------------------------------------------------------------------------------------------
static const uart_port_t uartPort = UART_NUM_0;
static TaskHandle_t devTaskHandle = NULL;
static TaskHandle_t colourMapTaskHandle = NULL;
// GPIOs
static GPIO led_rgb_red(3, GPIO_DIRECTION_OUTPUT);
static GPIO led_rgb_green(4, GPIO_DIRECTION_OUTPUT);
static GPIO led_rgb_blue(5, GPIO_DIRECTION_OUTPUT);
static GPIO led_orange(18, GPIO_DIRECTION_OUTPUT);
// -------------------------------------------------------
// LED Matrix components
static rmt_channel_handle_t led_chan = NULL;
static rmt_transmit_config_t tx_config;
static rmt_encoder_handle_t led_encoder = NULL;
static LEDMatrix_Parameters_t ledmatrix_parameters =
{
LEDMATRIX_ORIENTATION_ROW_LEFT_RIGHT,
LEDMATRIX_ORIENTATION_COLUM_UP_DOWN,
LEDMATRIX_ORIENTATION_ROW,
20,
13,
&led_chan,
&led_encoder,
&tx_config
};
static LEDMatrix matrix(&ledmatrix_parameters);
static ClockWordmap clockWordmap(&matrix);
static DayWordmap dayWordmap(&matrix);
static TemperatureWordmap tempWordmap(&matrix);
static gptimer_handle_t matrixRefreshTimer = NULL;
// --------------------------------------------------------------------------------------------------------------------
// Function declarations
// --------------------------------------------------------------------------------------------------------------------
// Simple countdown on display
static void countdown(int delay);
// Timer Callback for the LEDMatrix refresh
static bool timerCallback(gptimer_handle_t timer, const gptimer_alarm_event_data_t *edata, void *user_data);
static void devTask(void* parameters);
static void colourMapTask(void* parameters);
// --------------------------------------------------------------------------------------------------------------------
// Function definitions
// --------------------------------------------------------------------------------------------------------------------
extern "C" void app_main(void)
{
esp_log_level_set("*", ESP_LOG_WARN);
esp_err_t ret = nvs_flash_init();
if(ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND)
{
ESP_ERROR_CHECK(nvs_flash_erase());
ret = nvs_flash_init();
}
//--------------------------------------------
// UART
//
const uart_config_t uartConfig =
{
.baud_rate = 115200,
.data_bits = UART_DATA_8_BITS,
.parity = UART_PARITY_DISABLE,
.stop_bits = UART_STOP_BITS_1,
.flow_ctrl = UART_HW_FLOWCTRL_DISABLE,
.rx_flow_ctrl_thresh = 0,
.source_clk = UART_SCLK_DEFAULT
};
ESP_ERROR_CHECK(uart_param_config(uartPort, &uartConfig));
ESP_ERROR_CHECK(uart_set_pin(uartPort, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE));
ESP_ERROR_CHECK(uart_driver_install(uartPort, 1024, 1024, 0, NULL, 0));
//--------------------------------------------
// LOGGER
//
Logger logger(10, uartPort);
LOGGER_PRINT("\n\r-----------------------------------------------------------------------\n\r");
LOGGER_PRINT("System Start\n\r");
LOGGER_PRINT("\n\r");
LOGGER_PRINT("WordClock\n\r");
LOGGER_PRINT("Release: %f\n\r", RELEASE);
LOGGER_PRINT("Compiled on %d %d\n\r\n\r\n\r", __TIME__, __DATE__);
//--------------------------------------------
// RMT Channel
//
LOGGER_INFO("Create RMT TX channel");
rmt_tx_channel_config_t tx_chan_config;
memset(&tx_chan_config, 0, sizeof(tx_chan_config));
tx_chan_config.clk_src = RMT_CLK_SRC_DEFAULT; // select source clock
tx_chan_config.gpio_num = (gpio_num_t)RMT_LED_STRIP_GPIO_NUM;
tx_chan_config.mem_block_symbols = 64; // increase the block size can make the LED less flickering
tx_chan_config.resolution_hz = RMT_LED_STRIP_RESOLUTION_HZ;
tx_chan_config.trans_queue_depth = 4;
ESP_ERROR_CHECK(rmt_new_tx_channel(&tx_chan_config, &led_chan));
LOGGER_INFO("Install led strip encoder");
led_strip_encoder_config_t encoder_config;
memset(&encoder_config, 0, sizeof(encoder_config));
encoder_config.resolution = RMT_LED_STRIP_RESOLUTION_HZ;
ESP_ERROR_CHECK(rmt_new_led_strip_encoder(&encoder_config, &led_encoder));
LOGGER_INFO("Enable RMT TX channel");
ESP_ERROR_CHECK(rmt_enable(led_chan));
memset(&tx_config, 0, sizeof(tx_config));
tx_config.loop_count = 0;
//--------------------------------------------
// I2C
//
// SourceClock: GPIO 8
// SourceData: GPIO 9
I2C i2c0(8, 9);
//--------------------------------------------
// BMP280
//
// Communicates on I2C i2c0
// Has slave address 0x76
BMP280 bmp280(&i2c0, 0x76);
// Reset the sensor
bmp280.resetSensor();
// Make sure to apply a wait cycle between reset and continuous use - 2ms is advised as minimum
vTaskDelay(10);
// Initialize the BMP280
bmp280.initialize();
// Set the temperature Oversampling
bmp280.setSensorTemperatureOversampling(BMP280::BMP280_Oversampling_t::X1);
// Set the sensor to NORMAL mode
bmp280.setSensorMode(BMP280::BMP280_Mode_t::NORMAL);
Temperature temperature;
//--------------------------------------------
// LED Matrix
//
matrix.setGlobalColour(0x10, 0, 0x04);
//--------------------------------------------
// GP Timer for automatic matrix re-draw trigger
//
gptimer_config_t timer_config = { };
gptimer_event_callbacks_t cbs = { };
gptimer_alarm_config_t alarm_config = { };
timer_config.clk_src = GPTIMER_CLK_SRC_DEFAULT;
timer_config.direction = GPTIMER_COUNT_UP;
timer_config.resolution_hz = 1000000; // 1 MHz
cbs.on_alarm = timerCallback;
alarm_config.reload_count = 0;
alarm_config.alarm_count = timer_config.resolution_hz / 60;
alarm_config.flags.auto_reload_on_alarm = true;
ESP_ERROR_CHECK(gptimer_new_timer(&timer_config, &matrixRefreshTimer));
ESP_ERROR_CHECK(gptimer_register_event_callbacks(matrixRefreshTimer, &cbs, NULL));
ESP_ERROR_CHECK(gptimer_enable(matrixRefreshTimer));
ESP_ERROR_CHECK(gptimer_set_alarm_action(matrixRefreshTimer, &alarm_config));
ESP_ERROR_CHECK(gptimer_start(matrixRefreshTimer));
// Create the development task
if(xTaskCreate(devTask, "DevTask", 2048, NULL, 3, &devTaskHandle) != pdPASS)
{
LOGGER_ERROR("Task not created");
}
// Create the colour Map task
if(xTaskCreate(colourMapTask, "ColourTask", 2048, NULL, 3, &colourMapTaskHandle) != pdPASS)
{
LOGGER_ERROR("Task not created");
}
Wifi wifi;
wifi.start_client();
Clock clock(Clock::mode::TEN_BEFORE_HALF);
clockWordmap.setColour(0xFF, 0xFF, 0x00);
dayWordmap.setColour(0x20, 0xCC, 0x80);
// countdown(1000);
list<string> clockWordlist;
list<string> tempWordList;
while (true)
{
clock.generateWordlist(&clockWordlist);
matrix.clear();
std::list<string>::iterator it;
for(it = clockWordlist.begin(); it != clockWordlist.end(); it++)
{
clockWordmap.setWord(Wordmap::Language_t::NL, *it, true);
dayWordmap.setWord(Wordmap::Language_t::NL, *it, true);
}
// Get the temperature from sensor
int currentTemperature = bmp280.getTemperature() / 100;
LOGGER_INFO("The current temperature is: %i (%s)", currentTemperature, to_string(21));
// Generate temperature wordlist
temperature.generateWordlist(currentTemperature, &tempWordList);
for(it = tempWordList.begin(); it != tempWordList.end(); it++)
{
tempWordmap.setWord(Wordmap::Language_t::NL, *it, true);
}
uint8_t tRed, tGreen, tBlue;
temperature.calculateRGB(currentTemperature, &tRed, &tGreen, &tBlue);
tempWordmap.setColour(tRed, tGreen, tBlue);
// Add a seconds indicator
matrix.setPixelValue(11, 11, clock.getTime() % 2);
// Update the matrix
matrix.tick();
// Update the clock every second (1000 ms)
vTaskDelay(1000);
}
}
static void devTask(void* parameters)
{
uint32_t counter = 0;
printf("DevTask created");
while (true)
{
(void)led_orange.SetOutput((GPIO_Value_t)(counter % 2));
counter++;
vTaskDelay(500);
}
}
static void colourMapTask(void* parameters)
{
uint8_t red = 0xF0;
uint8_t green = 0x20;
uint8_t blue = 0xF0;
// uint8_t red = 0x00;
// uint8_t green = 0x00;
// uint8_t blue = 0x00;
uint32_t counter = 0;
while (true)
{
// red = 0;
// green = 0;
// blue = 0;
// if ((counter % 2) == 0)
// {
// red = 0xFF;
// }
// if ((counter % 5) == 0)
// {
// green = 0xFF;
// }
// if ((counter % 9) == 0)
// {
// blue = 0xFF;
// }
// matrix.setGlobalColour(red, green, blue);
// red = counter & 0xFF;
// green = (counter >> 8) & 0xFF;
// blue = (counter >> 16) & 0xFF;
counter++;
vTaskDelay(200);
}
}
static void countdown(int delay)
{
clockWordmap.setWord(Wordmap::Language_t::NL, "ten", true);
vTaskDelay(delay);
clockWordmap.setWord(Wordmap::Language_t::NL, "ten", false);
clockWordmap.setWord(Wordmap::Language_t::NL, "nine", true);
vTaskDelay(delay);
clockWordmap.setWord(Wordmap::Language_t::NL, "nine", false);
clockWordmap.setWord(Wordmap::Language_t::NL, "eight", true);
vTaskDelay(delay);
clockWordmap.setWord(Wordmap::Language_t::NL, "eight", false);
clockWordmap.setWord(Wordmap::Language_t::NL, "seven", true);
vTaskDelay(delay);
clockWordmap.setWord(Wordmap::Language_t::NL, "seven", false);
clockWordmap.setWord(Wordmap::Language_t::NL, "six", true);
vTaskDelay(delay);
clockWordmap.setWord(Wordmap::Language_t::NL, "six", false);
clockWordmap.setWord(Wordmap::Language_t::NL, "five", true);
vTaskDelay(delay);
clockWordmap.setWord(Wordmap::Language_t::NL, "five", false);
clockWordmap.setWord(Wordmap::Language_t::NL, "four", true);
vTaskDelay(delay);
clockWordmap.setWord(Wordmap::Language_t::NL, "four", false);
clockWordmap.setWord(Wordmap::Language_t::NL, "three", true);
vTaskDelay(delay);
clockWordmap.setWord(Wordmap::Language_t::NL, "three", false);
clockWordmap.setWord(Wordmap::Language_t::NL, "two", true);
vTaskDelay(delay);
clockWordmap.setWord(Wordmap::Language_t::NL, "two", false);
clockWordmap.setWord(Wordmap::Language_t::NL, "one", true);
vTaskDelay(delay);
clockWordmap.setWord(Wordmap::Language_t::NL, "one", false);
}
static bool IRAM_ATTR timerCallback(gptimer_handle_t timer, const gptimer_alarm_event_data_t *edata, void *user_data)
{
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
// xHigherPriorityTaskWoken = matrix.tick();
return xHigherPriorityTaskWoken == pdTRUE;
}
@@ -1,10 +1,10 @@
// --------------------------------------------------------------------------------------------------------------------
/// \file bme280.h
/// \file bmp280.h
/// \brief File description
// --------------------------------------------------------------------------------------------------------------------
//
// vbchaos software design
//
//
// --------------------------------------------------------------------------------------------------------------------
/// $Revision: $
/// $Author: $
@@ -13,12 +13,12 @@
// --------------------------------------------------------------------------------------------------------------------
#ifndef MAIN_INC_BMP280_H_
#define MAIN_INC_BMP280_H_
#ifndef MAIN_APPLICATION_INC_BMP280_H_
#define MAIN_APPLICATION_INC_BMP280_H_
/**
* bme280 implementation
* \defgroup bme280
* bmp280 implementation
* \defgroup bmp280
* \brief {group_description}
* \addtogroup {Layer}
*
@@ -29,39 +29,44 @@
// --------------------------------------------------------------------------------------------------------------------
// Include files
// Include files
// --------------------------------------------------------------------------------------------------------------------
// CompilerIncludes
// All include files that are provided by the compiler directly
#include <stdint.h>
// ProjectIncludes
// All include files that are provided by the project
#include "i2c.h"
#include "ISerialBus.h"
// --------------------------------------------------------------------------------------------------------------------
// Constant and macro definitions
// Constant and macro definitions
// --------------------------------------------------------------------------------------------------------------------
#define BMP280_DEVICE_ID ((uint8_t)0x58)
#define BMP280_RESET_VALUE ((uint8_t)0xB6)
// --------------------------------------------------------------------------------------------------------------------
// Type definitions.
// Type definitions.
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Function declarations
// Function declarations
// --------------------------------------------------------------------------------------------------------------------
class BMP280
class bmp280
{
// -----------------------------------------------------------------------------------------------------------------
// Public Section
// -----------------------------------------------------------------------------------------------------------------
public:
BMP280(I2C* bus, uint8_t slaveAddress);
// Class Constructor
bmp280(uint8_t slaveAddress, ISerialBus<uint8_t>& serialPort);
typedef enum
{
@@ -86,8 +91,16 @@ class BMP280
int getTemperature(void);
private:
// -----------------------------------------------------------------------------------------------------------------
// Protected Section
// -----------------------------------------------------------------------------------------------------------------
protected:
// -----------------------------------------------------------------------------------------------------------------
// Private Section
// -----------------------------------------------------------------------------------------------------------------
private:
struct CompensationParameters
{
// Temperature compensation parameters
@@ -141,8 +154,9 @@ class BMP280
int t_fine;
int temperature;
I2C* bus;
uint8_t slaveAddress;
ISerialBus<uint8_t>& bus;
bool initialized;
BMP280_Mode_t mode;
void resetDriver(void);
@@ -162,7 +176,7 @@ class BMP280
};
/** @} */
#endif /* MAIN_INC_BMP280_H_ */
#endif /* MAIN_APPLICATION_INC_OTA_H_ */
+216
View File
@@ -0,0 +1,216 @@
// --------------------------------------------------------------------------------------------------------------------
/// \file isl29125.h
/// \brief File description
// --------------------------------------------------------------------------------------------------------------------
//
// vbchaos software design
//
// --------------------------------------------------------------------------------------------------------------------
/// $Revision: $
/// $Author: $
/// $Date: $
// (c) 2023 vbchaos
// --------------------------------------------------------------------------------------------------------------------
#ifndef MAIN_PLATFORM_INC_ISL29125_H_
#define MAIN_PLATFORM_INC_ISL29125_H_
/**
* isl29125 implementation
* \defgroup isl29125
* \brief {group_description}
* \addtogroup {Layer}
*
* Detailed description
* @{
*/
// --------------------------------------------------------------------------------------------------------------------
// Include files
// --------------------------------------------------------------------------------------------------------------------
// CompilerIncludes
// All include files that are provided by the compiler directly
#include <stdint.h>
// ProjectIncludes
// All include files that are provided by the project
#include "ISerialBus.h"
// --------------------------------------------------------------------------------------------------------------------
// Constant and macro definitions
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Type definitions.
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Function declarations
// --------------------------------------------------------------------------------------------------------------------
class isl29125
{
// -----------------------------------------------------------------------------------------------------------------
// Public Section
// -----------------------------------------------------------------------------------------------------------------
public:
struct rgb_t
{
uint16_t red;
uint16_t green;
uint16_t blue;
} RGB_t;
typedef enum
{
POWER_DOWN = 0,
GREEN = 1,
RED = 2,
BLUE = 3,
STANDBY = 4,
RGB = 5,
GREEN_RED = 6,
GREEN_BLUE = 7
} Mode_t;
typedef enum
{
LOW = 0,
HIGH = 1
} Range_t;
typedef enum
{
RES_12BIT = 0,
RES_16BIT = 1
} Resolution_t;
const uint8_t deviceID = 0x7D;
// Class Constructor
isl29125(uint8_t slaveAddress, ISerialBus<uint8_t>& serialPort);
FunctionStatus initialize(void);
FunctionStatus setMode(Mode_t mode);
FunctionStatus setRange(Range_t range);
FunctionStatus setResolution(Resolution_t resolutionß);
FunctionStatus getRGB(struct rgb_t* rgb);
// -----------------------------------------------------------------------------------------------------------------
// Protected Section
// -----------------------------------------------------------------------------------------------------------------
protected:
// -----------------------------------------------------------------------------------------------------------------
// Private Section
// -----------------------------------------------------------------------------------------------------------------
private:
struct __attribute__ ((packed)) memorymap
{
uint8_t device_id;
struct
{
uint8_t mode :3;
uint8_t range :1;
uint8_t bits :1;
uint8_t sync :1;
uint8_t RESERVERED :2;
} configuration1;
struct
{
uint8_t alscc :6;
uint8_t RESERVED :1;
uint8_t ircom :1;
} configuration2;
struct
{
uint8_t intsel :2;
uint8_t prst :2;
uint8_t conven :1;
uint8_t RESERVED :3;
} configuration3;
struct
{
uint8_t lowByte;
uint8_t highByte;
} lowThreshold;
struct
{
uint8_t lowByte;
uint8_t highByte;
} highThreshold;
struct
{
uint8_t RESERVED1 :2;
uint8_t grbcf :2;
uint8_t RESERVED2 :1;
uint8_t boutf :1;
uint8_t convenf :1;
uint8_t rgbthf :1;
} statusFlags;
union
{
uint16_t word;
struct
{
uint8_t lowByte;
uint8_t highByte;
};
} greenData;
union
{
uint16_t word;
struct
{
uint8_t lowByte;
uint8_t highByte;
};
} redData;
union
{
uint16_t word;
struct
{
uint8_t lowByte;
uint8_t highByte;
};
} blueData;
};
struct memorymap memorymap;
uint8_t slaveAddress;
ISerialBus<uint8_t>& bus;
bool initialized;
// Reads the device ID directly into the memory map
FunctionStatus getDeviceID(void);
// Reads all configuration registers into the memory map
FunctionStatus getConfiguration(void);
// Reads all Threshold registers into the memory map
FunctionStatus getTheshold(void);
// Reads the status register into the memory map
FunctionStatus getStatusFlags(void);
// Reads the RGB data registers into the memory map
FunctionStatus getRGBRegisters(void);
// Read the full memory map from device into the local memory map, which creates a perfect memory copy
FunctionStatus getCompleteRegisterMap(void);
};
/** @} */
#endif /* MAIN_PLATFORM_INC_ISL29125_H_ */
+116
View File
@@ -0,0 +1,116 @@
// --------------------------------------------------------------------------------------------------------------------
/// \file ledmatrix.h
/// \brief File description
// --------------------------------------------------------------------------------------------------------------------
//
// vbchaos software design
//
// --------------------------------------------------------------------------------------------------------------------
/// $Revision: $
/// $Author: $
/// $Date: $
// (c) 2023 vbchaos
// --------------------------------------------------------------------------------------------------------------------
#ifndef MAIN_PLATFORM_INC_LEDMATRIX_H_
#define MAIN_PLATFORM_INC_LEDMATRIX_H_
/**
* ledmatrix implementation
* \defgroup ledmatrix
* \brief {group_description}
* \addtogroup {Layer}
*
* Detailed description
* @{
*/
// --------------------------------------------------------------------------------------------------------------------
// Include files
// --------------------------------------------------------------------------------------------------------------------
// CompilerIncludes
// All include files that are provided by the compiler directly
// ProjectIncludes
// All include files that are provided by the project
#include "prgm_ledstrip.h"
// --------------------------------------------------------------------------------------------------------------------
// Constant and macro definitions
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Type definitions.
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Function declarations
// --------------------------------------------------------------------------------------------------------------------
class ledmatrix : public prgm_ledstrip
{
// -----------------------------------------------------------------------------------------------------------------
// Public Section
// -----------------------------------------------------------------------------------------------------------------
public:
typedef enum
{
ORIENTATION_ROW_LEFT_UP = 0,
ORIENTATION_ROW_LEFT_DOWN = 1,
ORIENTATION_ROW_RIGHT_UP = 2,
ORIENTATION_ROW_RIGHT_DOWN = 3,
ORIENTATION_COL_LEFT_UP = 4,
ORIENTATION_COL_LEFT_DOWN = 5,
ORIENTATION_COL_RIGHT_UP = 6,
ORIENTATION_COL_RIGHT_DOWN = 7,
ORIENTATION_END = 8
} Orientation_t;
struct coordinate
{
uint32_t x;
uint32_t y;
};
// Class Constructor
ledmatrix(uint32_t rows, uint32_t columns, uint32_t gpio);
FunctionStatus setOrientation(Orientation_t orientation);
FunctionStatus setPixel(uint32_t row, uint32_t column, uint8_t red, uint8_t green, uint8_t blue);
FunctionStatus setRow(uint32_t row, uint8_t red, uint8_t green, uint8_t blue);
FunctionStatus setColumn(uint32_t row, uint8_t red, uint8_t green, uint8_t blue);
// -----------------------------------------------------------------------------------------------------------------
// Protected Section
// -----------------------------------------------------------------------------------------------------------------
protected:
// -----------------------------------------------------------------------------------------------------------------
// Private Section
// -----------------------------------------------------------------------------------------------------------------
private:
uint32_t width;
uint32_t highth;
Orientation_t orientation;
FunctionStatus calculateIndexFromCoordinates(uint32_t row, uint32_t column, uint32_t* index);
};
/** @} */
#endif /* MAIN_PLATFORM_INC_LEDMATRIX_H_ */
+179
View File
@@ -0,0 +1,179 @@
// --------------------------------------------------------------------------------------------------------------------
/// \file logger.h
/// \brief File description
// --------------------------------------------------------------------------------------------------------------------
//
// vbchaos software design
//
// --------------------------------------------------------------------------------------------------------------------
/// $Revision: $
/// $Author: $
/// $Date: $
// (c) 2023 vbchaos
// --------------------------------------------------------------------------------------------------------------------
#ifndef MAIN_PLATFORM_INC_LOGGER_H_
#define MAIN_PLATFORM_INC_LOGGER_H_
/**
* logger implementation
* \defgroup logger
* \brief {group_description}
* \addtogroup {Layer}
*
* Detailed description
* @{
*/
// --------------------------------------------------------------------------------------------------------------------
// Include files
// --------------------------------------------------------------------------------------------------------------------
// CompilerIncludes
// All include files that are provided by the compiler directly
#include <stdint.h>
#include <list>
#include <string>
#include <cstring>
// ProjectIncludes
// All include files that are provided by the project
#include <ISerialBus.h>
// --------------------------------------------------------------------------------------------------------------------
// Constant and macro definitions
// --------------------------------------------------------------------------------------------------------------------
#define ENABLE_SERIAL_LOGGING
#if defined(ENABLE_SERIAL_LOGGING)
#define LOGGER_LOG(severity,...) \
logger::log(__FILE__, __func__, __LINE__, severity, ##__VA_ARGS__)
#else
#define LOGGER_LOG(severity, message)
#endif
/**
* Logs an print message
* \memberof Logger
*/
#define LOGGER_PRINT(...) LOGGER_LOG(logger::LogType::LOGTYPE_PRINT, ##__VA_ARGS__)
/**
* Logs an debug message
* \memberof Logger
*/
#define LOGGER_DEBUG(...) LOGGER_LOG(logger::LogType::LOGTYPE_DEBUG, ##__VA_ARGS__)
/**
* Logs an info message
* \memberof Logger
*/
#define LOGGER_INFO(...) LOGGER_LOG(logger::LogType::LOGTYPE_INFO, ##__VA_ARGS__)
/**
* Logs an warning message
* \memberof Logger
*/
#define LOGGER_WARNING(...) LOGGER_LOG(logger::LogType::LOGTYPE_WARNING, ##__VA_ARGS__)
/**
* Logs an success message
* \memberof Logger
*/
#define LOGGER_SUCCESS(...) LOGGER_LOG(logger::LogType::LOGTYPE_SUCCESS, ##__VA_ARGS__)
/**
* Logs an error message
* \memberof Logger
*/
#define LOGGER_ERROR(...) LOGGER_LOG(logger::LogType::LOGTYPE_ERROR, ##__VA_ARGS__)
// --------------------------------------------------------------------------------------------------------------------
// Type definitions.
// --------------------------------------------------------------------------------------------------------------------
//class logger;
//extern logger debugLogger;
// --------------------------------------------------------------------------------------------------------------------
// Function declarations
// --------------------------------------------------------------------------------------------------------------------
class logger
{
// -----------------------------------------------------------------------------------------------------------------
// Public Section
// -----------------------------------------------------------------------------------------------------------------
public:
typedef enum
{
LOGTYPE_PRINT, /**< Raw print */
LOGTYPE_DEBUG, /**< Debug information only; will not be stored on SD-card */
LOGTYPE_INFO, /**< Informational messages of important events */
LOGTYPE_WARNING, /**< Recoverable fault */
LOGTYPE_SUCCESS, /**< A specific success message */
LOGTYPE_ERROR /**< Unrecoverable fault */
} LogType;
// Class Constructor
logger(uint32_t queuesize, ISerialBus<uint8_t>& serialPort);
static FunctionStatus log(const char* fileName, const char* functionName, int lineNumber, LogType logType, const char* format, ...);
// The Logger task - should be called by the system scheduler regularly
void task();
// -----------------------------------------------------------------------------------------------------------------
// Protected Section
// -----------------------------------------------------------------------------------------------------------------
protected:
// -----------------------------------------------------------------------------------------------------------------
// Private Section
// -----------------------------------------------------------------------------------------------------------------
private:
struct LogQueueItem
{
std::string fileName;
std::string functionName;
std::string context;
uint32_t lineNumber;
LogType logType;
};
struct typeParameters
{
LogType logType;
std::string vt100Prefix;
std::string logPrefix;
std::string vt100Postfix;
};
void composeTypeParameterList(void);
static void composeLogQueueItem(struct LogQueueItem* logQueueItem, const std::string& fileName, const std::string& functionName,
int lineNumber, LogType logType, const std::string& context);
std::list<struct typeParameters> typeParameterList;
static std::list<struct LogQueueItem> queue;
ISerialBus<uint8_t>& port;
static uint32_t queuesize;
static uint32_t numberOfLostMessages;
static bool overflowRecovery;
};
/** @} */
#endif /* MAIN_PLATFORM_INC_LOGGER_H_ */
+124
View File
@@ -0,0 +1,124 @@
// --------------------------------------------------------------------------------------------------------------------
/// \file prgm_ledstrip.h
/// \brief File description
// --------------------------------------------------------------------------------------------------------------------
//
// vbchaos software design
//
// --------------------------------------------------------------------------------------------------------------------
/// $Revision: $
/// $Author: $
/// $Date: $
// (c) 2023 vbchaos
// --------------------------------------------------------------------------------------------------------------------
#ifndef MAIN_PLATFORM_INC_PRGM_LEDSTRIP_H_
#define MAIN_PLATFORM_INC_PRGM_LEDSTRIP_H_
/**
* prgm_ledstrip implementation
* \defgroup prgm_ledstrip
* \brief {group_description}
* \addtogroup {Layer}
*
* Detailed description
* @{
*/
// --------------------------------------------------------------------------------------------------------------------
// Include files
// --------------------------------------------------------------------------------------------------------------------
// CompilerIncludes
// All include files that are provided by the compiler directly
#include <stdint.h>
// ProjectIncludes
// All include files that are provided by the project
#include "FunctionStatus.h"
#include "led_strip.h"
// --------------------------------------------------------------------------------------------------------------------
// Constant and macro definitions
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Type definitions.
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Function declarations
// --------------------------------------------------------------------------------------------------------------------
class prgm_ledstrip
{
// -----------------------------------------------------------------------------------------------------------------
// Public Section
// -----------------------------------------------------------------------------------------------------------------
public:
struct pixel
{
uint32_t index;
union
{
struct
{
uint8_t red;
uint8_t green;
uint8_t blue;
} rgb;
struct
{
uint16_t hue;
uint8_t saturation;
uint8_t value;
} hsv;
};
};
// Class Constructor
prgm_ledstrip(uint32_t numberOfLEDs, uint32_t gpio);
// Set and clear functions only update the pixel value(s) locally but do not push the values to the strip
FunctionStatus setPixelRGB(struct pixel& pixel);
FunctionStatus setPixelHSV(struct pixel& pixel);
FunctionStatus clearAll(void);
// Clears all pixels locally and automatically pushes the values to the strip
FunctionStatus clearAndUpdate(void);
// Push the latest pixel values to the strip
FunctionStatus update(void);
// -----------------------------------------------------------------------------------------------------------------
// Protected Section
// -----------------------------------------------------------------------------------------------------------------
protected:
// -----------------------------------------------------------------------------------------------------------------
// Private Section
// -----------------------------------------------------------------------------------------------------------------
private:
uint32_t numberOfLEDs;
uint32_t gpio;
led_strip_handle_t led_strip;
led_strip_config_t strip_config;
led_strip_rmt_config_t rmt_config;
};
/** @} */
#endif /* MAIN_PLATFORM_INC_PRGM_LEDSTRIP_H_ */
@@ -34,12 +34,12 @@
// CompilerIncludes
// All include files that are provided by the compiler directly
#include "esp_system.h"
//#include "esp_system.h"
#include "esp_event.h"
#include "esp_log.h"
//#include "esp_log.h"
//
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
//#include "freertos/task.h"
#include "freertos/event_groups.h"
@@ -2,7 +2,7 @@
/// \file bme280.cpp
/// \brief Description
// --------------------------------------------------------------------------------------------------------------------
//
//
// vbchaos software design
//
// --------------------------------------------------------------------------------------------------------------------
@@ -26,19 +26,19 @@
// --------------------------------------------------------------------------------------------------------------------
// List of registers
#define ADDRESS_COMP_PARAMETERS ((uint32_t)0x88)
#define ADDRESS_COMP_PARAMETERS ((uint8_t)0x88)
#define ADDRESS_REG_ID ((uint32_t)0xD0)
#define ADDRESS_REG_RESET ((uint32_t)0xE0)
#define ADDRESS_REG_STATUS ((uint32_t)0xF3)
#define ADDRESS_REG_CTRL_MEAS ((uint32_t)0xF4)
#define ADDRESS_REG_CONFIG ((uint32_t)0xF5)
#define ADDRESS_REG_PRESSURE_MSB ((uint32_t)0xF7)
#define ADDRESS_REG_PRESSURE_LSB ((uint32_t)0xF8)
#define ADDRESS_REG_PRESSURE_XLSB ((uint32_t)0xF9)
#define ADDRESS_REG_TEMPERATURE_MSB ((uint32_t)0xFA)
#define ADDRESS_REG_TEMPERATURE_LSB ((uint32_t)0xFB)
#define ADDRESS_REG_TEMPERATURE_XLSB ((uint32_t)0xFC)
#define ADDRESS_REG_ID ((uint8_t)0xD0)
#define ADDRESS_REG_RESET ((uint8_t)0xE0)
#define ADDRESS_REG_STATUS ((uint8_t)0xF3)
#define ADDRESS_REG_CTRL_MEAS ((uint8_t)0xF4)
#define ADDRESS_REG_CONFIG ((uint8_t)0xF5)
#define ADDRESS_REG_PRESSURE_MSB ((uint8_t)0xF7)
#define ADDRESS_REG_PRESSURE_LSB ((uint8_t)0xF8)
#define ADDRESS_REG_PRESSURE_XLSB ((uint8_t)0xF9)
#define ADDRESS_REG_TEMPERATURE_MSB ((uint8_t)0xFA)
#define ADDRESS_REG_TEMPERATURE_LSB ((uint8_t)0xFB)
#define ADDRESS_REG_TEMPERATURE_XLSB ((uint8_t)0xFC)
// --------------------------------------------------------------------------------------------------------------------
// Type definitions
@@ -62,23 +62,20 @@
// --------------------------------------------------------------------------------------------------------------------
BMP280::BMP280(I2C* bus, uint8_t slaveAddress)
bmp280::bmp280(uint8_t slaveAddress, ISerialBus<uint8_t>& serialPort) : slaveAddress {slaveAddress}, bus {serialPort}
{
// Take over the bus
BMP280::bus = bus;
// Take over the device slave address
BMP280::slaveAddress = slaveAddress;
initialized = false;
// Reset the driver itself
resetDriver();
// Reset the device
}
void BMP280::resetSensor(void)
void bmp280::resetSensor(void)
{
resetDevice();
}
bool BMP280::initialize(void)
bool bmp280::initialize(void)
{
bool returnValue = true;
@@ -98,7 +95,7 @@ bool BMP280::initialize(void)
return returnValue;
}
bool BMP280::setSensorMode(BMP280_Mode_t mode)
bool bmp280::setSensorMode(BMP280_Mode_t mode)
{
bool returnValue = true;
memorymap.ctrl_meas.mode = mode;
@@ -106,7 +103,7 @@ bool BMP280::setSensorMode(BMP280_Mode_t mode)
return returnValue;
}
bool BMP280::setSensorTemperatureOversampling(BMP280_Oversampling_t oversampling)
bool bmp280::setSensorTemperatureOversampling(BMP280_Oversampling_t oversampling)
{
bool returnValue = true;
memorymap.ctrl_meas.oversampling_temp = oversampling;
@@ -114,68 +111,72 @@ bool BMP280::setSensorTemperatureOversampling(BMP280_Oversampling_t oversampling
return returnValue;
}
int BMP280::getTemperature(void)
int bmp280::getTemperature(void)
{
// Get latest raw values from device
BMP280::getTemperatureValues();
getTemperatureValues();
// Calculate temperature
BMP280::compensateTemperature();
compensateTemperature();
// return the value
return temperature;
}
void BMP280::resetDriver(void)
void bmp280::resetDriver(void)
{
// Reset the parameters
BMP280::compensationParameters = {};
compensationParameters = {};
// Reset the device memory map
BMP280::memorymap = {};
memorymap = {};
// Reset the mode
BMP280::mode = STANDBY;
mode = STANDBY;
// Reset calculation values
t_fine = 0;
temperature = 0;
}
void BMP280::getDeviceID(void)
void bmp280::getDeviceID(void)
{
bus->read_register(slaveAddress, ADDRESS_REG_ID, &memorymap.id, 1);
uint32_t actualLength;
bus.read(slaveAddress, ADDRESS_REG_ID, &memorymap.id, 1, &actualLength);
}
void BMP280::resetDevice(void)
void bmp280::resetDevice(void)
{
uint8_t resetValue = BMP280_RESET_VALUE;
bus->write_register(slaveAddress, ADDRESS_REG_RESET, &resetValue, 1);
bus.write(slaveAddress, ADDRESS_REG_RESET, &resetValue, 1);
}
void BMP280::setSensorControlMeasurement(void)
void bmp280::setSensorControlMeasurement(void)
{
bus->write_register(slaveAddress, ADDRESS_REG_CTRL_MEAS, (uint8_t*)&memorymap.ctrl_meas, 1);
bus.write(slaveAddress, ADDRESS_REG_CTRL_MEAS, (uint8_t*)&memorymap.ctrl_meas, 1);
}
void BMP280::setSensorConfiguration(void)
void bmp280::setSensorConfiguration(void)
{
bus->write_register(slaveAddress, ADDRESS_REG_CONFIG, (uint8_t*)&memorymap.config, 1);
bus.write(slaveAddress, ADDRESS_REG_CONFIG, (uint8_t*)&memorymap.config, 1);
}
void BMP280::getCompensationValues(void)
void bmp280::getCompensationValues(void)
{
bus->read_register(slaveAddress, ADDRESS_COMP_PARAMETERS, (uint8_t*)&compensationParameters, sizeof(compensationParameters));
uint32_t actualLength;
bus.read(slaveAddress, ADDRESS_COMP_PARAMETERS, (uint8_t*)&compensationParameters, sizeof(compensationParameters), &actualLength);
LOGGER_DEBUG("Got compensation values: %04X %04X %04X", compensationParameters.dig_T1, compensationParameters.dig_T2, compensationParameters.dig_T3);
}
void BMP280::getPreasureValues(void)
void bmp280::getPreasureValues(void)
{
bus->read_register(slaveAddress, ADDRESS_REG_PRESSURE_LSB, (uint8_t*)&memorymap.pressure_raw, sizeof(memorymap.pressure_raw));
uint32_t actualLength;
bus.read(slaveAddress, ADDRESS_REG_PRESSURE_LSB, (uint8_t*)&memorymap.pressure_raw, sizeof(memorymap.pressure_raw), &actualLength);
}
void BMP280::getTemperatureValues(void)
void bmp280::getTemperatureValues(void)
{
bus->read_register(slaveAddress, ADDRESS_REG_TEMPERATURE_MSB, (uint8_t*)&memorymap.temperature_raw, sizeof(memorymap.temperature_raw));
uint32_t actualLength;
bus.read(slaveAddress, ADDRESS_REG_TEMPERATURE_MSB, (uint8_t*)&memorymap.temperature_raw, sizeof(memorymap.temperature_raw), &actualLength);
}
void BMP280::compensateTemperature(void)
void bmp280::compensateTemperature(void)
{
int adc_T = 0;
// Create a single temperature value from the individual memory entries
+195
View File
@@ -0,0 +1,195 @@
// --------------------------------------------------------------------------------------------------------------------
/// \file isl29125.cpp
/// \brief Description
// --------------------------------------------------------------------------------------------------------------------
//
// vbchaos software design
//
// --------------------------------------------------------------------------------------------------------------------
/// $Revision: $
/// $Author: $
/// $Date: $
// (c) 2023 vbchaos
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Include files
// --------------------------------------------------------------------------------------------------------------------
#include <isl29125.h>
// --------------------------------------------------------------------------------------------------------------------
// Constant and macro definitions
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Type definitions
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// File-scope variables
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Function declarations
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Function definitions
// --------------------------------------------------------------------------------------------------------------------
isl29125::isl29125(uint8_t slaveAddress, ISerialBus<uint8_t>& serialPort) : slaveAddress {slaveAddress}, bus {serialPort}
{
initialized = false;
}
FunctionStatus isl29125::initialize(void)
{
FunctionStatus returnValue = FUNCTION_STATUS_OK;
// Get the Device ID
returnValue = getDeviceID();
if (returnValue == FUNCTION_STATUS_OK)
{
// Verify the Device ID against the default known ID
if (memorymap.device_id != deviceID)
{
returnValue = FUNCTION_STATUS_ERROR;
}
}
if (returnValue == FUNCTION_STATUS_OK)
{
// Fetch the complete register map for an initial copy
returnValue = getCompleteRegisterMap();
}
if (returnValue == FUNCTION_STATUS_OK)
{
initialized = true;
}
return returnValue;
}
FunctionStatus isl29125::setMode(Mode_t mode)
{
FunctionStatus returnValue = FUNCTION_STATUS_OK;
if (!initialized)
{
returnValue = FUNCTION_STATUS_NOT_INITIALIZED;
}
else
{
memorymap.configuration1.mode = mode;
returnValue = bus.write(slaveAddress, 0x01, (uint8_t*)&memorymap.configuration1, 1);
}
return returnValue;
}
FunctionStatus isl29125::setRange(Range_t range)
{
FunctionStatus returnValue = FUNCTION_STATUS_OK;
if (!initialized)
{
returnValue = FUNCTION_STATUS_NOT_INITIALIZED;
}
else
{
memorymap.configuration1.range = range;
returnValue = bus.write(slaveAddress, 0x01, (uint8_t*)&memorymap.configuration1, 1);
}
return returnValue;
}
FunctionStatus isl29125::setResolution(Resolution_t resolution)
{
FunctionStatus returnValue = FUNCTION_STATUS_OK;
if (!initialized)
{
returnValue = FUNCTION_STATUS_NOT_INITIALIZED;
}
else
{
memorymap.configuration1.bits = resolution;
returnValue = bus.write(slaveAddress, 0x01, (uint8_t*)&memorymap.configuration1, 1);
}
return returnValue;
}
FunctionStatus isl29125::getRGB(struct rgb_t* rgb)
{
FunctionStatus returnValue = FUNCTION_STATUS_OK;
if (!initialized)
{
returnValue = FUNCTION_STATUS_NOT_INITIALIZED;
}
else
{
returnValue = getRGBRegisters();
}
if (returnValue == FUNCTION_STATUS_OK)
{
rgb->blue = memorymap.blueData.word;
rgb->green = memorymap.greenData.word;
rgb->red = memorymap.redData.word;
}
return returnValue;
}
FunctionStatus isl29125::getDeviceID(void)
{
uint32_t actualLength;
return bus.read(slaveAddress, 0x00, (uint8_t*)&memorymap, 1, &actualLength);
}
FunctionStatus isl29125::getConfiguration(void)
{
uint32_t actualLength;
return bus.read(slaveAddress, 0x01, (uint8_t*)&memorymap, 3, &actualLength);
}
FunctionStatus isl29125::getTheshold(void)
{
uint32_t actualLength;
return bus.read(slaveAddress, 0x04, (uint8_t*)&memorymap, 4, &actualLength);
}
FunctionStatus isl29125::getStatusFlags(void)
{
uint32_t actualLength;
return bus.read(slaveAddress, 0x08, (uint8_t*)&memorymap, 1, &actualLength);
}
FunctionStatus isl29125::getRGBRegisters(void)
{
uint32_t actualLength;
return bus.read(slaveAddress, 0x09, (uint8_t*)&memorymap, 6, &actualLength);
}
FunctionStatus isl29125::getCompleteRegisterMap(void)
{
uint32_t actualLength;
return bus.read(slaveAddress, 0x00, (uint8_t*)&memorymap, 1, &actualLength);
}
+168
View File
@@ -0,0 +1,168 @@
// --------------------------------------------------------------------------------------------------------------------
/// \file ledmatrix.cpp
/// \brief Description
// --------------------------------------------------------------------------------------------------------------------
//
// vbchaos software design
//
// --------------------------------------------------------------------------------------------------------------------
/// $Revision: $
/// $Author: $
/// $Date: $
// (c) 2023 vbchaos
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Include files
// --------------------------------------------------------------------------------------------------------------------
#include <ledmatrix.h>
// --------------------------------------------------------------------------------------------------------------------
// Constant and macro definitions
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Type definitions
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// File-scope variables
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Function declarations
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Function definitions
// --------------------------------------------------------------------------------------------------------------------
ledmatrix::ledmatrix(uint32_t rows, uint32_t columns, uint32_t gpio) : prgm_ledstrip(rows * columns, gpio)
{
this->width = columns;
this->highth = rows;
this->orientation = ORIENTATION_ROW_LEFT_UP;
}
FunctionStatus ledmatrix::setOrientation(Orientation_t orientation)
{
FunctionStatus returnValue = FUNCTION_STATUS_OK;
if (orientation < ORIENTATION_END)
{
this->orientation = orientation;
}
else
{
returnValue = FUNCTION_STATUS_ERROR;
}
return returnValue;
}
FunctionStatus ledmatrix::setPixel(uint32_t row, uint32_t column, uint8_t red, uint8_t green, uint8_t blue)
{
FunctionStatus returnValue = FUNCTION_STATUS_OK;
uint32_t index = 0;
if ((row > highth) || (column > width))
{
returnValue = FUNCTION_STATUS_ERROR;
}
if (returnValue == FUNCTION_STATUS_OK)
{
returnValue = calculateIndexFromCoordinates(row, column, &index);
}
if (returnValue == FUNCTION_STATUS_OK)
{
struct pixel p;
p.index = index;
p.rgb.red = red;
p.rgb.green = green;
p.rgb.blue = blue;
returnValue = prgm_ledstrip::setPixelRGB(p);
}
return returnValue;
}
FunctionStatus ledmatrix::setRow(uint32_t row, uint8_t red, uint8_t green, uint8_t blue)
{
FunctionStatus returnValue = FUNCTION_STATUS_OK;
for (uint32_t column = 0; column < width; column++)
{
returnValue = setPixel(row, column, red, green, blue);
if (returnValue != FUNCTION_STATUS_OK)
{
break;
}
}
return returnValue;
}
FunctionStatus ledmatrix::setColumn(uint32_t column, uint8_t red, uint8_t green, uint8_t blue)
{
FunctionStatus returnValue = FUNCTION_STATUS_OK;
for (uint32_t row = 0; row < highth; row++)
{
returnValue = setPixel(row, column, red, green, blue);
if (returnValue != FUNCTION_STATUS_OK)
{
break;
}
}
return returnValue;
}
FunctionStatus ledmatrix::calculateIndexFromCoordinates(uint32_t row, uint32_t column, uint32_t* index)
{
FunctionStatus returnValue = FUNCTION_STATUS_OK;
switch(orientation)
{
case ORIENTATION_ROW_LEFT_UP:
*index = row * width + column;
break;
case ORIENTATION_ROW_LEFT_DOWN:
break;
case ORIENTATION_ROW_RIGHT_UP:
break;
case ORIENTATION_ROW_RIGHT_DOWN:
break;
case ORIENTATION_COL_LEFT_UP:
break;
case ORIENTATION_COL_LEFT_DOWN:
break;
case ORIENTATION_COL_RIGHT_UP:
break;
case ORIENTATION_COL_RIGHT_DOWN:
break;
default:
*index = 0;
returnValue = FUNCTION_STATUS_ERROR;
}
return returnValue;
}
+196
View File
@@ -0,0 +1,196 @@
// --------------------------------------------------------------------------------------------------------------------
/// \file logger.cpp
/// \brief Description
// --------------------------------------------------------------------------------------------------------------------
//
// vbchaos software design
//
// --------------------------------------------------------------------------------------------------------------------
/// $Revision: $
/// $Author: $
/// $Date: $
// (c) 2023 vbchaos
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Include files
// --------------------------------------------------------------------------------------------------------------------
#include <logger.h>
#include <algorithm>
#include <cstdio>
#include <cstdarg>
// --------------------------------------------------------------------------------------------------------------------
// Constant and macro definitions
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Type definitions
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// File-scope variables
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Function declarations
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Function definitions
// --------------------------------------------------------------------------------------------------------------------
std::list<struct logger::LogQueueItem> logger::queue;
uint32_t logger::queuesize = 16;
uint32_t logger::numberOfLostMessages = 0;
bool logger::overflowRecovery = false;
logger::logger(uint32_t queuesize, ISerialBus<uint8_t>& serialPort) : port {serialPort}
{
numberOfLostMessages = 0;
// Compose the debug type level list
composeTypeParameterList();
}
FunctionStatus logger::log(const char* fileName, const char* functionName, int lineNumber, LogType logType, const char* format, ...)
{
FunctionStatus returnValue = FUNCTION_STATUS_OK;
#if defined(ENABLE_SERIAL_LOGGING)
int nrOfMessages;
struct LogQueueItem logQueueItem;
va_list ap;
nrOfMessages = queue.size();
if((nrOfMessages >= queuesize - 1) && !overflowRecovery)
{
// Queue almost full, only one entry left. Log a warning instead
composeLogQueueItem(&logQueueItem, __FILE__, __func__, __LINE__, LOGTYPE_WARNING, "Log queue overflow");
queue.push_back(logQueueItem);
overflowRecovery = true;
numberOfLostMessages = 1;
}
else if((nrOfMessages == 0) && overflowRecovery)
{
// Queue empty again after an overflow
std::string str = std::to_string(numberOfLostMessages) + " messages were lost in the logger due to QUEUE overflow";
composeLogQueueItem(&logQueueItem, __FILE__, __func__, __LINE__, LOGTYPE_WARNING, str);
queue.push_back(logQueueItem);
overflowRecovery = false;
}
else if(!overflowRecovery)
{
// Normal behaviour, queue not full
char str[128];
va_start(ap, format);
vsnprintf(str, sizeof(str) / sizeof(str[0]), format, ap);
va_end(ap);
composeLogQueueItem(&logQueueItem, fileName, functionName, lineNumber, logType, str);
queue.push_back(logQueueItem);
}
else
{
// Count number of lost messages
++numberOfLostMessages;
}
#endif
return returnValue;
}
void logger::composeTypeParameterList(void)
{
typeParameterList.clear();
// Add Debug information
typeParameterList.push_back({LOGTYPE_DEBUG, "\033[33m", "DBG", "\033[0m"});
// Add Warning information
typeParameterList.push_back({LOGTYPE_WARNING, "\033[35m", "WRN", "\033[0m"});
// Add Error information
typeParameterList.push_back({LOGTYPE_ERROR, "\033[31m", "ERR", "\033[0m"});
// Add Success information
typeParameterList.push_back({LOGTYPE_SUCCESS, "\033[32m", "SCS", "\033[0m"});
// Add Information information
typeParameterList.push_back({LOGTYPE_INFO, "\033[33m", "INF", "\033[0m"});
// Add Print information
typeParameterList.push_back({LOGTYPE_PRINT, "", "DBG", "\033[0m"});
}
#if defined(ENABLE_SERIAL_LOGGING)
void logger::composeLogQueueItem(struct LogQueueItem* logQueueItem, const std::string& fileName, const std::string& functionName,
int lineNumber, LogType logType, const std::string& context)
{
logQueueItem->logType = logType;
logQueueItem->context = context;
logQueueItem->fileName = fileName;
logQueueItem->functionName = functionName;
logQueueItem->lineNumber = lineNumber;
}
#endif
void logger::task()
{
struct LogQueueItem logQueueItem;
// Check if there is anything in the queue
// If queue is empty, return to scheduler
if (queue.empty())
{
return;
}
// Get the first log item from queue
logQueueItem = queue.front();
// Remove the item from the queue
queue.pop_front();
if(logQueueItem.logType == LOGTYPE_PRINT)
{
// Raw print
#if defined(ENABLE_SERIAL_LOGGING)
port.write(NO_DEVICE_ADDRESS, NO_REGISTER_ADDRESS, (uint8_t*)logQueueItem.context.c_str(), logQueueItem.context.length());
#endif
}
else
{
unsigned int seconds = 0;
#if defined(ENABLE_SERIAL_LOGGING)
// Formatted print
// Find the correct Log level type
auto it = std::find_if(typeParameterList.begin(), typeParameterList.end(), [&logQueueItem](const struct typeParameters& obj) {return obj.logType == logQueueItem.logType;});
std::string outputString = "\n\r"
+ it->vt100Prefix + " "
+ it->vt100Prefix + " "
+ std::to_string(seconds) + " "
+ logQueueItem.fileName + " "
+ logQueueItem.functionName + " "
+ "(line " + std::to_string(logQueueItem.lineNumber) + "): "
+ logQueueItem.context + " "
+ it->vt100Postfix;
port.write(NO_DEVICE_ADDRESS, NO_REGISTER_ADDRESS, (uint8_t*)outputString.c_str(), outputString.length() + 1);
#endif
}
}
+128
View File
@@ -0,0 +1,128 @@
// --------------------------------------------------------------------------------------------------------------------
/// \file prgm_ledstrip.cpp
/// \brief Description
// --------------------------------------------------------------------------------------------------------------------
//
// vbchaos software design
//
// --------------------------------------------------------------------------------------------------------------------
/// $Revision: $
/// $Author: $
/// $Date: $
// (c) 2023 vbchaos
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Include files
// --------------------------------------------------------------------------------------------------------------------
#include <cstring>
#include <prgm_ledstrip.h>
// --------------------------------------------------------------------------------------------------------------------
// Constant and macro definitions
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Type definitions
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// File-scope variables
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Function declarations
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Function definitions
// --------------------------------------------------------------------------------------------------------------------
prgm_ledstrip::prgm_ledstrip(uint32_t numberOfLEDs, uint32_t gpio) : numberOfLEDs(numberOfLEDs), gpio(gpio)
{
/* LED strip initialization with the GPIO and pixels number*/
memset(&strip_config, 0, sizeof(strip_config));
strip_config.strip_gpio_num = gpio; // The GPIO that connected to the LED strip's data line
strip_config.max_leds = numberOfLEDs; // The number of LEDs in the strip,
strip_config.led_pixel_format = LED_PIXEL_FORMAT_GRB; // Pixel format of your LED strip
strip_config.led_model = LED_MODEL_WS2812; // LED strip model
strip_config.flags.invert_out = false; // whether to invert the output signal (useful when your hardware has a level inverter)
memset(&rmt_config, 0, sizeof(rmt_config));
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0)
rmt_config.rmt_channel = 0;
#else
rmt_config.clk_src = RMT_CLK_SRC_DEFAULT; // different clock source can lead to different power consumption
rmt_config.resolution_hz = 10 * 1000 * 1000; // 10MHz
rmt_config.flags.with_dma = false; // whether to enable the DMA feature
rmt_config.mem_block_symbols = 128;
#endif
ESP_ERROR_CHECK(led_strip_new_rmt_device(&strip_config, &rmt_config, &led_strip));
}
FunctionStatus prgm_ledstrip::setPixelRGB(struct pixel& pixel)
{
FunctionStatus returnValue = FUNCTION_STATUS_OK;
if (pixel.index < numberOfLEDs)
{
ESP_ERROR_CHECK(led_strip_set_pixel(led_strip, pixel.index, pixel.rgb.red, pixel.rgb.green, pixel.rgb.blue));
}
else
{
returnValue = FUNCTION_STATUS_ERROR;
}
return returnValue;
}
FunctionStatus prgm_ledstrip::setPixelHSV(struct pixel& pixel)
{
FunctionStatus returnValue = FUNCTION_STATUS_OK;
if (pixel.index < numberOfLEDs)
{
ESP_ERROR_CHECK(led_strip_set_pixel_hsv(led_strip, pixel.index, pixel.hsv.hue, pixel.hsv.saturation, pixel.hsv.value));
}
else
{
returnValue = FUNCTION_STATUS_ERROR;
}
return returnValue;
}
FunctionStatus prgm_ledstrip::clearAll(void)
{
for (int i = 0; i < numberOfLEDs; i++)
{
ESP_ERROR_CHECK(led_strip_set_pixel(led_strip, i, 0, 0, 0));
}
return FUNCTION_STATUS_OK;
}
FunctionStatus prgm_ledstrip::clearAndUpdate(void)
{
ESP_ERROR_CHECK(led_strip_clear(led_strip));
return FUNCTION_STATUS_OK;
}
FunctionStatus prgm_ledstrip::update(void)
{
ESP_ERROR_CHECK(led_strip_refresh(led_strip));
return FUNCTION_STATUS_OK;
}
@@ -47,9 +47,10 @@
// File-scope variables
// --------------------------------------------------------------------------------------------------------------------
static const char* ssid = "Kowalski";
static const char* pass = "madagascar";
static const char* ssid = "Skipper";
static const char* pass = "w00t/?YeP";
//static const char* ssid = "Kowalski";
//static const char* pass = "madagascar";
//static const char* ssid = "vbchaos";
//static const char* pass = "mijninternet";
@@ -63,15 +64,13 @@ static const char* pass = "madagascar";
// Function definitions
// --------------------------------------------------------------------------------------------------------------------
int Wifi::s_retry_num = 0;
const char* Wifi::TAG = "wifi station";
EventGroupHandle_t Wifi::s_wifi_event_group = xEventGroupCreate();
int Wifi::s_retry_num = 0;
const char* Wifi::TAG;
Wifi::Wifi()
{
TAG = "wifi station";
}
void Wifi::event_handler(void *arg, esp_event_base_t event_base, int32_t event_id, void *event_data)
-124
View File
@@ -1,124 +0,0 @@
/*
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#include "esp_check.h"
#include "led_strip_encoder.h"
static const char *TAG = "led_encoder";
typedef struct {
rmt_encoder_t base;
rmt_encoder_t *bytes_encoder;
rmt_encoder_t *copy_encoder;
int state;
rmt_symbol_word_t reset_code;
} rmt_led_strip_encoder_t;
static size_t rmt_encode_led_strip(rmt_encoder_t *encoder, rmt_channel_handle_t channel, const void *primary_data, size_t data_size, rmt_encode_state_t *ret_state)
{
rmt_led_strip_encoder_t *led_encoder = __containerof(encoder, rmt_led_strip_encoder_t, base);
rmt_encoder_handle_t bytes_encoder = led_encoder->bytes_encoder;
rmt_encoder_handle_t copy_encoder = led_encoder->copy_encoder;
rmt_encode_state_t session_state = 0;
rmt_encode_state_t state = 0;
size_t encoded_symbols = 0;
switch (led_encoder->state) {
case 0: // send RGB data
encoded_symbols += bytes_encoder->encode(bytes_encoder, channel, primary_data, data_size, &session_state);
if (session_state & RMT_ENCODING_COMPLETE) {
led_encoder->state = 1; // switch to next state when current encoding session finished
}
if (session_state & RMT_ENCODING_MEM_FULL) {
state |= RMT_ENCODING_MEM_FULL;
goto out; // yield if there's no free space for encoding artifacts
}
// fall-through
case 1: // send reset code
encoded_symbols += copy_encoder->encode(copy_encoder, channel, &led_encoder->reset_code,
sizeof(led_encoder->reset_code), &session_state);
if (session_state & RMT_ENCODING_COMPLETE) {
led_encoder->state = 0; // back to the initial encoding session
state |= RMT_ENCODING_COMPLETE;
}
if (session_state & RMT_ENCODING_MEM_FULL) {
state |= RMT_ENCODING_MEM_FULL;
goto out; // yield if there's no free space for encoding artifacts
}
}
out:
*ret_state = state;
return encoded_symbols;
}
static esp_err_t rmt_del_led_strip_encoder(rmt_encoder_t *encoder)
{
rmt_led_strip_encoder_t *led_encoder = __containerof(encoder, rmt_led_strip_encoder_t, base);
rmt_del_encoder(led_encoder->bytes_encoder);
rmt_del_encoder(led_encoder->copy_encoder);
free(led_encoder);
return ESP_OK;
}
static esp_err_t rmt_led_strip_encoder_reset(rmt_encoder_t *encoder)
{
rmt_led_strip_encoder_t *led_encoder = __containerof(encoder, rmt_led_strip_encoder_t, base);
rmt_encoder_reset(led_encoder->bytes_encoder);
rmt_encoder_reset(led_encoder->copy_encoder);
led_encoder->state = 0;
return ESP_OK;
}
esp_err_t rmt_new_led_strip_encoder(const led_strip_encoder_config_t *config, rmt_encoder_handle_t *ret_encoder)
{
esp_err_t ret = ESP_OK;
rmt_led_strip_encoder_t *led_encoder = NULL;
ESP_GOTO_ON_FALSE(config && ret_encoder, ESP_ERR_INVALID_ARG, err, TAG, "invalid argument");
led_encoder = calloc(1, sizeof(rmt_led_strip_encoder_t));
ESP_GOTO_ON_FALSE(led_encoder, ESP_ERR_NO_MEM, err, TAG, "no mem for led strip encoder");
led_encoder->base.encode = rmt_encode_led_strip;
led_encoder->base.del = rmt_del_led_strip_encoder;
led_encoder->base.reset = rmt_led_strip_encoder_reset;
// different led strip might have its own timing requirements, following parameter is for WS2812
rmt_bytes_encoder_config_t bytes_encoder_config = {
.bit0 = {
.level0 = 1,
.duration0 = 0.3 * config->resolution / 1000000, // T0H=0.3us
.level1 = 0,
.duration1 = 0.9 * config->resolution / 1000000, // T0L=0.9us
},
.bit1 = {
.level0 = 1,
.duration0 = 0.9 * config->resolution / 1000000, // T1H=0.9us
.level1 = 0,
.duration1 = 0.3 * config->resolution / 1000000, // T1L=0.3us
},
.flags.msb_first = 1 // WS2812 transfer bit order: G7...G0R7...R0B7...B0
};
ESP_GOTO_ON_ERROR(rmt_new_bytes_encoder(&bytes_encoder_config, &led_encoder->bytes_encoder), err, TAG, "create bytes encoder failed");
rmt_copy_encoder_config_t copy_encoder_config = {};
ESP_GOTO_ON_ERROR(rmt_new_copy_encoder(&copy_encoder_config, &led_encoder->copy_encoder), err, TAG, "create copy encoder failed");
uint32_t reset_ticks = config->resolution / 1000000 * 50 / 2; // reset code duration defaults to 50us
led_encoder->reset_code = (rmt_symbol_word_t) {
.level0 = 0,
.duration0 = reset_ticks,
.level1 = 0,
.duration1 = reset_ticks,
};
*ret_encoder = &led_encoder->base;
return ESP_OK;
err:
if (led_encoder) {
if (led_encoder->bytes_encoder) {
rmt_del_encoder(led_encoder->bytes_encoder);
}
if (led_encoder->copy_encoder) {
rmt_del_encoder(led_encoder->copy_encoder);
}
free(led_encoder);
}
return ret;
}
-259
View File
@@ -1,259 +0,0 @@
// --------------------------------------------------------------------------------------------------------------------
/// \file ledmatrix.cpp
/// \brief Description
// --------------------------------------------------------------------------------------------------------------------
//
// vbchaos software design
//
// --------------------------------------------------------------------------------------------------------------------
/// $Revision: $
/// $Author: $
/// $Date: $
// (c) 2023 vbchaos
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Include files
// --------------------------------------------------------------------------------------------------------------------
#include "ledmatrix.h"
#include "logger.h"
#include "string.h"
// --------------------------------------------------------------------------------------------------------------------
// Constant and macro definitions
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Type definitions
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// File-scope variables
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Function declarations
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Function definitions
// --------------------------------------------------------------------------------------------------------------------
SemaphoreHandle_t LEDMatrix::taskSemaphore = 0;
TaskHandle_t LEDMatrix::matrixTaskHandle = NULL;
bool LEDMatrix::initialized = false;
LEDMatrix::LEDMatrix(LEDMatrix_Parameters_t* parameters)
{
// Take the parameters
LEDMatrix::parameters = *parameters;
// Calculate the total number of pixels
LEDMatrix::numberOfPixels = parameters->width * parameters->height;
// Create the matrix storage
matrix = new LEDMatrix_Pixel_t[parameters->width * parameters->height];
// Create the second matrix, that is actually transmitted to the periphery
// Create the task Semaphore
vSemaphoreCreateBinary(LEDMatrix::taskSemaphore);
// Take the semaphore immediately so the task cannot run
xSemaphoreTake(LEDMatrix::taskSemaphore, 0);
// Create the matrix task
xTaskCreate(matrixTask, (const char*)"matrixTask", 4096, this, 3, &LEDMatrix::matrixTaskHandle);
// Clear the matrix initially
LEDMatrix::clear();
initialized = true;
}
bool LEDMatrix::setPixelValue(unsigned int colum, unsigned int row, bool value)
{
bool returnValue = true;
// unsigned int rowC = 0;
// unsigned int colC = 0;
unsigned int pixelAddress = 0;
if ((row < parameters.height) && (colum < parameters.width))
{
returnValue = true;
}
else
{
returnValue = false;
}
if (returnValue)
{
// // Determine the actual row coordinate based on the matrix orientation
// if (parameters.columOrientation == LEDMATRIX_ORIENTATION_COLUM_UP_DOWN)
// {
// rowC = row;
// }
// else if (parameters.columOrientation == LEDMATRIX_ORIENTATION_COLUM_DOWN_UP)
// {
// rowC = (parameters.height - 1) - row;
// }
//
// // Determine the actual row coordinate based on the matrix orientation
// if (parameters.rowOrientation == LEDMATRIX_ORIENTATION_ROW_LEFT_RIGHT)
// {
// colC = colum;
// }
// else if (parameters.rowOrientation == LEDMATRIX_ORIENTATION_ROW_RIGHT_LEFT)
// {
// colC = (parameters.width - 1) - colum;
// }
//
// // Calculate the pixel address in the pixel array based on the previous information
// if (parameters.matrixOrientation == LEDMATRIX_ORIENTATION_COLUM)
// {
// pixelAddress = rowC + (colC * parameters.height);
// }
// else if (parameters.matrixOrientation == LEDMATRIX_ORIENTATION_ROW)
// {
// pixelAddress = (rowC * parameters.width) + colC;
// }
pixelAddress = LEDMatrix::findPixelIndexFromCoordinates(colum, row);
// Update the pixel value
matrix[pixelAddress].on = value;
}
return returnValue;
}
void LEDMatrix::setGlobalColour(uint8_t red, uint8_t green, uint8_t blue)
{
for (int i = 0; i < numberOfPixels; i++)
{
matrix[i].red = red;
matrix[i].green = green;
matrix[i].blue = blue;
}
}
void LEDMatrix::setPixelColour(unsigned int colum, unsigned int row, uint8_t red, uint8_t green, uint8_t blue)
{
unsigned int index;
index = LEDMatrix::findPixelIndexFromCoordinates(colum, row);
matrix[index].red = red;
matrix[index].green = green;
matrix[index].blue = blue;
}
void LEDMatrix::clear(void)
{
for (int i = 0; i < numberOfPixels; i++)
{
matrix[i].on = false;
}
}
unsigned int LEDMatrix::findPixelIndexFromCoordinates(unsigned int colum, unsigned int row)
{
bool returnValue = true;
unsigned int index = 0;
unsigned int rowC = 0;
unsigned int colC = 0;
if ((row < parameters.height) && (colum < parameters.width))
{
returnValue = true;
}
else
{
returnValue = false;
}
if (returnValue)
{
// Determine the actual row coordinate based on the matrix orientation
if (parameters.columOrientation == LEDMATRIX_ORIENTATION_COLUM_UP_DOWN)
{
rowC = row;
}
else if (parameters.columOrientation == LEDMATRIX_ORIENTATION_COLUM_DOWN_UP)
{
rowC = (parameters.height - 1) - row;
}
// Determine the actual row coordinate based on the matrix orientation
if (parameters.rowOrientation == LEDMATRIX_ORIENTATION_ROW_LEFT_RIGHT)
{
colC = colum;
}
else if (parameters.rowOrientation == LEDMATRIX_ORIENTATION_ROW_RIGHT_LEFT)
{
colC = (parameters.width - 1) - colum;
}
// Calculate the pixel address in the pixel array based on the previous information
if (parameters.matrixOrientation == LEDMATRIX_ORIENTATION_COLUM)
{
index = rowC + (colC * parameters.height);
}
else if (parameters.matrixOrientation == LEDMATRIX_ORIENTATION_ROW)
{
index = (rowC * parameters.width) + colC;
}
}
return index;
}
void LEDMatrix::matrixTask(void* parameters)
{
LEDMatrix* ledmatrix = (LEDMatrix*)parameters;
uint8_t matrix[ledmatrix->numberOfPixels * 3];
memset(&matrix, 0, sizeof(matrix));
while(1)
{
xSemaphoreTake(ledmatrix->taskSemaphore, portMAX_DELAY);
for (int i = 0; i < ledmatrix->numberOfPixels; i++)
{
if (ledmatrix->matrix[i].on)
{
matrix[i * 3 + LEDMATRIX_RED_INDEX] = ledmatrix->matrix[i].red;
matrix[i * 3 + LEDMATRIX_GREEN_INDEX] = ledmatrix->matrix[i].green;
matrix[i * 3 + LEDMATRIX_BLUE_INDEX] = ledmatrix->matrix[i].blue;
}
else
{
matrix[i * 3 + 0] = 0;
matrix[i * 3 + 1] = 0;
matrix[i * 3 + 2] = 0;
}
}
rmt_transmit(*ledmatrix->parameters.rmtChannel, *ledmatrix->parameters.rmtEncoder, matrix, sizeof(matrix), ledmatrix->parameters.rmtConfig);
}
}
-254
View File
@@ -1,254 +0,0 @@
// --------------------------------------------------------------------------------------------------------------------
/// \file logger.cpp
/// \brief Description
// --------------------------------------------------------------------------------------------------------------------
//
// vbchaos software design
//
// --------------------------------------------------------------------------------------------------------------------
/// $Revision: $
/// $Author: $
/// $Date: $
// (c) 2023 vbchaos
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Include files
// --------------------------------------------------------------------------------------------------------------------
#include <string.h>
#include <stdarg.h>
#include "logger.h"
// --------------------------------------------------------------------------------------------------------------------
// Constant and macro definitions
// --------------------------------------------------------------------------------------------------------------------
#define ENABLE_SERIAL_LOGGING
//#undef ENABLE_SERIAL_LOGGING
// --------------------------------------------------------------------------------------------------------------------
// Type definitions
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// File-scope variables
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Function declarations
// --------------------------------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------------------------------
// Function definitions
// --------------------------------------------------------------------------------------------------------------------
TaskHandle_t Logger::logTaskHandle = NULL;
uart_port_t Logger::uartPort = 0;
QueueHandle_t Logger::logQueue = NULL;
int Logger::queuesize = 0;
Logger::Logger(int queuesize, uart_port_t uartPort)
{
Logger::uartPort = uartPort;
Logger::queuesize = queuesize;
logQueue = xQueueCreate(queuesize, sizeof(struct LogQueueItem));
xTaskCreate(loggerTask, (const char*)"loggerTask", 3072, NULL, 3, &logTaskHandle);
}
void Logger::Logger_log(const char* fileName, const char* functionName, int lineNumber, LogType logType, const char* format, ...)
{
#if defined(ENABLE_SERIAL_LOGGING)
static int nrLostMessages = 0;
static bool overflowRecovery = false;
int nrOfMessages;
struct LogQueueItem logQueueItem;
va_list ap;
nrOfMessages = uxQueueMessagesWaiting(Logger::logQueue);
if((nrOfMessages == queuesize - 1) && !overflowRecovery)
{
// Queue almost full, only one entry left. Log a warning instead
composeLogQueueItem(&logQueueItem, __FILE__, __func__, __LINE__, LOGTYPE_WARNING, "Log queue overflow");
(void)xQueueSend(logQueue, &logQueueItem, 0);
overflowRecovery = true;
nrLostMessages = 1;
}
else if((nrOfMessages == 0) && overflowRecovery)
{
// Queue empty again after an overflow
char str[128];
snprintf(str, sizeof(str) / sizeof(str[0]), "%d messages lost", nrLostMessages);
composeLogQueueItem(&logQueueItem, __FILE__, __func__, __LINE__, LOGTYPE_WARNING, str);
(void)xQueueSend(logQueue, &logQueueItem, 0);
overflowRecovery = false;
}
else if(!overflowRecovery)
{
// Normal behaviour, queue not full
char str[128];
va_start(ap, format);
vsnprintf(str, sizeof(str) / sizeof(str[0]), format, ap);
va_end(ap);
composeLogQueueItem(&logQueueItem, fileName, functionName, lineNumber, logType, str);
(void)xQueueSend(logQueue, &logQueueItem, 0);
}
else
{
// Count number of lost messages
++nrLostMessages;
}
#endif
}
void Logger_logISR(struct Logger* self, const char* fileName, const char* functionName, int lineNumber, LogType logType, const char* context)
{
#if defined(ENABLE_LOGGING)
if (self->initialized)
{
struct LogQueueItem logQueueItem;
portBASE_TYPE higherPriorityTaskWoken = pdFALSE;
composeLogQueueItem(&logQueueItem, fileName, functionName, lineNumber, logType, context);
if(xQueueSendFromISR(self->logQueue, &logQueueItem, &higherPriorityTaskWoken) != pdTRUE)
{
// Queue failed
}
portEND_SWITCHING_ISR(higherPriorityTaskWoken);
}
#endif
}
#if defined(ENABLE_SERIAL_LOGGING)
void Logger::composeLogQueueItem(struct LogQueueItem* logQueueItem, const char* fileName, const char* functionName,
int lineNumber, LogType logType, const char* context)
{
const size_t fileNameSize = sizeof(logQueueItem->fileName) / sizeof(logQueueItem->fileName[0]);
const size_t functionNameSize = sizeof(logQueueItem->functionName) / sizeof(logQueueItem->functionName[0]);
const size_t contextSize = sizeof(logQueueItem->context) / sizeof(logQueueItem->context[0]);
logQueueItem->logType = logType;
strncpy(&(logQueueItem->context[0]), context, contextSize);
logQueueItem->context[contextSize - 1] = '\0';
if(logType != LOGTYPE_PRINT)
{
int fileNameIndex = 0;
// If filename starts with "src/", strip this part
if((fileName[0] == 's') &&
(fileName[1] == 'r') &&
(fileName[2] == 'c') &&
(fileName[3] == '/'))
{
fileNameIndex = 4;
}
// It is known that the strncpy use can potentially truncate the source string, meaning
// that the target string size is smaller then the original string
// This is not a problem in this particular case, so the compiler warning is disabled
// for this situation
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstringop-truncation"
// All logtypes except LOGTYPE_PRINT need filename, functionname and linenumber.
strncpy(&(logQueueItem->fileName[0]), &fileName[fileNameIndex], fileNameSize);
strncpy(&(logQueueItem->functionName[0]), functionName, functionNameSize);
#pragma GCC diagnostic pop
logQueueItem->lineNumber = lineNumber;
// Fix terminating null byte in strncpy in case string to be copied is too long
logQueueItem->fileName[fileNameSize - 1] = '\0';
logQueueItem->functionName[functionNameSize - 1] = '\0';
}
}
#endif
void Logger::loggerTask(void* parameters)
{
while(true)
{
struct LogQueueItem logQueueItem;
xQueueReceive(logQueue, &logQueueItem, portMAX_DELAY);
if(logQueueItem.logType == LOGTYPE_PRINT)
{
// Raw print
#if defined(ENABLE_SERIAL_LOGGING)
uart_write_bytes(uartPort, logQueueItem.context, strlen(logQueueItem.context));
#endif
}
else
{
#if defined(ENABLE_SERIAL_LOGGING)
char str[256];
char* vt100Prefix = "";
const char* vt100Postfix = "\033[0m";
#endif
#if defined(ENABLE_SERIAL_LOGGING)
if(logQueueItem.logType == LOGTYPE_INFO)
{
vt100Prefix = "\033[33m";
}
else if(logQueueItem.logType == LOGTYPE_WARNING)
{
vt100Prefix = "\033[35m";
}
else if(logQueueItem.logType == LOGTYPE_ERROR)
{
vt100Prefix = "\033[31m";
}
else if(logQueueItem.logType == LOGTYPE_SUCCESS)
{
vt100Prefix = "\033[32m";
}
#endif
unsigned int seconds = 0;
#if defined(ENABLE_SERIAL_LOGGING)
// Formatted print
snprintf(str, sizeof(str) / sizeof(str[0]), "%s[%s] %09d %s, %s, %d: %s%s\n\r",
vt100Prefix,
(logQueueItem.logType == LOGTYPE_DEBUG) ? "DBG" :
(logQueueItem.logType == LOGTYPE_INFO) ? "INF" :
(logQueueItem.logType == LOGTYPE_SUCCESS) ? "SCS" :
(logQueueItem.logType == LOGTYPE_WARNING) ? "WRN" : "ERR",
seconds,
logQueueItem.fileName,
logQueueItem.functionName,
logQueueItem.lineNumber,
logQueueItem.context,
vt100Postfix);
#endif
#if defined(ENABLE_SERIAL_LOGGING)
uart_write_bytes(uartPort, str, strlen(str));
#endif
}
}
vTaskDelete(NULL);
}
+95 -42
View File
@@ -1,6 +1,6 @@
#
# Automatically generated file. DO NOT EDIT.
# Espressif IoT Development Framework (ESP-IDF) 5.1.0 Project Configuration
# Espressif IoT Development Framework (ESP-IDF) 5.1.3 Project Configuration
#
CONFIG_SOC_ADC_SUPPORTED=y
CONFIG_SOC_DEDICATED_GPIO_SUPPORTED=y
@@ -72,7 +72,7 @@ CONFIG_SOC_CPU_INTR_NUM=32
CONFIG_SOC_CPU_HAS_FLEXIBLE_INTC=y
CONFIG_SOC_CPU_BREAKPOINTS_NUM=8
CONFIG_SOC_CPU_WATCHPOINTS_NUM=8
CONFIG_SOC_CPU_WATCHPOINT_SIZE=0x80000000
CONFIG_SOC_CPU_WATCHPOINT_MAX_REGION_SIZE=0x80000000
CONFIG_SOC_DS_SIGNATURE_MAX_BIT_LEN=3072
CONFIG_SOC_DS_KEY_PARAM_MD_IV_LENGTH=16
CONFIG_SOC_DS_KEY_CHECK_MAX_WAIT_US=1100
@@ -92,6 +92,7 @@ CONFIG_SOC_DEDIC_GPIO_IN_CHANNELS_NUM=8
CONFIG_SOC_DEDIC_PERIPH_ALWAYS_ENABLE=y
CONFIG_SOC_I2C_NUM=1
CONFIG_SOC_I2C_FIFO_LEN=32
CONFIG_SOC_I2C_CMD_REG_NUM=8
CONFIG_SOC_I2C_SUPPORT_SLAVE=y
CONFIG_SOC_I2C_SUPPORT_HW_CLR_BUS=y
CONFIG_SOC_I2C_SUPPORT_XTAL=y
@@ -180,6 +181,7 @@ CONFIG_SOC_TIMER_GROUP_COUNTER_BIT_WIDTH=54
CONFIG_SOC_TIMER_GROUP_SUPPORT_XTAL=y
CONFIG_SOC_TIMER_GROUP_SUPPORT_APB=y
CONFIG_SOC_TIMER_GROUP_TOTAL_TIMERS=2
CONFIG_SOC_MWDT_SUPPORT_XTAL=y
CONFIG_SOC_TWAI_CONTROLLER_NUM=1
CONFIG_SOC_TWAI_CLK_SUPPORT_APB=y
CONFIG_SOC_TWAI_BRP_MIN=2
@@ -242,6 +244,7 @@ CONFIG_SOC_BLE_MESH_SUPPORTED=y
CONFIG_SOC_BLE_50_SUPPORTED=y
CONFIG_SOC_BLE_DEVICE_PRIVACY_SUPPORTED=y
CONFIG_SOC_BLUFI_SUPPORTED=y
CONFIG_SOC_PHY_COMBO_MODULE=y
CONFIG_IDF_CMAKE=y
CONFIG_IDF_TARGET_ARCH_RISCV=y
CONFIG_IDF_TARGET_ARCH="riscv"
@@ -355,14 +358,14 @@ CONFIG_ESPTOOLPY_FLASHFREQ_80M=y
CONFIG_ESPTOOLPY_FLASHFREQ_80M_DEFAULT=y
CONFIG_ESPTOOLPY_FLASHFREQ="80m"
# CONFIG_ESPTOOLPY_FLASHSIZE_1MB is not set
CONFIG_ESPTOOLPY_FLASHSIZE_2MB=y
# CONFIG_ESPTOOLPY_FLASHSIZE_4MB is not set
# CONFIG_ESPTOOLPY_FLASHSIZE_2MB is not set
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
# CONFIG_ESPTOOLPY_FLASHSIZE_8MB is not set
# CONFIG_ESPTOOLPY_FLASHSIZE_16MB is not set
# CONFIG_ESPTOOLPY_FLASHSIZE_32MB is not set
# CONFIG_ESPTOOLPY_FLASHSIZE_64MB is not set
# CONFIG_ESPTOOLPY_FLASHSIZE_128MB is not set
CONFIG_ESPTOOLPY_FLASHSIZE="2MB"
CONFIG_ESPTOOLPY_FLASHSIZE="4MB"
# CONFIG_ESPTOOLPY_HEADER_FLASHSIZE_UPDATE is not set
CONFIG_ESPTOOLPY_BEFORE_RESET=y
# CONFIG_ESPTOOLPY_BEFORE_NORESET is not set
@@ -376,12 +379,12 @@ CONFIG_ESPTOOLPY_MONITOR_BAUD=115200
#
# Partition Table
#
CONFIG_PARTITION_TABLE_SINGLE_APP=y
# CONFIG_PARTITION_TABLE_SINGLE_APP is not set
# CONFIG_PARTITION_TABLE_SINGLE_APP_LARGE is not set
# CONFIG_PARTITION_TABLE_TWO_OTA is not set
CONFIG_PARTITION_TABLE_TWO_OTA=y
# CONFIG_PARTITION_TABLE_CUSTOM is not set
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv"
CONFIG_PARTITION_TABLE_FILENAME="partitions_singleapp.csv"
CONFIG_PARTITION_TABLE_FILENAME="partitions_two_ota.csv"
CONFIG_PARTITION_TABLE_OFFSET=0x8000
CONFIG_PARTITION_TABLE_MD5=y
# end of Partition Table
@@ -389,16 +392,16 @@ CONFIG_PARTITION_TABLE_MD5=y
#
# Example Configuration
#
CONFIG_ESP_WIFI_SSID="vbchaos"
CONFIG_ESP_WIFI_PASSWORD="mijninternet"
CONFIG_ESP_WIFI_SSID="myssid"
CONFIG_ESP_WIFI_PASSWORD="mypassword"
# end of Example Configuration
#
# Compiler options
#
# CONFIG_COMPILER_OPTIMIZATION_DEFAULT is not set
# CONFIG_COMPILER_OPTIMIZATION_SIZE is not set
CONFIG_COMPILER_OPTIMIZATION_PERF=y
CONFIG_COMPILER_OPTIMIZATION_SIZE=y
# CONFIG_COMPILER_OPTIMIZATION_PERF is not set
# CONFIG_COMPILER_OPTIMIZATION_NONE is not set
CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_ENABLE=y
# CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT is not set
@@ -503,6 +506,7 @@ CONFIG_TWAI_ERRATA_FIX_LISTEN_ONLY_DOM=y
#
# GPTimer Configuration
#
CONFIG_GPTIMER_ISR_HANDLER_IN_IRAM=y
# CONFIG_GPTIMER_CTRL_FUNC_IN_IRAM is not set
# CONFIG_GPTIMER_ISR_IRAM_SAFE is not set
# CONFIG_GPTIMER_SUPPRESS_DEPRECATE_WARN is not set
@@ -513,6 +517,7 @@ CONFIG_TWAI_ERRATA_FIX_LISTEN_ONLY_DOM=y
# RMT Configuration
#
# CONFIG_RMT_ISR_IRAM_SAFE is not set
# CONFIG_RMT_RECV_FUNC_IN_IRAM is not set
# CONFIG_RMT_SUPPRESS_DEPRECATE_WARN is not set
# CONFIG_RMT_ENABLE_DEBUG_LOG is not set
# end of RMT Configuration
@@ -641,14 +646,15 @@ CONFIG_HTTPD_PURGE_BUF_LEN=32
# CONFIG_ESP32C3_REV_MIN_2 is not set
CONFIG_ESP32C3_REV_MIN_3=y
# CONFIG_ESP32C3_REV_MIN_4 is not set
# CONFIG_ESP32C3_REV_MIN_101 is not set
CONFIG_ESP32C3_REV_MIN_FULL=3
CONFIG_ESP_REV_MIN_FULL=3
#
# Maximum Supported ESP32-C3 Revision (Rev v0.99)
# Maximum Supported ESP32-C3 Revision (Rev v1.99)
#
CONFIG_ESP32C3_REV_MAX_FULL=99
CONFIG_ESP_REV_MAX_FULL=99
CONFIG_ESP32C3_REV_MAX_FULL=199
CONFIG_ESP_REV_MAX_FULL=199
# end of Chip revision
#
@@ -662,15 +668,18 @@ CONFIG_ESP_MAC_UNIVERSAL_MAC_ADDRESSES_FOUR=y
# CONFIG_ESP32C3_UNIVERSAL_MAC_ADDRESSES_TWO is not set
CONFIG_ESP32C3_UNIVERSAL_MAC_ADDRESSES_FOUR=y
CONFIG_ESP32C3_UNIVERSAL_MAC_ADDRESSES=4
# CONFIG_ESP_MAC_USE_CUSTOM_MAC_AS_BASE_MAC is not set
# end of MAC Config
#
# Sleep Config
#
# CONFIG_ESP_SLEEP_POWER_DOWN_FLASH is not set
CONFIG_ESP_SLEEP_GPIO_RESET_WORKAROUND=y
CONFIG_ESP_SLEEP_FLASH_LEAKAGE_WORKAROUND=y
# CONFIG_ESP_SLEEP_MSPI_NEED_ALL_IO_PU is not set
CONFIG_ESP_SLEEP_GPIO_RESET_WORKAROUND=y
CONFIG_ESP_SLEEP_WAIT_FLASH_READY_EXTRA_DELAY=0
CONFIG_ESP_SLEEP_GPIO_ENABLE_INTERNAL_RESISTORS=y
# end of Sleep Config
CONFIG_ESP_SLEEP_SYSTIMER_STALL_WORKAROUND=y
@@ -729,6 +738,7 @@ CONFIG_ESP_NETIF_IP_LOST_TIMER_INTERVAL=120
CONFIG_ESP_NETIF_TCPIP_LWIP=y
# CONFIG_ESP_NETIF_LOOPBACK is not set
CONFIG_ESP_NETIF_USES_TCPIP_WITH_BSD_API=y
# CONFIG_ESP_NETIF_RECEIVE_REPORT_ERRORS is not set
# CONFIG_ESP_NETIF_L2_TAP is not set
# CONFIG_ESP_NETIF_BRIDGE_EN is not set
# end of ESP NETIF Adapter
@@ -745,7 +755,8 @@ CONFIG_ESP_PHY_CALIBRATION_AND_DATA_STORAGE=y
# CONFIG_ESP_PHY_INIT_DATA_IN_PARTITION is not set
CONFIG_ESP_PHY_MAX_WIFI_TX_POWER=20
CONFIG_ESP_PHY_MAX_TX_POWER=20
CONFIG_ESP_PHY_REDUCE_TX_POWER=y
# CONFIG_ESP_PHY_REDUCE_TX_POWER is not set
CONFIG_ESP_PHY_ENABLE_USB=y
# CONFIG_ESP_PHY_ENABLE_CERT_TEST is not set
CONFIG_ESP_PHY_RF_CAL_PARTIAL=y
# CONFIG_ESP_PHY_RF_CAL_NONE is not set
@@ -776,11 +787,12 @@ CONFIG_PM_POWER_DOWN_CPU_IN_LIGHT_SLEEP=y
# CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_80 is not set
CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_160=y
CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ=160
CONFIG_ESP_SYSTEM_PANIC_PRINT_HALT=y
# CONFIG_ESP_SYSTEM_PANIC_PRINT_REBOOT is not set
# CONFIG_ESP_SYSTEM_PANIC_PRINT_HALT is not set
CONFIG_ESP_SYSTEM_PANIC_PRINT_REBOOT=y
# CONFIG_ESP_SYSTEM_PANIC_SILENT_REBOOT is not set
# CONFIG_ESP_SYSTEM_PANIC_GDBSTUB is not set
# CONFIG_ESP_SYSTEM_GDBSTUB_RUNTIME is not set
CONFIG_ESP_SYSTEM_PANIC_REBOOT_DELAY_SECONDS=0
CONFIG_ESP_SYSTEM_SINGLE_CORE_MODE=y
CONFIG_ESP_SYSTEM_RTC_FAST_MEM_AS_HEAP_DEPCHECK=y
CONFIG_ESP_SYSTEM_ALLOW_RTC_FAST_MEM_AS_HEAP=y
@@ -800,13 +812,16 @@ CONFIG_ESP_MAIN_TASK_AFFINITY_CPU0=y
# CONFIG_ESP_MAIN_TASK_AFFINITY_NO_AFFINITY is not set
CONFIG_ESP_MAIN_TASK_AFFINITY=0x0
CONFIG_ESP_MINIMAL_SHARED_STACK_SIZE=2048
# CONFIG_ESP_CONSOLE_UART_DEFAULT is not set
CONFIG_ESP_CONSOLE_UART_DEFAULT=y
# CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG is not set
# CONFIG_ESP_CONSOLE_UART_CUSTOM is not set
CONFIG_ESP_CONSOLE_NONE=y
CONFIG_ESP_CONSOLE_SECONDARY_NONE=y
# CONFIG_ESP_CONSOLE_SECONDARY_USB_SERIAL_JTAG is not set
# CONFIG_ESP_CONSOLE_NONE is not set
# CONFIG_ESP_CONSOLE_SECONDARY_NONE is not set
CONFIG_ESP_CONSOLE_SECONDARY_USB_SERIAL_JTAG=y
CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG_ENABLED=y
CONFIG_ESP_CONSOLE_UART=y
CONFIG_ESP_CONSOLE_UART_NUM=0
CONFIG_ESP_CONSOLE_UART_BAUDRATE=115200
CONFIG_ESP_INT_WDT=y
CONFIG_ESP_INT_WDT_TIMEOUT_MS=300
CONFIG_ESP_TASK_WDT_EN=y
@@ -868,6 +883,10 @@ CONFIG_ESP_WIFI_DYNAMIC_RX_BUFFER_NUM=32
CONFIG_ESP_WIFI_DYNAMIC_TX_BUFFER=y
CONFIG_ESP_WIFI_TX_BUFFER_TYPE=1
CONFIG_ESP_WIFI_DYNAMIC_TX_BUFFER_NUM=32
CONFIG_ESP_WIFI_STATIC_RX_MGMT_BUFFER=y
# CONFIG_ESP_WIFI_DYNAMIC_RX_MGMT_BUFFER is not set
CONFIG_ESP_WIFI_DYNAMIC_RX_MGMT_BUF=0
CONFIG_ESP_WIFI_RX_MGMT_BUF_NUM_DEF=5
# CONFIG_ESP_WIFI_CSI_ENABLED is not set
CONFIG_ESP_WIFI_AMPDU_TX_ENABLED=y
CONFIG_ESP_WIFI_TX_BA_WIN=6
@@ -877,6 +896,7 @@ CONFIG_ESP_WIFI_NVS_ENABLED=y
CONFIG_ESP_WIFI_SOFTAP_BEACON_MAX_LEN=752
CONFIG_ESP_WIFI_MGMT_SBUF_NUM=32
CONFIG_ESP_WIFI_IRAM_OPT=y
# CONFIG_ESP_WIFI_EXTRA_IRAM_OPT is not set
CONFIG_ESP_WIFI_RX_IRAM_OPT=y
CONFIG_ESP_WIFI_ENABLE_WPA3_SAE=y
CONFIG_ESP_WIFI_ENABLE_SAE_PK=y
@@ -909,6 +929,7 @@ CONFIG_ESP_WIFI_MBEDTLS_TLS_CLIENT=y
# CONFIG_ESP_WIFI_DEBUG_PRINT is not set
# CONFIG_ESP_WIFI_TESTING_OPTIONS is not set
CONFIG_ESP_WIFI_ENTERPRISE_SUPPORT=y
# end of Wi-Fi
#
@@ -967,7 +988,7 @@ CONFIG_FATFS_VFS_FSTAT_BLKSIZE=0
#
# CONFIG_FREERTOS_SMP is not set
CONFIG_FREERTOS_UNICORE=y
CONFIG_FREERTOS_HZ=1000
CONFIG_FREERTOS_HZ=100
CONFIG_FREERTOS_OPTIMIZED_SCHEDULER=y
# CONFIG_FREERTOS_CHECK_STACKOVERFLOW_NONE is not set
# CONFIG_FREERTOS_CHECK_STACKOVERFLOW_PTRVAL is not set
@@ -1037,9 +1058,6 @@ CONFIG_HEAP_TRACING_OFF=y
# CONFIG_HEAP_PLACE_FUNCTION_INTO_FLASH is not set
# end of Heap memory debugging
CONFIG_IEEE802154_CCA_THRESHOLD=-60
CONFIG_IEEE802154_PENDING_TABLE_SIZE=20
#
# Log output
#
@@ -1062,14 +1080,18 @@ CONFIG_LOG_TIMESTAMP_SOURCE_RTOS=y
#
# LWIP
#
CONFIG_LWIP_LOCAL_HOSTNAME="wordclock"
CONFIG_LWIP_LOCAL_HOSTNAME="espressif"
# CONFIG_LWIP_NETIF_API is not set
CONFIG_LWIP_TCPIP_TASK_PRIO=18
# CONFIG_LWIP_TCPIP_CORE_LOCKING is not set
# CONFIG_LWIP_CHECK_THREAD_SAFETY is not set
CONFIG_LWIP_DNS_SUPPORT_MDNS_QUERIES=y
# CONFIG_LWIP_L2_TO_L3_COPY is not set
CONFIG_LWIP_IRAM_OPTIMIZATION=y
# CONFIG_LWIP_IRAM_OPTIMIZATION is not set
# CONFIG_LWIP_EXTRA_IRAM_OPTIMIZATION is not set
CONFIG_LWIP_TIMERS_ONDEMAND=y
CONFIG_LWIP_ND6=y
# CONFIG_LWIP_FORCE_ROUTER_FORWARDING is not set
CONFIG_LWIP_MAX_SOCKETS=10
# CONFIG_LWIP_USE_ONLY_LWIP_SELECT is not set
# CONFIG_LWIP_SO_LINGER is not set
@@ -1077,6 +1099,7 @@ CONFIG_LWIP_SO_REUSE=y
CONFIG_LWIP_SO_REUSE_RXTOALL=y
# CONFIG_LWIP_SO_RCVBUF is not set
# CONFIG_LWIP_NETBUF_RECVINFO is not set
CONFIG_LWIP_IP_DEFAULT_TTL=64
CONFIG_LWIP_IP4_FRAG=y
CONFIG_LWIP_IP6_FRAG=y
# CONFIG_LWIP_IP4_REASSEMBLY is not set
@@ -1127,10 +1150,12 @@ CONFIG_LWIP_TCP_MSS=1440
CONFIG_LWIP_TCP_TMR_INTERVAL=250
CONFIG_LWIP_TCP_MSL=60000
CONFIG_LWIP_TCP_FIN_WAIT_TIMEOUT=20000
CONFIG_LWIP_TCP_SND_BUF_DEFAULT=5744
CONFIG_LWIP_TCP_WND_DEFAULT=5744
CONFIG_LWIP_TCP_SND_BUF_DEFAULT=5760
CONFIG_LWIP_TCP_WND_DEFAULT=5760
CONFIG_LWIP_TCP_RECVMBOX_SIZE=6
CONFIG_LWIP_TCP_QUEUE_OOSEQ=y
CONFIG_LWIP_TCP_OOSEQ_TIMEOUT=6
CONFIG_LWIP_TCP_OOSEQ_MAX_PBUFS=4
# CONFIG_LWIP_TCP_SACK_OUT is not set
CONFIG_LWIP_TCP_OVERSIZE_MSS=y
# CONFIG_LWIP_TCP_OVERSIZE_QUARTER_MSS is not set
@@ -1199,6 +1224,9 @@ CONFIG_LWIP_HOOK_IP6_ROUTE_NONE=y
CONFIG_LWIP_HOOK_ND6_GET_GW_NONE=y
# CONFIG_LWIP_HOOK_ND6_GET_GW_DEFAULT is not set
# CONFIG_LWIP_HOOK_ND6_GET_GW_CUSTOM is not set
CONFIG_LWIP_HOOK_IP6_SELECT_SRC_ADDR_NONE=y
# CONFIG_LWIP_HOOK_IP6_SELECT_SRC_ADDR_DEFAULT is not set
# CONFIG_LWIP_HOOK_IP6_SELECT_SRC_ADDR_CUSTOM is not set
CONFIG_LWIP_HOOK_NETCONN_EXT_RESOLVE_NONE=y
# CONFIG_LWIP_HOOK_NETCONN_EXT_RESOLVE_DEFAULT is not set
# CONFIG_LWIP_HOOK_NETCONN_EXT_RESOLVE_CUSTOM is not set
@@ -1245,7 +1273,7 @@ CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_MAX_CERTS=200
# end of Certificate Bundle
# CONFIG_MBEDTLS_ECP_RESTARTABLE is not set
# CONFIG_MBEDTLS_CMAC_C is not set
CONFIG_MBEDTLS_CMAC_C=y
CONFIG_MBEDTLS_HARDWARE_AES=y
CONFIG_MBEDTLS_AES_USE_INTERRUPT=y
CONFIG_MBEDTLS_HARDWARE_MPI=y
@@ -1329,12 +1357,12 @@ CONFIG_MBEDTLS_ECP_DP_BP384R1_ENABLED=y
CONFIG_MBEDTLS_ECP_DP_BP512R1_ENABLED=y
CONFIG_MBEDTLS_ECP_DP_CURVE25519_ENABLED=y
CONFIG_MBEDTLS_ECP_NIST_OPTIM=y
CONFIG_MBEDTLS_ECP_FIXED_POINT_OPTIM=y
# CONFIG_MBEDTLS_POLY1305_C is not set
# CONFIG_MBEDTLS_CHACHA20_C is not set
# CONFIG_MBEDTLS_HKDF_C is not set
# CONFIG_MBEDTLS_THREADING_C is not set
CONFIG_MBEDTLS_LARGE_KEY_SOFTWARE_MPI=y
# CONFIG_MBEDTLS_SECURITY_RISKS is not set
# end of mbedTLS
#
@@ -1379,6 +1407,27 @@ CONFIG_NEWLIB_TIME_SYSCALL_USE_RTC_HRT=y
# OpenThread
#
# CONFIG_OPENTHREAD_ENABLED is not set
#
# Thread Operational Dataset
#
CONFIG_OPENTHREAD_NETWORK_NAME="OpenThread-ESP"
CONFIG_OPENTHREAD_MESH_LOCAL_PREFIX="fd00:db8:a0:0::/64"
CONFIG_OPENTHREAD_NETWORK_CHANNEL=15
CONFIG_OPENTHREAD_NETWORK_PANID=0x1234
CONFIG_OPENTHREAD_NETWORK_EXTPANID="dead00beef00cafe"
CONFIG_OPENTHREAD_NETWORK_MASTERKEY="00112233445566778899aabbccddeeff"
CONFIG_OPENTHREAD_NETWORK_PSKC="104810e2315100afd6bc9215a6bfac53"
# end of Thread Operational Dataset
CONFIG_OPENTHREAD_XTAL_ACCURACY=130
# CONFIG_OPENTHREAD_SPINEL_ONLY is not set
CONFIG_OPENTHREAD_RX_ON_WHEN_IDLE=y
#
# Thread Address Query Config
#
# end of Thread Address Query Config
# end of OpenThread
#
@@ -1528,7 +1577,9 @@ CONFIG_VFS_SUPPORT_IO=y
CONFIG_VFS_SUPPORT_DIR=y
CONFIG_VFS_SUPPORT_SELECT=y
CONFIG_VFS_SUPPRESS_SELECT_DEBUG_OUTPUT=y
# CONFIG_VFS_SELECT_IN_RAM is not set
CONFIG_VFS_SUPPORT_TERMIOS=y
CONFIG_VFS_MAX_COUNT=8
#
# Host File System I/O (Semihosting)
@@ -1577,8 +1628,8 @@ CONFIG_FLASHMODE_DIO=y
CONFIG_MONITOR_BAUD=115200
# CONFIG_OPTIMIZATION_LEVEL_DEBUG is not set
# CONFIG_COMPILER_OPTIMIZATION_LEVEL_DEBUG is not set
# CONFIG_OPTIMIZATION_LEVEL_RELEASE is not set
# CONFIG_COMPILER_OPTIMIZATION_LEVEL_RELEASE is not set
CONFIG_OPTIMIZATION_LEVEL_RELEASE=y
CONFIG_COMPILER_OPTIMIZATION_LEVEL_RELEASE=y
CONFIG_OPTIMIZATION_ASSERTIONS_ENABLED=y
# CONFIG_OPTIMIZATION_ASSERTIONS_SILENT is not set
# CONFIG_OPTIMIZATION_ASSERTIONS_DISABLED is not set
@@ -1609,8 +1660,8 @@ CONFIG_ESP32_PHY_CALIBRATION_AND_DATA_STORAGE=y
# CONFIG_ESP32_PHY_INIT_DATA_IN_PARTITION is not set
CONFIG_ESP32_PHY_MAX_WIFI_TX_POWER=20
CONFIG_ESP32_PHY_MAX_TX_POWER=20
CONFIG_REDUCE_PHY_TX_POWER=y
CONFIG_ESP32_REDUCE_PHY_TX_POWER=y
# CONFIG_REDUCE_PHY_TX_POWER is not set
# CONFIG_ESP32_REDUCE_PHY_TX_POWER is not set
CONFIG_ESP_SYSTEM_PM_POWER_DOWN_CPU=y
# CONFIG_ESP32C3_DEFAULT_CPU_FREQ_80 is not set
CONFIG_ESP32C3_DEFAULT_CPU_FREQ_160=y
@@ -1620,11 +1671,13 @@ CONFIG_ESP32C3_MEMPROT_FEATURE_LOCK=y
CONFIG_SYSTEM_EVENT_QUEUE_SIZE=32
CONFIG_SYSTEM_EVENT_TASK_STACK_SIZE=2304
CONFIG_MAIN_TASK_STACK_SIZE=3584
# CONFIG_CONSOLE_UART_DEFAULT is not set
CONFIG_CONSOLE_UART_DEFAULT=y
# CONFIG_CONSOLE_UART_CUSTOM is not set
CONFIG_CONSOLE_UART_NONE=y
CONFIG_ESP_CONSOLE_UART_NONE=y
# CONFIG_CONSOLE_UART_NONE is not set
# CONFIG_ESP_CONSOLE_UART_NONE is not set
CONFIG_CONSOLE_UART=y
CONFIG_CONSOLE_UART_NUM=0
CONFIG_CONSOLE_UART_BAUDRATE=115200
CONFIG_INT_WDT=y
CONFIG_INT_WDT_TIMEOUT_MS=300
CONFIG_TASK_WDT=y
@@ -1702,8 +1755,8 @@ CONFIG_TCP_MAXRTX=12
CONFIG_TCP_SYNMAXRTX=12
CONFIG_TCP_MSS=1440
CONFIG_TCP_MSL=60000
CONFIG_TCP_SND_BUF_DEFAULT=5744
CONFIG_TCP_WND_DEFAULT=5744
CONFIG_TCP_SND_BUF_DEFAULT=5760
CONFIG_TCP_WND_DEFAULT=5760
CONFIG_TCP_RECVMBOX_SIZE=6
CONFIG_TCP_QUEUE_OOSEQ=y
CONFIG_TCP_OVERSIZE_MSS=y
+5
View File
@@ -0,0 +1,5 @@
# This file was generated using idf.py save-defconfig. It can be edited manually.
# Espressif IoT Development Framework (ESP-IDF) Project Minimal Configuration
#
CONFIG_IDF_TARGET="esp32c3"
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
-1629
View File
File diff suppressed because it is too large Load Diff
BIN
View File
Binary file not shown.
Binary file not shown.