From 57e71a4476f508cc12361cdf7f71fb853946de23 Mon Sep 17 00:00:00 2001 From: erikkaashoek Date: Wed, 5 May 2021 14:25:28 +0200 Subject: [PATCH] Sleep while waiting for CTS --- nanovna.h | 1 + si4468.c | 6 +++++- ui.c | 11 +++++++++-- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/nanovna.h b/nanovna.h index 8170e38..10206be 100644 --- a/nanovna.h +++ b/nanovna.h @@ -86,6 +86,7 @@ #define DB_PER_DEGREE_BELOW 0.056 #define DB_PER_DEGREE_ABOVE 0.069 #define CENTER_TEMPERATURE 34.0 +#define __WAIT_CTS_WHILE_SLEEPING__ #else #endif diff --git a/si4468.c b/si4468.c index 124bab7..8a7ec13 100644 --- a/si4468.c +++ b/si4468.c @@ -566,7 +566,11 @@ static si446x_state_t SI4463_get_state(void); static void SI4463_set_state(si446x_state_t); #define SI4463_READ_CTS (palReadLine(LINE_RX_CTS)) -#define SI4463_WAIT_CTS while (!SI4463_READ_CTS); +#ifdef __WAIT_CTS_WHILE_SLEEPING__ +#define SI4463_WAIT_CTS while (!SI4463_READ_CTS) __WFI(); +#else +#define SI4463_WAIT_CTS while (!SI4463_READ_CTS) ; +#endif #if 0 // not used static void SI4463_write_byte(uint8_t ADR, uint8_t DATA) diff --git a/ui.c b/ui.c index 8f3efd2..d5c9df6 100644 --- a/ui.c +++ b/ui.c @@ -2920,6 +2920,8 @@ made_screenshot(int touch_x, int touch_y) UINT size; if (touch_y < SD_CARD_START || touch_y > SD_CARD_START + 20 || touch_x > OFFSETX) return FALSE; + ili9341_set_background(LCD_BG_COLOR); + ili9341_fill(4, SD_CARD_START, 16, 16); touch_wait_release(); // uint32_t time = chVTGetSystemTimeX(); // shell_printf("Screenshot\r\n"); @@ -2952,7 +2954,7 @@ made_screenshot(int touch_x, int touch_y) } // time = chVTGetSystemTimeX() - time; // shell_printf("Total time: %dms (write %d byte/sec)\r\n", time/10, (LCD_WIDTH*LCD_HEIGHT*sizeof(uint16_t)+sizeof(bmp_header_v4))*10000/time); - drawMessageBox("SCREENSHOT", res == FR_OK ? fs_filename : " Fail write ", 2000); + drawMessageBox("SCREENSHOT", res == FR_OK ? fs_filename : " Write failed ", 2000); redraw_request|= REDRAW_AREA; return TRUE; } @@ -3118,7 +3120,8 @@ static void extcb1(EXTDriver *extp, expchannel_t channel) { (void)extp; (void)channel; - operation_requested|=OP_LEVER; + if (channel != 9) + operation_requested|=OP_LEVER; // cur_button = READ_PORT() & BUTTON_MASK; } @@ -3133,7 +3136,11 @@ static const EXTConfig extcfg = { {EXT_CH_MODE_DISABLED, NULL}, {EXT_CH_MODE_DISABLED, NULL}, {EXT_CH_MODE_DISABLED, NULL}, +#ifdef __WAIT_CTS_WHILE_SLEEPING__ + {EXT_CH_MODE_RISING_EDGE | EXT_CH_MODE_AUTOSTART | EXT_MODE_GPIOB, extcb1}, +#else {EXT_CH_MODE_DISABLED, NULL}, +#endif {EXT_CH_MODE_DISABLED, NULL}, {EXT_CH_MODE_DISABLED, NULL}, {EXT_CH_MODE_DISABLED, NULL},