added dependable build for interface choice in menuconfig

This commit is contained in:
Lurkars 2020-12-17 10:21:10 +01:00
parent 45444bb8c5
commit 7e82c695ea
56 changed files with 483 additions and 522 deletions

136
README.md
View File

@ -24,26 +24,35 @@ The following acronyms will be used in code and comments:
### Additional features for full ENA device ### Additional features for full ENA device
#### Custom device Interface with display and input to
* RTC support with DS3231 (for correct system time)
* display support with SSD1306
* interface with a 7 button control (joystick up,down,left,right,enter,cancel,ok) to
* show exposure status * show exposure status
* set time
* connect to WiFi * connect to WiFi
* delete data * delete data
* set language * set language (currently supported: English and German)
* set timezone
* enter tan and uploading own exposure keys * enter tan and uploading own exposure keys
* set time and date (if no RTC/NTP available)
#### supported devices
##### M5StickC and M5StickC PLUS
* RTC support
* display support
* PMU support
* input with 2 buttons and accelerometer control
* ok/cancel with button 1 and button 2 (depending on screen orientation)
* up, down, left, right by tilting device
* long press button 1 for changing character set on input
##### Custom device
* RTC support with DS3231 (for correct system time)
* display support with SSD1306
* input with a 7 button control (joystick up,down,left,right,enter,cancel,ok)
* battery support with ESP32 development boards with integrated LiPo support * battery support with ESP32 development boards with integrated LiPo support
#### M5StickC and M5StickC PLUS ##### LILYGO TTGO T-Wristband \[in development\]
* RTC support
* PMU support
* display support * display support
* interface with 2 buttons and accelerometer control * RTC and input in development
* ok/cancel with button 1 and button 2 (depending on screen orientation)
* up, down, left, right with tilting device
* long press button 1 for changing character set on input
### Limitations/Problems/Questions ### Limitations/Problems/Questions
* WiFi or other external connection needed for infections status (auto-connect to open WiFis?) * WiFi or other external connection needed for infections status (auto-connect to open WiFis?)
@ -95,9 +104,16 @@ idf.py menuconfig
> Component config -> mbedTLS -> [*] HKDF algorithm (RFC 5869) > Component config -> mbedTLS -> [*] HKDF algorithm (RFC 5869)
* flash size > 3.9GB * flash size > 3.9GB
> Serial flasher config -> Flash size -> (x) 4MB > Serial flasher config -> Flash size -> (x) 4MB
* choose interface device (custom, M5StickC or M5StickC PLUS) * choose interface device (custom, M5StickC, M5StickC PLUS, TTGO T-Wristband \[in development\])
> ENA Interface -> ENA Interface device > ENA Interface -> ENA Interface device
***important***
If you ran into error ``region 'iram0_0_seg' overflowed by xxx bytes`` you can try disabling WiFi IRAM optimization
> Component config -> Wi-Fi -> WiFi IRAM speed optimization -> ( )
> Component config -> Wi-Fi -> WiFi RX IRAM speed optimization -> ( )
**recommended** **recommended**
* BLE *Scan Duplicate* (By Device Address and Advertising Data) * BLE *Scan Duplicate* (By Device Address and Advertising Data)
> Component config -> Bluetooth -> Bluetooth controller -> Scan Duplicate Type -> (X) Scan Duplicate By Device Address And Advertising Data > Component config -> Bluetooth -> Bluetooth controller -> Scan Duplicate Type -> (X) Scan Duplicate By Device Address And Advertising Data
@ -108,10 +124,6 @@ idf.py menuconfig
* Exposure Notification API / Storage enable *Dump storage* * Exposure Notification API / Storage enable *Dump storage*
> Exposure Notification API -> Storage -> [X] Dump storage > Exposure Notification API -> Storage -> [X] Dump storage
#### Configure device manually!
Select required device drivers manually, because config get not applied in interface's CmakeLists.txt (I don't know why!):
> comment in/out line in *components/interface/CmakeLists.txt* with matching interface
#### Configure SSL cert manually! #### Configure SSL cert manually!
@ -168,65 +180,65 @@ Request URL is parametrized with {day-string},({hour} in hourly mode,) {page}, {
Adds interface functionality for control and setup. Adds interface functionality for control and setup.
#### interface/custom-input
Interface input with 7 button input.
#### interface/m5-input
Interface input for M5StickC (PLUS) with 2 button input and accelerometer as axis input.
#### interface-m5-mpu6886
I²C driver for MPU6886 6-Axis IMU of M5StickC (PLUS).
#### interface/ttgo-input \[in development\]
Interface input for TTGO T-Wristband with 1 button input and accelerometer as axis input.
#### interface/ttgo-lsm9ds1 \[in development\]
I²C driver for LSM9DS1 6-Axis IMU of TTGO T-Wristband.
### display ### display
General module for display and gfx. General module for display and gfx.
#### display/custom-ssd1306
I²C driver for a SSD1306 display, implementation of [display](#-display) module.
### display/m5-axp192
I²C driver for AXP192 PMU of M5StickC (PLUS).
#### display/m5-st7735s
SPI driver for a ST7735s display of M5StickC, implementation of [display](#-display) module.
#### display/m5-st7789
SPI driver for a ST7789 display of M5StickC PLUS, implementation of [display](#-display) module
#### display/ttgo-st7735
SPI driver for a ST7735 display of TTGO T-Wristband, implementation of [display](#-display) module.
### rtc ### rtc
General module for set/get time from RTC. General module for set/get time from RTC.
### i2c-main #### rtc/custom-ds3231
Just start I²C driver.
### interface-custom-input
Interface with 7 button input.
### interface-m5-input
Interface with input for M5StickC (PLUS) with 2 button input and accelerometer as axis input.
### interface-ttgo-input \[in development\]
Interface with input for TTGO T-Wristband with 1 button input and accelerometer as axis input.
### rtc-custom-ds3231
I²C driver for a DS3231 RTC, implementation of [rtc](#-rtc) module. I²C driver for a DS3231 RTC, implementation of [rtc](#-rtc) module.
### rtc-m5-bm8563 #### rtc/m5-bm8563
I²C driver for BM8563 of M5StickC (PLUS), implementation of [rtc](#-rtc) module. I²C driver for BM8563 of M5StickC (PLUS), implementation of [rtc](#-rtc) module.
### display-custom-ssd1306 ### i2c-main
I²C driver for a SSD1306 display, implementation of [display](#-display) module. Just start I²C driver.
### display-m5-st7735s
SPI driver for a ST7735s display of M5StickC, implementation of [display](#-display) module.
### display-m5-st7789
SPI driver for a ST7789 display of M5StickC PLUS, implementation of [display](#-display) module
### display-ttgo-st7735
SPI driver for a ST7735 display of TTGO T-Wristband, implementation of [display](#-display) module.
### imu-m5-mpu6886
I²C driver for MPU6886 6-Axis IMU of M5StickC (PLUS).
### imu-ttgo-lsm9ds1 \[in development\]
I²C driver for LSM9DS1 6-Axis IMU of TTGO T-Wristband.
### pmu-m5-axp192
I²C driver for AXP192 PMU of M5StickC (PLUS).
### ena-binary-export \[deprecated\] ### ena-binary-export \[deprecated\]

View File

@ -1,8 +0,0 @@
idf_component_register(
SRCS
"ssd1306.c"
INCLUDE_DIRS "."
PRIV_REQUIRES
"display"
"i2c-main"
)

View File

@ -1,9 +0,0 @@
idf_component_register(
SRCS
"st7735s.c"
INCLUDE_DIRS "."
PRIV_REQUIRES
"display"
"spi_flash"
"pmu-m5-axp192"
)

View File

@ -1,9 +0,0 @@
idf_component_register(
SRCS
"st7789.c"
INCLUDE_DIRS "."
PRIV_REQUIRES
"display"
"spi_flash"
"pmu-m5-axp192"
)

View File

@ -1,8 +0,0 @@
idf_component_register(
SRCS
"st7735.c"
INCLUDE_DIRS "."
PRIV_REQUIRES
"display"
"spi_flash"
)

View File

@ -1,6 +1,28 @@
set(src_list "display.c" "display-gfx.c")
set(include_list ".")
if(CONFIG_ENA_INTERFACE_DISPLAY_SSD1306)
list(APPEND src_list "custom-ssd1306/ssd1306.c")
list(APPEND include_list "custom-ssd1306")
elseif(CONFIG_ENA_INTERFACE_M5STICKC)
list(APPEND src_list "m5-st7735s/st7735s.c" "m5-axp192/axp192.c")
list(APPEND include_list "m5-st7735s" "m5-axp192")
elseif(CONFIG_ENA_INTERFACE_M5STICKC_PLUS)
list(APPEND src_list "m5-st7789/st7789.c" "m5-axp192/axp192.c")
list(APPEND include_list "m5-st7789" "m5-axp192")
elseif(CONFIG_ENA_INTERFACE_TTGO_T_WRISTBAND)
list(APPEND src_list "ttgo-st7735/st7735.c")
list(APPEND include_list "ttgo-st7735")
else()
list(APPEND src_list "dummy.c")
endif()
idf_component_register( idf_component_register(
SRCS SRCS
"display.c" ${src_list}
"display-gfx.c" INCLUDE_DIRS
INCLUDE_DIRS "." ${include_list}
PRIV_REQUIRES
"i2c-main"
"spi_flash"
) )

View File

@ -34,6 +34,63 @@
#define CYAN 0x07FF #define CYAN 0x07FF
#define PURPLE 0xF81F #define PURPLE 0xF81F
/**
* @brief initalize display
*
* MUST BE DEFINED DEVICE SPECIFIC
*
*/
void display_start(void);
/**
* @brief clear the display
*
* MUST BE DEFINED DEVICE SPECIFIC
*
* @param[in] line the line to clear
* @param[in] invert if true, image is inverted
*/
void display_clear_line(uint8_t line, bool invert);
/**
* @brief clear the display
*
* MUST BE DEFINED DEVICE SPECIFIC
*
*/
void display_clear(void);
/**
* @brief set display on or off
*
* MUST BE DEFINED DEVICE SPECIFIC
*
* @param[in] on true if display on, false if display off
*/
void display_on(bool on);
/**
* @brief set display flipped or not
*
* MUST BE DEFINED DEVICE SPECIFIC
*
* @param[in] on true display is flipped
*/
void display_flipped(bool flipped);
/**
* @brief write raw bytes to display line at starting column
*
* MUST BE DEFINED DEVICE SPECIFIC
*
* @param[in] data bytes to display
* @param[in] length length of data
* @param[in] line the line to write to
* @param[in] offset number of offset chars to start
* @param[in] invert if true, image is inverted
*/
void display_data(uint8_t *data, size_t length, uint8_t line, uint8_t offset, bool invert);
/** /**
* *
*/ */
@ -44,55 +101,11 @@ void display_utf8_to_ascii(char *input, char *output);
*/ */
uint8_t *display_text_to_data(char *text, size_t text_length, size_t *length); uint8_t *display_text_to_data(char *text, size_t text_length, size_t *length);
/**
* @brief initalize display
*/
void display_start(void);
/**
* @brief clear the display
*
* @param[in] line the line to clear
* @param[in] invert if true, image is inverted
*/
void display_clear_line(uint8_t line, bool invert);
/**
* @brief clear the display
*
*/
void display_clear(void);
/**
* @brief set display on or off
*
* @param[in] on true if display on, false if display off
*/
void display_on(bool on);
/**
* @brief set display flipped or not
*
* @param[in] on true display is flipped
*/
void display_flipped(bool flipped);
/** /**
* *
*/ */
uint8_t *display_text_to_data(char *text, size_t text_length, size_t *length); uint8_t *display_text_to_data(char *text, size_t text_length, size_t *length);
/**
* @brief write raw bytes to display line at starting column
*
* @param[in] data bytes to display
* @param[in] length length of data
* @param[in] line the line to write to
* @param[in] offset number of offset chars to start
* @param[in] invert if true, image is inverted
*/
void display_data(uint8_t *data, size_t length, uint8_t line, uint8_t offset, bool invert);
/** /**
* @brief write chars to display * @brief write chars to display
* *

View File

@ -0,0 +1,39 @@
// 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 "display.h"
void display_start(void)
{
}
void display_clear_line(uint8_t line, bool invert)
{
}
void display_clear(void)
{
}
void display_on(bool on)
{
}
void display_data(uint8_t *data, size_t length, uint8_t line, uint8_t offset, bool invert)
{
}
void display_flipped(bool flipped)
{
}

View File

@ -26,6 +26,8 @@ static int scan_status = ENA_SCAN_STATUS_NOT_SCANNING;
static const uint16_t ENA_SERVICE_UUID = 0xFD6F; static const uint16_t ENA_SERVICE_UUID = 0xFD6F;
static int last_scan_num;
static esp_ble_scan_params_t ena_scan_params = { static esp_ble_scan_params_t ena_scan_params = {
.scan_type = BLE_SCAN_TYPE_ACTIVE, .scan_type = BLE_SCAN_TYPE_ACTIVE,
.own_addr_type = BLE_ADDR_TYPE_RANDOM, .own_addr_type = BLE_ADDR_TYPE_RANDOM,
@ -37,7 +39,6 @@ static esp_ble_scan_params_t ena_scan_params = {
void ena_bluetooth_scan_event_callback(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *param) void ena_bluetooth_scan_event_callback(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *param)
{ {
uint32_t unix_timestamp = (uint32_t)time(NULL); uint32_t unix_timestamp = (uint32_t)time(NULL);
esp_ble_gap_cb_param_t *p = (esp_ble_gap_cb_param_t *)param; esp_ble_gap_cb_param_t *p = (esp_ble_gap_cb_param_t *)param;
switch (event) switch (event)
@ -70,6 +71,7 @@ void ena_bluetooth_scan_event_callback(esp_gap_ble_cb_event_t event, esp_ble_gap
uint8_t *aem = malloc(ENA_AEM_METADATA_LENGTH); uint8_t *aem = malloc(ENA_AEM_METADATA_LENGTH);
memcpy(aem, &service_data[sizeof(ENA_SERVICE_UUID) + ENA_KEY_LENGTH], ENA_AEM_METADATA_LENGTH); memcpy(aem, &service_data[sizeof(ENA_SERVICE_UUID) + ENA_KEY_LENGTH], ENA_AEM_METADATA_LENGTH);
ena_beacon(unix_timestamp, rpi, aem, p->scan_rst.rssi); ena_beacon(unix_timestamp, rpi, aem, p->scan_rst.rssi);
last_scan_num++;
free(rpi); free(rpi);
free(aem); free(aem);
} }
@ -98,6 +100,7 @@ void ena_bluetooth_scan_init(void)
void ena_bluetooth_scan_start(uint32_t duration) void ena_bluetooth_scan_start(uint32_t duration)
{ {
scan_status = ENA_SCAN_STATUS_SCANNING; scan_status = ENA_SCAN_STATUS_SCANNING;
last_scan_num = 0;
ESP_ERROR_CHECK(esp_ble_gap_start_scanning(duration)); ESP_ERROR_CHECK(esp_ble_gap_start_scanning(duration));
} }
@ -111,3 +114,8 @@ int ena_bluetooth_scan_get_status(void)
{ {
return scan_status; return scan_status;
} }
int ena_bluetooth_scan_get_last_num(void)
{
return last_scan_num;
}

View File

@ -66,4 +66,12 @@ void ena_bluetooth_scan_stop(void);
*/ */
int ena_bluetooth_scan_get_status(void); int ena_bluetooth_scan_get_status(void);
/**
* @brief return the num of found devices in last scan
*
* @return
* num of last beacons
*/
int ena_bluetooth_scan_get_last_num(void);
#endif #endif

View File

@ -1,15 +0,0 @@
menu "I²C"
config I2C_SDA_PIN
int "I²C sda pin"
default 21
config I2C_SCL_PIN
int "I²C scl pin"
default 22
config I2C_CLOCKSPEED
int "I²C clock speed"
default 1000000
endmenu

View File

@ -20,9 +20,14 @@
#ifndef _i2c_main_H_ #ifndef _i2c_main_H_
#define _i2c_main_H_ #define _i2c_main_H_
#if defined(CONFIG_ENA_INTERFACE_CUSTOM)
#define I2C_SDA_PIN (CONFIG_I2C_SDA_PIN) #define I2C_SDA_PIN (CONFIG_I2C_SDA_PIN)
#define I2C_SCL_PIN (CONFIG_I2C_SCL_PIN) #define I2C_SCL_PIN (CONFIG_I2C_SCL_PIN)
#define I2C_CLK_SPEED (CONFIG_I2C_CLOCKSPEED) #else
#define I2C_SDA_PIN 21
#define I2C_SCL_PIN 22
#endif
#define I2C_CLK_SPEED (1000000)
/** /**
* @brief initialize main I2C interface * @brief initialize main I2C interface

View File

@ -1,7 +0,0 @@
idf_component_register(
SRCS
"mpu6886.c"
INCLUDE_DIRS "."
PRIV_REQUIRES
i2c-main
)

View File

@ -1,7 +0,0 @@
idf_component_register(
SRCS
"lsm9ds1.c"
INCLUDE_DIRS "."
PRIV_REQUIRES
i2c-main
)

View File

@ -1,7 +0,0 @@
idf_component_register(
SRCS
"custom-input.c"
INCLUDE_DIRS "."
PRIV_REQUIRES
interface
)

View File

@ -1,8 +0,0 @@
idf_component_register(
SRCS
"m5-input.c"
INCLUDE_DIRS "."
PRIV_REQUIRES
interface
imu-m5-mpu6886
)

View File

@ -1,8 +0,0 @@
idf_component_register(
SRCS
"ttgo-input.c"
INCLUDE_DIRS "."
PRIV_REQUIRES
interface
imu-ttgo-lsm9ds1
)

View File

@ -1,33 +1,40 @@
set(priv_requires "ena" "ena-eke-proxy" "display" "rtc" "wifi-controller" ) set(src_list
if(CONFIG_ENA_INTERFACE_CUSTOM)
list(APPEND priv_requires "display-custom-ssd1306" "rtc-custom-ds3231")
elseif(CONFIG_ENA_INTERFACE_M5STICKC)
list(APPEND priv_requires "display-m5-st7735s" "rtc-m5-bm8563" "imu-m5-mpu6886" "pmu-m5-axp192")
elseif(CONFIG_ENA_INTERFACE_M5STICKC_PLUS)
list(APPEND priv_requires "display-m5-st7789" "rtc-m5-bm8563" "imu-m5-mpu6886" "pmu-m5-axp192")
elseif(CONFIG_ENA_INTERFACE_TTGO_T_WRISTBAND)
list(APPEND priv_requires "display-ttgo-st7735" "imu-ttgo-lsm9ds1")
else()
list(APPEND priv_requires "display-custom-ssd1306" "rtc-custom-ds3231") # uncomment for custom device with SSD1306 und DS3231
# list(APPEND priv_requires "display-m5-st7735s" "rtc-m5-bm8563" "imu-m5-mpu6886" "pmu-m5-axp192") # uncomment for M5StickC
# list(APPEND priv_requires "display-m5-st7789" "rtc-m5-bm8563" "imu-m5-mpu6886" "pmu-m5-axp192") # uncomment for M5StickC PLUS
# list(APPEND priv_requires "display-ttgo-st7735" "imu-ttgo-lsm9ds1") # uncomment for TTGO T-Wristband
endif()
idf_component_register(
SRCS
"interface.c" "interface.c"
"interface-main.c" "interface-main.c"
"interface-data.c" "interface-data.c"
"interface-datetime.c" "interface-datetime.c"
"interface-debug.c"
"interface-info.c" "interface-info.c"
"interface-input.c" "interface-input.c"
"interface-label.c" "interface-label.c"
"interface-report.c" "interface-report.c"
"interface-settings.c" "interface-settings.c"
"interface-wifi.c" "interface-wifi.c")
INCLUDE_DIRS "."
PRIV_REQUIRES ${priv_requires} set(include_list ".")
if(CONFIG_ENA_INTERFACE_INPUT_CUSTOM)
list(APPEND src_list "custom-input/custom-input.c")
list(APPEND include_list "custom-input")
elseif(CONFIG_ENA_INTERFACE_M5STICKC OR CONFIG_ENA_INTERFACE_M5STICKC_PLUS)
list(APPEND src_list "m5-input/m5-input.c" "m5-mpu6886/mpu6886.c")
list(APPEND include_list "m5-input" "m5-mpu6886")
elseif(CONFIG_ENA_INTERFACE_TTGO_T_WRISTBAND)
list(APPEND src_list "ttgo-input/ttgo-input.c" "ttgo-lsm9ds1/lsm9ds1.c")
list(APPEND include_list "ttgo-input" "ttgo-lsm9ds1")
else()
list(APPEND src_list "dummy.c")
endif()
idf_component_register(
SRCS
${src_list}
INCLUDE_DIRS
${include_list}
PRIV_REQUIRES
"ena"
"ena-eke-proxy"
"display"
"rtc"
"wifi-controller"
"i2c-main"
) )

View File

@ -5,10 +5,6 @@ menu "ENA Interface"
int "Seconds after display turns off on inactivity" int "Seconds after display turns off on inactivity"
default 15 default 15
config ENA_INTERFACE_DEBUG
bool "Adds a debug interface for additional information for device"
default false
choice ENA_INTERFACE_DEVICE choice ENA_INTERFACE_DEVICE
prompt "Choose device" prompt "Choose device"
default ENA_INTERFACE_CUSTOM default ENA_INTERFACE_CUSTOM
@ -16,6 +12,49 @@ menu "ENA Interface"
config ENA_INTERFACE_CUSTOM config ENA_INTERFACE_CUSTOM
bool "Custom" bool "Custom"
choice ENA_INTERFACE_CUSTOM_DISPLAY
depends on ENA_INTERFACE_CUSTOM
prompt "Choose custom display"
default ENA_INTERFACE_DISPLAY_SSD1306
config ENA_INTERFACE_DISPLAY_SSD1306
bool "SSD1306"
config ENA_INTERFACE_DISPLAY_NONE
bool "none"
endchoice
choice ENA_INTERFACE_CUSTOM_RTC
depends on ENA_INTERFACE_CUSTOM
prompt "Choose custom rtc"
default ENA_INTERFACE_RTC_DS3231
config ENA_INTERFACE_RTC_DS3231
bool "DS3231"
config ENA_INTERFACE_RTC_NONE
bool "none"
endchoice
choice ENA_INTERFACE_CUSTOM_INPUT
depends on ENA_INTERFACE_CUSTOM
prompt "Choose custom input"
default ENA_INTERFACE_INPUT_CUSTOM
config ENA_INTERFACE_INPUT_CUSTOM
bool "7-Button input"
config ENA_INTERFACE_INPUT_NONE
bool "none"
endchoice
menu "Custom I²C"
depends on ENA_INTERFACE_CUSTOM
config I2C_SDA_PIN
int "I²C sda pin"
default 21
config I2C_SCL_PIN
int "I²C scl pin"
default 22
endmenu
config ENA_INTERFACE_M5STICKC config ENA_INTERFACE_M5STICKC
bool "M5StickC" bool "M5StickC"

View File

@ -97,7 +97,7 @@ void custom_input_task(void *pvParameter)
} }
} }
void custom_input_start(void) void interface_input_start(void)
{ {
gpio_config_t io_conf; gpio_config_t io_conf;

View File

@ -28,11 +28,4 @@
#define BUTTON_DWN GPIO_NUM_14 #define BUTTON_DWN GPIO_NUM_14
#define BUTTON_UP GPIO_NUM_12 #define BUTTON_UP GPIO_NUM_12
/**
* @brief
*
*
*/
void custom_input_start(void);
#endif #endif

View File

@ -0,0 +1,19 @@
// 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 <stdio.h>
#include "interface.h"
void interface_input_start(void)
{
}

View File

@ -109,11 +109,7 @@ void interface_data_lft(void)
void interface_data_rht(void) void interface_data_rht(void)
{ {
#if defined(CONFIG_ENA_INTERFACE_DEBUG)
interface_debug_start();
#else
interface_info_start(); interface_info_start();
#endif
} }
void interface_data_mid(void) void interface_data_mid(void)

View File

@ -1,168 +0,0 @@
// 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
#if defined(CONFIG_ENA_INTERFACE_TTGO_T_WRISTBAND)
#include "lsm9ds1.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) || defined(CONFIG_ENA_INTERFACE_TTGO_T_WRISTBAND)
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);
#endif
#if defined(CONFIG_ENA_INTERFACE_TTGO_T_WRISTBAND)
lsm9ds1_get_accel_data(&ax, &ay, &az);
lsm9ds1_get_gyro_data(&gx, &gy, &gz);
#endif
#if defined(CONFIG_ENA_INTERFACE_M5STICKC) || defined(CONFIG_ENA_INTERFACE_M5STICKC_PLUS) || defined(CONFIG_ENA_INTERFACE_TTGO_T_WRISTBAND)
char data_chars[32];
sprintf(data_chars, "acc x:%3.2f", ax);
display_text_line(data_chars, 1, false);
sprintf(data_chars, "acc y:%3.2f", ay);
display_text_line(data_chars, 2, false);
sprintf(data_chars, "acc z:%3.2f", az);
display_text_line(data_chars, 3, false);
sprintf(data_chars, "gyr x:%3.2f", gx);
display_text_line(data_chars, 4, false);
sprintf(data_chars, "gyr y:%3.2f", gy);
display_text_line(data_chars, 5, false);
sprintf(data_chars, "gyr z:%3.2f", gz);
display_text_line(data_chars, 6, false);
#endif
#if defined(CONFIG_ENA_INTERFACE_M5STICKC) || defined(CONFIG_ENA_INTERFACE_M5STICKC_PLUS)
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)
{
#if defined(CONFIG_ENA_INTERFACE_TTGO_T_WRISTBAND)
lsm9ds1_start();
#endif
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_register_command_callback(INTERFACE_COMMAND_RST_LONG, NULL);
interface_register_command_callback(INTERFACE_COMMAND_SET_LONG, NULL);
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;
}

View File

@ -24,9 +24,20 @@
#include "ena-storage.h" #include "ena-storage.h"
#include "ena-exposure.h" #include "ena-exposure.h"
#include "ena-bluetooth-scan.h"
#include "interface.h" #include "interface.h"
typedef enum
{
INTERFACE_INFO_STATUS_EXPOSURE = 0,
INTERFACE_INFO_STATUS_BEACONS,
INTERFACE_INFO_STATUS_SCAN,
INTERFACE_INFO_STATUS_SYSTEM
} info_status_e;
static int current_info_status = INTERFACE_INFO_STATUS_EXPOSURE;
void interface_info_set(void) void interface_info_set(void)
{ {
interface_main_start(); interface_main_start();
@ -38,11 +49,7 @@ void interface_info_rst(void)
void interface_info_lft(void) void interface_info_lft(void)
{ {
#if defined(CONFIG_ENA_INTERFACE_DEBUG)
interface_debug_start();
#else
interface_data_start(); interface_data_start();
#endif
} }
void interface_info_rht(void) void interface_info_rht(void)
@ -56,10 +63,20 @@ void interface_info_mid(void)
void interface_info_up(void) void interface_info_up(void)
{ {
current_info_status--;
if (current_info_status < INTERFACE_INFO_STATUS_EXPOSURE)
{
current_info_status = INTERFACE_INFO_STATUS_SYSTEM;
}
} }
void interface_info_dwn(void) void interface_info_dwn(void)
{ {
current_info_status++;
if (current_info_status > INTERFACE_INFO_STATUS_SYSTEM)
{
current_info_status = INTERFACE_INFO_STATUS_EXPOSURE;
}
} }
int interface_info_num_offset(int num) int interface_info_num_offset(int num)
@ -80,18 +97,45 @@ int interface_info_num_offset(int num)
void interface_info_display(void) void interface_info_display(void)
{ {
ena_exposure_summary_t *current_exposure_summary = ena_exposure_current_summary(); display_clear();
char char_buffer[64];
char data_chars[16];
display_menu_headline(interface_get_label_text(&interface_text_headline_info), true, 0); 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); display_data(display_gfx_arrow_up, 8, 1, 60, false);
if (current_info_status == INTERFACE_INFO_STATUS_EXPOSURE)
{
ena_exposure_summary_t *current_exposure_summary = ena_exposure_current_summary();
display_text_line_column(interface_get_label_text(&interface_text_info_exp_days), 3, 1, false);
int last = current_exposure_summary->days_since_last_exposure;
if (last >= 0)
{
sprintf(char_buffer, "%d", last);
display_text_line_column(char_buffer, 3, interface_info_num_offset(last), false);
}
display_text_line_column(interface_get_label_text(&interface_text_info_exp_num), 4, 1, false);
sprintf(char_buffer, "%d", current_exposure_summary->num_exposures);
display_text_line_column(char_buffer, 4, interface_info_num_offset(current_exposure_summary->num_exposures), false);
display_text_line_column(interface_get_label_text(&interface_text_info_exp_max), 5, 1, false);
sprintf(char_buffer, "%d", current_exposure_summary->max_risk_score);
display_text_line_column(char_buffer, 5, interface_info_num_offset(current_exposure_summary->max_risk_score), false);
display_text_line_column(interface_get_label_text(&interface_text_info_exp_sum), 6, 1, false);
sprintf(char_buffer, "%d", current_exposure_summary->risk_score_sum);
display_text_line_column(char_buffer, 6, interface_info_num_offset(current_exposure_summary->risk_score_sum), false);
}
else if (current_info_status == INTERFACE_INFO_STATUS_BEACONS)
{
display_text_line_column(interface_get_label_text(&interface_text_info_num_keys), 3, 1, false);
int num = ena_storage_beacons_count(); int num = ena_storage_beacons_count();
sprintf(data_chars, "%u", num); sprintf(char_buffer, "%u", num);
display_text_line_column(data_chars, 2, interface_info_num_offset(num), false); display_text_line_column(char_buffer, 3, interface_info_num_offset(num), false);
display_text_line_column(interface_get_label_text(&interface_text_info_last_keys), 3, 1, false); display_text_line_column(interface_get_label_text(&interface_text_info_last_keys), 4, 1, false);
time_t current_timstamp; time_t current_timstamp;
time(&current_timstamp); time(&current_timstamp);
@ -101,29 +145,36 @@ void interface_info_display(void)
if (last30 >= 0) if (last30 >= 0)
{ {
sprintf(data_chars, "%d", last30); sprintf(char_buffer, "%d", last30);
display_text_line_column(data_chars, 3, interface_info_num_offset(last30), false); display_text_line_column(char_buffer, 4, interface_info_num_offset(last30), false);
} }
}
display_text_line_column(interface_get_label_text(&interface_text_info_exp_days), 4, 1, false); else if (current_info_status == INTERFACE_INFO_STATUS_SCAN)
int last = current_exposure_summary->days_since_last_exposure;
if (last >= 0)
{ {
sprintf(data_chars, "%d", last); int current_scan = ena_bluetooth_scan_get_last_num();
display_text_line_column(data_chars, 4, interface_info_num_offset(last), false);
switch (ena_bluetooth_scan_get_status())
{
case ENA_SCAN_STATUS_SCANNING:
display_text_line_column(interface_get_label_text(&interface_text_info_scan_status_scanning), 3, 1, false);
break;
case ENA_SCAN_STATUS_NOT_SCANNING:
display_text_line_column(interface_get_label_text(&interface_text_info_scan_status_notscanning), 3, 1, false);
break;
case ENA_SCAN_STATUS_WAITING:
display_text_line_column(interface_get_label_text(&interface_text_info_scan_status_waiting), 3, 1, false);
break;
} }
display_text_line_column(interface_get_label_text(&interface_text_info_exp_num), 5, 1, false); display_text_line_column(interface_get_label_text(&interface_text_info_scan_last), 5, 1, false);
sprintf(data_chars, "%d", current_exposure_summary->num_exposures); sprintf(char_buffer, "%d", current_scan);
display_text_line_column(data_chars, 5, interface_info_num_offset(current_exposure_summary->num_exposures), false); display_text_line_column(char_buffer, 5, interface_info_num_offset(current_scan), false);
}
else if (current_info_status == INTERFACE_INFO_STATUS_SYSTEM)
{
}
display_text_line_column(interface_get_label_text(&interface_text_info_exp_max), 6, 1, false); display_data(display_gfx_arrow_down, 8, 7, 60, false);
sprintf(data_chars, "%d", current_exposure_summary->max_risk_score);
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, interface_info_num_offset(current_exposure_summary->risk_score_sum), false);
} }
void interface_info_start(void) void interface_info_start(void)

View File

@ -58,6 +58,11 @@ void interface_init_label(void)
interface_text_info_exp_max.text[EN] = "Score:"; interface_text_info_exp_max.text[EN] = "Score:";
interface_text_info_exp_sum.text[EN] = "Scores:"; interface_text_info_exp_sum.text[EN] = "Scores:";
interface_text_info_scan_status_scanning.text[EN] = "Scanning...";
interface_text_info_scan_status_notscanning.text[EN] = "Not scanning.";
interface_text_info_scan_status_waiting.text[EN] = "Waiting for scan";
interface_text_info_scan_last.text[EN] = "Last scan:";
interface_text_report_pending.text[EN] = "Uploading..."; interface_text_report_pending.text[EN] = "Uploading...";
interface_text_report_success.text[EN] = "Upload succeed!"; interface_text_report_success.text[EN] = "Upload succeed!";
interface_text_report_fail.text[EN] = "Upload failed!"; interface_text_report_fail.text[EN] = "Upload failed!";
@ -124,6 +129,11 @@ void interface_init_label(void)
interface_text_info_exp_max.text[DE] = "Score:"; interface_text_info_exp_max.text[DE] = "Score:";
interface_text_info_exp_sum.text[DE] = "Scores:"; interface_text_info_exp_sum.text[DE] = "Scores:";
interface_text_info_scan_status_scanning.text[DE] = "Scannen...";
interface_text_info_scan_status_notscanning.text[DE] = "Kein Scan.";
interface_text_info_scan_status_waiting.text[DE] = "Warten auf Scan.";
interface_text_info_scan_last.text[DE] = "letz. Scan:";
interface_text_report_pending.text[DE] = "Hochladen..."; interface_text_report_pending.text[DE] = "Hochladen...";
interface_text_report_success.text[DE] = "Erfolgreich!"; interface_text_report_success.text[DE] = "Erfolgreich!";
interface_text_report_fail.text[DE] = "Fehlgeschlagen!"; interface_text_report_fail.text[DE] = "Fehlgeschlagen!";

View File

@ -145,6 +145,8 @@ void interface_start(void)
display_clear(); display_clear();
xTaskCreate(&interface_display_task, "interface_display_task", 4096, NULL, 5, NULL); xTaskCreate(&interface_display_task, "interface_display_task", 4096, NULL, 5, NULL);
interface_input_start();
} }
void interface_flipped(bool flipped) void interface_flipped(bool flipped)

View File

@ -93,6 +93,10 @@ interface_label_t interface_text_info_exp_days;
interface_label_t interface_text_info_exp_num; interface_label_t interface_text_info_exp_num;
interface_label_t interface_text_info_exp_max; interface_label_t interface_text_info_exp_max;
interface_label_t interface_text_info_exp_sum; interface_label_t interface_text_info_exp_sum;
interface_label_t interface_text_info_scan_status_scanning;
interface_label_t interface_text_info_scan_status_notscanning;
interface_label_t interface_text_info_scan_status_waiting;
interface_label_t interface_text_info_scan_last;
interface_label_t interface_text_report_pending; interface_label_t interface_text_report_pending;
interface_label_t interface_text_report_success; interface_label_t interface_text_report_success;
@ -127,6 +131,16 @@ typedef void (*interface_display_function)(void);
*/ */
typedef void (*interface_text_callback)(char *text, uint8_t cursor); typedef void (*interface_text_callback)(char *text, uint8_t cursor);
/**
* @brief start input routine
*
* MUST BE DEFINED DEVICE SPECIFIC
*
*/
void interface_input_start(void);
/** /**
* @brief is interface in idle mode * @brief is interface in idle mode
* *
@ -268,11 +282,6 @@ void interface_settings_start(void);
*/ */
void interface_info_start(void); void interface_info_start(void);
/**
* @brief start debug interface
*/
void interface_debug_start(void);
/** /**
* @brief start interface for input * @brief start interface for input
* *

View File

@ -138,7 +138,7 @@ void m5_input_task(void *pvParameter)
} }
} }
void m5_input_start(void) void interface_input_start(void)
{ {
gpio_config_t io_conf; gpio_config_t io_conf;

View File

@ -23,11 +23,4 @@
#define BUTTON_RST GPIO_NUM_37 #define BUTTON_RST GPIO_NUM_37
#define BUTTON_SET GPIO_NUM_39 #define BUTTON_SET GPIO_NUM_39
/**
* @brief
*
*
*/
void m5_input_start(void);
#endif #endif

View File

@ -37,7 +37,7 @@ void ttgo_input_task(void *pvParameter)
} }
} }
void ttgo_input_start(void) void interface_input_start(void)
{ {
lsm9ds1_start(); lsm9ds1_start();
xTaskCreate(&ttgo_input_task, "ttgo_input_task", 4096, NULL, 5, NULL); xTaskCreate(&ttgo_input_task, "ttgo_input_task", 4096, NULL, 5, NULL);

View File

@ -20,11 +20,4 @@
#ifndef _ttgo_input_H_ #ifndef _ttgo_input_H_
#define _ttgo_input_H_ #define _ttgo_input_H_
/**
* @brief
*
*
*/
void ttgo_input_start(void);
#endif #endif

View File

@ -55,6 +55,11 @@ void lsm9ds1_i2c_write_bytes(uint8_t driver_addr, uint8_t start_addr, uint8_t nu
int lsm9ds1_start(void) int lsm9ds1_start(void)
{ {
if (!i2c_is_initialized())
{
i2c_main_init();
}
unsigned char regdata; unsigned char regdata;
// init ACC // init ACC
regdata = 0x38; regdata = 0x38;

View File

@ -1,7 +0,0 @@
idf_component_register(
SRCS
"axp192.c"
INCLUDE_DIRS "."
PRIV_REQUIRES
i2c-main
)

View File

@ -1,8 +0,0 @@
idf_component_register(
SRCS
"ds3231.c"
INCLUDE_DIRS "."
PRIV_REQUIRES
rtc
i2c-main
)

View File

@ -1,8 +0,0 @@
idf_component_register(
SRCS
"bm8563.c"
INCLUDE_DIRS "."
PRIV_REQUIRES
rtc
i2c-main
)

View File

@ -1,4 +1,20 @@
set(include_list ".")
if(CONFIG_ENA_INTERFACE_RTC_DS3231)
set(src_list "custom-ds3231/ds3231.c")
list(APPEND include_list "custom-ds3231")
elseif(CONFIG_ENA_INTERFACE_M5STICKC OR CONFIG_ENA_INTERFACE_M5STICKC_PLUS)
set(src_list "m5-bm8563/bm8563.c")
list(APPEND include_list "m5-bm8563")
else()
set(src_list "dummy.c")
endif()
idf_component_register( idf_component_register(
SRCS SRCS
INCLUDE_DIRS "." ${src_list}
INCLUDE_DIRS
${include_list}
PRIV_REQUIRES
"i2c-main"
) )

23
components/rtc/dummy.c Normal file
View File

@ -0,0 +1,23 @@
// 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 "rtc.h"
void rtc_get_time(struct tm *time)
{
}
void rtc_set_time(struct tm *time)
{
}

View File

@ -33,18 +33,6 @@
#include "sdkconfig.h" #include "sdkconfig.h"
#ifdef CONFIG_ENA_INTERFACE_CUSTOM
#include "custom-input.h"
#endif
#if defined(CONFIG_ENA_INTERFACE_M5STICKC) || defined(CONFIG_ENA_INTERFACE_M5STICKC_PLUS)
#include "m5-input.h"
#endif
#ifdef CONFIG_ENA_INTERFACE_TTGO_T_WRISTBAND
#include "ttgo-input.h"
#endif
void time_sync_notification_cb(struct timeval *tv) void time_sync_notification_cb(struct timeval *tv)
{ {
time_t time = (time_t)tv->tv_sec; time_t time = (time_t)tv->tv_sec;
@ -92,19 +80,6 @@ void app_main(void)
// start with main interface // start with main interface
interface_main_start(); interface_main_start();
// start input
#if defined(CONFIG_ENA_INTERFACE_CUSTOM)
custom_input_start();
#endif
#if defined(CONFIG_ENA_INTERFACE_M5STICKC) || defined(CONFIG_ENA_INTERFACE_M5STICKC_PLUS)
m5_input_start();
#endif
#if defined(CONFIG_ENA_INTERFACE_TTGO_T_WRISTBAND)
ttgo_input_start();
#endif
wifi_controller_reconnect(NULL); wifi_controller_reconnect(NULL);
while (1) while (1)