Minor tweaks

-add fontConv
-make rolloPos display current position of (first) selected rollo
-usability enhancements and fixes
-increase max. number of Rollos
-TODO: ADD METHOD TO SAVE DESIRED LOWER END POSITION
This commit is contained in:
Moirtz Wagner 2025-11-17 20:55:11 +01:00
parent b487cd1e2e
commit 20601a7ecd
12 changed files with 5602 additions and 21 deletions

5546
Bootstrap_Icons_34.c Normal file

File diff suppressed because it is too large Load Diff

BIN
LVGL_FontGen.zip Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,4 +1,5 @@
#include "tahoma.h" #include "tahoma.h"
#include "settings.h"
extern constexpr char Tahoma::serverURL[]; extern constexpr char Tahoma::serverURL[];
extern Tahoma::rolloCommand_t Tahoma::movement[]; extern Tahoma::rolloCommand_t Tahoma::movement[];
Tahoma::Tahoma(void) {} Tahoma::Tahoma(void) {}
@ -10,7 +11,8 @@ uint8_t Tahoma::getMyDevices(bool _force_update) {
if (!numDevs || _force_update) { if (!numDevs || _force_update) {
HTTPClient http; // Create an HTTP client object HTTPClient http; // Create an HTTP client object
String url = serverURL; String url = serverURL;
url += "?action=myactors"; // Construct the URL to fetch all devices url += "?action=myactors&filter=";
url += Settings::prefs.hostname; // 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 > 0) { // Check if the request was successful
@ -27,6 +29,7 @@ uint8_t Tahoma::getMyDevices(bool _force_update) {
doc[i]["name"] doc[i]["name"]
.as<String>(); // Get the device URL from the JSON response .as<String>(); // Get the device URL from the JSON response
devicelist[i].index = doc[i]["id"]; devicelist[i].index = doc[i]["id"];
devicelist[i].selected = false;
numDevs++; numDevs++;
} }
} }
@ -42,25 +45,38 @@ uint8_t Tahoma::getMyDevices(bool _force_update) {
return numDevs; return numDevs;
} }
bool Tahoma::isDeviceSelected(uint8_t deviceIndex) {
return devicelist[deviceIndex].selected;
}
Tahoma::rolloCommand_t Tahoma::getPos(int8_t deviceIndex) { Tahoma::rolloCommand_t Tahoma::getPos(int8_t deviceIndex) {
rolloCommand_t pos = {0}; rolloCommand_t pos = {0};
if (deviceIndex == -1) if(deviceIndex < 0){
deviceIndex = currentDevIndex; for(uint8_t i=0; i<numDevs;i++){
if(devicelist[i].selected){
deviceIndex = i;
break;
}
}
}
if (deviceIndex < numDevs) { if (deviceIndex < numDevs) {
HTTPClient http; // Create an HTTP client object HTTPClient http; // Create an HTTP client object
String url = serverURL; String url = serverURL;
url += "?action=pos&device=" + url += "?action=pos&device=" +
String(devicelist[deviceIndex] String(devicelist[deviceIndex]
.index); // Construct the URL to fetch all devices .index); // Construct the URL to fetch all devices
Serial.println(url); Serial.println(url);
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 > 0) { // Check if the request was successful
JsonDocument doc; // Create a JSON document to parse the response JsonDocument doc; // Create a JSON document to parse the response
String response = http.getString(); // Get the response as a string String response = http.getString(); // Get the response as a string
if (!deserializeJson(doc, response)) { // Check if the JSON was decoded wthout error if (!deserializeJson(
doc, response)) { // Check if the JSON was decoded wthout error
Serial.println("doc has content"); Serial.println("doc has content");
pos.rotation = doc["rotation"].as<uint8_t>(); // Get the device URL from the JSON response pos.rotation =
doc["rotation"]
.as<uint8_t>(); // Get the device URL from the JSON response
pos.position = doc["position"].as<uint8_t>(); pos.position = doc["position"].as<uint8_t>();
Serial.println(pos.rotation); Serial.println(pos.rotation);
Serial.println(pos.position); Serial.println(pos.position);
@ -136,6 +152,14 @@ uint8_t Tahoma::sendMove(uint8_t deviceIndex, uint8_t position,
return ret; return ret;
} }
void Tahoma::moveSelected(uint8_t position, uint8_t rotation) {
for (uint8_t i = 0; i < numDevs; i++) {
if (devicelist[i].selected) {
sendMove(i, position, rotation);
}
}
}
uint8_t Tahoma::sendfinalRot(uint8_t deviceIndex) { uint8_t Tahoma::sendfinalRot(uint8_t deviceIndex) {
uint8_t ret = 0; uint8_t ret = 0;
HTTPClient http; // Create an HTTP client object HTTPClient http; // Create an HTTP client object
@ -159,13 +183,12 @@ uint8_t Tahoma::sendfinalRot(uint8_t deviceIndex) {
return ret; return ret;
} }
void Tahoma::setCurrentDev(uint8_t i) { void Tahoma::selectDev(uint8_t i,bool _select) {
if (i <= numDevs) { if (i <= numDevs) {
currentDevIndex = i; devicelist[i].selected = _select;
} }
} }
uint8_t Tahoma::getCurrentDev() { return currentDevIndex; }
void Tahoma::loop(void) { void Tahoma::loop(void) {
for (uint8_t i = 0; i < numDevs; i++) { for (uint8_t i = 0; i < numDevs; i++) {

View File

@ -7,7 +7,7 @@
#include <HTTPClient.h> #include <HTTPClient.h>
#include <Ticker.h> #include <Ticker.h>
#include <ArduinoJson.h> // Include the ArduinoJson library for JSON parsing #include <ArduinoJson.h> // Include the ArduinoJson library for JSON parsing
#define MAX_NUM_DEVICES 5 // Maximum number of devices to fetch #define MAX_NUM_DEVICES 11 // Maximum number of devices to fetch
class Tahoma { class Tahoma {
public: public:
@ -22,6 +22,7 @@ typedef union {
typedef struct { typedef struct {
String name; // Device name String name; // Device name
uint16_t index; // Device URL uint16_t index; // Device URL
bool selected;
} device_t; } device_t;
// Constructor with hostname and token // Constructor with hostname and token
// Initializes the Tahoma object with the provided hostname and token // Initializes the Tahoma object with the provided hostname and token
@ -33,14 +34,14 @@ typedef union {
rolloCommand_t getPos(int8_t deviceIndex=-1); rolloCommand_t getPos(int8_t deviceIndex=-1);
uint8_t sendMove(uint8_t deviceIndex, uint8_t position, uint8_t rotation); uint8_t sendMove(uint8_t deviceIndex, uint8_t position, uint8_t rotation);
uint8_t sendfinalRot(uint8_t deviceIndex); uint8_t sendfinalRot(uint8_t deviceIndex);
void setCurrentDev(uint8_t i); void moveSelected(uint8_t position, uint8_t rotation);
uint8_t getCurrentDev(); void selectDev(uint8_t i, bool _selected);
bool isDeviceSelected(uint8_t deviceIndex);
void loop(void); void loop(void);
device_t devicelist[MAX_NUM_DEVICES]; device_t devicelist[MAX_NUM_DEVICES];
uint8_t numDevs{0}; uint8_t numDevs{0};
static rolloCommand_t movement[MAX_NUM_DEVICES]; static rolloCommand_t movement[MAX_NUM_DEVICES];
private: private:
uint8_t currentDevIndex{0};
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
Ticker movementCheckTicker; Ticker movementCheckTicker;

View File

@ -494,6 +494,8 @@ void showRolloPosScreen(lv_event_t *e) {
Tahoma::rolloCommand_t pos = tahoma.getPos(); Tahoma::rolloCommand_t pos = tahoma.getPos();
lv_slider_set_value(objects.rolloPos, pos.position, LV_ANIM_OFF); lv_slider_set_value(objects.rolloPos, pos.position, LV_ANIM_OFF);
lv_arc_set_value(objects.rolloRot, pos.rotation * 9); lv_arc_set_value(objects.rolloRot, pos.rotation * 9);
lv_obj_send_event(objects.rolloRot,LV_EVENT_VALUE_CHANGED,NULL);
lv_obj_send_event(objects.rolloPos,LV_EVENT_VALUE_CHANGED,NULL);
} }
objects.debugScr = NULL; objects.debugScr = NULL;
objects.mainScr = NULL; objects.mainScr = NULL;
@ -573,7 +575,7 @@ void setRolloListText(void) {
} else { } else {
txt = "Rollos wählen"; txt = "Rollos wählen";
} }
lv_obj_set_style_anim_duration(objects.selDevicesLbl, 70*(lv_text_get_width(txt.c_str(),txt.length(),&symbol_font_12,0)-100), LV_PART_MAIN); 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_label_set_text(objects.selDevicesLbl, txt.c_str()); lv_label_set_text(objects.selDevicesLbl, txt.c_str());
} }

View File

@ -216,15 +216,17 @@ void create_screen_menu() {
void rolloCheckbox_add(const char *txt, void *_tahomaDevice, bool _checked) { void rolloCheckbox_add(const char *txt, void *_tahomaDevice, bool _checked) {
lv_obj_t *obj = lv_checkbox_create(objects.deviceDropdown); lv_obj_t *obj = lv_checkbox_create(objects.deviceDropdown);
lv_obj_set_size(obj, LV_SIZE_CONTENT, 25);
lv_obj_set_style_min_width(obj,lv_pct(95),LV_PART_MAIN);
lv_checkbox_set_text(obj, txt); lv_checkbox_set_text(obj, txt);
lv_obj_set_user_data(obj, _tahomaDevice); lv_obj_set_user_data(obj, _tahomaDevice);
lv_obj_set_style_bg_image_src(obj, SYM_CHECK, lv_obj_set_style_bg_image_src(obj, SYM_CHECK,
LV_PART_INDICATOR | LV_STATE_CHECKED); LV_PART_INDICATOR | LV_STATE_CHECKED);
lv_obj_set_style_border_color(obj, lv_color_hex(0xff5D636E), lv_obj_set_style_border_color(obj, lv_color_hex(0xff000000),
LV_PART_INDICATOR | LV_STATE_DEFAULT); LV_PART_INDICATOR | LV_STATE_DEFAULT);
lv_obj_set_style_bg_color(obj, lv_palette_darken(LV_PALETTE_GREEN, 3), lv_obj_set_style_bg_color(obj, lv_palette_darken(LV_PALETTE_GREEN, 3),
LV_PART_INDICATOR | LV_STATE_CHECKED); LV_PART_INDICATOR | LV_STATE_CHECKED);
lv_obj_set_style_text_font(obj,&symbol_font_12,LV_STATE_DEFAULT); lv_obj_set_style_text_font(obj,&symbol_font_16,LV_STATE_DEFAULT| LV_PART_INDICATOR);
if (_checked) if (_checked)
lv_obj_add_state(obj, LV_STATE_CHECKED); lv_obj_add_state(obj, LV_STATE_CHECKED);
lv_obj_add_flag(obj, LV_OBJ_FLAG_EVENT_BUBBLE); lv_obj_add_flag(obj, LV_OBJ_FLAG_EVENT_BUBBLE);
@ -268,7 +270,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, 30); lv_obj_set_size(obj, 130, 35);
lv_obj_set_pos(obj, 55, 20); lv_obj_set_pos(obj, 55, 20);
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);
@ -296,7 +298,7 @@ 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, 60);
lv_obj_align(obj, LV_ALIGN_CENTER, 0, -15); lv_obj_align(obj, LV_ALIGN_CENTER, 0, -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, moveRolloUp, LV_EVENT_RELEASED, NULL); lv_obj_add_event_cb(obj, moveRolloUp, LV_EVENT_RELEASED, NULL);
@ -313,7 +315,7 @@ 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, 60);
lv_obj_align(obj, LV_ALIGN_CENTER, 0, 55); lv_obj_align(obj, LV_ALIGN_CENTER, 0, 52);
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);
@ -623,9 +625,9 @@ void create_screen_rolloPos() {
{ {
lv_obj_t *obj = lv_label_create(parent_obj); lv_obj_t *obj = lv_label_create(parent_obj);
objects.debugTxt = obj; objects.debugTxt = obj;
lv_obj_align(obj, LV_ALIGN_CENTER, 0, -85); lv_obj_align(obj, LV_ALIGN_CENTER, 0, -87);
lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT); lv_obj_set_size(obj, LV_SIZE_CONTENT, LV_SIZE_CONTENT);
lv_label_set_text(obj, "Gewählte Rollos manuell positionieren"); lv_label_set_text(obj, "Gewählte Rollos\nmanuell positionieren");
lv_obj_set_style_text_align(obj, LV_TEXT_ALIGN_CENTER, lv_obj_set_style_text_align(obj, LV_TEXT_ALIGN_CENTER,
LV_PART_MAIN | LV_STATE_DEFAULT); LV_PART_MAIN | LV_STATE_DEFAULT);
lv_obj_set_style_text_font(obj, &symbol_font_12, lv_obj_set_style_text_font(obj, &symbol_font_12,

View File

@ -0,0 +1,7 @@
bootstrap-icons.woff
63001-63004,62219-62221,62611,61829-61832,62719,62711,63478,62925-62930
montserrat-regulat.ttf
0x20-0x80,0xB0, 0xB7,0xA7,0xA9,0xB0-0xB3,0xB5,0xBC-0xBE
äöüÄÖÜ
MaterialSymbolsRounded[FILL,GRAD,opsz,wght].ttf
0xe406,0xf15f,0xea35,0xea99,0xf205,0xf4c4,0xf8ca,0xe798,0xe2cd,0xefd8,0xf157,0xf172,0xf176,0xec0f,0xe818,0xe166,0xe286,0xec1f,0xec12,0xe8c7,0xe764,0xebcc,0xe86c,0xe5ca,0xe8b5,0xe15a,0xf6b9,0xea9a,0xe8b8,0xf418,0xf16f,0xe4ca,0xe4d9,0xef16,0xef10,0xe648,0xf0b0,0xf537,0xf16a,0xf166,0xf16b,0xe585,0xe846,0xf6d7,0xf6d8,0xf8bb,0xf164,0xe2cb,0xf10b,0xe5c5,0xe5c7,0xe5df,0xe5de,0xe984,0xef7d,0xe986,0xe941,0xe313,0xe314,0xe315,0xe316,0xeac3,0xead0,0xeac9,0xeacf,0xe145,0xe5cd,0xe872

BIN
svg_to_font-main.zip Normal file

Binary file not shown.