Compare commits

...

6 Commits

Author SHA1 Message Date
a41945bcef Merge branch 'fix/etat_machine_logs' 2026-02-26 07:54:12 +01:00
7316561482 1ere implem son fin machine 2026-02-26 07:44:35 +01:00
ae99b85932 compat linux 2026-02-24 17:06:30 +01:00
5ac20b78fa adjust dtHToString 2026-02-24 16:46:13 +01:00
fc5f46d3fd ajout heure meteo ecran home 2026-02-24 16:35:19 +01:00
f5419e85aa reactivation volets 2026-02-24 16:30:24 +01:00
89 changed files with 279 additions and 66 deletions

View File

@ -0,0 +1,3 @@
idf_component_register(SRCS "audio.c"
INCLUDE_DIRS "include"
REQUIRES esp32_p4_function_ev_board)

102
components/audio/audio.c Normal file
View File

@ -0,0 +1,102 @@
#include <stdio.h>
#include "audio.h"
#include <stdio.h>
#include <inttypes.h>
#include <sdkconfig.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/queue.h"
#include "esp_log.h"
#include "bsp/esp-bsp.h"
/* Buffer for reading/writing to I2S driver. Same length as SPIFFS buffer and I2S buffer, for optimal read/write performance.
Recording audio data path:
I2S peripheral -> I2S buffer (DMA) -> App buffer (RAM) -> SPIFFS buffer -> External SPI Flash.
Vice versa for playback. */
#define BUFFER_SIZE (1024)
#define SAMPLE_RATE (16000) // For recording
#define DEFAULT_VOLUME (25)
/* Globals */
static const char *TAG = "audio";
TaskHandle_t audio_task_handle;
// Very simple WAV header, ignores most fields
typedef struct __attribute__((packed))
{
uint8_t ignore_0[22];
uint16_t num_channels;
uint32_t sample_rate;
uint8_t ignore_1[6];
uint16_t bits_per_sample;
uint8_t ignore_2[4];
uint32_t data_size;
uint8_t data[];
} dumb_wav_header_t;
static void audio_task(void *arg)
{
esp_codec_dev_handle_t spk_codec_dev = bsp_audio_codec_speaker_init();
assert(spk_codec_dev);
esp_codec_dev_set_out_vol(spk_codec_dev, DEFAULT_VOLUME);
/* Pointer to a file that is going to be played */
const char music_filename[] = "/littlefs/sounds/imperial_march.wav";
const char *play_filename = music_filename;
while (1) {
ulTaskNotifyTake(pdTRUE, portMAX_DELAY);
int16_t *wav_bytes = malloc(BUFFER_SIZE);
assert(wav_bytes != NULL);
/* Open WAV file */
ESP_LOGI(TAG, "Playing file %s", play_filename);
FILE *play_file = fopen(play_filename, "rb");
if (play_file == NULL) {
ESP_LOGW(TAG, "%s file does not exist!", play_filename);
break;
}
/* Read WAV header file */
dumb_wav_header_t wav_header;
if (fread((void *)&wav_header, 1, sizeof(wav_header), play_file) != sizeof(wav_header)) {
ESP_LOGW(TAG, "Error in reading file");
break;
}
ESP_LOGI(TAG, "Number of channels: %" PRIu16 "", wav_header.num_channels);
ESP_LOGI(TAG, "Bits per sample: %" PRIu16 "", wav_header.bits_per_sample);
ESP_LOGI(TAG, "Sample rate: %" PRIu32 "", wav_header.sample_rate);
ESP_LOGI(TAG, "Data size: %" PRIu32 "", wav_header.data_size);
esp_codec_dev_sample_info_t fs = {
.sample_rate = wav_header.sample_rate,
.channel = wav_header.num_channels,
.bits_per_sample = wav_header.bits_per_sample,
};
esp_codec_dev_open(spk_codec_dev, &fs);
uint32_t bytes_send_to_i2s = 0;
while (bytes_send_to_i2s < wav_header.data_size) {
/* Get data from SPIFFS and send it to codec */
size_t bytes_read_from_spiffs = fread(wav_bytes, 1, BUFFER_SIZE, play_file);
esp_codec_dev_write(spk_codec_dev, wav_bytes, bytes_read_from_spiffs);
bytes_send_to_i2s += bytes_read_from_spiffs;
}
fclose(play_file);
free(wav_bytes);
esp_codec_dev_close(spk_codec_dev);
}
}
void playSound(void)
{
if(audio_task_handle==NULL){
BaseType_t ret = xTaskCreate(audio_task, "audio_task", 4096, NULL, 6, &audio_task_handle);
assert(ret == pdPASS);
}
xTaskNotifyGive(audio_task_handle);
}

View File

@ -0,0 +1,2 @@
void playSound(void);

Binary file not shown.

View File

@ -32,7 +32,6 @@ if(${IDF_TARGET} STREQUAL "esp32p4" OR ${IDF_TARGET} STREQUAL "esp32s3")
lvgl_port_create_c_image("images/mqtt_ok.png" "images/" "AUTO" "NONE")
lvgl_port_create_c_image("images/mqtt_ko.png" "images/" "ARGB8888" "NONE")
lvgl_port_add_images(${COMPONENT_LIB} "images/")
littlefs_create_partition_image(littlefs images_meteo FLASH_IN_PROJECT)
elseif(${IDF_TARGET} STREQUAL "linux")
idf_component_register(SRC_DIRS . fonts images
INCLUDE_DIRS "include"

View File

@ -39,7 +39,7 @@ lv_subject_t dateHeureSubj;
lv_obj_t *lblTempInt;
lv_obj_t *lblTempExt;
char tempExtStr[6];
char tempIntStr[6];
char tempIntStr[50];
char hauteurCuveStr[9];
char hauteurCuveEvolStr[9];
lv_subject_t tempIntSubj;
@ -112,14 +112,17 @@ void draw_time(struct tm *dateHeure){
void draw_tempExt(char * tempHumid){
//if(display_lock("draw_temp")){
lv_label_set_text_fmt(lblTempExt,LV_SYMBOL_HOME "\xEF\x8B\x8A : %.1f°C", atof(tempHumid));
//lv_label_set_text_fmt(lblTempExt,LV_SYMBOL_HOME "\xEF\x8B\x8A : %.1f°C", atof(tempHumid));
lv_subject_copy_string(&tempExtSubj,tempHumid);
// display_unlock("draw_temp");
//}
}
void draw_temp(char * tempHumid){
//if(display_lock("draw_temp")){
lv_label_set_text_fmt(lblTempInt, "\xEE\x86\xB0\xEF\x8B\x8A : %s", tempHumid);
ESP_LOGE(TAG, "draw_temp : %s", tempHumid);
lv_subject_copy_string(&tempIntSubj,tempHumid);
//lv_label_set_text_fmt(lblTempInt, "\xEE\x86\xB0\xEF\x8B\x8A : %s", tempHumid);
// display_unlock("draw_temp");
//}
@ -146,6 +149,7 @@ lv_obj_t* lblEtatMachine;
static lv_style_t style_lbvValue;
static lv_style_t style_btn;
/*
lv_theme_t *lv_theme_create(void)
{
lv_theme_t *theme = lv_zalloc(sizeof(*theme));
@ -162,6 +166,7 @@ void lv_theme_copy(lv_theme_t *dst, const lv_theme_t *src)
}
lv_memcpy(dst, src, sizeof(*src));
}
*/
static void create_ui(void*)
{
// Initialisation du thème
@ -574,10 +579,15 @@ static void weatherdataHeure_obs_cb(lv_observer_t *observer, lv_subject_t *subje
if(isMinimal){
lv_obj_t *parent = (lv_obj_t *)(lv_observer_get_target(observer));
//lv_obj_dump_tree(parent);
lv_obj_t *descfld = lv_obj_get_child(parent, 1);
showMeteoIcon(data->previsions.icon, parent, 0);
lv_obj_t *timefld = lv_obj_get_child(parent, 0);
char buffer[8];
dtHToString(data->datetime, buffer,8);
lv_label_set_text(timefld, buffer);
showMeteoIcon(data->previsions.icon, parent, 1);
lv_obj_t *descfld = lv_obj_get_child(parent, 2);
lv_label_set_text(descfld, data->previsions.desc);
lv_obj_t *valuefld = lv_obj_get_child(parent, 2);
lv_obj_t *valuefld = lv_obj_get_child(parent, 3);
lv_label_set_text_fmt(valuefld, "%.1f°C", data->previsions.value);
}else{
@ -587,8 +597,8 @@ static void weatherdataHeure_obs_cb(lv_observer_t *observer, lv_subject_t *subje
lv_obj_t *temp_desc_icon = lv_obj_get_child(parent, 1);
showMeteoIcon(data->previsions.icon, temp_desc_icon, 1);
char buffer[80];
dtHToString(data->datetime, buffer);
char buffer[8];
dtHToString(data->datetime, buffer,8);
lv_label_set_text(datefld, buffer);
lv_label_set_text(lv_obj_get_child(temp_desc_icon, 2), data->previsions.desc);
@ -608,7 +618,7 @@ void showMeteoIcon(const char *icon, lv_obj_t *desc_icon, int childNr)
#if CONFIG_IDF_TARGET_LINUX
char *str1 = "A:/home/marc/esp/domotic/domotic/components/domotic_display/images_meteo/";
#else
char *str1 = "A:/littlefs/";
char *str1 = "A:/littlefs/images_meteo/";
#endif
int sizeOfStr;
sizeOfStr = strlen(str1) + strlen(icon) + 6;
@ -777,6 +787,11 @@ static lv_obj_t* weatherH_fragment_create_obj(int horaireNr, lv_obj_t *parent, b
lv_obj_set_size(container, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
lv_obj_add_flag(container, LV_OBJ_FLAG_EVENT_BUBBLE);
lv_obj_t *heure = lv_label_create(container);
lv_label_set_text(heure, "--");
lv_obj_add_style(heure, &tempStyle, 0);
lv_obj_set_style_text_font(heure,lv_theme_get_font_normal(heure),0);
lv_obj_t *img1 = lv_image_create(container);
lv_obj_set_name(img1, "meteo_img");
lv_obj_add_flag(img1, LV_OBJ_FLAG_EVENT_BUBBLE);
@ -800,7 +815,7 @@ static lv_obj_t* weatherH_fragment_create_obj(int horaireNr, lv_obj_t *parent, b
lv_obj_t *desc = lv_label_create(container);
lv_obj_set_name(desc, "meteo_desc");
lv_label_set_long_mode(desc, LV_LABEL_LONG_MODE_WRAP);
lv_obj_set_size(desc, 85, LV_SIZE_CONTENT);
lv_obj_set_size(desc, 130, LV_SIZE_CONTENT);
//lv_obj_set_style_text_color(desc, lv_color_white(), 0);
lv_label_set_text(desc, name);
lv_obj_set_style_text_align(desc, LV_TEXT_ALIGN_CENTER, 0);
@ -1278,6 +1293,15 @@ static inline void u8_to_2digits(char *buf, uint8_t v)
}
// Ce callback est appelé lorsque le pointeur "tempExt"/"tempInt" est modifié
static void temp_observer_cb(lv_observer_t *observer, lv_subject_t *subject){
lv_obj_t *tempObj = lv_observer_get_target_obj(observer);
char *templateValue = lv_observer_get_user_data(observer);
char *temp = lv_subject_get_string(subject);
//ESP_LOGE(TAG,"On passe dans temp_observer_cb pour %s avec %s - %s ",lv_obj_get_name(tempObj), templateValue, temp);
lv_label_set_text_fmt(tempObj,templateValue,temp);
}
static void time_observer_cb(lv_observer_t *observer, lv_subject_t *subject)
{
LV_UNUSED(observer);
@ -1749,7 +1773,7 @@ void messageCardContent(lv_obj_t *cont_messages)
lv_subject_init_string(&tempExtSubj, tempExtStr, NULL, 6, "--");
lv_subject_init_string(&tempIntSubj, tempIntStr, NULL, 6, "--");
lv_subject_init_string(&tempIntSubj, tempIntStr, NULL, 50, "--");
lv_subject_init_string(&hauteurCuveSubj, hauteurCuveStr, NULL, 9, "--");
lv_subject_init_string(&hauteurCuveEvolSubj, hauteurCuveEvolStr, NULL, 9, "--");
@ -1830,11 +1854,16 @@ void messageCardContent(lv_obj_t *cont_messages)
lv_obj_set_flex_flow(subContent, LV_FLEX_FLOW_COLUMN);
lv_obj_set_size(subContent, LV_PCT(70), LV_PCT(100));
lblTempInt = lv_label_create(subContent);
lv_label_set_text(lblTempInt, "\xEE\x86\xB0\xEF\x8B\x8A : --°C");
lv_obj_set_name(lblTempInt,"lblTempInt");
char *templateValue="\xEE\x86\xB0\xEF\x8B\x8A : %s";
lv_obj_set_style_text_font(lblTempInt, lv_theme_get_font_large(lblTempInt),0);
lv_subject_add_observer_obj(&tempIntSubj, temp_observer_cb, lblTempInt, templateValue);
lblTempExt = lv_label_create(subContent);
lv_label_set_text(lblTempExt, LV_SYMBOL_HOME "\xEF\x8B\x8A : --°C");
lv_obj_set_name(lblTempExt,"lblTempExt");
char *templateValue2=LV_SYMBOL_HOME "\xEF\x8B\x8A : %s°C";
lv_obj_set_style_text_font(lblTempExt, lv_theme_get_font_large(lblTempExt),0);
lv_subject_add_observer_obj(&tempExtSubj, temp_observer_cb, lblTempExt, templateValue2);
/*for (size_t i = 0; i < 2; i++)
{
@ -1857,11 +1886,11 @@ void messageCardContent(lv_obj_t *cont_messages)
lv_obj_set_flex_flow(apps, LV_FLEX_FLOW_ROW);
lv_obj_set_style_pad_column(apps, 6, 0);
create_card(apps, "Météo", meteoCardContent, meteoCb);
create_card(apps, "Météo", meteoCardContent, meteoCb,400);
create_card(apps, "Volets", coverCardContent, voletsCb);
create_card(apps, "Minuteur", minuteurCardContent, minuteurCb);
create_card(apps, "Messagerie", messageCardContent, messagerieCb);
create_card(apps, "Volets", coverCardContent, voletsCb,150);
create_card(apps, "Minuteur", minuteurCardContent, minuteurCb,300);
create_card(apps, "Messagerie", messageCardContent, messagerieCb,300);
return;
}
@ -1943,7 +1972,7 @@ static void app_card_click_cb(lv_event_t *e)
app_cb(base_obj);
}
void create_card(lv_obj_t *parent, char *lbl, void (*contentFct)(lv_obj_t *), app_cb_t app_cb)
void create_card(lv_obj_t *parent, char *lbl, void (*contentFct)(lv_obj_t *), app_cb_t app_cb, int width)
{
//lv_style_init(&objstyle);
//lv_style_init(&txtstyle);
@ -1958,6 +1987,9 @@ void create_card(lv_obj_t *parent, char *lbl, void (*contentFct)(lv_obj_t *), ap
lv_obj_set_id(app_card, "app_card");
lv_obj_set_name(app_card, "app_card");
//lv_obj_remove_style_all(app_card);
if(width>0)
lv_obj_set_size(app_card, width, 200);
else
lv_obj_set_size(app_card, 300, 200);
//lv_obj_set_size(app_card, 100, 60);
lv_obj_set_style_radius(app_card, 20, 0);

View File

@ -49,7 +49,7 @@ void ihm_gateway_process_queue(void) {
if (!evt) return;
UBaseType_t pending = uxQueueMessagesWaiting(xIHMEventQueue);
ESP_LOGE(TAG,"Evt recu %d. La queue comporte %d éléments à traiter", evt->eEventType, pending);
ESP_LOGV(TAG,"Evt recu %d. La queue comporte %d éléments à traiter", evt->eEventType, pending);
lv_async_call(traiteEvt, evt);
}
@ -66,6 +66,7 @@ void traiteEvt(void *arg)
case IHM_EVT_TIME_SETTED:
draw_time(evt->pvData);
evt->bNeedToFreeData=false;
break;
case IHM_EVT_OTA_STARTED:
@ -74,10 +75,12 @@ void traiteEvt(void *arg)
case IHM_EVT_HUMID_TEMP:
draw_temp((char *)evt->pvData);
evt->bNeedToFreeData=false;
break;
case IHM_EVT_TEMP_RECUE:
draw_tempExt((char *)evt->pvData);
evt->bNeedToFreeData=false;
break;
case IHM_EVT_PUISSANCE_EMISE:
@ -94,7 +97,7 @@ void traiteEvt(void *arg)
WashingMachineState wms = traiteMessage(etatMachine);
char etat[80];
getEtatMachineStr(wms, etat,80);
ESP_LOGE(TAG,"Etat machine : %s", etat);
ESP_LOGI(TAG,"Etat machine : %s", etat);
draw_minuteur(etat);
// lv_label_set_text(lblEtatMachine, etatFormate);
break;
@ -110,24 +113,24 @@ void traiteEvt(void *arg)
case IHM_EVT_METEO_RECUE:{
//(void *)evt->pvData; // Pointeur sur tableau
//(void *)evt->pvData
ESP_LOGE(TAG, "Reception evt MF");
ESP_LOGI(TAG, "Reception evt MF");
// On ne veut liberer la memoire que lorsque l'evenement aura été traité!
evt->bNeedToFreeData=false;
meteo_event_payload_t *datas = (meteo_event_payload_t *) evt->pvData;
for (size_t i = 0; i < 3; i++)
{
ESP_LOGE(TAG,"Type: %s - Valide : %d - %s", datas->daily[i].type, datas->daily[i].isValid, datas->daily[i].previsions.desc);
ESP_LOGI(TAG,"Type: %s - Valide : %d - %s", datas->daily[i].type, datas->daily[i].isValid, datas->daily[i].previsions.desc);
}
for (size_t i = 0; i < 3; i++)
{
ESP_LOGE(TAG,"Type: %s - Valide : %d - %s - %s - %f", datas->forecast[i].type, datas->forecast[i].isValid, datas->forecast[i].previsions.desc, datas->forecast[i].previsions.icon, datas->forecast[i].previsions.value);
ESP_LOGI(TAG,"Type: %s - Valide : %d - %s - %s - %f", datas->forecast[i].type, datas->forecast[i].isValid, datas->forecast[i].previsions.desc, datas->forecast[i].previsions.icon, datas->forecast[i].previsions.value);
}
draw_meteo(datas);
//lv_subject_set_int(&meteoStatus, 0);
//display_unlock("weather_data_retreived");
ESP_LOGE(TAG, "Fin Reception evt MF");
ESP_LOGI(TAG, "Fin Reception evt MF");
break;
}

View File

@ -1,3 +1,3 @@
idf_component_register(SRCS "obtain_time.c" "eventsManager.c" obtain_time.c
INCLUDE_DIRS "include"
REQUIRES mqtt esp_netif meteofrance)
REQUIRES mqtt esp_netif meteofrance audio)

View File

@ -6,10 +6,11 @@
#include "obtain_time.h"
#include <time.h>
#include "meteofrance.h"
#include "audio.h"
EventGroupHandle_t domotic_event_group;
QueueHandle_t ihm_queue;
//extern esp_mqtt_client_handle_t client;
extern esp_mqtt_client_handle_t client;
static const char *TAG = "evtMgr";
@ -26,8 +27,42 @@ void startEvtManager(){
/* Tache updateTime - FIN*/
}
const char * domo_event_to_str(domo_events evt)
{
switch (evt) {
case EVT_WIFI_CONNECTED: return "WIFI_CONNECTED";
case EVT_TIME_SETTED: return "TIME_SETTED";
case EVT_BTN_VOLET: return "BTN_VOLET";
case EVT_PUISSANCE_RECUE: return "PUISSANCE_RECUE";
case EVT_ETAT_MACHINE: return "ETAT_MACHINE";
case EVT_HAUTEUR_CUVE: return "HAUTEUR_CUVE";
case EVT_METEO_RECUE: return "METEO_RECUE";
case EVT_TEMP_EXT: return "TEMP_EXT";
case EVT_TEMP_INT: return "TEMP_INT";
case EVT_FIN_MACHINE: return "FIN_MACHINE";
default: return "EVT_UNKNOWN";
}
}
const char * ihm_event_to_str(eIHMEvent_t evt)
{
switch (evt) {
case IHM_EVT_WIFI_STATUS: return "IHM_WIFI_STATUS";
case IHM_EVT_TIME_SETTED: return "IHM_TIME_SETTED";
case IHM_EVT_OTA_STARTED: return "IHM_OTA_STARTED";
case IHM_EVT_OTA_PROGRESS: return "IHM_OTA_PROGRESS";
case IHM_EVT_HUMID_TEMP: return "IHM_HUMID_TEMP";
case IHM_EVT_PUISSANCE_EMISE: return "IHM_PUISSANCE_EMISE";
case IHM_EVT_ETAT_MACHINE: return "IHM_ETAT_MACHINE";
case IHM_EVT_HAUTEUR_CUVE: return "IHM_HAUTEUR_CUVE";
case IHM_EVT_METEO_RECUE: return "IHM_METEO_RECUE";
case IHM_EVT_TEMP_RECUE: return "IHM_TEMP_RECUE";
default: return "IHM_EVT_UNKNOWN";
}
}
void send_event(domo_events evt, void* pDatas) {
ESP_LOGV(TAG,"On est dans l'event handler %i", evt);
ESP_LOGI(TAG, "EventManager: On est dans l'event handler %s", domo_event_to_str(evt));
xIHMEvent_t *ihmEvt = malloc(sizeof(xIHMEvent_t));
if (!ihmEvt) {
@ -79,12 +114,13 @@ void send_event(domo_events evt, void* pDatas) {
break;
case EVT_BTN_VOLET:
//esp_mqtt_client_publish(client, "volets", pDatas, 0, 0, 0);
esp_mqtt_client_publish(client, "volets", pDatas, 0, 0, 0);
free(ihmEvt); // rien à envoyer à l'IHM
ihmEvt = NULL;
return;
case EVT_PUISSANCE_RECUE:
ESP_LOGE(TAG, "Puissance recue %i", *(int*)pDatas);
ESP_LOGI(TAG, "Puissance recue %i", *(int*)pDatas);
int *data = malloc(sizeof(int));
if (!data) {
ESP_LOGE(TAG, "malloc failed for puissance_5mn");
@ -170,13 +206,21 @@ void send_event(domo_events evt, void* pDatas) {
break;
}
case EVT_FIN_MACHINE:{
playSound();
free(ihmEvt); // rien à envoyer à l'IHM
ihmEvt = NULL;
break;
}
default:
ESP_LOGE(TAG, "Unhandled event type");
free(ihmEvt);
ihmEvt = NULL;
return;
}
ESP_LOGE(TAG, "Envoi d'un evt %i a l'IHM", ihmEvt->eEventType);
if( ihm_queue != NULL && ihmEvt){
ESP_LOGI(TAG, "Suite %s : Envoi d'un evt %s (%i) a l'IHM", domo_event_to_str(evt), ihm_event_to_str(ihmEvt->eEventType),ihmEvt->eEventType);
if (xQueueSendToFront(ihm_queue, &ihmEvt, pdMS_TO_TICKS(10)) != pdPASS)
{
ESP_LOGE(TAG, "La queue est pleine");
@ -186,5 +230,8 @@ void send_event(domo_events evt, void* pDatas) {
}
free(ihmEvt);
}
}else{
ESP_LOGI(TAG, "Suite %s : on n'envoie rien a l'IHM", domo_event_to_str(evt));
}
}

View File

@ -34,7 +34,8 @@ typedef enum domo_events{
EVT_HAUTEUR_CUVE,
EVT_METEO_RECUE,
EVT_TEMP_EXT,
EVT_TEMP_INT
EVT_TEMP_INT,
EVT_FIN_MACHINE
} domo_events;
void startEvtManager();
QueueHandle_t getIHMQueueHandle();

View File

@ -67,7 +67,7 @@
void printftemp(struct forecast_prev * tmp);
void printfdf(struct meteodailyforecast_data * tmp);
void dtToString(time_t, char *buffer);
void dtHToString(time_t, char *buffer);
void dtHToString(time_t, char *buffer, size_t bufSize);
void printff(struct meteoforecast_data * tmp);
void on_weather_data_retrieval(weather_data_callback data_retreived_cb);

View File

@ -70,10 +70,10 @@ void dtToString(time_t ttt, char* buffer){
//sprintf(strftime_buf, "%d %d %d", timeinfo.tm_wday, timeinfo.tm_mday, timeinfo.tm_mon + 1);
}
void dtHToString(time_t ttt, char* buffer){
void dtHToString(time_t ttt, char* buffer, size_t bufSize){
struct tm timeinfo = {0};
localtime_r(&ttt, &timeinfo);
strftime(buffer, MAX_SIZE, "%H:%M", &timeinfo);
strftime(buffer, bufSize, "%H:%M", &timeinfo);
//char strftime_buf[64];
//sprintf(strftime_buf, "%d %d %d", timeinfo.tm_wday, timeinfo.tm_mday, timeinfo.tm_mon + 1);
}

View File

@ -1,2 +1,2 @@
idf_component_register(SRCS "washingMachineState.c" PRIV_REQUIRES json
idf_component_register(SRCS "washingMachineState.c" PRIV_REQUIRES json eventsManager
INCLUDE_DIRS "include")

View File

@ -2,11 +2,13 @@
#include <cJSON.h>
#include <esp_log.h>
#include "washingMachineState.h"
#include "eventsManager.h"
#include <time.h>
#define TAG "WMS"
WashingMachineState wms;
bool stateOn; // Indique si la machine est en route
WashingMachineState traiteMessage(char* message){
@ -25,6 +27,15 @@ WashingMachineState traiteMessage(char* message){
wms.depuis = timestamp;
wms.ack = ack;
if(wms.etat==LAVEUSE_LAVAGE){
stateOn=true;
}
if(wms.etat==LAVEUSE_ARRET && stateOn){
//Fin détectée !
stateOn=false;
send_event(EVT_FIN_MACHINE, NULL);
}
cJSON_Delete(root);
return wms;

View File

@ -5,12 +5,13 @@ set(comps heap nvs_flash esp_netif image_downloader fatfs protocol_examples_comm
if(${IDF_TARGET} STREQUAL "esp32p4")
message(STATUS "SIMULATION_QEMU = OOF --> main standard")
list(APPEND comps esp32_p4_function_ev_board sdmmc vfs littlefs app_update esp_https_ota espcoredump esp_http_server esp_wifi )
list(APPEND comps esp32_p4_function_ev_board sdmmc vfs littlefs app_update esp_https_ota espcoredump esp_http_server esp_wifi)
idf_component_register(SRCS main.c communication.c
INCLUDE_DIRS "./include"
REQUIRES ${comps}
EMBED_TXTFILES ${PROJECT_DIR}/main/ca_cert.pem
EMBED_FILES "index.html")
littlefs_create_partition_image(littlefs medias FLASH_IN_PROJECT)
elseif(${IDF_TARGET} STREQUAL "linux")
message(STATUS "Linux Mode --> main standard")
list(APPEND comps vfs esp_http_server)

View File

@ -37,7 +37,9 @@
#include <esp_task_wdt.h>
#if CONFIG_IDF_TARGET_ESP32P4
#include "am2302_rmt.h"
#endif
// GPIO assignment
#define AM2302_GPIO 4
@ -483,6 +485,7 @@ ota_end:
}
*/}
#if CONFIG_IDF_TARGET_ESP32P4
am2302_handle_t sensor = NULL;
void readTempHumid(void *pvParameter)
@ -499,7 +502,26 @@ void readTempHumid(void *pvParameter)
vTaskDelay(60000 / portTICK_PERIOD_MS);
}
}
#include "esp_littlefs.h"
void littlefs_mount(void)
{
esp_vfs_littlefs_conf_t conf = {
.base_path = "/littlefs",
.partition_label = "littlefs", // ← DOIT matcher partitions.csv
.format_if_mount_failed = false
};
esp_err_t ret = esp_vfs_littlefs_register(&conf);
if (ret != ESP_OK) {
printf("LittleFS mount failed: %s\n", esp_err_to_name(ret));
} else {
printf("LittleFS mounted at /littlefs\n");
}
}
#endif
void alloc_fail(size_t size, uint32_t caps, const char * function_name){
ESP_LOGE(TAG,"fail alloc %u in %" PRIu32 " in %s", size,caps,function_name);
@ -849,24 +871,6 @@ void lightSensorTask(void *pvParameter){
}
*/
}
#include "esp_littlefs.h"
void littlefs_mount(void)
{
esp_vfs_littlefs_conf_t conf = {
.base_path = "/littlefs",
.partition_label = "littlefs", // ← DOIT matcher partitions.csv
.format_if_mount_failed = false
};
esp_err_t ret = esp_vfs_littlefs_register(&conf);
if (ret != ESP_OK) {
printf("LittleFS mount failed: %s\n", esp_err_to_name(ret));
} else {
printf("LittleFS mounted at /littlefs\n");
}
}
void app_main(void)
{
@ -875,8 +879,6 @@ void app_main(void)
ihm_gateway_init();
startEvtManager();
littlefs_mount();
boucleMeteo();
#if CONFIG_IDF_TARGET_LINUX
// en mode linux on simule l'obtention de la connexion wifi
@ -885,6 +887,7 @@ void app_main(void)
//drawIhm(getIHMQueueHandle());
#else
littlefs_mount();
xTaskCreate(&drawIhm,"ihm_task",10000,getIHMQueueHandle(),10,NULL);
//et sinon on se connecte
ESP_LOGI(TAG, "ESP_WIFI_MODE_STA");
@ -892,6 +895,7 @@ void app_main(void)
//start_wifi_logger();
#endif
boucleMeteo();
mqtt_app_start(mqtt_cb, domotic_event_group);
TaskHandle_t xHandle = NULL;
@ -901,6 +905,11 @@ void app_main(void)
{
ESP_LOGE(TAG, "Impossiblke de creer la tache imageDownload_task %i", ret1);
}*/
#if CONFIG_IDF_TARGET_ESP32P4
//playSound();
//send_event(EVT_FIN_MACHINE,NULL);
// Configuration de la sonde Temp/Humid.
am2302_config_t am2302_config = {
.gpio_num = AM2302_GPIO,
@ -910,6 +919,9 @@ void app_main(void)
};
ESP_ERROR_CHECK(am2302_new_sensor_rmt(&am2302_config, &rmt_config, &sensor));
xTaskCreate(&readTempHumid, "read_temp_task", 8192, NULL, 5, NULL);
#endif
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 551 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 551 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 551 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 930 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 930 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

View File

@ -1,10 +1,10 @@
# ESP-IDF Partition Table
# Name, Type, SubType, Offset, Size, Flags
nvs,data,nvs,,0x6000,,
otadata,data,ota,,0x2000,,
phy_init,data,phy,,0x1000,,
factory,app,factory,,3M,,
ota_0,app,ota_0,,3M,,
ota_1,app,ota_1,,3M,,
littlefs,data,littlefs,,1M,,
coredump, data, coredump,,64K,,
nvs,data,nvs,,0x6000,
otadata,data,ota,,0x2000,
phy_init,data,phy,,0x1000,
factory,app,factory,,3M,
ota_0,app,ota_0,,3M,
ota_1,app,ota_1,,3M,
littlefs,data,littlefs,,3M,
coredump,data,coredump,,64K,

1 # ESP-IDF Partition Table
2 # Name, Type, SubType, Offset, Size, Flags
3 nvs,data,nvs,,0x6000,, nvs,data,nvs,,0x6000,
4 otadata,data,ota,,0x2000,, otadata,data,ota,,0x2000,
5 phy_init,data,phy,,0x1000,, phy_init,data,phy,,0x1000,
6 factory,app,factory,,3M,, factory,app,factory,,3M,
7 ota_0,app,ota_0,,3M,, ota_0,app,ota_0,,3M,
8 ota_1,app,ota_1,,3M,, ota_1,app,ota_1,,3M,
9 littlefs,data,littlefs,,1M,, littlefs,data,littlefs,,3M,
10 coredump, data, coredump,,64K,, coredump,data,coredump,,64K,