Fixed formatting

This commit is contained in:
Emanuele Trabattoni
2025-06-22 12:35:19 +02:00
parent adb15962c6
commit b5de72a6d1
4 changed files with 217 additions and 223 deletions

View File

@@ -6,9 +6,11 @@
#define I2C_SCL_PIN 41
#define I2C_SDA_PIN 42
namespace drivers {
namespace drivers
{
class I2C {
class I2C
{
private:
bool isInitialized = false;
std::mutex busy;
@@ -19,7 +21,6 @@ namespace drivers {
const bool Read(const uint8_t deviceAddr, const uint8_t deviceReg, const uint8_t len, std::vector<uint8_t> &data);
const bool Write(const uint8_t deviceAddr, const uint8_t deviceReg, const std::vector<uint8_t> &data);
};
}

View File

@@ -5,9 +5,10 @@ datetime_t Update_datetime= {0};
static uint8_t decToBcd(int val);
static int bcdToDec(uint8_t val);
void Time_printf(void *parameter) {
while(1){
void Time_printf(void *parameter)
{
while (1)
{
char datetime_str[50];
datetime_to_str(datetime_str, datetime);
printf("Time:%s\r\n", datetime_str);
@@ -42,8 +43,7 @@ void PCF85063_Init(void) // PCF85063 initialized
NULL,
3,
NULL,
0
);
0);
// xTaskCreatePinnedToCore(
// Time_printf,
// "Time_printf",
@@ -55,8 +55,10 @@ void PCF85063_Init(void) // PCF85063 initialized
// );
}
void PCF85063Task(void *parameter) {
while(1){
void PCF85063Task(void *parameter)
{
while (1)
{
PCF85063_Read_Time(&datetime);
vTaskDelay(pdMS_TO_TICKS(100));
}
@@ -110,7 +112,8 @@ void PCF85063_Read_Time(datetime_t *time) // Read Time And Date
esp_err_t ret = I2C_Read(PCF85063_ADDRESS, RTC_SECOND_ADDR, buf, sizeof(buf));
if (ret != ESP_OK)
printf("PCF85063 : Time read failure\r\n");
else{
else
{
time->second = bcdToDec(buf[0] & 0x7F);
time->minute = bcdToDec(buf[1] & 0x7F);
time->hour = bcdToDec(buf[2] & 0x3F);
@@ -165,7 +168,8 @@ void PCF85063_Read_Alarm(datetime_t *time) // Read Alarm
esp_err_t ret = I2C_Read(PCF85063_ADDRESS, RTC_SECOND_ALARM, buf, sizeof(buf));
if (ret != ESP_OK)
printf("PCF85063 : Failed to read the alarm sign\r\n");
else{
else
{
time->second = bcdToDec(buf[0] & 0x7F);
time->minute = bcdToDec(buf[1] & 0x7F);
time->hour = bcdToDec(buf[2] & 0x3F);

View File

@@ -4,7 +4,7 @@
// PCF85063_ADDRESS
#define PCF85063_ADDRESS (0x51)
//
#define YEAR_OFFSET (1970)
// registar overview - crtl & status reg
#define RTC_CTRL_1_ADDR (0x00)
@@ -59,7 +59,8 @@
#define RTC_TIMER_FLAG (0x08)
typedef struct {
typedef struct
{
uint16_t year;
uint8_t month;
uint8_t day;
@@ -69,9 +70,8 @@ typedef struct {
uint8_t second;
} datetime_t;
const unsigned char MonthStr[12][4] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
const unsigned char Week[7][5] = {"SUN","Mon","Tues","Wed","Thur","Fri","Sat"};
const unsigned char Week[7][4] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
extern datetime_t datetime;
void PCF85063_Init(void);
@@ -84,20 +84,9 @@ void PCF85063_Set_All(datetime_t time);
void PCF85063_Read_Time(datetime_t *time);
void PCF85063_Enable_Alarm(void);
uint8_t PCF85063_Get_Alarm_Flag();
uint8_t PCF85063_Get_Alarm_Flag(void);
void PCF85063_Set_Alarm(datetime_t time);
void PCF85063_Read_Alarm(datetime_t *time);
void datetime_to_str(char *datetime_str, datetime_t time);
// weekday format
// 0 - sunday
// 1 - monday
// 2 - tuesday
// 3 - wednesday
// 4 - thursday
// 5 - friday
// 6 - saturday