diff options
Diffstat (limited to 'fw/fe310/eos/eve')
-rw-r--r-- | fw/fe310/eos/eve/eve.c | 32 | ||||
-rw-r--r-- | fw/fe310/eos/eve/eve_touch.c | 11 | ||||
-rw-r--r-- | fw/fe310/eos/eve/eve_touch.h | 2 |
3 files changed, 30 insertions, 15 deletions
diff --git a/fw/fe310/eos/eve/eve.c b/fw/fe310/eos/eve/eve.c index 0fb55d4..3447d6b 100644 --- a/fw/fe310/eos/eve/eve.c +++ b/fw/fe310/eos/eve/eve.c @@ -13,7 +13,6 @@ static uint16_t cmd_offset; static char dl_burst; static uint32_t dl_addr; -static uint8_t brigtness; static uint8_t power_state; void eve_command(uint8_t command, uint8_t parameter) { @@ -323,37 +322,44 @@ void eve_gpio_set_dir(uint8_t dir) { } void eve_active(void) { + uint16_t gpiox; + eve_command(EVE_ACTIVE, 0); - if (power_state == EVE_PSTATE_SLEEP) eve_time_sleep(40); - eve_write8(REG_PWM_DUTY, brigtness); - if (power_state != EVE_PSTATE_SLEEP) return; + if (power_state == EVE_PSTATE_SLEEP) { + eve_time_sleep(40); + eve_touch_active(); + } - eve_write8(REG_TOUCH_MODE, EVE_TMODE_CONTINUOUS); - eve_write8(REG_CTOUCH_EXTENDED, 0x00); + gpiox = eve_read16(REG_GPIOX) | 0x8000; + eve_write16(REG_GPIOX, gpiox); power_state = EVE_PSTATE_ACTIVE; } void eve_standby(void) { + uint16_t gpiox; + if (power_state != EVE_PSTATE_ACTIVE) return; - brigtness = eve_read8(REG_PWM_DUTY); + gpiox = eve_read16(REG_GPIOX) & ~0x8000; + eve_write16(REG_GPIOX, gpiox); + eve_command(EVE_STANDBY, 0); power_state = EVE_PSTATE_STANDBY; } void eve_sleep(void) { + uint16_t gpiox; + if (power_state != EVE_PSTATE_ACTIVE) return; - brigtness = eve_read8(REG_PWM_DUTY); - eve_write8(REG_PWM_DUTY, 0x0); + gpiox = eve_read16(REG_GPIOX) & ~0x8000; + eve_write16(REG_GPIOX, gpiox); - eve_write8(REG_CTOUCH_EXTENDED, 0x01); - eve_write8(REG_TOUCH_MODE, EVE_TMODE_OFF); + eve_touch_sleep(); - eve_time_sleep(500); eve_command(EVE_SLEEP, 0); power_state = EVE_PSTATE_SLEEP; @@ -394,7 +400,7 @@ static int _init(int touch_calibrate, uint32_t *touch_matrix, uint8_t gpio_dir) eve_write8(REG_PWM_DUTY, 0x00); eve_write16(REG_GPIOX_DIR, 0x8000 | (gpio_dir & 0x0f)); - eve_write16(REG_GPIOX, 0); + eve_write16(REG_GPIOX, 0x8000); /* initialize display */ eve_write16(REG_HCYCLE, EVE_HCYCLE); /* total number of clocks per line, incl front/back porch */ diff --git a/fw/fe310/eos/eve/eve_touch.c b/fw/fe310/eos/eve/eve_touch.c index 77a0bf9..035e122 100644 --- a/fw/fe310/eos/eve/eve_touch.c +++ b/fw/fe310/eos/eve/eve_touch.c @@ -300,11 +300,18 @@ void eve_handle_time(void) { } } +void eve_touch_active(void) { + eve_write8(REG_TOUCH_MODE, EVE_TMODE_CONTINUOUS); +} + +void eve_touch_sleep(void) { + eve_write8(REG_TOUCH_MODE, EVE_TMODE_OFF); +} + static void _init(int touch_calibrate, uint32_t *touch_matrix) { /* configure touch */ - eve_write16(REG_TOUCH_CONFIG, 0xb81); /* enable touch low power mode: 0xb81 - default: 0x381 */ + eve_write16(REG_TOUCH_CONFIG, 0x381); /* default */ eve_write8(REG_TOUCH_MODE, EVE_TMODE_CONTINUOUS); /* enable touch */ - eve_write16(REG_TOUCH_RZTHRESH, EVE_TOUCH_RZTHRESH); /* eliminate any false touches */ if (touch_calibrate) { eve_write8(REG_PWM_DUTY, 0x40); diff --git a/fw/fe310/eos/eve/eve_touch.h b/fw/fe310/eos/eve/eve_touch.h index 148ed48..074d37a 100644 --- a/fw/fe310/eos/eve/eve_touch.h +++ b/fw/fe310/eos/eve/eve_touch.h @@ -101,6 +101,8 @@ typedef void (*eve_touch_handler_t) (EVETouch *, uint16_t, uint8_t, void *); void eve_handle_touch(void); void eve_handle_time(void); +void eve_touch_active(void); +void eve_touch_sleep(void); void eve_touch_init(uint8_t wakeup_cause, int touch_calibrate, uint32_t *touch_matrix); void eve_touch_set_handler(eve_touch_handler_t handler, void *handler_param); EVETouch *eve_touch_get(int i); |