From fc98d3809e0db36d634f290417b9152f87f83e3e Mon Sep 17 00:00:00 2001 From: Uros Majstorovic Date: Sun, 4 Sep 2022 18:37:42 +0200 Subject: new phone firmware --- fw/fe310/phone/app/Makefile | 15 +++++++ fw/fe310/phone/app/app.c | 106 ++++++++++++++++++++++++++++++++++++++++++++ fw/fe310/phone/app/app.h | 27 +++++++++++ fw/fe310/phone/app/log.h | 6 +++ fw/fe310/phone/app/status.c | 68 ++++++++++++++++++++++++++++ fw/fe310/phone/app/status.h | 6 +++ 6 files changed, 228 insertions(+) create mode 100644 fw/fe310/phone/app/Makefile create mode 100644 fw/fe310/phone/app/app.c create mode 100644 fw/fe310/phone/app/app.h create mode 100644 fw/fe310/phone/app/log.h create mode 100644 fw/fe310/phone/app/status.c create mode 100644 fw/fe310/phone/app/status.h (limited to 'fw/fe310/phone/app') diff --git a/fw/fe310/phone/app/Makefile b/fw/fe310/phone/app/Makefile new file mode 100644 index 0000000..8169de3 --- /dev/null +++ b/fw/fe310/phone/app/Makefile @@ -0,0 +1,15 @@ +include ../../common.mk + +obj = app.o status.o + + +%.o: %.c %.h + $(CC) $(CFLAGS) -c $< + +%.o: %.S + $(CC) $(CFLAGS) -c $< + +all: $(obj) + +clean: + rm -f *.o diff --git a/fw/fe310/phone/app/app.c b/fw/fe310/phone/app/app.c new file mode 100644 index 0000000..ae25545 --- /dev/null +++ b/fw/fe310/phone/app/app.c @@ -0,0 +1,106 @@ +#include + +#include + +#include +#include +#include + +#include +#include +#include + +#include "status.h" +#include "app.h" + +#define KBD_X 0 +#define KBD_Y 629 +#define KBD_W 480 +#define KBD_H 225 + +static EVEKbd kbd; +static EVEFont font; +static EVEWindowRoot win_root; +static EVEWindowKbd win_kbd; +static EVEWindow win_status; +static EVEWindow win_main; +static EVEView view_status; +static EVEViewStack view_stack; + +EVEWindowRoot *app_root(void) { + return &win_root; +} + +EVEViewStack *app_stack(void){ + return &view_stack; +} + +EVEFont *app_font(void) { + return &font; +} + +void app_refresh(void) { + eve_select(); + eve_window_root_draw(app_root()); + eve_deselect(); +} + +EVEView *app_search_view(char *name) { + EVEWindow *win = eve_window_search(&win_root.w, name); + + if (win) return win->view; + return NULL; +} + +eve_view_constructor_t app_current_view(void) { + return eve_stack_get(&view_stack); +} + +void app_init(eve_view_constructor_t home_page, int b) { + EVERect g; + + eve_select(); + + if (b >= 0) eve_brightness(b); + + eve_font_init(&font, APP_FONT_HANDLE); + + g.x = 0; + g.y = 0; + g.w = APP_SCREEN_W; + g.h = APP_SCREEN_H; + eve_window_init_root(&win_root, &g, "root", &font); + + g.x = KBD_X; + g.y = KBD_Y; + g.w = KBD_W; + g.h = KBD_H; + eve_kbd_init(&kbd, &g, win_root.mem_next, &win_root.mem_next); + eve_window_init_kbd(&win_kbd, &g, &win_root, "kbd", &kbd); + + g.x = 0; + g.y = 0; + g.w = APP_SCREEN_W; + g.h = APP_STATUS_H; + eve_window_init(&win_status, &g, (EVEWindow *)&win_root, "status"); + app_status_init(&view_status, &win_status); + + g.x = 0; + g.y = APP_STATUS_H; + g.w = APP_SCREEN_W; + g.h = APP_SCREEN_H - APP_STATUS_H; + eve_window_init(&win_main, &g, (EVEWindow *)&win_root, "main"); + + eve_stack_init(&view_stack); + eve_stack_create_view(&view_stack, &win_main, home_page); + + eve_window_append(&win_status); + eve_window_append(&win_main); + + eve_window_root_draw(&win_root); + + eve_deselect(); + + eos_net_acquire_for_evt(EOS_EVT_EVE | EVE_ETYPE_INTR, 1); + // eos_net_acquire_for_evt(EOS_EVT_TIMER | EOS_TIMER_ETYPE_EVE, 1); +} diff --git a/fw/fe310/phone/app/app.h b/fw/fe310/phone/app/app.h new file mode 100644 index 0000000..1ba2dca --- /dev/null +++ b/fw/fe310/phone/app/app.h @@ -0,0 +1,27 @@ +#include + +#include "log.h" + +#define APP_SCREEN_W 480 +#define APP_SCREEN_H 854 +#define APP_STATUS_H 60 + +#define APP_FONT_HANDLE 31 + +#define APP_SPEC_SIZE(spec) (sizeof(spec) / sizeof(EVEFormSpec)) +#define APP_SPACERW(__w__,__h__) { \ + .widget.type = EVE_WIDGET_TYPE_SPACER, \ + .widget.flags = EVE_WIDGET_FLAG_SKIP, \ + .widget.g.w = (__w__), \ + .widget.g.h = (__h__), \ +} + + +EVEWindowRoot *app_root(void); +EVEViewStack *app_stack(void); +EVEFont *app_font(void); + +void app_refresh(void); +EVEView *app_search_view(char *name); +eve_view_constructor_t app_current_view(void); +void app_init(eve_view_constructor_t home_page, int b); diff --git a/fw/fe310/phone/app/log.h b/fw/fe310/phone/app/log.h new file mode 100644 index 0000000..48ac5f0 --- /dev/null +++ b/fw/fe310/phone/app/log.h @@ -0,0 +1,6 @@ +#define APP_LOG_DEBUG 1 +#define APP_LOG_INFO 2 +#define APP_LOG_ERR 3 + +#define APP_LOG_LEVEL APP_LOG_DEBUG +#define APP_LOG(l, ...) (l >= APP_LOG_LEVEL ? fprintf(stderr, __VA_ARGS__) : 0 ) diff --git a/fw/fe310/phone/app/status.c b/fw/fe310/phone/app/status.c new file mode 100644 index 0000000..fec391b --- /dev/null +++ b/fw/fe310/phone/app/status.c @@ -0,0 +1,68 @@ +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include + +#include +#include +#include + +#include "app.h" +#include "status.h" + +void app_status_init(EVEView *view, EVEWindow *win) { + eve_view_init(view, win, app_status_draw, app_status_touch, NULL, NULL); + eve_view_set_color_bg(view, 0x20, 0x20, 0x20); +} + +int app_status_touch(EVEView *view, EVETouch *touch, uint16_t evt, uint8_t tag0) { + unsigned char state = 0; + int8_t touch_idx; + + /* only first touch */ + touch_idx = eve_touch_get_idx(touch); + if (touch_idx != 0) return 0; + + evt = eve_touch_evt(touch, evt, tag0, view->tag, 2); + if (evt & EVE_TOUCH_ETYPE_POINT_UP) { + view->param = NULL; + return 1; + } + return 0; +} + +uint8_t app_status_draw(EVEView *view, uint8_t tag0) { + uint8_t tag_opt = EVE_TOUCH_OPT_TRACK | EVE_TOUCH_OPT_TRACK_XY; + char *status_msg = view->param; + + tag0 = eve_view_clear(view, tag0, tag_opt); + + if (tag0 != EVE_NOTAG) { + eve_touch_set_opt(tag0, eve_touch_get_opt(tag0) | tag_opt); + eve_cmd_dl(TAG(tag0)); + tag0++; + } + + if (status_msg) eve_cmd(CMD_TEXT, "hhhhs", 0, 0, 31, 0, status_msg); + + return tag0; +} + +void app_status_set_msg(char *msg) { + EVEView *status; + + status = app_search_view("status"); + if (status == NULL) return; + + status->param = msg; + + if (!eve_selected()) app_refresh(); +} diff --git a/fw/fe310/phone/app/status.h b/fw/fe310/phone/app/status.h new file mode 100644 index 0000000..1350ae6 --- /dev/null +++ b/fw/fe310/phone/app/status.h @@ -0,0 +1,6 @@ +#include + +void app_status_init(EVEView *view, EVEWindow *win); +int app_status_touch(EVEView *view, EVETouch *touch, uint16_t evt, uint8_t tag0); +uint8_t app_status_draw(EVEView *view, uint8_t tag0); +void app_status_set_msg(char *msg); -- cgit v1.2.3