summaryrefslogtreecommitdiff
path: root/code/fe310/eos
diff options
context:
space:
mode:
authorUros Majstorovic <majstor@majstor.org>2020-01-27 07:29:11 +0100
committerUros Majstorovic <majstor@majstor.org>2020-01-27 07:29:11 +0100
commit445d72abf487dc325ccbde1e3a12d1c4cf695a6a (patch)
treeaee5cd0e2637625b25ad679f05edaf388368da55 /code/fe310/eos
parent2d9f22e056b61917979db67da49fc0655b0af3a4 (diff)
added screen tracking feature
Diffstat (limited to 'code/fe310/eos')
-rw-r--r--code/fe310/eos/eve.c313
-rw-r--r--code/fe310/eos/eve.h24
-rw-r--r--code/fe310/eos/eve_kbd.c8
-rw-r--r--code/fe310/eos/eve_text.c12
4 files changed, 176 insertions, 181 deletions
diff --git a/code/fe310/eos/eve.c b/code/fe310/eos/eve.c
index 98a729d..3766355 100644
--- a/code/fe310/eos/eve.c
+++ b/code/fe310/eos/eve.c
@@ -13,12 +13,12 @@
#include "eve.h"
#include "irq_def.h"
-#define MEM_WRITE 0x800000
+#define MEM_WRITE 0x800000
-#define EVE_PIN_INT 0
-#define EVE_MAX_TOUCH 5
+#define EVE_PIN_INT 0
+#define EVE_MAX_TOUCH 5
-#define EVE_ETYPE_INT 1
+#define EVE_ETYPE_INT 1
static char eve_cmd_burst;
static uint16_t eve_cmd_offset;
@@ -28,7 +28,7 @@ static int eve_int_mask = EVE_INT_TAG | EVE_INT_TOUCH;
static int eve_multitouch = 0;
static uint8_t eve_tag0;
static EOSTouch eve_touch[5];
-static uint8_t eve_touch_evt[256];
+static uint8_t eve_tag_evt[256];
static eos_eve_fptr_t eve_renderer;
static const uint32_t _reg_touch[] = {
@@ -166,19 +166,12 @@ static void _cmd_end(void) {
static void _cmd_string(const char *s, uint8_t flags) {
int i = 0, p = 0;
- while(s[i] != 0) {
+ while (s[i] != 0) {
eos_spi_xchg8(s[i], EOS_SPI_FLAG_BSWAP | flags);
i++;
}
- /* padding */
- p = i & 3; /* 0, 1, 2 or 3 */
- p = 4 - p; /* 4, 3, 2 or 1 */
- i += p;
-
- while(p > 0) {
- eos_spi_xchg8(0, EOS_SPI_FLAG_BSWAP | flags);
- p--;
- }
+ eos_spi_xchg8(0, EOS_SPI_FLAG_BSWAP | flags);
+ i++;
_cmd_inc(i);
}
@@ -188,16 +181,7 @@ static void _cmd_buffer(const char *b, int size, uint8_t flags) {
for (i=0; i<size; i++) {
eos_spi_xchg8(b[i], EOS_SPI_FLAG_BSWAP | flags);
}
- /* padding */
- p = i & 3; /* 0, 1, 2 or 3 */
- p = 4 - p; /* 4, 3, 2 or 1 */
- i += p;
-
- while(p > 0) {
- eos_spi_xchg8(0, EOS_SPI_FLAG_BSWAP | flags);
- p--;
- }
- _cmd_inc(i);
+ _cmd_inc(size);
}
void eos_eve_cmd(uint32_t cmd, const char *fmt, ...) {
@@ -222,7 +206,7 @@ void eos_eve_cmd(uint32_t cmd, const char *fmt, ...) {
eos_spi_xchg32(va_arg(argv, int), EOS_SPI_FLAG_BSWAP | flags);
_cmd_inc(4);
break;
- case 'W':
+ case '&':
p = va_arg(argv, uint16_t *);
*p = eve_cmd_offset;
eos_spi_xchg32(0, EOS_SPI_FLAG_BSWAP | flags);
@@ -237,6 +221,17 @@ void eos_eve_cmd(uint32_t cmd, const char *fmt, ...) {
}
i++;
}
+ /* padding */
+ i = eve_cmd_offset & 3; /* equivalent to eve_cmd_offset % 4 */
+ if (i) {
+ i = 4 - i; /* 3, 2 or 1 */
+ _cmd_inc(i);
+
+ while (i > 0) {
+ eos_spi_xchg8(0, EOS_SPI_FLAG_BSWAP | flags);
+ i--;
+ }
+ }
_cmd_end();
va_end(argv);
}
@@ -295,137 +290,117 @@ static void eve_handler_int(void) {
}
static void eve_handler_evt(unsigned char type, unsigned char *buffer, uint16_t len) {
+ int i;
uint8_t flags;
- uint8_t touch_tag;
- uint32_t touch_xy;
- uint32_t touch_track;
uint8_t tag0 = eve_tag0;
- uint8_t touch_idx = 0;
- int touch_idx_max = -1;
- int i;
- EOSTouch *touch;
+ uint8_t touch_last = 0;
+ char touch_ex = 0;
+ char int_ccomplete = 0;
eos_spi_dev_start(EOS_SPI_DEV_DISP);
flags = eos_eve_read8(REG_INT_FLAGS) & eve_int_mask;
- if (!eve_multitouch) {
- touch = &eve_touch[0];
+ /*
+ if (flags == 0) {
+ GPIO_REG(GPIO_LOW_IP) = (1 << EVE_PIN_INT);
+ GPIO_REG(GPIO_LOW_IE) |= (1 << EVE_PIN_INT);
+ eos_spi_dev_stop();
+ return;
+ }
+ */
- tag0 = eve_tag0;
- touch->evt &= (EOS_TOUCH_ETYPE_DRAG | EOS_TOUCH_ETYPE_TRACK);
- touch_xy = eos_eve_read32(REG_CTOUCH_TOUCH0_XY);
- if (touch_xy == 0x80008000) {
- touch_tag = 0;
- eve_tag0 = 0;
- touch->t = 0;
- touch->evt &= ~(EOS_TOUCH_ETYPE_DRAG | EOS_TOUCH_ETYPE_TRACK);
- if (eve_int_mask & EVE_INT_CONVCOMPLETE) {
- eve_int_mask &= ~EVE_INT_CONVCOMPLETE;
- eos_eve_write8(REG_INT_MASK, eve_int_mask);
+ if (!eve_multitouch && (flags & EVE_INT_TOUCH)) eve_multitouch = 1;
+
+ for (i=0; i<EVE_MAX_TOUCH; i++) {
+ uint8_t touch_tag;
+ uint32_t touch_xy;
+ EOSTouch *touch = &eve_touch[i];
+
+ touch->evt &= EOS_TOUCH_ETYPE_TRACK_MASK;
+
+ touch_xy = i < 4 ? eos_eve_read32(_reg_touch[i]) : (((uint32_t)eos_eve_read16(REG_CTOUCH_TOUCH4_X) << 16) | eos_eve_read16(REG_CTOUCH_TOUCH4_Y));
+
+ if (touch_xy != 0x80008000) {
+ uint16_t touch_x = touch_xy >> 16;
+ uint16_t touch_y = touch_xy & 0xffff;
+ if (touch->x == 0x8000) {
+ touch->evt |= EOS_TOUCH_ETYPE_POINT_DOWN;
+ touch->x0 = touch_x;
+ touch->y0 = touch_y;
}
- } else {
- touch->t = 1;
- touch->x = touch_xy >> 16;
- touch->y = touch_xy & 0xffff;
- if ((flags & EVE_INT_TAG) && !(touch->evt & (EOS_TOUCH_ETYPE_DRAG | EOS_TOUCH_ETYPE_TRACK))) {
- touch_tag = eos_eve_read8(REG_TOUCH_TAG);
+ touch->x = touch_x;
+ touch->y = touch_y;
+ if (eve_multitouch || (flags & EVE_INT_TAG)) {
+ touch_tag = eos_eve_read8(_reg_tag[i]);
} else {
- touch_tag = touch->tag;
- }
- if (touch->evt & EOS_TOUCH_ETYPE_TRACK) {
- touch_track = eos_eve_read32(REG_TRACKER);
- touch->tracker.tag = touch_track & 0xffff;
- touch->tracker.val = touch_track >> 16;
- }
- if (touch->evt & (EOS_TOUCH_ETYPE_DRAG | EOS_TOUCH_ETYPE_TRACK)) {
- touch_idx = 1;
- touch_idx_max = 1;
- }
- if (flags & EVE_INT_TOUCH) {
- eve_multitouch = 1;
- if (!(eve_int_mask & EVE_INT_CONVCOMPLETE)) {
- eve_int_mask |= EVE_INT_CONVCOMPLETE;
- eos_eve_write8(REG_INT_MASK, eve_int_mask);
- }
+ touch_tag = touch->tag_down;
}
+ touch_ex = 1;
+ } else {
+ touch_tag = 0;
+ if (touch->x != 0x8000) touch->evt |= EOS_TOUCH_ETYPE_POINT_UP;
}
- if ((touch_tag != touch->tag) && !(touch->evt & (EOS_TOUCH_ETYPE_DRAG | EOS_TOUCH_ETYPE_TRACK))) {
- touch->tag_prev = touch->tag;
- touch->tag = touch_tag;
- touch_idx = 1;
- touch_idx_max = 1;
- if (touch->tag) touch->evt |= EOS_TOUCH_ETYPE_DOWN;
- if (touch->tag_prev) touch->evt |= EOS_TOUCH_ETYPE_UP;
- if (touch_tag && !eve_tag0) {
- eve_tag0 = touch_tag;
- tag0 = touch_tag;
- if (eve_touch_evt[touch_tag]) {
- touch->evt |= eve_touch_evt[touch_tag];
- touch->tracker.tag = 0;
- if (!(eve_int_mask & EVE_INT_CONVCOMPLETE)) {
- eve_int_mask |= EVE_INT_CONVCOMPLETE;
- eos_eve_write8(REG_INT_MASK, eve_int_mask);
+ if (touch_tag != touch->tag_down) {
+ if (touch_tag) {
+ if (!eve_tag0) tag0 = eve_tag0 = touch_tag;
+ if (!touch->tag0) {
+ printf("TAG0:%x\n", touch_tag);
+ touch->tag0 = touch_tag;
+ touch->evt |= eve_tag_evt[touch->tag0] & EOS_TOUCH_ETYPE_TRACK_MASK;
+ if (touch->evt & EOS_TOUCH_ETYPE_TRACK_MASK) {
+ touch->tracker.tag = touch_tag;
+ } else {
+ touch->evt |= eve_tag_evt[0xff] & EOS_TOUCH_ETYPE_TRACK_MASK;
+ if (touch->evt & EOS_TOUCH_ETYPE_TRACK_MASK) touch->tracker.tag = 0xff;
}
}
}
+ touch->tag_up = touch->tag_down;
+ touch->tag_down = touch_tag;
+ if (touch->tag_up) touch->evt |= EOS_TOUCH_ETYPE_TAG_UP;
+ if (touch->tag_down) touch->evt |= EOS_TOUCH_ETYPE_TAG_DOWN;
}
- } else if (flags & EVE_INT_CONVCOMPLETE) {
- int touched = 0;
-
- for (i=0; i<EVE_MAX_TOUCH; i++) {
- touch = &eve_touch[i];
-
- touch->evt &= (EOS_TOUCH_ETYPE_DRAG | EOS_TOUCH_ETYPE_TRACK);
- touch_xy = i < 4 ? eos_eve_read32(_reg_touch[i]) : (((uint32_t)eos_eve_read16(REG_CTOUCH_TOUCH4_X) << 16) | eos_eve_read16(REG_CTOUCH_TOUCH4_Y));
- if (touch_xy == 0x80008000) {
- touch_tag = 0;
- touch->t = 0;
- touch->evt &= ~(EOS_TOUCH_ETYPE_DRAG | EOS_TOUCH_ETYPE_TRACK);
- } else {
- touch->t = 1;
- touch->x = touch_xy >> 16;
- touch->y = touch_xy & 0xffff;
- if (!(touch->evt & (EOS_TOUCH_ETYPE_DRAG | EOS_TOUCH_ETYPE_TRACK))) {
- touch_tag = eos_eve_read8(_reg_tag[i]);
- } else {
- touch_tag = touch->tag;
- }
- if (touch->evt & EOS_TOUCH_ETYPE_TRACK) {
- touch_track = eos_eve_read32(_reg_track[i]);
- touch->tracker.tag = touch_track & 0xffff;
- touch->tracker.val = touch_track >> 16;
- }
- if (touch->evt & (EOS_TOUCH_ETYPE_DRAG | EOS_TOUCH_ETYPE_TRACK)) {
- touch_idx |= (1 << i);
- touch_idx_max = i + 1;
- }
- touched = 1;
- }
- if (touch_tag != touch->tag) {
- touch->tag_prev = touch->tag;
- touch->tag = touch_tag;
- touch_idx |= (1 << i);
- touch_idx_max = i + 1;
- if (touch->tag) touch->evt |= EOS_TOUCH_ETYPE_DOWN;
- if (touch->tag_prev) touch->evt |= EOS_TOUCH_ETYPE_UP;
- if (eve_touch_evt[touch_tag]) {
- touch->evt |= eve_touch_evt[touch_tag];
- touch->tracker.tag = 0;
- }
- }
+ if (touch->evt & EOS_TOUCH_ETYPE_TRACK_REG) {
+ uint32_t touch_track = eos_eve_read32(_reg_track[i]);
+ touch->tracker.tag = touch_track & 0xffff;
+ touch->tracker.val = touch_track >> 16;
}
-
- if (!touched) {
- eve_tag0 = 0;
- eve_multitouch = 0;
- eve_int_mask &= ~EVE_INT_CONVCOMPLETE;
- eos_eve_write8(REG_INT_MASK, eve_int_mask);
+ if (touch->evt) {
+ touch_last = i + 1;
+ if (touch->evt & EOS_TOUCH_ETYPE_TRACK_MASK) int_ccomplete = 1;
}
+ if (!eve_multitouch) break;
}
- if (touch_idx_max != -1) {
- for (i=0; i<touch_idx_max; i++) {
- if (touch_idx & 1) eve_renderer(tag0, i);
- touch_idx = touch_idx >> 1;
+ if (!touch_ex) {
+ eve_tag0 = 0;
+ eve_multitouch = 0;
+ }
+
+ if (eve_multitouch) int_ccomplete = 1;
+
+ if (int_ccomplete && !(eve_int_mask & EVE_INT_CONVCOMPLETE)) {
+ eve_int_mask |= EVE_INT_CONVCOMPLETE;
+ eos_eve_write8(REG_INT_MASK, eve_int_mask);
+ }
+ if (!int_ccomplete && (eve_int_mask & EVE_INT_CONVCOMPLETE)) {
+ eve_int_mask &= ~EVE_INT_CONVCOMPLETE;
+ eos_eve_write8(REG_INT_MASK, eve_int_mask);
+ }
+
+ for (i=0; i<touch_last; i++) {
+ EOSTouch *touch = &eve_touch[i];
+ if (touch->evt) {
+ eve_renderer(tag0, i);
+ if (touch->evt & EOS_TOUCH_ETYPE_POINT_UP) {
+ touch->x = 0x8000;
+ touch->y = 0x8000;
+ touch->evt = 0;
+ touch->tag0 = 0;
+ touch->tag_up = 0;
+ touch->tag_down = 0;
+ touch->tracker.tag = 0;
+ touch->tracker.val = 0;
+ }
}
}
@@ -435,6 +410,7 @@ static void eve_handler_evt(unsigned char type, unsigned char *buffer, uint16_t
}
int eos_eve_init(void) {
+ int i;
uint8_t chipid = 0;
uint16_t timeout = 0;
uint32_t touch_transform[6] = {0xfa46,0xfffffcf6,0x422fe,0xffffff38,0x10002,0xf3cb0};
@@ -493,18 +469,7 @@ int eos_eve_init(void) {
eos_eve_write8(REG_INT_MASK, eve_int_mask);
while(eos_eve_read8(REG_INT_FLAGS));
- eos_evtq_set_handler(EOS_EVT_UI, eve_handler_evt);
-
- GPIO_REG(GPIO_INPUT_EN) |= (1 << EVE_PIN_INT);
- GPIO_REG(GPIO_OUTPUT_EN) &= ~(1 << EVE_PIN_INT);
- GPIO_REG(GPIO_PULLUP_EN) &= ~(1 << EVE_PIN_INT);
- GPIO_REG(GPIO_OUTPUT_XOR) &= ~(1 << EVE_PIN_INT);
-
- GPIO_REG(GPIO_LOW_IE) |= (1 << EVE_PIN_INT);
- eos_intr_set(INT_GPIO_BASE + EVE_PIN_INT, IRQ_PRIORITY_UI, eve_handler_int);
-
/*
- // eos_eve_cmd_burst_start();
eos_eve_cmd_dl(CMD_DLSTART);
eos_eve_cmd_dl(CLEAR_COLOR_RGB(0,0,0));
eos_eve_cmd_dl(CLEAR(1,1,1));
@@ -512,7 +477,6 @@ int eos_eve_init(void) {
eos_eve_cmd(CMD_CALIBRATE, "w", 0);
eos_eve_cmd_dl(DISPLAY());
eos_eve_cmd_dl(CMD_SWAP);
- // eos_eve_cmd_burst_end();
eos_eve_cmd_exec(1);
uint32_t touch_transform[0] = eos_eve_read32(REG_TOUCH_TRANSFORM_A);
@@ -539,6 +503,21 @@ int eos_eve_init(void) {
eos_timer_sleep(500);
eos_eve_command(EVE_STANDBY, 0);
+ for (i=0; i<EVE_MAX_TOUCH; i++) {
+ EOSTouch *touch = &eve_touch[i];
+ touch->x = 0x8000;
+ touch->y = 0x8000;
+ }
+ eos_evtq_set_handler(EOS_EVT_UI, eve_handler_evt);
+
+ GPIO_REG(GPIO_INPUT_EN) |= (1 << EVE_PIN_INT);
+ GPIO_REG(GPIO_OUTPUT_EN) &= ~(1 << EVE_PIN_INT);
+ GPIO_REG(GPIO_PULLUP_EN) &= ~(1 << EVE_PIN_INT);
+ GPIO_REG(GPIO_OUTPUT_XOR) &= ~(1 << EVE_PIN_INT);
+
+ GPIO_REG(GPIO_LOW_IE) |= (1 << EVE_PIN_INT);
+ eos_intr_set(INT_GPIO_BASE + EVE_PIN_INT, IRQ_PRIORITY_UI, eve_handler_int);
+
return EOS_OK;
}
@@ -548,7 +527,8 @@ void eos_eve_set_renderer(eos_eve_fptr_t renderer, uint8_t flags) {
}
EOSTouch *eos_touch_evt(uint8_t tag0, int touch_idx, uint8_t tag_min, uint8_t tag_max, uint8_t *evt) {
- uint8_t tag;
+ uint8_t _tag;
+ uint8_t _evt;
EOSTouch *ret = NULL;
*evt = 0;
@@ -557,18 +537,27 @@ EOSTouch *eos_touch_evt(uint8_t tag0, int touch_idx, uint8_t tag_min, uint8_t ta
ret = &eve_touch[touch_idx];
if ((tag0 < tag_min) || (tag0 > tag_max)) return ret;
- tag = eve_touch[touch_idx].tag;
- if ((tag >= tag_min) && (tag <= tag_max)) *evt |= (eve_touch[touch_idx].evt & (EOS_TOUCH_ETYPE_DOWN | EOS_TOUCH_ETYPE_DRAG));
-
- tag = eve_touch[touch_idx].tag_prev;
- if ((tag >= tag_min) && (tag <= tag_max)) *evt |= (eve_touch[touch_idx].evt & EOS_TOUCH_ETYPE_UP);
-
- tag = eve_touch[touch_idx].tracker.tag;
- if ((tag >= tag_min) && (tag <= tag_max)) *evt |= (eve_touch[touch_idx].evt & EOS_TOUCH_ETYPE_TRACK);
+ _evt = ret->evt;
+ if (_evt & EOS_TOUCH_ETYPE_TAG_UP) {
+ _tag = ret->tag_up;
+ if ((_tag >= tag_min) && (_tag <= tag_max)) *evt |= EOS_TOUCH_ETYPE_TAG_UP;
+ }
+ if (_evt & EOS_TOUCH_ETYPE_TAG_DOWN) {
+ _tag = ret->tag_down;
+ if ((_tag >= tag_min) && (_tag <= tag_max)) *evt |= EOS_TOUCH_ETYPE_TAG_DOWN;
+ }
+ if (_evt & EOS_TOUCH_ETYPE_TRACK) {
+ _tag = ret->tracker.tag;
+ if ((_tag >= tag_min) && (_tag <= tag_max)) *evt |= EOS_TOUCH_ETYPE_TRACK;
+ }
+ if (_evt & EOS_TOUCH_ETYPE_TRACK_REG) {
+ _tag = ret->tracker.tag;
+ if ((_tag >= tag_min) && (_tag <= tag_max) && (_tag == ret->tag0)) *evt |= EOS_TOUCH_ETYPE_TRACK_REG;
+ }
return ret;
}
-void eos_touch_set_evt(uint8_t tag, uint8_t evt) {
- eve_touch_evt[tag] = evt;
+void eos_touch_evt_set(uint8_t tag, uint8_t evt) {
+ eve_tag_evt[tag] = evt;
}
diff --git a/code/fe310/eos/eve.h b/code/fe310/eos/eve.h
index dc22f80..3e76b92 100644
--- a/code/fe310/eos/eve.h
+++ b/code/fe310/eos/eve.h
@@ -2,18 +2,26 @@
#include "eve_def.h"
-#define EOS_TOUCH_ETYPE_DOWN 0x01
-#define EOS_TOUCH_ETYPE_UP 0x02
-#define EOS_TOUCH_ETYPE_DRAG 0x04
-#define EOS_TOUCH_ETYPE_TRACK 0x08
+#define EOS_TOUCH_ETYPE_TRACK 0x01
+#define EOS_TOUCH_ETYPE_TRACK_REG 0x02
+#define EOS_TOUCH_ETYPE_POINT_UP 0x10
+#define EOS_TOUCH_ETYPE_POINT_DOWN 0x20
+#define EOS_TOUCH_ETYPE_TAG_UP 0x40
+#define EOS_TOUCH_ETYPE_TAG_DOWN 0x80
+
+#define EOS_TOUCH_ETYPE_TRACK_MASK 0x03
+#define EOS_TOUCH_ETYPE_POINT_MASK 0x30
+#define EOS_TOUCH_ETYPE_TAG_MASK 0xc0
typedef struct EOSTouch {
uint16_t x;
uint16_t y;
- uint8_t tag;
- uint8_t tag_prev;
+ uint16_t x0;
+ uint16_t y0;
+ uint8_t tag0;
+ uint8_t tag_up;
+ uint8_t tag_down;
uint8_t evt;
- char t;
struct {
uint16_t tag;
uint16_t val;
@@ -50,4 +58,4 @@ void eos_eve_cmd_burst_end(void);
int eos_eve_init(void);
void eos_eve_set_renderer(eos_eve_fptr_t renderer, uint8_t flags);
EOSTouch *eos_touch_evt(uint8_t tag0, int touch_idx, uint8_t tag_min, uint8_t tag_max, uint8_t *evt);
-void eos_touch_set_evt(uint8_t tag, uint8_t evt);
+void eos_touch_evt_set(uint8_t tag, uint8_t evt);
diff --git a/code/fe310/eos/eve_kbd.c b/code/fe310/eos/eve_kbd.c
index 00d5328..995d0ca 100644
--- a/code/fe310/eos/eve_kbd.c
+++ b/code/fe310/eos/eve_kbd.c
@@ -37,8 +37,8 @@ void eos_kbd_draw(EOSKbd *kbd, uint8_t tag0, int touch_idx) {
EOSTouch *t = eos_touch_evt(tag0, touch_idx, 1, 127, &evt);
if (t && evt) {
- if (evt & EOS_TOUCH_ETYPE_DOWN) {
- uint8_t _tag = t->tag;
+ if (evt & EOS_TOUCH_ETYPE_TAG_DOWN) {
+ uint8_t _tag = t->tag_down;
if (_tag >= KEY_SHIFT && _tag <= KEY_FN) {
if (touch_idx == 0) {
@@ -67,8 +67,8 @@ void eos_kbd_draw(EOSKbd *kbd, uint8_t tag0, int touch_idx) {
}
}
}
- if (evt & EOS_TOUCH_ETYPE_UP) {
- uint8_t _tag = t->tag_prev;
+ if (evt & EOS_TOUCH_ETYPE_TAG_UP) {
+ uint8_t _tag = t->tag_up;
if (_tag >= KEY_SHIFT && _tag <= KEY_FN) {
if (touch_idx == 0) {
diff --git a/code/fe310/eos/eve_text.c b/code/fe310/eos/eve_text.c
index 93e628c..c944455 100644
--- a/code/fe310/eos/eve_text.c
+++ b/code/fe310/eos/eve_text.c
@@ -39,7 +39,7 @@ void eos_text_init(EOSText *box, int x, int y, int w, int h, double scale_x, dou
box->dl_size += 1;
}
- eos_touch_set_evt(tag, EOS_TOUCH_ETYPE_DRAG);
+ eos_touch_evt_set(tag, EOS_TOUCH_ETYPE_TRACK);
eos_eve_cmd(CMD_MEMSET, "www", mem_addr, 0x0, w * 2 * buf_line_h);
eos_eve_cmd_exec(1);
@@ -49,25 +49,23 @@ void eos_text_init(EOSText *box, int x, int y, int w, int h, double scale_x, dou
}
void eos_text_draw(EOSText *box, uint8_t tag0, int touch_idx) {
- static int y0;
static int line_idx = -1;
static int line_idx_last;
uint8_t evt;
EOSTouch *t = eos_touch_evt(tag0, touch_idx, box->tag, box->tag, &evt);
if (t && evt) {
- if (evt & EOS_TOUCH_ETYPE_DOWN) {
- y0 = t->y;
+ if (evt & EOS_TOUCH_ETYPE_TAG_DOWN) {
if (line_idx < 0) {
line_idx = box->line_idx;
line_idx_last = line_idx;
}
}
- if (evt & EOS_TOUCH_ETYPE_UP) {
+ if (evt & EOS_TOUCH_ETYPE_TAG_UP) {
line_idx = line_idx_last;
}
- if (evt & EOS_TOUCH_ETYPE_DRAG) {
- int _line_idx = LINE_IDX_ADD(line_idx, (y0 - t->y) / box->ch_h, box->buf_line_h);
+ if (evt & EOS_TOUCH_ETYPE_TRACK) {
+ int _line_idx = LINE_IDX_ADD(line_idx, ((int)t->y0 - t->y) / box->ch_h, box->buf_line_h);
if (LINE_IDX_LTE(_line_idx, box->line_idx, box->buf_line_h, box->h)) {
eos_text_update(box, _line_idx);
line_idx_last = _line_idx;