improved interface with triggering, wifi enhancements

This commit is contained in:
Lurkars
2020-12-12 22:26:37 +01:00
parent c352edbe48
commit fd54320f7d
17 changed files with 199 additions and 144 deletions
+2 -2
View File
@@ -7,9 +7,9 @@ elseif(ENA_INTERFACE_M5STICKC)
elseif(ENA_INTERFACE_M5STICKC_PLUS)
list(APPEND priv_requires "display-st7789" "rtc-bm8563" "imu-mpu6886" "pmu-axp192")
else()
list(APPEND priv_requires "display-ssd1306" "rtc-ds3231") # uncomment for custom device with SSD1306 und DS3231
# list(APPEND priv_requires "display-ssd1306" "rtc-ds3231") # uncomment for custom device with SSD1306 und DS3231
# list(APPEND priv_requires "display-st7735s" "rtc-bm8563" "imu-mpu6886" "pmu-axp192") # uncomment for M5StickC
# list(APPEND priv_requires "display-st7789" "rtc-bm8563" "imu-mpu6886" "pmu-axp192") # uncomment for M5StickC PLUS
list(APPEND priv_requires "display-st7789" "rtc-bm8563" "imu-mpu6886" "pmu-axp192") # uncomment for M5StickC PLUS
endif()
idf_component_register(
+2
View File
@@ -212,6 +212,8 @@ void interface_data_start(void)
interface_register_command_callback(INTERFACE_COMMAND_MID, &interface_data_mid);
interface_register_command_callback(INTERFACE_COMMAND_UP, &interface_data_up);
interface_register_command_callback(INTERFACE_COMMAND_DWN, &interface_data_dwn);
interface_register_command_callback(INTERFACE_COMMAND_RST_LONG, NULL);
interface_register_command_callback(INTERFACE_COMMAND_SET_LONG, NULL);
interface_set_display_function(&interface_data_display);
}
@@ -172,6 +172,8 @@ void interface_datetime_start(void)
interface_register_command_callback(INTERFACE_COMMAND_UP, &interface_datetime_up);
interface_register_command_callback(INTERFACE_COMMAND_DWN, &interface_datetime_dwn);
interface_register_command_callback(INTERFACE_COMMAND_SET, &interface_datetime_set);
interface_register_command_callback(INTERFACE_COMMAND_RST_LONG, NULL);
interface_register_command_callback(INTERFACE_COMMAND_SET_LONG, NULL);
interface_set_display_function(&interface_datetime_display);
interface_set_display_refresh_function(&interface_datetime_display_refresh);
+2
View File
@@ -130,6 +130,8 @@ void interface_debug_start(void)
interface_register_command_callback(INTERFACE_COMMAND_MID, &interface_debug_mid);
interface_register_command_callback(INTERFACE_COMMAND_UP, &interface_debug_up);
interface_register_command_callback(INTERFACE_COMMAND_DWN, &interface_debug_dwn);
interface_register_command_callback(INTERFACE_COMMAND_RST_LONG, NULL);
interface_register_command_callback(INTERFACE_COMMAND_SET_LONG, NULL);
interface_set_display_function(NULL);
+2
View File
@@ -137,6 +137,8 @@ void interface_info_start(void)
interface_register_command_callback(INTERFACE_COMMAND_MID, &interface_info_mid);
interface_register_command_callback(INTERFACE_COMMAND_UP, &interface_info_up);
interface_register_command_callback(INTERFACE_COMMAND_DWN, &interface_info_dwn);
interface_register_command_callback(INTERFACE_COMMAND_RST_LONG, NULL);
interface_register_command_callback(INTERFACE_COMMAND_SET_LONG, NULL);
interface_set_display_function(&interface_info_display);
}
+3 -7
View File
@@ -288,13 +288,6 @@ void interface_input(interface_text_callback callback_rst, interface_text_callba
strcpy(current_char_set, char_set_uppercase);
printf("char_set_uppercase: %d %s\n", strlen(char_set_uppercase), char_set_uppercase);
printf("char_set_lowercase: %d %s\n", strlen(char_set_lowercase), char_set_lowercase);
printf("char_set_numeric: %d %s\n", strlen(char_set_numeric), char_set_numeric);
printf("char_set_special1: %d %s\n", strlen(char_set_special1), char_set_special1);
printf("char_set_special_uppercasecase: %d %s\n", strlen(char_set_special_uppercasecase), char_set_special_uppercasecase);
printf("char_set_special_lowercase: %d %s\n", strlen(char_set_special_lowercase), char_set_special_lowercase);
current_char_index = 0;
current_max_index = 0;
if (current_limit == 0)
@@ -310,8 +303,11 @@ void interface_input(interface_text_callback callback_rst, interface_text_callba
interface_register_command_callback(INTERFACE_COMMAND_RHT, &interface_input_rht);
interface_register_command_callback(INTERFACE_COMMAND_MID, &interface_input_mid);
interface_register_command_callback(INTERFACE_COMMAND_UP, &interface_input_up);
interface_command_callback_set_trigger(INTERFACE_COMMAND_UP);
interface_register_command_callback(INTERFACE_COMMAND_DWN, &interface_input_dwn);
interface_command_callback_set_trigger(INTERFACE_COMMAND_DWN);
interface_register_command_callback(INTERFACE_COMMAND_RST_LONG, &interface_input_mid);
interface_register_command_callback(INTERFACE_COMMAND_SET_LONG, NULL);
interface_set_display_function(&interface_input_display);
}
+2
View File
@@ -41,6 +41,7 @@ void interface_init_label(void)
interface_text_headline_debug.text[EN] = "DEBUG";
interface_text_wifi_scanning.text[EN] = "Scanning...";
interface_text_wifi_nothing.text[EN] = "None...";
interface_text_settings_locale.text[EN] = "Language:";
interface_text_settings_locales[EN].text[EN] = "EN";
@@ -104,6 +105,7 @@ void interface_init_label(void)
interface_text_headline_debug.text[DE] = "DEBUG";
interface_text_wifi_scanning.text[DE] = "Scannen...";
interface_text_wifi_nothing.text[DE] = "Keine...";
interface_text_settings_locale.text[DE] = "Sprache:";
interface_text_settings_locales[EN].text[DE] = "EN";
+2
View File
@@ -139,6 +139,8 @@ void interface_main_start(void)
interface_register_command_callback(INTERFACE_COMMAND_MID, NULL);
interface_register_command_callback(INTERFACE_COMMAND_UP, NULL);
interface_register_command_callback(INTERFACE_COMMAND_DWN, NULL);
interface_register_command_callback(INTERFACE_COMMAND_RST_LONG, NULL);
interface_register_command_callback(INTERFACE_COMMAND_SET_LONG, NULL);
interface_set_display_function(&interface_main_display);
interface_set_display_refresh_function(&interface_main_display_refresh);
+3
View File
@@ -307,8 +307,11 @@ void interface_report_start(void)
interface_register_command_callback(INTERFACE_COMMAND_LFT, &interface_report_lft);
interface_register_command_callback(INTERFACE_COMMAND_RHT, &interface_report_rht);
interface_register_command_callback(INTERFACE_COMMAND_UP, &interface_report_up);
interface_command_callback_set_trigger(INTERFACE_COMMAND_UP);
interface_register_command_callback(INTERFACE_COMMAND_DWN, &interface_report_dwn);
interface_command_callback_set_trigger(INTERFACE_COMMAND_DWN);
interface_register_command_callback(INTERFACE_COMMAND_RST_LONG, &interface_report_mid);
interface_register_command_callback(INTERFACE_COMMAND_SET_LONG, NULL);
interface_set_display_function(&interface_report_display);
}
@@ -194,6 +194,8 @@ void interface_settings_start(void)
interface_register_command_callback(INTERFACE_COMMAND_MID, &interface_settings_mid);
interface_register_command_callback(INTERFACE_COMMAND_UP, &interface_settings_up);
interface_register_command_callback(INTERFACE_COMMAND_DWN, &interface_settings_dwn);
interface_register_command_callback(INTERFACE_COMMAND_RST_LONG, NULL);
interface_register_command_callback(INTERFACE_COMMAND_SET_LONG, NULL);
interface_set_display_function(&interface_settings_display);
}
+42 -18
View File
@@ -28,10 +28,11 @@
#define APS_TO_DISPLAY 3
wifi_ap_record_t ap_info[10];
uint16_t ap_count = 0;
int ap_index = 0;
int ap_selected = 0;
static wifi_ap_record_t ap_info[10];
static uint16_t ap_count = 0;
static int ap_index = 0;
static int ap_selected = 0;
static bool interface_wifi_working = false;
static wifi_config_t current_wifi_config;
@@ -116,14 +117,10 @@ void interface_wifi_dwn(void)
void interface_wifi_display(void)
{
display_menu_headline(interface_get_label_text(&interface_text_headline_wifi), true, 0);
}
void interface_wifi_display_refresh(void)
{
display_menu_headline(interface_get_label_text(&interface_text_headline_wifi), true, 0);
if (ap_count > 0)
{
ena_eke_proxy_resume();
display_clear_line(2, false);
display_clear_line(4, false);
display_clear_line(6, false);
@@ -171,6 +168,38 @@ void interface_wifi_display_refresh(void)
}
}
void interface_wifi_scan(void)
{
if (!interface_wifi_working)
{
interface_wifi_working = true;
memset(ap_info, 0, sizeof(ap_info));
ap_count = 0;
ap_index = 0;
ap_selected = 0;
ena_eke_proxy_pause();
display_clear();
display_menu_headline(interface_get_label_text(&interface_text_headline_wifi), true, 0);
display_text_line_column(interface_get_label_text(&interface_text_wifi_scanning), 4, 1, false);
wifi_controller_scan(ap_info, &ap_count, interface_wifi_display);
ena_eke_proxy_resume();
interface_wifi_working = false;
}
}
void interface_wifi_reconnect(void)
{
if (!interface_wifi_working)
{
interface_wifi_working = true;
wifi_controller_reconnect(NULL);
interface_wifi_working = false;
}
}
void interface_wifi_start(void)
{
interface_register_command_callback(INTERFACE_COMMAND_SET, &interface_wifi_set);
@@ -180,16 +209,11 @@ void interface_wifi_start(void)
interface_register_command_callback(INTERFACE_COMMAND_UP, &interface_wifi_up);
interface_register_command_callback(INTERFACE_COMMAND_DWN, &interface_wifi_dwn);
interface_register_command_callback(INTERFACE_COMMAND_RST, &interface_wifi_mid);
interface_register_command_callback(INTERFACE_COMMAND_SET_LONG, &interface_wifi_scan);
interface_register_command_callback(INTERFACE_COMMAND_RST_LONG, &interface_wifi_reconnect);
interface_set_display_function(&interface_wifi_display);
interface_set_display_refresh_function(&interface_wifi_display_refresh);
interface_set_display_refresh_function(NULL);
memset(ap_info, 0, sizeof(ap_info));
ap_count = 0;
ap_index = 0;
ap_selected = 0;
ena_eke_proxy_pause();
wifi_controller_scan(ap_info, &ap_count);
interface_wifi_scan();
}
+15
View File
@@ -24,6 +24,7 @@
#include "interface.h"
static interface_command_callback command_callbacks[INTERFACE_COMMANDS_SIZE];
static bool command_callback_trigger[INTERFACE_COMMANDS_SIZE];
static interface_display_function current_display_function;
static interface_display_function current_display_refresh_function;
@@ -39,6 +40,12 @@ bool interface_is_idle(void)
void interface_register_command_callback(interface_command_t command, interface_command_callback callback)
{
command_callbacks[command] = callback;
command_callback_trigger[command] = false;
}
void interface_command_callback_set_trigger(interface_command_t command)
{
command_callback_trigger[command] = true;
}
void interface_set_display_function(interface_display_function display_function)
@@ -89,6 +96,14 @@ void interface_execute_command(interface_command_t command)
}
}
void interface_execute_command_trigger(interface_command_t command)
{
if (command_callback_trigger[command])
{
interface_execute_command(command);
}
}
void interface_display_task(void *pvParameter)
{
xTimerStart(interface_idle_timer, 0);
+16 -1
View File
@@ -31,7 +31,7 @@
#define INTERFACE_IDLE_SECONDS CONFIG_ENA_INTERFACE_IDLE_TIME
#define INTERFACE_INPUT_TICKS_MS 20
#define INTERFACE_LONG_STATE_SECONDS 1.0
#define INTERFACE_LONG_STATE_SECONDS 0.6
/**
* @brief available commands
@@ -99,6 +99,7 @@ interface_label_t interface_text_report_success;
interface_label_t interface_text_report_fail;
interface_label_t interface_text_wifi_scanning;
interface_label_t interface_text_wifi_nothing;
interface_label_t interface_text_data_del[6];
@@ -181,6 +182,13 @@ void interface_set_timezone_offset(int timezone_offset);
*/
void interface_register_command_callback(interface_command_t command, interface_command_callback callback);
/**
* @brief set if command is trigger
*
* @param[in] command id of the command to set as trigger
*/
void interface_command_callback_set_trigger(interface_command_t command);
/**
* @brief execute a command
*
@@ -188,6 +196,13 @@ void interface_register_command_callback(interface_command_t command, interface_
*/
void interface_execute_command(interface_command_t command);
/**
* @brief execute a command as trigger
*
* @param[in] command id of the command to trigger
*/
void interface_execute_command_trigger(interface_command_t command);
/**
* @brief set the display function
*