Make tahoma communication more robust and add Possibility to change setTemp via MQTT
This commit is contained in:
parent
20601a7ecd
commit
bc175426d4
BIN
KiCAD/raumtemp_relay_schematic.pdf
Normal file
BIN
KiCAD/raumtemp_relay_schematic.pdf
Normal file
Binary file not shown.
@ -15,10 +15,10 @@ monitor_speed = 115200
|
|||||||
framework = arduino
|
framework = arduino
|
||||||
board_build.partitions = min_spiffs.csv
|
board_build.partitions = min_spiffs.csv
|
||||||
upload_protocol = espota
|
upload_protocol = espota
|
||||||
upload_port = TMP-EG-WoZi.fritz.box
|
upload_port = TMP-EG-Bad.fritz.box
|
||||||
lib_deps =
|
lib_deps =
|
||||||
moononournation/GFX Library for Arduino@^1.5.3
|
moononournation/GFX Library for Arduino@^1.5.3
|
||||||
lvgl/lvgl@^9.2.2
|
lvgl/lvgl@^9.4.0
|
||||||
finitespace/BME280@^3.0.0
|
finitespace/BME280@^3.0.0
|
||||||
tzapu/WiFiManager@^2.0.17
|
tzapu/WiFiManager@^2.0.17
|
||||||
build_flags =
|
build_flags =
|
||||||
@ -26,4 +26,5 @@ build_flags =
|
|||||||
-D LV_LVGL_H_INCLUDE_SIMPLE
|
-D LV_LVGL_H_INCLUDE_SIMPLE
|
||||||
-I src
|
-I src
|
||||||
;to install on all targets:
|
;to install on all targets:
|
||||||
;(pio run -t nobuild -t upload --upload-port TMP-EG-WoZi.fritz.box) -and (pio run -t nobuild -t upload --upload-port TMP-EG-Florian.fritz.box) -and (pio run -t nobuild -t upload --upload-port TMP-EG-Bad.fritz.box) -and (pio run -t nobuild -t upload --upload-port TMP-OG-Bad.fritz.box) -and (pio run -t nobuild -t upload --upload-port TMP-OG-Buero.fritz.box) -and (pio run -t nobuild -t upload --upload-port TMP-OG-KiZi.fritz.box) -and (pio run -t nobuild -t upload --upload-port TMP-OGSchlafen.fritz.box) -and (pio run -t nobuild -t upload --upload-port TMP-OGWoZi.fritz.box) -and (pio run -t nobuild -t upload --upload-port TMP-UG-Bad.fritz.box) -and (pio run -t nobuild -t upload --upload-port TMP-UG-Buero.fritz.box) -and (pio run -t nobuild -t upload --upload-port TMP-UG-Kueche.fritz.box)
|
;(pio run -t nobuild -t upload --upload-port TMP-EG-WoZi.fritz.box) -and (pio run -t nobuild -t upload --upload-port TMP-EG-Florian.fritz.box) -and (pio run -t nobuild -t upload --upload-port TMP-EG-Bad.fritz.box) -and (pio run -t nobuild -t upload --upload-port TMP-EG-Magdalena.fritz.box) -and (pio run -t nobuild -t upload --upload-port TMP-EG-Schlafen.fritz.box)
|
||||||
|
;-and (pio run -t nobuild -t upload --upload-port TMP-OG-Bad.fritz.box) -and (pio run -t nobuild -t upload --upload-port TMP-OG-Buero.fritz.box) -and (pio run -t nobuild -t upload --upload-port TMP-OG-KiZi.fritz.box) -and (pio run -t nobuild -t upload --upload-port TMP-OGSchlafen.fritz.box) -and (pio run -t nobuild -t upload --upload-port TMP-OGWoZi.fritz.box) -and (pio run -t nobuild -t upload --upload-port TMP-UG-Bad.fritz.box) -and (pio run -t nobuild -t upload --upload-port TMP-UG-Buero.fritz.box) -and (pio run -t nobuild -t upload --upload-port TMP-UG-Kueche.fritz.box)
|
||||||
@ -129,7 +129,16 @@ void MQTT::saveConfigToFlash(void){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MQTT::receiveTopic(char* topic, byte* payload, unsigned int length) {
|
void MQTT::receiveTopic(char* topic, byte* payload, unsigned int length) {
|
||||||
|
String strTopic = String(topic);
|
||||||
|
if(topic == "weatherStation/tempAmb")
|
||||||
glblData.outTemp = String((char*)payload).toFloat();
|
glblData.outTemp = String((char*)payload).toFloat();
|
||||||
|
else if(strTopic.endsWith("/changeSetTemp")){
|
||||||
|
float newSetTemp = String((char*)payload).toFloat();
|
||||||
|
if(newSetTemp >= 5.0 && newSetTemp <= 30.0){
|
||||||
|
glblData.settemp = newSetTemp;
|
||||||
|
ui_settemp(glblData.settemp);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MQTT::reconnect(void) {
|
void MQTT::reconnect(void) {
|
||||||
@ -138,6 +147,11 @@ void MQTT::reconnect(void) {
|
|||||||
// Attempt to connect
|
// Attempt to connect
|
||||||
if (psclient.connect(Settings::prefs.hostname)) {
|
if (psclient.connect(Settings::prefs.hostname)) {
|
||||||
psclient.subscribe("weatherStation/tempAmb");
|
psclient.subscribe("weatherStation/tempAmb");
|
||||||
|
char newtopic[60];
|
||||||
|
strcpy(newtopic,Settings::prefs.mqtt_topic);
|
||||||
|
strcat(newtopic,"/");
|
||||||
|
strcat(newtopic,"changeSetTemp");
|
||||||
|
psclient.subscribe(newtopic);
|
||||||
Serial.println("connected");
|
Serial.println("connected");
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -8,6 +8,7 @@
|
|||||||
#include <WiFiClient.h>
|
#include <WiFiClient.h>
|
||||||
#include <ArduinoOTA.h>
|
#include <ArduinoOTA.h>
|
||||||
#include <ui/vars.h>
|
#include <ui/vars.h>
|
||||||
|
#include <ui/actions.h>
|
||||||
#include <MQTT.h>
|
#include <MQTT.h>
|
||||||
#include <ESPAsyncWebServer.h>
|
#include <ESPAsyncWebServer.h>
|
||||||
#include <settings.h>
|
#include <settings.h>
|
||||||
|
|||||||
@ -52,7 +52,7 @@
|
|||||||
|
|
||||||
#if LV_USE_STDLIB_MALLOC == LV_STDLIB_BUILTIN
|
#if LV_USE_STDLIB_MALLOC == LV_STDLIB_BUILTIN
|
||||||
/*Size of the memory available for `lv_malloc()` in bytes (>= 2kB)*/
|
/*Size of the memory available for `lv_malloc()` in bytes (>= 2kB)*/
|
||||||
#define LV_MEM_SIZE (64 * 1024U) /*[bytes]*/
|
#define LV_MEM_SIZE (96 * 1024U) /*[bytes]*/
|
||||||
|
|
||||||
/*Size of the memory expand for `lv_malloc()` in bytes*/
|
/*Size of the memory expand for `lv_malloc()` in bytes*/
|
||||||
#define LV_MEM_POOL_EXPAND_SIZE 0
|
#define LV_MEM_POOL_EXPAND_SIZE 0
|
||||||
|
|||||||
@ -22,7 +22,7 @@
|
|||||||
#define MEASINT_S 5
|
#define MEASINT_S 5
|
||||||
#define SCREEN_UPDATE_S 30 //update screen every 30 secs
|
#define SCREEN_UPDATE_S 30 //update screen every 30 secs
|
||||||
#define HISTINT_S (5*60) //make history point every 5 min.
|
#define HISTINT_S (5*60) //make history point every 5 min.
|
||||||
#define WDT_TIMEOUT SCREEN_UPDATE_S*3 //set WDT timeout to 3 times the screen update time
|
#define WDT_TIMEOUT SCREEN_UPDATE_S*7 //set WDT timeout to 3 times the screen update time
|
||||||
|
|
||||||
// -- Initial password to connect to the Thing, when it creates an own Access Point.
|
// -- Initial password to connect to the Thing, when it creates an own Access Point.
|
||||||
|
|
||||||
@ -48,7 +48,7 @@ BME280I2C::Settings settings(
|
|||||||
BME280I2C bme(settings);
|
BME280I2C bme(settings);
|
||||||
|
|
||||||
#define DRAW_BUF_SIZE (SCREEN_WIDTH * SCREEN_HEIGHT / 2 * (LV_COLOR_DEPTH / 8))
|
#define DRAW_BUF_SIZE (SCREEN_WIDTH * SCREEN_HEIGHT / 2 * (LV_COLOR_DEPTH / 8))
|
||||||
uint32_t draw_buf[DRAW_BUF_SIZE / 4];
|
uint32_t draw_buf[DRAW_BUF_SIZE / 5];
|
||||||
bool newMeasurement=false,newHistory=false;
|
bool newMeasurement=false,newHistory=false;
|
||||||
float temp(NAN), hum(NAN), pres(NAN),seaLevelPress(NAN);
|
float temp(NAN), hum(NAN), pres(NAN),seaLevelPress(NAN);
|
||||||
bool presAlarm = false;
|
bool presAlarm = false;
|
||||||
@ -156,8 +156,9 @@ void loop()
|
|||||||
update_wifi_strength(glblData.wifiStrength,glblData.wifiMode);
|
update_wifi_strength(glblData.wifiStrength,glblData.wifiMode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
checkTahomaActions(); //slowdown done in loop function
|
||||||
|
|
||||||
if(millis() - secondsTick > 1000){
|
if(millis() - secondsTick > 1000){
|
||||||
checkTahomaActions();
|
|
||||||
secondsTick = millis();
|
secondsTick = millis();
|
||||||
update_status();
|
update_status();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
#include "tahoma.h"
|
#include "tahoma.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
extern constexpr char Tahoma::serverURL[];
|
extern constexpr char Tahoma::serverURL[];
|
||||||
|
extern unsigned long lastCheck;
|
||||||
extern Tahoma::rolloCommand_t Tahoma::movement[];
|
extern Tahoma::rolloCommand_t Tahoma::movement[];
|
||||||
Tahoma::Tahoma(void) {}
|
Tahoma::Tahoma(void) {}
|
||||||
|
|
||||||
@ -125,6 +126,8 @@ uint8_t Tahoma::sendMove(uint8_t deviceIndex, uint8_t position,
|
|||||||
if (position != 0 && rotation > 20) {
|
if (position != 0 && rotation > 20) {
|
||||||
movement[deviceIndex].position = position;
|
movement[deviceIndex].position = position;
|
||||||
movement[deviceIndex].rotation = rotation;
|
movement[deviceIndex].rotation = rotation;
|
||||||
|
movement[deviceIndex].movingFilter = 0;
|
||||||
|
lastCheck = millis();
|
||||||
rotation = 0;
|
rotation = 0;
|
||||||
}
|
}
|
||||||
url = url + "?action=move&pos=" + String(position) +
|
url = url + "?action=move&pos=" + String(position) +
|
||||||
@ -133,7 +136,7 @@ uint8_t Tahoma::sendMove(uint8_t deviceIndex, uint8_t position,
|
|||||||
.index); // Construct the URL to fetch all devices
|
.index); // Construct the URL to fetch all devices
|
||||||
http.begin(url); // Initialize the HTTP connection
|
http.begin(url); // Initialize the HTTP connection
|
||||||
int httpCode = http.GET(); // Send the GET request and get the response code
|
int httpCode = http.GET(); // Send the GET request and get the response code
|
||||||
if (httpCode > 0) { // Check if the request was successful
|
if (httpCode > 199 && httpCode < 300) { // Check if the request was successful
|
||||||
String response = http.getString(); // Get the response as a string
|
String response = http.getString(); // Get the response as a string
|
||||||
if (response.indexOf("stop") != -1) {
|
if (response.indexOf("stop") != -1) {
|
||||||
movement[deviceIndex].position = 0;
|
movement[deviceIndex].position = 0;
|
||||||
@ -165,7 +168,7 @@ uint8_t Tahoma::sendfinalRot(uint8_t deviceIndex) {
|
|||||||
HTTPClient http; // Create an HTTP client object
|
HTTPClient http; // Create an HTTP client object
|
||||||
String url = serverURL;
|
String url = serverURL;
|
||||||
if (movement[deviceIndex].position == 0) {
|
if (movement[deviceIndex].position == 0) {
|
||||||
return 0; // no movement stored
|
return 1; // no movement stored
|
||||||
}
|
}
|
||||||
url = url + "?action=move&pos=" + String(movement[deviceIndex].position) +
|
url = url + "?action=move&pos=" + String(movement[deviceIndex].position) +
|
||||||
"&angle=" + String(movement[deviceIndex].rotation) + "&device=" +
|
"&angle=" + String(movement[deviceIndex].rotation) + "&device=" +
|
||||||
@ -173,8 +176,9 @@ uint8_t Tahoma::sendfinalRot(uint8_t deviceIndex) {
|
|||||||
.index); // Construct the URL to fetch all devices
|
.index); // Construct the URL to fetch all devices
|
||||||
http.begin(url); // Initialize the HTTP connection
|
http.begin(url); // Initialize the HTTP connection
|
||||||
int httpCode = http.GET(); // Send the GET request and get the response code
|
int httpCode = http.GET(); // Send the GET request and get the response code
|
||||||
if (httpCode > 0) { // Check if the request was successful
|
if (httpCode > 199 && httpCode < 300) { // Check if the request was successful
|
||||||
movement[deviceIndex].position = 0;
|
movement[deviceIndex].position = 0;
|
||||||
|
movement[deviceIndex].movingFilter = 0;
|
||||||
ret = 1;
|
ret = 1;
|
||||||
} else {
|
} else {
|
||||||
ret = 0;
|
ret = 0;
|
||||||
@ -191,11 +195,26 @@ void Tahoma::selectDev(uint8_t i,bool _select) {
|
|||||||
|
|
||||||
|
|
||||||
void Tahoma::loop(void) {
|
void Tahoma::loop(void) {
|
||||||
|
static uint8_t errorCnt = 0;
|
||||||
|
if (millis() - lastCheck < 1000) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
lastCheck = millis();
|
||||||
for (uint8_t i = 0; i < numDevs; i++) {
|
for (uint8_t i = 0; i < numDevs; i++) {
|
||||||
if (movement[i].position != 0) {
|
if (movement[i].position != 0) {
|
||||||
Serial.print(devicelist[i].index);
|
Serial.print(devicelist[i].index);
|
||||||
if (!checkMovement(i)) {
|
if (!checkMovement(i)) {
|
||||||
sendfinalRot(i);
|
if(movement[i].movingFilter++ >= 1){
|
||||||
|
if(!sendfinalRot(i)){
|
||||||
|
errorCnt++;
|
||||||
|
}else{
|
||||||
|
errorCnt = 0;
|
||||||
|
}
|
||||||
|
if(errorCnt > 10){ //give up after 10 errors regardless what devices caused errors.
|
||||||
|
movement[i].position = 0;
|
||||||
|
errorCnt = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,10 +12,12 @@
|
|||||||
class Tahoma {
|
class Tahoma {
|
||||||
public:
|
public:
|
||||||
typedef union {
|
typedef union {
|
||||||
uint16_t movement;
|
uint32_t movement;
|
||||||
struct {
|
struct {
|
||||||
uint16_t position : 8;
|
uint32_t position : 8;
|
||||||
uint16_t rotation : 8;
|
uint32_t rotation : 8;
|
||||||
|
uint32_t movingFilter : 8;
|
||||||
|
uint32_t reserved : 8;
|
||||||
};
|
};
|
||||||
} rolloCommand_t;
|
} rolloCommand_t;
|
||||||
|
|
||||||
@ -44,6 +46,7 @@ typedef union {
|
|||||||
private:
|
private:
|
||||||
bool checkMovement(uint8_t deviceIndex);
|
bool checkMovement(uint8_t deviceIndex);
|
||||||
static constexpr char serverURL[]{"http://nas.local/smart/ajax/tahoma.php"}; // Hostname of the Tahoma system
|
static constexpr char serverURL[]{"http://nas.local/smart/ajax/tahoma.php"}; // Hostname of the Tahoma system
|
||||||
|
unsigned long lastCheck{0};
|
||||||
Ticker movementCheckTicker;
|
Ticker movementCheckTicker;
|
||||||
// Simulate fetching data from the Tahoma system
|
// Simulate fetching data from the Tahoma system
|
||||||
};
|
};
|
||||||
|
|||||||
@ -4,7 +4,8 @@
|
|||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
|
||||||
bool arc_pressed = false;
|
bool arc_pressed = false;
|
||||||
bool animating = false;
|
bool zoomed = false;
|
||||||
|
uint32_t last_press_time = 0;
|
||||||
|
|
||||||
float curr_temp = 0.0;
|
float curr_temp = 0.0;
|
||||||
int32_t scale_max = 0, scale_min = 0, lastSelChartValue = 0;
|
int32_t scale_max = 0, scale_min = 0, lastSelChartValue = 0;
|
||||||
@ -85,8 +86,12 @@ void update_status(void) {
|
|||||||
ledcWrite(PWM_REL, 0); // relay off
|
ledcWrite(PWM_REL, 0); // relay off
|
||||||
lv_obj_add_flag(objects.heaterIcn, LV_OBJ_FLAG_HIDDEN);
|
lv_obj_add_flag(objects.heaterIcn, LV_OBJ_FLAG_HIDDEN);
|
||||||
}
|
}
|
||||||
|
if(objects.rolloScr != NULL) {
|
||||||
if (objects.mainScr == NULL) {
|
lv_label_set_text_fmt(objects.temp_txt,SYM_THERMOMETER_HALF"%2.1f°C(%2.0f°C) "SYM_NATURE"%2.1f°C",glblData.temp,glblData.settemp,glblData.outTemp);
|
||||||
|
}else if (objects.mainScr != NULL) {
|
||||||
|
if(zoomed) {
|
||||||
|
glblData.settemp = lv_arc_get_value(objects.temp_arc);
|
||||||
|
lv_label_set_text_fmt(objects.temp_txt, "%2.1f °C", glblData.settemp);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dotState = !dotState;
|
dotState = !dotState;
|
||||||
@ -105,12 +110,10 @@ void update_status(void) {
|
|||||||
lv_label_set_text_fmt(objects.outTemp_txt, SYM_NATURE " %2.1f °C",
|
lv_label_set_text_fmt(objects.outTemp_txt, SYM_NATURE " %2.1f °C",
|
||||||
glblData.outTemp);
|
glblData.outTemp);
|
||||||
lv_label_set_text(objects.time_txt, buffer);
|
lv_label_set_text(objects.time_txt, buffer);
|
||||||
if (!arc_pressed && !animating) {
|
|
||||||
lv_label_set_text_fmt(objects.temp_txt, "%2.1f °C", glblData.temp);
|
lv_label_set_text_fmt(objects.temp_txt, "%2.1f °C", glblData.temp);
|
||||||
} else {
|
|
||||||
glblData.settemp = lv_arc_get_value(objects.temp_arc);
|
|
||||||
lv_label_set_text_fmt(objects.temp_txt, "%2.1f °C", glblData.settemp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void update_wifi_strength(wifistrength_t strength, wifimode_t mode) {
|
void update_wifi_strength(wifistrength_t strength, wifimode_t mode) {
|
||||||
@ -323,6 +326,10 @@ void moveRolloUp(lv_event_t *e) {
|
|||||||
;
|
;
|
||||||
tahoma.moveSelected(0, 0);
|
tahoma.moveSelected(0, 0);
|
||||||
}
|
}
|
||||||
|
void resetAnimationFlags(void) {
|
||||||
|
arc_pressed = false;
|
||||||
|
zoomed = false;
|
||||||
|
}
|
||||||
|
|
||||||
void zoomAniWrapper(void *var, int32_t val) {
|
void zoomAniWrapper(void *var, int32_t val) {
|
||||||
lv_obj_t *obj = (lv_obj_t *)var;
|
lv_obj_t *obj = (lv_obj_t *)var;
|
||||||
@ -335,26 +342,33 @@ void zoomAniWrapper(void *var, int32_t val) {
|
|||||||
lv_obj_set_style_text_opa(objects.outTemp_txt, 255 - val, 0);
|
lv_obj_set_style_text_opa(objects.outTemp_txt, 255 - val, 0);
|
||||||
lv_obj_set_style_text_opa(objects.time_txt, 255 - val, 0);
|
lv_obj_set_style_text_opa(objects.time_txt, 255 - val, 0);
|
||||||
}
|
}
|
||||||
void zomFinishedCB(lv_anim_t *var) {
|
void zoomFinishedCB(lv_anim_t *var) {
|
||||||
|
|
||||||
if (arc_pressed) {
|
|
||||||
arc_pressed = false;
|
|
||||||
animating = false;
|
|
||||||
lv_label_set_text_fmt(objects.temp_txt, "%2.1f °C", glblData.temp);
|
|
||||||
} else if (ui_getCurrentScreen() == objects.mainScr) {
|
|
||||||
// only set arc pressed true if main screen is
|
|
||||||
// still active, otherwise we'll lock screen
|
|
||||||
// switching
|
|
||||||
arc_pressed = true;
|
|
||||||
animating = false;
|
|
||||||
lv_label_set_text_fmt(objects.temp_txt, "%2.1f °C", glblData.settemp);
|
lv_label_set_text_fmt(objects.temp_txt, "%2.1f °C", glblData.settemp);
|
||||||
|
}
|
||||||
|
void unzoomFinishedCB(lv_anim_t *var) {
|
||||||
|
lv_label_set_text_fmt(objects.temp_txt, "%2.1f °C", glblData.temp);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void checkZoomState(void){
|
||||||
|
if (zoomed && !arc_pressed && (millis() - last_press_time) > 3000) {
|
||||||
|
zoomed = false;
|
||||||
|
lv_anim_t a;
|
||||||
|
lv_anim_init(&a);
|
||||||
|
lv_anim_set_var(&a, objects.temp_txt);
|
||||||
|
lv_anim_set_values(&a, 255, 0);
|
||||||
|
lv_anim_set_duration(&a, 200);
|
||||||
|
lv_anim_set_exec_cb(&a, zoomAniWrapper);
|
||||||
|
lv_anim_set_path_cb(&a, lv_anim_path_ease_in_out);
|
||||||
|
lv_anim_set_completed_cb(&a, unzoomFinishedCB);
|
||||||
|
lv_anim_start(&a);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void action_zoom_set_temp(lv_event_t *e) {
|
void action_zoom_set_temp(lv_event_t *e) {
|
||||||
if ((int)lv_event_get_user_data(e) == 1) {
|
if ((int)lv_event_get_user_data(e) == 1) {
|
||||||
if (arc_pressed == false && animating == false) {
|
if (arc_pressed == false && zoomed == false) {
|
||||||
animating = true;
|
zoomed = true;
|
||||||
lv_anim_t a;
|
lv_anim_t a;
|
||||||
lv_anim_init(&a);
|
lv_anim_init(&a);
|
||||||
lv_anim_set_var(&a, objects.temp_txt);
|
lv_anim_set_var(&a, objects.temp_txt);
|
||||||
@ -362,23 +376,13 @@ void action_zoom_set_temp(lv_event_t *e) {
|
|||||||
lv_anim_set_duration(&a, 200);
|
lv_anim_set_duration(&a, 200);
|
||||||
lv_anim_set_exec_cb(&a, zoomAniWrapper);
|
lv_anim_set_exec_cb(&a, zoomAniWrapper);
|
||||||
lv_anim_set_path_cb(&a, lv_anim_path_ease_in_out);
|
lv_anim_set_path_cb(&a, lv_anim_path_ease_in_out);
|
||||||
lv_anim_set_completed_cb(&a, zomFinishedCB);
|
lv_anim_set_completed_cb(&a, zoomFinishedCB);
|
||||||
lv_anim_start(&a);
|
lv_anim_start(&a);
|
||||||
}
|
}
|
||||||
|
arc_pressed = true;
|
||||||
|
last_press_time = millis();
|
||||||
} else {
|
} else {
|
||||||
if (arc_pressed == true && animating == false) {
|
arc_pressed = false;
|
||||||
animating = true;
|
|
||||||
lv_anim_t a;
|
|
||||||
lv_anim_init(&a);
|
|
||||||
lv_anim_set_var(&a, objects.temp_txt);
|
|
||||||
lv_anim_set_values(&a, 255, 0);
|
|
||||||
lv_anim_set_delay(&a, 3000);
|
|
||||||
lv_anim_set_duration(&a, 200);
|
|
||||||
lv_anim_set_exec_cb(&a, zoomAniWrapper);
|
|
||||||
lv_anim_set_path_cb(&a, lv_anim_path_ease_in_out);
|
|
||||||
lv_anim_set_completed_cb(&a, zomFinishedCB);
|
|
||||||
lv_anim_start(&a);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// lv_label_set_text_fmt(objects.temp_txt,"%2.1f
|
// lv_label_set_text_fmt(objects.temp_txt,"%2.1f
|
||||||
// °C",lv_arc_get_value(objects.temp_arc)/2.0);
|
// °C",lv_arc_get_value(objects.temp_arc)/2.0);
|
||||||
@ -390,7 +394,7 @@ static void anim_height_cb(void *var, int32_t v) {
|
|||||||
lv_obj_set_height(obj, v);
|
lv_obj_set_height(obj, v);
|
||||||
}
|
}
|
||||||
|
|
||||||
void action_switch_screens(lv_event_t *e) {
|
void action_switch_charts(lv_event_t *e) {
|
||||||
lv_dir_t gestDir = lv_indev_get_gesture_dir(lv_indev_get_act());
|
lv_dir_t gestDir = lv_indev_get_gesture_dir(lv_indev_get_act());
|
||||||
lastChartPt.x = -1; // clear labels on chart change
|
lastChartPt.x = -1; // clear labels on chart change
|
||||||
int32_t chartheight = lv_obj_get_height(objects.chart);
|
int32_t chartheight = lv_obj_get_height(objects.chart);
|
||||||
@ -423,29 +427,29 @@ void action_switch_screens(lv_event_t *e) {
|
|||||||
}
|
}
|
||||||
void showChartScreen(lv_event_t *e) {
|
void showChartScreen(lv_event_t *e) {
|
||||||
if (ui_getCurrentScreen() != objects.chartScr) {
|
if (ui_getCurrentScreen() != objects.chartScr) {
|
||||||
create_screen_chart();
|
|
||||||
loadChart(ui_getCurrentChart());
|
|
||||||
update_status();
|
|
||||||
update_wifi_strength(glblData.wifiStrength, glblData.wifiMode);
|
|
||||||
}
|
|
||||||
objects.debugScr = NULL;
|
objects.debugScr = NULL;
|
||||||
objects.mainScr = NULL;
|
objects.mainScr = NULL;
|
||||||
objects.rolloScr = NULL;
|
objects.rolloScr = NULL;
|
||||||
objects.menuScr = NULL;
|
objects.menuScr = NULL;
|
||||||
objects.rolloPosScr = NULL;
|
objects.rolloPosScr = NULL;
|
||||||
|
create_screen_chart();
|
||||||
|
loadChart(ui_getCurrentChart());
|
||||||
|
update_status();
|
||||||
|
update_wifi_strength(glblData.wifiStrength, glblData.wifiMode);
|
||||||
|
}
|
||||||
loadScreen(objects.chartScr);
|
loadScreen(objects.chartScr);
|
||||||
}
|
}
|
||||||
void showMenuScreen(lv_event_t *e) {
|
void showMenuScreen(lv_event_t *e) {
|
||||||
if (ui_getCurrentScreen() != objects.menuScr) {
|
if (ui_getCurrentScreen() != objects.menuScr) {
|
||||||
create_screen_menu();
|
|
||||||
update_status();
|
|
||||||
update_wifi_strength(glblData.wifiStrength, glblData.wifiMode);
|
|
||||||
}
|
|
||||||
objects.debugScr = NULL;
|
objects.debugScr = NULL;
|
||||||
objects.mainScr = NULL;
|
objects.mainScr = NULL;
|
||||||
objects.rolloScr = NULL;
|
objects.rolloScr = NULL;
|
||||||
objects.chartScr = NULL;
|
objects.chartScr = NULL;
|
||||||
objects.rolloPosScr = NULL;
|
objects.rolloPosScr = NULL;
|
||||||
|
create_screen_menu();
|
||||||
|
update_status();
|
||||||
|
update_wifi_strength(glblData.wifiStrength, glblData.wifiMode);
|
||||||
|
}
|
||||||
loadScreen(objects.menuScr);
|
loadScreen(objects.menuScr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -460,6 +464,11 @@ void toggleRolloChooser(lv_event_t *e) {
|
|||||||
|
|
||||||
void showRolloScreen(lv_event_t *e) {
|
void showRolloScreen(lv_event_t *e) {
|
||||||
if (ui_getCurrentScreen() != objects.rolloScr) {
|
if (ui_getCurrentScreen() != objects.rolloScr) {
|
||||||
|
objects.debugScr = NULL;
|
||||||
|
objects.mainScr = NULL;
|
||||||
|
objects.chartScr = NULL;
|
||||||
|
objects.menuScr = NULL;
|
||||||
|
objects.rolloPosScr = NULL;
|
||||||
create_screen_rollos();
|
create_screen_rollos();
|
||||||
update_status();
|
update_status();
|
||||||
update_wifi_strength(glblData.wifiStrength, glblData.wifiMode);
|
update_wifi_strength(glblData.wifiStrength, glblData.wifiMode);
|
||||||
@ -476,16 +485,16 @@ void showRolloScreen(lv_event_t *e) {
|
|||||||
setRolloListText();
|
setRolloListText();
|
||||||
// lv_dropdown_add_option(objects.deviceDropdown, "Alle",
|
// lv_dropdown_add_option(objects.deviceDropdown, "Alle",
|
||||||
// LV_DROPDOWN_POS_LAST);
|
// LV_DROPDOWN_POS_LAST);
|
||||||
objects.debugScr = NULL;
|
|
||||||
objects.mainScr = NULL;
|
|
||||||
objects.chartScr = NULL;
|
|
||||||
objects.menuScr = NULL;
|
|
||||||
objects.rolloPosScr = NULL;
|
|
||||||
loadScreen(objects.rolloScr);
|
loadScreen(objects.rolloScr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void showRolloPosScreen(lv_event_t *e) {
|
void showRolloPosScreen(lv_event_t *e) {
|
||||||
if (ui_getCurrentScreen() != objects.rolloPosScr) {
|
if (ui_getCurrentScreen() != objects.rolloPosScr) {
|
||||||
|
objects.debugScr = NULL;
|
||||||
|
objects.mainScr = NULL;
|
||||||
|
objects.chartScr = NULL;
|
||||||
|
objects.menuScr = NULL;
|
||||||
|
objects.rolloScr = NULL;
|
||||||
create_screen_rolloPos();
|
create_screen_rolloPos();
|
||||||
update_status();
|
update_status();
|
||||||
update_wifi_strength(glblData.wifiStrength, glblData.wifiMode);
|
update_wifi_strength(glblData.wifiStrength, glblData.wifiMode);
|
||||||
@ -497,16 +506,16 @@ void showRolloPosScreen(lv_event_t *e) {
|
|||||||
lv_obj_send_event(objects.rolloRot,LV_EVENT_VALUE_CHANGED,NULL);
|
lv_obj_send_event(objects.rolloRot,LV_EVENT_VALUE_CHANGED,NULL);
|
||||||
lv_obj_send_event(objects.rolloPos,LV_EVENT_VALUE_CHANGED,NULL);
|
lv_obj_send_event(objects.rolloPos,LV_EVENT_VALUE_CHANGED,NULL);
|
||||||
}
|
}
|
||||||
objects.debugScr = NULL;
|
|
||||||
objects.mainScr = NULL;
|
|
||||||
objects.chartScr = NULL;
|
|
||||||
objects.menuScr = NULL;
|
|
||||||
objects.rolloScr = NULL;
|
|
||||||
loadScreen(objects.rolloPosScr);
|
loadScreen(objects.rolloPosScr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void showDebugScreen(lv_event_t *e) {
|
void showDebugScreen(lv_event_t *e) {
|
||||||
if (ui_getCurrentScreen() != objects.debugScr) {
|
if (ui_getCurrentScreen() != objects.debugScr) {
|
||||||
|
objects.chartScr = NULL;
|
||||||
|
objects.mainScr = NULL;
|
||||||
|
objects.rolloScr = NULL;
|
||||||
|
objects.menuScr = NULL;
|
||||||
|
objects.rolloPosScr = NULL;
|
||||||
create_screen_debug();
|
create_screen_debug();
|
||||||
update_status();
|
update_status();
|
||||||
update_wifi_strength(glblData.wifiStrength, glblData.wifiMode);
|
update_wifi_strength(glblData.wifiStrength, glblData.wifiMode);
|
||||||
@ -517,11 +526,6 @@ void showDebugScreen(lv_event_t *e) {
|
|||||||
glblData.myIP, Settings::prefs.hostname, Settings::prefs.mqtt_server,
|
glblData.myIP, Settings::prefs.hostname, Settings::prefs.mqtt_server,
|
||||||
Settings::prefs.mqtt_port, Settings::prefs.mqtt_topic, glblData.enBuff);
|
Settings::prefs.mqtt_port, Settings::prefs.mqtt_topic, glblData.enBuff);
|
||||||
}
|
}
|
||||||
objects.chartScr = NULL;
|
|
||||||
objects.mainScr = NULL;
|
|
||||||
objects.rolloScr = NULL;
|
|
||||||
objects.menuScr = NULL;
|
|
||||||
objects.rolloPosScr = NULL;
|
|
||||||
loadScreen(objects.debugScr);
|
loadScreen(objects.debugScr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -529,16 +533,18 @@ void rebootESP(lv_event_t *e) { ESP.restart(); }
|
|||||||
|
|
||||||
void showMainScreen(lv_event_t *e) {
|
void showMainScreen(lv_event_t *e) {
|
||||||
if (ui_getCurrentScreen() != objects.mainScr) {
|
if (ui_getCurrentScreen() != objects.mainScr) {
|
||||||
create_screen_main();
|
|
||||||
update_status();
|
|
||||||
update_wifi_strength(glblData.wifiStrength, glblData.wifiMode);
|
|
||||||
ui_settemp(glblData.settemp);
|
|
||||||
}
|
|
||||||
objects.chartScr = NULL;
|
objects.chartScr = NULL;
|
||||||
objects.debugScr = NULL;
|
objects.debugScr = NULL;
|
||||||
objects.rolloScr = NULL;
|
objects.rolloScr = NULL;
|
||||||
objects.menuScr = NULL;
|
objects.menuScr = NULL;
|
||||||
objects.rolloPosScr = NULL;
|
objects.rolloPosScr = NULL;
|
||||||
|
create_screen_main();
|
||||||
|
resetAnimationFlags();
|
||||||
|
ui_settemp(glblData.settemp);
|
||||||
|
update_status();
|
||||||
|
update_wifi_strength(glblData.wifiStrength, glblData.wifiMode);
|
||||||
|
|
||||||
|
}
|
||||||
loadScreen(objects.mainScr);
|
loadScreen(objects.mainScr);
|
||||||
Serial.println("Main screen loaded");
|
Serial.println("Main screen loaded");
|
||||||
}
|
}
|
||||||
@ -575,7 +581,9 @@ void setRolloListText(void) {
|
|||||||
} else {
|
} else {
|
||||||
txt = "Rollos wählen";
|
txt = "Rollos wählen";
|
||||||
}
|
}
|
||||||
lv_obj_set_style_anim_duration(objects.selDevicesLbl, 50*(lv_text_get_width(txt.c_str(),txt.length(),&symbol_font_12,0)), LV_PART_MAIN);
|
lv_point_t size;
|
||||||
|
lv_text_get_size(&size,txt.c_str(),&symbol_font_12,0,0,LV_COORD_MAX,LV_TEXT_FLAG_NONE);
|
||||||
|
lv_obj_set_style_anim_duration(objects.selDevicesLbl, 50*(size.x), LV_PART_MAIN);
|
||||||
lv_label_set_text(objects.selDevicesLbl, txt.c_str());
|
lv_label_set_text(objects.selDevicesLbl, txt.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -11,8 +11,10 @@ extern "C" {
|
|||||||
|
|
||||||
|
|
||||||
void ui_settemp(float tmp);
|
void ui_settemp(float tmp);
|
||||||
|
void checkZoomState(void);
|
||||||
void action_zoom_set_temp(lv_event_t * e);
|
void action_zoom_set_temp(lv_event_t * e);
|
||||||
void action_switch_screens(lv_event_t * e);
|
void resetAnimationFlags(void);
|
||||||
|
void action_switch_charts(lv_event_t * e);
|
||||||
void showDebugScreen(lv_event_t * e);
|
void showDebugScreen(lv_event_t * e);
|
||||||
void showChartScreen(lv_event_t * e);
|
void showChartScreen(lv_event_t * e);
|
||||||
void showMainScreen(lv_event_t * e);
|
void showMainScreen(lv_event_t * e);
|
||||||
|
|||||||
@ -246,6 +246,7 @@ void rolloCheckbox_finish(void) {
|
|||||||
lv_obj_set_style_text_font(obj, &symbol_font_16,
|
lv_obj_set_style_text_font(obj, &symbol_font_16,
|
||||||
LV_PART_MAIN | LV_STATE_DEFAULT);
|
LV_PART_MAIN | LV_STATE_DEFAULT);
|
||||||
lv_obj_set_style_align(obj, LV_ALIGN_CENTER, LV_PART_MAIN | LV_STATE_DEFAULT);
|
lv_obj_set_style_align(obj, LV_ALIGN_CENTER, LV_PART_MAIN | LV_STATE_DEFAULT);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void create_screen_rollos() {
|
void create_screen_rollos() {
|
||||||
@ -271,7 +272,7 @@ void create_screen_rollos() {
|
|||||||
{ // rolloChooser BTN
|
{ // rolloChooser BTN
|
||||||
lv_obj_t *obj = lv_btn_create(parent_obj);
|
lv_obj_t *obj = lv_btn_create(parent_obj);
|
||||||
lv_obj_set_size(obj, 130, 35);
|
lv_obj_set_size(obj, 130, 35);
|
||||||
lv_obj_set_pos(obj, 55, 20);
|
lv_obj_set_pos(obj, 55, 18);
|
||||||
lv_obj_set_style_bg_color(obj, lv_color_hex(0xff2f3237),
|
lv_obj_set_style_bg_color(obj, lv_color_hex(0xff2f3237),
|
||||||
LV_PART_MAIN | LV_STATE_DEFAULT);
|
LV_PART_MAIN | LV_STATE_DEFAULT);
|
||||||
lv_obj_add_event_cb(obj, toggleRolloChooser, LV_EVENT_RELEASED, NULL);
|
lv_obj_add_event_cb(obj, toggleRolloChooser, LV_EVENT_RELEASED, NULL);
|
||||||
@ -297,8 +298,8 @@ label scrolls back to the initial position*/
|
|||||||
}
|
}
|
||||||
{ // UP BTN
|
{ // UP BTN
|
||||||
lv_obj_t *obj = lv_btn_create(parent_obj);
|
lv_obj_t *obj = lv_btn_create(parent_obj);
|
||||||
lv_obj_set_size(obj, 120, 60);
|
lv_obj_set_size(obj, 120, 50);
|
||||||
lv_obj_align(obj, LV_ALIGN_CENTER, 0, -18);
|
lv_obj_align(obj, LV_ALIGN_CENTER, 0, -35);
|
||||||
lv_obj_set_style_bg_color(obj, lv_color_hex(0xff2f3237),
|
lv_obj_set_style_bg_color(obj, lv_color_hex(0xff2f3237),
|
||||||
LV_PART_MAIN | LV_STATE_DEFAULT);
|
LV_PART_MAIN | LV_STATE_DEFAULT);
|
||||||
lv_obj_add_event_cb(obj, moveRolloUp, LV_EVENT_RELEASED, NULL);
|
lv_obj_add_event_cb(obj, moveRolloUp, LV_EVENT_RELEASED, NULL);
|
||||||
@ -314,8 +315,8 @@ label scrolls back to the initial position*/
|
|||||||
}
|
}
|
||||||
{ // DOWN BTN
|
{ // DOWN BTN
|
||||||
lv_obj_t *obj = lv_btn_create(parent_obj);
|
lv_obj_t *obj = lv_btn_create(parent_obj);
|
||||||
lv_obj_set_size(obj, 120, 60);
|
lv_obj_set_size(obj, 120, 50);
|
||||||
lv_obj_align(obj, LV_ALIGN_CENTER, 0, 52);
|
lv_obj_align(obj, LV_ALIGN_CENTER, 0, 35);
|
||||||
lv_obj_set_style_bg_color(obj, lv_color_hex(0xff2f3237),
|
lv_obj_set_style_bg_color(obj, lv_color_hex(0xff2f3237),
|
||||||
LV_PART_MAIN | LV_STATE_DEFAULT);
|
LV_PART_MAIN | LV_STATE_DEFAULT);
|
||||||
lv_obj_add_event_cb(obj, moveRolloDown, LV_EVENT_RELEASED, NULL);
|
lv_obj_add_event_cb(obj, moveRolloDown, LV_EVENT_RELEASED, NULL);
|
||||||
@ -329,6 +330,17 @@ label scrolls back to the initial position*/
|
|||||||
lv_obj_set_style_align(obj, LV_ALIGN_CENTER,
|
lv_obj_set_style_align(obj, LV_ALIGN_CENTER,
|
||||||
LV_PART_MAIN | LV_STATE_DEFAULT);
|
LV_PART_MAIN | LV_STATE_DEFAULT);
|
||||||
}
|
}
|
||||||
|
{ // infoLBL
|
||||||
|
obj = lv_label_create(parent_obj);
|
||||||
|
objects.temp_txt = obj;
|
||||||
|
lv_obj_align(obj, LV_ALIGN_CENTER, 0, 0);
|
||||||
|
lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
|
||||||
|
lv_label_set_text(obj, SYM_THERMOMETER_HALF"24.5°C(20°C) "SYM_NATURE"18.0°C");
|
||||||
|
lv_obj_set_style_text_font(obj, &symbol_font_12,
|
||||||
|
LV_PART_MAIN | LV_STATE_DEFAULT);
|
||||||
|
lv_obj_set_style_align(obj, LV_ALIGN_CENTER,
|
||||||
|
LV_PART_MAIN | LV_STATE_DEFAULT);
|
||||||
|
}
|
||||||
|
|
||||||
{ // ROLLOPOS BTN
|
{ // ROLLOPOS BTN
|
||||||
lv_obj_t *obj = lv_btn_create(parent_obj);
|
lv_obj_t *obj = lv_btn_create(parent_obj);
|
||||||
@ -356,7 +368,7 @@ label scrolls back to the initial position*/
|
|||||||
lv_obj_align(obj, LV_ALIGN_CENTER, -95, 0);
|
lv_obj_align(obj, LV_ALIGN_CENTER, -95, 0);
|
||||||
lv_obj_set_style_bg_color(obj, lv_color_hex(0xff2f3237),
|
lv_obj_set_style_bg_color(obj, lv_color_hex(0xff2f3237),
|
||||||
LV_PART_MAIN | LV_STATE_DEFAULT);
|
LV_PART_MAIN | LV_STATE_DEFAULT);
|
||||||
lv_obj_add_event_cb(obj, showMenuScreen, LV_EVENT_RELEASED, NULL);
|
lv_obj_add_event_cb(obj, showMainScreen, LV_EVENT_RELEASED, NULL);
|
||||||
|
|
||||||
lv_obj_t *parent_obj = obj;
|
lv_obj_t *parent_obj = obj;
|
||||||
|
|
||||||
@ -373,6 +385,7 @@ label scrolls back to the initial position*/
|
|||||||
{
|
{
|
||||||
lv_obj_t *main_cont = lv_obj_create(parent_obj);
|
lv_obj_t *main_cont = lv_obj_create(parent_obj);
|
||||||
objects.deviceDropdown = main_cont;
|
objects.deviceDropdown = main_cont;
|
||||||
|
lv_obj_remove_flag(main_cont, LV_OBJ_FLAG_SCROLL_ELASTIC);
|
||||||
lv_obj_set_flex_flow(main_cont, LV_FLEX_FLOW_COLUMN);
|
lv_obj_set_flex_flow(main_cont, LV_FLEX_FLOW_COLUMN);
|
||||||
lv_obj_add_event_cb(main_cont, rolloChanged, LV_EVENT_CLICKED, 0);
|
lv_obj_add_event_cb(main_cont, rolloChanged, LV_EVENT_CLICKED, 0);
|
||||||
lv_obj_add_flag(main_cont, LV_OBJ_FLAG_HIDDEN);
|
lv_obj_add_flag(main_cont, LV_OBJ_FLAG_HIDDEN);
|
||||||
@ -651,7 +664,7 @@ void create_screen_chart() {
|
|||||||
objects.chartScr = obj;
|
objects.chartScr = obj;
|
||||||
lv_obj_set_pos(obj, 0, 0);
|
lv_obj_set_pos(obj, 0, 0);
|
||||||
lv_obj_set_size(obj, 240, 240);
|
lv_obj_set_size(obj, 240, 240);
|
||||||
lv_obj_add_event_cb(obj, action_switch_screens, LV_EVENT_GESTURE, (void *)1);
|
lv_obj_add_event_cb(obj, action_switch_charts, LV_EVENT_GESTURE, (void *)1);
|
||||||
lv_obj_set_style_bg_color(obj, lv_color_hex(0xff000000),
|
lv_obj_set_style_bg_color(obj, lv_color_hex(0xff000000),
|
||||||
LV_PART_MAIN | LV_STATE_DEFAULT);
|
LV_PART_MAIN | LV_STATE_DEFAULT);
|
||||||
{
|
{
|
||||||
|
|||||||
@ -17,7 +17,7 @@ Arduino_GC9A01 *gfx =
|
|||||||
TouchDrvCSTXXX touch;
|
TouchDrvCSTXXX touch;
|
||||||
Ticker fadeTicker;
|
Ticker fadeTicker;
|
||||||
bool isPressed = false, sleeping = false;
|
bool isPressed = false, sleeping = false;
|
||||||
unsigned long lastTouch;
|
unsigned long lastTouch=0, lastAniTick=0;
|
||||||
static lv_obj_t *currentScreen = NULL;
|
static lv_obj_t *currentScreen = NULL;
|
||||||
static enum ChartsEnum currentChart = CHART_ID_TEMP;
|
static enum ChartsEnum currentChart = CHART_ID_TEMP;
|
||||||
/*
|
/*
|
||||||
@ -136,6 +136,11 @@ void ui_tick() {
|
|||||||
lv_task_handler(); // let the GUI do its work
|
lv_task_handler(); // let the GUI do its work
|
||||||
sleeping = false;
|
sleeping = false;
|
||||||
isPressed = false;
|
isPressed = false;
|
||||||
|
}else{
|
||||||
|
if(currentScreen == objects.mainScr && millis() - lastAniTick > 100){
|
||||||
|
lastAniTick = millis();
|
||||||
|
checkZoomState();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user