Skip to content

Commit

Permalink
improved logging
Browse files Browse the repository at this point in the history
  • Loading branch information
KlausMu committed May 10, 2024
1 parent 8f0ceeb commit 8db3cef
Show file tree
Hide file tree
Showing 18 changed files with 246 additions and 161 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ int lastActiveGUIlistIndex;

void init_preferences_HAL(void) {
// set some values for tests
activeScene = ""; // "Off", "TV", "Fire TV", "Chromecast", "Apple TV";
activeGUIname = ""; // "Scene selection", "Smart Home", "Settings", "IR Receiver" // "Numpad", "Apple TV"
activeGUIlist = MAIN_GUI_LIST; // MAIN_GUI_LIST, SCENE_GUI_LIST;
activeScene = ""; // "Off", "TV", "Fire TV", "Chromecast", "Apple TV";
activeGUIname = "Scene selection"; // "Scene selection", "Smart Home", "Settings", "IR Receiver" // "Numpad", "Apple TV"
activeGUIlist = MAIN_GUI_LIST; // MAIN_GUI_LIST, SCENE_GUI_LIST;
lastActiveGUIlistIndex = 0;
}
void save_preferences_HAL(void) {
Expand Down
16 changes: 10 additions & 6 deletions Platformio/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ build_flags =
-D USE_SCENE_SPECIFIC_GUI_LIST=1
-D SCR_WIDTH=${env.custom_screen_width}
-D SCR_HEIGHT=${env.custom_screen_heigth}
;-D OMOTE_LOG_LEVEL=OMOTE_LOG_LEVEL_NONE
;-D OMOTE_LOG_LEVEL=OMOTE_LOG_LEVEL_ERROR
;-D OMOTE_LOG_LEVEL=OMOTE_LOG_LEVEL_WARN
-D OMOTE_LOG_LEVEL=OMOTE_LOG_LEVEL_INFO
;-D OMOTE_LOG_LEVEL=OMOTE_LOG_LEVEL_DEBUG
;-D OMOTE_LOG_LEVEL=OMOTE_LOG_LEVEL_VERBOSE
;-- lvgl ------------------------------------------------------------------
; lvgl variant 1:
; Don't use lv_conf.h. Tweak params via platfom.ini. See lv_conf_internal.h line 31. Don't change this line.
Expand All @@ -48,13 +54,11 @@ build_flags =
; Enable the log module
-D LV_USE_LOG=1
-D LV_LOG_PRINTF=1
;-D LV_LOG_LEVEL=LV_LOG_LEVEL_TRACE
;-D LV_LOG_LEVEL=LV_LOG_LEVEL_INFO
;-D LV_LOG_LEVEL=LV_LOG_LEVEL_WARN
-D LV_LOG_LEVEL=LV_LOG_LEVEL_ERROR
;-D LV_LOG_LEVEL=LV_LOG_LEVEL_USER
;-D LV_LOG_LEVEL=LV_LOG_LEVEL_NONE
; trace really gives a lot of messages ...
;-D LV_LOG_LEVEL=LV_LOG_LEVEL_USER
-D LV_LOG_LEVEL=LV_LOG_LEVEL_ERROR
;-D LV_LOG_LEVEL=LV_LOG_LEVEL_WARN
;-D LV_LOG_LEVEL=LV_LOG_LEVEL_INFO
;-D LV_LOG_LEVEL=LV_LOG_LEVEL_TRACE
; ---
; Enable asserts if an operation is failed or an invalid data is found.
Expand Down
21 changes: 11 additions & 10 deletions Platformio/src/applicationInternal/commandHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "applicationInternal/commandHandler.h"
#include "applicationInternal/scenes/sceneHandler.h"
#include "applicationInternal/hardware/hardwarePresenter.h"
#include "applicationInternal/omote_log.h"
#include "devices/misc/device_specialCommands.h"
// show WiFi status
#include "applicationInternal/gui/guiBase.h"
Expand Down Expand Up @@ -179,15 +180,15 @@ std::string convertStringListToString(std::list<std::string> listOfStrings) {
void executeCommandWithData(uint16_t command, commandData commandData, std::string additionalPayload = "") {
switch (commandData.commandHandler) {
case IR: {
// Serial.printf(" generic IR, payloads %s\r\n", convertStringListToString(commandData.commandPayloads).c_str());
omote_log_v(" generic IR, payloads %s\r\n", convertStringListToString(commandData.commandPayloads).c_str());

// we received a comma separated list of strings
// the first string is the IR protocol, the second is the payload to be sent
std::list<std::string>::iterator it = commandData.commandPayloads.begin();
// get protocol and erase first element in list
std::string protocol = *it;
it = commandData.commandPayloads.erase(it);
// Serial.printf(" protocol %s, payload %s\r\n", protocol.c_str(), convertStringListToString(commandData.commandPayloads).c_str());
omote_log_v(" protocol %s, payload %s\r\n", protocol.c_str(), convertStringListToString(commandData.commandPayloads).c_str());

sendIRcode((IRprotocols)std::stoi(protocol), commandData.commandPayloads, additionalPayload);
break;
Expand All @@ -204,7 +205,7 @@ void executeCommandWithData(uint16_t command, commandData commandData, std::stri
} else {
payload = additionalPayload;
}
Serial.printf("execute: will send MQTT, topic '%s', payload '%s'\r\n", topic.c_str(), payload.c_str());
omote_log_d("execute: will send MQTT, topic '%s', payload '%s'\r\n", topic.c_str(), payload.c_str());
publishMQTTMessage(topic.c_str(), payload.c_str());
break;
}
Expand All @@ -219,30 +220,30 @@ void executeCommandWithData(uint16_t command, commandData commandData, std::stri
if (additionalPayload != "") {
payload = additionalPayload;
}
Serial.printf("execute: will send BLE keyboard command, command '%u', payload '%s'\r\n", command, payload.c_str());
omote_log_d("execute: will send BLE keyboard command, command '%u', payload '%s'\r\n", command, payload.c_str());
keyboard_ble_executeCommand(command, payload);
break;
}
#endif

case SCENE: {
// let the sceneHandler do the scene stuff
Serial.printf("execute: will send scene command to the sceneHandler\r\n");
omote_log_d("execute: will send scene command to the sceneHandler\r\n");
handleScene(command, commandData, additionalPayload);
break;
}

case GUI: {
// let the sceneHandler find and show the gui
Serial.printf("execute: will send gui command to the sceneHandler\r\n");
omote_log_d("execute: will send gui command to the sceneHandler\r\n");
handleGUI(command, commandData, additionalPayload);
break;
}

case SPECIAL: {
if (command == MY_SPECIAL_COMMAND) {
// do your special command here
Serial.printf("execute: could execute a special command here, if you define one\r\n");
omote_log_d("execute: could execute a special command here, if you define one\r\n");

}
break;
Expand All @@ -253,14 +254,14 @@ void executeCommandWithData(uint16_t command, commandData commandData, std::stri
void executeCommand(uint16_t command, std::string additionalPayload) {
try {
if (commands.count(command) > 0) {
Serial.printf("command: will execute command '%u' with additionalPayload '%s'\r\n", command, additionalPayload.c_str());
omote_log_d("command: will execute command '%u' with additionalPayload '%s'\r\n", command, additionalPayload.c_str());
executeCommandWithData(command, commands.at(command), additionalPayload);
} else {
Serial.printf("command: command '%u' not found\r\n", command);
omote_log_w("command: command '%u' not found\r\n", command);
}
}
catch (const std::out_of_range& oor) {
Serial.printf("executeCommand: internal error, command not registered\r\n");
omote_log_e("executeCommand: internal error, command not registered\r\n");
}
}

Expand Down
9 changes: 5 additions & 4 deletions Platformio/src/applicationInternal/gui/guiBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "applicationInternal/gui/guiMemoryOptimizer.h"
// for changing to scene Selection gui
#include "applicationInternal/commandHandler.h"
#include "applicationInternal/omote_log.h"
#include "scenes/scene__default.h"

lv_color_t color_primary = lv_color_hex(0x303030); // gray
Expand Down Expand Up @@ -45,7 +46,7 @@ void pageIndicator_navigate_event_cb(lv_event_t* e) {

// callback when sceneLabel or pageIndicator was clicked
void sceneLabel_or_pageIndicator_event_cb(lv_event_t* e) {
Serial.println("- Scene selection: sceneLabel or pageIndicator clicked received for navigating to scene selection page");
omote_log_d("- Scene selection: sceneLabel or pageIndicator clicked received for navigating to scene selection page\r\n");
executeCommand(SCENE_SELECTION);
}

Expand All @@ -54,7 +55,7 @@ void screen_gesture_event_cb(lv_event_t* e) {
lv_obj_t* screen = lv_event_get_current_target(e);
lv_dir_t dir = lv_indev_get_gesture_dir(lv_indev_get_act());
if (dir == LV_DIR_BOTTOM) {
Serial.println("- Scene selection: swipe down received for navigating to scene selection page");
omote_log_d("- Scene selection: swipe down received for navigating to scene selection page\r\n");
executeCommand(SCENE_SELECTION);
}
}
Expand All @@ -77,7 +78,7 @@ void tabview_content_is_scrolling_event_cb(lv_event_t* e){
if ((tabviewX >= 475) && (tabviewX <= 480)) {tabviewX = 480;}
// we need 158 more (the size of one page indicator), because we always have one more page indicator at the beginning and at the end (so normally 5 when having 3 tabs)
int16_t panelX = tabviewX * bias - offset + 158;
// Serial.printf("scroll %d to %d\r\n", tabviewX, panelX);
omote_log_v("scroll %d to %d\r\n", tabviewX, panelX);
lv_obj_scroll_to_x(panel, panelX, LV_ANIM_OFF);
// lv_obj_scroll_to_x(panel, lv_obj_get_scroll_x(tabviewContent) * bias - offset, LV_ANIM_OFF);
}
Expand Down Expand Up @@ -118,7 +119,7 @@ void tabview_tab_changed_event_cb(lv_event_t* e) {
lv_anim_set_ready_cb(anim, tabview_animation_ready_cb);
} else {
// Swipe is complete, no additional animation is needed. Most likely only possible in simulator
Serial.println("Change of tab detected, without animation at the end. Will directly do my job after sliding.");
omote_log_d("Change of tab detected, without animation at the end. Will directly do my job after sliding.\r\n");
guis_doTabCreationAfterSliding(newTabID);
}
}
Expand Down
Loading

0 comments on commit 8db3cef

Please sign in to comment.