summaryrefslogtreecommitdiff
path: root/fw/fe310/eos
diff options
context:
space:
mode:
authorUros Majstorovic <majstor@majstor.org>2021-02-24 19:50:20 +0100
committerUros Majstorovic <majstor@majstor.org>2021-02-24 19:50:20 +0100
commit3050565531af2b3a09f2213893f10c64cf9fe43f (patch)
tree689d10ca064dba4480a85b6ec14a4eb8305d5c89 /fw/fe310/eos
parentd0a0fee0571be63f023f8f6a49a0b76b89871e56 (diff)
added test app with voice, wifi/cellular data connectivity examples
Diffstat (limited to 'fw/fe310/eos')
-rw-r--r--fw/fe310/eos/Makefile2
-rw-r--r--fw/fe310/eos/app/root.c7
-rw-r--r--fw/fe310/eos/app/root.h2
-rw-r--r--fw/fe310/eos/cell.c17
-rw-r--r--fw/fe310/eos/cell.h33
-rw-r--r--fw/fe310/eos/eve/eve.h4
-rw-r--r--fw/fe310/eos/eve/eve_kbd.c26
-rw-r--r--fw/fe310/eos/eve/eve_kbd.h1
-rw-r--r--fw/fe310/eos/eve/eve_platform.c13
-rw-r--r--fw/fe310/eos/eve/eve_platform.h9
-rw-r--r--fw/fe310/eos/eve/eve_text.c2
-rw-r--r--fw/fe310/eos/eve/eve_touch.c7
-rw-r--r--fw/fe310/eos/eve/eve_touch.h10
-rw-r--r--fw/fe310/eos/eve/screen/form.c84
-rw-r--r--fw/fe310/eos/eve/screen/form.h13
-rw-r--r--fw/fe310/eos/eve/screen/page.c39
-rw-r--r--fw/fe310/eos/eve/screen/page.h10
-rw-r--r--fw/fe310/eos/eve/screen/screen.c12
-rw-r--r--fw/fe310/eos/eve/widget/Makefile2
-rw-r--r--fw/fe310/eos/eve/widget/freew.c29
-rw-r--r--fw/fe310/eos/eve/widget/freew.h6
-rw-r--r--fw/fe310/eos/eve/widget/pagew.c28
-rw-r--r--fw/fe310/eos/eve/widget/pagew.h3
-rw-r--r--fw/fe310/eos/eve/widget/selectw.c24
-rw-r--r--fw/fe310/eos/eve/widget/selectw.h6
-rw-r--r--fw/fe310/eos/eve/widget/spacerw.c6
-rw-r--r--fw/fe310/eos/eve/widget/spacerw.h2
-rw-r--r--fw/fe310/eos/eve/widget/strw.c132
-rw-r--r--fw/fe310/eos/eve/widget/strw.h3
-rw-r--r--fw/fe310/eos/eve/widget/textw.c159
-rw-r--r--fw/fe310/eos/eve/widget/textw.h7
-rw-r--r--fw/fe310/eos/eve/widget/widget.c3
-rw-r--r--fw/fe310/eos/eve/widget/widget.h5
-rw-r--r--fw/fe310/eos/eve/widget/widgets.h2
-rw-r--r--fw/fe310/eos/net.c14
-rw-r--r--fw/fe310/eos/power.c9
-rw-r--r--fw/fe310/eos/power.h5
-rw-r--r--fw/fe310/eos/sock.c9
-rw-r--r--fw/fe310/eos/sock.h1
-rw-r--r--fw/fe310/eos/wifi.c15
-rw-r--r--fw/fe310/eos/wifi.h10
41 files changed, 407 insertions, 364 deletions
diff --git a/fw/fe310/eos/Makefile b/fw/fe310/eos/Makefile
index ef08fd1..0b3d6fe 100644
--- a/fw/fe310/eos/Makefile
+++ b/fw/fe310/eos/Makefile
@@ -2,7 +2,7 @@ include ../common.mk
CFLAGS += -I. -I../bsp/include -I../bsp/drivers
-obj = trap_entry.o eos.o msgq.o event.o interrupt.o timer.o power.o i2s.o uart.o spi.o spi_dev.o net.o wifi.o cell.o sock.o unicode.o
+obj = trap_entry.o eos.o msgq.o event.o interrupt.o timer.o power.o i2s.o i2c.o uart.o spi.o spi_dev.o net.o wifi.o cell.o sock.o unicode.o
%.o: %.c %.h
diff --git a/fw/fe310/eos/app/root.c b/fw/fe310/eos/app/root.c
index 6eb3fa6..a86b291 100644
--- a/fw/fe310/eos/app/root.c
+++ b/fw/fe310/eos/app/root.c
@@ -97,10 +97,11 @@ static void widgets_destroy(EVEWidget *widget, uint16_t widget_size) {
for (i=0; i<widget_size; i++) {
if (widget->label) eve_free(widget->label);
eve_widget_destroy(widget);
+ widget = eve_widget_next(widget);
}
}
-EVEForm *app_form_create(EVEWindow *window, EVEViewStack *stack, APPWidgetSpec spec[], uint16_t spec_size, eve_page_destructor_t destructor) {
+EVEForm *app_form_create(EVEWindow *window, EVEViewStack *stack, APPWidgetSpec spec[], uint16_t spec_size, eve_form_action_t action, eve_form_destructor_t destructor) {
EVEWidget *widgets;
EVEWidget *widget;
EVELabel *label;
@@ -146,8 +147,8 @@ EVEForm *app_form_create(EVEWindow *window, EVEViewStack *stack, APPWidgetSpec s
widget = eve_widget_next(widget);
}
- if (destructor == NULL) destructor = (eve_page_destructor_t)app_form_destroy;
- eve_form_init(form, window, stack, widgets, spec_size, destructor);
+ if (destructor == NULL) destructor = app_form_destroy;
+ eve_form_init(form, window, stack, widgets, spec_size, action, destructor);
return form;
}
diff --git a/fw/fe310/eos/app/root.h b/fw/fe310/eos/app/root.h
index 1885515..2b6fc63 100644
--- a/fw/fe310/eos/app/root.h
+++ b/fw/fe310/eos/app/root.h
@@ -24,5 +24,5 @@ typedef struct APPWidgetSpec {
EVEScreen *app_screen(void);
void app_root_init(eve_view_constructor_t home_page);
-EVEForm *app_form_create(EVEWindow *window, EVEViewStack *stack, APPWidgetSpec spec[], uint16_t spec_size, eve_page_destructor_t destructor);
+EVEForm *app_form_create(EVEWindow *window, EVEViewStack *stack, APPWidgetSpec spec[], uint16_t spec_size, eve_form_action_t action, eve_form_destructor_t destructor);
void app_form_destroy(EVEForm *form);
diff --git a/fw/fe310/eos/cell.c b/fw/fe310/eos/cell.c
index 452fb47..2886041 100644
--- a/fw/fe310/eos/cell.c
+++ b/fw/fe310/eos/cell.c
@@ -10,7 +10,7 @@
static eos_evt_handler_t evt_handler[EOS_CELL_MAX_MTYPE];
-static void cell_handle_evt(unsigned char type, unsigned char *buffer, uint16_t len) {
+static void cell_handle_msg(unsigned char type, unsigned char *buffer, uint16_t len) {
unsigned char mtype;
unsigned char idx;
@@ -28,19 +28,13 @@ static void cell_handle_evt(unsigned char type, unsigned char *buffer, uint16_t
}
}
-static void cell_handle_rdy(unsigned char type, unsigned char *buffer, uint16_t len) {
- // Do nothing
- eos_net_free(buffer, 0);
-}
-
void eos_cell_init(void) {
int i;
for (i=0; i<EOS_CELL_MAX_MTYPE; i++) {
evt_handler[i] = NULL;
}
- eos_net_set_handler(EOS_NET_MTYPE_CELL, cell_handle_evt);
- eos_cell_set_handler(EOS_CELL_MTYPE_READY, cell_handle_rdy);
+ eos_net_set_handler(EOS_NET_MTYPE_CELL, cell_handle_msg);
}
void eos_cell_set_handler(unsigned char mtype, eos_evt_handler_t handler) {
@@ -48,3 +42,10 @@ void eos_cell_set_handler(unsigned char mtype, eos_evt_handler_t handler) {
if (idx < EOS_CELL_MAX_MTYPE) evt_handler[idx] = handler;
}
+
+eos_evt_handler_t eos_cell_get_handler(unsigned char mtype) {
+ unsigned char idx = (mtype & EOS_CELL_MTYPE_MASK) >> 4;
+
+ if (idx < EOS_CELL_MAX_MTYPE) return evt_handler[idx];
+ return NULL;
+}
diff --git a/fw/fe310/eos/cell.h b/fw/fe310/eos/cell.h
index 371f7ba..90bb349 100644
--- a/fw/fe310/eos/cell.h
+++ b/fw/fe310/eos/cell.h
@@ -1,23 +1,25 @@
#include <stdint.h>
#include "event.h"
-#define EOS_CELL_MTYPE_DEV 0x00
-#define EOS_CELL_MTYPE_VOICE 0x10
-#define EOS_CELL_MTYPE_SMS 0x20
-#define EOS_CELL_MTYPE_CBS 0x30
-#define EOS_CELL_MTYPE_USSD 0x40
+#define EOS_CELL_MTYPE_DEV 0x10
+#define EOS_CELL_MTYPE_VOICE 0x20
+#define EOS_CELL_MTYPE_SMS 0x30
+#define EOS_CELL_MTYPE_CBS 0x40
+#define EOS_CELL_MTYPE_USSD 0x50
#define EOS_CELL_MTYPE_DATA 0x70
#define EOS_CELL_MTYPE_MASK 0xf0
#define EOS_CELL_MAX_MTYPE 8
-#define EOS_CELL_MTYPE_READY 0
-#define EOS_CELL_MTYPE_UART_DATA 1
-#define EOS_CELL_MTYPE_UART_TAKE 2
-#define EOS_CELL_MTYPE_UART_GIVE 3
-#define EOS_CELL_MTYPE_PCM_DATA 4
-#define EOS_CELL_MTYPE_PCM_START 5
-#define EOS_CELL_MTYPE_PCM_STOP 6
+/* EOS_CELL_MTYPE_DEV subtypes */
+#define EOS_CELL_MTYPE_READY 1
+#define EOS_CELL_MTYPE_UART_DATA 2
+#define EOS_CELL_MTYPE_UART_TAKE 3
+#define EOS_CELL_MTYPE_UART_GIVE 4
+#define EOS_CELL_MTYPE_PCM_DATA 5
+#define EOS_CELL_MTYPE_PCM_START 6
+#define EOS_CELL_MTYPE_PCM_STOP 7
+#define EOS_CELL_MTYPE_RESET 8
#define EOS_CELL_MTYPE_VOICE_DIAL 1
#define EOS_CELL_MTYPE_VOICE_RING 2
@@ -25,7 +27,9 @@
#define EOS_CELL_MTYPE_VOICE_HANGUP 4
#define EOS_CELL_MTYPE_VOICE_BEGIN 5
#define EOS_CELL_MTYPE_VOICE_END 6
-#define EOS_CELL_MTYPE_VOICE_MISSED 7
+#define EOS_CELL_MTYPE_VOICE_MISS 7
+#define EOS_CELL_MTYPE_VOICE_BUSY 8
+#define EOS_CELL_MTYPE_VOICE_ERR 9
#define EOS_CELL_MTYPE_SMS_LIST 1
#define EOS_CELL_MTYPE_SMS_SEND 2
@@ -45,4 +49,5 @@
#define EOS_CELL_SMS_ADDRTYPE_OTHER 3
void eos_cell_init(void);
-void eos_cell_set_handler(unsigned char mtype, eos_evt_handler_t handler); \ No newline at end of file
+void eos_cell_set_handler(unsigned char mtype, eos_evt_handler_t handler);
+eos_evt_handler_t eos_cell_get_handler(unsigned char mtype); \ No newline at end of file
diff --git a/fw/fe310/eos/eve/eve.h b/fw/fe310/eos/eve/eve.h
index e204158..e0583f0 100644
--- a/fw/fe310/eos/eve/eve.h
+++ b/fw/fe310/eos/eve/eve.h
@@ -7,6 +7,10 @@
#define EVE_OK 0
#define EVE_ERR -1
+
+#define EVE_ERR_FULL -10
+#define EVE_ERR_EMPTY -11
+
#define EVE_ERR_NOMEM -100
#define EVE_PSTATE_ACTIVE 0
diff --git a/fw/fe310/eos/eve/eve_kbd.c b/fw/fe310/eos/eve/eve_kbd.c
index 99210ce..5dd4d5a 100644
--- a/fw/fe310/eos/eve/eve_kbd.c
+++ b/fw/fe310/eos/eve/eve_kbd.c
@@ -38,24 +38,36 @@ void eve_kbd_init(EVEKbd *kbd, EVERect *g, uint32_t mem_addr, uint32_t *mem_next
}
kbd->mem_addr = mem_addr;
kbd->key_modifier = 0;
+ kbd->key_modifier_sticky = 0;
+ kbd->key_modifier_lock = 0;
kbd->key_count = 0;
kbd->key_down = 0;
kbd->putc = NULL;
kbd->param = NULL;
- kbd->active = 1;
+ kbd->key_down = 0xff;
eve_write16(REG_CMD_DL, 0);
eve_kbd_draw(kbd);
eve_cmd_exec(1);
mem_size = eve_read16(REG_CMD_DL);
eve_cmd(CMD_MEMCPY, "www", mem_addr, EVE_RAM_DL, mem_size);
eve_cmd_exec(1);
- kbd->active = 0;
+ kbd->key_down = 0;
kbd->mem_size = mem_size;
*mem_next = kbd->mem_addr + kbd->mem_size;
}
+void eve_kbd_close(EVEKbd *kbd) {
+ kbd->key_modifier = 0;
+ kbd->key_modifier_sticky = 0;
+ kbd->key_modifier_lock = 0;
+ kbd->key_count = 0;
+ kbd->key_down = 0;
+ kbd->putc = NULL;
+ kbd->param = NULL;
+}
+
void eve_kbd_set_handler(EVEKbd *kbd, eve_kbd_input_handler_t putc, void *param) {
kbd->putc = putc;
kbd->param = param;
@@ -64,9 +76,12 @@ void eve_kbd_set_handler(EVEKbd *kbd, eve_kbd_input_handler_t putc, void *param)
int eve_kbd_touch(EVEKbd *kbd, uint8_t tag0, int touch_idx) {
EVETouch *t;
uint16_t evt;
+ int ret;
t = eve_touch_evt(tag0, touch_idx, 1, 126, &evt);
if (t && evt) {
+ ret = 1;
+
if (evt & EVE_TOUCH_ETYPE_TAG) {
uint8_t _tag = t->tag;
@@ -117,16 +132,15 @@ int eve_kbd_touch(EVEKbd *kbd, uint8_t tag0, int touch_idx) {
}
}
}
- kbd->active = 1;
} else {
- kbd->active = 0;
+ ret = 0;
}
- return kbd->active;
+ return ret;
}
uint8_t eve_kbd_draw(EVEKbd *kbd) {
- if (kbd->active) {
+ if (kbd->key_down || kbd->key_modifier) {
int x = kbd->g.x;
int y = kbd->g.y;
int w = kbd->g.w;
diff --git a/fw/fe310/eos/eve/eve_kbd.h b/fw/fe310/eos/eve/eve_kbd.h
index b27f54d..7746472 100644
--- a/fw/fe310/eos/eve/eve_kbd.h
+++ b/fw/fe310/eos/eve/eve_kbd.h
@@ -17,6 +17,7 @@ typedef struct EVEKbd {
} EVEKbd;
void eve_kbd_init(EVEKbd *kbd, EVERect *g, uint32_t mem_addr, uint32_t *mem_next);
+void eve_kbd_close(EVEKbd *kbd);
void eve_kbd_set_handler(EVEKbd *kbd, eve_kbd_input_handler_t putc, void *param);
int eve_kbd_touch(EVEKbd *kbd, uint8_t tag0, int touch_idx);
uint8_t eve_kbd_draw(EVEKbd *kbd);
diff --git a/fw/fe310/eos/eve/eve_platform.c b/fw/fe310/eos/eve/eve_platform.c
index e64d326..7f1b775 100644
--- a/fw/fe310/eos/eve/eve_platform.c
+++ b/fw/fe310/eos/eve/eve_platform.c
@@ -61,3 +61,16 @@ void eve_platform_init(void) {
eos_spi_dev_set_div(EOS_DEV_DISP, 4);
}
+
+#include <stdio.h>
+
+void *eve_malloc(size_t size) {
+ void *p = malloc(size);
+ printf("MALLOC:%p %d\n", p, size);
+ return p;
+}
+
+void eve_free(void *p) {
+ printf("FREE:%p\n", p);
+ free(p);
+}
diff --git a/fw/fe310/eos/eve/eve_platform.h b/fw/fe310/eos/eve/eve_platform.h
index 514c4ee..7d085db 100644
--- a/fw/fe310/eos/eve/eve_platform.h
+++ b/fw/fe310/eos/eve/eve_platform.h
@@ -19,12 +19,15 @@
#define eve_spi_xchg24 eos_spi_xchg24
#define eve_spi_xchg32 eos_spi_xchg32
-#define eve_malloc malloc
-#define eve_free free
-
void eve_time_sleep(uint32_t ms);
void eve_timer_set(uint32_t ms);
void eve_timer_clear(void);
uint64_t eve_time_get_tick(void);
void eve_platform_init(void);
+
+//#define eve_malloc malloc
+//#define eve_free free
+
+void *eve_malloc(size_t);
+void eve_free(void *); \ No newline at end of file
diff --git a/fw/fe310/eos/eve/eve_text.c b/fw/fe310/eos/eve/eve_text.c
index 7a42a24..d23d012 100644
--- a/fw/fe310/eos/eve/eve_text.c
+++ b/fw/fe310/eos/eve/eve_text.c
@@ -151,7 +151,7 @@ uint8_t eve_text_draw(EVEText *box, uint8_t tag) {
box->tag = tag;
if (tag != EVE_TAG_NOTAG) {
eve_cmd_dl(TAG(tag));
- eve_touch_set_opt(tag, EVE_TOUCH_OPT_TRACK | EVE_TOUCH_OPT_TRACK_EXT);
+ eve_touch_set_opt(tag, EVE_TOUCH_OPT_TRACK | EVE_TOUCH_OPT_TRACK_EXT_Y);
tag++;
}
eve_cmd(CMD_APPEND, "ww", box->mem_addr + box->w * 2 * box->line_size, box->dl_size * 4);
diff --git a/fw/fe310/eos/eve/eve_touch.c b/fw/fe310/eos/eve/eve_touch.c
index a6db581..e3dae58 100644
--- a/fw/fe310/eos/eve/eve_touch.c
+++ b/fw/fe310/eos/eve/eve_touch.c
@@ -111,7 +111,7 @@ void eve_handle_touch(void) {
}
_touch_timer_clear();
}
- touch->evt = EVE_TOUCH_ETYPE_POINT | _eevt;
+ touch->evt = EVE_TOUCH_ETYPE_POINT | _evt;
touch->eevt = _eevt;
touch->tag0 = 0;
touch->tag = 0;
@@ -149,7 +149,10 @@ void eve_handle_touch(void) {
if (!_touch_timer.evt) _touch_timer_clear();
}
if (touch->tracker.tag && touch->tracker.track) {
- if (!_touch_timer.tag && (_tag_opt[touch->tracker.tag] & EVE_TOUCH_OPT_TRACK_EXT)) {
+ uint8_t opt = _tag_opt[touch->tracker.tag];
+ char track_ext = ((opt & EVE_TOUCH_OPT_TRACK_EXT_X) && (touch->eevt & EVE_TOUCH_EETYPE_TRACK_X)) ||
+ ((opt & EVE_TOUCH_OPT_TRACK_EXT_Y) && (touch->eevt & EVE_TOUCH_EETYPE_TRACK_Y));
+ if (!_touch_timer.tag && track_ext) {
_touch_timer_set(touch->tracker.tag, i, EVE_TOUCH_ETYPE_TRACK, touch->x, touch->y, EVE_TIMEOUT_TRACK);
if (_ext_tracker.init) _ext_tracker.init(&_touch_timer, touch);
} else {
diff --git a/fw/fe310/eos/eve/eve_touch.h b/fw/fe310/eos/eve/eve_touch.h
index 9f935bc..454dcc7 100644
--- a/fw/fe310/eos/eve/eve_touch.h
+++ b/fw/fe310/eos/eve/eve_touch.h
@@ -37,13 +37,15 @@
#define EVE_TOUCH_OPT_TRACK_REG EVE_TOUCH_ETYPE_TRACK_REG
#define EVE_TOUCH_OPT_TRACK_X 0x04
#define EVE_TOUCH_OPT_TRACK_Y 0x08
-#define EVE_TOUCH_OPT_TRACK_EXT 0x10
+#define EVE_TOUCH_OPT_TRACK_EXT_X 0x10
+#define EVE_TOUCH_OPT_TRACK_EXT_Y 0x20
#define EVE_TOUCH_OPT_LPRESS 0x40
#define EVE_TOUCH_OPT_DTAP 0x80
-#define EVE_TOUCH_OPT_TRACK_XY (EVE_TOUCH_OPT_TRACK_X | EVE_TOUCH_OPT_TRACK_Y)
-#define EVE_TOUCH_OPT_TRACK_MASK (EVE_TOUCH_OPT_TRACK | EVE_TOUCH_OPT_TRACK_REG)
-#define EVE_TOUCH_OPT_TIMER_MASK (EVE_TOUCH_OPT_LPRESS | EVE_TOUCH_OPT_DTAP)
+#define EVE_TOUCH_OPT_TRACK_XY (EVE_TOUCH_OPT_TRACK_X | EVE_TOUCH_OPT_TRACK_Y)
+#define EVE_TOUCH_OPT_TRACK_EXT_XY (EVE_TOUCH_OPT_TRACK_EXT_X | EVE_TOUCH_OPT_TRACK_EXT_Y)
+#define EVE_TOUCH_OPT_TRACK_MASK (EVE_TOUCH_OPT_TRACK | EVE_TOUCH_OPT_TRACK_REG)
+#define EVE_TOUCH_OPT_TIMER_MASK (EVE_TOUCH_OPT_LPRESS | EVE_TOUCH_OPT_DTAP)
typedef void (*eve_touch_handler_t) (void *, uint8_t, int);
diff --git a/fw/fe310/eos/eve/screen/form.c b/fw/fe310/eos/eve/screen/form.c
index fe1bd0d..cf5653b 100644
--- a/fw/fe310/eos/eve/screen/form.c
+++ b/fw/fe310/eos/eve/screen/form.c
@@ -18,39 +18,45 @@
#define MIN(X, Y) (((X) < (Y)) ? (X) : (Y))
#define MAX(X, Y) (((X) > (Y)) ? (X) : (Y))
-int eve_form_init(EVEForm *form, EVEWindow *window, EVEViewStack *stack, EVEWidget *widget, uint16_t widget_size, eve_page_destructor_t destructor) {
+int eve_form_init(EVEForm *form, EVEWindow *window, EVEViewStack *stack, EVEWidget *widget, uint16_t widget_size, eve_form_action_t action, eve_form_destructor_t destructor) {
memset(form, 0, sizeof(EVEForm));
- eve_page_init(&form->p, window, stack, eve_form_touch, eve_form_draw, eve_form_handle_evt, eve_form_update_g, destructor);
+ eve_page_init(&form->p, window, stack, eve_form_touch, eve_form_draw, (eve_page_destructor_t)destructor);
+
form->widget = widget;
form->widget_size = widget_size;
- eve_form_update_g(&form->p, NULL);
+ form->action = action;
+ eve_form_update_g(form, NULL);
}
int eve_form_touch(EVEView *v, uint8_t tag0, int touch_idx) {
EVEForm *form = (EVEForm *)v;
EVEWidget *widget = form->widget;
+ EVETouch *t;
+ uint16_t evt;
int i, ret = 0;
- if (touch_idx == 0) {
- EVETouch *t;
- uint16_t evt;
+ if (touch_idx > 0) return 0;
- t = eve_touch_evt(tag0, touch_idx, form->p.v.window->tag, 1, &evt);
- if (t && evt) {
- eve_form_handle_evt(&form->p, NULL, t, evt, tag0, touch_idx);
- if ((evt & EVE_TOUCH_ETYPE_POINT_UP) && (t->eevt == 0)) eve_page_set_focus(&form->p, NULL, NULL);
- ret = 1;
- }
+ t = eve_touch_evt(tag0, touch_idx, form->p.v.window->tag, 1, &evt);
+ if (t && evt) {
+ ret = eve_form_handle_evt(form, NULL, t, evt);
+ if ((evt & EVE_TOUCH_ETYPE_POINT_UP) && (t->eevt == 0)) eve_page_set_focus(&form->p, NULL, NULL);
+ if (ret) return 1;
}
for (i=0; i<form->widget_size; i++) {
if (eve_page_rect_visible(&form->p, &widget->g)) {
- int r = widget->touch(widget, &form->p, tag0, touch_idx);
- ret = ret || r;
+ t = eve_touch_evt(tag0, touch_idx, widget->tag0, widget->tagN - widget->tag0, &evt);
+ if (t && evt) {
+ ret = widget->touch(widget, &form->p, t, evt);
+ if (ret) return 1;
+ ret = eve_form_handle_evt(form, widget, t, evt);
+ if (ret) return 1;
+ }
}
widget = eve_widget_next(widget);
}
- return ret;
+ return 0;
}
uint8_t eve_form_draw(EVEView *v, uint8_t tag0) {
@@ -58,6 +64,7 @@ uint8_t eve_form_draw(EVEView *v, uint8_t tag0) {
EVEWidget *widget = form->widget;
int i;
uint8_t tagN = tag0;
+ uint8_t tag_opt = EVE_TOUCH_OPT_TRACK | EVE_TOUCH_OPT_TRACK_XY | EVE_TOUCH_OPT_TRACK_EXT_Y;
eve_cmd_dl(SAVE_CONTEXT());
eve_cmd_dl(VERTEX_FORMAT(0));
@@ -70,32 +77,25 @@ uint8_t eve_form_draw(EVEView *v, uint8_t tag0) {
eve_label_draw(widget->label);
eve_cmd_dl(TAG_MASK(1));
}
- if (eve_page_rect_visible(&form->p, &widget->g)) tagN = widget->draw(widget, &form->p, tagN);
+ if (eve_page_rect_visible(&form->p, &widget->g)) {
+ uint16_t h = widget->g.h;
+ tagN = widget->draw(widget, &form->p, tagN);
+ if (h != widget->g.h) eve_form_update_g(form, widget);
+ }
widget = eve_widget_next(widget);
}
eve_cmd_dl(RESTORE_CONTEXT());
for (i=tag0; i<tagN; i++) {
- eve_touch_set_opt(i, eve_touch_get_opt(i) | EVE_TOUCH_OPT_TRACK | EVE_TOUCH_OPT_TRACK_XY | EVE_TOUCH_OPT_TRACK_EXT);
+ eve_touch_set_opt(i, eve_touch_get_opt(i) | tag_opt);
}
- if (v->window->tag != EVE_TAG_NOTAG) eve_touch_set_opt(v->window->tag, eve_touch_get_opt(v->window->tag) | EVE_TOUCH_OPT_TRACK | EVE_TOUCH_OPT_TRACK_XY | EVE_TOUCH_OPT_TRACK_EXT);
+ if (v->window->tag != EVE_TAG_NOTAG) eve_touch_set_opt(v->window->tag, eve_touch_get_opt(v->window->tag) | tag_opt);
return tagN;
}
-int eve_form_handle_evt(EVEPage *page, EVEWidget *widget, EVETouch *touch, uint16_t evt, uint8_t tag0, int touch_idx) {
- /*
- if (evt & EVE_TOUCH_ETYPE_TRACK_Y) {
- // do scroll
- } else {
- // go back / forward
- }
- */
-}
-
-void eve_form_update_g(EVEPage *page, EVEWidget *_widget) {
- EVEForm *form = (EVEForm *)page;
+void eve_form_update_g(EVEForm *form, EVEWidget *_widget) {
EVEWidget *widget = form->widget;
int i;
uint16_t w = 0;
@@ -125,10 +125,34 @@ void eve_form_update_g(EVEPage *page, EVEWidget *_widget) {
}
}
+int eve_form_handle_evt(EVEForm *form, EVEWidget *widget, EVETouch *touch, uint16_t evt) {
+ static int16_t start;
+
+ if ((evt & EVE_TOUCH_ETYPE_TRACK) && (touch->eevt & EVE_TOUCH_EETYPE_TRACK_Y)) {
+ if (evt & EVE_TOUCH_ETYPE_TRACK_START) {
+ start = form->p.win_y;
+ }
+ form->p.win_y = start + touch->y0 - touch->y;
+ return 1;
+ }
+ if ((evt & EVE_TOUCH_ETYPE_POINT_UP) && (touch->eevt & EVE_TOUCH_EETYPE_TRACK_RIGHT)) {
+ eve_page_close((EVEPage *)form);
+ return 1;
+ }
+ if ((evt & EVE_TOUCH_ETYPE_POINT_UP) && (touch->eevt & EVE_TOUCH_EETYPE_TRACK_LEFT) && form->action) {
+ form->action(form);
+ return 1;
+ }
+
+ return 0;
+}
+
EVEWidget *eve_form_widget(EVEForm *form, uint16_t idx) {
EVEWidget *w = form->widget;
int i;
+ if (idx >= form->widget_size) return NULL;
+
for (i=0; i<idx; i++) {
w = eve_widget_next(w);
}
diff --git a/fw/fe310/eos/eve/screen/form.h b/fw/fe310/eos/eve/screen/form.h
index cab10b9..426a655 100644
--- a/fw/fe310/eos/eve/screen/form.h
+++ b/fw/fe310/eos/eve/screen/form.h
@@ -1,16 +1,23 @@
#include <stdint.h>
struct EVEWidget;
+struct EVEForm;
+
+typedef void (*eve_form_action_t) (struct EVEForm *);
+typedef void (*eve_form_destructor_t) (struct EVEForm *);
typedef struct EVEForm {
EVEPage p;
struct EVEWidget *widget;
uint16_t widget_size;
+ eve_form_action_t action;
} EVEForm;
-int eve_form_init(EVEForm *form, EVEWindow *window, EVEViewStack *stack, struct EVEWidget *widget, uint16_t widget_size, eve_page_destructor_t destructor);
+int eve_form_init(EVEForm *form, EVEWindow *window, EVEViewStack *stack, struct EVEWidget *widget, uint16_t widget_size, eve_form_action_t action, eve_form_destructor_t destructor);
+
int eve_form_touch(EVEView *v, uint8_t tag0, int touch_idx);
uint8_t eve_form_draw(EVEView *v, uint8_t tag0);
-int eve_form_handle_evt(EVEPage *page, struct EVEWidget *widget, EVETouch *touch, uint16_t evt, uint8_t tag0, int touch_idx);
-void eve_form_update_g(EVEPage *page, struct EVEWidget *widget);
+
+void eve_form_update_g(EVEForm *form, struct EVEWidget *widget);
+int eve_form_handle_evt(EVEForm *form, struct EVEWidget *widget, EVETouch *touch, uint16_t evt);
struct EVEWidget *eve_form_widget(EVEForm *form, uint16_t idx);
diff --git a/fw/fe310/eos/eve/screen/page.c b/fw/fe310/eos/eve/screen/page.c
index 9568ce6..980cf33 100644
--- a/fw/fe310/eos/eve/screen/page.c
+++ b/fw/fe310/eos/eve/screen/page.c
@@ -16,11 +16,9 @@
#define CH_EOF 0x1a
-void eve_page_init(EVEPage *page, EVEWindow *window, EVEViewStack *stack, eve_view_touch_t touch, eve_view_draw_t draw, eve_page_evt_handler_t handle_evt, eve_page_g_updater_t update_g, eve_page_destructor_t destructor) {
+void eve_page_init(EVEPage *page, EVEWindow *window, EVEViewStack *stack, eve_view_touch_t touch, eve_view_draw_t draw, eve_page_destructor_t destructor) {
memset(page, 0, sizeof(EVEPage));
eve_view_init(&page->v, window, touch, draw, NULL);
- page->handle_evt = handle_evt;
- page->update_g = update_g;
page->destructor = destructor;
page->stack = stack;
page->widget_f = NULL;
@@ -37,11 +35,15 @@ void eve_page_open(EVEPage *parent, eve_view_constructor_t constructor) {
void eve_page_close(EVEPage *page) {
EVEWindow *window = page->v.window;
+ EVEScreen *screen = window->screen;
EVEViewStack *stack = page->stack;
eve_page_destructor_t destructor = page->destructor;
- if (destructor) destructor(page);
- eve_view_destroy(window, stack);
+ if (stack->level > 1) {
+ if (destructor) destructor(page);
+ eve_screen_hide_kbd(screen);
+ eve_view_destroy(window, stack);
+ }
}
int16_t eve_page_x(EVEPage *page, int16_t x) {
@@ -62,21 +64,18 @@ int16_t eve_page_scr_y(EVEPage *page, int16_t y) {
void eve_page_set_focus(EVEPage *page, EVEWidget *widget, EVERect *f) {
if (page->widget_f != widget) {
- EVEKbd *kbd = eve_screen_get_kbd(page->v.window->screen);
-
- if (kbd) {
- EVEWidget *widget_f = page->widget_f;
-
- if (widget_f && widget_f->putc) {
- eve_screen_hide_kbd(page->v.window->screen);
- widget_f->putc(page, CH_EOF);
- }
- if (widget && widget->putc) {
- eve_kbd_set_handler(kbd, widget->putc, page);
- eve_screen_show_kbd(page->v.window->screen);
- } else {
- eve_kbd_set_handler(kbd, NULL, NULL);
- }
+ EVEScreen *screen = page->v.window->screen;
+ EVEWidget *widget_f = page->widget_f;
+
+ if (widget_f && widget_f->putc) {
+ eve_screen_hide_kbd(screen);
+ widget_f->putc(page, CH_EOF);
+ }
+ if (widget && widget->putc) {
+ EVEKbd *kbd = eve_screen_get_kbd(screen);
+
+ if (kbd) eve_kbd_set_handler(kbd, widget->putc, page);
+ eve_screen_show_kbd(screen);
}
page->widget_f = widget;
}
diff --git a/fw/fe310/eos/eve/screen/page.h b/fw/fe310/eos/eve/screen/page.h
index 168a017..ed558ba 100644
--- a/fw/fe310/eos/eve/screen/page.h
+++ b/fw/fe310/eos/eve/screen/page.h
@@ -1,24 +1,20 @@
#include <stdint.h>
-struct EVEPage;
struct EVEWidget;
+struct EVEPage;
-typedef int (*eve_page_evt_handler_t) (struct EVEPage *, struct EVEWidget *, EVETouch *, uint16_t, uint8_t, int);
-typedef void (*eve_page_g_updater_t) (struct EVEPage *, struct EVEWidget *);
typedef void (*eve_page_destructor_t) (struct EVEPage *);
typedef struct EVEPage {
EVEView v;
int16_t win_x;
int16_t win_y;
- eve_page_evt_handler_t handle_evt;
- eve_page_g_updater_t update_g;
eve_page_destructor_t destructor;
- struct EVEViewStack *stack;
+ EVEViewStack *stack;
struct EVEWidget *widget_f;
} EVEPage;
-void eve_page_init(EVEPage *page, EVEWindow *window, EVEViewStack *stack, eve_view_touch_t touch, eve_view_draw_t draw, eve_page_evt_handler_t handle_evt, eve_page_g_updater_t update_g, eve_page_destructor_t destructor);
+void eve_page_init(EVEPage *page, EVEWindow *window, EVEViewStack *stack, eve_view_touch_t touch, eve_view_draw_t draw, eve_page_destructor_t destructor);
void eve_page_open(EVEPage *parent, eve_view_constructor_t constructor);
void eve_page_close(EVEPage *page);
diff --git a/fw/fe310/eos/eve/screen/screen.c b/fw/fe310/eos/eve/screen/screen.c
index af5a91f..fa4a0aa 100644
--- a/fw/fe310/eos/eve/screen/screen.c
+++ b/fw/fe310/eos/eve/screen/screen.c
@@ -28,13 +28,17 @@ void eve_screen_show_kbd(EVEScreen *screen) {
EVEWindow *win = screen->win_tail;
EVEKbd *kbd = eve_screen_get_kbd(screen);
- if (win) win->g.y = screen->h - kbd->g.h;
+ if (win && kbd) win->g.y = screen->h - kbd->g.h;
}
void eve_screen_hide_kbd(EVEScreen *screen) {
EVEWindow *win = screen->win_tail;
+ EVEKbd *kbd = eve_screen_get_kbd(screen);
- if (win) win->g.y = screen->h;
+ if (win && kbd) {
+ win->g.y = screen->h;
+ eve_kbd_close(kbd);
+ }
}
void eve_screen_draw(EVEScreen *screen) {
@@ -87,6 +91,7 @@ void eve_screen_draw(EVEScreen *screen) {
void eve_screen_handle_touch(void *s, uint8_t tag0, int touch_idx) {
EVEScreen *screen = s;
EVEWindow *win;
+ int h;
eve_touch_clear_opt();
@@ -94,7 +99,8 @@ void eve_screen_handle_touch(void *s, uint8_t tag0, int touch_idx) {
win = screen->win_tail;
while (win) {
if (eve_window_visible(win)) {
- int a = win->view->touch(win->view, tag0, touch_idx);
+ h = win->view->touch(win->view, tag0, touch_idx);
+ if (h) break;
}
win = win->prev;
}
diff --git a/fw/fe310/eos/eve/widget/Makefile b/fw/fe310/eos/eve/widget/Makefile
index 720029e..fa5b41c 100644
--- a/fw/fe310/eos/eve/widget/Makefile
+++ b/fw/fe310/eos/eve/widget/Makefile
@@ -2,7 +2,7 @@ include ../../../common.mk
CFLAGS += -I.. -I../..
-obj = clipb.o font.o label.o widget.o freew.o spacerw.o pagew.o strw.o textw.o
+obj = clipb.o font.o label.o widget.o freew.o spacerw.o pagew.o strw.o textw.o selectw.o
%.o: %.c %.h
diff --git a/fw/fe310/eos/eve/widget/freew.c b/fw/fe310/eos/eve/widget/freew.c
index eaf982c..8fcc2f6 100644
--- a/fw/fe310/eos/eve/widget/freew.c
+++ b/fw/fe310/eos/eve/widget/freew.c
@@ -36,35 +36,26 @@ void eve_freew_update(EVEFreeWidget *widget, eve_freew_touch_t touch, eve_freew_
}
void eve_freew_tag(EVEFreeWidget *widget) {
- if (widget->tagN != EVE_TAG_NOTAG) {
- eve_cmd_dl(TAG(widget->tagN));
- widget->tagN++;
+ EVEWidget *_widget = &widget->w;
+
+ if (_widget->tagN != EVE_TAG_NOTAG) {
+ eve_cmd_dl(TAG(_widget->tagN));
+ _widget->tagN++;
}
}
-int eve_freew_touch(EVEWidget *_widget, EVEPage *page, uint8_t tag0, int touch_idx) {
+int eve_freew_touch(EVEWidget *_widget, EVEPage *page, EVETouch *t, uint16_t evt) {
EVEFreeWidget *widget = (EVEFreeWidget *)_widget;
- EVETouch *t;
- uint16_t evt;
- int ret = 0;
-
- if (touch_idx > 0) return 0;
-
- t = eve_touch_evt(tag0, touch_idx, widget->tag0, widget->tagN - widget->tag0, &evt);
- if (t && evt) {
- ret = widget->_touch(widget, page, t, evt, tag0, touch_idx);
- if (!ret && page && page->handle_evt) ret = page->handle_evt(page, _widget, t, evt, tag0, touch_idx);
- }
- return ret;
+ return widget->_touch(widget, page, t, evt);
}
uint8_t eve_freew_draw(EVEWidget *_widget, EVEPage *page, uint8_t tag0) {
EVEFreeWidget *widget = (EVEFreeWidget *)_widget;
- widget->tag0 = tag0;
- widget->tagN = tag0;
+ _widget->tag0 = tag0;
+ _widget->tagN = tag0;
widget->_draw(widget, page);
- return widget->tagN;
+ return _widget->tagN;
}
diff --git a/fw/fe310/eos/eve/widget/freew.h b/fw/fe310/eos/eve/widget/freew.h
index 3347e68..c7d8076 100644
--- a/fw/fe310/eos/eve/widget/freew.h
+++ b/fw/fe310/eos/eve/widget/freew.h
@@ -2,15 +2,13 @@
struct EVEFreeWidget;
-typedef int (*eve_freew_touch_t) (struct EVEFreeWidget *, EVEPage *, EVETouch *, uint16_t, uint8_t, int);
+typedef int (*eve_freew_touch_t) (struct EVEFreeWidget *, EVEPage *, EVETouch *, uint16_t);
typedef void (*eve_freew_draw_t) (struct EVEFreeWidget *, EVEPage *);
typedef struct EVEFreeWidget {
EVEWidget w;
eve_freew_touch_t _touch;
eve_freew_draw_t _draw;
- uint8_t tag0;
- uint8_t tagN;
} EVEFreeWidget;
typedef struct EVEFreeSpec {
@@ -24,5 +22,5 @@ void eve_freew_init(EVEFreeWidget *widget, EVERect *g, eve_freew_touch_t touch,
void eve_freew_update(EVEFreeWidget *widget, eve_freew_touch_t touch, eve_freew_draw_t draw, eve_kbd_input_handler_t putc);
void eve_freew_tag(EVEFreeWidget *widget);
-int eve_freew_touch(EVEWidget *_widget, EVEPage *page, uint8_t tag0, int touch_idx);
+int eve_freew_touch(EVEWidget *_widget, EVEPage *page, EVETouch *t, uint16_t evt);
uint8_t eve_freew_draw(EVEWidget *_widget, EVEPage *page, uint8_t tag0);
diff --git a/fw/fe310/eos/eve/widget/pagew.c b/fw/fe310/eos/eve/widget/pagew.c
index 319e207..2142cb9 100644
--- a/fw/fe310/eos/eve/widget/pagew.c
+++ b/fw/fe310/eos/eve/widget/pagew.c
@@ -39,36 +39,28 @@ void eve_pagew_update(EVEPageWidget *widget, EVEFont *font, char *title, eve_vie
if (_widget->g.h == 0) _widget->g.h = eve_font_h(font);
}
-int eve_pagew_touch(EVEWidget *_widget, EVEPage *page, uint8_t tag0, int touch_idx) {
+int eve_pagew_touch(EVEWidget *_widget, EVEPage *page, EVETouch *t, uint16_t evt) {
EVEPageWidget *widget = (EVEPageWidget *)_widget;
- EVETouch *t;
- uint16_t evt;
- int ret = 0;
-
- if (touch_idx > 0) return 0;
-
- t = eve_touch_evt(tag0, touch_idx, widget->tag, 1, &evt);
- if (t && evt) {
- if (evt & EVE_TOUCH_ETYPE_TRACK_MASK) {
- if (page->handle_evt) ret = page->handle_evt(page, _widget, t, evt, tag0, touch_idx);
- } else if (evt & EVE_TOUCH_ETYPE_TAG_UP) {
- eve_page_open(page, widget->constructor);
- ret = 1;
- }
+
+ if (evt & EVE_TOUCH_ETYPE_TAG_UP) {
+ eve_page_open(page, widget->constructor);
+ return 1;
}
- return ret;
+ return 0;
}
uint8_t eve_pagew_draw(EVEWidget *_widget, EVEPage *page, uint8_t tag0) {
EVEPageWidget *widget = (EVEPageWidget *)_widget;
- widget->tag = tag0;
+ _widget->tag0 = tag0;
if (tag0 != EVE_TAG_NOTAG) {
eve_cmd_dl(TAG(tag0));
tag0++;
}
+ _widget->tagN = tag0;
+
eve_cmd(CMD_TEXT, "hhhhs", _widget->g.x, _widget->g.y, widget->font->id, 0, widget->title);
- return tag0;
+ return _widget->tagN;
}
diff --git a/fw/fe310/eos/eve/widget/pagew.h b/fw/fe310/eos/eve/widget/pagew.h
index 67b1199..6560654 100644
--- a/fw/fe310/eos/eve/widget/pagew.h
+++ b/fw/fe310/eos/eve/widget/pagew.h
@@ -5,7 +5,6 @@ typedef struct EVEPageWidget {
char *title;
EVEFont *font;
eve_view_constructor_t constructor;
- uint8_t tag;
} EVEPageWidget;
typedef struct EVEPageSpec {
@@ -18,5 +17,5 @@ int eve_pagew_create(EVEPageWidget *widget, EVERect *g, EVEPageSpec *spec);
void eve_pagew_init(EVEPageWidget *widget, EVERect *g, EVEFont *font, char *title, eve_view_constructor_t constructor);
void eve_pagew_update(EVEPageWidget *widget, EVEFont *font, char *title, eve_view_constructor_t constructor);
-int eve_pagew_touch(EVEWidget *_widget, EVEPage *page, uint8_t tag0, int touch_idx);
+int eve_pagew_touch(EVEWidget *_widget, EVEPage *page, EVETouch *t, uint16_t evt);
uint8_t eve_pagew_draw(EVEWidget *_widget, EVEPage *page, uint8_t tag0);
diff --git a/fw/fe310/eos/eve/widget/selectw.c b/fw/fe310/eos/eve/widget/selectw.c
index 48f7f6d..eeb956f 100644
--- a/fw/fe310/eos/eve/widget/selectw.c
+++ b/fw/fe310/eos/eve/widget/selectw.c
@@ -50,11 +50,11 @@ void eve_selectw_update(EVESelectWidget *widget, EVEFont *font, utf8_t *option,
if (option) {
widget->option = option;
widget->option_size = option_size;
+ widget->select = SELECTW_NOSELECT;
}
- widget->select = SELECTW_NOSELECT;
}
-int eve_selectw_touch(EVEWidget *_widget, EVEPage *page, EVETouch *t, uint16_t evt, uint8_t tag0, int touch_idx) {
+int eve_selectw_touch(EVEWidget *_widget, EVEPage *page, EVETouch *t, uint16_t evt) {
EVESelectWidget *widget = (EVESelectWidget *)_widget;
if (evt & EVE_TOUCH_ETYPE_TAG_UP) {
@@ -111,11 +111,7 @@ uint8_t eve_selectw_draw(EVEWidget *_widget, EVEPage *page, uint8_t tag0) {
}
} while (o_len);
- new_h = i * widget->font->h;
- if (_widget->g.h != new_h) {
- _widget->g.h = new_h;
- if (page && page->update_g) page->update_g(page, _widget);
- }
+ _widget->g.h = i * widget->font->h;
return _widget->tagN;
}
@@ -138,10 +134,8 @@ utf8_t *eve_selectw_option_get(EVESelectWidget *widget, int idx) {
return NULL;
}
-int eve_selectw_option_set(EVESelectWidget *widget, utf8_t *opt, uint16_t size) {
- if (size > widget->option_size) return EVE_ERR_FULL;
- memcpy(widget->option, opt, size);
- memset(widget->option + size, 0, widget->option_size - size);
+utf8_t *eve_selectw_option_get_select(EVESelectWidget *widget) {
+ return eve_selectw_option_get(widget, widget->select);
}
int eve_selectw_option_add(EVESelectWidget *widget, utf8_t *opt) {
@@ -162,6 +156,10 @@ int eve_selectw_option_add(EVESelectWidget *widget, utf8_t *opt) {
return EVE_OK;
}
-utf8_t *eve_selectw_option_get_select(EVESelectWidget *widget) {
- return eve_selectw_option_get(widget, widget->select);
+int eve_selectw_option_set(EVESelectWidget *widget, utf8_t *opt, uint16_t size) {
+ if (size > widget->option_size) return EVE_ERR_FULL;
+ memcpy(widget->option, opt, size);
+ memset(widget->option + size, 0, widget->option_size - size);
+
+ return EVE_OK;
}
diff --git a/fw/fe310/eos/eve/widget/selectw.h b/fw/fe310/eos/eve/widget/selectw.h
index 6e2c203..953ba4a 100644
--- a/fw/fe310/eos/eve/widget/selectw.h
+++ b/fw/fe310/eos/eve/widget/selectw.h
@@ -18,10 +18,10 @@ void eve_selectw_destroy(EVESelectWidget *widget);
void eve_selectw_init(EVESelectWidget *widget, EVERect *g, EVEFont *font, utf8_t *option, uint16_t option_size);
void eve_selectw_update(EVESelectWidget *widget, EVEFont *font, utf8_t *option, uint16_t option_size);
-int eve_selectw_touch(EVEWidget *_widget, EVEPage *page, EVETouch *t, uint16_t evt, uint8_t tag0, int touch_idx);
+int eve_selectw_touch(EVEWidget *_widget, EVEPage *page, EVETouch *t, uint16_t evt);
uint8_t eve_selectw_draw(EVEWidget *_widget, EVEPage *page, uint8_t tag0);
utf8_t *eve_selectw_option_get(EVESelectWidget *widget, int idx);
-int eve_selectw_option_set(EVESelectWidget *widget, utf8_t *opt, uint16_t size);
-int eve_selectw_option_add(EVESelectWidget *widget, utf8_t *opt);
utf8_t *eve_selectw_option_get_select(EVESelectWidget *widget);
+int eve_selectw_option_add(EVESelectWidget *widget, utf8_t *opt);
+int eve_selectw_option_set(EVESelectWidget *widget, utf8_t *opt, uint16_t size);
diff --git a/fw/fe310/eos/eve/widget/spacerw.c b/fw/fe310/eos/eve/widget/spacerw.c
index e53c9c1..3a0216f 100644
--- a/fw/fe310/eos/eve/widget/spacerw.c
+++ b/fw/fe310/eos/eve/widget/spacerw.c
@@ -28,10 +28,12 @@ void eve_spacerw_init(EVESpacerWidget *widget, EVERect *g) {
eve_widget_init(_widget, EVE_WIDGET_TYPE_SPACER, g, eve_spacerw_touch, eve_spacerw_draw, NULL);
}
-int eve_spacerw_touch(EVEWidget *_widget, EVEPage *page, uint8_t tag0, int touch_idx) {
+int eve_spacerw_touch(EVEWidget *_widget, EVEPage *page, EVETouch *t, uint16_t evt) {
return 0;
}
uint8_t eve_spacerw_draw(EVEWidget *_widget, EVEPage *page, uint8_t tag0) {
- return tag0;
+ _widget->tag0 = tag0;
+ _widget->tagN = tag0;
+ return _widget->tagN;
}
diff --git a/fw/fe310/eos/eve/widget/spacerw.h b/fw/fe310/eos/eve/widget/spacerw.h
index cbde4e8..073f134 100644
--- a/fw/fe310/eos/eve/widget/spacerw.h
+++ b/fw/fe310/eos/eve/widget/spacerw.h
@@ -10,5 +10,5 @@ typedef struct EVESpacerSpec {
int eve_spacerw_create(EVESpacerWidget *widget, EVERect *g, EVESpacerSpec *spec);
void eve_spacerw_init(EVESpacerWidget *widget, EVERect *g);
-int eve_spacerw_touch(EVEWidget *_widget, EVEPage *page, uint8_t tag0, int touch_idx);
+int eve_spacerw_touch(EVEWidget *_widget, EVEPage *page, EVETouch *t, uint16_t evt);
uint8_t eve_spacerw_draw(EVEWidget *_widget, EVEPage *page, uint8_t tag0);
diff --git a/fw/fe310/eos/eve/widget/strw.c b/fw/fe310/eos/eve/widget/strw.c
index 0e1c97f..fe71b89 100644
--- a/fw/fe310/eos/eve/widget/strw.c
+++ b/fw/fe310/eos/eve/widget/strw.c
@@ -24,9 +24,9 @@
#define CH_CTRLC 0x03
#define CH_CTRLV 0x16
-#define STRW_TMODE_CURSOR 1
-#define STRW_TMODE_SCROLL_X 2
-#define STRW_TMODE_SCROLL_Y 3
+#define STRW_TRACK_NONE 0
+#define STRW_TRACK_CRSR 1
+#define STRW_TRACK_TXT 2
#define CHAR_VALID_INPUT(c) ((c >= 0x20) && (c < 0x7f))
@@ -97,93 +97,76 @@ static EVEStrCursor *cursor_prox(EVEStrWidget *widget, EVEStrCursor *cursor, EVE
return NULL;
}
-int eve_strw_touch(EVEWidget *_widget, EVEPage *page, uint8_t tag0, int touch_idx) {
+int eve_strw_touch(EVEWidget *_widget, EVEPage *page, EVETouch *t, uint16_t evt) {
EVEStrWidget *widget = (EVEStrWidget *)_widget;
- EVETouch *t;
- uint16_t evt;
+ EVEStrCursor *t_cursor = NULL;
+ short dx;
+ int ret = 0;
- if (touch_idx > 0) return 0;
-
- t = eve_touch_evt(tag0, touch_idx, widget->tag, 1, &evt);
- if (t && evt) {
- EVEStrCursor *t_cursor = NULL;
- short dx;
-
- if (evt & (EVE_TOUCH_ETYPE_LPRESS | EVE_TOUCH_ETYPE_TRACK_START)) {
- if (widget->cursor2.on) {
- t_cursor = cursor_prox(widget, &widget->cursor2, page, t, &dx);
- }
- if ((t_cursor == NULL) && widget->cursor1.on) {
- t_cursor = cursor_prox(widget, &widget->cursor1, page, t, &dx);
- }
- if (evt & EVE_TOUCH_ETYPE_TRACK_START) {
+ if (evt & (EVE_TOUCH_ETYPE_LPRESS | EVE_TOUCH_ETYPE_TRACK_START)) {
+ if (widget->cursor2.on) {
+ t_cursor = cursor_prox(widget, &widget->cursor2, page, t, &dx);
+ }
+ if ((t_cursor == NULL) && widget->cursor1.on) {
+ t_cursor = cursor_prox(widget, &widget->cursor1, page, t, &dx);
+ }
+ if (evt & EVE_TOUCH_ETYPE_TRACK_START) {
+ if (t_cursor) {
+ widget->track.mode = STRW_TRACK_CRSR;
widget->track.cursor = t_cursor;
- if (t_cursor) {
- widget->track.mode = STRW_TMODE_CURSOR;
- widget->track.dx = dx;
- } else if (t->eevt & EVE_TOUCH_EETYPE_TRACK_X) {
- widget->track.mode = STRW_TMODE_SCROLL_X;
- } else if (t->eevt & EVE_TOUCH_EETYPE_TRACK_Y) {
- widget->track.mode = STRW_TMODE_SCROLL_Y;
- }
+ widget->track.dx = dx;
+ } else if (t->eevt & EVE_TOUCH_EETYPE_TRACK_X) {
+ widget->track.mode = STRW_TRACK_TXT;
}
}
+ }
- switch (widget->track.mode) {
- case STRW_TMODE_SCROLL_Y:
- if (page->handle_evt) page->handle_evt(page, _widget, t, evt, tag0, touch_idx);
- break;
+ if ((evt & EVE_TOUCH_ETYPE_TRACK) && widget->track.mode) {
+ int x, w1;
- case STRW_TMODE_SCROLL_X:
+ switch (widget->track.mode) {
+ case STRW_TRACK_TXT:
if (evt & EVE_TOUCH_ETYPE_TRACK_START) {
widget->str_g.x0 = widget->str_g.x;
}
- if (evt & EVE_TOUCH_ETYPE_TRACK) {
- int x = widget->str_g.x0 + t->x0 - t->x;
- int w1 = widget->w.g.w - widget->font->w;
-
- if (x > widget->str_g.w - w1) x = widget->str_g.w - w1;
- if (x < 0) x = 0;
- widget->str_g.x = x;
- }
- break;
-
- case STRW_TMODE_CURSOR:
- if (evt & EVE_TOUCH_ETYPE_TRACK) eve_strw_cursor_set(widget, widget->track.cursor, eve_page_x(page, t->x) + widget->track.dx);
+ x = widget->str_g.x0 + t->x0 - t->x;
+ w1 = widget->w.g.w - widget->font->w;
+ if (x > widget->str_g.w - w1) x = widget->str_g.w - w1;
+ if (x < 0) x = 0;
+ widget->str_g.x = x;
break;
- default:
- if (evt & EVE_TOUCH_ETYPE_LPRESS) {
- if (widget->cursor2.on) {
- // copy
- } else if (widget->cursor1.on) {
- if (t_cursor) {
- // paste
- } else {
- eve_strw_cursor_set(widget, &widget->cursor2, eve_page_x(page, t->x));
- }
- } else {
- // select
- }
- }
- if ((evt & EVE_TOUCH_ETYPE_POINT_UP) && !(t->eevt & EVE_TOUCH_EETYPE_LPRESS)) {
- eve_strw_cursor_set(widget, &widget->cursor1, eve_page_x(page, t->x0));
- if (widget->cursor2.on) eve_strw_cursor_clear(widget, &widget->cursor2);
- set_focus(widget, page);
- }
+ case STRW_TRACK_CRSR:
+ eve_strw_cursor_set(widget, widget->track.cursor, eve_page_x(page, t->x) + widget->track.dx);
break;
}
-
- if (evt & EVE_TOUCH_ETYPE_TRACK_STOP) {
- widget->track.mode = 0;
- widget->track.cursor = NULL;
- widget->track.dx = 0;
+ ret = 1;
+ } else if (evt & EVE_TOUCH_ETYPE_LPRESS) {
+ if (widget->cursor2.on) {
+ // copy
+ } else if (widget->cursor1.on) {
+ if (t_cursor) {
+ // paste
+ } else {
+ eve_strw_cursor_set(widget, &widget->cursor2, eve_page_x(page, t->x));
+ }
+ } else {
+ // select
}
+ ret = 1;
+ } else if ((evt & EVE_TOUCH_ETYPE_POINT_UP) && !(t->eevt & EVE_TOUCH_EETYPE_LPRESS)) {
+ eve_strw_cursor_set(widget, &widget->cursor1, eve_page_x(page, t->x0));
+ if (widget->cursor2.on) eve_strw_cursor_clear(widget, &widget->cursor2);
+ set_focus(widget, page);
+ }
- return 1;
+ if (evt & EVE_TOUCH_ETYPE_TRACK_STOP) {
+ widget->track.mode = STRW_TRACK_NONE;
+ widget->track.cursor = NULL;
+ widget->track.dx = 0;
}
- return 0;
+ return ret;
}
static void _draw_str(EVEStrWidget *widget, EVEWindow *window, uint16_t ch, uint16_t len, uint16_t x1, uint16_t x2, char s) {
@@ -227,12 +210,13 @@ uint8_t eve_strw_draw(EVEWidget *_widget, EVEPage *page, uint8_t tag0) {
EVEStrWidget *widget = (EVEStrWidget *)_widget;
char cut = widget->str_g.x || (widget->str_g.w > _widget->g.w);
- widget->tag = tag0;
+ _widget->tag0 = tag0;
if (tag0 != EVE_TAG_NOTAG) {
eve_cmd_dl(TAG(tag0));
eve_touch_set_opt(tag0, EVE_TOUCH_OPT_LPRESS);
tag0++;
}
+ _widget->tagN = tag0;
if (cut) {
EVEWindow *window = page->v.window;
@@ -293,7 +277,7 @@ uint8_t eve_strw_draw(EVEWidget *_widget, EVEPage *page, uint8_t tag0) {
eve_cmd_dl(RESTORE_CONTEXT());
}
- return tag0;
+ return _widget->tagN;
}
void eve_strw_putc(void *_page, int c) {
diff --git a/fw/fe310/eos/eve/widget/strw.h b/fw/fe310/eos/eve/widget/strw.h
index 9456603..dcb34c1 100644
--- a/fw/fe310/eos/eve/widget/strw.h
+++ b/fw/fe310/eos/eve/widget/strw.h
@@ -19,7 +19,6 @@ typedef struct EVEStrWidget {
} str_g;
EVEStrCursor cursor1;
EVEStrCursor cursor2;
- uint8_t tag;
struct {
EVEStrCursor *cursor;
short dx;
@@ -37,7 +36,7 @@ void eve_strw_destroy(EVEStrWidget *widget);
void eve_strw_init(EVEStrWidget *widget, EVERect *g, EVEFont *font, utf8_t *str, uint16_t str_size);
void eve_strw_update(EVEStrWidget *widget, EVEFont *font, utf8_t *str, uint16_t str_size);
-int eve_strw_touch(EVEWidget *_widget, EVEPage *page, uint8_t tag0, int touch_idx);
+int eve_strw_touch(EVEWidget *_widget, EVEPage *page, EVETouch *t, uint16_t evt);
uint8_t eve_strw_draw(EVEWidget *_widget, EVEPage *page, uint8_t tag0);
void eve_strw_putc(void *_page, int c);
void eve_strw_cursor_set(EVEStrWidget *widget, EVEStrCursor *cursor, int16_t x);
diff --git a/fw/fe310/eos/eve/widget/textw.c b/fw/fe310/eos/eve/widget/textw.c
index c81031a..62cbeff 100644
--- a/fw/fe310/eos/eve/widget/textw.c
+++ b/fw/fe310/eos/eve/widget/textw.c
@@ -24,9 +24,6 @@
#define CH_CTRLC 0x03
#define CH_CTRLV 0x16
-#define TEXTW_TMODE_CURSOR 1
-#define TEXTW_TMODE_SCROLL 2
-
#define LINE_LEN(w,l) ((l) ? (w->line[l] ? w->line[l] - w->line[(l) - 1] - 1 : 0) : w->line[l])
#define LINE_START(w,l) ((l) ? w->line[(l) - 1] + 1 : 0)
#define LINE_END(w,l) (w->line[l])
@@ -88,7 +85,7 @@ void eve_textw_update(EVETextWidget *widget, EVEFont *font, utf8_t *text, uint16
widget->line_size = line_size;
}
memset(widget->line, 0xff, line_size * sizeof(uint16_t));
- eve_textw_text_update(widget, NULL, 0);
+ eve_textw_text_update(widget, 0);
}
static void set_focus(EVETextWidget *widget, EVETextCursor *cursor, EVEPage *page) {
@@ -105,7 +102,7 @@ static void set_focus(EVETextWidget *widget, EVETextCursor *cursor, EVEPage *pag
static EVETextCursor *cursor_prox(EVETextWidget *widget, EVETextCursor *cursor, EVEPage *page, EVETouch *t, short *dx, short *dl) {
EVEWidget *_widget = &widget->w;
int x = eve_page_x(page, t->x0) - _widget->g.x;
- int l = (int)t->tag0 - widget->tag0 + widget->line0;
+ int l = (int)t->tag0 - _widget->tag0 + widget->line0;
int _dx, _dl;
*dx = cursor->x - x;
@@ -118,81 +115,55 @@ static EVETextCursor *cursor_prox(EVETextWidget *widget, EVETextCursor *cursor,
return NULL;
}
-int eve_textw_touch(EVEWidget *_widget, EVEPage *page, uint8_t tag0, int touch_idx) {
+int eve_textw_touch(EVEWidget *_widget, EVEPage *page, EVETouch *t, uint16_t evt) {
EVETextWidget *widget = (EVETextWidget *)_widget;
- EVETouch *t;
- uint16_t evt;
-
- if (touch_idx > 0) return 0;
+ EVETextCursor *t_cursor = NULL;
+ short dx, dl;
+ int ret = 0;
- t = eve_touch_evt(tag0, touch_idx, widget->tag0, widget->tagN - widget->tag0, &evt);
- if (t && evt) {
- EVETextCursor *t_cursor = NULL;
- short dx, dl;
-
- if (evt & (EVE_TOUCH_ETYPE_LPRESS | EVE_TOUCH_ETYPE_TRACK_START)) {
- if (widget->cursor2.on) {
- t_cursor = cursor_prox(widget, &widget->cursor2, page, t, &dx, &dl);
- }
- if ((t_cursor == NULL) && widget->cursor1.on) {
- t_cursor = cursor_prox(widget, &widget->cursor1, page, t, &dx, &dl);
- }
- if (evt & EVE_TOUCH_ETYPE_TRACK_START) {
- widget->track.cursor = t_cursor;
- if (t_cursor) {
- widget->track.mode = TEXTW_TMODE_CURSOR;
- widget->track.dx = dx;
- widget->track.dl = dl;
- } else {
- widget->track.mode = TEXTW_TMODE_SCROLL;
- }
- }
+ if (evt & (EVE_TOUCH_ETYPE_LPRESS | EVE_TOUCH_ETYPE_TRACK_START)) {
+ if (widget->cursor2.on) {
+ t_cursor = cursor_prox(widget, &widget->cursor2, page, t, &dx, &dl);
}
-
- switch (widget->track.mode) {
- case TEXTW_TMODE_SCROLL:
- if (page->handle_evt) page->handle_evt(page, _widget, t, evt, tag0, touch_idx);
- break;
-
- case TEXTW_TMODE_CURSOR:
- if (evt & EVE_TOUCH_ETYPE_TRACK) {
- eve_textw_cursor_set(widget, widget->track.cursor, t->tag + widget->track.dl, eve_page_x(page, t->x) + widget->track.dx);
- }
- break;
-
- default:
- if (evt & EVE_TOUCH_ETYPE_LPRESS) {
- if (widget->cursor2.on) {
- // copy
- } else if (widget->cursor1.on) {
- if (t_cursor && (dl == 0)) {
- // paste
- } else {
- eve_textw_cursor_set(widget, &widget->cursor2, t->tag, eve_page_x(page, t->x));
- }
- } else {
- // select
- }
- }
- if ((evt & EVE_TOUCH_ETYPE_POINT_UP) && !(t->eevt & EVE_TOUCH_EETYPE_LPRESS)) {
- eve_textw_cursor_set(widget, &widget->cursor1, t->tag_up, eve_page_x(page, t->x0));
- if (widget->cursor2.on) eve_textw_cursor_clear(widget, &widget->cursor2);
- set_focus(widget, &widget->cursor1, page);
- }
- break;
+ if ((t_cursor == NULL) && widget->cursor1.on) {
+ t_cursor = cursor_prox(widget, &widget->cursor1, page, t, &dx, &dl);
}
+ if (t_cursor && (evt & EVE_TOUCH_ETYPE_TRACK_START)) {
+ widget->track.cursor = t_cursor;
+ widget->track.dx = dx;
+ widget->track.dl = dl;
+ }
+ }
- if (evt & EVE_TOUCH_ETYPE_TRACK_STOP) {
- widget->track.mode = 0;
- widget->track.cursor = NULL;
- widget->track.dx = 0;
- widget->track.dl = 0;
+ if ((evt & EVE_TOUCH_ETYPE_TRACK) && widget->track.cursor) {
+ eve_textw_cursor_set(widget, widget->track.cursor, t->tag + widget->track.dl, eve_page_x(page, t->x) + widget->track.dx);
+ ret = 1;
+ } else if (evt & EVE_TOUCH_ETYPE_LPRESS) {
+ if (widget->cursor2.on) {
+ // copy
+ } else if (widget->cursor1.on) {
+ if (t_cursor && (dl == 0)) {
+ // paste
+ } else {
+ eve_textw_cursor_set(widget, &widget->cursor2, t->tag, eve_page_x(page, t->x));
+ }
+ } else {
+ // select
}
+ ret = 1;
+ } else if ((evt & EVE_TOUCH_ETYPE_POINT_UP) && !(t->eevt & EVE_TOUCH_EETYPE_LPRESS)) {
+ eve_textw_cursor_set(widget, &widget->cursor1, t->tag_up, eve_page_x(page, t->x0));
+ if (widget->cursor2.on) eve_textw_cursor_clear(widget, &widget->cursor2);
+ set_focus(widget, &widget->cursor1, page);
+ }
- return 1;
+ if (evt & EVE_TOUCH_ETYPE_TRACK_STOP) {
+ widget->track.cursor = NULL;
+ widget->track.dx = 0;
+ widget->track.dl = 0;
}
- return 0;
+ return ret;
}
static void _draw_line(EVETextWidget *widget, EVEWindow *window, uint16_t l, uint16_t ch, uint16_t len, uint16_t x1, uint16_t x2, char s) {
@@ -250,8 +221,8 @@ uint8_t eve_textw_draw(EVEWidget *_widget, EVEPage *page, uint8_t tag0) {
EVETextCursor *c1, *c2;
widget->line0 = line0;
- widget->tag0 = tag0;
- widget->tagN = tag0;
+ _widget->tag0 = tag0;
+ _widget->tagN = tag0;
if (widget->cursor2.on) {
if (widget->cursor1.ch <= widget->cursor2.ch) {
@@ -267,10 +238,10 @@ uint8_t eve_textw_draw(EVEWidget *_widget, EVEPage *page, uint8_t tag0) {
}
for (i=line0; i<lineN; i++) {
- if (widget->tagN != EVE_TAG_NOTAG) {
- eve_cmd_dl(TAG(widget->tagN));
- eve_touch_set_opt(widget->tagN, EVE_TOUCH_OPT_LPRESS);
- widget->tagN++;
+ if (_widget->tagN != EVE_TAG_NOTAG) {
+ eve_cmd_dl(TAG(_widget->tagN));
+ eve_touch_set_opt(_widget->tagN, EVE_TOUCH_OPT_LPRESS);
+ _widget->tagN++;
}
if (!s && c1 && (c1->line == i)) {
int l1, l2, l3;
@@ -306,22 +277,22 @@ uint8_t eve_textw_draw(EVEWidget *_widget, EVEPage *page, uint8_t tag0) {
}
}
if (lineNvisible) {
- if (widget->tagN != EVE_TAG_NOTAG) {
- eve_cmd_dl(TAG(widget->tagN));
- eve_touch_set_opt(widget->tagN, EVE_TOUCH_OPT_LPRESS);
- widget->tagN++;
+ if (_widget->tagN != EVE_TAG_NOTAG) {
+ eve_cmd_dl(TAG(_widget->tagN));
+ eve_touch_set_opt(_widget->tagN, EVE_TOUCH_OPT_LPRESS);
+ _widget->tagN++;
}
_draw_line(widget, page->v.window, lineN, 0, 0, 0, _widget->g.w, 0);
}
-
- return widget->tagN;
} else {
widget->line0 = 0;
- widget->tag0 = EVE_TAG_NOTAG;
- widget->tagN = EVE_TAG_NOTAG;
-
- return tag0;
+ _widget->tag0 = EVE_TAG_NOTAG;
+ _widget->tagN = EVE_TAG_NOTAG;
}
+
+ _widget->g.h = (widget->line_len + 1) * widget->font->h;
+
+ return _widget->tagN;
}
void eve_textw_putc(void *_page, int c) {
@@ -428,8 +399,8 @@ void eve_textw_putc(void *_page, int c) {
}
r = cursor1->line;
- if (cursor1->line) r = eve_textw_text_update(widget, page, cursor1->line - 1);
- if ((cursor1->line == 0) || (r == cursor1->line - 1)) r = eve_textw_text_update(widget, page, cursor1->line);
+ if (cursor1->line) r = eve_textw_text_update(widget, cursor1->line - 1);
+ if ((cursor1->line == 0) || (r == cursor1->line - 1)) r = eve_textw_text_update(widget, cursor1->line);
if (cursor1->line && (cursor1->ch < LINE_START(widget, cursor1->line))) {
cursor1->line--;
@@ -444,7 +415,7 @@ void eve_textw_putc(void *_page, int c) {
}
}
-uint16_t eve_textw_text_update(EVETextWidget *widget, EVEPage *page, uint16_t line) {
+uint16_t eve_textw_text_update(EVETextWidget *widget, uint16_t line) {
int i;
utf32_t ch;
uint8_t ch_w;
@@ -501,16 +472,10 @@ uint16_t eve_textw_text_update(EVETextWidget *widget, EVEPage *page, uint16_t li
}
widget->line_len = line;
- new_h = (line + 1) * widget->font->h;
for (i=line; i<widget->line_size; i++) {
widget->line[i] = LINE_EMPTY;
}
- if (_widget->g.h != new_h) {
- _widget->g.h = new_h;
- if (page && page->update_g) page->update_g(page, _widget);
- }
-
return line;
}
@@ -537,7 +502,7 @@ void eve_textw_cursor_set(EVETextWidget *widget, EVETextCursor *cursor, uint8_t
uint8_t ch_l;
EVEWidget *_widget = &widget->w;
- if ((tag >= widget->tag0) && ((widget->tagN == EVE_TAG_NOTAG) || (tag < widget->tagN))) c_line = tag - widget->tag0 + widget->line0;
+ if ((tag >= _widget->tag0) && ((_widget->tagN == EVE_TAG_NOTAG) || (tag < _widget->tagN))) c_line = tag - _widget->tag0 + widget->line0;
if (c_line < widget->line_len) {
cursor->line = c_line;
} else if (c_line == widget->line_len) {
diff --git a/fw/fe310/eos/eve/widget/textw.h b/fw/fe310/eos/eve/widget/textw.h
index 36ab466..95f0091 100644
--- a/fw/fe310/eos/eve/widget/textw.h
+++ b/fw/fe310/eos/eve/widget/textw.h
@@ -19,13 +19,10 @@ typedef struct EVETextWidget {
EVETextCursor cursor1;
EVETextCursor cursor2;
uint16_t line0;
- uint8_t tag0;
- uint8_t tagN;
struct {
EVETextCursor *cursor;
short dx;
short dl;
- char mode;
} track;
} EVETextWidget;
@@ -40,10 +37,10 @@ void eve_textw_destroy(EVETextWidget *widget);
void eve_textw_init(EVETextWidget *widget, EVERect *g, EVEFont *font, utf8_t *text, uint16_t text_size, uint16_t *line, uint16_t line_size);
void eve_textw_update(EVETextWidget *widget, EVEFont *font, utf8_t *text, uint16_t text_size, uint16_t *line, uint16_t line_size);
-int eve_textw_touch(EVEWidget *_widget, EVEPage *page, uint8_t tag0, int touch_idx);
+int eve_textw_touch(EVEWidget *_widget, EVEPage *page, EVETouch *t, uint16_t evt);
uint8_t eve_textw_draw(EVEWidget *_widget, EVEPage *page, uint8_t tag0);
void eve_textw_putc(void *_w, int c);
-uint16_t eve_textw_text_update(EVETextWidget *widget, EVEPage *page, uint16_t line);
+uint16_t eve_textw_text_update(EVETextWidget *widget, uint16_t line);
void eve_textw_cursor_update(EVETextWidget *widget, EVETextCursor *cursor);
void eve_textw_cursor_set(EVETextWidget *widget, EVETextCursor *cursor, uint8_t tag, int16_t x);
void eve_textw_cursor_clear(EVETextWidget *widget, EVETextCursor *cursor);
diff --git a/fw/fe310/eos/eve/widget/widget.c b/fw/fe310/eos/eve/widget/widget.c
index 1d610bf..a223169 100644
--- a/fw/fe310/eos/eve/widget/widget.c
+++ b/fw/fe310/eos/eve/widget/widget.c
@@ -19,6 +19,7 @@ static const size_t _widget_size[] = {
sizeof(EVEPageWidget),
sizeof(EVEStrWidget),
sizeof(EVETextWidget),
+ sizeof(EVESelectWidget),
};
static const eve_widget_create_t _widget_create[] = {
@@ -28,6 +29,7 @@ static const eve_widget_create_t _widget_create[] = {
(eve_widget_create_t)eve_pagew_create,
(eve_widget_create_t)eve_strw_create,
(eve_widget_create_t)eve_textw_create,
+ (eve_widget_create_t)eve_selectw_create,
};
static const eve_widget_destroy_t _widget_destroy[] = {
@@ -37,6 +39,7 @@ static const eve_widget_destroy_t _widget_destroy[] = {
NULL,
(eve_widget_destroy_t)eve_strw_destroy,
(eve_widget_destroy_t)eve_textw_destroy,
+ (eve_widget_destroy_t)eve_selectw_destroy,
};
void eve_widget_init(EVEWidget *widget, uint8_t type, EVERect *g, eve_widget_touch_t touch, eve_widget_draw_t draw, eve_kbd_input_handler_t putc) {
diff --git a/fw/fe310/eos/eve/widget/widget.h b/fw/fe310/eos/eve/widget/widget.h
index cff5c1d..3e04f3e 100644
--- a/fw/fe310/eos/eve/widget/widget.h
+++ b/fw/fe310/eos/eve/widget/widget.h
@@ -5,10 +5,11 @@
#define EVE_WIDGET_TYPE_PAGE 3
#define EVE_WIDGET_TYPE_STR 4
#define EVE_WIDGET_TYPE_TEXT 5
+#define EVE_WIDGET_TYPE_SELECT 6
struct EVEWidget;
-typedef int (*eve_widget_touch_t) (struct EVEWidget *, EVEPage *, uint8_t, int);
+typedef int (*eve_widget_touch_t) (struct EVEWidget *, EVEPage *, EVETouch *, uint16_t);
typedef uint8_t (*eve_widget_draw_t) (struct EVEWidget *, EVEPage *, uint8_t);
typedef struct EVEWidget {
@@ -18,6 +19,8 @@ typedef struct EVEWidget {
eve_kbd_input_handler_t putc;
EVELabel *label;
uint8_t type;
+ uint8_t tag0;
+ uint8_t tagN;
} EVEWidget;
void eve_widget_init(EVEWidget *widget, uint8_t type, EVERect *g, eve_widget_touch_t touch, eve_widget_draw_t draw, eve_kbd_input_handler_t putc);
diff --git a/fw/fe310/eos/eve/widget/widgets.h b/fw/fe310/eos/eve/widget/widgets.h
index 4206894..542b350 100644
--- a/fw/fe310/eos/eve/widget/widgets.h
+++ b/fw/fe310/eos/eve/widget/widgets.h
@@ -7,6 +7,7 @@
#include "pagew.h"
#include "strw.h"
#include "textw.h"
+#include "selectw.h"
typedef union EVEWidgetSpec {
EVEFreeSpec free;
@@ -14,6 +15,7 @@ typedef union EVEWidgetSpec {
EVEPageSpec page;
EVEStrSpec str;
EVETextSpec text;
+ EVESelectSpec select;
} EVEWidgetSpec;
typedef int (*eve_widget_create_t) (EVEWidget *, EVERect *g, EVEWidgetSpec *);
diff --git a/fw/fe310/eos/net.c b/fw/fe310/eos/net.c
index 297e8f0..46700e8 100644
--- a/fw/fe310/eos/net.c
+++ b/fw/fe310/eos/net.c
@@ -456,10 +456,16 @@ void eos_net_release(void) {
unsigned char *eos_net_alloc(void) {
unsigned char *ret = NULL;
- clear_csr(mstatus, MSTATUS_MIE);
- ret = net_state_next_buf;
- net_state_next_buf = NULL;
- set_csr(mstatus, MSTATUS_MIE);
+ while (!ret) {
+ clear_csr(mstatus, MSTATUS_MIE);
+ if (net_state_next_buf) {
+ ret = net_state_next_buf;
+ net_state_next_buf = NULL;
+ } else {
+ asm volatile ("wfi");
+ }
+ set_csr(mstatus, MSTATUS_MIE);
+ }
return ret;
}
diff --git a/fw/fe310/eos/power.c b/fw/fe310/eos/power.c
index 2b13c9f..8717553 100644
--- a/fw/fe310/eos/power.c
+++ b/fw/fe310/eos/power.c
@@ -18,7 +18,7 @@
static eos_evt_handler_t evt_handler[EOS_PWR_MAX_MTYPE];
static unsigned char power_btn_down;
-static void power_handle_evt(unsigned char type, unsigned char *buffer, uint16_t len) {
+static void power_handle_msg(unsigned char type, unsigned char *buffer, uint16_t len) {
unsigned char mtype;
if ((buffer == NULL) || (len < 1)) {
@@ -53,7 +53,7 @@ void eos_power_init(void) {
for (i=0; i<EOS_PWR_MAX_MTYPE; i++) {
evt_handler[i] = NULL;
}
- eos_net_set_handler(EOS_NET_MTYPE_POWER, power_handle_evt);
+ eos_net_set_handler(EOS_NET_MTYPE_POWER, power_handle_msg);
eos_power_set_handler(EOS_PWR_MTYPE_BUTTON, power_handle_btn);
AON_REG(AON_PMUKEY) = 0x51F15E;
@@ -110,3 +110,8 @@ void eos_power_wake_disable(void) {
void eos_power_set_handler(unsigned char mtype, eos_evt_handler_t handler) {
if (mtype < EOS_PWR_MAX_MTYPE) evt_handler[mtype] = handler;
}
+
+eos_evt_handler_t eos_power_get_handler(unsigned char mtype) {
+ if (mtype < EOS_PWR_MAX_MTYPE) return evt_handler[mtype];
+ return NULL;
+}
diff --git a/fw/fe310/eos/power.h b/fw/fe310/eos/power.h
index 466573f..3eee817 100644
--- a/fw/fe310/eos/power.h
+++ b/fw/fe310/eos/power.h
@@ -1,7 +1,7 @@
#include <stdint.h>
#include "event.h"
-#define EOS_PWR_MTYPE_BUTTON 0
+#define EOS_PWR_MTYPE_BUTTON 1
#define EOS_PWR_MAX_MTYPE 2
@@ -19,4 +19,5 @@ uint8_t eos_power_reset_cause(void);
void eos_power_sleep(void);
void eos_power_wake_at(uint32_t msec);
void eos_power_wake_disable(void);
-void eos_power_set_handler(unsigned char mtype, eos_evt_handler_t handler); \ No newline at end of file
+void eos_power_set_handler(unsigned char mtype, eos_evt_handler_t handler);
+eos_evt_handler_t eos_power_get_handler(unsigned char mtype); \ No newline at end of file
diff --git a/fw/fe310/eos/sock.c b/fw/fe310/eos/sock.c
index 9abb9e8..a2e30e3 100644
--- a/fw/fe310/eos/sock.c
+++ b/fw/fe310/eos/sock.c
@@ -10,7 +10,7 @@
static eos_evt_handler_t evt_handler[EOS_SOCK_MAX_SOCK];
-static void sock_handle_evt(unsigned char type, unsigned char *buffer, uint16_t len) {
+static void sock_handle_msg(unsigned char type, unsigned char *buffer, uint16_t len) {
unsigned char sock;
if ((buffer == NULL) || (len < 2)) {
@@ -40,13 +40,18 @@ void eos_sock_init(void) {
for (i=0; i<EOS_SOCK_MAX_SOCK; i++) {
evt_handler[i] = NULL;
}
- eos_net_set_handler(EOS_NET_MTYPE_SOCK, sock_handle_evt);
+ eos_net_set_handler(EOS_NET_MTYPE_SOCK, sock_handle_msg);
}
void eos_sock_set_handler(unsigned char sock, eos_evt_handler_t handler) {
if (sock && (sock <= EOS_SOCK_MAX_SOCK)) evt_handler[sock - 1] = handler;
}
+eos_evt_handler_t eos_sock_get_handler(unsigned char sock) {
+ if (sock && (sock <= EOS_SOCK_MAX_SOCK)) return evt_handler[sock - 1];
+ return NULL;
+}
+
int eos_sock_open_udp(eos_evt_handler_t handler) {
unsigned char type = EOS_SOCK_MTYPE_OPEN_DGRAM;
unsigned char *buffer = eos_net_alloc();
diff --git a/fw/fe310/eos/sock.h b/fw/fe310/eos/sock.h
index cec8aae..7461473 100644
--- a/fw/fe310/eos/sock.h
+++ b/fw/fe310/eos/sock.h
@@ -18,6 +18,7 @@ typedef struct EOSNetAddr {
void eos_sock_init(void);
void eos_sock_set_handler(unsigned char sock, eos_evt_handler_t handler);
+eos_evt_handler_t eos_sock_get_handler(unsigned char sock);
int eos_sock_open_udp(eos_evt_handler_t handler);
void eos_sock_close(unsigned char sock);
diff --git a/fw/fe310/eos/wifi.c b/fw/fe310/eos/wifi.c
index 6d39332..c3449e8 100644
--- a/fw/fe310/eos/wifi.c
+++ b/fw/fe310/eos/wifi.c
@@ -10,7 +10,7 @@
static eos_evt_handler_t evt_handler[EOS_WIFI_MAX_MTYPE];
-static void wifi_handle_evt(unsigned char type, unsigned char *buffer, uint16_t len) {
+static void wifi_handle_msg(unsigned char type, unsigned char *buffer, uint16_t len) {
unsigned char mtype;
if ((buffer == NULL) || (len < 1)) {
@@ -32,13 +32,24 @@ void eos_wifi_init(void) {
for (i=0; i<EOS_WIFI_MAX_MTYPE; i++) {
evt_handler[i] = NULL;
}
- eos_net_set_handler(EOS_NET_MTYPE_WIFI, wifi_handle_evt);
+ eos_net_set_handler(EOS_NET_MTYPE_WIFI, wifi_handle_msg);
}
void eos_wifi_set_handler(unsigned char mtype, eos_evt_handler_t handler) {
if (mtype < EOS_WIFI_MAX_MTYPE) evt_handler[mtype] = handler;
}
+eos_evt_handler_t eos_wifi_get_handler(unsigned char mtype) {
+ if (mtype < EOS_WIFI_MAX_MTYPE) return evt_handler[mtype];
+ return NULL;
+}
+
+void eos_wifi_scan(void) {
+ unsigned char *buffer = eos_net_alloc();
+ buffer[0] = EOS_WIFI_MTYPE_SCAN;
+ eos_net_send(EOS_NET_MTYPE_WIFI, buffer, 1, 0);
+}
+
void eos_wifi_connect(const char *ssid, const char *pass) {
int ssid_len = strlen(ssid);
int pass_len = strlen(pass);
diff --git a/fw/fe310/eos/wifi.h b/fw/fe310/eos/wifi.h
index 732a7a9..57048af 100644
--- a/fw/fe310/eos/wifi.h
+++ b/fw/fe310/eos/wifi.h
@@ -1,14 +1,16 @@
#include <stdint.h>
#include "event.h"
-#define EOS_WIFI_MTYPE_SCAN 0
-#define EOS_WIFI_MTYPE_CONNECT 1
-#define EOS_WIFI_MTYPE_DISCONNECT 2
+#define EOS_WIFI_MTYPE_SCAN 1
+#define EOS_WIFI_MTYPE_CONNECT 2
+#define EOS_WIFI_MTYPE_DISCONNECT 3
-#define EOS_WIFI_MAX_MTYPE 3
+#define EOS_WIFI_MAX_MTYPE 4
void eos_wifi_init(void);
void eos_wifi_set_handler(unsigned char mtype, eos_evt_handler_t handler);
+eos_evt_handler_t eos_wifi_get_handler(unsigned char mtype);
+void eos_wifi_scan(void);
void eos_wifi_connect(const char *ssid, const char *pass);
void eos_wifi_disconnect(void);