diff --git a/chconf.h b/chconf.h index 56a273b..deb0f9e 100644 --- a/chconf.h +++ b/chconf.h @@ -48,7 +48,7 @@ * @details Frequency of the system timer that drives the system ticks. This * setting also defines the system tick time unit. */ -#define CH_CFG_ST_FREQUENCY 2000 +#define CH_CFG_ST_FREQUENCY 10000 /** * @brief Time delta constant for the tick-less mode. diff --git a/ili9341.c b/ili9341.c index 2594683..833f1c6 100644 --- a/ili9341.c +++ b/ili9341.c @@ -469,6 +469,12 @@ void ili9341_fill(int x, int y, int w, int h) dmaStreamSetMemory0(dmatx, &background_color); dmaStreamSetMode(dmatx, txdmamode | STM32_DMA_CR_PSIZE_HWORD | STM32_DMA_CR_MSIZE_HWORD); dmaStreamFlush(w * h); + if (auto_capture) { + send_region("fill", x,y,w,h); + spi_buffer[0] = background_color; + send_buffer((uint8_t *)spi_buffer, 2); +// auto_capture = false; + } // LCD_CS_HIGH; } @@ -483,6 +489,13 @@ void ili9341_bulk(int x, int y, int w, int h) dmaStreamSetMode(dmatx, txdmamode | STM32_DMA_CR_PSIZE_HWORD | STM32_DMA_CR_MSIZE_HWORD | STM32_DMA_CR_MINC); dmaStreamFlush(w * h); +#if 1 + if (auto_capture) { + send_region("bulk", x,y,w,h); + send_buffer((uint8_t *)spi_buffer, w*h*2); +// auto_capture = false; + } +#endif // LCD_CS_HIGH; } #endif diff --git a/main.c b/main.c index c29bb69..b43ddc1 100644 --- a/main.c +++ b/main.c @@ -106,6 +106,7 @@ static int8_t drive_strength = DRIVE_STRENGTH_AUTO; #endif uint8_t sweep_mode = SWEEP_ENABLE; volatile uint8_t redraw_request = 0; // contains REDRAW_XXX flags +volatile int auto_capture = false; // Version text, displayed in Config->Version menu, also send by info command const char *info_about[]={ @@ -124,7 +125,6 @@ const char *info_about[]={ }; uint16_t dirty = true; - bool completed = false; static THD_WORKING_AREA(waThread1, 1124); @@ -806,12 +806,51 @@ VNA_SHELL_FUNCTION(cmd_dump) } #endif +VNA_SHELL_FUNCTION(cmd_refresh) +{ +// read pixel count at one time (PART*2 bytes required for read buffer) + int i, y; + int m = generic_option_cmd("refresh", "off|on", argc, argv[0]); + if (m>=0) { + auto_capture = m; + } +} + +volatile int mouse_x = 0; +volatile int mouse_y = 0; +volatile int mouse_down = false; + +VNA_SHELL_FUNCTION(cmd_touch) +{ + if (argc == 2){ + mouse_x = (uint32_t)my_atoi(argv[0]); + mouse_y = (uint32_t)my_atoi(argv[1]); + mouse_down = true; + handle_touch_interrupt(); + } +} + +VNA_SHELL_FUNCTION(cmd_release) +{ + if (argc==2) { + mouse_x = (uint32_t)my_atoi(argv[0]); + mouse_y = (uint32_t)my_atoi(argv[1]); + } + mouse_down = false; + handle_touch_interrupt(); +} + VNA_SHELL_FUNCTION(cmd_capture) { // read pixel count at one time (PART*2 bytes required for read buffer) - (void)argc; - (void)argv; int i, y; +#if 0 + int m = generic_option_cmd("capture", "off|on", argc, argv[0]); + if (m>=0) { + auto_capture = m; + return; + } +#endif #if SPI_BUFFER_SIZE < (2*LCD_WIDTH) #error "Low size of spi_buffer for cmd_capture" #endif @@ -826,6 +865,26 @@ VNA_SHELL_FUNCTION(cmd_capture) } } +void send_region(const char *t, int x, int y, int w, int h) +{ + shell_printf("%s\r\n", t); + streamPut(shell_stream, (((uint16_t) x) & 0xff)); + streamPut(shell_stream, (((uint16_t)x>>8) & 0xff)); + streamPut(shell_stream, (((uint16_t) y) & 0xff)); + streamPut(shell_stream, (((uint16_t)y>>8) & 0xff)); + streamPut(shell_stream, (((uint16_t) w) & 0xff)); + streamPut(shell_stream, (((uint16_t)w>>8) & 0xff)); + streamPut(shell_stream, (((uint16_t) h) & 0xff)); + streamPut(shell_stream, (((uint16_t)h>>8) & 0xff)); +} + +void send_buffer(uint8_t * buf, int s) +{ + for (int i = 0; i < s; i++) { + streamPut(shell_stream, *buf++); + } + shell_printf("ch> \r\n"); +} #if 0 VNA_SHELL_FUNCTION(cmd_gamma) { @@ -2385,6 +2444,10 @@ static const VNAShellCommand commands[] = {"edelay" , cmd_edelay , 0}, #endif {"capture" , cmd_capture , CMD_WAIT_MUTEX}, + {"refresh" , cmd_refresh , 0}, + {"touch" , cmd_touch , 0}, + {"release" , cmd_release , 0}, + {"vbat" , cmd_vbat , CMD_WAIT_MUTEX}, // Uses same adc as touch!!!!! #ifdef ENABLE_VBAT_OFFSET_COMMAND {"vbat_offset" , cmd_vbat_offset , 0}, diff --git a/nanovna.h b/nanovna.h index 28e3e70..40d6dcf 100644 --- a/nanovna.h +++ b/nanovna.h @@ -98,6 +98,11 @@ typedef float measurement_t[TRACES_MAX][POINTS_COUNT]; extern measurement_t measured; #endif +extern volatile int auto_capture; +extern volatile int mouse_x; +extern volatile int mouse_y; +extern volatile int mouse_down; + #ifdef __VNA__ // Minimum frequency set #define START_MIN 50000 @@ -167,6 +172,8 @@ uint32_t get_sweep_frequency(int type); void my_microsecond_delay(int t); float my_atof(const char *p); int shell_printf(const char *fmt, ...); +void send_region(const char *t, int x, int y, int w, int h); +void send_buffer(uint8_t * buf, int s); void set_marker_frequency(int m, uint32_t f); void toggle_sweep(void); @@ -307,6 +314,8 @@ void set_measurement(int); //extern int setting.step_delay; void sweep_remote(void); extern void set_modulo(uint32_t f); +extern int generic_option_cmd( const char *cmd, const char *cmd_list, int argc, char *argv); + #ifdef __AUDIO__ /* * dsp.c diff --git a/sa_core.c b/sa_core.c index 653b6b6..e8aa7ff 100644 --- a/sa_core.c +++ b/sa_core.c @@ -1762,31 +1762,24 @@ search_maximum(int m, uint32_t center, int span) //static const unsigned int spur_alternate_IF = DEFAULT_SPUR_IF; // if the frequency is found in the spur table use this IF frequency static const uint32_t spur_table[] = // Frequencies to avoid { - 117716000, - 243775000, +// 117716000, + 243775000, // OK // 244250000, - 325000000, + 325000000, // Not OK // 325190000, - 487541650, // This is linked to the MODULO of the ADF4350 + 487541650, // OK This is linked to the MODULO of the ADF4350 // 487993000, // 488020700, // 487551700, // 487578000, // 488500000, - 650700000, + 650687000, // OK // 651333333, - 732750000, - 746083000 - /* - * 144.3 - * 159 - * 209.8 30MHz - * 239.8 - * 269.9 30MHz? - */ - - // 1956000000, -#if 0 + 731780000, // OK +// 746083000 + + + #if 0 // 580000, // 433.8 MHz table // 880000, //? 960000, diff --git a/ui.c b/ui.c index 1c41b48..3a879b4 100644 --- a/ui.c +++ b/ui.c @@ -312,6 +312,14 @@ touch_check(void) last_touch_x = x; last_touch_y = y; } + mouse_down = false; + } + if (!stat) { + stat = mouse_down; + if (mouse_down) { + last_touch_x = mouse_x; + last_touch_y = mouse_y; + } } #if 0 // Long press detection systime_t ticks = chVTGetSystemTimeX(); @@ -420,12 +428,15 @@ touch_draw_test(void) do { if (touch_check() == EVT_TOUCH_PRESSED){ touch_position(&x0, &y0); + ili9341_line(x0, y0, x0, y0); do { chThdSleepMilliseconds(50); touch_position(&x1, &y1); - ili9341_line(x0, y0, x1, y1); - x0 = x1; - y0 = y1; + if (x0!= x1 || y0 != y1) { + ili9341_line(x0, y0, x1, y1); + x0 = x1; + y0 = y1; + } } while (touch_check() != EVT_TOUCH_RELEASED); } }while (!(btn_check() & EVT_BUTTON_SINGLE_CLICK)); @@ -436,8 +447,8 @@ touch_draw_test(void) void touch_position(int *x, int *y) { - *x = (last_touch_x - config.touch_cal[0]) * 16 / config.touch_cal[2]; - *y = (last_touch_y - config.touch_cal[1]) * 16 / config.touch_cal[3]; + *x = (mouse_down ? mouse_x : (last_touch_x - config.touch_cal[0]) * 16 / config.touch_cal[2]); + *y = (mouse_down ? mouse_y : (last_touch_y - config.touch_cal[1]) * 16 / config.touch_cal[3]); } @@ -2862,6 +2873,9 @@ void ui_process_touch(void) } static int previous_button_state = 0; +static int previous_mouse_state = 0; +static int previous_mouse_x = 0; +static int previous_mouse_y = 0; void ui_process(void) @@ -2874,10 +2888,12 @@ ui_process(void) if (operation_requested&OP_LEVER || previous_button_state != button_state) { ui_process_lever(); previous_button_state = button_state; - } - if (operation_requested&OP_TOUCH) + operation_requested = OP_NONE; + } else if (operation_requested&OP_TOUCH || previous_mouse_state != mouse_down || previous_mouse_x != mouse_x || previous_mouse_y != mouse_y) { ui_process_touch(); - operation_requested = OP_NONE; + previous_mouse_state = mouse_down; + operation_requested = OP_NONE; + } } /* Triggered when the button is pressed or released. The LED4 is set to ON.*/ diff --git a/ui_sa.c b/ui_sa.c index 7147f19..1453f2e 100644 --- a/ui_sa.c +++ b/ui_sa.c @@ -971,10 +971,10 @@ static UI_FUNCTION_ADV_CALLBACK(menu_measure_acb) kp_help_text = "Modulation frequency, 3 .. 10 kHz"; ui_mode_keypad(KM_SPAN); ui_process_keypad(); - if (uistat.value < 3000) - break; +// if (uistat.value < 3000) +// break; span = uistat.value; - set_sweep_frequency(ST_SPAN, 50000); // 100kHz + set_sweep_frequency(ST_SPAN, span * 10); // update_frequencies(); // To ensure markers are positioned right!!!!!! set_measurement(M_AM); set_marker_frequency(0, center); @@ -1402,6 +1402,22 @@ static UI_FUNCTION_ADV_CALLBACK(menu_pause_acb) // draw_cal_status(); } +static UI_FUNCTION_ADV_CALLBACK(menu_send_display_acb) +{ + (void) data; + (void) item; + if (b){ + b->icon = auto_capture ? BUTTON_ICON_CHECK : BUTTON_ICON_NOCHECK; + return; + } + auto_capture = ! auto_capture; +// menu_move_back(); +// ui_mode_normal(); + draw_menu(); +// draw_cal_status(); +} + + static UI_FUNCTION_ADV_CALLBACK(menu_outputmode_acb) { (void) data; @@ -1991,6 +2007,7 @@ static const menuitem_t menu_display[] = { { MT_ADV_CALLBACK,3, "NORMALIZE", menu_storage_acb}, { MT_ADV_CALLBACK,4, "WATER\nFALL", menu_waterfall_acb}, { MT_SUBMENU, 0, "SWEEP\nSETTINGS", menu_sweep_speed}, + { MT_ADV_CALLBACK,0, "SEND\nDISPLAY", menu_send_display_acb}, // { MT_KEYPAD, KM_SWEEP_TIME, "SWEEP\nTIME", NULL}, { MT_CANCEL, 0, S_LARROW" BACK", NULL },