diff options
author | Uros Majstorovic <majstor@majstor.org> | 2021-11-18 03:18:18 +0100 |
---|---|---|
committer | Uros Majstorovic <majstor@majstor.org> | 2021-11-18 03:18:18 +0100 |
commit | c44897fda572cf8837b4535a6d1aaad4605c14af (patch) | |
tree | c3c98c36589253da3a1a6308ec2804b5eb4a4d75 /fw/fe310/eos/eve/eve.c | |
parent | b0e84c72d7a533f62ca750a73445da7fcebe8d18 (diff) |
eve sleep improved
Diffstat (limited to 'fw/fe310/eos/eve/eve.c')
-rw-r--r-- | fw/fe310/eos/eve/eve.c | 32 |
1 files changed, 19 insertions, 13 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 */ |