summaryrefslogtreecommitdiff
path: root/fw/fe310/eos/eve
diff options
context:
space:
mode:
authorUros Majstorovic <majstor@majstor.org>2022-05-13 12:26:19 +0200
committerUros Majstorovic <majstor@majstor.org>2022-05-13 12:26:19 +0200
commit9ccb4db8d59ec9dab33ee8617d462f21a8bb4fa8 (patch)
treea4f8ba9375a4ee82bae6ddc0cb3a35227f6f9469 /fw/fe310/eos/eve
parent45f0d9b890b086493f9bb06428c46cd802324223 (diff)
touch controller/eve fixes
Diffstat (limited to 'fw/fe310/eos/eve')
-rw-r--r--fw/fe310/eos/eve/Makefile2
-rw-r--r--fw/fe310/eos/eve/eve.c42
-rw-r--r--fw/fe310/eos/eve/eve.h12
-rwxr-xr-xfw/fe310/eos/eve/eve_config.h16
-rwxr-xr-xfw/fe310/eos/eve/eve_def.h4
-rw-r--r--fw/fe310/eos/eve/eve_eos.c104
-rw-r--r--fw/fe310/eos/eve/eve_eos.h6
-rw-r--r--fw/fe310/eos/eve/eve_phy.c15
-rw-r--r--fw/fe310/eos/eve/eve_phy.h4
-rw-r--r--fw/fe310/eos/eve/eve_platform.c14
-rw-r--r--fw/fe310/eos/eve/eve_platform.h8
-rw-r--r--fw/fe310/eos/eve/eve_touch.c483
-rw-r--r--fw/fe310/eos/eve/eve_touch.h25
-rw-r--r--fw/fe310/eos/eve/eve_vtrack.c9
-rw-r--r--fw/fe310/eos/eve/eve_vtrack.h2
-rw-r--r--fw/fe310/eos/eve/screen/page.c10
-rw-r--r--fw/fe310/eos/eve/screen/page.h2
-rw-r--r--fw/fe310/eos/eve/widget/strw.c2
18 files changed, 290 insertions, 470 deletions
diff --git a/fw/fe310/eos/eve/Makefile b/fw/fe310/eos/eve/Makefile
index 323a132..462891c 100644
--- a/fw/fe310/eos/eve/Makefile
+++ b/fw/fe310/eos/eve/Makefile
@@ -1,7 +1,7 @@
include ../../common.mk
CFLAGS += -I$(bsp_dir)/include
-obj = eve.o eve_eos.o eve_platform.o eve_touch.o eve_phy.o eve_vtrack.o eve_font.o eve_kbd.o eve_text.o clipb.o
+obj = eve.o eve_platform.o eve_touch.o eve_touch_engine.o eve_phy.o eve_vtrack.o eve_font.o eve_kbd.o eve_text.o clipb.o
%.o: %.c %.h
diff --git a/fw/fe310/eos/eve/eve.c b/fw/fe310/eos/eve/eve.c
index e1191fc..02e0cae 100644
--- a/fw/fe310/eos/eve/eve.c
+++ b/fw/fe310/eos/eve/eve.c
@@ -13,6 +13,7 @@ static char dl_burst;
static uint32_t dl_addr;
static uint8_t power_state;
+static int lcd_absent = 0;
void eve_command(uint8_t command, uint8_t parameter) {
eve_spi_cs_set();
@@ -289,6 +290,7 @@ int eve_cmd_exec(int w) {
void eve_cmd_burst_start(void) {
uint32_t addr = EVE_RAM_CMD + cmd_offset;
+
eve_spi_lock();
eve_spi_cs_set();
eve_spi_xchg24(addr | EVE_MEM_WRITE, EVE_SPI_FLAG_TX);
@@ -306,10 +308,10 @@ void eve_handle_intr(void) {
uint16_t intr_flags;
intr_flags = eve_read16(REG_INT_FLAGS);
- eve_handle_touch(intr_flags);
+ if (intr_flags & (EVE_INT_CONVCOMPLETE | EVE_INT_TAG)) eve_handle_touch(intr_flags);
}
-int eve_init(uint8_t gpio_dir, int touch_calibrate, uint32_t *touch_matrix) {
+int eve_init(uint8_t gpio_dir) {
uint8_t chipid = 0;
uint8_t reset = 0x07;
uint16_t timeout;
@@ -319,11 +321,11 @@ int eve_init(uint8_t gpio_dir, int touch_calibrate, uint32_t *touch_matrix) {
eve_command(EVE_CLKEXT, 0);
eve_command(EVE_CLKSEL, 0x46); /* set clock to 72 MHz */
eve_command(EVE_ACTIVE, 0); /* start EVE */
- eve_time_sleep(4);
+ eve_sleep(4);
timeout = 0;
while (chipid != 0x7c) { /* if chipid is not 0x7c, continue to read it until it is, EVE needs a moment for it's power on self-test and configuration */
- eve_time_sleep(1);
+ eve_sleep(1);
chipid = eve_read8(REG_ID);
timeout++;
if (timeout > 400) return EVE_ERR;
@@ -331,7 +333,7 @@ int eve_init(uint8_t gpio_dir, int touch_calibrate, uint32_t *touch_matrix) {
timeout = 0;
while (reset != 0x00) { /* check if EVE is in working status */
- eve_time_sleep(1);
+ eve_sleep(1);
reset = eve_read8(REG_CPURESET) & 0x07;
timeout++;
if(timeout > 50) return EVE_ERR;
@@ -381,21 +383,16 @@ int eve_init(uint8_t gpio_dir, int touch_calibrate, uint32_t *touch_matrix) {
#endif
/* nothing is being displayed yet... the pixel clock is still 0x00 */
- eve_touch_init(touch_calibrate, touch_matrix);
return EVE_OK;
}
void eve_start(void) {
- eve_touch_start();
-
/* enable interrupts */
eve_write8(REG_INT_EN, 0x01);
while(eve_read8(REG_INT_FLAGS));
}
void eve_stop(void) {
- eve_touch_stop();
-
/* disable interrupts */
eve_write8(REG_INT_EN, 0x00);
while(eve_read8(REG_INT_FLAGS));
@@ -417,12 +414,12 @@ void eve_stop_clk(void) {
eve_write8(REG_PCLK, 0);
}
-void eve_active(void) {
+void eve_activate(void) {
eve_command(EVE_ACTIVE, 0);
- eve_time_sleep(40);
+ eve_sleep(40);
}
-void eve_standby(void) {
+void eve_pwr_standby(void) {
if (power_state != EVE_PSTATE_ACTIVE) return;
eve_command(EVE_STANDBY, 0);
@@ -430,7 +427,7 @@ void eve_standby(void) {
power_state = EVE_PSTATE_STANDBY;
}
-void eve_sleep(void) {
+void eve_pwr_sleep(void) {
if (power_state != EVE_PSTATE_ACTIVE) return;
eve_stop_clk();
@@ -441,8 +438,8 @@ void eve_sleep(void) {
power_state = EVE_PSTATE_SLEEP;
}
-void eve_wake(void) {
- eve_active();
+void eve_pwr_wake(void) {
+ eve_activate();
if (power_state == EVE_PSTATE_SLEEP) {
eve_start();
@@ -452,10 +449,6 @@ void eve_wake(void) {
power_state = EVE_PSTATE_ACTIVE;
}
-void eve_brightness(uint8_t b) {
- eve_write8(REG_PWM_DUTY, b);
-}
-
int eve_gpio_get(int gpio) {
uint16_t reg = eve_read16(REG_GPIOX);
@@ -483,3 +476,12 @@ void eve_gpio_set_dir(uint8_t dir) {
reg |= dir & 0x0f;
eve_write16(REG_GPIOX_DIR, reg);
}
+
+void eve_brightness(uint8_t b) {
+ if (lcd_absent) b = 0;
+ eve_write8(REG_PWM_DUTY, b);
+}
+
+void eve_lcd_absent(void) {
+ lcd_absent = 1;
+}
diff --git a/fw/fe310/eos/eve/eve.h b/fw/fe310/eos/eve/eve.h
index 02fa697..6b31818 100644
--- a/fw/fe310/eos/eve/eve.h
+++ b/fw/fe310/eos/eve/eve.h
@@ -58,19 +58,21 @@ void eve_cmd_burst_end(void);
void eve_handle_intr(void);
-int eve_init(uint8_t gpio_dir, int touch_calibrate, uint32_t *touch_matrix);
+int eve_init(uint8_t gpio_dir);
void eve_start(void);
void eve_stop(void);
void eve_start_clk(void);
void eve_stop_clk(void);
-void eve_active(void);
-void eve_standby(void);
-void eve_sleep(void);
-void eve_wake(void);
+void eve_activate(void);
+void eve_pwr_standby(void);
+void eve_pwr_sleep(void);
+void eve_pwr_wake(void);
int eve_gpio_get(int gpio);
void eve_gpio_set(int gpio, int val);
uint8_t eve_gpio_get_dir(void);
void eve_gpio_set_dir(uint8_t dir);
+
void eve_brightness(uint8_t b);
+void eve_lcd_absent(void); \ No newline at end of file
diff --git a/fw/fe310/eos/eve/eve_config.h b/fw/fe310/eos/eve/eve_config.h
index 1126277..b151c63 100755
--- a/fw/fe310/eos/eve/eve_config.h
+++ b/fw/fe310/eos/eve/eve_config.h
@@ -3,20 +3,19 @@
/* FocusLCDs E50RG84885LWAM520-CA */
-#define EVE_HLPW 6 /* horizontal low pulse width */
-#define EVE_HBP 6 /* horizontal back porch */
-#define EVE_HFP 6 /* horizontal front porch */
+#define EVE_HLPW 20 /* horizontal low pulse width */
+#define EVE_HBP 60 /* horizontal back porch */
+#define EVE_HFP 40 /* horizontal front porch */
#define EVE_HACT 480 /* horizontal active pixels */
#define EVE_HTOT (EVE_HLPW + EVE_HBP + EVE_HFP + EVE_HACT + 10)
-#define EVE_VLPW 6 /* vertical low pulse width */
-#define EVE_VBP 6 /* vertical back porch */
-#define EVE_VFP 6 /* vertical front porch */
+#define EVE_VLPW 26 /* vertical low pulse width */
+#define EVE_VBP 50 /* vertical back porch */
+#define EVE_VFP 30 /* vertical front porch */
#define EVE_VACT 854 /* vertical active pixels */
#define EVE_VTOT (EVE_VLPW + EVE_VBP + EVE_VFP + EVE_VACT + 10)
-
#define EVE_HCYCLE (EVE_HTOT) /* Th Total length of line (visible and non-visible) (in PCLKs) */
#define EVE_HSIZE (EVE_HACT) /* Length of visible part of line (in PCLKs) - display width */
#define EVE_HOFFSET (EVE_HFP + EVE_HLPW + EVE_HBP) /* Length of non-visible part of line (in PCLK cycles) */
@@ -33,8 +32,7 @@
#define EVE_SWIZZLE 0 /* Defines the arrangement of the RGB pins */
#define EVE_CSPREAD 0 /* helps with noise, when set to 1 fewer signals are changed simultaneously, reset-default: 1 */
-#define EVE_PCLK 1 /* Clock from EVE_PCLK_FREQ */
-#define EVE_PCLK_FREQ 27000000
+#define EVE_PCLK 2 /* 36 MHz */
#define EVE_GEN 4
diff --git a/fw/fe310/eos/eve/eve_def.h b/fw/fe310/eos/eve/eve_def.h
index 2f7e0b7..b7110b9 100755
--- a/fw/fe310/eos/eve/eve_def.h
+++ b/fw/fe310/eos/eve/eve_def.h
@@ -697,6 +697,10 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR TH
#define REG_PLAY_CONTROL 0x30914eUL
#define REG_COPRO_PATCH_PTR 0x309162UL
+#define REG_EHOST_TOUCH_X 0x30210cUL
+#define REG_EHOST_TOUCH_Y 0x302118UL
+#define REG_EHOST_TOUCH_ID 0x302114UL
+#define REG_EHOST_TOUCH_ACK 0x302170UL
/* BT81x graphics engine specific macros */
#define BITMAP_EXT_FORMAT(format) ((46UL<<24)|(((format)&65535UL)<<0))
diff --git a/fw/fe310/eos/eve/eve_eos.c b/fw/fe310/eos/eve/eve_eos.c
deleted file mode 100644
index 2e13cd2..0000000
--- a/fw/fe310/eos/eve/eve_eos.c
+++ /dev/null
@@ -1,104 +0,0 @@
-#include <stdlib.h>
-
-#include "platform.h"
-
-#include "eos.h"
-#include "interrupt.h"
-#include "event.h"
-#include "pwr.h"
-
-#include "board.h"
-
-#include "eve.h"
-#include "eve_eos.h"
-
-static int _run;
-
-static void handle_time(unsigned char type) {
- if (_run) {
- eve_spi_start();
- eve_handle_time();
- eve_spi_stop();
- }
-}
-
-static void handle_evt(unsigned char type, unsigned char *buffer, uint16_t len) {
- if (_run) {
- eve_spi_start();
- eve_handle_intr();
- eve_spi_stop();
-
- GPIO_REG(GPIO_LOW_IE) |= (1 << EVE_PIN_INTR);
- }
-}
-
-static void handle_intr(void) {
- GPIO_REG(GPIO_LOW_IE) &= ~(1 << EVE_PIN_INTR);
- GPIO_REG(GPIO_LOW_IP) = (1 << EVE_PIN_INTR);
- eos_evtq_push_isr(EOS_EVT_UI | EVE_ETYPE_INTR, NULL, 0);
-}
-
-
-static void _start(void) {
- eve_start();
-
- GPIO_REG(GPIO_INPUT_EN) |= (1 << EVE_PIN_INTR);
- GPIO_REG(GPIO_OUTPUT_EN) &= ~(1 << EVE_PIN_INTR);
-
- GPIO_REG(GPIO_LOW_IE) |= (1 << EVE_PIN_INTR);
-
- eos_intr_enable(INT_GPIO_BASE + EVE_PIN_INTR);
- _run = 1;
-}
-
-static void _stop(void) {
- _run = 0;
- eos_intr_disable(INT_GPIO_BASE + EVE_PIN_INTR);
-
- GPIO_REG(GPIO_LOW_IE) &= ~(1 << EVE_PIN_INTR);
-
- eve_stop();
-}
-
-int eos_eve_init(uint8_t wakeup_cause, uint8_t gpio_dir, int touch_calibrate, uint32_t *touch_matrix) {
- int rst = (wakeup_cause == EOS_PWR_WAKE_RST);
- int rv = EVE_OK;
-
- eve_spi_start();
- if (rst) {
- rv = eve_init(gpio_dir, touch_calibrate, touch_matrix);
- } else {
- eve_active();
- }
- eve_spi_stop();
-
- if (rv) return EOS_ERR;
-
- eos_evtq_set_handler(EOS_EVT_UI, handle_evt);
- eos_timer_set_handler(EOS_TIMER_ETYPE_UI, handle_time);
- eos_intr_set(INT_GPIO_BASE + EVE_PIN_INTR, IRQ_PRIORITY_UI, handle_intr);
- eos_intr_disable(INT_GPIO_BASE + EVE_PIN_INTR);
-
- return EOS_OK;
-}
-
-int eos_eve_run(uint8_t wakeup_cause) {
- eve_spi_start();
- _start();
- eve_start_clk();
- eve_spi_stop();
-
- return EOS_OK;
-}
-
-void eos_eve_start(void) {
- eve_spi_start();
- _start();
- eve_spi_stop();
-}
-
-void eos_eve_stop(void) {
- eve_spi_start();
- _stop();
- eve_spi_stop();
-}
diff --git a/fw/fe310/eos/eve/eve_eos.h b/fw/fe310/eos/eve/eve_eos.h
deleted file mode 100644
index 80eea86..0000000
--- a/fw/fe310/eos/eve/eve_eos.h
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <stdint.h>
-
-int eos_eve_init(uint8_t wakeup_cause, uint8_t gpio_dir, int touch_calibrate, uint32_t *touch_matrix);
-int eos_eve_run(uint8_t wakeup_cause);
-void eos_eve_start(void);
-void eos_eve_stop(void);
diff --git a/fw/fe310/eos/eve/eve_phy.c b/fw/fe310/eos/eve/eve_phy.c
index 1e255fe..09a86c6 100644
--- a/fw/fe310/eos/eve/eve_phy.c
+++ b/fw/fe310/eos/eve/eve_phy.c
@@ -19,20 +19,27 @@ void eve_phy_acc_start(EVEPhyAcc *param, int x0, int y0, int v0x, int v0y) {
param->k = 2 * v0 / param->a * EVE_RTC_FREQ;
}
-int eve_phy_acc_tick(EVEPhyAcc *param, int dt, int *x, int *y) {
+int eve_phy_acc_tick(EVEPhyAcc *param, uint32_t dt, int *x, int *y) {
int k = param->k;
int x0 = param->x0;
int y0 = param->y0;
int v0x = param->v0x;
int v0y = param->v0y;
+ int _dt = dt;
int more = 1;
+ if (k == 0) {
+ if (x) *x = x0;
+ if (y) *y = y0;
+ return 0;
+ }
+
if ((k < 0) && (dt >= -k / 2)) {
dt = -k / 2;
more = 0;
}
- if (x) *x = x0 + (v0x * dt + v0x * dt / k * dt) / (int)(EVE_RTC_FREQ);
- if (y) *y = y0 + (v0y * dt + v0y * dt / k * dt) / (int)(EVE_RTC_FREQ);
+ if (x) *x = x0 + (v0x * _dt + v0x * _dt / k * _dt) / EVE_RTC_FREQ;
+ if (y) *y = y0 + (v0y * _dt + v0y * _dt / k * _dt) / EVE_RTC_FREQ;
return more;
}
@@ -55,7 +62,7 @@ int eve_phy_lho_start(EVEPhyLHO *param, int x0, int y0) {
param->y0 = y0;
}
-int eve_phy_lho_tick(EVEPhyLHO *param, int dt, int *x, int *y) {
+int eve_phy_lho_tick(EVEPhyLHO *param, uint32_t dt, int *x, int *y) {
int ax = param->x0 - param->x;
int ay = param->y0 - param->y;
int more = 1;
diff --git a/fw/fe310/eos/eve/eve_phy.h b/fw/fe310/eos/eve/eve_phy.h
index 1be5fd0..37d0221 100644
--- a/fw/fe310/eos/eve/eve_phy.h
+++ b/fw/fe310/eos/eve/eve_phy.h
@@ -11,7 +11,7 @@ typedef struct EVEPhyAcc {
void eve_phy_acc_init(EVEPhyAcc *param, int a);
void eve_phy_acc_start(EVEPhyAcc *param, int x0, int y0, int v0x, int v0y);
-int eve_phy_acc_tick(EVEPhyAcc *param, int dt, int *x, int *y);
+int eve_phy_acc_tick(EVEPhyAcc *param, uint32_t dt, int *x, int *y);
typedef struct EVEPhyLHO {
int x;
@@ -25,4 +25,4 @@ typedef struct EVEPhyLHO {
void eve_phy_lho_init(EVEPhyLHO *param, int x, int y, uint32_t T, double d, uint32_t t_max);
int eve_phy_lho_start(EVEPhyLHO *param, int x0, int y0);
-int eve_phy_lho_tick(EVEPhyLHO *param, int dt, int *x, int *y); \ No newline at end of file
+int eve_phy_lho_tick(EVEPhyLHO *param, uint32_t dt, int *x, int *y); \ No newline at end of file
diff --git a/fw/fe310/eos/eve/eve_platform.c b/fw/fe310/eos/eve/eve_platform.c
index 4450412..f0fc399 100644
--- a/fw/fe310/eos/eve/eve_platform.c
+++ b/fw/fe310/eos/eve/eve_platform.c
@@ -17,19 +17,19 @@ void eve_free(void *p) {
free(p);
}
-void eve_timer_set(uint32_t ms) {
- eos_timer_set(ms, EOS_TIMER_ETYPE_UI);
+void eve_sleep(uint32_t ms) {
+ eos_time_sleep(ms);
}
-void eve_time_sleep(uint32_t ms) {
- eos_time_sleep(ms);
+uint32_t eve_get_tick(void) {
+ return (uint32_t)eos_time_get_tick();
}
-uint64_t eve_time_get_tick(void) {
- return eos_time_get_tick();
+void eve_sys_timer_set(uint32_t ms) {
+ eos_timer_set(EOS_TIMER_ETYPE_UI, ms);
}
-void eve_timer_clear(void) {
+void eve_sys_timer_clear(void) {
eos_timer_clear(EOS_TIMER_ETYPE_UI);
}
diff --git a/fw/fe310/eos/eve/eve_platform.h b/fw/fe310/eos/eve/eve_platform.h
index 77afffc..9d472b5 100644
--- a/fw/fe310/eos/eve/eve_platform.h
+++ b/fw/fe310/eos/eve/eve_platform.h
@@ -31,7 +31,7 @@ void eve_spi_stop(void);
#define eve_spi_lock eos_spi_lock
#define eve_spi_unlock eos_spi_unlock
-void eve_time_sleep(uint32_t ms);
-uint64_t eve_time_get_tick(void);
-void eve_timer_set(uint32_t ms);
-void eve_timer_clear(void);
+void eve_sleep(uint32_t ms);
+uint32_t eve_get_tick(void);
+void eve_sys_timer_set(uint32_t ms);
+void eve_sys_timer_clear(void);
diff --git a/fw/fe310/eos/eve/eve_touch.c b/fw/fe310/eos/eve/eve_touch.c
index 7c06f81..0dc8b31 100644
--- a/fw/fe310/eos/eve/eve_touch.c
+++ b/fw/fe310/eos/eve/eve_touch.c
@@ -1,10 +1,9 @@
#include <stdlib.h>
#include <string.h>
-#include <math.h>
#include "eve.h"
+#include "eve_touch_engine.h"
-static int touch_multi;
static uint8_t touch_tag0;
static EVETouch touch_obj[EVE_MAX_TOUCH];
@@ -14,235 +13,210 @@ static eve_touch_handler_t touch_handler;
static void *touch_handler_param;
static uint8_t touch_tag_opt[256];
-static const uint32_t _reg_touch[] = {
- REG_CTOUCH_TOUCH0_XY,
- REG_CTOUCH_TOUCH1_XY,
- REG_CTOUCH_TOUCH2_XY,
- REG_CTOUCH_TOUCH3_XY
-};
-
-static const uint32_t _reg_tag[] = {
- REG_TOUCH_TAG,
- REG_TOUCH_TAG1,
- REG_TOUCH_TAG2,
- REG_TOUCH_TAG3,
- REG_TOUCH_TAG4
-};
-
-static const uint32_t _reg_track[] = {
- REG_TRACKER,
- REG_TRACKER_1,
- REG_TRACKER_2,
- REG_TRACKER_3,
- REG_TRACKER_4
-};
-
-void eve_handle_touch(uint16_t intr_flags) {
+void eve_touch_init(void) {
int i;
- char touch_ex = 0;
- char int_ccomplete = 0;
- uint16_t intr_mask;
-
- intr_mask = eve_read16(REG_INT_MASK);
- if (!touch_multi && (intr_flags & EVE_INT_TOUCH)) touch_multi = 1;
+ touch_tag0 = 0;
+ memset(&touch_timer, 0, sizeof(touch_timer));
for (i=0; i<EVE_MAX_TOUCH; i++) {
- uint8_t touch_tag;
- uint32_t touch_xy;
- uint64_t now = 0;
- uint16_t touch_evt = 0;
EVETouch *touch = &touch_obj[i];
- touch_xy = i < 4 ? eve_read32(_reg_touch[i]) : (((uint32_t)eve_read16(REG_CTOUCH_TOUCH4_X) << 16) | eve_read16(REG_CTOUCH_TOUCH4_Y));
+ memset(&touch_obj[i], 0, sizeof(EVETouch));
+ touch->eevt |= EVE_TOUCH_EETYPE_NOTOUCH;
+ }
+ eve_vtrack_init();
+}
- if (touch_xy != EVE_NOTOUCH) {
- int16_t touch_x = touch_xy >> 16;
- int16_t touch_y = touch_xy & 0xffff;
- now = eve_time_get_tick();
- if (touch->eevt & EVE_TOUCH_EETYPE_NOTOUCH) {
- uint16_t _evt = 0;
- uint16_t _eevt = 0;
- uint16_t _ttevt = eve_touch_timer_get_evt(touch);
+void eve_handle_touch(uint16_t intr_flags) {
+ int i;
- if (_ttevt) {
- touch->eevt &= ~EVE_TOUCH_EETYPE_NOTOUCH;
+ for (i=0; i<EVE_MAX_TOUCH; i++) {
+ uint32_t now = 0;
+ uint16_t touch_evt = 0;
+ EVETouch *touch = &touch_obj[i];
- if (_ttevt & EVE_TOUCH_ETYPE_TAP2) {
- int dx = touch_x - touch->x0;
- int dy = touch_y - touch->y0;
+ now = eve_get_tick();
+
+ if (intr_flags & EVE_INT_CONVCOMPLETE) {
+ uint32_t touch_xy = eve_touch_reg_xy(i);
+ uint16_t timer_evt;
+
+ if (touch_xy != EVE_NOTOUCH) {
+ int16_t touch_x = touch_xy >> 16;
+ int16_t touch_y = touch_xy & 0xffff;
+ int check_track, check_timer;
+
+ if (touch->eevt & EVE_TOUCH_EETYPE_NOTOUCH) {
+ uint16_t _evt = 0;
+ uint16_t _eevt = 0;
+
+ timer_evt = eve_timer_get_evt(touch);
+ if (timer_evt) {
+ uint16_t _touch_evt = 0;
+
+ touch->eevt &= ~EVE_TOUCH_EETYPE_NOTOUCH;
+ if (timer_evt & EVE_TOUCH_ETYPE_TAP2) {
+ int dx = touch_x - touch->x0;
+ int dy = touch_y - touch->y0;
+
+ dx = dx < 0 ? -dx : dx;
+ dy = dy < 0 ? -dy : dy;
+ if ((dx > EVE_TOUCH_THRESHOLD_X) || (dy > EVE_TOUCH_THRESHOLD_Y)) {
+ _touch_evt |= EVE_TOUCH_ETYPE_TAP1;
+ } else {
+ _evt |= EVE_TOUCH_ETYPE_TAP2;
+ _eevt |= EVE_TOUCH_EETYPE_TAP2;
+ }
+ }
+ if (timer_evt & EVE_TOUCH_ETYPE_TRACK) {
+ EVEVTrack *vtrack = eve_vtrack_get();
- dx = dx < 0 ? -dx : dx;
- dy = dy < 0 ? -dy : dy;
- if ((dx > EVE_TOUCH_THRESHOLD_X) || (dy > EVE_TOUCH_THRESHOLD_Y)) {
- touch_evt |= EVE_TOUCH_ETYPE_TAP1;
- } else {
- _evt |= EVE_TOUCH_ETYPE_TAP2;
- _eevt |= EVE_TOUCH_EETYPE_TAP2;
+ _eevt |= EVE_TOUCH_EETYPE_TRACK_ABORT;
+ _touch_evt |= (EVE_TOUCH_ETYPE_TRACK_STOP | EVE_TOUCH_ETYPE_TRACK_ABORT);
+ if (vtrack->stop) vtrack->stop(touch, vtrack->param);
+ }
+ if (timer_evt & EVE_TOUCH_ETYPE_TIMER) {
+ _eevt |= EVE_TOUCH_EETYPE_TIMER_ABORT;
+ _touch_evt |= EVE_TOUCH_ETYPE_TIMER_ABORT;
}
- }
- if (_ttevt & EVE_TOUCH_ETYPE_TRACK) {
- EVEVTrack *vtrack = eve_vtrack_get();
- _eevt |= EVE_TOUCH_EETYPE_TRACK_ABORT;
- touch_evt |= (EVE_TOUCH_ETYPE_TRACK_STOP | EVE_TOUCH_ETYPE_TRACK_ABORT);
- if (vtrack->stop) vtrack->stop(touch, vtrack->param);
+ eve_timer_clear(touch);
+ if (touch_handler && _touch_evt) {
+ touch_handler(touch_timer.touch, _touch_evt, touch_timer.tag0, touch_handler_param);
+ }
}
- if (_ttevt & EVE_TOUCH_ETYPE_TIMER) {
- _eevt |= EVE_TOUCH_EETYPE_TIMER_ABORT;
- touch_evt |= EVE_TOUCH_ETYPE_TIMER_ABORT;
+ touch_evt |= EVE_TOUCH_ETYPE_POINT | _evt;
+ touch->eevt = _eevt;
+ touch->tag0 = 0;
+ touch->tag = 0;
+ touch->tag_up = 0;
+ touch->tracker.tag = 0;
+ touch->tracker.track = 0;
+ touch->tracker.val = 0;
+ touch->t = 0;
+ touch->vx = 0;
+ touch->vy = 0;
+ touch->x0 = touch_x;
+ touch->y0 = touch_y;
+ } else if (touch->tracker.track) {
+ uint32_t dt = now - touch->t;
+ int vx = ((int)touch_x - touch->x) * EVE_RTC_FREQ / (int)dt;
+ int vy = ((int)touch_y - touch->y) * EVE_RTC_FREQ / (int)dt;
+
+ touch->vx = vx;
+ touch->vy = vy;
+ touch->t = now;
+ }
+ touch->x = touch_x;
+ touch->y = touch_y;
+
+ timer_evt = eve_timer_get_evt(touch);
+ check_track = touch->tracker.tag && !touch->tracker.track;
+ check_timer = timer_evt & (EVE_TOUCH_ETYPE_LPRESS | EVE_TOUCH_ETYPE_TAP2);
+
+ if (check_track || check_timer) {
+ int dx = touch->x - touch->x0;
+ int dy = touch->y - touch->y0;
+
+ dx = dx < 0 ? -dx : dx;
+ dy = dy < 0 ? -dy : dy;
+ if (check_track) {
+ if ((dx > EVE_TOUCH_THRESHOLD_X) && !(touch_tag_opt[touch->tracker.tag] & EVE_TOUCH_OPT_TRACK_X)) {
+ touch->tracker.tag = 0;
+ }
+ if ((dy > EVE_TOUCH_THRESHOLD_Y) && !(touch_tag_opt[touch->tracker.tag] & EVE_TOUCH_OPT_TRACK_Y)) {
+ touch->tracker.tag = 0;
+ }
+ if (touch->tracker.tag && ((dx > EVE_TOUCH_THRESHOLD_X) || (dy > EVE_TOUCH_THRESHOLD_Y))) {
+ if (dx > EVE_TOUCH_THRESHOLD_X) {
+ touch->eevt |= touch->x > touch->x0 ? EVE_TOUCH_EETYPE_TRACK_RIGHT : EVE_TOUCH_EETYPE_TRACK_LEFT;
+ }
+ if (dy > EVE_TOUCH_THRESHOLD_Y) {
+ touch->eevt |= touch->y > touch->y0 ? EVE_TOUCH_EETYPE_TRACK_DOWN : EVE_TOUCH_EETYPE_TRACK_UP;
+ }
+ touch_evt |= EVE_TOUCH_ETYPE_TRACK_START;
+ touch->tracker.track = 1;
+ touch->t = now;
+ }
}
-
- eve_touch_timer_clear(touch);
- if (touch_handler && touch_evt) {
- touch_handler(touch_timer.touch, touch_evt, touch_timer.tag0, touch_handler_param);
+ if (check_timer && ((dx > EVE_TOUCH_THRESHOLD_X) || (dy > EVE_TOUCH_THRESHOLD_Y))) {
+ eve_timer_set_evt(touch, timer_evt & ~(EVE_TOUCH_ETYPE_LPRESS | EVE_TOUCH_ETYPE_TAP2));
}
}
- touch_evt = EVE_TOUCH_ETYPE_POINT | _evt;
- touch->eevt = _eevt;
- touch->tag0 = 0;
- touch->tag = 0;
- touch->tag_up = 0;
- touch->tracker.tag = 0;
- touch->tracker.track = 0;
- touch->tracker.val = 0;
- touch->t = 0;
- touch->vx = 0;
- touch->vy = 0;
- touch->x0 = touch_x;
- touch->y0 = touch_y;
- } else if (touch->t) {
- int dt = now - touch->t;
- int vx = ((int)touch_x - touch->x) * (int)(EVE_RTC_FREQ) / dt;
- int vy = ((int)touch_y - touch->y) * (int)(EVE_RTC_FREQ) / dt;
- touch->vx = touch->vx ? (vx + touch->vx * EVE_TOUCH_TRAVG) / (EVE_TOUCH_TRAVG + 1) : vx;
- touch->vy = touch->vy ? (vy + touch->vy * EVE_TOUCH_TRAVG) / (EVE_TOUCH_TRAVG + 1) : vy;
- touch->t = now;
- }
- touch->x = touch_x;
- touch->y = touch_y;
- if (touch_multi || (intr_flags & EVE_INT_TAG)) {
- touch_tag = eve_read8(_reg_tag[i]);
- } else {
- touch_tag = touch->tag;
- }
- touch_ex = 1;
- } else {
- touch_tag = 0;
- if (!(touch->eevt & EVE_TOUCH_EETYPE_NOTOUCH)) {
- uint16_t _ttevt = eve_touch_timer_get_evt(touch);
-
- touch_evt = EVE_TOUCH_ETYPE_POINT_UP;
- touch->eevt |= EVE_TOUCH_EETYPE_NOTOUCH;
- if (_ttevt & EVE_TOUCH_ETYPE_LPRESS) {
- eve_touch_timer_set_evt(touch, _ttevt & ~EVE_TOUCH_ETYPE_LPRESS);
- }
if (touch->tracker.tag && touch->tracker.track) {
- uint8_t opt = touch_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 (!eve_touch_timer_get_evt(NULL) && track_ext) {
- EVEVTrack *vtrack = eve_vtrack_get();
-
- eve_touch_timer_set(touch, EVE_TOUCH_ETYPE_TRACK, touch_tag0, EVE_TOUCH_TIMEOUT_TRACK);
- if (vtrack->start) vtrack->start(touch, vtrack->param);
+ if (touch_tag_opt[touch->tracker.tag] & EVE_TOUCH_OPT_TRACK) touch_evt |= EVE_TOUCH_ETYPE_TRACK;
+ if (touch_tag_opt[touch->tracker.tag] & EVE_TOUCH_OPT_TRACK_REG) touch_evt |= EVE_TOUCH_ETYPE_TRACK_REG;
+ }
+ if (touch_evt & EVE_TOUCH_ETYPE_TRACK_REG) {
+ uint32_t touch_track = eve_touch_reg_track(i);
+
+ if (touch->tracker.tag == (touch_track & 0xff)) {
+ touch->tracker.val = touch_track >> 16;
} else {
- touch_evt |= EVE_TOUCH_ETYPE_TRACK_STOP;
+ touch_evt &= ~EVE_TOUCH_ETYPE_TRACK_REG;
}
}
- }
- }
- if (touch_tag != touch->tag) {
- if (touch_tag) {
- if (!touch_tag0) touch_tag0 = touch_tag;
- if (!touch->tag0) {
- touch->tag0 = touch_tag;
- if (touch_tag_opt[touch_tag] & (EVE_TOUCH_OPT_TRACK | EVE_TOUCH_OPT_TRACK_REG)) {
- touch->tracker.tag = touch_tag;
- }
- if (touch->tracker.tag && !(touch_tag_opt[touch->tracker.tag] & EVE_TOUCH_OPT_TRACK_XY)) {
- touch_evt |= EVE_TOUCH_ETYPE_TRACK_START;
- touch->tracker.track = 1;
- touch->t = now;
- }
- if (!eve_touch_timer_get_evt(NULL) && (touch_tag_opt[touch_tag] & (EVE_TOUCH_OPT_LPRESS | EVE_TOUCH_OPT_TAP2))) {
- uint16_t _evt = 0;
+ } else {
+ if (!(touch->eevt & EVE_TOUCH_EETYPE_NOTOUCH)) {
+ touch_evt |= EVE_TOUCH_ETYPE_POINT_UP;
+ touch->eevt |= EVE_TOUCH_EETYPE_NOTOUCH;
- if (touch_tag_opt[touch_tag] & EVE_TOUCH_OPT_LPRESS) _evt |= EVE_TOUCH_ETYPE_LPRESS;
- if (touch_tag_opt[touch_tag] & EVE_TOUCH_OPT_TAP2) _evt |= EVE_TOUCH_ETYPE_TAP2;
- eve_touch_timer_set(touch, _evt, touch_tag0, EVE_TOUCH_TIMEOUT_TAP);
+ timer_evt = eve_timer_get_evt(touch);
+ if (timer_evt & EVE_TOUCH_ETYPE_LPRESS) {
+ eve_timer_set_evt(touch, timer_evt & ~EVE_TOUCH_ETYPE_LPRESS);
+ }
+ if (touch->tracker.tag && touch->tracker.track) {
+ uint8_t opt = touch_tag_opt[touch->tracker.tag];
+ uint8_t 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 (!eve_timer_get_evt(NULL) && track_ext) {
+ EVEVTrack *vtrack = eve_vtrack_get();
+
+ eve_timer_set(touch, EVE_TOUCH_ETYPE_TRACK, touch_tag0, EVE_TOUCH_TIMEOUT_TRACK);
+ if (vtrack->start) vtrack->start(touch, vtrack->param);
+ } else {
+ touch_evt |= EVE_TOUCH_ETYPE_TRACK_STOP;
+ }
}
}
}
- touch->tag_up = touch->tag;
- if (touch->tag_up) touch_evt |= EVE_TOUCH_ETYPE_TAG_UP;
- touch->tag = touch_tag;
- if (touch->tag) touch_evt |= EVE_TOUCH_ETYPE_TAG;
}
- if (touch_xy != EVE_NOTOUCH) {
- uint16_t _ttevt = eve_touch_timer_get_evt(touch);
- int _track = touch->tracker.tag && !touch->tracker.track;
- int _timer = _ttevt & (EVE_TOUCH_ETYPE_LPRESS | EVE_TOUCH_ETYPE_TAP2);
- if (_track || _timer) {
- int dx = touch->x - touch->x0;
- int dy = touch->y - touch->y0;
- dx = dx < 0 ? -dx : dx;
- dy = dy < 0 ? -dy : dy;
- if (_track) {
- if ((dx > EVE_TOUCH_THRESHOLD_X) && !(touch_tag_opt[touch->tracker.tag] & EVE_TOUCH_OPT_TRACK_X)) {
- touch->tracker.tag = 0;
- }
- if ((dy > EVE_TOUCH_THRESHOLD_Y) && !(touch_tag_opt[touch->tracker.tag] & EVE_TOUCH_OPT_TRACK_Y)) {
- touch->tracker.tag = 0;
- }
- if (touch->tracker.tag && ((dx > EVE_TOUCH_THRESHOLD_X) || (dy > EVE_TOUCH_THRESHOLD_Y))) {
- if (dx > EVE_TOUCH_THRESHOLD_X) {
- touch->eevt |= touch->x > touch->x0 ? EVE_TOUCH_EETYPE_TRACK_RIGHT : EVE_TOUCH_EETYPE_TRACK_LEFT;
+
+ if (intr_flags & EVE_INT_TAG) {
+ uint8_t touch_tag = eve_touch_reg_tag(i);
+
+ if (touch_tag != touch->tag) {
+ if (touch_tag) {
+ if (!touch_tag0) touch_tag0 = touch_tag;
+ if (!touch->tag0) {
+ touch->tag0 = touch_tag;
+ if (touch_tag_opt[touch_tag] & (EVE_TOUCH_OPT_TRACK | EVE_TOUCH_OPT_TRACK_REG)) {
+ touch->tracker.tag = touch_tag;
}
- if (dy > EVE_TOUCH_THRESHOLD_Y) {
- touch->eevt |= touch->y > touch->y0 ? EVE_TOUCH_EETYPE_TRACK_DOWN : EVE_TOUCH_EETYPE_TRACK_UP;
+ if (touch->tracker.tag && !(touch_tag_opt[touch->tracker.tag] & EVE_TOUCH_OPT_TRACK_XY)) {
+ touch_evt |= EVE_TOUCH_ETYPE_TRACK_START;
+ touch->tracker.track = 1;
+ touch->t = now;
+ }
+ if (!eve_timer_get_evt(NULL) && (touch_tag_opt[touch_tag] & (EVE_TOUCH_OPT_LPRESS | EVE_TOUCH_OPT_TAP2))) {
+ uint16_t _evt = 0;
+
+ if (touch_tag_opt[touch_tag] & EVE_TOUCH_OPT_LPRESS) _evt |= EVE_TOUCH_ETYPE_LPRESS;
+ if (touch_tag_opt[touch_tag] & EVE_TOUCH_OPT_TAP2) _evt |= EVE_TOUCH_ETYPE_TAP2;
+ eve_timer_set(touch, _evt, touch_tag0, EVE_TOUCH_TIMEOUT_TAP);
}
- touch_evt |= EVE_TOUCH_ETYPE_TRACK_START;
- touch->tracker.track = 1;
- touch->t = now;
}
}
- if (_timer && ((dx > EVE_TOUCH_THRESHOLD_X) || (dy > EVE_TOUCH_THRESHOLD_Y))) {
- eve_touch_timer_set_evt(touch, _ttevt & ~(EVE_TOUCH_ETYPE_LPRESS | EVE_TOUCH_ETYPE_TAP2));
- _timer = 0;
- }
+ touch->tag_up = touch->tag;
+ if (touch->tag_up) touch_evt |= EVE_TOUCH_ETYPE_TAG_UP;
+ touch->tag = touch_tag;
+ if (touch->tag) touch_evt |= EVE_TOUCH_ETYPE_TAG;
}
- if (touch->tracker.tag && touch->tracker.track) {
- if (touch_tag_opt[touch->tracker.tag] & EVE_TOUCH_OPT_TRACK) touch_evt |= EVE_TOUCH_ETYPE_TRACK;
- if (touch_tag_opt[touch->tracker.tag] & EVE_TOUCH_OPT_TRACK_REG) touch_evt |= EVE_TOUCH_ETYPE_TRACK_REG;
- }
- if (touch_evt & EVE_TOUCH_ETYPE_TRACK_REG) {
- uint32_t touch_track = eve_read32(_reg_track[i]);
- if (touch->tracker.tag == (touch_track & 0xff)) {
- touch->tracker.val = touch_track >> 16;
- } else {
- touch_evt &= ~EVE_TOUCH_ETYPE_TRACK_REG;
- }
- }
- if (touch->tracker.tag || _timer) int_ccomplete = 1;
}
+
if (touch_handler && touch_evt) {
touch_handler(touch, touch_evt, touch_tag0, touch_handler_param);
}
- if (!touch_multi) break;
- }
-
- if (!touch_ex) {
- touch_tag0 = 0;
- touch_multi = 0;
- }
-
- if (touch_multi) int_ccomplete = 1;
-
- if (int_ccomplete && !(intr_mask & EVE_INT_CONVCOMPLETE)) {
- eve_write16(REG_INT_MASK, intr_mask | EVE_INT_CONVCOMPLETE);
- }
- if (!int_ccomplete && (intr_mask & EVE_INT_CONVCOMPLETE)) {
- eve_write16(REG_INT_MASK, intr_mask & ~EVE_INT_CONVCOMPLETE);
}
}
@@ -278,7 +252,7 @@ void eve_handle_time(void) {
}
if (more) {
- eve_timer_set(touch_timer.to);
+ eve_sys_timer_set(touch_timer.to);
} else {
touch_timer.evt = 0;
}
@@ -289,74 +263,12 @@ void eve_handle_time(void) {
}
}
-void eve_touch_init(int touch_calibrate, uint32_t *touch_matrix) {
- /* configure touch */
- eve_write8(REG_CPURESET, 2); /* touch engine reset */
- eve_write16(REG_TOUCH_CONFIG, 0x4000); /* host mode multi touch */
- eve_write8(REG_CPURESET, 0); /* clear reset */
-
- if (touch_calibrate) {
- eve_write8(REG_PWM_DUTY, 0x40);
- eve_cmd(CMD_TEXT, "hhhhs", EVE_HSIZE/2, EVE_VSIZE/2, 27, EVE_OPT_CENTER, "Please tap on the dot.");
- eve_cmd(CMD_CALIBRATE, "w", 0);
- eve_cmd_exec(1);
- eve_write8(REG_PWM_DUTY, 0);
-
- touch_matrix[0] = eve_read32(REG_TOUCH_TRANSFORM_A);
- touch_matrix[1] = eve_read32(REG_TOUCH_TRANSFORM_B);
- touch_matrix[2] = eve_read32(REG_TOUCH_TRANSFORM_C);
- touch_matrix[3] = eve_read32(REG_TOUCH_TRANSFORM_D);
- touch_matrix[4] = eve_read32(REG_TOUCH_TRANSFORM_E);
- touch_matrix[5] = eve_read32(REG_TOUCH_TRANSFORM_F);
- } else {
- eve_write32(REG_TOUCH_TRANSFORM_A, touch_matrix[0]);
- eve_write32(REG_TOUCH_TRANSFORM_B, touch_matrix[1]);
- eve_write32(REG_TOUCH_TRANSFORM_C, touch_matrix[2]);
- eve_write32(REG_TOUCH_TRANSFORM_D, touch_matrix[3]);
- eve_write32(REG_TOUCH_TRANSFORM_E, touch_matrix[4]);
- eve_write32(REG_TOUCH_TRANSFORM_F, touch_matrix[5]);
- }
-
- eve_write8(REG_CTOUCH_EXTENDED, 0x00); /* set extended mode */
-}
-
-void eve_touch_start(void) {
- uint16_t intr_mask;
- int i;
-
- touch_multi = 0;
- touch_tag0 = 0;
- memset(&touch_timer, 0, sizeof(touch_timer));
- for (i=0; i<EVE_MAX_TOUCH; i++) {
- EVETouch *touch = &touch_obj[i];
-
- memset(&touch_obj[i], 0, sizeof(EVETouch));
- touch->eevt |= EVE_TOUCH_EETYPE_NOTOUCH;
- }
- eve_vtrack_init();
-
- intr_mask = eve_read16(REG_INT_MASK);
- eve_write16(REG_INT_MASK, intr_mask | EVE_INT_TAG | EVE_INT_TOUCH);
-
- eve_write8(REG_TOUCH_MODE, EVE_TMODE_CONTINUOUS);
-}
-
-void eve_touch_stop(void) {
- uint16_t intr_mask;
-
- intr_mask = eve_read16(REG_INT_MASK);
- eve_write16(REG_INT_MASK, intr_mask & ~(EVE_INT_TAG | EVE_INT_TOUCH | EVE_INT_CONVCOMPLETE));
- eve_touch_timer_clear(touch_timer.touch);
-
- eve_write8(REG_TOUCH_MODE, EVE_TMODE_OFF);
-}
-
void eve_touch_set_handler(eve_touch_handler_t handler, void *param) {
touch_handler = handler;
touch_handler_param = param;
}
-EVETouch *eve_touch_get(int i) {
+EVETouch *eve_touch_get_obj(int i) {
return &touch_obj[i];
}
@@ -411,46 +323,55 @@ void eve_touch_clear_opt(void) {
memset(touch_tag_opt, 0, sizeof(touch_tag_opt));
}
-void eve_touch_timer_set(EVETouch *touch, uint16_t evt, uint8_t tag0, uint32_t to) {
+void eve_timer_set(EVETouch *touch, uint16_t evt, uint8_t tag0, uint32_t to) {
touch_timer.touch = touch;
touch_timer.evt = evt;
touch_timer.tag0 = tag0;
touch_timer.to = to;
- eve_timer_set(to);
+ eve_sys_timer_set(to);
}
-void eve_touch_timer_clear(EVETouch *touch) {
- eve_touch_timer_set_evt(touch, 0);
+void eve_timer_clear(EVETouch *touch) {
+ eve_timer_set_evt(touch, 0);
}
-uint16_t eve_touch_timer_get_evt(EVETouch *touch) {
+void eve_timer_set_evt(EVETouch *touch, uint16_t evt) {
+ if ((touch == NULL) || (touch == touch_timer.touch)) {
+ touch_timer.evt = evt;
+ } else if (touch_timer.touch == NULL) {
+ touch_timer.evt = evt;
+ }
+ if (!touch_timer.evt) {
+ eve_sys_timer_clear();
+ touch_timer.touch = NULL;
+ touch_timer.tag0 = 0;
+ touch_timer.to = 0;
+ }
+}
+
+uint16_t eve_timer_get_evt(EVETouch *touch) {
uint16_t ret = 0;
if ((touch == NULL) || (touch_timer.touch == touch)) {
ret = touch_timer.evt;
} else if (touch_timer.touch == NULL) {
- ret = touch_timer.evt & EVE_TOUCH_ETYPE_TIMER;
+ ret = touch_timer.evt;
}
return ret;
}
-void eve_touch_timer_set_evt(EVETouch *touch, uint16_t evt) {
- if (touch == touch_timer.touch) {
- touch_timer.evt = evt;
- } else if (touch_timer.touch == NULL) {
- touch_timer.evt = evt & EVE_TOUCH_ETYPE_TIMER;
- }
- if (!touch_timer.evt) eve_timer_clear();
+EVETouchTimer *eve_timer_get_obj(void) {
+ return &touch_timer;
}
-void eve_touch_timer_start(uint8_t tag0, uint32_t to) {
- eve_touch_timer_set(NULL, EVE_TOUCH_ETYPE_TIMER, tag0, to);
+void eve_timer_start(uint8_t tag0, uint32_t to) {
+ if (!touch_timer.evt) eve_timer_set(NULL, EVE_TOUCH_ETYPE_TIMER, tag0, to);
}
-void eve_touch_timer_stop(void) {
- eve_touch_timer_clear(NULL);
+void eve_timer_stop(void) {
+ if (touch_timer.touch == NULL) eve_timer_clear(NULL);
}
-EVETouchTimer *eve_touch_timer_get(void) {
- return &touch_timer;
+void eve_touch_clear_tag0(void) {
+ touch_tag0 = 0;
}
diff --git a/fw/fe310/eos/eve/eve_touch.h b/fw/fe310/eos/eve/eve_touch.h
index b10fde2..e3e92b0 100644
--- a/fw/fe310/eos/eve/eve_touch.h
+++ b/fw/fe310/eos/eve/eve_touch.h
@@ -5,7 +5,6 @@
#define EVE_TOUCH_THRESHOLD_X 5
#define EVE_TOUCH_THRESHOLD_Y 5
-#define EVE_TOUCH_TRAVG 3
#define EVE_NOTAG 0
#define EVE_NOTOUCH 0x80008000
@@ -77,7 +76,7 @@ typedef struct EVETouch {
int vy;
int x0;
int y0;
- uint64_t t;
+ uint32_t t;
uint16_t eevt;
uint8_t tag0;
uint8_t tag;
@@ -98,15 +97,12 @@ typedef struct EVETouchTimer {
typedef void (*eve_touch_handler_t) (EVETouch *, uint16_t, uint8_t, void *);
+void eve_touch_init(void);
void eve_handle_touch(uint16_t intr_flags);
void eve_handle_time(void);
-void eve_touch_init(int touch_calibrate, uint32_t *touch_matrix);
-void eve_touch_start(void);
-void eve_touch_stop(void);
-
void eve_touch_set_handler(eve_touch_handler_t handler, void *handler_param);
-EVETouch *eve_touch_get(int i);
+EVETouch *eve_touch_get_obj(int i);
int8_t eve_touch_get_idx(EVETouch *touch);
uint16_t eve_touch_evt(EVETouch *touch, uint16_t evt, uint8_t tag0, uint8_t tag_min, uint8_t tag_n);
@@ -114,11 +110,12 @@ void eve_touch_set_opt(uint8_t tag, uint8_t opt);
uint8_t eve_touch_get_opt(uint8_t tag);
void eve_touch_clear_opt(void);
-void eve_touch_timer_set(EVETouch *touch, uint16_t evt, uint8_t tag0, uint32_t to);
-void eve_touch_timer_clear(EVETouch *touch);
-uint16_t eve_touch_timer_get_evt(EVETouch *touch);
-void eve_touch_timer_set_evt(EVETouch *touch, uint16_t evt);
-void eve_touch_timer_start(uint8_t tag0, uint32_t to);
-void eve_touch_timer_stop(void);
+void eve_timer_set(EVETouch *touch, uint16_t evt, uint8_t tag0, uint32_t to);
+void eve_timer_clear(EVETouch *touch);
+void eve_timer_set_evt(EVETouch *touch, uint16_t evt);
+uint16_t eve_timer_get_evt(EVETouch *touch);
+EVETouchTimer *eve_timer_get_obj(void);
-EVETouchTimer *eve_touch_timer_get(void);
+void eve_timer_start(uint8_t tag0, uint32_t to);
+void eve_timer_stop(void);
+void eve_touch_clear_tag0(void);
diff --git a/fw/fe310/eos/eve/eve_vtrack.c b/fw/fe310/eos/eve/eve_vtrack.c
index b9f28af..bd9158b 100644
--- a/fw/fe310/eos/eve/eve_vtrack.c
+++ b/fw/fe310/eos/eve/eve_vtrack.c
@@ -27,12 +27,12 @@ void eve_vtrack_reset(void) {
}
void eve_vtrack_start(EVETouch *touch, uint8_t tag0, uint32_t to) {
- eve_touch_timer_set(touch, EVE_TOUCH_ETYPE_TRACK, tag0, to);
+ eve_timer_set(touch, EVE_TOUCH_ETYPE_TRACK, tag0, to);
if (vtrack.start) vtrack.start(touch, vtrack.param);
}
void eve_vtrack_stop(EVETouch *touch) {
- eve_touch_timer_clear(touch);
+ eve_timer_clear(touch);
eve_vtrack_reset();
}
@@ -44,7 +44,7 @@ void eve_vtrack_acc_start(EVETouch *touch, void *p) {
int eve_vtrack_acc_tick(EVETouch *touch, void *p) {
EVEPhyAcc *param = (EVEPhyAcc *)p;
- return eve_phy_acc_tick(param, eve_time_get_tick() - touch->t, &touch->x, &touch->y);
+ return eve_phy_acc_tick(param, eve_get_tick() - touch->t, &touch->x, &touch->y);
}
void eve_vtrack_lho_start(EVETouch *touch, void *p) {
@@ -56,10 +56,9 @@ void eve_vtrack_lho_start(EVETouch *touch, void *p) {
int eve_vtrack_lho_tick(EVETouch *touch, void *p) {
EVEPhyLHO *param = (EVEPhyLHO *)p;
- return eve_phy_lho_tick(param, eve_time_get_tick() - touch->t, &touch->x, &touch->y);
+ return eve_phy_lho_tick(param, eve_get_tick() - touch->t, &touch->x, &touch->y);
}
void eve_vtrack_lho_stop(EVETouch *touch, void *p) {
eve_vtrack_reset();
}
-
diff --git a/fw/fe310/eos/eve/eve_vtrack.h b/fw/fe310/eos/eve/eve_vtrack.h
index b75f673..fa7e7b7 100644
--- a/fw/fe310/eos/eve/eve_vtrack.h
+++ b/fw/fe310/eos/eve/eve_vtrack.h
@@ -1,6 +1,6 @@
#include <stdint.h>
-#define EVE_VTRACK_ACC_A 1000
+#define EVE_VTRACK_ACC_A 10000
typedef void (*eve_vtrack_start_t) (EVETouch *, void *);
typedef int (*eve_vtrack_tick_t) (EVETouch *, void *);
diff --git a/fw/fe310/eos/eve/screen/page.c b/fw/fe310/eos/eve/screen/page.c
index 65dd534..28526ca 100644
--- a/fw/fe310/eos/eve/screen/page.c
+++ b/fw/fe310/eos/eve/screen/page.c
@@ -47,7 +47,7 @@ void eve_page_close(EVEPage *page) {
if (page->lho_t0) {
page->lho_t0 = 0;
- eve_touch_timer_stop();
+ eve_timer_stop();
}
if (eve_window_scroll(window->root, NULL) == window) {
eve_window_scroll_stop(window);
@@ -213,8 +213,8 @@ static int page_touch(EVEPage *page, EVETouch *touch, uint16_t evt, uint8_t tag0
eve_phy_lho_init(lho, lho_x, lho_y, 1000, 0.5, 0);
eve_phy_lho_start(lho, page->g.x, page->g.y);
- page->lho_t0 = eve_time_get_tick();
- eve_touch_timer_start(_tag, 20);
+ page->lho_t0 = eve_get_tick();
+ eve_timer_start(_tag, 20);
}
}
@@ -256,14 +256,14 @@ static int page_touch(EVEPage *page, EVETouch *touch, uint16_t evt, uint8_t tag0
EVEPhyLHO *lho = &page->lho;
int x, y, more;
- more = eve_phy_lho_tick(lho, eve_time_get_tick() - page->lho_t0, scroll_x ? &x : NULL, scroll_y ? &y : NULL);
+ more = eve_phy_lho_tick(lho, eve_get_tick() - page->lho_t0, scroll_x ? &x : NULL, scroll_y ? &y : NULL);
if (scroll_x) page->g.x = x;
if (scroll_y) page->g.y = y;
if (!more) {
int _ret = 0;
page->lho_t0 = 0;
- eve_touch_timer_stop();
+ eve_timer_stop();
page->track_mode = PAGE_TMODE_NONE;
eve_window_scroll_stop(window);
_ret = eve_view_uievt_pusht(view, EVE_UIEVT_PAGE_SCROLL_STOP, touch, evt, tag0);
diff --git a/fw/fe310/eos/eve/screen/page.h b/fw/fe310/eos/eve/screen/page.h
index 26c33c5..0fc9809 100644
--- a/fw/fe310/eos/eve/screen/page.h
+++ b/fw/fe310/eos/eve/screen/page.h
@@ -26,7 +26,7 @@ typedef struct EVEPage {
uint16_t widget_size;
struct EVEWidget *widget_f;
EVEPhyLHO lho;
- uint64_t lho_t0;
+ uint32_t lho_t0;
uint8_t track_mode;
uint8_t opt;
} EVEPage;
diff --git a/fw/fe310/eos/eve/widget/strw.c b/fw/fe310/eos/eve/widget/strw.c
index e78cf46..55eeca4 100644
--- a/fw/fe310/eos/eve/widget/strw.c
+++ b/fw/fe310/eos/eve/widget/strw.c
@@ -71,6 +71,7 @@ int eve_strw_update(EVEStrWidget *widget) {
widget->str[str_len] = '\0';
}
widget->str_len = str_len;
+ widget->str_g.w = eve_font_str_w(widget->font, widget->str);
return (rv == UTF_OK) ? EVE_OK : EVE_ERR;
}
@@ -305,7 +306,6 @@ void eve_strw_putc(void *w, int c) {
int ins_c = 0, del_c = 0;
int ins_w = 0, del_w = 0;
-
if (c == EVE_PAGE_KBDCH_CLOSE) {
if (cursor1->on) eve_strw_cursor_clear(widget, cursor1);
if (cursor2->on) eve_strw_cursor_clear(widget, cursor2);