From b627efc44b3b138d28e7d9a56103aaa89d9b9a12 Mon Sep 17 00:00:00 2001 From: Hendrik Sauer Date: Wed, 2 Jun 2021 17:22:38 +0200 Subject: [PATCH] Dummy functions in case of no display --- build_native.sh | 7 ------- src/display.c | 24 +++++++++++++++--------- src/display.h | 2 +- 3 files changed, 16 insertions(+), 17 deletions(-) delete mode 100755 build_native.sh diff --git a/build_native.sh b/build_native.sh deleted file mode 100755 index f3d7623..0000000 --- a/build_native.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash - -rm -rf zephyr/build -cp .pio/libdeps/nrf52840_dk/exposure-notification/*/exposure-notification.* src -west build -b native_posix_64 zephyr -- -DCMAKE_C_FLAGS="-DNATIVE_POSIX -I../include/tls_config -DDISPLAY" -rm src/exposure-notification.c src/exposure-notification.h -echo "Run ./build/zephyr/zephyr.elf --bt-dev=hci0" \ No newline at end of file diff --git a/src/display.c b/src/display.c index d678f36..d982e90 100644 --- a/src/display.c +++ b/src/display.c @@ -1,16 +1,15 @@ +#ifdef DISPLAY #include #include #include +#endif #include #include #include #include "display.h" -#define LOG_LEVEL CONFIG_LOG_DEFAULT_LEVEL -#include -LOG_MODULE_REGISTER(app); - +#ifdef DISPLAY const struct device* display_dev; lv_obj_t* display_center_pane; lv_obj_t* display_top_bar; @@ -26,6 +25,7 @@ lv_obj_t* display_msg_label; lv_style_t green_button_style; lv_style_t yellow_button_style; lv_style_t red_button_style; +#endif int get_battery_percentage() { return 74; @@ -50,6 +50,7 @@ int get_risk_contacts() { } int init_styles() { + #ifdef DISPLAY lv_style_init(&green_button_style); lv_style_init(&yellow_button_style); lv_style_init(&red_button_style); @@ -71,7 +72,7 @@ int init_styles() { lv_style_set_text_color(&yellow_button_style, LV_STATE_DEFAULT, LV_COLOR_BLACK); lv_style_set_bg_color(&red_button_style, LV_STATE_DEFAULT, LV_COLOR_RED); lv_style_set_text_color(&red_button_style, LV_STATE_DEFAULT, LV_COLOR_WHITE); - + #endif return 0; } @@ -79,26 +80,27 @@ int update_display() { display_set_contacts(get_contacts()); display_set_risk_contacts(get_risk_contacts()); - int time = get_time(); - lv_label_set_text_fmt(display_clock_label, "%d:%02d", (time / 100) % 100, time % 100); + display_set_time(get_time()); display_set_bat(get_battery_percentage()); display_set_mem(get_memory_percentage()); + #ifdef DISPLAY lv_task_handler(); + #endif return 0; } int init_display() { + #ifdef DISPLAY init_styles(); - #ifdef DISPLAY display_dev = device_get_binding(CONFIG_LVGL_DISPLAY_DEV_NAME); if (display_dev == NULL) { - LOG_ERR("device not found. Aborting test."); + printk("device not found. Aborting test."); return -1; } @@ -169,6 +171,10 @@ int display_set_message(char* msg) { return 0; } +int display_set_time(int time) { + return 0; +} + int display_set_bat(int bat) { #ifdef DISPLAY lv_label_set_text_fmt(display_battery_label, "Bat: %d%%", bat); diff --git a/src/display.h b/src/display.h index 3e85e13..c09a2ee 100644 --- a/src/display.h +++ b/src/display.h @@ -7,7 +7,7 @@ int update_display(); int display_set_message(char* msg); -int display_set_time(); +int display_set_time(int time); int display_set_bat(int bat);