Dummy functions in case of no display

This commit is contained in:
Hendrik Sauer 2021-06-02 17:22:38 +02:00 committed by Patrick Rathje
parent f783970389
commit b627efc44b
3 changed files with 16 additions and 17 deletions

View File

@ -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"

View File

@ -1,16 +1,15 @@
#ifdef DISPLAY
#include <device.h>
#include <drivers/display.h>
#include <lvgl.h>
#endif
#include <stdio.h>
#include <string.h>
#include <zephyr.h>
#include "display.h"
#define LOG_LEVEL CONFIG_LOG_DEFAULT_LEVEL
#include <logging/log.h>
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);

View File

@ -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);