summaryrefslogtreecommitdiff
path: root/fw/fe310/test/app
diff options
context:
space:
mode:
Diffstat (limited to 'fw/fe310/test/app')
-rw-r--r--fw/fe310/test/app/Makefile15
-rw-r--r--fw/fe310/test/app/app_root.c88
-rw-r--r--fw/fe310/test/app/app_root.h12
-rw-r--r--fw/fe310/test/app/app_status.c76
-rw-r--r--fw/fe310/test/app/app_status.h5
5 files changed, 196 insertions, 0 deletions
diff --git a/fw/fe310/test/app/Makefile b/fw/fe310/test/app/Makefile
new file mode 100644
index 0000000..fe0ba21
--- /dev/null
+++ b/fw/fe310/test/app/Makefile
@@ -0,0 +1,15 @@
+include ../../common.mk
+
+obj = app_root.o app_status.o
+
+
+%.o: %.c %.h
+ $(CC) $(CFLAGS) -c $<
+
+%.o: %.S
+ $(CC) $(CFLAGS) -c $<
+
+all: $(obj)
+
+clean:
+ rm -f *.o
diff --git a/fw/fe310/test/app/app_root.c b/fw/fe310/test/app/app_root.c
new file mode 100644
index 0000000..7dda3c7
--- /dev/null
+++ b/fw/fe310/test/app/app_root.c
@@ -0,0 +1,88 @@
+#include <stdlib.h>
+
+#include <net.h>
+
+#include <eve/eve.h>
+#include <eve/eve_kbd.h>
+#include <eve/eve_font.h>
+
+#include <eve/screen/window.h>
+#include <eve/screen/page.h>
+#include <eve/screen/form.h>
+
+#include <eve/widget/widgets.h>
+
+#include "app_status.h"
+#include "app_root.h"
+
+#define KBD_X 0
+#define KBD_Y 575
+#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;
+}
+
+void app_root_refresh(void) {
+ eve_spi_start();
+ eve_window_root_draw(app_root());
+ eve_spi_stop();
+}
+
+void app_root_init(eve_view_constructor_t home_page, int b) {
+ EVERect g;
+
+ eve_spi_start();
+
+ 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");
+ eve_view_init(&view_status, &win_status, app_status_draw, app_status_touch, NULL, NULL);
+
+ 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_view_stack_init(&view_stack);
+ eve_view_create(&win_main, &view_stack, home_page);
+
+ eve_window_append(&win_status);
+ eve_window_append(&win_main);
+
+ eve_window_root_draw(&win_root);
+
+ eve_spi_stop();
+
+ eos_net_acquire_for_evt(EOS_EVT_UI | EVE_ETYPE_INTR, 1);
+}
diff --git a/fw/fe310/test/app/app_root.h b/fw/fe310/test/app/app_root.h
new file mode 100644
index 0000000..b085344
--- /dev/null
+++ b/fw/fe310/test/app/app_root.h
@@ -0,0 +1,12 @@
+#include <stdint.h>
+
+#define APP_SCREEN_W 480
+#define APP_SCREEN_H 800
+#define APP_STATUS_H 60
+
+#define APP_FONT_HANDLE 31
+
+EVEWindowRoot *app_root(void);
+void app_root_refresh(void);
+
+void app_root_init(eve_view_constructor_t home_page, int b);
diff --git a/fw/fe310/test/app/app_status.c b/fw/fe310/test/app/app_status.c
new file mode 100644
index 0000000..cc25599
--- /dev/null
+++ b/fw/fe310/test/app/app_status.c
@@ -0,0 +1,76 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+
+#include <eos.h>
+#include <net.h>
+#include <cell.h>
+
+#include <eve/eve.h>
+#include <eve/eve_kbd.h>
+#include <eve/eve_font.h>
+
+#include <eve/screen/window.h>
+#include <eve/screen/page.h>
+#include <eve/screen/form.h>
+
+#include <eve/widget/widgets.h>
+
+#include "app_root.h"
+#include "app_status.h"
+
+#include "../phone.h"
+
+static char status_msg[128];
+
+int app_status_touch(EVEView *view, EVETouch *touch, uint16_t evt, uint8_t tag0) {
+ unsigned char state = 0;
+ int8_t touch_idx;
+
+ // state = app_phone_state_get();
+ touch_idx = eve_touch_get_idx(touch);
+ if (touch_idx != 0) return 0;
+
+ evt = eve_touch_evt(touch, evt, tag0, view->tag, 2);
+ if (touch && (evt & EVE_TOUCH_ETYPE_POINT_UP)) {
+ if ((state == VOICE_STATE_RING) && (touch->eevt & EVE_TOUCH_EETYPE_TRACK_LEFT)) {
+ unsigned char *buf = eos_net_alloc();
+
+ buf[0] = EOS_CELL_MTYPE_VOICE | EOS_CELL_MTYPE_VOICE_ANSWER;
+ eos_net_send_async(EOS_NET_MTYPE_CELL, buf, 1, 0);
+ status_msg[0] = '\0';
+ }
+ if ((state != VOICE_STATE_IDLE) && (touch->eevt & EVE_TOUCH_EETYPE_TRACK_RIGHT)) {
+ unsigned char *buf = eos_net_alloc();
+
+ buf[0] = EOS_CELL_MTYPE_VOICE | EOS_CELL_MTYPE_VOICE_HANGUP;
+ eos_net_send_async(EOS_NET_MTYPE_CELL, buf, 1, 0);
+ status_msg[0] = '\0';
+ }
+ 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;
+
+ 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++;
+ }
+
+ eve_cmd(CMD_TEXT, "hhhhs", 0, 0, 31, 0, status_msg);
+
+ return tag0;
+}
+
+void app_status_msg_set(char *msg, int refresh) {
+ strcpy(status_msg, msg);
+
+ if (refresh) app_root_refresh();
+}
diff --git a/fw/fe310/test/app/app_status.h b/fw/fe310/test/app/app_status.h
new file mode 100644
index 0000000..262d29c
--- /dev/null
+++ b/fw/fe310/test/app/app_status.h
@@ -0,0 +1,5 @@
+#include <stdint.h>
+
+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_msg_set(char *msg, int refresh);