diff --git a/README.md b/README.md index 5fd0702..03ff12c 100644 --- a/README.md +++ b/README.md @@ -24,26 +24,35 @@ The following acronyms will be used in code and comments: ### Additional features for full ENA device -#### Custom device +Interface with display and input to + * show exposure status + * connect to WiFi + * delete data + * set language (currently supported: English and German) + * set timezone + * 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 -* interface with a 7 button control (joystick up,down,left,right,enter,cancel,ok) to - * show exposure status - * set time - * connect to WiFi - * delete data - * set language - * enter tan and uploading own exposure keys +* input with a 7 button control (joystick up,down,left,right,enter,cancel,ok) * battery support with ESP32 development boards with integrated LiPo support -#### M5StickC and M5StickC PLUS -* RTC support -* PMU support +##### LILYGO TTGO T-Wristband \[in development\] * display support -* interface with 2 buttons and accelerometer control - * 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 +* RTC and input in development ### Limitations/Problems/Questions * 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) * flash size > 3.9GB > 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 +***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** * 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 @@ -107,11 +123,7 @@ idf.py menuconfig > Component config -> Log output -> Default log verbosity -> (X) Debug * Exposure Notification API / Storage enable *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! @@ -168,65 +180,65 @@ Request URL is parametrized with {day-string},({hour} in hourly mode,) {page}, { 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 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 General module for set/get time from RTC. -### i2c-main - -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 +#### rtc/custom-ds3231 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. -### display-custom-ssd1306 +### i2c-main -I²C driver for a SSD1306 display, implementation of [display](#-display) module. - -### 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). +Just start I²C driver. ### ena-binary-export \[deprecated\] diff --git a/components/display-custom-ssd1306/CMakeLists.txt b/components/display-custom-ssd1306/CMakeLists.txt deleted file mode 100644 index 68d532e..0000000 --- a/components/display-custom-ssd1306/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -idf_component_register( - SRCS - "ssd1306.c" - INCLUDE_DIRS "." - PRIV_REQUIRES - "display" - "i2c-main" -) \ No newline at end of file diff --git a/components/display-m5-st7735s/CMakeLists.txt b/components/display-m5-st7735s/CMakeLists.txt deleted file mode 100644 index 6fd6d21..0000000 --- a/components/display-m5-st7735s/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -idf_component_register( - SRCS - "st7735s.c" - INCLUDE_DIRS "." - PRIV_REQUIRES - "display" - "spi_flash" - "pmu-m5-axp192" -) diff --git a/components/display-m5-st7789/CMakeLists.txt b/components/display-m5-st7789/CMakeLists.txt deleted file mode 100644 index c02633c..0000000 --- a/components/display-m5-st7789/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -idf_component_register( - SRCS - "st7789.c" - INCLUDE_DIRS "." - PRIV_REQUIRES - "display" - "spi_flash" - "pmu-m5-axp192" -) \ No newline at end of file diff --git a/components/display-ttgo-st7735/CMakeLists.txt b/components/display-ttgo-st7735/CMakeLists.txt deleted file mode 100644 index 5ca2ed4..0000000 --- a/components/display-ttgo-st7735/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -idf_component_register( - SRCS - "st7735.c" - INCLUDE_DIRS "." - PRIV_REQUIRES - "display" - "spi_flash" -) diff --git a/components/display/CMakeLists.txt b/components/display/CMakeLists.txt index e9072a4..70fb6c6 100644 --- a/components/display/CMakeLists.txt +++ b/components/display/CMakeLists.txt @@ -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( SRCS - "display.c" - "display-gfx.c" - INCLUDE_DIRS "." + ${src_list} + INCLUDE_DIRS + ${include_list} + PRIV_REQUIRES + "i2c-main" + "spi_flash" ) \ No newline at end of file diff --git a/components/display-custom-ssd1306/ssd1306.c b/components/display/custom-ssd1306/ssd1306.c similarity index 100% rename from components/display-custom-ssd1306/ssd1306.c rename to components/display/custom-ssd1306/ssd1306.c diff --git a/components/display-custom-ssd1306/ssd1306.h b/components/display/custom-ssd1306/ssd1306.h similarity index 100% rename from components/display-custom-ssd1306/ssd1306.h rename to components/display/custom-ssd1306/ssd1306.h diff --git a/components/display/display.h b/components/display/display.h index 239566e..eaec230 100644 --- a/components/display/display.h +++ b/components/display/display.h @@ -34,6 +34,63 @@ #define CYAN 0x07FF #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); -/** - * @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); -/** - * @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 * diff --git a/components/display/dummy.c b/components/display/dummy.c new file mode 100644 index 0000000..6628921 --- /dev/null +++ b/components/display/dummy.c @@ -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 +#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) +{ +} \ No newline at end of file diff --git a/components/pmu-m5-axp192/axp192.c b/components/display/m5-axp192/axp192.c similarity index 100% rename from components/pmu-m5-axp192/axp192.c rename to components/display/m5-axp192/axp192.c diff --git a/components/pmu-m5-axp192/axp192.h b/components/display/m5-axp192/axp192.h similarity index 100% rename from components/pmu-m5-axp192/axp192.h rename to components/display/m5-axp192/axp192.h diff --git a/components/display-m5-st7735s/st7735s.c b/components/display/m5-st7735s/st7735s.c similarity index 100% rename from components/display-m5-st7735s/st7735s.c rename to components/display/m5-st7735s/st7735s.c diff --git a/components/display-m5-st7735s/st7735s.h b/components/display/m5-st7735s/st7735s.h similarity index 100% rename from components/display-m5-st7735s/st7735s.h rename to components/display/m5-st7735s/st7735s.h diff --git a/components/display-m5-st7789/st7789.c b/components/display/m5-st7789/st7789.c similarity index 100% rename from components/display-m5-st7789/st7789.c rename to components/display/m5-st7789/st7789.c diff --git a/components/display-m5-st7789/st7789.h b/components/display/m5-st7789/st7789.h similarity index 100% rename from components/display-m5-st7789/st7789.h rename to components/display/m5-st7789/st7789.h diff --git a/components/display-ttgo-st7735/st7735.c b/components/display/ttgo-st7735/st7735.c similarity index 100% rename from components/display-ttgo-st7735/st7735.c rename to components/display/ttgo-st7735/st7735.c diff --git a/components/display-ttgo-st7735/st7735.h b/components/display/ttgo-st7735/st7735.h similarity index 100% rename from components/display-ttgo-st7735/st7735.h rename to components/display/ttgo-st7735/st7735.h diff --git a/components/ena/ena-bluetooth-scan.c b/components/ena/ena-bluetooth-scan.c index c5745a1..526337a 100644 --- a/components/ena/ena-bluetooth-scan.c +++ b/components/ena/ena-bluetooth-scan.c @@ -26,6 +26,8 @@ static int scan_status = ENA_SCAN_STATUS_NOT_SCANNING; static const uint16_t ENA_SERVICE_UUID = 0xFD6F; +static int last_scan_num; + static esp_ble_scan_params_t ena_scan_params = { .scan_type = BLE_SCAN_TYPE_ACTIVE, .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) { - uint32_t unix_timestamp = (uint32_t)time(NULL); esp_ble_gap_cb_param_t *p = (esp_ble_gap_cb_param_t *)param; 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); 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); + last_scan_num++; free(rpi); free(aem); } @@ -98,6 +100,7 @@ void ena_bluetooth_scan_init(void) void ena_bluetooth_scan_start(uint32_t duration) { scan_status = ENA_SCAN_STATUS_SCANNING; + last_scan_num = 0; ESP_ERROR_CHECK(esp_ble_gap_start_scanning(duration)); } @@ -111,3 +114,8 @@ int ena_bluetooth_scan_get_status(void) { return scan_status; } + +int ena_bluetooth_scan_get_last_num(void) +{ + return last_scan_num; +} \ No newline at end of file diff --git a/components/ena/include/ena-bluetooth-scan.h b/components/ena/include/ena-bluetooth-scan.h index d1ca3fa..deeffdf 100644 --- a/components/ena/include/ena-bluetooth-scan.h +++ b/components/ena/include/ena-bluetooth-scan.h @@ -66,4 +66,12 @@ void ena_bluetooth_scan_stop(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 \ No newline at end of file diff --git a/components/i2c-main/Kconfig.projbuild b/components/i2c-main/Kconfig.projbuild deleted file mode 100644 index 59ce8fe..0000000 --- a/components/i2c-main/Kconfig.projbuild +++ /dev/null @@ -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 \ No newline at end of file diff --git a/components/i2c-main/i2c-main.h b/components/i2c-main/i2c-main.h index 10ff92a..4f8f8b1 100644 --- a/components/i2c-main/i2c-main.h +++ b/components/i2c-main/i2c-main.h @@ -20,9 +20,14 @@ #ifndef _i2c_main_H_ #define _i2c_main_H_ +#if defined(CONFIG_ENA_INTERFACE_CUSTOM) #define I2C_SDA_PIN (CONFIG_I2C_SDA_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 diff --git a/components/imu-m5-mpu6886/CMakeLists.txt b/components/imu-m5-mpu6886/CMakeLists.txt deleted file mode 100644 index 2e50628..0000000 --- a/components/imu-m5-mpu6886/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -idf_component_register( - SRCS - "mpu6886.c" - INCLUDE_DIRS "." - PRIV_REQUIRES - i2c-main -) \ No newline at end of file diff --git a/components/imu-ttgo-lsm9ds1/CMakeLists.txt b/components/imu-ttgo-lsm9ds1/CMakeLists.txt deleted file mode 100644 index 7484257..0000000 --- a/components/imu-ttgo-lsm9ds1/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -idf_component_register( - SRCS - "lsm9ds1.c" - INCLUDE_DIRS "." - PRIV_REQUIRES - i2c-main -) \ No newline at end of file diff --git a/components/interface-custom-input/CMakeLists.txt b/components/interface-custom-input/CMakeLists.txt deleted file mode 100644 index 012a098..0000000 --- a/components/interface-custom-input/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -idf_component_register( - SRCS - "custom-input.c" - INCLUDE_DIRS "." - PRIV_REQUIRES - interface -) \ No newline at end of file diff --git a/components/interface-m5-input/CMakeLists.txt b/components/interface-m5-input/CMakeLists.txt deleted file mode 100644 index 233c95b..0000000 --- a/components/interface-m5-input/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -idf_component_register( - SRCS - "m5-input.c" - INCLUDE_DIRS "." - PRIV_REQUIRES - interface - imu-m5-mpu6886 -) \ No newline at end of file diff --git a/components/interface-ttgo-input/CMakeLists.txt b/components/interface-ttgo-input/CMakeLists.txt deleted file mode 100644 index 897dba0..0000000 --- a/components/interface-ttgo-input/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -idf_component_register( - SRCS - "ttgo-input.c" - INCLUDE_DIRS "." - PRIV_REQUIRES - interface - imu-ttgo-lsm9ds1 -) \ No newline at end of file diff --git a/components/interface/CMakeLists.txt b/components/interface/CMakeLists.txt index 2ef7e95..3caaccc 100644 --- a/components/interface/CMakeLists.txt +++ b/components/interface/CMakeLists.txt @@ -1,33 +1,40 @@ -set(priv_requires "ena" "ena-eke-proxy" "display" "rtc" "wifi-controller" ) +set(src_list + "interface.c" + "interface-main.c" + "interface-data.c" + "interface-datetime.c" + "interface-info.c" + "interface-input.c" + "interface-label.c" + "interface-report.c" + "interface-settings.c" + "interface-wifi.c") -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") +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 priv_requires "display-ttgo-st7735" "imu-ttgo-lsm9ds1") + list(APPEND src_list "ttgo-input/ttgo-input.c" "ttgo-lsm9ds1/lsm9ds1.c") + list(APPEND include_list "ttgo-input" "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 + list(APPEND src_list "dummy.c") 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" - "interface-report.c" - "interface-settings.c" - "interface-wifi.c" - INCLUDE_DIRS "." - PRIV_REQUIRES ${priv_requires} + ${src_list} + INCLUDE_DIRS + ${include_list} + PRIV_REQUIRES + "ena" + "ena-eke-proxy" + "display" + "rtc" + "wifi-controller" + "i2c-main" ) diff --git a/components/interface/Kconfig.projbuild b/components/interface/Kconfig.projbuild index 4081550..ca7b5e3 100644 --- a/components/interface/Kconfig.projbuild +++ b/components/interface/Kconfig.projbuild @@ -5,17 +5,56 @@ menu "ENA Interface" 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" - + + 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 bool "M5StickC" diff --git a/components/interface-custom-input/custom-input.c b/components/interface/custom-input/custom-input.c similarity index 99% rename from components/interface-custom-input/custom-input.c rename to components/interface/custom-input/custom-input.c index a0a0bda..581e349 100644 --- a/components/interface-custom-input/custom-input.c +++ b/components/interface/custom-input/custom-input.c @@ -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; diff --git a/components/interface-custom-input/custom-input.h b/components/interface/custom-input/custom-input.h similarity index 93% rename from components/interface-custom-input/custom-input.h rename to components/interface/custom-input/custom-input.h index 279521e..c46dc79 100644 --- a/components/interface-custom-input/custom-input.h +++ b/components/interface/custom-input/custom-input.h @@ -28,11 +28,4 @@ #define BUTTON_DWN GPIO_NUM_14 #define BUTTON_UP GPIO_NUM_12 -/** - * @brief - * - * - */ -void custom_input_start(void); - #endif \ No newline at end of file diff --git a/components/interface/dummy.c b/components/interface/dummy.c new file mode 100644 index 0000000..84f63e4 --- /dev/null +++ b/components/interface/dummy.c @@ -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 +#include "interface.h" + +void interface_input_start(void) +{ +} \ No newline at end of file diff --git a/components/interface/interface-data.c b/components/interface/interface-data.c index 667d039..1c3606d 100644 --- a/components/interface/interface-data.c +++ b/components/interface/interface-data.c @@ -109,11 +109,7 @@ 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) diff --git a/components/interface/interface-debug.c b/components/interface/interface-debug.c deleted file mode 100644 index 4ced522..0000000 --- a/components/interface/interface-debug.c +++ /dev/null @@ -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 -#include -#include -#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; -} diff --git a/components/interface/interface-info.c b/components/interface/interface-info.c index 31cd358..1584e90 100644 --- a/components/interface/interface-info.c +++ b/components/interface/interface-info.c @@ -24,9 +24,20 @@ #include "ena-storage.h" #include "ena-exposure.h" +#include "ena-bluetooth-scan.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) { interface_main_start(); @@ -38,11 +49,7 @@ 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) @@ -56,10 +63,20 @@ void interface_info_mid(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) { + 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) @@ -80,50 +97,84 @@ int interface_info_num_offset(int num) void interface_info_display(void) { - ena_exposure_summary_t *current_exposure_summary = ena_exposure_current_summary(); - - char data_chars[16]; + display_clear(); + char char_buffer[64]; 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); - int num = ena_storage_beacons_count(); - sprintf(data_chars, "%u", num); - display_text_line_column(data_chars, 2, interface_info_num_offset(num), false); - - display_text_line_column(interface_get_label_text(&interface_text_info_last_keys), 3, 1, false); - - time_t current_timstamp; - time(¤t_timstamp); - - int min = ena_expore_check_find_min((uint32_t)current_timstamp - 60 * 30); - int last30 = num - min; - - if (last30 >= 0) + 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(); + sprintf(char_buffer, "%u", num); + 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), 4, 1, false); + + time_t current_timstamp; + time(¤t_timstamp); + + int min = ena_expore_check_find_min((uint32_t)current_timstamp - 60 * 30); + int last30 = num - min; + + if (last30 >= 0) + { + sprintf(char_buffer, "%d", last30); + display_text_line_column(char_buffer, 4, interface_info_num_offset(last30), false); + } + } + else if (current_info_status == INTERFACE_INFO_STATUS_SCAN) + { + int current_scan = ena_bluetooth_scan_get_last_num(); + + 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_scan_last), 5, 1, false); + sprintf(char_buffer, "%d", current_scan); + display_text_line_column(char_buffer, 5, interface_info_num_offset(current_scan), false); + } + else if (current_info_status == INTERFACE_INFO_STATUS_SYSTEM) { - 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); - int last = current_exposure_summary->days_since_last_exposure; - if (last >= 0) - { - 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, 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, 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); + display_data(display_gfx_arrow_down, 8, 7, 60, false); } void interface_info_start(void) diff --git a/components/interface/interface-label.c b/components/interface/interface-label.c index 055d5ce..05c3e25 100644 --- a/components/interface/interface-label.c +++ b/components/interface/interface-label.c @@ -58,6 +58,11 @@ void interface_init_label(void) interface_text_info_exp_max.text[EN] = "Score:"; 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_success.text[EN] = "Upload succeed!"; 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_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_success.text[DE] = "Erfolgreich!"; interface_text_report_fail.text[DE] = "Fehlgeschlagen!"; diff --git a/components/interface/interface.c b/components/interface/interface.c index bd13941..f8045b0 100644 --- a/components/interface/interface.c +++ b/components/interface/interface.c @@ -145,6 +145,8 @@ void interface_start(void) display_clear(); xTaskCreate(&interface_display_task, "interface_display_task", 4096, NULL, 5, NULL); + + interface_input_start(); } void interface_flipped(bool flipped) diff --git a/components/interface/interface.h b/components/interface/interface.h index 1781152..c24e389 100644 --- a/components/interface/interface.h +++ b/components/interface/interface.h @@ -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_max; 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_success; @@ -127,6 +131,16 @@ typedef void (*interface_display_function)(void); */ 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 * @@ -268,11 +282,6 @@ void interface_settings_start(void); */ void interface_info_start(void); -/** - * @brief start debug interface - */ -void interface_debug_start(void); - /** * @brief start interface for input * diff --git a/components/interface-m5-input/m5-input.c b/components/interface/m5-input/m5-input.c similarity index 99% rename from components/interface-m5-input/m5-input.c rename to components/interface/m5-input/m5-input.c index 3c9aaa7..e180a12 100644 --- a/components/interface-m5-input/m5-input.c +++ b/components/interface/m5-input/m5-input.c @@ -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; diff --git a/components/interface-m5-input/m5-input.h b/components/interface/m5-input/m5-input.h similarity index 92% rename from components/interface-m5-input/m5-input.h rename to components/interface/m5-input/m5-input.h index 1af81d5..0750037 100644 --- a/components/interface-m5-input/m5-input.h +++ b/components/interface/m5-input/m5-input.h @@ -23,11 +23,4 @@ #define BUTTON_RST GPIO_NUM_37 #define BUTTON_SET GPIO_NUM_39 -/** - * @brief - * - * - */ -void m5_input_start(void); - #endif \ No newline at end of file diff --git a/components/imu-m5-mpu6886/mpu6886.c b/components/interface/m5-mpu6886/mpu6886.c similarity index 100% rename from components/imu-m5-mpu6886/mpu6886.c rename to components/interface/m5-mpu6886/mpu6886.c diff --git a/components/imu-m5-mpu6886/mpu6886.h b/components/interface/m5-mpu6886/mpu6886.h similarity index 100% rename from components/imu-m5-mpu6886/mpu6886.h rename to components/interface/m5-mpu6886/mpu6886.h diff --git a/components/interface-ttgo-input/ttgo-input.c b/components/interface/ttgo-input/ttgo-input.c similarity index 97% rename from components/interface-ttgo-input/ttgo-input.c rename to components/interface/ttgo-input/ttgo-input.c index 3ebe24b..c4ff977 100644 --- a/components/interface-ttgo-input/ttgo-input.c +++ b/components/interface/ttgo-input/ttgo-input.c @@ -37,7 +37,7 @@ void ttgo_input_task(void *pvParameter) } } -void ttgo_input_start(void) +void interface_input_start(void) { lsm9ds1_start(); xTaskCreate(&ttgo_input_task, "ttgo_input_task", 4096, NULL, 5, NULL); diff --git a/components/interface-ttgo-input/ttgo-input.h b/components/interface/ttgo-input/ttgo-input.h similarity index 91% rename from components/interface-ttgo-input/ttgo-input.h rename to components/interface/ttgo-input/ttgo-input.h index 2d0653a..d50c2c6 100644 --- a/components/interface-ttgo-input/ttgo-input.h +++ b/components/interface/ttgo-input/ttgo-input.h @@ -20,11 +20,4 @@ #ifndef _ttgo_input_H_ #define _ttgo_input_H_ -/** - * @brief - * - * - */ -void ttgo_input_start(void); - #endif \ No newline at end of file diff --git a/components/imu-ttgo-lsm9ds1/lsm9ds1.c b/components/interface/ttgo-lsm9ds1/lsm9ds1.c similarity index 97% rename from components/imu-ttgo-lsm9ds1/lsm9ds1.c rename to components/interface/ttgo-lsm9ds1/lsm9ds1.c index 7ef8ba4..d9a3ae3 100644 --- a/components/imu-ttgo-lsm9ds1/lsm9ds1.c +++ b/components/interface/ttgo-lsm9ds1/lsm9ds1.c @@ -55,6 +55,11 @@ void lsm9ds1_i2c_write_bytes(uint8_t driver_addr, uint8_t start_addr, uint8_t nu int lsm9ds1_start(void) { + if (!i2c_is_initialized()) + { + i2c_main_init(); + } + unsigned char regdata; // init ACC regdata = 0x38; @@ -77,7 +82,7 @@ int lsm9ds1_start(void) aRes = 16.0 / 32768.0; gRes = 500.0 / 32768.0; - return 0; + return 0; } void lsm9ds1_get_accel_adc(int16_t *ax, int16_t *ay, int16_t *az) diff --git a/components/imu-ttgo-lsm9ds1/lsm9ds1.h b/components/interface/ttgo-lsm9ds1/lsm9ds1.h similarity index 100% rename from components/imu-ttgo-lsm9ds1/lsm9ds1.h rename to components/interface/ttgo-lsm9ds1/lsm9ds1.h diff --git a/components/pmu-m5-axp192/CMakeLists.txt b/components/pmu-m5-axp192/CMakeLists.txt deleted file mode 100644 index 35389c9..0000000 --- a/components/pmu-m5-axp192/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -idf_component_register( - SRCS - "axp192.c" - INCLUDE_DIRS "." - PRIV_REQUIRES - i2c-main -) \ No newline at end of file diff --git a/components/rtc-custom-ds3231/CMakeLists.txt b/components/rtc-custom-ds3231/CMakeLists.txt deleted file mode 100644 index db5950a..0000000 --- a/components/rtc-custom-ds3231/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -idf_component_register( - SRCS - "ds3231.c" - INCLUDE_DIRS "." - PRIV_REQUIRES - rtc - i2c-main -) \ No newline at end of file diff --git a/components/rtc-m5-bm8563/CMakeLists.txt b/components/rtc-m5-bm8563/CMakeLists.txt deleted file mode 100644 index e563b8f..0000000 --- a/components/rtc-m5-bm8563/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -idf_component_register( - SRCS - "bm8563.c" - INCLUDE_DIRS "." - PRIV_REQUIRES - rtc - i2c-main -) \ No newline at end of file diff --git a/components/rtc/CMakeLists.txt b/components/rtc/CMakeLists.txt index 746b052..2aa9221 100644 --- a/components/rtc/CMakeLists.txt +++ b/components/rtc/CMakeLists.txt @@ -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( SRCS - INCLUDE_DIRS "." + ${src_list} + INCLUDE_DIRS + ${include_list} + PRIV_REQUIRES + "i2c-main" ) \ No newline at end of file diff --git a/components/rtc-custom-ds3231/ds3231.c b/components/rtc/custom-ds3231/ds3231.c similarity index 100% rename from components/rtc-custom-ds3231/ds3231.c rename to components/rtc/custom-ds3231/ds3231.c diff --git a/components/rtc-custom-ds3231/ds3231.h b/components/rtc/custom-ds3231/ds3231.h similarity index 100% rename from components/rtc-custom-ds3231/ds3231.h rename to components/rtc/custom-ds3231/ds3231.h diff --git a/components/rtc/dummy.c b/components/rtc/dummy.c new file mode 100644 index 0000000..d05c666 --- /dev/null +++ b/components/rtc/dummy.c @@ -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 +#include "rtc.h" + +void rtc_get_time(struct tm *time) +{ +} + +void rtc_set_time(struct tm *time) +{ +} \ No newline at end of file diff --git a/components/rtc-m5-bm8563/bm8563.c b/components/rtc/m5-bm8563/bm8563.c similarity index 100% rename from components/rtc-m5-bm8563/bm8563.c rename to components/rtc/m5-bm8563/bm8563.c diff --git a/components/rtc-m5-bm8563/bm8563.h b/components/rtc/m5-bm8563/bm8563.h similarity index 100% rename from components/rtc-m5-bm8563/bm8563.h rename to components/rtc/m5-bm8563/bm8563.h diff --git a/main/main.c b/main/main.c index cb1dcf6..bff5164 100644 --- a/main/main.c +++ b/main/main.c @@ -33,18 +33,6 @@ #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) { time_t time = (time_t)tv->tv_sec; @@ -92,19 +80,6 @@ void app_main(void) // start with main interface 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); while (1)