updated interface, added M5Stick (PLUS) support

This commit is contained in:
Lurkars
2020-12-12 14:26:08 +01:00
parent 559ed3762a
commit 0d3fd854f8
43 changed files with 2832 additions and 313 deletions
+16 -8
View File
@@ -1,9 +1,24 @@
set(priv_requires "ena" "ena-eke-proxy" "display" "rtc" "wifi-controller" )
if(CONFIG_ENA_INTERFACE_CUSTOM)
list(APPEND priv_requires "display-ssd1306" "rtc-ds3231")
elseif(ENA_INTERFACE_M5STICKC)
list(APPEND priv_requires "display-st7735s" "rtc-bm8563" "imu-mpu6886" "pmu-axp192")
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-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
endif()
idf_component_register(
SRCS
"interface.c"
"interface-main.c"
"interface-data.c"
"interface-datetime.c"
"interface-debug.c"
"interface-info.c"
"interface-input.c"
"interface-label.c"
@@ -11,12 +26,5 @@ idf_component_register(
"interface-settings.c"
"interface-wifi.c"
INCLUDE_DIRS "."
PRIV_REQUIRES
ena
ena-eke-proxy
display
display-ssd1306
rtc
rtc-ds3231
wifi-controller
PRIV_REQUIRES ${priv_requires}
)
+26
View File
@@ -0,0 +1,26 @@
menu "ENA Interface"
config ENA_INTERFACE_IDLE_TIME
int "Seconds after display turns off on inactivity"
default 15
config ENA_INTERFACE_DEBUG
bool "Adds a debug interface for additional information for device"
default false
choice ENA_INTERFACE_DEVICE
prompt "Choose device"
default ENA_INTERFACE_CUSTOM
config ENA_INTERFACE_CUSTOM
bool "Custom"
config ENA_INTERFACE_M5STICKC
bool "M5StickC"
config ENA_INTERFACE_M5STICKC_PLUS
bool "M5StickC PLUS"
endchoice
endmenu
+48 -27
View File
@@ -49,9 +49,12 @@ void interface_data_set(void)
else
{
confirm_current = false;
display_clear_line( 2, false);
display_clear_line( 4, false);
display_clear_line( 6, false);
display_clear_line(2, false);
display_clear_line(3, false);
display_clear_line(4, false);
display_clear_line(5, false);
display_clear_line(6, false);
display_clear_line(7, false);
}
}
@@ -83,9 +86,19 @@ void interface_data_rst(void)
}
confirm_current = false;
display_clear_line( 2, false);
display_clear_line( 4, false);
display_clear_line( 6, false);
display_clear_line(2, false);
display_clear_line(3, false);
display_clear_line(4, false);
display_clear_line(5, false);
display_clear_line(6, false);
display_clear_line(7, false);
}
else
{
display_clear_line(2, false);
display_clear_line(4, false);
display_clear_line(6, false);
confirm_current = true;
}
}
@@ -96,16 +109,20 @@ void interface_data_lft(void)
void interface_data_rht(void)
{
#if defined(CONFIG_ENA_INTERFACE_DEBUG)
interface_debug_start();
#else
interface_info_start();
#endif
}
void interface_data_mid(void)
{
if (!confirm_current)
{
display_clear_line( 2, false);
display_clear_line( 4, false);
display_clear_line( 6, false);
display_clear_line(2, false);
display_clear_line(4, false);
display_clear_line(6, false);
confirm_current = true;
}
}
@@ -124,9 +141,9 @@ void interface_data_up(void)
current_data_index--;
}
display_clear_line( 2, false);
display_clear_line( 4, false);
display_clear_line( 6, false);
display_clear_line(2, false);
display_clear_line(4, false);
display_clear_line(6, false);
}
void interface_data_dwn(void)
@@ -142,26 +159,28 @@ void interface_data_dwn(void)
current_data_index++;
}
display_clear_line( 2, false);
display_clear_line( 4, false);
display_clear_line( 6, false);
display_clear_line(2, false);
display_clear_line(4, false);
display_clear_line(6, false);
}
void interface_data_display(void)
{
display_menu_headline( interface_get_label_text(&interface_text_headline_data), true, 0);
display_menu_headline(interface_get_label_text(&interface_text_headline_data), true, 0);
if (confirm_current)
{
display_text_line_column( interface_get_label_text(&interface_text_data_del[current_interface_data_state]), 2, 2, false);
display_text_line_column( "?", 2, strlen(interface_get_label_text(&interface_text_data_del[current_interface_data_state])) + 2, false);
display_text_line_column(interface_get_label_text(&interface_text_data_del[current_interface_data_state]), 2, 2, false);
display_text_line_column("?", 2, strlen(interface_get_label_text(&interface_text_data_del[current_interface_data_state])) + 2, false);
display_set_button( interface_get_label_text(&interface_text_button_cancel), true, false);
display_set_button( interface_get_label_text(&interface_text_button_ok), false, true);
display_set_button(interface_get_label_text(&interface_text_button_cancel), true, false);
display_set_button(interface_get_label_text(&interface_text_button_ok), false, true);
}
else
{
display_clear_line( 5, false);
display_clear_line( 7, false);
display_clear_line(2, false);
display_clear_line(4, false);
display_clear_line(6, false);
for (int i = 0; i < 3; i++)
{
int index = i + current_data_index;
@@ -169,10 +188,14 @@ void interface_data_display(void)
{
if (index == current_interface_data_state)
{
display_data( display_gfx_arrow_right, 8, i * 2 + 2, 8, false);
display_data(display_gfx_arrow_right, 8, i * 2 + 2, 8, false);
}
else
{
display_data(display_gfx_clear, 8, i * 2 + 2, 8, false);
}
display_text_line_column( interface_get_label_text(&interface_text_data_del[index]), i * 2 + 2, 2, false);
display_text_line_column(interface_get_label_text(&interface_text_data_del[index]), i * 2 + 2, 2, false);
}
}
}
@@ -189,8 +212,6 @@ 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_set_display_function(&interface_data_display);
interface_set_display_refresh_function(NULL);
ESP_LOGD(INTERFACE_LOG, "start delete data interface");
interface_set_display_function(&interface_data_display);
}
+18 -15
View File
@@ -64,7 +64,6 @@ void interface_datetime_mid(void)
{
current_interface_datetime_state = INTERFACE_DATETIME_STATE_HOUR;
}
ESP_LOGD(INTERFACE_LOG, "datetime to %d", current_interface_datetime_state);
}
void interface_datetime_up(void)
@@ -75,7 +74,6 @@ void interface_datetime_up(void)
tv.tv_sec = curtime;
settimeofday(&tv, NULL);
rtc_set_time(gmtime(&curtime));
ESP_LOGD(INTERFACE_LOG, "increment %d about %u %s", current_interface_datetime_state, interface_datetime_steps[current_interface_datetime_state], ctime(&curtime));
}
void interface_datetime_dwn(void)
@@ -86,37 +84,40 @@ void interface_datetime_dwn(void)
tv.tv_sec = curtime;
settimeofday(&tv, NULL);
rtc_set_time(gmtime(&curtime));
ESP_LOGD(INTERFACE_LOG, "decrement %d about %u %s", current_interface_datetime_state, interface_datetime_steps[current_interface_datetime_state], ctime(&curtime));
}
void interface_datetime_display(void)
{
display_menu_headline(interface_get_label_text(&interface_text_headline_time), true, 0);
}
void interface_datetime_display_refresh(void)
{
static time_t current_timstamp;
static struct tm *current_tm;
static char time_buffer[9];
static char date_buffer[32];
display_menu_headline( interface_get_label_text(&interface_text_headline_time), true, 0);
static char edit_char[3];
static int edit_line = 3;
int edit_length = 2;
int edit_offset = 0;
display_clear_line( edit_line - 1, false);
display_clear_line( edit_line + 1, false);
display_clear_line(edit_line - 1, false);
display_clear_line(edit_line + 1, false);
time(&current_timstamp);
current_tm = gmtime(&current_timstamp);
current_tm->tm_hour = current_tm->tm_hour + (interface_get_timezone_offset()) % 24;
strftime(time_buffer, 16, INTERFACE_FORMAT_TIME, current_tm);
display_text_line_column( time_buffer, 3, 4, false);
display_text_line_column(time_buffer, 3, 4, false);
sprintf(date_buffer, "%02d %s %02d",
current_tm->tm_mday,
interface_get_label_text(&interface_texts_month[current_tm->tm_mon]),
current_tm->tm_year - 100);
display_text_line_column( date_buffer, 6, 4, false);
display_text_line_column(date_buffer, 6, 4, false);
switch (interface_datetime_state())
{
@@ -154,9 +155,11 @@ void interface_datetime_display(void)
break;
}
display_data( display_gfx_arrow_up, 8, edit_line - 1, edit_offset * 8 + 4, false);
display_chars( edit_char, edit_length, edit_line, edit_offset, true);
display_data( display_gfx_arrow_down, 8, edit_line + 1, edit_offset * 8 + 4, false);
display_data(display_gfx_arrow_up, 8, edit_line - 1, edit_offset * 8 + 4, false);
display_chars(edit_char, edit_length, edit_line, edit_offset, true);
display_data(display_gfx_arrow_down, 8, edit_line + 1, edit_offset * 8 + 4, false);
display_menu_headline(interface_get_label_text(&interface_text_headline_time), true, 0);
}
void interface_datetime_start(void)
@@ -164,12 +167,12 @@ void interface_datetime_start(void)
current_interface_datetime_state = INTERFACE_DATETIME_STATE_HOUR;
interface_register_command_callback(INTERFACE_COMMAND_LFT, &interface_datetime_lft);
interface_register_command_callback(INTERFACE_COMMAND_RHT, &interface_datetime_rht);
interface_register_command_callback(INTERFACE_COMMAND_RST, &interface_datetime_mid);
interface_register_command_callback(INTERFACE_COMMAND_MID, &interface_datetime_mid);
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, NULL);
interface_set_display_function(NULL);
interface_set_display_refresh_function(&interface_datetime_display);
ESP_LOGD(INTERFACE_LOG, "start datetime interface");
interface_set_display_function(&interface_datetime_display);
interface_set_display_refresh_function(&interface_datetime_display_refresh);
}
+148
View File
@@ -0,0 +1,148 @@
// Copyright 2020 Lukas Haubaum
//
// Licensed under the GNU Affero General Public License, Version 3;
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// https://www.gnu.org/licenses/agpl-3.0.html
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include <string.h>
#include <time.h>
#include <sys/time.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_log.h"
#include "driver/gpio.h"
#include "display.h"
#include "display-gfx.h"
#if defined(CONFIG_ENA_INTERFACE_M5STICKC) || defined(CONFIG_ENA_INTERFACE_M5STICKC_PLUS)
#include "mpu6886.h"
#include "axp192.h"
#endif
#include "interface.h"
static bool runTask = true;
static TaskHandle_t debugTaskHandle = NULL;
void interface_debug_set(void)
{
runTask = false;
vTaskDelay(100 / portTICK_PERIOD_MS);
vTaskSuspend(debugTaskHandle);
interface_main_start();
}
void interface_debug_rst(void)
{
}
void interface_debug_lft(void)
{
runTask = false;
vTaskDelay(100 / portTICK_PERIOD_MS);
vTaskSuspend(debugTaskHandle);
interface_data_start();
}
void interface_debug_rht(void)
{
runTask = false;
vTaskDelay(100 / portTICK_PERIOD_MS);
vTaskSuspend(debugTaskHandle);
interface_info_start();
}
void interface_debug_mid(void)
{
}
void interface_debug_up(void)
{
}
void interface_debug_dwn(void)
{
}
void interface_debug_task(void *pvParameter)
{
#if defined(CONFIG_ENA_INTERFACE_M5STICKC) || defined(CONFIG_ENA_INTERFACE_M5STICKC_PLUS)
float ax = 0;
float ay = 0;
float az = 0;
float gx = 0;
float gy = 0;
float gz = 0;
#endif
while (1)
{
if (!interface_is_idle() && runTask)
{
#if defined(CONFIG_ENA_INTERFACE_M5STICKC) || defined(CONFIG_ENA_INTERFACE_M5STICKC_PLUS)
mpu6886_get_accel_data(&ax, &ay, &az);
mpu6886_get_gyro_data(&gx, &gy, &gz);
char data_chars[32];
sprintf(data_chars, "acc x:%3.2f", ax);
display_text_line(data_chars, 2, false);
sprintf(data_chars, "acc y:%3.2f", ay);
display_text_line(data_chars, 3, false);
sprintf(data_chars, "acc z:%3.2f", az);
display_text_line(data_chars, 4, false);
sprintf(data_chars, "gyr x:%3.2f", gx);
display_text_line(data_chars, 5, false);
sprintf(data_chars, "gyr y:%3.2f", gy);
display_text_line(data_chars, 6, false);
sprintf(data_chars, "gyr z:%3.2f", gz);
display_text_line(data_chars, 7, false);
float bat_v = axp192_get_bat_voltage();
sprintf(data_chars, "Battery: %.2f V", bat_v);
display_text_line(data_chars, 7, false);
#endif
}
vTaskDelay(10 / portTICK_PERIOD_MS);
}
}
void interface_debug_start(void)
{
interface_register_command_callback(INTERFACE_COMMAND_RST, &interface_debug_rst);
interface_register_command_callback(INTERFACE_COMMAND_SET, &interface_debug_set);
interface_register_command_callback(INTERFACE_COMMAND_LFT, &interface_debug_lft);
interface_register_command_callback(INTERFACE_COMMAND_RHT, &interface_debug_rht);
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_set_display_function(NULL);
display_menu_headline(interface_get_label_text(&interface_text_headline_debug), true, 0);
if (debugTaskHandle == NULL)
{
xTaskCreate(&interface_debug_task, "interface_debug_task", 4096 * 2, NULL, 5, &debugTaskHandle);
}
else
{
vTaskResume(debugTaskHandle);
}
runTask = true;
}
+48 -17
View File
@@ -38,7 +38,11 @@ void interface_info_rst(void)
void interface_info_lft(void)
{
#if defined(CONFIG_ENA_INTERFACE_DEBUG)
interface_debug_start();
#else
interface_data_start();
#endif
}
void interface_info_rht(void)
@@ -58,40 +62,69 @@ void interface_info_dwn(void)
{
}
int interface_info_num_offset(int num)
{
if (num < 10)
{
return 13;
}
else if (num < 100)
{
return 12;
}
else
{
return 11;
}
}
void interface_info_display(void)
{
char data_chars[10];
ena_exposure_summary_t *current_exposure_summary = ena_exposure_current_summary();
char data_chars[16];
display_menu_headline(interface_get_label_text(&interface_text_headline_info), true, 0);
display_text_line_column(interface_get_label_text(&interface_text_info_num_keys), 2, 1, false);
sprintf(data_chars, "%u", ena_storage_beacons_count());
display_text_line_column(data_chars, 2, 9, false);
int num = ena_storage_beacons_count();
sprintf(data_chars, "%u", num);
display_text_line_column(data_chars, 2, interface_info_num_offset(num), false);
ena_exposure_summary_t *current_exposure_summary = ena_exposure_current_summary();
display_text_line_column(interface_get_label_text(&interface_text_info_last_keys), 3, 1, false);
time_t current_timstamp;
time(&current_timstamp);
int max = ena_expore_check_find_min((uint32_t)current_timstamp);
int min = ena_expore_check_find_min((uint32_t)current_timstamp - 60 * 30);
int last30 = max - min;
if (last30 > 0)
{
sprintf(data_chars, "%d", last30);
display_text_line_column(data_chars, 3, interface_info_num_offset(last30), false);
}
display_text_line_column(interface_get_label_text(&interface_text_info_exp_days), 4, 1, false);
sprintf(data_chars, "%d", current_exposure_summary->days_since_last_exposure);
if (current_exposure_summary->days_since_last_exposure < 0)
int last = current_exposure_summary->days_since_last_exposure;
if (last >= 0)
{
display_text_line_column("/", 4, 12, false);
}
else
{
display_text_line_column(data_chars, 4, 12, false);
sprintf(data_chars, "%d", last);
display_text_line_column(data_chars, 4, interface_info_num_offset(last), false);
}
display_text_line_column(interface_get_label_text(&interface_text_info_exp_num), 5, 1, false);
sprintf(data_chars, "%d", current_exposure_summary->num_exposures);
display_text_line_column(data_chars, 5, 12, false);
display_text_line_column(data_chars, 5, interface_info_num_offset(current_exposure_summary->num_exposures), false);
display_text_line_column(interface_get_label_text(&interface_text_info_exp_max), 6, 1, false);
sprintf(data_chars, "%d", current_exposure_summary->max_risk_score);
display_text_line_column(data_chars, 6, 12, false);
display_text_line_column(data_chars, 6, interface_info_num_offset(current_exposure_summary->max_risk_score), false);
display_text_line_column(interface_get_label_text(&interface_text_info_exp_sum), 7, 1, false);
sprintf(data_chars, "%d", current_exposure_summary->risk_score_sum);
display_text_line_column(data_chars, 7, 12, false);
display_text_line_column(data_chars, 7, interface_info_num_offset(current_exposure_summary->risk_score_sum), false);
}
void interface_info_start(void)
@@ -104,8 +137,6 @@ 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_set_display_function(&interface_info_display);
interface_set_display_refresh_function(NULL);
ESP_LOGD(INTERFACE_LOG, "start info interface");
interface_set_display_function(&interface_info_display);
}
+32 -35
View File
@@ -76,7 +76,6 @@ void interface_input_set_char_set(void)
strcpy(current_char_set, char_set_uppercase);
current_char_index = strlen(current_char_set) - strlen(ret);
}
printf("current_char_set: %d %s\n", strlen(current_char_set), current_char_set);
}
void interface_input_set(void)
@@ -152,7 +151,6 @@ void interface_input_mid(void)
}
current_char_index = 0;
current_text[current_cursor] = current_char_set[current_char_index];
printf("current_char_set: %d %s\n", strlen(current_char_set), current_char_set);
}
void interface_input_up(void)
@@ -187,8 +185,8 @@ void interface_input_display(void)
{
// buttons
display_set_button( interface_get_label_text(&interface_text_button_cancel), true, false);
display_set_button( interface_get_label_text(&interface_text_button_ok), false, true);
display_set_button(interface_get_label_text(&interface_text_button_cancel), true, false);
display_set_button(interface_get_label_text(&interface_text_button_ok), false, true);
size_t start = 0;
uint8_t display_cursor = current_cursor + 1;
@@ -198,26 +196,9 @@ void interface_input_display(void)
display_cursor = 14;
}
// arrow
if (current_cursor > 0)
{
display_data( display_gfx_arrow_left, 8, 2, 0, false);
}
else
{
display_data( display_gfx_clear, 8, 2, 0, false);
}
// bounday
display_text_line_column( "______________", 2, 1, false);
// arrow
if (current_cursor < current_limit)
{
display_data( display_gfx_arrow_right, 8, 2, 15 * 8, false);
}
else
{
display_data( display_gfx_clear, 8, 2, 15 * 8, false);
}
display_text_line_column("______________", 2, 1, false);
// text
size_t text_length = strlen(current_text);
if (strlen(current_text) > 14)
@@ -231,14 +212,14 @@ void interface_input_display(void)
memcpy(&textdata[i * 8], display_gfx_font[(uint8_t)current_text[i + start] - 32], 8);
}
display_data( textdata, length, 2, 8, true);
display_data(textdata, length, 2, 8, true);
free(textdata);
// clear
display_clear_line( 0, false);
display_clear_line( 1, false);
display_clear_line( 3, false);
display_clear_line( 4, false);
display_clear_line(0, false);
display_clear_line(1, false);
display_clear_line(3, false);
display_clear_line(4, false);
uint8_t current_char = (uint8_t)current_char_set[current_char_index] - 32;
uint8_t prev_char = (uint8_t)current_char_set[current_char_index - 1] - 32;
@@ -255,15 +236,32 @@ void interface_input_display(void)
}
// arrow
display_data( display_gfx_arrow_up, 8, 0, display_cursor * 8, false);
display_data(display_gfx_arrow_up, 8, 0, display_cursor * 8, false);
// upper char
display_data( display_gfx_font[prev_char], 8, 1, display_cursor * 8, false);
display_data(display_gfx_font[prev_char], 8, 1, display_cursor * 8, false);
// sel char
display_data( display_gfx_font[current_char], 8, 2, display_cursor * 8, false);
display_data(display_gfx_font[current_char], 8, 2, display_cursor * 8, false);
// lower char
display_data( display_gfx_font[next_char], 8, 3, display_cursor * 8, false);
display_data(display_gfx_font[next_char], 8, 3, display_cursor * 8, false);
// arrow
display_data( display_gfx_arrow_down, 8, 4, display_cursor * 8, false);
display_data(display_gfx_arrow_down, 8, 4, display_cursor * 8, false);
if (current_cursor > 0)
{
display_data(display_gfx_arrow_left, 8, 2, 0, false);
}
else
{
display_data(display_gfx_clear, 8, 2, 0, false);
}
if (current_cursor < current_limit)
{
display_data(display_gfx_arrow_right, 8, 2, 15 * 8, false);
}
else
{
display_data(display_gfx_clear, 8, 2, 15 * 8, false);
}
}
void interface_input_set_text(char *text)
@@ -313,8 +311,7 @@ void interface_input(interface_text_callback callback_rst, interface_text_callba
interface_register_command_callback(INTERFACE_COMMAND_MID, &interface_input_mid);
interface_register_command_callback(INTERFACE_COMMAND_UP, &interface_input_up);
interface_register_command_callback(INTERFACE_COMMAND_DWN, &interface_input_dwn);
interface_register_command_callback(INTERFACE_COMMAND_RST_LONG, &interface_input_mid);
interface_set_display_function(&interface_input_display);
interface_set_display_refresh_function(NULL);
ESP_LOGD(INTERFACE_LOG, "start input interface");
}
+2
View File
@@ -49,6 +49,7 @@ void interface_init_label(void)
interface_text_settings_timezone.text[EN] = "UTC:";
interface_text_info_num_keys.text[EN] = "Seen:";
interface_text_info_last_keys.text[EN] = "<=30m:";
interface_text_info_exp_days.text[EN] = "Last Exp:";
interface_text_info_exp_num.text[EN] = "Num Exp:";
interface_text_info_exp_max.text[EN] = "Score:";
@@ -111,6 +112,7 @@ void interface_init_label(void)
interface_text_settings_timezone.text[DE] = "GMT:";
interface_text_info_num_keys.text[DE] = "Gesehen:";
interface_text_info_last_keys.text[DE] = "<=30m:";
interface_text_info_exp_days.text[DE] = "letz. Exp:";
interface_text_info_exp_num.text[DE] = "Anz. Exp:";
interface_text_info_exp_max.text[DE] = "Score:";
+10 -6
View File
@@ -51,6 +51,7 @@ void interface_main_display(void)
// status unknown if no update or last update older than two days
if (last_update == 0 || ((current_timstamp - last_update) / (60 * 60 * 24)) > 2)
{
display_set_color(YELLOW);
display_data(display_gfx_question[0], 24, 0, 12, false);
display_data(display_gfx_question[1], 24, 1, 12, false);
display_data(display_gfx_question[2], 24, 2, 12, false);
@@ -58,18 +59,23 @@ void interface_main_display(void)
}
else if (current_exposure_summary->max_risk_score < 100)
{
display_set_color(GREEN);
display_data(display_gfx_smile[0], 24, 0, 12, false);
display_data(display_gfx_smile[1], 24, 1, 12, false);
display_data(display_gfx_smile[2], 24, 2, 12, false);
display_data(display_gfx_smile[3], 24, 3, 12, false);
display_set_color(WHITE);
}
else
{
display_set_color(RED);
display_data(display_gfx_sad[0], 24, 0, 12, false);
display_data(display_gfx_sad[1], 24, 1, 12, false);
display_data(display_gfx_sad[2], 24, 2, 12, false);
display_data(display_gfx_sad[3], 24, 3, 12, false);
display_set_color(WHITE);
}
// clock icon
display_data(display_gfx_clock, 8, 4, 8, false);
@@ -78,9 +84,9 @@ void interface_main_display(void)
last_update_tm->tm_hour = last_update_tm->tm_hour + (interface_get_timezone_offset()) % 24;
sprintf(time_buffer, "%02d %s %02d:%02d",
last_update_tm->tm_mday,
sprintf(time_buffer, "%s %02d %02d:%02d",
interface_get_label_text(&interface_texts_month[last_update_tm->tm_mon]),
last_update_tm->tm_mday,
last_update_tm->tm_hour,
last_update_tm->tm_min);
@@ -89,6 +95,8 @@ void interface_main_display(void)
display_text_line_column(time_buffer, 4, 3, false);
}
display_set_color(WHITE);
// buttons
display_set_button(interface_get_label_text(&interface_text_button_menu), true, false);
display_set_button(interface_get_label_text(&interface_text_button_report), false, true);
@@ -124,7 +132,6 @@ void interface_main_display_refresh(void)
void interface_main_start(void)
{
interface_register_command_callback(INTERFACE_COMMAND_RST, &interface_main_rst);
interface_register_command_callback(INTERFACE_COMMAND_SET, &interface_main_set);
interface_register_command_callback(INTERFACE_COMMAND_LFT, NULL);
@@ -135,7 +142,4 @@ void interface_main_start(void)
interface_set_display_function(&interface_main_display);
interface_set_display_refresh_function(&interface_main_display_refresh);
interface_main_display();
ESP_LOGD(INTERFACE_LOG, "start main interface");
}
+27 -26
View File
@@ -48,10 +48,10 @@ static int current_report_status = INTERFACE_REPORT_STATUS_NONE;
void interface_report_display(void)
{
display_clear();
if (current_report_status == INTERFACE_REPORT_STATUS_NONE)
{
display_menu_headline(interface_get_label_text(&interface_text_headline_tan), false, 0);
// buttons
display_set_button(interface_get_label_text(&interface_text_button_cancel), true, false);
if (current_cursor == 9)
@@ -59,24 +59,6 @@ void interface_report_display(void)
display_set_button(interface_get_label_text(&interface_text_button_ok), false, true);
}
if (current_cursor > 0)
{
display_data(display_gfx_arrow_left, 8, 3, 8, false);
}
else
{
display_data(display_gfx_clear, 8, 3, 8, false);
}
if (current_cursor < 9)
{
display_data(display_gfx_arrow_right, 8, 3, 112, false);
}
else
{
display_data(display_gfx_clear, 8, 3, 112, false);
}
display_clear_line(2, false);
display_clear_line(4, false);
@@ -123,25 +105,45 @@ void interface_report_display(void)
display_data(display_gfx_arrow_down, 8, 4, current_cursor * 8 + offset * 8, false);
display_chars(&current_tan[current_cursor], 1, 3, current_cursor + offset, false);
if (current_cursor > 0)
{
display_data(display_gfx_arrow_left, 8, 3, 8, false);
}
else
{
display_data(display_gfx_clear, 8, 3, 8, false);
}
if (current_cursor < 9)
{
display_data(display_gfx_arrow_right, 8, 3, 112, false);
}
else
{
display_data(display_gfx_clear, 8, 3, 112, false);
}
}
else if (current_report_status == INTERFACE_REPORT_STATUS_PENDING)
{
display_menu_headline(interface_get_label_text(&interface_text_headline_report), false, 0);
display_clear();
display_text_line_column(interface_get_label_text(&interface_text_report_pending), 4, 1, false);
display_menu_headline(interface_get_label_text(&interface_text_headline_report), false, 0);
}
else if (current_report_status == INTERFACE_REPORT_STATUS_SUCCESS)
{
display_menu_headline(interface_get_label_text(&interface_text_headline_report), false, 0);
display_clear();
display_text_line_column(interface_get_label_text(&interface_text_report_success), 3, 1, false);
display_set_button(interface_get_label_text(&interface_text_button_ok), false, true);
display_menu_headline(interface_get_label_text(&interface_text_headline_report), false, 0);
}
else if (current_report_status == INTERFACE_REPORT_STATUS_FAIL)
{
display_menu_headline(interface_get_label_text(&interface_text_headline_report), false, 0);
display_clear();
display_text_line_column(interface_get_label_text(&interface_text_report_fail), 3, 1, false);
display_set_button(interface_get_label_text(&interface_text_button_back), true, false);
display_set_button(interface_get_label_text(&interface_text_button_ok), false, true);
display_menu_headline(interface_get_label_text(&interface_text_headline_report), false, 0);
}
}
@@ -306,8 +308,7 @@ void interface_report_start(void)
interface_register_command_callback(INTERFACE_COMMAND_RHT, &interface_report_rht);
interface_register_command_callback(INTERFACE_COMMAND_UP, &interface_report_up);
interface_register_command_callback(INTERFACE_COMMAND_DWN, &interface_report_dwn);
interface_set_display_function(&interface_report_display);
interface_set_display_refresh_function(NULL);
interface_register_command_callback(INTERFACE_COMMAND_RST_LONG, &interface_report_mid);
ESP_LOGD(INTERFACE_LOG, "start report interface");
interface_set_display_function(&interface_report_display);
}
+2 -8
View File
@@ -50,10 +50,6 @@ void interface_settings_set(void)
interface_main_start();
}
void interface_settings_rst(void)
{
}
void interface_settings_lft(void)
{
interface_info_start();
@@ -191,15 +187,13 @@ void interface_settings_start(void)
{
current_interface_settings_state = INTERFACE_SETTINGS_LOCALE;
interface_register_command_callback(INTERFACE_COMMAND_RST, &interface_settings_rst);
interface_register_command_callback(INTERFACE_COMMAND_RST, &interface_settings_mid);
interface_register_command_callback(INTERFACE_COMMAND_SET, &interface_settings_set);
interface_register_command_callback(INTERFACE_COMMAND_LFT, &interface_settings_lft);
interface_register_command_callback(INTERFACE_COMMAND_RHT, &interface_settings_rht);
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_set_display_function(&interface_settings_display);
interface_set_display_refresh_function(NULL);
ESP_LOGD(INTERFACE_LOG, "start settings interface");
}
+11 -4
View File
@@ -22,6 +22,7 @@
#include "display.h"
#include "display-gfx.h"
#include "wifi-controller.h"
#include "ena-eke-proxy.h"
#include "interface.h"
@@ -70,12 +71,14 @@ void interface_wifi_rht(void)
{
interface_datetime_start();
}
void interface_wifi_mid(void)
{
memset(&current_wifi_config, 0, sizeof(wifi_config_t));
memcpy(current_wifi_config.sta.ssid, ap_info[ap_selected].ssid, strlen((char *)ap_info[ap_selected].ssid));
interface_input(&interface_wifi_input_rst, &interface_wifi_input_set, 64);
}
void interface_wifi_up(void)
{
ap_selected--;
@@ -120,6 +123,7 @@ void interface_wifi_display_refresh(void)
{
if (ap_count > 0)
{
ena_eke_proxy_resume();
display_clear_line(2, false);
display_clear_line(4, false);
display_clear_line(6, false);
@@ -132,6 +136,10 @@ void interface_wifi_display_refresh(void)
{
display_data(display_gfx_arrow_right, 8, i * 2 + 2, 8, false);
}
else
{
display_data(display_gfx_clear, 8, i * 2 + 2, 8, false);
}
if (sizeof(ap_info[i].ssid) > 0)
{
@@ -171,18 +179,17 @@ void interface_wifi_start(void)
interface_register_command_callback(INTERFACE_COMMAND_MID, &interface_wifi_mid);
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, NULL);
interface_register_command_callback(INTERFACE_COMMAND_RST, &interface_wifi_mid);
interface_set_display_function(&interface_wifi_display);
interface_set_display_refresh_function(&interface_wifi_display_refresh);
interface_wifi_display();
ESP_LOGD(INTERFACE_LOG, "start wifi interface and scanning");
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);
}
+42 -17
View File
@@ -29,6 +29,12 @@ static interface_display_function current_display_refresh_function;
static TimerHandle_t interface_idle_timer;
static bool interface_idle = false;
static bool busy = false;
bool interface_is_idle(void)
{
return interface_idle;
}
void interface_register_command_callback(interface_command_t command, interface_command_callback callback)
{
@@ -37,14 +43,26 @@ void interface_register_command_callback(interface_command_t command, interface_
void interface_set_display_function(interface_display_function display_function)
{
busy = true;
display_clear();
current_display_refresh_function = NULL;
current_display_function = display_function;
if (current_display_function != NULL)
{
(*current_display_function)();
}
busy = false;
}
void interface_set_display_refresh_function(interface_display_function display_function)
{
display_clear();
busy = true;
current_display_refresh_function = display_function;
if (current_display_function != NULL)
{
(*current_display_function)();
}
busy = false;
}
void interface_execute_command(interface_command_t command)
@@ -53,19 +71,14 @@ void interface_execute_command(interface_command_t command)
{
xTimerReset(interface_idle_timer, 0);
(*command_callbacks[command])();
if (current_display_function != NULL || current_display_refresh_function != NULL)
if (!busy)
{
display_clear();
if (current_display_refresh_function != NULL)
{
vTaskDelay(10 / portTICK_PERIOD_MS);
(*current_display_refresh_function)();
}
busy = true;
if (current_display_function != NULL)
{
vTaskDelay(10 / portTICK_PERIOD_MS);
(*current_display_function)();
}
busy = false;
}
}
else if (interface_idle && command == INTERFACE_COMMAND_SET)
@@ -82,11 +95,15 @@ void interface_display_task(void *pvParameter)
while (1)
{
if (current_display_refresh_function != NULL)
if (!interface_idle && !busy && current_display_refresh_function != NULL)
{
(*current_display_refresh_function)();
vTaskDelay(500 / portTICK_PERIOD_MS);
}
else
{
vTaskDelay(100 / portTICK_PERIOD_MS);
}
vTaskDelay(500 / portTICK_PERIOD_MS);
}
}
@@ -101,7 +118,7 @@ void interface_start(void)
interface_idle_timer = xTimerCreate(
"interface_idle",
(15 * 1000) / portTICK_PERIOD_MS,
(INTERFACE_IDLE_SECONDS * 1000) / portTICK_PERIOD_MS,
false,
NULL,
interface_idle_callback);
@@ -112,10 +129,18 @@ void interface_start(void)
display_start();
display_clear();
for (int i = 0; i < 8; i++)
{
display_data(display_gfx_logo[i], 64, i, 32, false);
}
xTaskCreate(&interface_display_task, "interface_display_task", 4096, NULL, 5, NULL);
}
void interface_flipped(bool flipped)
{
busy = true;
vTaskDelay(500 / portTICK_PERIOD_MS);
display_clear();
display_flipped(flipped);
if (current_display_function != NULL)
{
(*current_display_function)();
}
busy = false;
}
+27
View File
@@ -28,6 +28,11 @@
#define INTERFACE_NUM_LOCALE 2
#define INTERFACE_IDLE_SECONDS CONFIG_ENA_INTERFACE_IDLE_TIME
#define INTERFACE_INPUT_TICKS_MS 20
#define INTERFACE_LONG_STATE_SECONDS 1.0
/**
* @brief available commands
*/
@@ -40,6 +45,8 @@ typedef enum
INTERFACE_COMMAND_LFT,
INTERFACE_COMMAND_DWN,
INTERFACE_COMMAND_UP,
INTERFACE_COMMAND_RST_LONG,
INTERFACE_COMMAND_SET_LONG,
INTERFACE_COMMANDS_SIZE,
} interface_command_t;
@@ -80,6 +87,7 @@ interface_label_t interface_text_settings_locales[INTERFACE_NUM_LOCALE];
interface_label_t interface_text_settings_timezone;
interface_label_t interface_text_info_num_keys;
interface_label_t interface_text_info_last_keys;
interface_label_t interface_text_info_exp_update;
interface_label_t interface_text_info_exp_days;
interface_label_t interface_text_info_exp_num;
@@ -116,6 +124,13 @@ typedef void (*interface_display_function)(void);
*/
typedef void (*interface_text_callback)(char *text, uint8_t cursor);
/**
* @brief is interface in idle mode
*
* @return if interface is idle
*/
bool interface_is_idle(void);
/**
* @brief init label
*/
@@ -194,6 +209,13 @@ void interface_set_display_refresh_function(interface_display_function display_f
*/
void interface_start(void);
/**
* @brief set interface flipped or not
*
* @param[in] on true interface is flipped
*/
void interface_flipped(bool flipped);
/**
* @brief start delete data interface
*/
@@ -229,6 +251,11 @@ void interface_settings_start(void);
*/
void interface_info_start(void);
/**
* @brief start debug interface
*/
void interface_debug_start(void);
/**
* @brief start interface for input
*