From 1e5eb7cb910e6f23c69c2c986b6373e9f9abb980 Mon Sep 17 00:00:00 2001 From: Uros Majstorovic Date: Sun, 23 Aug 2020 22:37:16 +0200 Subject: dynamic memory alloc for gui added; page navigation added --- fw/fe310/eos/app/Makefile | 17 ++++++ fw/fe310/eos/app/root.c | 133 ++++++++++++++++++++++++++++++++++++++++++++++ fw/fe310/eos/app/root.h | 27 ++++++++++ fw/fe310/eos/app/status.c | 23 ++++++++ fw/fe310/eos/app/status.h | 4 ++ 5 files changed, 204 insertions(+) create mode 100644 fw/fe310/eos/app/Makefile create mode 100644 fw/fe310/eos/app/root.c create mode 100644 fw/fe310/eos/app/root.h create mode 100644 fw/fe310/eos/app/status.c create mode 100644 fw/fe310/eos/app/status.h (limited to 'fw/fe310/eos/app') diff --git a/fw/fe310/eos/app/Makefile b/fw/fe310/eos/app/Makefile new file mode 100644 index 0000000..7bb9951 --- /dev/null +++ b/fw/fe310/eos/app/Makefile @@ -0,0 +1,17 @@ +include ../../common.mk + +CFLAGS += -I.. + +obj = root.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/eos/app/root.c b/fw/fe310/eos/app/root.c new file mode 100644 index 0000000..160316f --- /dev/null +++ b/fw/fe310/eos/app/root.c @@ -0,0 +1,133 @@ +#include + +#include "net.h" +#include "unicode.h" + +#include "eve/eve.h" +#include "eve/eve_kbd.h" + +#include "eve/screen/screen.h" +#include "eve/screen/window.h" +#include "eve/screen/kbdwin.h" +#include "eve/screen/page.h" +#include "eve/screen/form.h" + +#include "eve/widget/widgets.h" + +#include "status.h" +#include "root.h" + +EVEFont _app_font_default; +extern eve_page_constructor_t _app_home_page; + +static EVEScreen screen; +static EVEWindow win_status; +static EVEWindow win_main; +static EVEKbdWin win_kbd; +static EVEView view_status = { + app_status_touch, + app_status_draw, + NULL +}; +static EVEPageStack page_stack; + +static void widgets_destroy(EVEWidget *widget, uint16_t widget_size) { + int i; + + for (i=0; ilabel) eve_free(widget->label); + eve_widget_destroy(widget); + } +} + +EVEForm *app_form_create(EVEWindow *window, EVEPageStack *stack, APPWidgetSpec spec[], uint16_t spec_size, eve_page_destructor_t destructor) { + EVEWidget *widgets; + EVEWidget *widget; + EVELabel *label; + EVEForm *form; + int w_size = 0; + int i, r; + + for (i=0; iwidget, form->widget_size); + eve_free(form->widget); + eve_free(form); +} + +void app_root_init(void) { + EVERect g; + + eos_spi_dev_start(EOS_DEV_DISP); + + eve_brightness(0x40); + eve_font_init(&_app_font_default, APP_FONT_HANDLE); + eve_screen_init(&screen, APP_SCREEN_W, APP_SCREEN_H); + + g.x = 0; + g.y = 0; + g.w = APP_SCREEN_W; + g.h = APP_STATUS_H; + eve_window_init(&win_status, &g, &view_status, &screen); + 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, NULL, &screen); + eve_kbdwin_init(&win_kbd, &screen); + + eve_page_stack_init(&page_stack); + eve_page_create(&win_main, &page_stack, _app_home_page); + + eve_window_append(&win_status); + eve_window_append(&win_main); + eve_kbdwin_append(&win_kbd); + eve_screen_draw(&screen); + + eos_spi_dev_stop(); + + eos_net_acquire_for_evt(EOS_EVT_UI | EVE_ETYPE_INTR, 1); +} diff --git a/fw/fe310/eos/app/root.h b/fw/fe310/eos/app/root.h new file mode 100644 index 0000000..09284e2 --- /dev/null +++ b/fw/fe310/eos/app/root.h @@ -0,0 +1,27 @@ +#include + +#define APP_SCREEN_W 480 +#define APP_SCREEN_H 800 +#define APP_STATUS_H 60 + +#define APP_FONT_HANDLE 31 + +typedef struct APPLabelSpec { + EVERect g; + EVEFont *font; + char *title; +} APPLabelSpec; + +typedef struct APPWidgetSpec { + APPLabelSpec label; + struct { + EVERect g; + EVEWidgetSpec spec; + uint8_t type; + } widget; +} APPWidgetSpec; + + +void app_root_init(void); +EVEForm *app_form_create(EVEWindow *window, EVEPageStack *stack, APPWidgetSpec spec[], uint16_t spec_size, eve_page_destructor_t destructor); +void app_form_destroy(EVEForm *form); \ No newline at end of file diff --git a/fw/fe310/eos/app/status.c b/fw/fe310/eos/app/status.c new file mode 100644 index 0000000..39c471e --- /dev/null +++ b/fw/fe310/eos/app/status.c @@ -0,0 +1,23 @@ + +#include + +#include "unicode.h" + +#include "eve/eve.h" +#include "eve/eve_kbd.h" + +#include "eve/screen/screen.h" +#include "eve/screen/window.h" +#include "eve/screen/page.h" + +#include "status.h" + +int app_status_touch(EVEView *v, uint8_t tag0, int touch_idx) { + return 0; +} + +uint8_t app_status_draw(EVEView *v, uint8_t tag0) { + return tag0; +} + + diff --git a/fw/fe310/eos/app/status.h b/fw/fe310/eos/app/status.h new file mode 100644 index 0000000..a121b13 --- /dev/null +++ b/fw/fe310/eos/app/status.h @@ -0,0 +1,4 @@ +#include + +int app_status_touch(EVEView *v, uint8_t tag0, int touch_idx); +uint8_t app_status_draw(EVEView *v, uint8_t tag0); -- cgit v1.2.3