2016-11-18 11:26:53 +01:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2014-2015, TAKAHASHI Tomohiro (TTRFTECH) edy555@gmail.com
|
|
|
|
|
* All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* This is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 3, or (at your option)
|
|
|
|
|
* any later version.
|
|
|
|
|
*
|
|
|
|
|
* The software is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with GNU Radio; see the file COPYING. If not, write to
|
|
|
|
|
* the Free Software Foundation, Inc., 51 Franklin Street,
|
|
|
|
|
* Boston, MA 02110-1301, USA.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "ch.h"
|
|
|
|
|
#include "hal.h"
|
2019-10-06 00:56:25 +02:00
|
|
|
#include "chprintf.h"
|
2016-11-18 11:26:53 +01:00
|
|
|
#include "nanovna.h"
|
Big code redisign (increase CELL draw size, more faster screen render), also save about 4-5kB flash size
Try remove all hardcoded values from code (use definition if set)
Some error fix
main.c:
Rewrite Shell, now it run on main thread and require less RAM (not need stack)
(possible run it as thread if define VNA_SHELL_THREAD
Remove not used trace_info[].scale_unit in set_trace_scale/get_trace_scale (it just divede on set and multiple on get, better use it for default scale set)
Replace some hardcoded values
MARKERS_MAX
SAVEAREA_MAX
TRACES_MAX
plot.c
Rewrite CELLWIDTH and CELLHEIGHT use, now possible set any CELL width and height (CELLWIDTH * CELLHEIGHT <= spi_buffer size)
Free RAM from shell stack use fore increase spi_buffer size now it have 2048 pixel (64x32)
Rewrite cell index and markmap use (now correct use cell size, and more faster), correct use CELLWIDTH and CELLHEIGHT in calculation
Fore set update area use invalidateRect (still need use some hardcoded values :( )
Rewrite cell_draw_line
Rewrite many hardcoded size definitions
Refrence point now draw as bitmap (less size, more costumable)
Fix drag marker (now correct search closest index in search_nearest_index)
Rewrite plot_into_index, now correct use size definitions, moe
ui.c
Small rewrite keyboard definitions, for use less flash size
Define KP_WIDTH, KP_HEIGHT for set key size
Better look some big font symvols
All:
use static fore some local functions (use less space on calls)
replace tabs on spaces (code style)
Use M_PI from math.h fore define pi value
Fix printf on print HEX values
2020-02-22 08:50:54 +01:00
|
|
|
//#include <stdlib.h>
|
2017-01-02 08:59:10 +01:00
|
|
|
#include <string.h>
|
2016-11-18 11:26:53 +01:00
|
|
|
|
2017-09-30 16:06:21 +02:00
|
|
|
uistat_t uistat = {
|
|
|
|
|
digit: 6,
|
2019-11-17 02:54:39 +01:00
|
|
|
current_trace: 0,
|
2019-11-29 13:53:07 +01:00
|
|
|
lever_mode: LM_MARKER,
|
2019-11-30 02:17:14 +01:00
|
|
|
marker_delta: FALSE,
|
2020-03-05 20:36:44 +01:00
|
|
|
marker_tracking : FALSE,
|
2017-09-30 16:06:21 +02:00
|
|
|
};
|
2016-11-18 11:26:53 +01:00
|
|
|
|
2020-03-21 00:03:09 +01:00
|
|
|
#define NO_EVENT 0
|
|
|
|
|
#define EVT_BUTTON_SINGLE_CLICK 0x01
|
|
|
|
|
#define EVT_BUTTON_DOUBLE_CLICK 0x02
|
|
|
|
|
#define EVT_BUTTON_DOWN_LONG 0x04
|
|
|
|
|
#define EVT_UP 0x10
|
|
|
|
|
#define EVT_DOWN 0x20
|
|
|
|
|
#define EVT_REPEAT 0x40
|
|
|
|
|
|
2020-06-20 11:07:38 +02:00
|
|
|
#define BUTTON_DOWN_LONG_TICKS 5000 /* 500ms */
|
|
|
|
|
#define BUTTON_DOUBLE_TICKS 2500 /* 250ms */
|
2020-07-17 16:36:14 +02:00
|
|
|
#define BUTTON_REPEAT_TICKS 100 /* 10ms */
|
|
|
|
|
#define BUTTON_DEBOUNCE_TICKS 400 /* 40ms */
|
2016-11-18 11:26:53 +01:00
|
|
|
|
|
|
|
|
/* lever switch assignment */
|
2020-03-21 00:03:09 +01:00
|
|
|
#define BIT_UP1 3
|
|
|
|
|
#define BIT_PUSH 2
|
|
|
|
|
#define BIT_DOWN1 1
|
2016-11-18 11:26:53 +01:00
|
|
|
|
|
|
|
|
#define READ_PORT() palReadPort(GPIOA)
|
|
|
|
|
#define BUTTON_MASK 0b1111
|
|
|
|
|
|
|
|
|
|
static uint16_t last_button = 0b0000;
|
2020-03-22 17:18:40 +01:00
|
|
|
static systime_t last_button_down_ticks;
|
|
|
|
|
static systime_t last_button_repeat_ticks;
|
2016-12-17 10:32:27 +01:00
|
|
|
|
2020-03-05 20:36:44 +01:00
|
|
|
volatile uint8_t operation_requested = OP_NONE;
|
2016-11-18 11:26:53 +01:00
|
|
|
|
2019-08-18 01:18:52 +02:00
|
|
|
int8_t previous_marker = -1;
|
2017-09-15 17:48:34 +02:00
|
|
|
|
2020-07-01 11:29:25 +02:00
|
|
|
#ifdef __USE_SD_CARD__
|
|
|
|
|
#if SPI_BUFFER_SIZE < 2048
|
|
|
|
|
#error "SPI_BUFFER_SIZE for SD card support need size = 2048"
|
|
|
|
|
#else
|
|
|
|
|
// Fat file system work area (at the end of spi_buffer)
|
|
|
|
|
static FATFS *fs_volume = (FATFS *)(((uint8_t*)(&spi_buffer[SPI_BUFFER_SIZE])) - sizeof(FATFS));
|
|
|
|
|
// FatFS file object (at the end of spi_buffer)
|
|
|
|
|
static FIL *fs_file = ( FIL*)(((uint8_t*)(&spi_buffer[SPI_BUFFER_SIZE])) - sizeof(FATFS) - sizeof(FIL));
|
|
|
|
|
// Filename object (at the end of spi_buffer)
|
|
|
|
|
static char *fs_filename = ( char*)(((uint8_t*)(&spi_buffer[SPI_BUFFER_SIZE])) - sizeof(FATFS) - sizeof(FIL) - FF_LFN_BUF - 4);
|
|
|
|
|
#endif
|
|
|
|
|
#endif
|
|
|
|
|
|
2016-12-04 08:19:31 +01:00
|
|
|
enum {
|
2017-09-30 16:06:21 +02:00
|
|
|
UI_NORMAL, UI_MENU, UI_NUMERIC, UI_KEYPAD
|
2016-12-04 08:19:31 +01:00
|
|
|
};
|
|
|
|
|
|
2020-07-09 10:59:33 +02:00
|
|
|
// Keypad structures
|
|
|
|
|
// Enum for keypads_list
|
2016-12-04 08:19:31 +01:00
|
|
|
enum {
|
2020-07-05 11:33:40 +02:00
|
|
|
KM_START, KM_STOP, KM_CENTER, KM_SPAN, KM_CW, KM_SCALE, KM_REFPOS, KM_EDELAY, KM_VELOCITY_FACTOR, KM_SCALEDELAY, KM_NONE
|
2016-12-04 08:19:31 +01:00
|
|
|
};
|
|
|
|
|
|
2020-07-09 10:59:33 +02:00
|
|
|
typedef struct {
|
|
|
|
|
uint8_t x:4;
|
|
|
|
|
uint8_t y:4;
|
|
|
|
|
uint8_t c;
|
|
|
|
|
} keypads_t;
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
|
const keypads_t *keypad_type;
|
|
|
|
|
const char *name;
|
|
|
|
|
} keypads_list;
|
|
|
|
|
// Max keyboard input length
|
2020-03-05 20:36:44 +01:00
|
|
|
#define NUMINPUT_LEN 10
|
|
|
|
|
|
2020-01-26 18:56:45 +01:00
|
|
|
static uint8_t ui_mode = UI_NORMAL;
|
2020-07-05 11:33:40 +02:00
|
|
|
static const keypads_t *keypads;
|
2020-01-26 18:56:45 +01:00
|
|
|
static uint8_t keypad_mode;
|
2020-03-05 20:36:44 +01:00
|
|
|
static uint8_t keypads_last_index;
|
|
|
|
|
static char kp_buf[NUMINPUT_LEN+1];
|
|
|
|
|
static int8_t kp_index = 0;
|
|
|
|
|
static uint8_t menu_current_level = 0;
|
2020-01-26 18:56:45 +01:00
|
|
|
static int8_t selection = 0;
|
2016-12-04 08:19:31 +01:00
|
|
|
|
2020-07-05 11:33:40 +02:00
|
|
|
// UI menu structure
|
|
|
|
|
// Type of menu item:
|
|
|
|
|
#define MT_NONE 0x00
|
|
|
|
|
#define MT_BLANK 0x01
|
|
|
|
|
#define MT_SUBMENU 0x02
|
|
|
|
|
#define MT_CALLBACK 0x03
|
|
|
|
|
#define MT_CANCEL 0x04
|
|
|
|
|
#define MT_CLOSE 0x05
|
2020-07-13 23:15:46 +02:00
|
|
|
#define MT_ADV_CALLBACK 0x06
|
|
|
|
|
|
2020-07-14 20:30:27 +02:00
|
|
|
// Button definition (used in MT_ADV_CALLBACK for custom)
|
2020-07-13 23:15:46 +02:00
|
|
|
#define BUTTON_ICON_NONE -1
|
|
|
|
|
#define BUTTON_ICON_NOCHECK 0
|
|
|
|
|
#define BUTTON_ICON_CHECK 1
|
|
|
|
|
#define BUTTON_ICON_GROUP 2
|
|
|
|
|
#define BUTTON_ICON_GROUP_CHECKED 3
|
|
|
|
|
|
2020-07-14 11:21:44 +02:00
|
|
|
#define BUTTON_BORDER_NONE 0x00
|
2020-07-15 13:34:50 +02:00
|
|
|
#define BUTTON_BORDER_WIDTH_MASK 0x0F
|
2020-07-14 11:21:44 +02:00
|
|
|
|
2020-07-15 13:34:50 +02:00
|
|
|
// Define mask for draw border (if 1 use light color, if 0 dark)
|
|
|
|
|
#define BUTTON_BORDER_TYPE_MASK 0xF0
|
|
|
|
|
#define BUTTON_BORDER_TOP 0x10
|
|
|
|
|
#define BUTTON_BORDER_BOTTOM 0x20
|
|
|
|
|
#define BUTTON_BORDER_LEFT 0x40
|
|
|
|
|
#define BUTTON_BORDER_RIGHT 0x80
|
|
|
|
|
|
|
|
|
|
#define BUTTON_BORDER_FLAT 0x00
|
|
|
|
|
#define BUTTON_BORDER_RISE (BUTTON_BORDER_TOP|BUTTON_BORDER_RIGHT)
|
|
|
|
|
#define BUTTON_BORDER_FALLING (BUTTON_BORDER_BOTTOM|BUTTON_BORDER_LEFT)
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
2020-07-13 23:15:46 +02:00
|
|
|
uint16_t bg;
|
|
|
|
|
uint16_t fg;
|
|
|
|
|
uint8_t border;
|
|
|
|
|
int8_t icon;
|
|
|
|
|
} button_t;
|
2020-07-05 11:33:40 +02:00
|
|
|
|
|
|
|
|
// Call back functions for MT_CALLBACK type
|
|
|
|
|
typedef void (*menuaction_cb_t)(int item, uint16_t data);
|
|
|
|
|
#define UI_FUNCTION_CALLBACK(ui_function_name) void ui_function_name(int item, uint16_t data)
|
|
|
|
|
|
2020-07-13 23:15:46 +02:00
|
|
|
typedef void (*menuaction_acb_t)(int item, uint16_t data, button_t *b);
|
|
|
|
|
#define UI_FUNCTION_ADV_CALLBACK(ui_function_name) void ui_function_name(int item, uint16_t data, button_t *b)
|
2020-07-05 11:33:40 +02:00
|
|
|
|
2020-01-25 13:46:09 +01:00
|
|
|
// Set structure align as WORD (save flash memory)
|
|
|
|
|
#pragma pack(push, 2)
|
2016-12-06 19:34:33 +01:00
|
|
|
typedef struct {
|
|
|
|
|
uint8_t type;
|
2020-01-25 13:46:09 +01:00
|
|
|
uint8_t data;
|
2016-12-06 19:34:33 +01:00
|
|
|
char *label;
|
|
|
|
|
const void *reference;
|
|
|
|
|
} menuitem_t;
|
2020-01-25 13:46:09 +01:00
|
|
|
#pragma pack(pop)
|
2016-12-06 19:34:33 +01:00
|
|
|
|
2020-01-26 18:56:45 +01:00
|
|
|
// Touch screen
|
2020-02-26 21:30:50 +01:00
|
|
|
#define EVT_TOUCH_NONE 0
|
|
|
|
|
#define EVT_TOUCH_DOWN 1
|
|
|
|
|
#define EVT_TOUCH_PRESSED 2
|
|
|
|
|
#define EVT_TOUCH_RELEASED 3
|
|
|
|
|
|
|
|
|
|
static int8_t last_touch_status = EVT_TOUCH_NONE;
|
2020-01-26 18:56:45 +01:00
|
|
|
static int16_t last_touch_x;
|
|
|
|
|
static int16_t last_touch_y;
|
|
|
|
|
|
2017-01-01 12:03:21 +01:00
|
|
|
#define KP_CONTINUE 0
|
|
|
|
|
#define KP_DONE 1
|
|
|
|
|
#define KP_CANCEL 2
|
|
|
|
|
|
Big code redisign (increase CELL draw size, more faster screen render), also save about 4-5kB flash size
Try remove all hardcoded values from code (use definition if set)
Some error fix
main.c:
Rewrite Shell, now it run on main thread and require less RAM (not need stack)
(possible run it as thread if define VNA_SHELL_THREAD
Remove not used trace_info[].scale_unit in set_trace_scale/get_trace_scale (it just divede on set and multiple on get, better use it for default scale set)
Replace some hardcoded values
MARKERS_MAX
SAVEAREA_MAX
TRACES_MAX
plot.c
Rewrite CELLWIDTH and CELLHEIGHT use, now possible set any CELL width and height (CELLWIDTH * CELLHEIGHT <= spi_buffer size)
Free RAM from shell stack use fore increase spi_buffer size now it have 2048 pixel (64x32)
Rewrite cell index and markmap use (now correct use cell size, and more faster), correct use CELLWIDTH and CELLHEIGHT in calculation
Fore set update area use invalidateRect (still need use some hardcoded values :( )
Rewrite cell_draw_line
Rewrite many hardcoded size definitions
Refrence point now draw as bitmap (less size, more costumable)
Fix drag marker (now correct search closest index in search_nearest_index)
Rewrite plot_into_index, now correct use size definitions, moe
ui.c
Small rewrite keyboard definitions, for use less flash size
Define KP_WIDTH, KP_HEIGHT for set key size
Better look some big font symvols
All:
use static fore some local functions (use less space on calls)
replace tabs on spaces (code style)
Use M_PI from math.h fore define pi value
Fix printf on print HEX values
2020-02-22 08:50:54 +01:00
|
|
|
static void ui_mode_normal(void);
|
|
|
|
|
static void ui_mode_menu(void);
|
|
|
|
|
static void ui_mode_numeric(int _keypad_mode);
|
|
|
|
|
static void ui_mode_keypad(int _keypad_mode);
|
|
|
|
|
static void draw_menu(void);
|
|
|
|
|
static void leave_ui_mode(void);
|
|
|
|
|
static void erase_menu_buttons(void);
|
|
|
|
|
static void ui_process_keypad(void);
|
2019-08-27 10:46:26 +02:00
|
|
|
static void ui_process_numeric(void);
|
2020-07-13 05:56:49 +02:00
|
|
|
static void touch_position(int *x, int *y);
|
2020-07-05 11:33:40 +02:00
|
|
|
static void menu_move_back(bool leave_ui);
|
2016-12-06 19:34:33 +01:00
|
|
|
static void menu_push_submenu(const menuitem_t *submenu);
|
|
|
|
|
|
2016-11-18 11:26:53 +01:00
|
|
|
static int btn_check(void)
|
|
|
|
|
{
|
2020-03-22 17:18:40 +01:00
|
|
|
systime_t ticks;
|
|
|
|
|
// Debounce input
|
|
|
|
|
while(TRUE){
|
|
|
|
|
ticks = chVTGetSystemTimeX();
|
|
|
|
|
if(ticks - last_button_down_ticks > BUTTON_DEBOUNCE_TICKS)
|
|
|
|
|
break;
|
|
|
|
|
chThdSleepMilliseconds(10);
|
|
|
|
|
}
|
|
|
|
|
int status = 0;
|
|
|
|
|
uint16_t cur_button = READ_PORT() & BUTTON_MASK;
|
|
|
|
|
// Detect only changed and pressed buttons
|
|
|
|
|
uint16_t button_set = (last_button ^ cur_button) & cur_button;
|
|
|
|
|
last_button_down_ticks = ticks;
|
|
|
|
|
last_button = cur_button;
|
|
|
|
|
|
|
|
|
|
if (button_set & (1<<BIT_PUSH))
|
|
|
|
|
status |= EVT_BUTTON_SINGLE_CLICK;
|
|
|
|
|
if (button_set & (1<<BIT_UP1))
|
|
|
|
|
status |= EVT_UP;
|
|
|
|
|
if (button_set & (1<<BIT_DOWN1))
|
|
|
|
|
status |= EVT_DOWN;
|
|
|
|
|
return status;
|
2016-11-18 11:26:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int btn_wait_release(void)
|
|
|
|
|
{
|
|
|
|
|
while (TRUE) {
|
2020-03-22 17:18:40 +01:00
|
|
|
systime_t ticks = chVTGetSystemTimeX();
|
|
|
|
|
systime_t dt = ticks - last_button_down_ticks;
|
|
|
|
|
// Debounce input
|
2020-06-20 11:07:38 +02:00
|
|
|
// if (dt < BUTTON_DEBOUNCE_TICKS){
|
|
|
|
|
// chThdSleepMilliseconds(10);
|
|
|
|
|
// continue;
|
|
|
|
|
// }
|
|
|
|
|
chThdSleepMilliseconds(1);
|
2020-03-22 17:18:40 +01:00
|
|
|
uint16_t cur_button = READ_PORT() & BUTTON_MASK;
|
|
|
|
|
uint16_t changed = last_button ^ cur_button;
|
|
|
|
|
if (dt >= BUTTON_DOWN_LONG_TICKS && (cur_button & (1<<BIT_PUSH)))
|
|
|
|
|
return EVT_BUTTON_DOWN_LONG;
|
|
|
|
|
else if (changed & (1<<BIT_PUSH)) // release
|
|
|
|
|
return EVT_BUTTON_SINGLE_CLICK;
|
2017-09-30 16:06:21 +02:00
|
|
|
|
2016-11-18 11:26:53 +01:00
|
|
|
if (changed) {
|
|
|
|
|
// finished
|
|
|
|
|
last_button = cur_button;
|
2017-02-02 23:28:20 +01:00
|
|
|
last_button_down_ticks = ticks;
|
2016-11-18 11:26:53 +01:00
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-22 17:18:40 +01:00
|
|
|
if (dt > BUTTON_DOWN_LONG_TICKS &&
|
|
|
|
|
ticks > last_button_repeat_ticks) {
|
|
|
|
|
int status = 0;
|
2020-03-05 20:36:44 +01:00
|
|
|
if (cur_button & (1<<BIT_DOWN1))
|
2016-11-18 11:26:53 +01:00
|
|
|
status |= EVT_DOWN | EVT_REPEAT;
|
2020-03-05 20:36:44 +01:00
|
|
|
if (cur_button & (1<<BIT_UP1))
|
2016-11-18 11:26:53 +01:00
|
|
|
status |= EVT_UP | EVT_REPEAT;
|
2020-03-22 17:18:40 +01:00
|
|
|
last_button_repeat_ticks = ticks + BUTTON_REPEAT_TICKS;
|
2016-11-18 11:26:53 +01:00
|
|
|
return status;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-07-05 11:33:40 +02:00
|
|
|
#if 0
|
|
|
|
|
#define SWAP_16(x,y) {uint16_t t = x;x=y;y=t;}
|
|
|
|
|
static void bubbleSort(uint16_t *v, int n) {
|
|
|
|
|
bool swapped = true;
|
|
|
|
|
int i = 0, j;
|
|
|
|
|
while (i < n - 1 && swapped) { // keep going while we swap in the unordered part
|
|
|
|
|
swapped = false;
|
|
|
|
|
for (j = n - 1; j > i; j--) { // unordered part
|
|
|
|
|
if (v[j] < v[j - 1]) {
|
|
|
|
|
SWAP_16(v[j], v[j - 1]);
|
|
|
|
|
swapped = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
i++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|
2016-11-18 11:26:53 +01:00
|
|
|
|
2020-07-05 11:33:40 +02:00
|
|
|
// ADC read count for measure X and Y (2^N count)
|
|
|
|
|
#define TOUCH_X_N 3
|
|
|
|
|
#define TOUCH_Y_N 3
|
Big code redisign (increase CELL draw size, more faster screen render), also save about 4-5kB flash size
Try remove all hardcoded values from code (use definition if set)
Some error fix
main.c:
Rewrite Shell, now it run on main thread and require less RAM (not need stack)
(possible run it as thread if define VNA_SHELL_THREAD
Remove not used trace_info[].scale_unit in set_trace_scale/get_trace_scale (it just divede on set and multiple on get, better use it for default scale set)
Replace some hardcoded values
MARKERS_MAX
SAVEAREA_MAX
TRACES_MAX
plot.c
Rewrite CELLWIDTH and CELLHEIGHT use, now possible set any CELL width and height (CELLWIDTH * CELLHEIGHT <= spi_buffer size)
Free RAM from shell stack use fore increase spi_buffer size now it have 2048 pixel (64x32)
Rewrite cell index and markmap use (now correct use cell size, and more faster), correct use CELLWIDTH and CELLHEIGHT in calculation
Fore set update area use invalidateRect (still need use some hardcoded values :( )
Rewrite cell_draw_line
Rewrite many hardcoded size definitions
Refrence point now draw as bitmap (less size, more costumable)
Fix drag marker (now correct search closest index in search_nearest_index)
Rewrite plot_into_index, now correct use size definitions, moe
ui.c
Small rewrite keyboard definitions, for use less flash size
Define KP_WIDTH, KP_HEIGHT for set key size
Better look some big font symvols
All:
use static fore some local functions (use less space on calls)
replace tabs on spaces (code style)
Use M_PI from math.h fore define pi value
Fix printf on print HEX values
2020-02-22 08:50:54 +01:00
|
|
|
static int
|
2016-12-17 10:32:27 +01:00
|
|
|
touch_measure_y(void)
|
|
|
|
|
{
|
2020-07-05 11:33:40 +02:00
|
|
|
// drive low to high on X line (At this state after touch_prepare_sense)
|
|
|
|
|
// palSetPadMode(GPIOB, GPIOB_XN, PAL_MODE_OUTPUT_PUSHPULL); //
|
|
|
|
|
// palSetPadMode(GPIOA, GPIOA_XP, PAL_MODE_OUTPUT_PUSHPULL); //
|
|
|
|
|
// drive low to high on X line (coordinates from top to bottom)
|
|
|
|
|
palClearPad(GPIOB, GPIOB_XN);
|
|
|
|
|
// palSetPad(GPIOA, GPIOA_XP);
|
2016-12-17 10:32:27 +01:00
|
|
|
|
2020-07-05 11:33:40 +02:00
|
|
|
// open Y line (At this state after touch_prepare_sense)
|
|
|
|
|
// palSetPadMode(GPIOB, GPIOB_YN, PAL_MODE_INPUT); // Hi-z mode
|
|
|
|
|
palSetPadMode(GPIOA, GPIOA_YP, PAL_MODE_INPUT_ANALOG); // <- ADC_TOUCH_Y channel
|
|
|
|
|
|
|
|
|
|
// chThdSleepMilliseconds(20);
|
|
|
|
|
uint32_t v = 0, cnt = 1<<TOUCH_Y_N;
|
|
|
|
|
do{v+=adc_single_read(ADC_TOUCH_Y);}while(--cnt);
|
|
|
|
|
return v>>TOUCH_Y_N;
|
2016-12-17 10:32:27 +01:00
|
|
|
}
|
|
|
|
|
|
Big code redisign (increase CELL draw size, more faster screen render), also save about 4-5kB flash size
Try remove all hardcoded values from code (use definition if set)
Some error fix
main.c:
Rewrite Shell, now it run on main thread and require less RAM (not need stack)
(possible run it as thread if define VNA_SHELL_THREAD
Remove not used trace_info[].scale_unit in set_trace_scale/get_trace_scale (it just divede on set and multiple on get, better use it for default scale set)
Replace some hardcoded values
MARKERS_MAX
SAVEAREA_MAX
TRACES_MAX
plot.c
Rewrite CELLWIDTH and CELLHEIGHT use, now possible set any CELL width and height (CELLWIDTH * CELLHEIGHT <= spi_buffer size)
Free RAM from shell stack use fore increase spi_buffer size now it have 2048 pixel (64x32)
Rewrite cell index and markmap use (now correct use cell size, and more faster), correct use CELLWIDTH and CELLHEIGHT in calculation
Fore set update area use invalidateRect (still need use some hardcoded values :( )
Rewrite cell_draw_line
Rewrite many hardcoded size definitions
Refrence point now draw as bitmap (less size, more costumable)
Fix drag marker (now correct search closest index in search_nearest_index)
Rewrite plot_into_index, now correct use size definitions, moe
ui.c
Small rewrite keyboard definitions, for use less flash size
Define KP_WIDTH, KP_HEIGHT for set key size
Better look some big font symvols
All:
use static fore some local functions (use less space on calls)
replace tabs on spaces (code style)
Use M_PI from math.h fore define pi value
Fix printf on print HEX values
2020-02-22 08:50:54 +01:00
|
|
|
static int
|
2016-12-17 10:32:27 +01:00
|
|
|
touch_measure_x(void)
|
|
|
|
|
{
|
2020-07-05 11:33:40 +02:00
|
|
|
// drive high to low on Y line (coordinates from left to right)
|
|
|
|
|
palSetPad(GPIOB, GPIOB_YN);
|
|
|
|
|
palClearPad(GPIOA, GPIOA_YP);
|
|
|
|
|
// Set Y line as output
|
|
|
|
|
palSetPadMode(GPIOB, GPIOB_YN, PAL_MODE_OUTPUT_PUSHPULL);
|
|
|
|
|
palSetPadMode(GPIOA, GPIOA_YP, PAL_MODE_OUTPUT_PUSHPULL);
|
|
|
|
|
// Set X line as input
|
|
|
|
|
palSetPadMode(GPIOB, GPIOB_XN, PAL_MODE_INPUT); // Hi-z mode
|
|
|
|
|
palSetPadMode(GPIOA, GPIOA_XP, PAL_MODE_INPUT_ANALOG); // <- ADC_TOUCH_X channel
|
2016-12-17 10:32:27 +01:00
|
|
|
|
2020-07-05 11:33:40 +02:00
|
|
|
uint32_t v = 0, cnt = 1<<TOUCH_X_N;
|
|
|
|
|
do{v+=adc_single_read(ADC_TOUCH_X);}while(--cnt);
|
|
|
|
|
return v>>TOUCH_X_N;
|
2016-12-17 10:32:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
touch_prepare_sense(void)
|
|
|
|
|
{
|
2020-07-05 11:33:40 +02:00
|
|
|
// Set Y line as input
|
|
|
|
|
palSetPadMode(GPIOB, GPIOB_YN, PAL_MODE_INPUT); // Hi-z mode
|
|
|
|
|
palSetPadMode(GPIOA, GPIOA_YP, PAL_MODE_INPUT_PULLDOWN); // Use pull
|
|
|
|
|
// drive high on X line (for touch sense on Y)
|
|
|
|
|
palSetPad(GPIOB, GPIOB_XN);
|
|
|
|
|
palSetPad(GPIOA, GPIOA_XP);
|
2016-12-17 10:32:27 +01:00
|
|
|
// force high X line
|
2020-07-05 11:33:40 +02:00
|
|
|
palSetPadMode(GPIOB, GPIOB_XN, PAL_MODE_OUTPUT_PUSHPULL);
|
|
|
|
|
palSetPadMode(GPIOA, GPIOA_XP, PAL_MODE_OUTPUT_PUSHPULL);
|
|
|
|
|
|
|
|
|
|
// chThdSleepMilliseconds(10); // Wait 10ms for denounce touch
|
2016-12-17 10:32:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
touch_start_watchdog(void)
|
|
|
|
|
{
|
|
|
|
|
touch_prepare_sense();
|
2020-05-17 22:47:15 +02:00
|
|
|
adc_start_analog_watchdogd(ADC_TOUCH_Y);
|
2016-12-17 10:32:27 +01:00
|
|
|
}
|
|
|
|
|
|
2020-07-05 11:33:40 +02:00
|
|
|
static inline int
|
2016-12-17 10:32:27 +01:00
|
|
|
touch_status(void)
|
|
|
|
|
{
|
2020-07-05 11:33:40 +02:00
|
|
|
// touch_prepare_sense();
|
2020-05-17 22:47:15 +02:00
|
|
|
return adc_single_read(ADC_TOUCH_Y) > TOUCH_THRESHOLD;
|
2016-12-17 10:32:27 +01:00
|
|
|
}
|
|
|
|
|
|
Big code redisign (increase CELL draw size, more faster screen render), also save about 4-5kB flash size
Try remove all hardcoded values from code (use definition if set)
Some error fix
main.c:
Rewrite Shell, now it run on main thread and require less RAM (not need stack)
(possible run it as thread if define VNA_SHELL_THREAD
Remove not used trace_info[].scale_unit in set_trace_scale/get_trace_scale (it just divede on set and multiple on get, better use it for default scale set)
Replace some hardcoded values
MARKERS_MAX
SAVEAREA_MAX
TRACES_MAX
plot.c
Rewrite CELLWIDTH and CELLHEIGHT use, now possible set any CELL width and height (CELLWIDTH * CELLHEIGHT <= spi_buffer size)
Free RAM from shell stack use fore increase spi_buffer size now it have 2048 pixel (64x32)
Rewrite cell index and markmap use (now correct use cell size, and more faster), correct use CELLWIDTH and CELLHEIGHT in calculation
Fore set update area use invalidateRect (still need use some hardcoded values :( )
Rewrite cell_draw_line
Rewrite many hardcoded size definitions
Refrence point now draw as bitmap (less size, more costumable)
Fix drag marker (now correct search closest index in search_nearest_index)
Rewrite plot_into_index, now correct use size definitions, moe
ui.c
Small rewrite keyboard definitions, for use less flash size
Define KP_WIDTH, KP_HEIGHT for set key size
Better look some big font symvols
All:
use static fore some local functions (use less space on calls)
replace tabs on spaces (code style)
Use M_PI from math.h fore define pi value
Fix printf on print HEX values
2020-02-22 08:50:54 +01:00
|
|
|
static int
|
|
|
|
|
touch_check(void)
|
2016-12-17 10:32:27 +01:00
|
|
|
{
|
|
|
|
|
int stat = touch_status();
|
|
|
|
|
if (stat) {
|
2017-02-02 21:40:57 +01:00
|
|
|
int y = touch_measure_y();
|
2020-07-05 11:33:40 +02:00
|
|
|
int x = touch_measure_x();
|
|
|
|
|
touch_prepare_sense();
|
|
|
|
|
if (touch_status())
|
|
|
|
|
{
|
2017-02-02 21:40:57 +01:00
|
|
|
last_touch_x = x;
|
|
|
|
|
last_touch_y = y;
|
2019-08-24 02:36:03 +02:00
|
|
|
}
|
2016-12-17 10:32:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (stat != last_touch_status) {
|
|
|
|
|
last_touch_status = stat;
|
2020-02-26 21:30:50 +01:00
|
|
|
return stat ? EVT_TOUCH_PRESSED : EVT_TOUCH_RELEASED;
|
2016-12-17 10:32:27 +01:00
|
|
|
}
|
2020-02-26 21:30:50 +01:00
|
|
|
return stat ? EVT_TOUCH_DOWN : EVT_TOUCH_NONE;
|
2016-12-17 10:32:27 +01:00
|
|
|
}
|
|
|
|
|
|
2020-02-26 21:30:50 +01:00
|
|
|
static inline void
|
2020-03-21 00:03:09 +01:00
|
|
|
touch_wait_release(void)
|
|
|
|
|
{
|
|
|
|
|
while (touch_check() != EVT_TOUCH_RELEASED)
|
|
|
|
|
;
|
2020-02-26 21:30:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline void
|
2020-03-21 00:03:09 +01:00
|
|
|
touch_wait_pressed(void)
|
|
|
|
|
{
|
|
|
|
|
while (touch_check() != EVT_TOUCH_PRESSED)
|
|
|
|
|
;
|
2016-12-17 10:32:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
touch_cal_exec(void)
|
|
|
|
|
{
|
|
|
|
|
int x1, x2, y1, y2;
|
2020-03-21 00:03:09 +01:00
|
|
|
|
2020-03-07 21:37:39 +01:00
|
|
|
adc_stop();
|
2020-03-21 00:03:09 +01:00
|
|
|
ili9341_set_foreground(DEFAULT_FG_COLOR);
|
|
|
|
|
ili9341_set_background(DEFAULT_BG_COLOR);
|
|
|
|
|
ili9341_clear_screen();
|
2020-01-19 09:16:18 +01:00
|
|
|
ili9341_line(0, 0, 0, 32);
|
|
|
|
|
ili9341_line(0, 0, 32, 0);
|
|
|
|
|
ili9341_drawstring("TOUCH UPPER LEFT", 10, 10);
|
2017-02-02 21:40:57 +01:00
|
|
|
|
2020-02-26 21:30:50 +01:00
|
|
|
touch_wait_release();
|
2016-12-17 10:32:27 +01:00
|
|
|
x1 = last_touch_x;
|
|
|
|
|
y1 = last_touch_y;
|
|
|
|
|
|
2020-03-21 00:03:09 +01:00
|
|
|
ili9341_clear_screen();
|
2020-03-30 19:01:51 +02:00
|
|
|
ili9341_line(LCD_WIDTH-1, LCD_HEIGHT-1, LCD_WIDTH-1, LCD_HEIGHT-32);
|
|
|
|
|
ili9341_line(LCD_WIDTH-1, LCD_HEIGHT-1, LCD_WIDTH-32, LCD_HEIGHT-1);
|
2020-03-30 20:45:06 +02:00
|
|
|
ili9341_drawstring("TOUCH LOWER RIGHT", LCD_WIDTH-17*(FONT_WIDTH)-10, LCD_HEIGHT-FONT_GET_HEIGHT-10);
|
2017-02-02 21:40:57 +01:00
|
|
|
|
2020-02-26 21:30:50 +01:00
|
|
|
touch_wait_release();
|
2016-12-17 10:32:27 +01:00
|
|
|
x2 = last_touch_x;
|
|
|
|
|
y2 = last_touch_y;
|
|
|
|
|
|
2017-01-04 10:28:52 +01:00
|
|
|
config.touch_cal[0] = x1;
|
|
|
|
|
config.touch_cal[1] = y1;
|
2020-03-30 19:01:51 +02:00
|
|
|
config.touch_cal[2] = (x2 - x1) * 16 / LCD_WIDTH;
|
|
|
|
|
config.touch_cal[3] = (y2 - y1) * 16 / LCD_HEIGHT;
|
2017-02-02 21:40:57 +01:00
|
|
|
|
2017-02-03 11:54:00 +01:00
|
|
|
//redraw_all();
|
2017-02-02 21:40:57 +01:00
|
|
|
touch_start_watchdog();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
touch_draw_test(void)
|
|
|
|
|
{
|
|
|
|
|
int x0, y0;
|
|
|
|
|
int x1, y1;
|
|
|
|
|
|
2020-03-07 21:37:39 +01:00
|
|
|
adc_stop();
|
2017-02-02 21:40:57 +01:00
|
|
|
|
2020-03-21 00:03:09 +01:00
|
|
|
ili9341_set_foreground(DEFAULT_FG_COLOR);
|
|
|
|
|
ili9341_set_background(DEFAULT_BG_COLOR);
|
|
|
|
|
ili9341_clear_screen();
|
2020-07-05 11:33:40 +02:00
|
|
|
ili9341_drawstring("TOUCH TEST: DRAG PANEL, PRESS BUTTON TO FINISH", OFFSETX, LCD_HEIGHT - FONT_GET_HEIGHT);
|
2017-02-02 21:40:57 +01:00
|
|
|
|
|
|
|
|
do {
|
2020-07-05 11:33:40 +02:00
|
|
|
if (touch_check() == EVT_TOUCH_PRESSED){
|
|
|
|
|
touch_position(&x0, &y0);
|
|
|
|
|
do {
|
|
|
|
|
chThdSleepMilliseconds(50);
|
|
|
|
|
touch_position(&x1, &y1);
|
|
|
|
|
ili9341_line(x0, y0, x1, y1);
|
|
|
|
|
x0 = x1;
|
|
|
|
|
y0 = y1;
|
|
|
|
|
} while (touch_check() != EVT_TOUCH_RELEASED);
|
|
|
|
|
}
|
|
|
|
|
}while (!(btn_check() & EVT_BUTTON_SINGLE_CLICK));
|
2017-02-02 21:40:57 +01:00
|
|
|
touch_start_watchdog();
|
2016-12-17 10:32:27 +01:00
|
|
|
}
|
|
|
|
|
|
2017-02-02 21:40:57 +01:00
|
|
|
|
2020-07-13 05:56:49 +02:00
|
|
|
static void
|
2016-12-17 10:32:27 +01:00
|
|
|
touch_position(int *x, int *y)
|
|
|
|
|
{
|
2017-01-04 10:28:52 +01:00
|
|
|
*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];
|
2016-12-17 10:32:27 +01:00
|
|
|
}
|
|
|
|
|
|
2020-07-13 05:56:49 +02:00
|
|
|
static void
|
2019-09-05 15:14:44 +02:00
|
|
|
show_version(void)
|
|
|
|
|
{
|
2020-06-20 11:07:38 +02:00
|
|
|
int x = 5, y = 5, i = 1;
|
2020-07-14 13:15:28 +02:00
|
|
|
adc_stop();
|
2020-03-21 00:03:09 +01:00
|
|
|
ili9341_set_foreground(DEFAULT_FG_COLOR);
|
|
|
|
|
ili9341_set_background(DEFAULT_BG_COLOR);
|
2020-02-26 21:55:06 +01:00
|
|
|
|
2020-03-21 00:03:09 +01:00
|
|
|
ili9341_clear_screen();
|
2020-06-20 11:07:38 +02:00
|
|
|
uint16_t shift = 0b000100000;
|
|
|
|
|
ili9341_drawstring_size(BOARD_NAME, x , y, 3);
|
|
|
|
|
y+=FONT_GET_HEIGHT*3+3-5;
|
2020-03-21 00:03:09 +01:00
|
|
|
while (info_about[i]) {
|
2020-03-08 06:32:38 +01:00
|
|
|
do {shift>>=1; y+=5;} while (shift&1);
|
2020-06-20 11:07:38 +02:00
|
|
|
ili9341_drawstring(info_about[i++], x, y+=FONT_STR_HEIGHT+3-5);
|
2020-03-08 06:32:38 +01:00
|
|
|
}
|
2020-06-20 11:07:38 +02:00
|
|
|
// Update battery and time
|
|
|
|
|
y+=3*FONT_STR_HEIGHT;
|
|
|
|
|
uint16_t cnt = 0;
|
2019-09-14 06:42:22 +02:00
|
|
|
while (true) {
|
|
|
|
|
if (touch_check() == EVT_TOUCH_PRESSED)
|
|
|
|
|
break;
|
|
|
|
|
if (btn_check() & EVT_BUTTON_SINGLE_CLICK)
|
|
|
|
|
break;
|
2020-06-20 11:07:38 +02:00
|
|
|
chThdSleepMilliseconds(40);
|
|
|
|
|
if ((cnt++)&0x07) continue; // Not update time so fast
|
|
|
|
|
|
|
|
|
|
#ifdef __USE_RTC__
|
|
|
|
|
char buffer[32];
|
|
|
|
|
uint32_t tr = rtc_get_tr_bin(); // TR read first
|
|
|
|
|
uint32_t dr = rtc_get_dr_bin(); // DR read second
|
|
|
|
|
plot_printf(buffer, sizeof(buffer), "Time: 20%02d/%02d/%02d %02d:%02d:%02d",
|
|
|
|
|
RTC_DR_YEAR(dr),
|
|
|
|
|
RTC_DR_MONTH(dr),
|
|
|
|
|
RTC_DR_DAY(dr),
|
|
|
|
|
RTC_TR_HOUR(dr),
|
|
|
|
|
RTC_TR_MIN(dr),
|
|
|
|
|
RTC_TR_SEC(dr));
|
|
|
|
|
ili9341_drawstring(buffer, x, y);
|
|
|
|
|
#endif
|
|
|
|
|
// uint32_t vbat = adc_vbat_read();
|
|
|
|
|
// plot_printf(buffer, sizeof(buffer), "Battery: %d.%03dV", vbat/1000, vbat%1000);
|
|
|
|
|
// ili9341_drawstring(buffer, x, y + FONT_STR_HEIGHT + 2);
|
2019-09-14 06:42:22 +02:00
|
|
|
}
|
2019-09-05 15:14:44 +02:00
|
|
|
|
2020-07-14 13:15:28 +02:00
|
|
|
touch_start_watchdog();
|
2019-09-05 15:14:44 +02:00
|
|
|
}
|
2016-12-17 10:32:27 +01:00
|
|
|
|
2019-09-06 13:46:39 +02:00
|
|
|
void
|
|
|
|
|
enter_dfu(void)
|
|
|
|
|
{
|
2020-03-07 21:37:39 +01:00
|
|
|
adc_stop();
|
2019-09-06 13:46:39 +02:00
|
|
|
|
2020-07-09 19:41:24 +02:00
|
|
|
int x = 5, y = 20;
|
2020-03-21 00:03:09 +01:00
|
|
|
ili9341_set_foreground(DEFAULT_FG_COLOR);
|
|
|
|
|
ili9341_set_background(DEFAULT_BG_COLOR);
|
2019-09-06 14:04:47 +02:00
|
|
|
// leave a last message
|
2020-03-21 00:03:09 +01:00
|
|
|
ili9341_clear_screen();
|
2020-07-09 19:41:24 +02:00
|
|
|
ili9341_drawstring("DFU: Device Firmware Update Mode\n"
|
|
|
|
|
"To exit DFU mode, please reset device yourself.", x, y);
|
2019-09-06 14:04:47 +02:00
|
|
|
// see __early_init in ./NANOVNA_STM32_F072/board.c
|
2019-09-06 13:46:39 +02:00
|
|
|
*((unsigned long *)BOOT_FROM_SYTEM_MEMORY_MAGIC_ADDRESS) = BOOT_FROM_SYTEM_MEMORY_MAGIC;
|
|
|
|
|
NVIC_SystemReset();
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-22 14:41:50 +01:00
|
|
|
static void
|
|
|
|
|
select_lever_mode(int mode)
|
|
|
|
|
{
|
|
|
|
|
if (uistat.lever_mode != mode) {
|
|
|
|
|
uistat.lever_mode = mode;
|
|
|
|
|
redraw_request |= REDRAW_FREQUENCY | REDRAW_MARKER;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-13 23:15:46 +02:00
|
|
|
static UI_FUNCTION_ADV_CALLBACK(menu_calop_acb)
|
2016-11-19 05:11:49 +01:00
|
|
|
{
|
2020-07-13 23:15:46 +02:00
|
|
|
if (b){
|
|
|
|
|
if ((data == CAL_OPEN && (cal_status & CALSTAT_OPEN))
|
|
|
|
|
|| (data == CAL_SHORT && (cal_status & CALSTAT_SHORT))
|
|
|
|
|
|| (data == CAL_LOAD && (cal_status & CALSTAT_LOAD))
|
|
|
|
|
|| (data == CAL_ISOLN && (cal_status & CALSTAT_ISOLN))
|
|
|
|
|
|| (data == CAL_THRU && (cal_status & CALSTAT_THRU)))
|
|
|
|
|
b->icon = BUTTON_ICON_CHECK;
|
|
|
|
|
return;
|
|
|
|
|
}
|
2020-01-25 13:46:09 +01:00
|
|
|
cal_collect(data);
|
2017-02-02 23:28:20 +01:00
|
|
|
selection = item+1;
|
2016-11-19 05:11:49 +01:00
|
|
|
draw_cal_status();
|
2016-12-06 19:34:33 +01:00
|
|
|
draw_menu();
|
2016-11-19 05:11:49 +01:00
|
|
|
}
|
|
|
|
|
|
2020-07-05 11:33:40 +02:00
|
|
|
static UI_FUNCTION_CALLBACK(menu_caldone_cb)
|
2016-11-19 05:11:49 +01:00
|
|
|
{
|
2017-01-02 14:03:20 +01:00
|
|
|
extern const menuitem_t menu_save[];
|
2017-09-15 16:22:01 +02:00
|
|
|
//extern const menuitem_t menu_cal[];
|
2016-12-04 08:19:31 +01:00
|
|
|
(void)item;
|
2020-01-25 13:46:09 +01:00
|
|
|
(void)data;
|
2016-11-19 05:11:49 +01:00
|
|
|
cal_done();
|
|
|
|
|
draw_cal_status();
|
2020-07-05 11:33:40 +02:00
|
|
|
menu_move_back(false);
|
2017-01-02 14:03:20 +01:00
|
|
|
menu_push_submenu(menu_save);
|
2016-11-19 05:11:49 +01:00
|
|
|
}
|
|
|
|
|
|
2020-07-13 23:15:46 +02:00
|
|
|
static UI_FUNCTION_ADV_CALLBACK(menu_cal2_acb)
|
2016-12-06 19:34:33 +01:00
|
|
|
{
|
2020-01-25 13:46:09 +01:00
|
|
|
(void)data;
|
2020-07-13 23:15:46 +02:00
|
|
|
if (b){
|
|
|
|
|
if (item == 3) b->icon = (cal_status&CALSTAT_APPLY) ? BUTTON_ICON_CHECK : BUTTON_ICON_NOCHECK;
|
|
|
|
|
return;
|
|
|
|
|
}
|
2016-12-06 19:34:33 +01:00
|
|
|
switch (item) {
|
2019-08-11 17:21:04 +02:00
|
|
|
case 2: // RESET
|
2016-12-06 19:34:33 +01:00
|
|
|
cal_status = 0;
|
|
|
|
|
break;
|
2019-08-11 17:21:04 +02:00
|
|
|
case 3: // CORRECTION
|
2017-02-02 23:28:20 +01:00
|
|
|
// toggle applying correction
|
2020-01-25 13:46:09 +01:00
|
|
|
cal_status ^= CALSTAT_APPLY;
|
2016-12-06 19:34:33 +01:00
|
|
|
break;
|
|
|
|
|
}
|
2020-02-26 21:30:50 +01:00
|
|
|
draw_menu();
|
2016-12-06 19:34:33 +01:00
|
|
|
draw_cal_status();
|
2017-02-02 23:28:20 +01:00
|
|
|
//menu_move_back();
|
2016-12-06 19:34:33 +01:00
|
|
|
}
|
|
|
|
|
|
2020-07-05 11:33:40 +02:00
|
|
|
static UI_FUNCTION_CALLBACK(menu_recall_cb)
|
2016-11-19 05:11:49 +01:00
|
|
|
{
|
2020-01-25 13:46:09 +01:00
|
|
|
(void)item;
|
2020-04-29 13:23:59 +02:00
|
|
|
load_properties(data);
|
2020-07-03 22:08:52 +02:00
|
|
|
// menu_move_back();
|
|
|
|
|
// ui_mode_normal();
|
2020-02-28 21:15:38 +01:00
|
|
|
update_grid();
|
|
|
|
|
draw_cal_status();
|
2016-11-19 05:11:49 +01:00
|
|
|
}
|
|
|
|
|
|
2020-07-05 11:33:40 +02:00
|
|
|
static UI_FUNCTION_CALLBACK(menu_config_cb)
|
2019-08-24 02:36:03 +02:00
|
|
|
{
|
2020-01-25 13:46:09 +01:00
|
|
|
(void)data;
|
2019-08-24 02:36:03 +02:00
|
|
|
switch (item) {
|
|
|
|
|
case 0:
|
|
|
|
|
touch_cal_exec();
|
|
|
|
|
break;
|
|
|
|
|
case 1:
|
|
|
|
|
touch_draw_test();
|
|
|
|
|
break;
|
2020-04-29 13:32:40 +02:00
|
|
|
case 4:
|
2019-09-05 15:14:44 +02:00
|
|
|
show_version();
|
2020-01-25 18:54:03 +01:00
|
|
|
break;
|
2019-09-06 14:04:47 +02:00
|
|
|
}
|
2020-01-25 18:54:03 +01:00
|
|
|
redraw_frame();
|
|
|
|
|
request_to_redraw_grid();
|
|
|
|
|
draw_menu();
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-05 11:33:40 +02:00
|
|
|
static UI_FUNCTION_CALLBACK(menu_config_save_cb)
|
2020-01-25 18:54:03 +01:00
|
|
|
{
|
|
|
|
|
(void)item;
|
|
|
|
|
(void)data;
|
|
|
|
|
config_save();
|
2020-07-05 11:33:40 +02:00
|
|
|
menu_move_back(true);
|
2019-09-06 14:04:47 +02:00
|
|
|
}
|
|
|
|
|
|
2020-07-05 11:33:40 +02:00
|
|
|
static UI_FUNCTION_CALLBACK(menu_dfu_cb)
|
2019-09-06 14:04:47 +02:00
|
|
|
{
|
2020-01-25 13:46:09 +01:00
|
|
|
(void)item;
|
|
|
|
|
(void)data;
|
|
|
|
|
enter_dfu();
|
2019-08-24 02:36:03 +02:00
|
|
|
}
|
|
|
|
|
|
2020-07-05 11:33:40 +02:00
|
|
|
static UI_FUNCTION_CALLBACK(menu_save_cb)
|
2016-12-04 08:19:31 +01:00
|
|
|
{
|
2020-01-25 13:46:09 +01:00
|
|
|
(void)item;
|
|
|
|
|
if (caldata_save(data) == 0) {
|
2020-07-05 11:33:40 +02:00
|
|
|
menu_move_back(true);
|
2016-12-06 19:34:33 +01:00
|
|
|
draw_cal_status();
|
2016-12-04 08:19:31 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-15 22:17:24 +02:00
|
|
|
static void
|
|
|
|
|
choose_active_trace(void)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
if (trace[uistat.current_trace].enabled)
|
|
|
|
|
// do nothing
|
|
|
|
|
return;
|
Big code redisign (increase CELL draw size, more faster screen render), also save about 4-5kB flash size
Try remove all hardcoded values from code (use definition if set)
Some error fix
main.c:
Rewrite Shell, now it run on main thread and require less RAM (not need stack)
(possible run it as thread if define VNA_SHELL_THREAD
Remove not used trace_info[].scale_unit in set_trace_scale/get_trace_scale (it just divede on set and multiple on get, better use it for default scale set)
Replace some hardcoded values
MARKERS_MAX
SAVEAREA_MAX
TRACES_MAX
plot.c
Rewrite CELLWIDTH and CELLHEIGHT use, now possible set any CELL width and height (CELLWIDTH * CELLHEIGHT <= spi_buffer size)
Free RAM from shell stack use fore increase spi_buffer size now it have 2048 pixel (64x32)
Rewrite cell index and markmap use (now correct use cell size, and more faster), correct use CELLWIDTH and CELLHEIGHT in calculation
Fore set update area use invalidateRect (still need use some hardcoded values :( )
Rewrite cell_draw_line
Rewrite many hardcoded size definitions
Refrence point now draw as bitmap (less size, more costumable)
Fix drag marker (now correct search closest index in search_nearest_index)
Rewrite plot_into_index, now correct use size definitions, moe
ui.c
Small rewrite keyboard definitions, for use less flash size
Define KP_WIDTH, KP_HEIGHT for set key size
Better look some big font symvols
All:
use static fore some local functions (use less space on calls)
replace tabs on spaces (code style)
Use M_PI from math.h fore define pi value
Fix printf on print HEX values
2020-02-22 08:50:54 +01:00
|
|
|
for (i = 0; i < TRACES_MAX; i++)
|
2019-08-15 22:17:24 +02:00
|
|
|
if (trace[i].enabled) {
|
|
|
|
|
uistat.current_trace = i;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-13 23:15:46 +02:00
|
|
|
static UI_FUNCTION_ADV_CALLBACK(menu_trace_acb)
|
2016-11-26 16:47:21 +01:00
|
|
|
{
|
2020-01-26 18:56:45 +01:00
|
|
|
(void)item;
|
2020-07-13 23:15:46 +02:00
|
|
|
if (b){
|
|
|
|
|
if (trace[data].enabled){
|
|
|
|
|
b->bg = config.trace_color[data];
|
|
|
|
|
if (data == selection) b->fg = ~config.trace_color[data];
|
|
|
|
|
b->icon = BUTTON_ICON_CHECK;
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-25 13:46:09 +01:00
|
|
|
if (trace[data].enabled) {
|
|
|
|
|
if (data == uistat.current_trace) {
|
2019-09-28 23:42:45 +02:00
|
|
|
// disable if active trace is selected
|
2020-01-25 13:46:09 +01:00
|
|
|
trace[data].enabled = FALSE;
|
2019-09-28 23:42:45 +02:00
|
|
|
choose_active_trace();
|
|
|
|
|
} else {
|
|
|
|
|
// make active selected trace
|
2020-01-26 18:56:45 +01:00
|
|
|
uistat.current_trace = data;
|
2019-09-28 23:42:45 +02:00
|
|
|
}
|
2017-02-07 22:17:14 +01:00
|
|
|
} else {
|
2020-01-25 13:46:09 +01:00
|
|
|
trace[data].enabled = TRUE;
|
2020-01-26 18:56:45 +01:00
|
|
|
uistat.current_trace = data;
|
2017-02-07 22:17:14 +01:00
|
|
|
}
|
2019-08-15 22:17:24 +02:00
|
|
|
request_to_redraw_grid();
|
|
|
|
|
draw_menu();
|
2016-11-26 16:47:21 +01:00
|
|
|
}
|
|
|
|
|
|
2020-07-05 11:33:40 +02:00
|
|
|
static UI_FUNCTION_CALLBACK(menu_format_cb)
|
2016-11-26 16:47:21 +01:00
|
|
|
{
|
2020-01-25 13:46:09 +01:00
|
|
|
(void)item;
|
|
|
|
|
set_trace_type(uistat.current_trace, data);
|
2017-09-17 11:52:02 +02:00
|
|
|
request_to_redraw_grid();
|
2016-12-04 08:19:31 +01:00
|
|
|
ui_mode_normal();
|
2017-09-15 21:11:18 +02:00
|
|
|
//redraw_all();
|
2016-11-26 16:47:21 +01:00
|
|
|
}
|
|
|
|
|
|
2020-07-05 11:33:40 +02:00
|
|
|
static UI_FUNCTION_CALLBACK(menu_channel_cb)
|
2016-11-30 12:17:55 +01:00
|
|
|
{
|
2020-01-25 13:46:09 +01:00
|
|
|
(void)item;
|
|
|
|
|
set_trace_channel(uistat.current_trace, data);
|
2020-07-05 11:33:40 +02:00
|
|
|
menu_move_back(true);
|
2016-11-30 17:08:13 +01:00
|
|
|
}
|
|
|
|
|
|
2020-07-13 23:15:46 +02:00
|
|
|
static UI_FUNCTION_ADV_CALLBACK(menu_transform_window_acb)
|
2016-11-30 17:08:13 +01:00
|
|
|
{
|
2020-01-25 13:46:09 +01:00
|
|
|
(void)item;
|
|
|
|
|
// TODO
|
2020-07-13 23:15:46 +02:00
|
|
|
if(b){
|
|
|
|
|
b->icon = (domain_mode & TD_WINDOW) == data ? BUTTON_ICON_GROUP_CHECKED : BUTTON_ICON_GROUP;
|
|
|
|
|
return;
|
|
|
|
|
}
|
2020-01-25 13:46:09 +01:00
|
|
|
domain_mode = (domain_mode & ~TD_WINDOW) | data;
|
2016-12-04 08:19:31 +01:00
|
|
|
ui_mode_normal();
|
2016-11-30 12:17:55 +01:00
|
|
|
}
|
|
|
|
|
|
2020-07-13 23:15:46 +02:00
|
|
|
static UI_FUNCTION_ADV_CALLBACK(menu_transform_acb)
|
2019-09-11 13:47:17 +02:00
|
|
|
{
|
2020-01-25 13:46:09 +01:00
|
|
|
(void)item;
|
|
|
|
|
(void)data;
|
2020-07-13 23:15:46 +02:00
|
|
|
if(b){
|
|
|
|
|
if (domain_mode & DOMAIN_TIME) b->icon = BUTTON_ICON_CHECK;
|
|
|
|
|
return;
|
|
|
|
|
}
|
2020-01-25 13:46:09 +01:00
|
|
|
domain_mode ^= DOMAIN_TIME;
|
2020-02-22 14:41:50 +01:00
|
|
|
select_lever_mode(LM_MARKER);
|
2020-01-25 13:46:09 +01:00
|
|
|
ui_mode_normal();
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-13 23:15:46 +02:00
|
|
|
static UI_FUNCTION_ADV_CALLBACK(menu_transform_filter_acb)
|
2019-09-10 15:39:20 +02:00
|
|
|
{
|
2020-01-25 13:46:09 +01:00
|
|
|
(void)item;
|
2020-07-13 23:15:46 +02:00
|
|
|
if(b){
|
|
|
|
|
b->icon = (domain_mode & TD_FUNC) == data ? BUTTON_ICON_GROUP_CHECKED : BUTTON_ICON_GROUP;
|
|
|
|
|
return;
|
|
|
|
|
}
|
2020-01-25 13:46:09 +01:00
|
|
|
domain_mode = (domain_mode & ~TD_FUNC) | data;
|
|
|
|
|
ui_mode_normal();
|
2019-09-10 15:39:20 +02:00
|
|
|
}
|
|
|
|
|
|
2020-07-13 23:15:46 +02:00
|
|
|
static UI_FUNCTION_ADV_CALLBACK(menu_bandwidth_acb)
|
2020-01-14 17:07:40 +01:00
|
|
|
{
|
2020-03-21 14:15:03 +01:00
|
|
|
(void)item;
|
2020-07-13 23:15:46 +02:00
|
|
|
if (b){
|
|
|
|
|
b->icon = config.bandwidth == data ? BUTTON_ICON_GROUP_CHECKED : BUTTON_ICON_GROUP;
|
|
|
|
|
return;
|
|
|
|
|
}
|
2020-04-02 15:36:59 +02:00
|
|
|
config.bandwidth = data;
|
2020-04-04 07:43:32 +02:00
|
|
|
draw_frequencies();
|
2020-01-14 17:07:40 +01:00
|
|
|
draw_menu();
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-13 23:15:46 +02:00
|
|
|
static UI_FUNCTION_ADV_CALLBACK(menu_points_acb)
|
2020-04-29 13:32:40 +02:00
|
|
|
{
|
|
|
|
|
(void)item;
|
2020-07-13 23:15:46 +02:00
|
|
|
if (b){
|
|
|
|
|
b->icon = sweep_points == data ? BUTTON_ICON_GROUP_CHECKED : BUTTON_ICON_GROUP;
|
|
|
|
|
return;
|
|
|
|
|
}
|
2020-04-29 13:32:40 +02:00
|
|
|
set_sweep_points(data);
|
|
|
|
|
draw_menu();
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-14 00:18:59 +02:00
|
|
|
static void
|
2016-11-28 01:17:54 +01:00
|
|
|
choose_active_marker(void)
|
2016-11-26 16:47:21 +01:00
|
|
|
{
|
|
|
|
|
int i;
|
2020-02-26 21:55:06 +01:00
|
|
|
for (i = 0; i < MARKERS_MAX; i++)
|
2016-11-26 16:47:21 +01:00
|
|
|
if (markers[i].enabled) {
|
|
|
|
|
active_marker = i;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
active_marker = -1;
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-05 11:33:40 +02:00
|
|
|
static UI_FUNCTION_CALLBACK(menu_keyboard_cb)
|
2016-12-04 08:19:31 +01:00
|
|
|
{
|
2020-01-25 13:46:09 +01:00
|
|
|
(void)item;
|
|
|
|
|
if (data == KM_SCALE && trace[uistat.current_trace].type == TRC_DELAY) {
|
Big code redisign (increase CELL draw size, more faster screen render), also save about 4-5kB flash size
Try remove all hardcoded values from code (use definition if set)
Some error fix
main.c:
Rewrite Shell, now it run on main thread and require less RAM (not need stack)
(possible run it as thread if define VNA_SHELL_THREAD
Remove not used trace_info[].scale_unit in set_trace_scale/get_trace_scale (it just divede on set and multiple on get, better use it for default scale set)
Replace some hardcoded values
MARKERS_MAX
SAVEAREA_MAX
TRACES_MAX
plot.c
Rewrite CELLWIDTH and CELLHEIGHT use, now possible set any CELL width and height (CELLWIDTH * CELLHEIGHT <= spi_buffer size)
Free RAM from shell stack use fore increase spi_buffer size now it have 2048 pixel (64x32)
Rewrite cell index and markmap use (now correct use cell size, and more faster), correct use CELLWIDTH and CELLHEIGHT in calculation
Fore set update area use invalidateRect (still need use some hardcoded values :( )
Rewrite cell_draw_line
Rewrite many hardcoded size definitions
Refrence point now draw as bitmap (less size, more costumable)
Fix drag marker (now correct search closest index in search_nearest_index)
Rewrite plot_into_index, now correct use size definitions, moe
ui.c
Small rewrite keyboard definitions, for use less flash size
Define KP_WIDTH, KP_HEIGHT for set key size
Better look some big font symvols
All:
use static fore some local functions (use less space on calls)
replace tabs on spaces (code style)
Use M_PI from math.h fore define pi value
Fix printf on print HEX values
2020-02-22 08:50:54 +01:00
|
|
|
data = KM_SCALEDELAY;
|
2019-09-08 14:39:57 +02:00
|
|
|
}
|
2020-02-26 21:30:50 +01:00
|
|
|
if (btn_wait_release() & EVT_BUTTON_DOWN_LONG) {
|
2020-01-25 13:46:09 +01:00
|
|
|
ui_mode_numeric(data);
|
2020-07-05 11:33:40 +02:00
|
|
|
// ui_process_numeric();
|
2019-08-10 07:15:35 +02:00
|
|
|
} else {
|
2020-01-25 13:46:09 +01:00
|
|
|
ui_mode_keypad(data);
|
2019-08-10 07:15:35 +02:00
|
|
|
ui_process_keypad();
|
2017-09-30 17:56:43 +02:00
|
|
|
}
|
2016-12-04 08:19:31 +01:00
|
|
|
}
|
|
|
|
|
|
2020-07-13 23:15:46 +02:00
|
|
|
static UI_FUNCTION_ADV_CALLBACK(menu_pause_acb)
|
2016-12-04 08:19:31 +01:00
|
|
|
{
|
2020-07-05 11:33:40 +02:00
|
|
|
(void)item;
|
2020-01-25 13:46:09 +01:00
|
|
|
(void)data;
|
2020-07-13 23:15:46 +02:00
|
|
|
if (b){
|
|
|
|
|
b->icon = sweep_mode&SWEEP_ENABLE ? BUTTON_ICON_NOCHECK : BUTTON_ICON_CHECK;
|
|
|
|
|
return;
|
|
|
|
|
}
|
2020-07-05 11:33:40 +02:00
|
|
|
toggle_sweep();
|
|
|
|
|
//menu_move_back();
|
|
|
|
|
//ui_mode_normal();
|
|
|
|
|
draw_menu();
|
2016-12-04 08:19:31 +01:00
|
|
|
}
|
|
|
|
|
|
2020-01-25 18:54:03 +01:00
|
|
|
static uint32_t
|
2017-09-17 11:52:02 +02:00
|
|
|
get_marker_frequency(int marker)
|
|
|
|
|
{
|
2020-02-26 21:30:50 +01:00
|
|
|
if (marker < 0 || marker >= MARKERS_MAX)
|
2020-01-25 18:54:03 +01:00
|
|
|
return 0;
|
2017-09-17 11:52:02 +02:00
|
|
|
if (!markers[marker].enabled)
|
2020-01-25 18:54:03 +01:00
|
|
|
return 0;
|
2017-09-17 11:52:02 +02:00
|
|
|
return frequencies[markers[marker].index];
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-05 11:33:40 +02:00
|
|
|
static UI_FUNCTION_CALLBACK(menu_marker_op_cb)
|
2017-01-02 08:33:10 +01:00
|
|
|
{
|
2020-01-25 18:54:03 +01:00
|
|
|
uint32_t freq = get_marker_frequency(active_marker);
|
|
|
|
|
if (freq == 0)
|
2017-09-17 11:52:02 +02:00
|
|
|
return; // no active marker
|
2017-01-02 08:33:10 +01:00
|
|
|
|
|
|
|
|
switch (item) {
|
2019-10-22 06:11:00 +02:00
|
|
|
case 0: /* MARKER->START */
|
|
|
|
|
case 1: /* MARKER->STOP */
|
|
|
|
|
case 2: /* MARKER->CENTER */
|
2020-01-25 18:54:03 +01:00
|
|
|
set_sweep_frequency(data, freq);
|
2017-01-02 08:33:10 +01:00
|
|
|
break;
|
2019-10-22 06:11:00 +02:00
|
|
|
case 3: /* MARKERS->SPAN */
|
2017-09-15 16:22:01 +02:00
|
|
|
{
|
2019-11-17 02:54:39 +01:00
|
|
|
if (previous_marker == -1 || active_marker == previous_marker) {
|
2020-01-25 18:54:03 +01:00
|
|
|
// if only 1 marker is active, keep center freq and make span the marker comes to the edge
|
2020-01-27 05:00:13 +01:00
|
|
|
uint32_t center = get_sweep_frequency(ST_CENTER);
|
|
|
|
|
uint32_t span = center > freq ? center - freq : freq - center;
|
2019-11-17 02:54:39 +01:00
|
|
|
set_sweep_frequency(ST_SPAN, span * 2);
|
|
|
|
|
} else {
|
2019-11-23 03:04:45 +01:00
|
|
|
// if 2 or more marker active, set start and stop freq to each marker
|
2020-01-25 18:54:03 +01:00
|
|
|
uint32_t freq2 = get_marker_frequency(previous_marker);
|
|
|
|
|
if (freq2 == 0)
|
2019-11-17 02:54:39 +01:00
|
|
|
return;
|
|
|
|
|
if (freq > freq2) {
|
|
|
|
|
freq2 = freq;
|
|
|
|
|
freq = get_marker_frequency(previous_marker);
|
|
|
|
|
}
|
|
|
|
|
set_sweep_frequency(ST_START, freq);
|
|
|
|
|
set_sweep_frequency(ST_STOP, freq2);
|
2017-09-17 11:52:02 +02:00
|
|
|
}
|
2017-09-15 16:22:01 +02:00
|
|
|
}
|
2017-01-02 08:33:10 +01:00
|
|
|
break;
|
2019-11-23 03:04:45 +01:00
|
|
|
case 4: /* MARKERS->EDELAY */
|
|
|
|
|
{
|
2019-11-23 09:47:14 +01:00
|
|
|
if (uistat.current_trace == -1)
|
|
|
|
|
break;
|
2019-11-23 03:04:45 +01:00
|
|
|
float (*array)[2] = measured[trace[uistat.current_trace].channel];
|
|
|
|
|
float v = groupdelay_from_array(markers[active_marker].index, array);
|
|
|
|
|
set_electrical_delay(electrical_delay + (v / 1e-12));
|
|
|
|
|
}
|
|
|
|
|
break;
|
2017-01-02 08:33:10 +01:00
|
|
|
}
|
|
|
|
|
ui_mode_normal();
|
2017-09-17 13:19:12 +02:00
|
|
|
draw_cal_status();
|
2017-09-15 21:11:18 +02:00
|
|
|
//redraw_all();
|
2017-01-02 08:33:10 +01:00
|
|
|
}
|
|
|
|
|
|
2020-07-05 11:33:40 +02:00
|
|
|
static UI_FUNCTION_CALLBACK(menu_marker_search_cb)
|
2019-10-22 06:11:00 +02:00
|
|
|
{
|
2020-01-25 13:46:09 +01:00
|
|
|
(void)data;
|
Increase screen render (in some cases up to 2x speedup), decrease stack usage (code size less on 1500 bytes)
Write simple profiling definitions
START_PROFILE
STOP_PROFILE
Use it for detect sys tick amount and output to screen
main.c
Reduce VNA_SHELL_MAX_LENGTH to 48, and made shell_line as static (reduce stack usage)
Remove BaseSequentialStream *chp from command calls (use static shell_stream), it reduce code size and stack usage
Use VNA_SHELL_FUNCTION definition for all commands
Remove chMtxLock(&mutex);chMtxUnlock(&mutex); from commands, and define command flag for use it in calls
Apply default scale from trace_info on trace change
Led blink outside from main sweep cycle (better look, and less noise)
Some size fixes
chprintf.c
Implement small memory stream object, only put function and plot_printf(char *str, int size, const char *fmt, ...)
Use it in all code (little increase speed, and huge decrease size)
Restore USE_EXCEPTIONS_STACKSIZE = 0x180 (possible not need, but not good tested)
plot.c
Made huge screen render profile (add some comments)
Not use cell clipping on draw cell data (use constants increase speed, decrease stack usage (not need put it to stack))
Clip cell if need only on screen flush
Use new plot_printf, remove chsnprintf usage
Apply code style
============================================================================================================
Interesting fact
Usage memset(spi_buffer, DEFAULT_BG_COLOR, (h*CELLWIDTH)*sizeof(uint16_t)); dramatically decrease render speed
possibly it fill buffer by 8 bit data, so slow
Usage
uint32_t *p = (uint32_t *)spi_buffer;
while (count--) {
p[0] = DEFAULT_BG_COLOR|(DEFAULT_BG_COLOR<<16);
p[1] = DEFAULT_BG_COLOR|(DEFAULT_BG_COLOR<<16);
p[2] = DEFAULT_BG_COLOR|(DEFAULT_BG_COLOR<<16);
p[3] = DEFAULT_BG_COLOR|(DEFAULT_BG_COLOR<<16);
p+=4;
}
gives x10 speed perfomance
Draw polar and smit grid very slow (but i don`t know how increase it except use bitmaps, but it need about 5-8k flash size and file prepare)
On long lines render slow down, but clipping use more calculation, and not give good result
Need made stack usage check
2020-02-24 20:47:52 +01:00
|
|
|
int i = -1;
|
2019-10-22 06:11:00 +02:00
|
|
|
if (active_marker == -1)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
switch (item) {
|
|
|
|
|
case 0: /* maximum */
|
|
|
|
|
case 1: /* minimum */
|
2020-01-18 14:27:56 +01:00
|
|
|
set_marker_search(item);
|
|
|
|
|
i = marker_search();
|
2019-10-22 06:11:00 +02:00
|
|
|
break;
|
|
|
|
|
case 2: /* search Left */
|
|
|
|
|
i = marker_search_left(markers[active_marker].index);
|
2020-05-14 00:18:59 +02:00
|
|
|
uistat.marker_tracking = false;
|
2019-10-22 06:11:00 +02:00
|
|
|
break;
|
|
|
|
|
case 3: /* search right */
|
|
|
|
|
i = marker_search_right(markers[active_marker].index);
|
2020-05-14 00:18:59 +02:00
|
|
|
uistat.marker_tracking = false;
|
2019-10-22 06:11:00 +02:00
|
|
|
break;
|
|
|
|
|
}
|
Increase screen render (in some cases up to 2x speedup), decrease stack usage (code size less on 1500 bytes)
Write simple profiling definitions
START_PROFILE
STOP_PROFILE
Use it for detect sys tick amount and output to screen
main.c
Reduce VNA_SHELL_MAX_LENGTH to 48, and made shell_line as static (reduce stack usage)
Remove BaseSequentialStream *chp from command calls (use static shell_stream), it reduce code size and stack usage
Use VNA_SHELL_FUNCTION definition for all commands
Remove chMtxLock(&mutex);chMtxUnlock(&mutex); from commands, and define command flag for use it in calls
Apply default scale from trace_info on trace change
Led blink outside from main sweep cycle (better look, and less noise)
Some size fixes
chprintf.c
Implement small memory stream object, only put function and plot_printf(char *str, int size, const char *fmt, ...)
Use it in all code (little increase speed, and huge decrease size)
Restore USE_EXCEPTIONS_STACKSIZE = 0x180 (possible not need, but not good tested)
plot.c
Made huge screen render profile (add some comments)
Not use cell clipping on draw cell data (use constants increase speed, decrease stack usage (not need put it to stack))
Clip cell if need only on screen flush
Use new plot_printf, remove chsnprintf usage
Apply code style
============================================================================================================
Interesting fact
Usage memset(spi_buffer, DEFAULT_BG_COLOR, (h*CELLWIDTH)*sizeof(uint16_t)); dramatically decrease render speed
possibly it fill buffer by 8 bit data, so slow
Usage
uint32_t *p = (uint32_t *)spi_buffer;
while (count--) {
p[0] = DEFAULT_BG_COLOR|(DEFAULT_BG_COLOR<<16);
p[1] = DEFAULT_BG_COLOR|(DEFAULT_BG_COLOR<<16);
p[2] = DEFAULT_BG_COLOR|(DEFAULT_BG_COLOR<<16);
p[3] = DEFAULT_BG_COLOR|(DEFAULT_BG_COLOR<<16);
p+=4;
}
gives x10 speed perfomance
Draw polar and smit grid very slow (but i don`t know how increase it except use bitmaps, but it need about 5-8k flash size and file prepare)
On long lines render slow down, but clipping use more calculation, and not give good result
Need made stack usage check
2020-02-24 20:47:52 +01:00
|
|
|
if (i != -1)
|
|
|
|
|
markers[active_marker].index = i;
|
2020-01-25 18:54:03 +01:00
|
|
|
draw_menu();
|
2020-03-09 20:28:05 +01:00
|
|
|
redraw_marker(active_marker);
|
2020-02-22 14:41:50 +01:00
|
|
|
select_lever_mode(LM_SEARCH);
|
2019-10-22 06:11:00 +02:00
|
|
|
}
|
|
|
|
|
|
2020-07-13 23:15:46 +02:00
|
|
|
static UI_FUNCTION_ADV_CALLBACK(menu_marker_tracking_acb)
|
2019-11-30 02:17:14 +01:00
|
|
|
{
|
2020-01-25 13:46:09 +01:00
|
|
|
(void)item;
|
2020-07-13 23:15:46 +02:00
|
|
|
(void)data;
|
|
|
|
|
if (b){
|
|
|
|
|
b->icon = uistat.marker_tracking ? BUTTON_ICON_CHECK : BUTTON_ICON_NOCHECK;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
uistat.marker_tracking = !uistat.marker_tracking;
|
|
|
|
|
draw_menu();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static UI_FUNCTION_ADV_CALLBACK(menu_marker_smith_acb)
|
|
|
|
|
{
|
|
|
|
|
(void)item;
|
|
|
|
|
if (b){
|
|
|
|
|
b->icon = marker_smith_format == data ? BUTTON_ICON_GROUP_CHECKED : BUTTON_ICON_GROUP;
|
|
|
|
|
return;
|
|
|
|
|
}
|
2020-01-25 13:46:09 +01:00
|
|
|
marker_smith_format = data;
|
2020-03-09 20:28:05 +01:00
|
|
|
redraw_marker(active_marker);
|
2019-11-30 02:17:14 +01:00
|
|
|
draw_menu();
|
|
|
|
|
}
|
|
|
|
|
|
Big code redisign (increase CELL draw size, more faster screen render), also save about 4-5kB flash size
Try remove all hardcoded values from code (use definition if set)
Some error fix
main.c:
Rewrite Shell, now it run on main thread and require less RAM (not need stack)
(possible run it as thread if define VNA_SHELL_THREAD
Remove not used trace_info[].scale_unit in set_trace_scale/get_trace_scale (it just divede on set and multiple on get, better use it for default scale set)
Replace some hardcoded values
MARKERS_MAX
SAVEAREA_MAX
TRACES_MAX
plot.c
Rewrite CELLWIDTH and CELLHEIGHT use, now possible set any CELL width and height (CELLWIDTH * CELLHEIGHT <= spi_buffer size)
Free RAM from shell stack use fore increase spi_buffer size now it have 2048 pixel (64x32)
Rewrite cell index and markmap use (now correct use cell size, and more faster), correct use CELLWIDTH and CELLHEIGHT in calculation
Fore set update area use invalidateRect (still need use some hardcoded values :( )
Rewrite cell_draw_line
Rewrite many hardcoded size definitions
Refrence point now draw as bitmap (less size, more costumable)
Fix drag marker (now correct search closest index in search_nearest_index)
Rewrite plot_into_index, now correct use size definitions, moe
ui.c
Small rewrite keyboard definitions, for use less flash size
Define KP_WIDTH, KP_HEIGHT for set key size
Better look some big font symvols
All:
use static fore some local functions (use less space on calls)
replace tabs on spaces (code style)
Use M_PI from math.h fore define pi value
Fix printf on print HEX values
2020-02-22 08:50:54 +01:00
|
|
|
static void
|
2019-09-29 00:01:23 +02:00
|
|
|
active_marker_select(int item)
|
|
|
|
|
{
|
|
|
|
|
if (item == -1) {
|
|
|
|
|
active_marker = previous_marker;
|
|
|
|
|
previous_marker = -1;
|
|
|
|
|
if (active_marker == -1) {
|
|
|
|
|
choose_active_marker();
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (previous_marker != active_marker)
|
|
|
|
|
previous_marker = active_marker;
|
|
|
|
|
active_marker = item;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-13 23:15:46 +02:00
|
|
|
static UI_FUNCTION_ADV_CALLBACK(menu_marker_sel_acb)
|
2016-11-26 16:47:21 +01:00
|
|
|
{
|
2020-01-25 13:46:09 +01:00
|
|
|
(void)data;
|
2020-02-26 21:30:50 +01:00
|
|
|
int t;
|
2020-07-13 23:15:46 +02:00
|
|
|
if (b){
|
|
|
|
|
if (item < 4 && markers[item].enabled) b->icon = BUTTON_ICON_CHECK;
|
|
|
|
|
else if (item == 5) b->icon = uistat.marker_delta ? BUTTON_ICON_CHECK : BUTTON_ICON_NOCHECK;
|
|
|
|
|
return;
|
|
|
|
|
}
|
2020-02-26 21:30:50 +01:00
|
|
|
if (item >= 0 && item < MARKERS_MAX) {
|
2019-09-29 00:01:23 +02:00
|
|
|
if (markers[item].enabled) {
|
|
|
|
|
if (item == active_marker) {
|
|
|
|
|
// disable if active trace is selected
|
|
|
|
|
markers[item].enabled = FALSE;
|
|
|
|
|
active_marker_select(-1);
|
|
|
|
|
} else {
|
|
|
|
|
active_marker_select(item);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
markers[item].enabled = TRUE;
|
|
|
|
|
active_marker_select(item);
|
|
|
|
|
}
|
2019-08-18 01:18:52 +02:00
|
|
|
} else if (item == 4) { /* all off */
|
2020-02-26 21:30:50 +01:00
|
|
|
for (t = 0; t < MARKERS_MAX; t++)
|
|
|
|
|
markers[t].enabled = FALSE;
|
2019-08-18 01:18:52 +02:00
|
|
|
previous_marker = -1;
|
|
|
|
|
active_marker = -1;
|
2019-11-29 13:53:07 +01:00
|
|
|
} else if (item == 5) { /* marker delta */
|
|
|
|
|
uistat.marker_delta = !uistat.marker_delta;
|
2019-08-18 01:06:05 +02:00
|
|
|
}
|
2020-03-09 20:28:05 +01:00
|
|
|
redraw_marker(active_marker);
|
2019-08-18 01:06:05 +02:00
|
|
|
draw_menu();
|
2016-11-26 16:47:21 +01:00
|
|
|
}
|
|
|
|
|
|
2020-07-01 11:29:25 +02:00
|
|
|
#ifdef __USE_SD_CARD__
|
|
|
|
|
#define SAVE_S1P_FILE 1
|
|
|
|
|
#define SAVE_S2P_FILE 2
|
|
|
|
|
|
|
|
|
|
static const char s1_file_header[] =
|
|
|
|
|
"!File created by NanoVNA\r\n"\
|
|
|
|
|
"# HZ S RI R 50\r\n";
|
|
|
|
|
|
|
|
|
|
static const char s1_file_param[] =
|
|
|
|
|
"%10d % f % f\r\n";
|
|
|
|
|
|
|
|
|
|
static const char s2_file_header[] =
|
|
|
|
|
"!File created by NanoVNA\r\n"\
|
|
|
|
|
"# HZ S RI R 50\r\n";
|
|
|
|
|
|
|
|
|
|
static const char s2_file_param[] =
|
|
|
|
|
"%10d % f % f % f % f 0 0 0 0\r\n";
|
|
|
|
|
|
2020-07-05 11:33:40 +02:00
|
|
|
static UI_FUNCTION_CALLBACK(menu_sdcard_cb)
|
2020-07-01 11:29:25 +02:00
|
|
|
{
|
|
|
|
|
(void)item;
|
|
|
|
|
char *buf = (char *)spi_buffer;
|
|
|
|
|
// shell_printf("S file\r\n");
|
|
|
|
|
FRESULT res = f_mount(fs_volume, "", 1);
|
|
|
|
|
// shell_printf("Mount = %d\r\n", res);
|
|
|
|
|
if (res != FR_OK)
|
|
|
|
|
return;
|
|
|
|
|
// Prepare filename = .s1p or .s2p and open for write
|
|
|
|
|
#if FF_USE_LFN >= 1
|
|
|
|
|
uint32_t tr = rtc_get_tr_bcd(); // TR read first
|
|
|
|
|
uint32_t dr = rtc_get_dr_bcd(); // DR read second
|
|
|
|
|
plot_printf(fs_filename, FF_LFN_BUF, "VNA_%06X_%06X.s%dp", dr, tr, data);
|
|
|
|
|
#else
|
|
|
|
|
plot_printf(fs_filename, FF_LFN_BUF, "%08X.s%dp", rtc_get_FAT(), data);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
int i;
|
|
|
|
|
UINT size;
|
|
|
|
|
// UINT total_size = 0;
|
|
|
|
|
// systime_t time = chVTGetSystemTimeX();
|
|
|
|
|
res = f_open(fs_file, fs_filename, FA_CREATE_ALWAYS | FA_READ | FA_WRITE);
|
|
|
|
|
// shell_printf("Open %s, = %d\r\n", fs_filename, res);
|
|
|
|
|
if (res == FR_OK){
|
|
|
|
|
// Write S1P file
|
|
|
|
|
if (data == SAVE_S1P_FILE){
|
|
|
|
|
// write s1p header (not write NULL terminate at end)
|
|
|
|
|
res = f_write(fs_file, s1_file_header, sizeof(s1_file_header)-1, &size);
|
|
|
|
|
// total_size+=size;
|
|
|
|
|
// Write all points data
|
|
|
|
|
for (i = 0; i < sweep_points && res == FR_OK; i++) {
|
|
|
|
|
size = plot_printf(buf, 128, s1_file_param, frequencies[i], measured[0][i][0], measured[0][i][1]);
|
|
|
|
|
// total_size+=size;
|
|
|
|
|
res = f_write(fs_file, buf, size, &size);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// Write S2P file
|
|
|
|
|
else if (data == SAVE_S2P_FILE){
|
|
|
|
|
// Write s2p header (not write NULL terminate at end)
|
|
|
|
|
res = f_write(fs_file, s2_file_header, sizeof(s2_file_header)-1, &size);
|
|
|
|
|
// total_size+=size;
|
|
|
|
|
// Write all points data
|
|
|
|
|
for (i = 0; i < sweep_points && res == FR_OK; i++) {
|
|
|
|
|
size = plot_printf(buf, 128, s2_file_param, frequencies[i], measured[0][i][0], measured[0][i][1], measured[1][i][0], measured[1][i][1]);
|
|
|
|
|
// total_size+=size;
|
|
|
|
|
res = f_write(fs_file, buf, size, &size);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
res = f_close(fs_file);
|
|
|
|
|
// shell_printf("Close = %d\r\n", res);
|
|
|
|
|
// testLog();
|
|
|
|
|
// time = chVTGetSystemTimeX() - time;
|
|
|
|
|
// shell_printf("Total time: %dms (write %d byte/sec)\r\n", time/10, total_size*10000/time);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ili9341_fill(LCD_WIDTH/2-96, LCD_HEIGHT/2-30, 96*2, 60, config.menu_normal_color);
|
|
|
|
|
ili9341_set_foreground(DEFAULT_MENU_TEXT_COLOR);
|
|
|
|
|
ili9341_set_background(config.menu_normal_color);
|
|
|
|
|
ili9341_drawstring("SAVE TRACE", LCD_WIDTH/2-5*FONT_WIDTH, LCD_HEIGHT/2-20);
|
|
|
|
|
ili9341_drawstring(res == FR_OK ? fs_filename : " Fail write ", LCD_WIDTH/2-76, LCD_HEIGHT/2);
|
|
|
|
|
chThdSleepMilliseconds(2000);
|
|
|
|
|
request_to_redraw_grid();
|
|
|
|
|
ui_mode_normal();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static const menuitem_t menu_sdcard[] = {
|
|
|
|
|
{ MT_CALLBACK, SAVE_S1P_FILE, "SAVE S1P", menu_sdcard_cb },
|
|
|
|
|
{ MT_CALLBACK, SAVE_S2P_FILE, "SAVE S2P", menu_sdcard_cb },
|
|
|
|
|
{ MT_CANCEL, 0, S_LARROW" BACK", NULL },
|
|
|
|
|
{ MT_NONE, 0, NULL, NULL } // sentinel
|
|
|
|
|
};
|
|
|
|
|
#endif
|
|
|
|
|
|
Big code redisign (increase CELL draw size, more faster screen render), also save about 4-5kB flash size
Try remove all hardcoded values from code (use definition if set)
Some error fix
main.c:
Rewrite Shell, now it run on main thread and require less RAM (not need stack)
(possible run it as thread if define VNA_SHELL_THREAD
Remove not used trace_info[].scale_unit in set_trace_scale/get_trace_scale (it just divede on set and multiple on get, better use it for default scale set)
Replace some hardcoded values
MARKERS_MAX
SAVEAREA_MAX
TRACES_MAX
plot.c
Rewrite CELLWIDTH and CELLHEIGHT use, now possible set any CELL width and height (CELLWIDTH * CELLHEIGHT <= spi_buffer size)
Free RAM from shell stack use fore increase spi_buffer size now it have 2048 pixel (64x32)
Rewrite cell index and markmap use (now correct use cell size, and more faster), correct use CELLWIDTH and CELLHEIGHT in calculation
Fore set update area use invalidateRect (still need use some hardcoded values :( )
Rewrite cell_draw_line
Rewrite many hardcoded size definitions
Refrence point now draw as bitmap (less size, more costumable)
Fix drag marker (now correct search closest index in search_nearest_index)
Rewrite plot_into_index, now correct use size definitions, moe
ui.c
Small rewrite keyboard definitions, for use less flash size
Define KP_WIDTH, KP_HEIGHT for set key size
Better look some big font symvols
All:
use static fore some local functions (use less space on calls)
replace tabs on spaces (code style)
Use M_PI from math.h fore define pi value
Fix printf on print HEX values
2020-02-22 08:50:54 +01:00
|
|
|
static const menuitem_t menu_calop[] = {
|
2020-07-13 23:15:46 +02:00
|
|
|
{ MT_ADV_CALLBACK, CAL_OPEN, "OPEN", menu_calop_acb },
|
|
|
|
|
{ MT_ADV_CALLBACK, CAL_SHORT, "SHORT", menu_calop_acb },
|
|
|
|
|
{ MT_ADV_CALLBACK, CAL_LOAD, "LOAD", menu_calop_acb },
|
|
|
|
|
{ MT_ADV_CALLBACK, CAL_ISOLN, "ISOLN", menu_calop_acb },
|
|
|
|
|
{ MT_ADV_CALLBACK, CAL_THRU, "THRU", menu_calop_acb },
|
2020-01-25 13:46:09 +01:00
|
|
|
{ MT_CALLBACK, 0, "DONE", menu_caldone_cb },
|
|
|
|
|
{ MT_CANCEL, 0, S_LARROW" BACK", NULL },
|
|
|
|
|
{ MT_NONE, 0, NULL, NULL } // sentinel
|
2016-12-06 19:34:33 +01:00
|
|
|
};
|
2016-11-19 05:11:49 +01:00
|
|
|
|
2017-01-02 14:03:20 +01:00
|
|
|
const menuitem_t menu_save[] = {
|
2020-01-25 13:46:09 +01:00
|
|
|
{ MT_CALLBACK, 0, "SAVE 0", menu_save_cb },
|
|
|
|
|
{ MT_CALLBACK, 1, "SAVE 1", menu_save_cb },
|
|
|
|
|
{ MT_CALLBACK, 2, "SAVE 2", menu_save_cb },
|
|
|
|
|
{ MT_CALLBACK, 3, "SAVE 3", menu_save_cb },
|
|
|
|
|
{ MT_CALLBACK, 4, "SAVE 4", menu_save_cb },
|
|
|
|
|
{ MT_CANCEL, 0, S_LARROW" BACK", NULL },
|
|
|
|
|
{ MT_NONE, 0, NULL, NULL } // sentinel
|
2017-01-02 14:03:20 +01:00
|
|
|
};
|
|
|
|
|
|
2016-11-19 05:11:49 +01:00
|
|
|
const menuitem_t menu_cal[] = {
|
2020-01-25 13:46:09 +01:00
|
|
|
{ MT_SUBMENU, 0, "CALIBRATE", menu_calop },
|
2020-07-13 15:14:15 +02:00
|
|
|
{ MT_SUBMENU, 0, "SAVE", menu_save },
|
2020-07-13 23:15:46 +02:00
|
|
|
{ MT_ADV_CALLBACK, 0, "RESET", menu_cal2_acb },
|
|
|
|
|
{ MT_ADV_CALLBACK, 0, "APPLY", menu_cal2_acb },
|
2020-01-25 13:46:09 +01:00
|
|
|
{ MT_CANCEL, 0, S_LARROW" BACK", NULL },
|
|
|
|
|
{ MT_NONE, 0, NULL, NULL } // sentinel
|
2016-11-19 05:11:49 +01:00
|
|
|
};
|
|
|
|
|
|
2016-11-26 16:47:21 +01:00
|
|
|
const menuitem_t menu_trace[] = {
|
2020-07-13 23:15:46 +02:00
|
|
|
{ MT_ADV_CALLBACK, 0, "TRACE 0", menu_trace_acb },
|
|
|
|
|
{ MT_ADV_CALLBACK, 1, "TRACE 1", menu_trace_acb },
|
|
|
|
|
{ MT_ADV_CALLBACK, 2, "TRACE 2", menu_trace_acb },
|
|
|
|
|
{ MT_ADV_CALLBACK, 3, "TRACE 3", menu_trace_acb },
|
2020-01-25 13:46:09 +01:00
|
|
|
{ MT_CANCEL, 0, S_LARROW" BACK", NULL },
|
|
|
|
|
{ MT_NONE, 0, NULL, NULL } // sentinel
|
2016-11-26 16:47:21 +01:00
|
|
|
};
|
|
|
|
|
|
2016-11-30 12:17:55 +01:00
|
|
|
const menuitem_t menu_format2[] = {
|
2020-01-25 13:46:09 +01:00
|
|
|
{ MT_CALLBACK, TRC_POLAR, "POLAR", menu_format_cb },
|
|
|
|
|
{ MT_CALLBACK, TRC_LINEAR, "LINEAR", menu_format_cb },
|
|
|
|
|
{ MT_CALLBACK, TRC_REAL, "REAL", menu_format_cb },
|
|
|
|
|
{ MT_CALLBACK, TRC_IMAG, "IMAG", menu_format_cb },
|
|
|
|
|
{ MT_CALLBACK, TRC_R, "RESISTANCE", menu_format_cb },
|
|
|
|
|
{ MT_CALLBACK, TRC_X, "REACTANCE", menu_format_cb },
|
2020-06-16 02:23:10 +02:00
|
|
|
{ MT_CALLBACK, TRC_Q, "Q FACTOR", menu_format_cb },
|
2020-01-25 13:46:09 +01:00
|
|
|
{ MT_CANCEL, 0, S_LARROW" BACK", NULL },
|
|
|
|
|
{ MT_NONE, 0, NULL, NULL } // sentinel
|
2016-11-30 12:17:55 +01:00
|
|
|
};
|
|
|
|
|
|
2016-11-26 16:47:21 +01:00
|
|
|
const menuitem_t menu_format[] = {
|
2020-01-25 13:46:09 +01:00
|
|
|
{ MT_CALLBACK, TRC_LOGMAG, "LOGMAG", menu_format_cb },
|
|
|
|
|
{ MT_CALLBACK, TRC_PHASE, "PHASE", menu_format_cb },
|
|
|
|
|
{ MT_CALLBACK, TRC_DELAY, "DELAY", menu_format_cb },
|
|
|
|
|
{ MT_CALLBACK, TRC_SMITH, "SMITH", menu_format_cb },
|
|
|
|
|
{ MT_CALLBACK, TRC_SWR, "SWR", menu_format_cb },
|
|
|
|
|
{ MT_SUBMENU, 0, S_RARROW" MORE", menu_format2 },
|
|
|
|
|
//{ MT_CALLBACK, TRC_LINEAR, "LINEAR", menu_format_cb },
|
|
|
|
|
//{ MT_CALLBACK, TRC_SWR, "SWR", menu_format_cb },
|
|
|
|
|
{ MT_CANCEL, 0, S_LARROW" BACK", NULL },
|
|
|
|
|
{ MT_NONE, 0, NULL, NULL } // sentinel
|
2016-11-26 16:47:21 +01:00
|
|
|
};
|
|
|
|
|
|
2017-01-05 15:28:32 +01:00
|
|
|
const menuitem_t menu_scale[] = {
|
2020-07-05 11:33:40 +02:00
|
|
|
{ MT_CALLBACK, KM_SCALE, "SCALE/DIV", menu_keyboard_cb },
|
2020-07-09 19:41:24 +02:00
|
|
|
{ MT_CALLBACK, KM_REFPOS, "REFERENCE\nPOSITION", menu_keyboard_cb },
|
|
|
|
|
{ MT_CALLBACK, KM_EDELAY, "ELECTRICAL\nDELAY", menu_keyboard_cb },
|
2020-01-25 13:46:09 +01:00
|
|
|
{ MT_CANCEL, 0, S_LARROW" BACK", NULL },
|
|
|
|
|
{ MT_NONE, 0, NULL, NULL } // sentinel
|
2017-01-05 15:28:32 +01:00
|
|
|
};
|
|
|
|
|
|
2016-11-30 17:08:13 +01:00
|
|
|
const menuitem_t menu_channel[] = {
|
2020-07-09 19:41:24 +02:00
|
|
|
{ MT_CALLBACK, 0, "CH0\nREFLECT", menu_channel_cb },
|
|
|
|
|
{ MT_CALLBACK, 1, "CH1\nTHROUGH", menu_channel_cb },
|
2020-01-25 13:46:09 +01:00
|
|
|
{ MT_CANCEL, 0, S_LARROW" BACK", NULL },
|
|
|
|
|
{ MT_NONE, 0, NULL, NULL } // sentinel
|
2016-11-30 17:08:13 +01:00
|
|
|
};
|
|
|
|
|
|
2019-09-11 13:47:17 +02:00
|
|
|
const menuitem_t menu_transform_window[] = {
|
2020-07-13 23:15:46 +02:00
|
|
|
{ MT_ADV_CALLBACK, TD_WINDOW_MINIMUM, "MINIMUM", menu_transform_window_acb },
|
|
|
|
|
{ MT_ADV_CALLBACK, TD_WINDOW_NORMAL, "NORMAL", menu_transform_window_acb },
|
|
|
|
|
{ MT_ADV_CALLBACK, TD_WINDOW_MAXIMUM, "MAXIMUM", menu_transform_window_acb },
|
2020-01-25 13:46:09 +01:00
|
|
|
{ MT_CANCEL, 0, S_LARROW" BACK", NULL },
|
|
|
|
|
{ MT_NONE, 0, NULL, NULL } // sentinel
|
2019-09-11 13:47:17 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const menuitem_t menu_transform[] = {
|
2020-07-13 23:15:46 +02:00
|
|
|
{ MT_ADV_CALLBACK, 0, "TRANS\nFORM ON", menu_transform_acb },
|
|
|
|
|
{ MT_ADV_CALLBACK, TD_FUNC_LOWPASS_IMPULSE, "LOW PASS\nIMPULSE", menu_transform_filter_acb },
|
|
|
|
|
{ MT_ADV_CALLBACK, TD_FUNC_LOWPASS_STEP, "LOW PASS\nSTEP", menu_transform_filter_acb },
|
|
|
|
|
{ MT_ADV_CALLBACK, TD_FUNC_BANDPASS, "BANDPASS", menu_transform_filter_acb },
|
2020-01-25 13:46:09 +01:00
|
|
|
{ MT_SUBMENU, 0, "WINDOW", menu_transform_window },
|
2020-07-09 19:41:24 +02:00
|
|
|
{ MT_CALLBACK, KM_VELOCITY_FACTOR, "VELOCITY\nFACTOR", menu_keyboard_cb },
|
2020-01-25 13:46:09 +01:00
|
|
|
{ MT_CANCEL, 0, S_LARROW" BACK", NULL },
|
|
|
|
|
{ MT_NONE, 0, NULL, NULL } // sentinel
|
2019-09-10 15:39:20 +02:00
|
|
|
};
|
|
|
|
|
|
2020-01-14 17:07:40 +01:00
|
|
|
const menuitem_t menu_bandwidth[] = {
|
2020-07-17 16:36:14 +02:00
|
|
|
#ifdef BANDWIDTH_2000
|
2020-07-13 23:15:46 +02:00
|
|
|
{ MT_ADV_CALLBACK, BANDWIDTH_2000, "2 kHz", menu_bandwidth_acb },
|
2020-07-17 16:36:14 +02:00
|
|
|
#endif
|
2020-07-13 23:15:46 +02:00
|
|
|
{ MT_ADV_CALLBACK, BANDWIDTH_1000, "1 kHz", menu_bandwidth_acb },
|
|
|
|
|
{ MT_ADV_CALLBACK, BANDWIDTH_333, "333 Hz", menu_bandwidth_acb },
|
|
|
|
|
{ MT_ADV_CALLBACK, BANDWIDTH_100, "100 Hz", menu_bandwidth_acb },
|
|
|
|
|
{ MT_ADV_CALLBACK, BANDWIDTH_30, "30 Hz", menu_bandwidth_acb },
|
|
|
|
|
{ MT_ADV_CALLBACK, BANDWIDTH_10, "10 Hz", menu_bandwidth_acb },
|
2020-03-21 19:58:51 +01:00
|
|
|
{ MT_CANCEL, 255, S_LARROW" BACK", NULL },
|
2020-01-14 17:07:40 +01:00
|
|
|
{ MT_NONE, 0, NULL, NULL } // sentinel
|
|
|
|
|
};
|
|
|
|
|
|
2016-11-26 16:47:21 +01:00
|
|
|
const menuitem_t menu_display[] = {
|
2020-01-25 13:46:09 +01:00
|
|
|
{ MT_SUBMENU, 0, "TRACE", menu_trace },
|
|
|
|
|
{ MT_SUBMENU, 0, "FORMAT", menu_format },
|
|
|
|
|
{ MT_SUBMENU, 0, "SCALE", menu_scale },
|
|
|
|
|
{ MT_SUBMENU, 0, "CHANNEL", menu_channel },
|
|
|
|
|
{ MT_SUBMENU, 0, "TRANSFORM", menu_transform },
|
2020-03-21 14:15:03 +01:00
|
|
|
{ MT_SUBMENU, 0, "BANDWIDTH", menu_bandwidth },
|
2020-01-25 13:46:09 +01:00
|
|
|
{ MT_CANCEL, 0, S_LARROW" BACK", NULL },
|
|
|
|
|
{ MT_NONE, 0, NULL, NULL } // sentinel
|
2016-11-26 16:47:21 +01:00
|
|
|
};
|
|
|
|
|
|
2020-04-29 13:32:40 +02:00
|
|
|
const menuitem_t menu_sweep_points[] = {
|
2020-07-13 23:15:46 +02:00
|
|
|
{ MT_ADV_CALLBACK, POINTS_SET_51, " 51 pt", menu_points_acb },
|
|
|
|
|
{ MT_ADV_CALLBACK, POINTS_SET_101, "101 pt", menu_points_acb },
|
2020-04-29 13:32:40 +02:00
|
|
|
{ MT_CANCEL, 0, S_LARROW" BACK", NULL },
|
|
|
|
|
{ MT_NONE, 0, NULL, NULL } // sentinel
|
|
|
|
|
};
|
|
|
|
|
|
2016-12-04 08:19:31 +01:00
|
|
|
const menuitem_t menu_stimulus[] = {
|
2020-07-05 11:33:40 +02:00
|
|
|
{ MT_CALLBACK, KM_START, "START", menu_keyboard_cb },
|
|
|
|
|
{ MT_CALLBACK, KM_STOP, "STOP", menu_keyboard_cb },
|
|
|
|
|
{ MT_CALLBACK, KM_CENTER, "CENTER", menu_keyboard_cb },
|
|
|
|
|
{ MT_CALLBACK, KM_SPAN, "SPAN", menu_keyboard_cb },
|
|
|
|
|
{ MT_CALLBACK, KM_CW, "CW FREQ", menu_keyboard_cb },
|
2020-07-13 23:15:46 +02:00
|
|
|
{ MT_ADV_CALLBACK, 0, "PAUSE\nSWEEP", menu_pause_acb },
|
2020-01-25 13:46:09 +01:00
|
|
|
{ MT_CANCEL, 0, S_LARROW" BACK", NULL },
|
|
|
|
|
{ MT_NONE, 0, NULL, NULL } // sentinel
|
2016-12-04 08:19:31 +01:00
|
|
|
};
|
|
|
|
|
|
2017-01-02 08:33:10 +01:00
|
|
|
const menuitem_t menu_marker_sel[] = {
|
2020-07-13 23:15:46 +02:00
|
|
|
{ MT_ADV_CALLBACK, 1, "MARKER 1", menu_marker_sel_acb },
|
|
|
|
|
{ MT_ADV_CALLBACK, 2, "MARKER 2", menu_marker_sel_acb },
|
|
|
|
|
{ MT_ADV_CALLBACK, 3, "MARKER 3", menu_marker_sel_acb },
|
|
|
|
|
{ MT_ADV_CALLBACK, 4, "MARKER 4", menu_marker_sel_acb },
|
|
|
|
|
{ MT_ADV_CALLBACK, 0, "ALL OFF", menu_marker_sel_acb },
|
|
|
|
|
{ MT_ADV_CALLBACK, 0, "DELTA", menu_marker_sel_acb },
|
2020-01-25 13:46:09 +01:00
|
|
|
{ MT_CANCEL, 0, S_LARROW" BACK", NULL },
|
|
|
|
|
{ MT_NONE, 0, NULL, NULL } // sentinel
|
2017-01-02 08:33:10 +01:00
|
|
|
};
|
|
|
|
|
|
2019-10-22 06:11:00 +02:00
|
|
|
const menuitem_t menu_marker_ops[] = {
|
2020-01-25 18:54:03 +01:00
|
|
|
{ MT_CALLBACK, ST_START, S_RARROW"START", menu_marker_op_cb },
|
|
|
|
|
{ MT_CALLBACK, ST_STOP, S_RARROW"STOP", menu_marker_op_cb },
|
|
|
|
|
{ MT_CALLBACK, ST_CENTER, S_RARROW"CENTER", menu_marker_op_cb },
|
|
|
|
|
{ MT_CALLBACK, ST_SPAN, S_RARROW"SPAN", menu_marker_op_cb },
|
2020-01-25 13:46:09 +01:00
|
|
|
{ MT_CALLBACK, 0, S_RARROW"EDELAY", menu_marker_op_cb },
|
|
|
|
|
{ MT_CANCEL, 0, S_LARROW" BACK", NULL },
|
|
|
|
|
{ MT_NONE, 0, NULL, NULL } // sentinel
|
2016-11-26 16:47:21 +01:00
|
|
|
};
|
|
|
|
|
|
2019-10-22 06:11:00 +02:00
|
|
|
const menuitem_t menu_marker_search[] = {
|
|
|
|
|
//{ MT_CALLBACK, "OFF", menu_marker_search_cb },
|
2020-01-25 13:46:09 +01:00
|
|
|
{ MT_CALLBACK, 0, "MAXIMUM", menu_marker_search_cb },
|
|
|
|
|
{ MT_CALLBACK, 0, "MINIMUM", menu_marker_search_cb },
|
2020-07-09 19:41:24 +02:00
|
|
|
{ MT_CALLBACK, 0, "SEARCH\n" S_LARROW" LEFT", menu_marker_search_cb },
|
|
|
|
|
{ MT_CALLBACK, 0, "SEARCH\n" S_RARROW" RIGHT", menu_marker_search_cb },
|
2020-07-13 23:15:46 +02:00
|
|
|
{ MT_ADV_CALLBACK, 0, "TRACKING", menu_marker_tracking_acb },
|
2020-01-25 13:46:09 +01:00
|
|
|
{ MT_CANCEL, 0, S_LARROW" BACK", NULL },
|
|
|
|
|
{ MT_NONE, 0, NULL, NULL } // sentinel
|
2019-10-22 06:11:00 +02:00
|
|
|
};
|
|
|
|
|
|
2019-11-30 02:17:14 +01:00
|
|
|
const menuitem_t menu_marker_smith[] = {
|
2020-07-13 23:15:46 +02:00
|
|
|
{ MT_ADV_CALLBACK, MS_LIN, "LIN", menu_marker_smith_acb },
|
|
|
|
|
{ MT_ADV_CALLBACK, MS_LOG, "LOG", menu_marker_smith_acb },
|
|
|
|
|
{ MT_ADV_CALLBACK, MS_REIM,"Re+Im", menu_marker_smith_acb },
|
|
|
|
|
{ MT_ADV_CALLBACK, MS_RX, "R+jX", menu_marker_smith_acb },
|
|
|
|
|
{ MT_ADV_CALLBACK, MS_RLC, "R+L/C", menu_marker_smith_acb },
|
2020-01-25 13:46:09 +01:00
|
|
|
{ MT_CANCEL, 0, S_LARROW" BACK", NULL },
|
|
|
|
|
{ MT_NONE, 0, NULL, NULL } // sentinel
|
2019-11-30 02:17:14 +01:00
|
|
|
};
|
|
|
|
|
|
2019-10-22 06:11:00 +02:00
|
|
|
const menuitem_t menu_marker[] = {
|
2020-07-09 19:41:24 +02:00
|
|
|
{ MT_SUBMENU, 0, "SELECT\nMARKER", menu_marker_sel },
|
2020-01-25 13:46:09 +01:00
|
|
|
{ MT_SUBMENU, 0, "SEARCH", menu_marker_search },
|
|
|
|
|
{ MT_SUBMENU, 0, "OPERATIONS", menu_marker_ops },
|
2020-07-09 19:41:24 +02:00
|
|
|
{ MT_SUBMENU, 0, "SMITH\nVALUE", menu_marker_smith },
|
2020-01-25 13:46:09 +01:00
|
|
|
{ MT_CANCEL, 0, S_LARROW" BACK", NULL },
|
|
|
|
|
{ MT_NONE, 0, NULL, NULL } // sentinel
|
2019-10-22 06:11:00 +02:00
|
|
|
};
|
|
|
|
|
|
2016-11-19 05:11:49 +01:00
|
|
|
const menuitem_t menu_recall[] = {
|
2020-01-25 13:46:09 +01:00
|
|
|
{ MT_CALLBACK, 0, "RECALL 0", menu_recall_cb },
|
|
|
|
|
{ MT_CALLBACK, 1, "RECALL 1", menu_recall_cb },
|
|
|
|
|
{ MT_CALLBACK, 2, "RECALL 2", menu_recall_cb },
|
|
|
|
|
{ MT_CALLBACK, 3, "RECALL 3", menu_recall_cb },
|
|
|
|
|
{ MT_CALLBACK, 4, "RECALL 4", menu_recall_cb },
|
|
|
|
|
{ MT_CANCEL, 0, S_LARROW" BACK", NULL },
|
|
|
|
|
{ MT_NONE, 0, NULL, NULL } // sentinel
|
2016-11-19 05:11:49 +01:00
|
|
|
};
|
|
|
|
|
|
2019-09-06 14:04:47 +02:00
|
|
|
const menuitem_t menu_dfu[] = {
|
2020-07-09 19:41:24 +02:00
|
|
|
{ MT_CALLBACK, 0, "RESET AND\nENTER DFU", menu_dfu_cb },
|
2020-01-25 13:46:09 +01:00
|
|
|
{ MT_CANCEL, 0, S_LARROW"CANCEL", NULL },
|
|
|
|
|
{ MT_NONE, 0, NULL, NULL } // sentinel
|
2019-09-06 14:04:47 +02:00
|
|
|
};
|
|
|
|
|
|
2019-08-24 02:36:03 +02:00
|
|
|
const menuitem_t menu_config[] = {
|
2020-01-25 13:46:09 +01:00
|
|
|
{ MT_CALLBACK, 0, "TOUCH CAL", menu_config_cb },
|
|
|
|
|
{ MT_CALLBACK, 0, "TOUCH TEST", menu_config_cb },
|
2020-01-25 18:54:03 +01:00
|
|
|
{ MT_CALLBACK, 0, "SAVE", menu_config_save_cb },
|
2020-07-09 19:41:24 +02:00
|
|
|
{ MT_SUBMENU, 0, "SWEEP\nPOINTS", menu_sweep_points },
|
2020-01-25 13:46:09 +01:00
|
|
|
{ MT_CALLBACK, 0, "VERSION", menu_config_cb },
|
|
|
|
|
{ MT_SUBMENU, 0, S_RARROW"DFU", menu_dfu },
|
|
|
|
|
{ MT_CANCEL, 0, S_LARROW" BACK", NULL },
|
|
|
|
|
{ MT_NONE, 0, NULL, NULL } // sentinel
|
2019-08-24 02:36:03 +02:00
|
|
|
};
|
|
|
|
|
|
2016-11-19 05:11:49 +01:00
|
|
|
const menuitem_t menu_top[] = {
|
2020-01-25 13:46:09 +01:00
|
|
|
{ MT_SUBMENU, 0, "DISPLAY", menu_display },
|
|
|
|
|
{ MT_SUBMENU, 0, "MARKER", menu_marker },
|
|
|
|
|
{ MT_SUBMENU, 0, "STIMULUS", menu_stimulus },
|
2020-07-13 15:14:15 +02:00
|
|
|
{ MT_SUBMENU, 0, "CALIBRATE", menu_cal },
|
2020-01-25 13:46:09 +01:00
|
|
|
{ MT_SUBMENU, 0, "RECALL", menu_recall },
|
2020-07-01 11:29:25 +02:00
|
|
|
#ifdef __USE_SD_CARD__
|
|
|
|
|
{ MT_SUBMENU, 0, "SD CARD", menu_sdcard },
|
|
|
|
|
#endif
|
2020-01-25 13:46:09 +01:00
|
|
|
{ MT_SUBMENU, 0, "CONFIG", menu_config },
|
|
|
|
|
{ MT_NONE, 0, NULL, NULL } // sentinel
|
2016-11-19 05:11:49 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#define MENU_STACK_DEPTH_MAX 4
|
2020-02-26 21:30:50 +01:00
|
|
|
const menuitem_t *menu_stack[MENU_STACK_DEPTH_MAX] = {
|
2020-01-27 04:55:41 +01:00
|
|
|
menu_top, NULL, NULL, NULL
|
2016-11-19 05:11:49 +01:00
|
|
|
};
|
|
|
|
|
|
2016-11-30 17:08:13 +01:00
|
|
|
static void
|
|
|
|
|
ensure_selection(void)
|
|
|
|
|
{
|
|
|
|
|
const menuitem_t *menu = menu_stack[menu_current_level];
|
|
|
|
|
int i;
|
|
|
|
|
for (i = 0; menu[i].type != MT_NONE; i++)
|
|
|
|
|
;
|
2020-07-09 19:41:24 +02:00
|
|
|
if (selection < 0)
|
|
|
|
|
selection = -1;
|
|
|
|
|
else if (selection >= i)
|
2016-11-30 17:08:13 +01:00
|
|
|
selection = i-1;
|
|
|
|
|
}
|
|
|
|
|
|
Big code redisign (increase CELL draw size, more faster screen render), also save about 4-5kB flash size
Try remove all hardcoded values from code (use definition if set)
Some error fix
main.c:
Rewrite Shell, now it run on main thread and require less RAM (not need stack)
(possible run it as thread if define VNA_SHELL_THREAD
Remove not used trace_info[].scale_unit in set_trace_scale/get_trace_scale (it just divede on set and multiple on get, better use it for default scale set)
Replace some hardcoded values
MARKERS_MAX
SAVEAREA_MAX
TRACES_MAX
plot.c
Rewrite CELLWIDTH and CELLHEIGHT use, now possible set any CELL width and height (CELLWIDTH * CELLHEIGHT <= spi_buffer size)
Free RAM from shell stack use fore increase spi_buffer size now it have 2048 pixel (64x32)
Rewrite cell index and markmap use (now correct use cell size, and more faster), correct use CELLWIDTH and CELLHEIGHT in calculation
Fore set update area use invalidateRect (still need use some hardcoded values :( )
Rewrite cell_draw_line
Rewrite many hardcoded size definitions
Refrence point now draw as bitmap (less size, more costumable)
Fix drag marker (now correct search closest index in search_nearest_index)
Rewrite plot_into_index, now correct use size definitions, moe
ui.c
Small rewrite keyboard definitions, for use less flash size
Define KP_WIDTH, KP_HEIGHT for set key size
Better look some big font symvols
All:
use static fore some local functions (use less space on calls)
replace tabs on spaces (code style)
Use M_PI from math.h fore define pi value
Fix printf on print HEX values
2020-02-22 08:50:54 +01:00
|
|
|
static void
|
2020-07-05 11:33:40 +02:00
|
|
|
menu_move_back(bool leave_ui)
|
2016-11-19 05:11:49 +01:00
|
|
|
{
|
|
|
|
|
if (menu_current_level == 0)
|
|
|
|
|
return;
|
|
|
|
|
menu_current_level--;
|
2016-11-30 17:08:13 +01:00
|
|
|
ensure_selection();
|
2016-12-04 08:19:31 +01:00
|
|
|
erase_menu_buttons();
|
2020-07-05 11:33:40 +02:00
|
|
|
if (leave_ui)
|
|
|
|
|
ui_mode_normal();
|
|
|
|
|
else
|
|
|
|
|
draw_menu();
|
2016-12-04 08:19:31 +01:00
|
|
|
}
|
|
|
|
|
|
Big code redisign (increase CELL draw size, more faster screen render), also save about 4-5kB flash size
Try remove all hardcoded values from code (use definition if set)
Some error fix
main.c:
Rewrite Shell, now it run on main thread and require less RAM (not need stack)
(possible run it as thread if define VNA_SHELL_THREAD
Remove not used trace_info[].scale_unit in set_trace_scale/get_trace_scale (it just divede on set and multiple on get, better use it for default scale set)
Replace some hardcoded values
MARKERS_MAX
SAVEAREA_MAX
TRACES_MAX
plot.c
Rewrite CELLWIDTH and CELLHEIGHT use, now possible set any CELL width and height (CELLWIDTH * CELLHEIGHT <= spi_buffer size)
Free RAM from shell stack use fore increase spi_buffer size now it have 2048 pixel (64x32)
Rewrite cell index and markmap use (now correct use cell size, and more faster), correct use CELLWIDTH and CELLHEIGHT in calculation
Fore set update area use invalidateRect (still need use some hardcoded values :( )
Rewrite cell_draw_line
Rewrite many hardcoded size definitions
Refrence point now draw as bitmap (less size, more costumable)
Fix drag marker (now correct search closest index in search_nearest_index)
Rewrite plot_into_index, now correct use size definitions, moe
ui.c
Small rewrite keyboard definitions, for use less flash size
Define KP_WIDTH, KP_HEIGHT for set key size
Better look some big font symvols
All:
use static fore some local functions (use less space on calls)
replace tabs on spaces (code style)
Use M_PI from math.h fore define pi value
Fix printf on print HEX values
2020-02-22 08:50:54 +01:00
|
|
|
static void
|
|
|
|
|
menu_push_submenu(const menuitem_t *submenu)
|
2016-12-04 08:19:31 +01:00
|
|
|
{
|
|
|
|
|
if (menu_current_level < MENU_STACK_DEPTH_MAX-1)
|
|
|
|
|
menu_current_level++;
|
|
|
|
|
menu_stack[menu_current_level] = submenu;
|
|
|
|
|
ensure_selection();
|
|
|
|
|
erase_menu_buttons();
|
|
|
|
|
draw_menu();
|
2016-11-19 05:11:49 +01:00
|
|
|
}
|
|
|
|
|
|
2017-01-16 17:49:22 +01:00
|
|
|
/*
|
Big code redisign (increase CELL draw size, more faster screen render), also save about 4-5kB flash size
Try remove all hardcoded values from code (use definition if set)
Some error fix
main.c:
Rewrite Shell, now it run on main thread and require less RAM (not need stack)
(possible run it as thread if define VNA_SHELL_THREAD
Remove not used trace_info[].scale_unit in set_trace_scale/get_trace_scale (it just divede on set and multiple on get, better use it for default scale set)
Replace some hardcoded values
MARKERS_MAX
SAVEAREA_MAX
TRACES_MAX
plot.c
Rewrite CELLWIDTH and CELLHEIGHT use, now possible set any CELL width and height (CELLWIDTH * CELLHEIGHT <= spi_buffer size)
Free RAM from shell stack use fore increase spi_buffer size now it have 2048 pixel (64x32)
Rewrite cell index and markmap use (now correct use cell size, and more faster), correct use CELLWIDTH and CELLHEIGHT in calculation
Fore set update area use invalidateRect (still need use some hardcoded values :( )
Rewrite cell_draw_line
Rewrite many hardcoded size definitions
Refrence point now draw as bitmap (less size, more costumable)
Fix drag marker (now correct search closest index in search_nearest_index)
Rewrite plot_into_index, now correct use size definitions, moe
ui.c
Small rewrite keyboard definitions, for use less flash size
Define KP_WIDTH, KP_HEIGHT for set key size
Better look some big font symvols
All:
use static fore some local functions (use less space on calls)
replace tabs on spaces (code style)
Use M_PI from math.h fore define pi value
Fix printf on print HEX values
2020-02-22 08:50:54 +01:00
|
|
|
static void
|
|
|
|
|
menu_move_top(void)
|
2016-11-19 05:11:49 +01:00
|
|
|
{
|
|
|
|
|
if (menu_current_level == 0)
|
|
|
|
|
return;
|
|
|
|
|
menu_current_level = 0;
|
2016-11-30 17:08:13 +01:00
|
|
|
ensure_selection();
|
2016-12-04 08:19:31 +01:00
|
|
|
erase_menu_buttons();
|
|
|
|
|
draw_menu();
|
2016-11-19 05:11:49 +01:00
|
|
|
}
|
2017-01-16 17:49:22 +01:00
|
|
|
*/
|
2016-11-19 05:11:49 +01:00
|
|
|
|
Big code redisign (increase CELL draw size, more faster screen render), also save about 4-5kB flash size
Try remove all hardcoded values from code (use definition if set)
Some error fix
main.c:
Rewrite Shell, now it run on main thread and require less RAM (not need stack)
(possible run it as thread if define VNA_SHELL_THREAD
Remove not used trace_info[].scale_unit in set_trace_scale/get_trace_scale (it just divede on set and multiple on get, better use it for default scale set)
Replace some hardcoded values
MARKERS_MAX
SAVEAREA_MAX
TRACES_MAX
plot.c
Rewrite CELLWIDTH and CELLHEIGHT use, now possible set any CELL width and height (CELLWIDTH * CELLHEIGHT <= spi_buffer size)
Free RAM from shell stack use fore increase spi_buffer size now it have 2048 pixel (64x32)
Rewrite cell index and markmap use (now correct use cell size, and more faster), correct use CELLWIDTH and CELLHEIGHT in calculation
Fore set update area use invalidateRect (still need use some hardcoded values :( )
Rewrite cell_draw_line
Rewrite many hardcoded size definitions
Refrence point now draw as bitmap (less size, more costumable)
Fix drag marker (now correct search closest index in search_nearest_index)
Rewrite plot_into_index, now correct use size definitions, moe
ui.c
Small rewrite keyboard definitions, for use less flash size
Define KP_WIDTH, KP_HEIGHT for set key size
Better look some big font symvols
All:
use static fore some local functions (use less space on calls)
replace tabs on spaces (code style)
Use M_PI from math.h fore define pi value
Fix printf on print HEX values
2020-02-22 08:50:54 +01:00
|
|
|
static void
|
|
|
|
|
menu_invoke(int item)
|
2016-11-19 05:11:49 +01:00
|
|
|
{
|
|
|
|
|
const menuitem_t *menu = menu_stack[menu_current_level];
|
2016-12-04 08:19:31 +01:00
|
|
|
menu = &menu[item];
|
2016-11-19 05:11:49 +01:00
|
|
|
|
|
|
|
|
switch (menu->type) {
|
|
|
|
|
case MT_NONE:
|
|
|
|
|
case MT_BLANK:
|
2016-11-26 16:47:21 +01:00
|
|
|
case MT_CLOSE:
|
2016-12-04 08:19:31 +01:00
|
|
|
ui_mode_normal();
|
2016-11-19 05:11:49 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case MT_CANCEL:
|
2020-07-05 11:33:40 +02:00
|
|
|
menu_move_back(false);
|
2016-11-19 05:11:49 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case MT_CALLBACK: {
|
|
|
|
|
menuaction_cb_t cb = (menuaction_cb_t)menu->reference;
|
2020-07-13 23:15:46 +02:00
|
|
|
if (cb) (*cb)(item, menu->data);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case MT_ADV_CALLBACK: {
|
|
|
|
|
menuaction_acb_t cb = (menuaction_acb_t)menu->reference;
|
|
|
|
|
if (cb) (*cb)(item, menu->data, NULL);
|
2016-11-19 05:11:49 +01:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case MT_SUBMENU:
|
2016-12-04 08:19:31 +01:00
|
|
|
menu_push_submenu((const menuitem_t*)menu->reference);
|
2016-11-19 05:11:49 +01:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
Big code redisign (increase CELL draw size, more faster screen render), also save about 4-5kB flash size
Try remove all hardcoded values from code (use definition if set)
Some error fix
main.c:
Rewrite Shell, now it run on main thread and require less RAM (not need stack)
(possible run it as thread if define VNA_SHELL_THREAD
Remove not used trace_info[].scale_unit in set_trace_scale/get_trace_scale (it just divede on set and multiple on get, better use it for default scale set)
Replace some hardcoded values
MARKERS_MAX
SAVEAREA_MAX
TRACES_MAX
plot.c
Rewrite CELLWIDTH and CELLHEIGHT use, now possible set any CELL width and height (CELLWIDTH * CELLHEIGHT <= spi_buffer size)
Free RAM from shell stack use fore increase spi_buffer size now it have 2048 pixel (64x32)
Rewrite cell index and markmap use (now correct use cell size, and more faster), correct use CELLWIDTH and CELLHEIGHT in calculation
Fore set update area use invalidateRect (still need use some hardcoded values :( )
Rewrite cell_draw_line
Rewrite many hardcoded size definitions
Refrence point now draw as bitmap (less size, more costumable)
Fix drag marker (now correct search closest index in search_nearest_index)
Rewrite plot_into_index, now correct use size definitions, moe
ui.c
Small rewrite keyboard definitions, for use less flash size
Define KP_WIDTH, KP_HEIGHT for set key size
Better look some big font symvols
All:
use static fore some local functions (use less space on calls)
replace tabs on spaces (code style)
Use M_PI from math.h fore define pi value
Fix printf on print HEX values
2020-02-22 08:50:54 +01:00
|
|
|
// Key names
|
|
|
|
|
#define KP_0 0
|
|
|
|
|
#define KP_1 1
|
|
|
|
|
#define KP_2 2
|
|
|
|
|
#define KP_3 3
|
|
|
|
|
#define KP_4 4
|
|
|
|
|
#define KP_5 5
|
|
|
|
|
#define KP_6 6
|
|
|
|
|
#define KP_7 7
|
|
|
|
|
#define KP_8 8
|
|
|
|
|
#define KP_9 9
|
|
|
|
|
#define KP_PERIOD 10
|
|
|
|
|
#define KP_MINUS 11
|
|
|
|
|
#define KP_X1 12
|
|
|
|
|
#define KP_K 13
|
|
|
|
|
#define KP_M 14
|
|
|
|
|
#define KP_G 15
|
|
|
|
|
#define KP_BS 16
|
|
|
|
|
#define KP_INF 17
|
|
|
|
|
#define KP_DB 18
|
2019-10-11 14:22:00 +02:00
|
|
|
#define KP_PLUSMINUS 19
|
Big code redisign (increase CELL draw size, more faster screen render), also save about 4-5kB flash size
Try remove all hardcoded values from code (use definition if set)
Some error fix
main.c:
Rewrite Shell, now it run on main thread and require less RAM (not need stack)
(possible run it as thread if define VNA_SHELL_THREAD
Remove not used trace_info[].scale_unit in set_trace_scale/get_trace_scale (it just divede on set and multiple on get, better use it for default scale set)
Replace some hardcoded values
MARKERS_MAX
SAVEAREA_MAX
TRACES_MAX
plot.c
Rewrite CELLWIDTH and CELLHEIGHT use, now possible set any CELL width and height (CELLWIDTH * CELLHEIGHT <= spi_buffer size)
Free RAM from shell stack use fore increase spi_buffer size now it have 2048 pixel (64x32)
Rewrite cell index and markmap use (now correct use cell size, and more faster), correct use CELLWIDTH and CELLHEIGHT in calculation
Fore set update area use invalidateRect (still need use some hardcoded values :( )
Rewrite cell_draw_line
Rewrite many hardcoded size definitions
Refrence point now draw as bitmap (less size, more costumable)
Fix drag marker (now correct search closest index in search_nearest_index)
Rewrite plot_into_index, now correct use size definitions, moe
ui.c
Small rewrite keyboard definitions, for use less flash size
Define KP_WIDTH, KP_HEIGHT for set key size
Better look some big font symvols
All:
use static fore some local functions (use less space on calls)
replace tabs on spaces (code style)
Use M_PI from math.h fore define pi value
Fix printf on print HEX values
2020-02-22 08:50:54 +01:00
|
|
|
#define KP_KEYPAD 20
|
|
|
|
|
#define KP_N 21
|
|
|
|
|
#define KP_P 22
|
2020-07-05 11:33:40 +02:00
|
|
|
// Stop
|
|
|
|
|
#define KP_NONE 255
|
Big code redisign (increase CELL draw size, more faster screen render), also save about 4-5kB flash size
Try remove all hardcoded values from code (use definition if set)
Some error fix
main.c:
Rewrite Shell, now it run on main thread and require less RAM (not need stack)
(possible run it as thread if define VNA_SHELL_THREAD
Remove not used trace_info[].scale_unit in set_trace_scale/get_trace_scale (it just divede on set and multiple on get, better use it for default scale set)
Replace some hardcoded values
MARKERS_MAX
SAVEAREA_MAX
TRACES_MAX
plot.c
Rewrite CELLWIDTH and CELLHEIGHT use, now possible set any CELL width and height (CELLWIDTH * CELLHEIGHT <= spi_buffer size)
Free RAM from shell stack use fore increase spi_buffer size now it have 2048 pixel (64x32)
Rewrite cell index and markmap use (now correct use cell size, and more faster), correct use CELLWIDTH and CELLHEIGHT in calculation
Fore set update area use invalidateRect (still need use some hardcoded values :( )
Rewrite cell_draw_line
Rewrite many hardcoded size definitions
Refrence point now draw as bitmap (less size, more costumable)
Fix drag marker (now correct search closest index in search_nearest_index)
Rewrite plot_into_index, now correct use size definitions, moe
ui.c
Small rewrite keyboard definitions, for use less flash size
Define KP_WIDTH, KP_HEIGHT for set key size
Better look some big font symvols
All:
use static fore some local functions (use less space on calls)
replace tabs on spaces (code style)
Use M_PI from math.h fore define pi value
Fix printf on print HEX values
2020-02-22 08:50:54 +01:00
|
|
|
|
|
|
|
|
static const keypads_t keypads_freq[] = {
|
|
|
|
|
{ 1, 3, KP_PERIOD },
|
|
|
|
|
{ 0, 3, KP_0 },
|
|
|
|
|
{ 0, 2, KP_1 },
|
|
|
|
|
{ 1, 2, KP_2 },
|
|
|
|
|
{ 2, 2, KP_3 },
|
|
|
|
|
{ 0, 1, KP_4 },
|
|
|
|
|
{ 1, 1, KP_5 },
|
|
|
|
|
{ 2, 1, KP_6 },
|
|
|
|
|
{ 0, 0, KP_7 },
|
|
|
|
|
{ 1, 0, KP_8 },
|
|
|
|
|
{ 2, 0, KP_9 },
|
|
|
|
|
{ 3, 0, KP_G },
|
|
|
|
|
{ 3, 1, KP_M },
|
|
|
|
|
{ 3, 2, KP_K },
|
|
|
|
|
{ 3, 3, KP_X1 },
|
|
|
|
|
{ 2, 3, KP_BS },
|
2020-07-05 11:33:40 +02:00
|
|
|
{ 0, 0, KP_NONE}
|
2016-12-04 08:19:31 +01:00
|
|
|
};
|
2017-02-03 13:18:33 +01:00
|
|
|
|
Big code redisign (increase CELL draw size, more faster screen render), also save about 4-5kB flash size
Try remove all hardcoded values from code (use definition if set)
Some error fix
main.c:
Rewrite Shell, now it run on main thread and require less RAM (not need stack)
(possible run it as thread if define VNA_SHELL_THREAD
Remove not used trace_info[].scale_unit in set_trace_scale/get_trace_scale (it just divede on set and multiple on get, better use it for default scale set)
Replace some hardcoded values
MARKERS_MAX
SAVEAREA_MAX
TRACES_MAX
plot.c
Rewrite CELLWIDTH and CELLHEIGHT use, now possible set any CELL width and height (CELLWIDTH * CELLHEIGHT <= spi_buffer size)
Free RAM from shell stack use fore increase spi_buffer size now it have 2048 pixel (64x32)
Rewrite cell index and markmap use (now correct use cell size, and more faster), correct use CELLWIDTH and CELLHEIGHT in calculation
Fore set update area use invalidateRect (still need use some hardcoded values :( )
Rewrite cell_draw_line
Rewrite many hardcoded size definitions
Refrence point now draw as bitmap (less size, more costumable)
Fix drag marker (now correct search closest index in search_nearest_index)
Rewrite plot_into_index, now correct use size definitions, moe
ui.c
Small rewrite keyboard definitions, for use less flash size
Define KP_WIDTH, KP_HEIGHT for set key size
Better look some big font symvols
All:
use static fore some local functions (use less space on calls)
replace tabs on spaces (code style)
Use M_PI from math.h fore define pi value
Fix printf on print HEX values
2020-02-22 08:50:54 +01:00
|
|
|
static const keypads_t keypads_scale[] = {
|
|
|
|
|
{ 1, 3, KP_PERIOD },
|
|
|
|
|
{ 0, 3, KP_0 },
|
|
|
|
|
{ 0, 2, KP_1 },
|
|
|
|
|
{ 1, 2, KP_2 },
|
|
|
|
|
{ 2, 2, KP_3 },
|
|
|
|
|
{ 0, 1, KP_4 },
|
|
|
|
|
{ 1, 1, KP_5 },
|
|
|
|
|
{ 2, 1, KP_6 },
|
|
|
|
|
{ 0, 0, KP_7 },
|
|
|
|
|
{ 1, 0, KP_8 },
|
|
|
|
|
{ 2, 0, KP_9 },
|
|
|
|
|
{ 3, 3, KP_X1 },
|
|
|
|
|
{ 2, 3, KP_BS },
|
2020-07-05 11:33:40 +02:00
|
|
|
{ 0, 0, KP_NONE }
|
2017-02-03 13:18:33 +01:00
|
|
|
};
|
|
|
|
|
|
Big code redisign (increase CELL draw size, more faster screen render), also save about 4-5kB flash size
Try remove all hardcoded values from code (use definition if set)
Some error fix
main.c:
Rewrite Shell, now it run on main thread and require less RAM (not need stack)
(possible run it as thread if define VNA_SHELL_THREAD
Remove not used trace_info[].scale_unit in set_trace_scale/get_trace_scale (it just divede on set and multiple on get, better use it for default scale set)
Replace some hardcoded values
MARKERS_MAX
SAVEAREA_MAX
TRACES_MAX
plot.c
Rewrite CELLWIDTH and CELLHEIGHT use, now possible set any CELL width and height (CELLWIDTH * CELLHEIGHT <= spi_buffer size)
Free RAM from shell stack use fore increase spi_buffer size now it have 2048 pixel (64x32)
Rewrite cell index and markmap use (now correct use cell size, and more faster), correct use CELLWIDTH and CELLHEIGHT in calculation
Fore set update area use invalidateRect (still need use some hardcoded values :( )
Rewrite cell_draw_line
Rewrite many hardcoded size definitions
Refrence point now draw as bitmap (less size, more costumable)
Fix drag marker (now correct search closest index in search_nearest_index)
Rewrite plot_into_index, now correct use size definitions, moe
ui.c
Small rewrite keyboard definitions, for use less flash size
Define KP_WIDTH, KP_HEIGHT for set key size
Better look some big font symvols
All:
use static fore some local functions (use less space on calls)
replace tabs on spaces (code style)
Use M_PI from math.h fore define pi value
Fix printf on print HEX values
2020-02-22 08:50:54 +01:00
|
|
|
static const keypads_t keypads_time[] = {
|
|
|
|
|
{ 1, 3, KP_PERIOD },
|
|
|
|
|
{ 0, 3, KP_0 },
|
|
|
|
|
{ 0, 2, KP_1 },
|
|
|
|
|
{ 1, 2, KP_2 },
|
|
|
|
|
{ 2, 2, KP_3 },
|
|
|
|
|
{ 0, 1, KP_4 },
|
|
|
|
|
{ 1, 1, KP_5 },
|
|
|
|
|
{ 2, 1, KP_6 },
|
|
|
|
|
{ 0, 0, KP_7 },
|
|
|
|
|
{ 1, 0, KP_8 },
|
|
|
|
|
{ 2, 0, KP_9 },
|
|
|
|
|
{ 3, 1, KP_N },
|
|
|
|
|
{ 3, 2, KP_P },
|
|
|
|
|
{ 3, 3, KP_MINUS },
|
|
|
|
|
{ 2, 3, KP_BS },
|
2020-07-05 11:33:40 +02:00
|
|
|
{ 0, 0, KP_NONE }
|
2019-08-10 07:15:35 +02:00
|
|
|
};
|
|
|
|
|
|
2020-07-09 10:59:33 +02:00
|
|
|
static const keypads_list keypads_mode_tbl[KM_NONE] = {
|
|
|
|
|
{keypads_freq , "START" }, // start
|
|
|
|
|
{keypads_freq , "STOP" }, // stop
|
|
|
|
|
{keypads_freq , "CENTER" }, // center
|
|
|
|
|
{keypads_freq , "SPAN" }, // span
|
|
|
|
|
{keypads_freq , "CW FREQ" }, // cw freq
|
|
|
|
|
{keypads_scale, "SCALE" }, // scale
|
|
|
|
|
{keypads_scale, "REFPOS" }, // refpos
|
|
|
|
|
{keypads_time , "EDELAY" }, // electrical delay
|
|
|
|
|
{keypads_scale, "VELOCITY%"}, // velocity factor
|
|
|
|
|
{keypads_time , "DELAY" } // scale of delay
|
2017-02-03 13:18:33 +01:00
|
|
|
};
|
|
|
|
|
|
2020-07-03 21:03:54 +02:00
|
|
|
static void
|
2020-07-13 15:14:15 +02:00
|
|
|
draw_button(uint16_t x, uint16_t y, uint16_t w, uint16_t h, button_t *b)
|
2020-07-03 21:03:54 +02:00
|
|
|
{
|
2020-07-14 11:21:44 +02:00
|
|
|
uint16_t bw = b->border&BUTTON_BORDER_WIDTH_MASK;
|
2020-07-13 15:14:15 +02:00
|
|
|
ili9341_fill(x + bw, y + bw, w - (bw * 2), h - (bw * 2), b->bg);
|
2020-07-14 11:21:44 +02:00
|
|
|
if (bw==0) return;
|
2020-07-15 13:34:50 +02:00
|
|
|
uint16_t br = RGB565(255,255,255);
|
|
|
|
|
uint16_t bd = RGB565(196,196,196);
|
|
|
|
|
uint16_t type = b->border;
|
|
|
|
|
ili9341_fill(x, y, w, bw, type&BUTTON_BORDER_TOP ? br : bd); // top
|
|
|
|
|
ili9341_fill(x + w - bw, y, bw, h, type&BUTTON_BORDER_RIGHT ? br : bd); // right
|
|
|
|
|
ili9341_fill(x, y, bw, h, type&BUTTON_BORDER_LEFT ? br : bd); // left
|
|
|
|
|
ili9341_fill(x, y + h - bw, w, bw, type&BUTTON_BORDER_BOTTOM ? br : bd); // bottom
|
2020-07-03 21:03:54 +02:00
|
|
|
}
|
|
|
|
|
|
Big code redisign (increase CELL draw size, more faster screen render), also save about 4-5kB flash size
Try remove all hardcoded values from code (use definition if set)
Some error fix
main.c:
Rewrite Shell, now it run on main thread and require less RAM (not need stack)
(possible run it as thread if define VNA_SHELL_THREAD
Remove not used trace_info[].scale_unit in set_trace_scale/get_trace_scale (it just divede on set and multiple on get, better use it for default scale set)
Replace some hardcoded values
MARKERS_MAX
SAVEAREA_MAX
TRACES_MAX
plot.c
Rewrite CELLWIDTH and CELLHEIGHT use, now possible set any CELL width and height (CELLWIDTH * CELLHEIGHT <= spi_buffer size)
Free RAM from shell stack use fore increase spi_buffer size now it have 2048 pixel (64x32)
Rewrite cell index and markmap use (now correct use cell size, and more faster), correct use CELLWIDTH and CELLHEIGHT in calculation
Fore set update area use invalidateRect (still need use some hardcoded values :( )
Rewrite cell_draw_line
Rewrite many hardcoded size definitions
Refrence point now draw as bitmap (less size, more costumable)
Fix drag marker (now correct search closest index in search_nearest_index)
Rewrite plot_into_index, now correct use size definitions, moe
ui.c
Small rewrite keyboard definitions, for use less flash size
Define KP_WIDTH, KP_HEIGHT for set key size
Better look some big font symvols
All:
use static fore some local functions (use less space on calls)
replace tabs on spaces (code style)
Use M_PI from math.h fore define pi value
Fix printf on print HEX values
2020-02-22 08:50:54 +01:00
|
|
|
static void
|
2016-12-04 08:19:31 +01:00
|
|
|
draw_keypad(void)
|
|
|
|
|
{
|
|
|
|
|
int i = 0;
|
2020-07-13 15:14:15 +02:00
|
|
|
button_t button;
|
|
|
|
|
button.fg = DEFAULT_MENU_TEXT_COLOR;
|
2020-07-05 11:33:40 +02:00
|
|
|
while (keypads[i].c != KP_NONE) {
|
2020-07-14 20:30:27 +02:00
|
|
|
button.bg = config.menu_normal_color;
|
2020-07-14 11:21:44 +02:00
|
|
|
if (i == selection){
|
2020-07-14 20:30:27 +02:00
|
|
|
button.bg = config.menu_active_color;
|
2020-07-14 11:21:44 +02:00
|
|
|
button.border = KEYBOARD_BUTTON_BORDER|BUTTON_BORDER_FALLING;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
button.border = KEYBOARD_BUTTON_BORDER|BUTTON_BORDER_RISE;
|
2020-07-13 15:14:15 +02:00
|
|
|
ili9341_set_foreground(button.fg);
|
|
|
|
|
ili9341_set_background(button.bg);
|
Big code redisign (increase CELL draw size, more faster screen render), also save about 4-5kB flash size
Try remove all hardcoded values from code (use definition if set)
Some error fix
main.c:
Rewrite Shell, now it run on main thread and require less RAM (not need stack)
(possible run it as thread if define VNA_SHELL_THREAD
Remove not used trace_info[].scale_unit in set_trace_scale/get_trace_scale (it just divede on set and multiple on get, better use it for default scale set)
Replace some hardcoded values
MARKERS_MAX
SAVEAREA_MAX
TRACES_MAX
plot.c
Rewrite CELLWIDTH and CELLHEIGHT use, now possible set any CELL width and height (CELLWIDTH * CELLHEIGHT <= spi_buffer size)
Free RAM from shell stack use fore increase spi_buffer size now it have 2048 pixel (64x32)
Rewrite cell index and markmap use (now correct use cell size, and more faster), correct use CELLWIDTH and CELLHEIGHT in calculation
Fore set update area use invalidateRect (still need use some hardcoded values :( )
Rewrite cell_draw_line
Rewrite many hardcoded size definitions
Refrence point now draw as bitmap (less size, more costumable)
Fix drag marker (now correct search closest index in search_nearest_index)
Rewrite plot_into_index, now correct use size definitions, moe
ui.c
Small rewrite keyboard definitions, for use less flash size
Define KP_WIDTH, KP_HEIGHT for set key size
Better look some big font symvols
All:
use static fore some local functions (use less space on calls)
replace tabs on spaces (code style)
Use M_PI from math.h fore define pi value
Fix printf on print HEX values
2020-02-22 08:50:54 +01:00
|
|
|
int x = KP_GET_X(keypads[i].x);
|
|
|
|
|
int y = KP_GET_Y(keypads[i].y);
|
2020-07-13 15:14:15 +02:00
|
|
|
draw_button(x, y, KP_WIDTH, KP_HEIGHT, &button);
|
2020-03-21 00:03:09 +01:00
|
|
|
ili9341_drawfont(keypads[i].c,
|
|
|
|
|
x + (KP_WIDTH - NUM_FONT_GET_WIDTH) / 2,
|
|
|
|
|
y + (KP_HEIGHT - NUM_FONT_GET_HEIGHT) / 2);
|
2016-12-04 08:19:31 +01:00
|
|
|
i++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
Big code redisign (increase CELL draw size, more faster screen render), also save about 4-5kB flash size
Try remove all hardcoded values from code (use definition if set)
Some error fix
main.c:
Rewrite Shell, now it run on main thread and require less RAM (not need stack)
(possible run it as thread if define VNA_SHELL_THREAD
Remove not used trace_info[].scale_unit in set_trace_scale/get_trace_scale (it just divede on set and multiple on get, better use it for default scale set)
Replace some hardcoded values
MARKERS_MAX
SAVEAREA_MAX
TRACES_MAX
plot.c
Rewrite CELLWIDTH and CELLHEIGHT use, now possible set any CELL width and height (CELLWIDTH * CELLHEIGHT <= spi_buffer size)
Free RAM from shell stack use fore increase spi_buffer size now it have 2048 pixel (64x32)
Rewrite cell index and markmap use (now correct use cell size, and more faster), correct use CELLWIDTH and CELLHEIGHT in calculation
Fore set update area use invalidateRect (still need use some hardcoded values :( )
Rewrite cell_draw_line
Rewrite many hardcoded size definitions
Refrence point now draw as bitmap (less size, more costumable)
Fix drag marker (now correct search closest index in search_nearest_index)
Rewrite plot_into_index, now correct use size definitions, moe
ui.c
Small rewrite keyboard definitions, for use less flash size
Define KP_WIDTH, KP_HEIGHT for set key size
Better look some big font symvols
All:
use static fore some local functions (use less space on calls)
replace tabs on spaces (code style)
Use M_PI from math.h fore define pi value
Fix printf on print HEX values
2020-02-22 08:50:54 +01:00
|
|
|
static void
|
2017-09-30 16:06:21 +02:00
|
|
|
draw_numeric_area_frame(void)
|
2016-12-04 08:19:31 +01:00
|
|
|
{
|
2020-07-15 13:34:50 +02:00
|
|
|
ili9341_fill(0, LCD_HEIGHT-NUM_INPUT_HEIGHT, LCD_WIDTH, NUM_INPUT_HEIGHT, DEFAULT_FG_COLOR);
|
2020-03-21 00:03:09 +01:00
|
|
|
ili9341_set_foreground(DEFAULT_MENU_TEXT_COLOR);
|
2020-07-15 13:34:50 +02:00
|
|
|
ili9341_set_background(DEFAULT_FG_COLOR);
|
2020-07-09 10:59:33 +02:00
|
|
|
ili9341_drawstring(keypads_mode_tbl[keypad_mode].name, 10, LCD_HEIGHT-(FONT_GET_HEIGHT+NUM_INPUT_HEIGHT)/2);
|
2020-01-19 09:16:18 +01:00
|
|
|
//ili9341_drawfont(KP_KEYPAD, 300, 216);
|
2017-09-30 16:06:21 +02:00
|
|
|
}
|
|
|
|
|
|
Big code redisign (increase CELL draw size, more faster screen render), also save about 4-5kB flash size
Try remove all hardcoded values from code (use definition if set)
Some error fix
main.c:
Rewrite Shell, now it run on main thread and require less RAM (not need stack)
(possible run it as thread if define VNA_SHELL_THREAD
Remove not used trace_info[].scale_unit in set_trace_scale/get_trace_scale (it just divede on set and multiple on get, better use it for default scale set)
Replace some hardcoded values
MARKERS_MAX
SAVEAREA_MAX
TRACES_MAX
plot.c
Rewrite CELLWIDTH and CELLHEIGHT use, now possible set any CELL width and height (CELLWIDTH * CELLHEIGHT <= spi_buffer size)
Free RAM from shell stack use fore increase spi_buffer size now it have 2048 pixel (64x32)
Rewrite cell index and markmap use (now correct use cell size, and more faster), correct use CELLWIDTH and CELLHEIGHT in calculation
Fore set update area use invalidateRect (still need use some hardcoded values :( )
Rewrite cell_draw_line
Rewrite many hardcoded size definitions
Refrence point now draw as bitmap (less size, more costumable)
Fix drag marker (now correct search closest index in search_nearest_index)
Rewrite plot_into_index, now correct use size definitions, moe
ui.c
Small rewrite keyboard definitions, for use less flash size
Define KP_WIDTH, KP_HEIGHT for set key size
Better look some big font symvols
All:
use static fore some local functions (use less space on calls)
replace tabs on spaces (code style)
Use M_PI from math.h fore define pi value
Fix printf on print HEX values
2020-02-22 08:50:54 +01:00
|
|
|
static void
|
2017-09-30 16:06:21 +02:00
|
|
|
draw_numeric_input(const char *buf)
|
|
|
|
|
{
|
Big code redisign (increase CELL draw size, more faster screen render), also save about 4-5kB flash size
Try remove all hardcoded values from code (use definition if set)
Some error fix
main.c:
Rewrite Shell, now it run on main thread and require less RAM (not need stack)
(possible run it as thread if define VNA_SHELL_THREAD
Remove not used trace_info[].scale_unit in set_trace_scale/get_trace_scale (it just divede on set and multiple on get, better use it for default scale set)
Replace some hardcoded values
MARKERS_MAX
SAVEAREA_MAX
TRACES_MAX
plot.c
Rewrite CELLWIDTH and CELLHEIGHT use, now possible set any CELL width and height (CELLWIDTH * CELLHEIGHT <= spi_buffer size)
Free RAM from shell stack use fore increase spi_buffer size now it have 2048 pixel (64x32)
Rewrite cell index and markmap use (now correct use cell size, and more faster), correct use CELLWIDTH and CELLHEIGHT in calculation
Fore set update area use invalidateRect (still need use some hardcoded values :( )
Rewrite cell_draw_line
Rewrite many hardcoded size definitions
Refrence point now draw as bitmap (less size, more costumable)
Fix drag marker (now correct search closest index in search_nearest_index)
Rewrite plot_into_index, now correct use size definitions, moe
ui.c
Small rewrite keyboard definitions, for use less flash size
Define KP_WIDTH, KP_HEIGHT for set key size
Better look some big font symvols
All:
use static fore some local functions (use less space on calls)
replace tabs on spaces (code style)
Use M_PI from math.h fore define pi value
Fix printf on print HEX values
2020-02-22 08:50:54 +01:00
|
|
|
int i;
|
|
|
|
|
int x;
|
2017-09-30 16:06:21 +02:00
|
|
|
int focused = FALSE;
|
2020-01-19 09:16:18 +01:00
|
|
|
uint16_t xsim = 0b0010010000000000;
|
|
|
|
|
|
2020-03-31 23:36:43 +02:00
|
|
|
for (i = 0, x = 10 + 10 * FONT_WIDTH + 4; i < 10 && buf[i]; i++, xsim<<=1) {
|
2020-01-19 09:16:18 +01:00
|
|
|
uint16_t fg = DEFAULT_MENU_TEXT_COLOR;
|
2020-07-15 13:34:50 +02:00
|
|
|
uint16_t bg = DEFAULT_FG_COLOR;
|
2017-09-30 16:06:21 +02:00
|
|
|
int c = buf[i];
|
|
|
|
|
if (c == '.')
|
2016-12-04 08:19:31 +01:00
|
|
|
c = KP_PERIOD;
|
2017-09-30 16:06:21 +02:00
|
|
|
else if (c == '-')
|
2016-12-04 08:19:31 +01:00
|
|
|
c = KP_MINUS;
|
Big code redisign (increase CELL draw size, more faster screen render), also save about 4-5kB flash size
Try remove all hardcoded values from code (use definition if set)
Some error fix
main.c:
Rewrite Shell, now it run on main thread and require less RAM (not need stack)
(possible run it as thread if define VNA_SHELL_THREAD
Remove not used trace_info[].scale_unit in set_trace_scale/get_trace_scale (it just divede on set and multiple on get, better use it for default scale set)
Replace some hardcoded values
MARKERS_MAX
SAVEAREA_MAX
TRACES_MAX
plot.c
Rewrite CELLWIDTH and CELLHEIGHT use, now possible set any CELL width and height (CELLWIDTH * CELLHEIGHT <= spi_buffer size)
Free RAM from shell stack use fore increase spi_buffer size now it have 2048 pixel (64x32)
Rewrite cell index and markmap use (now correct use cell size, and more faster), correct use CELLWIDTH and CELLHEIGHT in calculation
Fore set update area use invalidateRect (still need use some hardcoded values :( )
Rewrite cell_draw_line
Rewrite many hardcoded size definitions
Refrence point now draw as bitmap (less size, more costumable)
Fix drag marker (now correct search closest index in search_nearest_index)
Rewrite plot_into_index, now correct use size definitions, moe
ui.c
Small rewrite keyboard definitions, for use less flash size
Define KP_WIDTH, KP_HEIGHT for set key size
Better look some big font symvols
All:
use static fore some local functions (use less space on calls)
replace tabs on spaces (code style)
Use M_PI from math.h fore define pi value
Fix printf on print HEX values
2020-02-22 08:50:54 +01:00
|
|
|
else// if (c >= '0' && c <= '9')
|
2017-09-30 16:06:21 +02:00
|
|
|
c = c - '0';
|
Big code redisign (increase CELL draw size, more faster screen render), also save about 4-5kB flash size
Try remove all hardcoded values from code (use definition if set)
Some error fix
main.c:
Rewrite Shell, now it run on main thread and require less RAM (not need stack)
(possible run it as thread if define VNA_SHELL_THREAD
Remove not used trace_info[].scale_unit in set_trace_scale/get_trace_scale (it just divede on set and multiple on get, better use it for default scale set)
Replace some hardcoded values
MARKERS_MAX
SAVEAREA_MAX
TRACES_MAX
plot.c
Rewrite CELLWIDTH and CELLHEIGHT use, now possible set any CELL width and height (CELLWIDTH * CELLHEIGHT <= spi_buffer size)
Free RAM from shell stack use fore increase spi_buffer size now it have 2048 pixel (64x32)
Rewrite cell index and markmap use (now correct use cell size, and more faster), correct use CELLWIDTH and CELLHEIGHT in calculation
Fore set update area use invalidateRect (still need use some hardcoded values :( )
Rewrite cell_draw_line
Rewrite many hardcoded size definitions
Refrence point now draw as bitmap (less size, more costumable)
Fix drag marker (now correct search closest index in search_nearest_index)
Rewrite plot_into_index, now correct use size definitions, moe
ui.c
Small rewrite keyboard definitions, for use less flash size
Define KP_WIDTH, KP_HEIGHT for set key size
Better look some big font symvols
All:
use static fore some local functions (use less space on calls)
replace tabs on spaces (code style)
Use M_PI from math.h fore define pi value
Fix printf on print HEX values
2020-02-22 08:50:54 +01:00
|
|
|
if (ui_mode == UI_NUMERIC && uistat.digit == 8-i) {
|
2020-01-25 18:54:03 +01:00
|
|
|
fg = DEFAULT_SPEC_INPUT_COLOR;
|
2020-07-15 13:34:50 +02:00
|
|
|
focused = true;
|
|
|
|
|
if (uistat.digit_mode){
|
|
|
|
|
bg = DEFAULT_SPEC_INPUT_COLOR;
|
|
|
|
|
fg = DEFAULT_MENU_TEXT_COLOR;
|
|
|
|
|
}
|
2017-09-30 16:06:21 +02:00
|
|
|
}
|
2020-03-21 00:03:09 +01:00
|
|
|
ili9341_set_foreground(fg);
|
|
|
|
|
ili9341_set_background(bg);
|
2020-07-15 13:34:50 +02:00
|
|
|
if (c < 0 && focused) c = 0;
|
Big code redisign (increase CELL draw size, more faster screen render), also save about 4-5kB flash size
Try remove all hardcoded values from code (use definition if set)
Some error fix
main.c:
Rewrite Shell, now it run on main thread and require less RAM (not need stack)
(possible run it as thread if define VNA_SHELL_THREAD
Remove not used trace_info[].scale_unit in set_trace_scale/get_trace_scale (it just divede on set and multiple on get, better use it for default scale set)
Replace some hardcoded values
MARKERS_MAX
SAVEAREA_MAX
TRACES_MAX
plot.c
Rewrite CELLWIDTH and CELLHEIGHT use, now possible set any CELL width and height (CELLWIDTH * CELLHEIGHT <= spi_buffer size)
Free RAM from shell stack use fore increase spi_buffer size now it have 2048 pixel (64x32)
Rewrite cell index and markmap use (now correct use cell size, and more faster), correct use CELLWIDTH and CELLHEIGHT in calculation
Fore set update area use invalidateRect (still need use some hardcoded values :( )
Rewrite cell_draw_line
Rewrite many hardcoded size definitions
Refrence point now draw as bitmap (less size, more costumable)
Fix drag marker (now correct search closest index in search_nearest_index)
Rewrite plot_into_index, now correct use size definitions, moe
ui.c
Small rewrite keyboard definitions, for use less flash size
Define KP_WIDTH, KP_HEIGHT for set key size
Better look some big font symvols
All:
use static fore some local functions (use less space on calls)
replace tabs on spaces (code style)
Use M_PI from math.h fore define pi value
Fix printf on print HEX values
2020-02-22 08:50:54 +01:00
|
|
|
if (c >= 0) // c is number
|
2020-03-30 19:01:51 +02:00
|
|
|
ili9341_drawfont(c, x, LCD_HEIGHT-NUM_INPUT_HEIGHT+4);
|
2020-07-15 13:34:50 +02:00
|
|
|
else // erase
|
2020-03-30 19:01:51 +02:00
|
|
|
ili9341_fill(x, LCD_HEIGHT-NUM_INPUT_HEIGHT+4, NUM_FONT_GET_HEIGHT, NUM_FONT_GET_WIDTH+2+8, bg);
|
2020-03-21 00:03:09 +01:00
|
|
|
|
Big code redisign (increase CELL draw size, more faster screen render), also save about 4-5kB flash size
Try remove all hardcoded values from code (use definition if set)
Some error fix
main.c:
Rewrite Shell, now it run on main thread and require less RAM (not need stack)
(possible run it as thread if define VNA_SHELL_THREAD
Remove not used trace_info[].scale_unit in set_trace_scale/get_trace_scale (it just divede on set and multiple on get, better use it for default scale set)
Replace some hardcoded values
MARKERS_MAX
SAVEAREA_MAX
TRACES_MAX
plot.c
Rewrite CELLWIDTH and CELLHEIGHT use, now possible set any CELL width and height (CELLWIDTH * CELLHEIGHT <= spi_buffer size)
Free RAM from shell stack use fore increase spi_buffer size now it have 2048 pixel (64x32)
Rewrite cell index and markmap use (now correct use cell size, and more faster), correct use CELLWIDTH and CELLHEIGHT in calculation
Fore set update area use invalidateRect (still need use some hardcoded values :( )
Rewrite cell_draw_line
Rewrite many hardcoded size definitions
Refrence point now draw as bitmap (less size, more costumable)
Fix drag marker (now correct search closest index in search_nearest_index)
Rewrite plot_into_index, now correct use size definitions, moe
ui.c
Small rewrite keyboard definitions, for use less flash size
Define KP_WIDTH, KP_HEIGHT for set key size
Better look some big font symvols
All:
use static fore some local functions (use less space on calls)
replace tabs on spaces (code style)
Use M_PI from math.h fore define pi value
Fix printf on print HEX values
2020-02-22 08:50:54 +01:00
|
|
|
x += xsim&0x8000 ? NUM_FONT_GET_WIDTH+2+8 : NUM_FONT_GET_WIDTH+2;
|
2019-09-05 13:58:10 +02:00
|
|
|
}
|
Big code redisign (increase CELL draw size, more faster screen render), also save about 4-5kB flash size
Try remove all hardcoded values from code (use definition if set)
Some error fix
main.c:
Rewrite Shell, now it run on main thread and require less RAM (not need stack)
(possible run it as thread if define VNA_SHELL_THREAD
Remove not used trace_info[].scale_unit in set_trace_scale/get_trace_scale (it just divede on set and multiple on get, better use it for default scale set)
Replace some hardcoded values
MARKERS_MAX
SAVEAREA_MAX
TRACES_MAX
plot.c
Rewrite CELLWIDTH and CELLHEIGHT use, now possible set any CELL width and height (CELLWIDTH * CELLHEIGHT <= spi_buffer size)
Free RAM from shell stack use fore increase spi_buffer size now it have 2048 pixel (64x32)
Rewrite cell index and markmap use (now correct use cell size, and more faster), correct use CELLWIDTH and CELLHEIGHT in calculation
Fore set update area use invalidateRect (still need use some hardcoded values :( )
Rewrite cell_draw_line
Rewrite many hardcoded size definitions
Refrence point now draw as bitmap (less size, more costumable)
Fix drag marker (now correct search closest index in search_nearest_index)
Rewrite plot_into_index, now correct use size definitions, moe
ui.c
Small rewrite keyboard definitions, for use less flash size
Define KP_WIDTH, KP_HEIGHT for set key size
Better look some big font symvols
All:
use static fore some local functions (use less space on calls)
replace tabs on spaces (code style)
Use M_PI from math.h fore define pi value
Fix printf on print HEX values
2020-02-22 08:50:54 +01:00
|
|
|
// erase last
|
2020-07-15 13:34:50 +02:00
|
|
|
ili9341_fill(x, LCD_HEIGHT-NUM_INPUT_HEIGHT+4, NUM_FONT_GET_WIDTH+2+8, NUM_FONT_GET_WIDTH+2+8, DEFAULT_FG_COLOR);
|
2016-12-04 08:19:31 +01:00
|
|
|
}
|
|
|
|
|
|
2017-01-02 08:33:10 +01:00
|
|
|
static int
|
2020-07-09 19:41:24 +02:00
|
|
|
menu_is_multiline(const char *label)
|
2017-01-02 08:33:10 +01:00
|
|
|
{
|
2020-07-09 19:41:24 +02:00
|
|
|
int n = 1;
|
|
|
|
|
while (*label)
|
|
|
|
|
if (*label++ == '\n')
|
|
|
|
|
n++;
|
|
|
|
|
return n;
|
2017-01-02 08:33:10 +01:00
|
|
|
}
|
2016-11-19 05:11:49 +01:00
|
|
|
|
2020-07-13 23:15:46 +02:00
|
|
|
#if 0
|
2020-07-15 13:34:50 +02:00
|
|
|
// Obsolete, now use ADV_CALLBACK for change settings
|
2017-01-05 15:28:32 +01:00
|
|
|
static void
|
2020-07-13 15:14:15 +02:00
|
|
|
menu_item_modify_attribute(const menuitem_t *menu, int item, button_t *b)
|
2017-01-05 15:28:32 +01:00
|
|
|
{
|
2020-07-03 21:03:54 +02:00
|
|
|
bool swap = false;
|
2020-02-26 21:30:50 +01:00
|
|
|
if (menu == menu_trace && item < TRACES_MAX) {
|
2020-07-03 21:03:54 +02:00
|
|
|
if (trace[item].enabled){
|
2020-07-13 15:14:15 +02:00
|
|
|
b->bg = config.trace_color[item];
|
|
|
|
|
if (item == selection) b->fg = ~config.trace_color[item];
|
|
|
|
|
swap = true;
|
2019-11-30 02:17:14 +01:00
|
|
|
}
|
2020-07-03 21:03:54 +02:00
|
|
|
} else if (menu == menu_marker_sel) {
|
|
|
|
|
if ((item < 4 && markers[item].enabled) ||
|
|
|
|
|
(item == 5 && uistat.marker_delta))
|
|
|
|
|
swap = true;
|
|
|
|
|
else if (item == 5 && uistat.marker_delta)
|
|
|
|
|
swap = true;
|
2020-01-18 14:27:56 +01:00
|
|
|
} else if (menu == menu_marker_search) {
|
2020-07-03 21:03:54 +02:00
|
|
|
if (item == 4 && uistat.marker_tracking)
|
|
|
|
|
swap = true;
|
2019-11-30 02:17:14 +01:00
|
|
|
} else if (menu == menu_marker_smith) {
|
2020-07-03 21:03:54 +02:00
|
|
|
if (marker_smith_format == item)
|
|
|
|
|
swap = true;
|
2017-01-05 15:28:32 +01:00
|
|
|
} else if (menu == menu_calop) {
|
2017-01-16 17:49:22 +01:00
|
|
|
if ((item == 0 && (cal_status & CALSTAT_OPEN))
|
|
|
|
|
|| (item == 1 && (cal_status & CALSTAT_SHORT))
|
|
|
|
|
|| (item == 2 && (cal_status & CALSTAT_LOAD))
|
|
|
|
|
|| (item == 3 && (cal_status & CALSTAT_ISOLN))
|
2020-07-03 21:03:54 +02:00
|
|
|
|| (item == 4 && (cal_status & CALSTAT_THRU)))
|
|
|
|
|
swap = true;
|
2019-08-11 16:57:36 +02:00
|
|
|
} else if (menu == menu_stimulus) {
|
2020-07-03 21:03:54 +02:00
|
|
|
if (item == 5 /* PAUSE */ && !(sweep_mode&SWEEP_ENABLE))
|
|
|
|
|
swap = true;
|
2019-08-11 16:57:36 +02:00
|
|
|
} else if (menu == menu_cal) {
|
2020-07-03 21:03:54 +02:00
|
|
|
if (item == 3 /* CORRECTION */ && (cal_status & CALSTAT_APPLY))
|
|
|
|
|
swap = true;
|
2020-01-14 17:07:40 +01:00
|
|
|
} else if (menu == menu_bandwidth) {
|
2020-07-03 21:03:54 +02:00
|
|
|
if (menu_bandwidth[item].data == config.bandwidth)
|
|
|
|
|
swap = true;
|
2020-04-29 13:32:40 +02:00
|
|
|
} else if (menu == menu_sweep_points) {
|
2020-07-03 21:03:54 +02:00
|
|
|
if (menu_sweep_points[item].data == sweep_points)
|
|
|
|
|
swap = true;
|
2019-09-11 13:47:17 +02:00
|
|
|
} else if (menu == menu_transform) {
|
2020-04-04 07:43:32 +02:00
|
|
|
if ((item == 0 && (domain_mode & DOMAIN_MODE) == DOMAIN_TIME)
|
2019-09-11 16:05:01 +02:00
|
|
|
|| (item == 1 && (domain_mode & TD_FUNC) == TD_FUNC_LOWPASS_IMPULSE)
|
|
|
|
|
|| (item == 2 && (domain_mode & TD_FUNC) == TD_FUNC_LOWPASS_STEP)
|
|
|
|
|
|| (item == 3 && (domain_mode & TD_FUNC) == TD_FUNC_BANDPASS)
|
2020-07-03 21:03:54 +02:00
|
|
|
) swap = true;
|
2019-09-11 13:47:17 +02:00
|
|
|
} else if (menu == menu_transform_window) {
|
2019-09-11 16:05:01 +02:00
|
|
|
if ((item == 0 && (domain_mode & TD_WINDOW) == TD_WINDOW_MINIMUM)
|
|
|
|
|
|| (item == 1 && (domain_mode & TD_WINDOW) == TD_WINDOW_NORMAL)
|
|
|
|
|
|| (item == 2 && (domain_mode & TD_WINDOW) == TD_WINDOW_MAXIMUM)
|
2020-07-03 21:03:54 +02:00
|
|
|
) swap = true;
|
2017-01-05 15:28:32 +01:00
|
|
|
}
|
2020-07-13 23:15:46 +02:00
|
|
|
if (swap) b->icon = BUTTON_ICON_CHECK;
|
2017-01-05 15:28:32 +01:00
|
|
|
}
|
2020-07-13 23:15:46 +02:00
|
|
|
#endif
|
2017-01-05 15:28:32 +01:00
|
|
|
|
2020-07-13 23:15:46 +02:00
|
|
|
#define ICON_WIDTH 16
|
|
|
|
|
#define ICON_HEIGHT 11
|
2020-07-13 15:14:15 +02:00
|
|
|
static const uint16_t check_box[] = {
|
|
|
|
|
0b0011111111110000,
|
|
|
|
|
0b0010000000010000,
|
|
|
|
|
0b0010000000010000,
|
|
|
|
|
0b0010000000010000,
|
|
|
|
|
0b0010000000010000,
|
|
|
|
|
0b0010000000010000,
|
|
|
|
|
0b0010000000010000,
|
|
|
|
|
0b0010000000010000,
|
|
|
|
|
0b0010000000010000,
|
|
|
|
|
0b0010000000010000,
|
|
|
|
|
0b0011111111110000,
|
|
|
|
|
|
|
|
|
|
0b0011111111110000,
|
|
|
|
|
0b0010000000001000,
|
|
|
|
|
0b0010000000011000,
|
|
|
|
|
0b0010000000110000,
|
|
|
|
|
0b0010000001100000,
|
|
|
|
|
0b0010100011010000,
|
|
|
|
|
0b0010110110010000,
|
|
|
|
|
0b0010011100010000,
|
|
|
|
|
0b0010001000010000,
|
|
|
|
|
0b0010000000010000,
|
2020-07-13 23:15:46 +02:00
|
|
|
0b0011111111110000,
|
|
|
|
|
|
|
|
|
|
0b0000000000000000,
|
|
|
|
|
0b0000001111000000,
|
|
|
|
|
0b0000010000100000,
|
|
|
|
|
0b0000100000010000,
|
|
|
|
|
0b0001000000001000,
|
|
|
|
|
0b0001000000001000,
|
|
|
|
|
0b0001000000001000,
|
|
|
|
|
0b0001000000001000,
|
|
|
|
|
0b0000100000010000,
|
|
|
|
|
0b0000010000100000,
|
|
|
|
|
0b0000001111000000,
|
2020-07-15 13:34:50 +02:00
|
|
|
/*
|
2020-07-13 23:15:46 +02:00
|
|
|
0b0000000000000000,
|
|
|
|
|
0b0000001111000000,
|
|
|
|
|
0b0000010000100000,
|
|
|
|
|
0b0000100000010000,
|
|
|
|
|
0b0001000110001000,
|
|
|
|
|
0b0001001111001000,
|
|
|
|
|
0b0001001111001000,
|
|
|
|
|
0b0001000110001000,
|
|
|
|
|
0b0000100000010000,
|
|
|
|
|
0b0000010000100000,
|
|
|
|
|
0b0000001111000000,
|
2020-07-15 13:34:50 +02:00
|
|
|
*/
|
|
|
|
|
0b0000000000000000,
|
|
|
|
|
0b0000001111000000,
|
|
|
|
|
0b0000010000100000,
|
|
|
|
|
0b0000100110010000,
|
|
|
|
|
0b0001001111001000,
|
|
|
|
|
0b0001011111101000,
|
|
|
|
|
0b0001011111101000,
|
|
|
|
|
0b0001001111001000,
|
|
|
|
|
0b0000100110010000,
|
|
|
|
|
0b0000010000100000,
|
|
|
|
|
0b0000001111000000,
|
2020-07-13 15:14:15 +02:00
|
|
|
};
|
|
|
|
|
|
Big code redisign (increase CELL draw size, more faster screen render), also save about 4-5kB flash size
Try remove all hardcoded values from code (use definition if set)
Some error fix
main.c:
Rewrite Shell, now it run on main thread and require less RAM (not need stack)
(possible run it as thread if define VNA_SHELL_THREAD
Remove not used trace_info[].scale_unit in set_trace_scale/get_trace_scale (it just divede on set and multiple on get, better use it for default scale set)
Replace some hardcoded values
MARKERS_MAX
SAVEAREA_MAX
TRACES_MAX
plot.c
Rewrite CELLWIDTH and CELLHEIGHT use, now possible set any CELL width and height (CELLWIDTH * CELLHEIGHT <= spi_buffer size)
Free RAM from shell stack use fore increase spi_buffer size now it have 2048 pixel (64x32)
Rewrite cell index and markmap use (now correct use cell size, and more faster), correct use CELLWIDTH and CELLHEIGHT in calculation
Fore set update area use invalidateRect (still need use some hardcoded values :( )
Rewrite cell_draw_line
Rewrite many hardcoded size definitions
Refrence point now draw as bitmap (less size, more costumable)
Fix drag marker (now correct search closest index in search_nearest_index)
Rewrite plot_into_index, now correct use size definitions, moe
ui.c
Small rewrite keyboard definitions, for use less flash size
Define KP_WIDTH, KP_HEIGHT for set key size
Better look some big font symvols
All:
use static fore some local functions (use less space on calls)
replace tabs on spaces (code style)
Use M_PI from math.h fore define pi value
Fix printf on print HEX values
2020-02-22 08:50:54 +01:00
|
|
|
static void
|
2016-11-19 05:11:49 +01:00
|
|
|
draw_menu_buttons(const menuitem_t *menu)
|
|
|
|
|
{
|
2020-07-03 21:03:54 +02:00
|
|
|
int i = 0, y = 0;
|
|
|
|
|
for (i = 0; i < MENU_BUTTON_MAX; i++, y+=MENU_BUTTON_HEIGHT) {
|
2016-11-19 05:11:49 +01:00
|
|
|
if (menu[i].type == MT_NONE)
|
|
|
|
|
break;
|
2020-02-26 21:30:50 +01:00
|
|
|
if (menu[i].type == MT_BLANK)
|
2016-11-19 05:11:49 +01:00
|
|
|
continue;
|
2020-07-03 21:03:54 +02:00
|
|
|
|
2020-07-13 15:14:15 +02:00
|
|
|
button_t button;
|
2020-07-14 20:30:27 +02:00
|
|
|
button.bg = config.menu_normal_color;
|
2020-07-13 15:14:15 +02:00
|
|
|
button.fg = DEFAULT_MENU_TEXT_COLOR;
|
2020-07-13 23:15:46 +02:00
|
|
|
button.icon = BUTTON_ICON_NONE;
|
2016-12-04 08:19:31 +01:00
|
|
|
// focus only in MENU mode but not in KEYPAD mode
|
2020-07-14 11:21:44 +02:00
|
|
|
if (ui_mode == UI_MENU && i == selection){
|
2020-07-14 20:30:27 +02:00
|
|
|
button.bg = config.menu_active_color;
|
2020-07-14 11:21:44 +02:00
|
|
|
button.border = MENU_BUTTON_BORDER|BUTTON_BORDER_FALLING;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
button.border = MENU_BUTTON_BORDER|BUTTON_BORDER_RISE;
|
2020-07-15 13:34:50 +02:00
|
|
|
|
2020-07-13 23:15:46 +02:00
|
|
|
if (menu[i].type == MT_ADV_CALLBACK){
|
|
|
|
|
menuaction_acb_t cb = (menuaction_acb_t)menu[i].reference;
|
|
|
|
|
if (cb) (*cb)(i, menu[i].data, &button);
|
|
|
|
|
}
|
2020-07-15 13:34:50 +02:00
|
|
|
draw_button(LCD_WIDTH-MENU_BUTTON_WIDTH, y, MENU_BUTTON_WIDTH, MENU_BUTTON_HEIGHT, &button);
|
|
|
|
|
|
2020-07-13 15:14:15 +02:00
|
|
|
ili9341_set_foreground(button.fg);
|
|
|
|
|
ili9341_set_background(button.bg);
|
2020-07-15 13:34:50 +02:00
|
|
|
uint16_t text_offs = LCD_WIDTH-MENU_BUTTON_WIDTH+MENU_BUTTON_BORDER + 5;
|
2020-07-03 21:03:54 +02:00
|
|
|
|
|
|
|
|
|
2020-07-13 23:15:46 +02:00
|
|
|
if (button.icon >=0){
|
|
|
|
|
blit16BitWidthBitmap(LCD_WIDTH-MENU_BUTTON_WIDTH+MENU_BUTTON_BORDER + 1, y+(MENU_BUTTON_HEIGHT-ICON_HEIGHT)/2, ICON_WIDTH, ICON_HEIGHT, &check_box[button.icon*ICON_HEIGHT]);
|
|
|
|
|
text_offs=LCD_WIDTH-MENU_BUTTON_WIDTH+MENU_BUTTON_BORDER+1+ICON_WIDTH;
|
2020-07-13 15:14:15 +02:00
|
|
|
}
|
2020-07-15 13:34:50 +02:00
|
|
|
int lines = menu_is_multiline(menu[i].label);
|
2020-07-13 15:14:15 +02:00
|
|
|
ili9341_drawstring(menu[i].label, text_offs, y+(MENU_BUTTON_HEIGHT-lines*FONT_GET_HEIGHT)/2);
|
2016-11-19 05:11:49 +01:00
|
|
|
}
|
2020-07-03 21:03:54 +02:00
|
|
|
for (; i < MENU_BUTTON_MAX; i++, y+=MENU_BUTTON_HEIGHT) {
|
|
|
|
|
ili9341_fill(LCD_WIDTH-MENU_BUTTON_WIDTH, y, MENU_BUTTON_WIDTH, MENU_BUTTON_HEIGHT, DEFAULT_BG_COLOR);
|
|
|
|
|
}
|
2016-11-19 05:11:49 +01:00
|
|
|
}
|
|
|
|
|
|
Big code redisign (increase CELL draw size, more faster screen render), also save about 4-5kB flash size
Try remove all hardcoded values from code (use definition if set)
Some error fix
main.c:
Rewrite Shell, now it run on main thread and require less RAM (not need stack)
(possible run it as thread if define VNA_SHELL_THREAD
Remove not used trace_info[].scale_unit in set_trace_scale/get_trace_scale (it just divede on set and multiple on get, better use it for default scale set)
Replace some hardcoded values
MARKERS_MAX
SAVEAREA_MAX
TRACES_MAX
plot.c
Rewrite CELLWIDTH and CELLHEIGHT use, now possible set any CELL width and height (CELLWIDTH * CELLHEIGHT <= spi_buffer size)
Free RAM from shell stack use fore increase spi_buffer size now it have 2048 pixel (64x32)
Rewrite cell index and markmap use (now correct use cell size, and more faster), correct use CELLWIDTH and CELLHEIGHT in calculation
Fore set update area use invalidateRect (still need use some hardcoded values :( )
Rewrite cell_draw_line
Rewrite many hardcoded size definitions
Refrence point now draw as bitmap (less size, more costumable)
Fix drag marker (now correct search closest index in search_nearest_index)
Rewrite plot_into_index, now correct use size definitions, moe
ui.c
Small rewrite keyboard definitions, for use less flash size
Define KP_WIDTH, KP_HEIGHT for set key size
Better look some big font symvols
All:
use static fore some local functions (use less space on calls)
replace tabs on spaces (code style)
Use M_PI from math.h fore define pi value
Fix printf on print HEX values
2020-02-22 08:50:54 +01:00
|
|
|
static void
|
2016-12-17 10:32:27 +01:00
|
|
|
menu_select_touch(int i)
|
|
|
|
|
{
|
|
|
|
|
selection = i;
|
|
|
|
|
draw_menu();
|
|
|
|
|
touch_wait_release();
|
2017-02-02 21:58:50 +01:00
|
|
|
selection = -1;
|
|
|
|
|
menu_invoke(i);
|
2016-12-17 10:32:27 +01:00
|
|
|
}
|
|
|
|
|
|
Big code redisign (increase CELL draw size, more faster screen render), also save about 4-5kB flash size
Try remove all hardcoded values from code (use definition if set)
Some error fix
main.c:
Rewrite Shell, now it run on main thread and require less RAM (not need stack)
(possible run it as thread if define VNA_SHELL_THREAD
Remove not used trace_info[].scale_unit in set_trace_scale/get_trace_scale (it just divede on set and multiple on get, better use it for default scale set)
Replace some hardcoded values
MARKERS_MAX
SAVEAREA_MAX
TRACES_MAX
plot.c
Rewrite CELLWIDTH and CELLHEIGHT use, now possible set any CELL width and height (CELLWIDTH * CELLHEIGHT <= spi_buffer size)
Free RAM from shell stack use fore increase spi_buffer size now it have 2048 pixel (64x32)
Rewrite cell index and markmap use (now correct use cell size, and more faster), correct use CELLWIDTH and CELLHEIGHT in calculation
Fore set update area use invalidateRect (still need use some hardcoded values :( )
Rewrite cell_draw_line
Rewrite many hardcoded size definitions
Refrence point now draw as bitmap (less size, more costumable)
Fix drag marker (now correct search closest index in search_nearest_index)
Rewrite plot_into_index, now correct use size definitions, moe
ui.c
Small rewrite keyboard definitions, for use less flash size
Define KP_WIDTH, KP_HEIGHT for set key size
Better look some big font symvols
All:
use static fore some local functions (use less space on calls)
replace tabs on spaces (code style)
Use M_PI from math.h fore define pi value
Fix printf on print HEX values
2020-02-22 08:50:54 +01:00
|
|
|
static void
|
2020-05-25 12:29:34 +02:00
|
|
|
menu_apply_touch(int touch_x, int touch_y)
|
2016-12-17 10:32:27 +01:00
|
|
|
{
|
|
|
|
|
const menuitem_t *menu = menu_stack[menu_current_level];
|
2017-01-01 07:03:41 +01:00
|
|
|
int i;
|
|
|
|
|
|
2020-03-22 17:18:40 +01:00
|
|
|
for (i = 0; i < MENU_BUTTON_MAX; i++) {
|
2016-12-17 10:32:27 +01:00
|
|
|
if (menu[i].type == MT_NONE)
|
|
|
|
|
break;
|
2020-03-21 00:03:09 +01:00
|
|
|
if (menu[i].type == MT_BLANK)
|
2016-12-17 10:32:27 +01:00
|
|
|
continue;
|
2020-02-26 21:30:50 +01:00
|
|
|
int y = MENU_BUTTON_HEIGHT*i;
|
2020-03-30 19:01:51 +02:00
|
|
|
if (y < touch_y && touch_y < y+MENU_BUTTON_HEIGHT && LCD_WIDTH-MENU_BUTTON_WIDTH < touch_x) {
|
2016-12-17 10:32:27 +01:00
|
|
|
menu_select_touch(i);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
touch_wait_release();
|
|
|
|
|
ui_mode_normal();
|
|
|
|
|
}
|
|
|
|
|
|
Big code redisign (increase CELL draw size, more faster screen render), also save about 4-5kB flash size
Try remove all hardcoded values from code (use definition if set)
Some error fix
main.c:
Rewrite Shell, now it run on main thread and require less RAM (not need stack)
(possible run it as thread if define VNA_SHELL_THREAD
Remove not used trace_info[].scale_unit in set_trace_scale/get_trace_scale (it just divede on set and multiple on get, better use it for default scale set)
Replace some hardcoded values
MARKERS_MAX
SAVEAREA_MAX
TRACES_MAX
plot.c
Rewrite CELLWIDTH and CELLHEIGHT use, now possible set any CELL width and height (CELLWIDTH * CELLHEIGHT <= spi_buffer size)
Free RAM from shell stack use fore increase spi_buffer size now it have 2048 pixel (64x32)
Rewrite cell index and markmap use (now correct use cell size, and more faster), correct use CELLWIDTH and CELLHEIGHT in calculation
Fore set update area use invalidateRect (still need use some hardcoded values :( )
Rewrite cell_draw_line
Rewrite many hardcoded size definitions
Refrence point now draw as bitmap (less size, more costumable)
Fix drag marker (now correct search closest index in search_nearest_index)
Rewrite plot_into_index, now correct use size definitions, moe
ui.c
Small rewrite keyboard definitions, for use less flash size
Define KP_WIDTH, KP_HEIGHT for set key size
Better look some big font symvols
All:
use static fore some local functions (use less space on calls)
replace tabs on spaces (code style)
Use M_PI from math.h fore define pi value
Fix printf on print HEX values
2020-02-22 08:50:54 +01:00
|
|
|
static void
|
2016-12-04 08:19:31 +01:00
|
|
|
draw_menu(void)
|
2016-11-18 11:26:53 +01:00
|
|
|
{
|
2016-11-19 05:11:49 +01:00
|
|
|
draw_menu_buttons(menu_stack[menu_current_level]);
|
2016-11-18 11:26:53 +01:00
|
|
|
}
|
|
|
|
|
|
Big code redisign (increase CELL draw size, more faster screen render), also save about 4-5kB flash size
Try remove all hardcoded values from code (use definition if set)
Some error fix
main.c:
Rewrite Shell, now it run on main thread and require less RAM (not need stack)
(possible run it as thread if define VNA_SHELL_THREAD
Remove not used trace_info[].scale_unit in set_trace_scale/get_trace_scale (it just divede on set and multiple on get, better use it for default scale set)
Replace some hardcoded values
MARKERS_MAX
SAVEAREA_MAX
TRACES_MAX
plot.c
Rewrite CELLWIDTH and CELLHEIGHT use, now possible set any CELL width and height (CELLWIDTH * CELLHEIGHT <= spi_buffer size)
Free RAM from shell stack use fore increase spi_buffer size now it have 2048 pixel (64x32)
Rewrite cell index and markmap use (now correct use cell size, and more faster), correct use CELLWIDTH and CELLHEIGHT in calculation
Fore set update area use invalidateRect (still need use some hardcoded values :( )
Rewrite cell_draw_line
Rewrite many hardcoded size definitions
Refrence point now draw as bitmap (less size, more costumable)
Fix drag marker (now correct search closest index in search_nearest_index)
Rewrite plot_into_index, now correct use size definitions, moe
ui.c
Small rewrite keyboard definitions, for use less flash size
Define KP_WIDTH, KP_HEIGHT for set key size
Better look some big font symvols
All:
use static fore some local functions (use less space on calls)
replace tabs on spaces (code style)
Use M_PI from math.h fore define pi value
Fix printf on print HEX values
2020-02-22 08:50:54 +01:00
|
|
|
static void
|
2016-12-04 08:19:31 +01:00
|
|
|
erase_menu_buttons(void)
|
2016-11-18 11:26:53 +01:00
|
|
|
{
|
2020-07-03 21:03:54 +02:00
|
|
|
// ili9341_fill(LCD_WIDTH-MENU_BUTTON_WIDTH, 0, MENU_BUTTON_WIDTH, MENU_BUTTON_HEIGHT*MENU_BUTTON_MAX, DEFAULT_BG_COLOR);
|
2016-11-18 11:26:53 +01:00
|
|
|
}
|
|
|
|
|
|
Big code redisign (increase CELL draw size, more faster screen render), also save about 4-5kB flash size
Try remove all hardcoded values from code (use definition if set)
Some error fix
main.c:
Rewrite Shell, now it run on main thread and require less RAM (not need stack)
(possible run it as thread if define VNA_SHELL_THREAD
Remove not used trace_info[].scale_unit in set_trace_scale/get_trace_scale (it just divede on set and multiple on get, better use it for default scale set)
Replace some hardcoded values
MARKERS_MAX
SAVEAREA_MAX
TRACES_MAX
plot.c
Rewrite CELLWIDTH and CELLHEIGHT use, now possible set any CELL width and height (CELLWIDTH * CELLHEIGHT <= spi_buffer size)
Free RAM from shell stack use fore increase spi_buffer size now it have 2048 pixel (64x32)
Rewrite cell index and markmap use (now correct use cell size, and more faster), correct use CELLWIDTH and CELLHEIGHT in calculation
Fore set update area use invalidateRect (still need use some hardcoded values :( )
Rewrite cell_draw_line
Rewrite many hardcoded size definitions
Refrence point now draw as bitmap (less size, more costumable)
Fix drag marker (now correct search closest index in search_nearest_index)
Rewrite plot_into_index, now correct use size definitions, moe
ui.c
Small rewrite keyboard definitions, for use less flash size
Define KP_WIDTH, KP_HEIGHT for set key size
Better look some big font symvols
All:
use static fore some local functions (use less space on calls)
replace tabs on spaces (code style)
Use M_PI from math.h fore define pi value
Fix printf on print HEX values
2020-02-22 08:50:54 +01:00
|
|
|
static void
|
2017-09-30 16:06:21 +02:00
|
|
|
erase_numeric_input(void)
|
|
|
|
|
{
|
2020-03-30 19:01:51 +02:00
|
|
|
ili9341_fill(0, LCD_HEIGHT-NUM_INPUT_HEIGHT, LCD_WIDTH, NUM_INPUT_HEIGHT, DEFAULT_BG_COLOR);
|
2017-09-30 16:06:21 +02:00
|
|
|
}
|
|
|
|
|
|
Big code redisign (increase CELL draw size, more faster screen render), also save about 4-5kB flash size
Try remove all hardcoded values from code (use definition if set)
Some error fix
main.c:
Rewrite Shell, now it run on main thread and require less RAM (not need stack)
(possible run it as thread if define VNA_SHELL_THREAD
Remove not used trace_info[].scale_unit in set_trace_scale/get_trace_scale (it just divede on set and multiple on get, better use it for default scale set)
Replace some hardcoded values
MARKERS_MAX
SAVEAREA_MAX
TRACES_MAX
plot.c
Rewrite CELLWIDTH and CELLHEIGHT use, now possible set any CELL width and height (CELLWIDTH * CELLHEIGHT <= spi_buffer size)
Free RAM from shell stack use fore increase spi_buffer size now it have 2048 pixel (64x32)
Rewrite cell index and markmap use (now correct use cell size, and more faster), correct use CELLWIDTH and CELLHEIGHT in calculation
Fore set update area use invalidateRect (still need use some hardcoded values :( )
Rewrite cell_draw_line
Rewrite many hardcoded size definitions
Refrence point now draw as bitmap (less size, more costumable)
Fix drag marker (now correct search closest index in search_nearest_index)
Rewrite plot_into_index, now correct use size definitions, moe
ui.c
Small rewrite keyboard definitions, for use less flash size
Define KP_WIDTH, KP_HEIGHT for set key size
Better look some big font symvols
All:
use static fore some local functions (use less space on calls)
replace tabs on spaces (code style)
Use M_PI from math.h fore define pi value
Fix printf on print HEX values
2020-02-22 08:50:54 +01:00
|
|
|
static void
|
2017-09-30 16:06:21 +02:00
|
|
|
leave_ui_mode()
|
|
|
|
|
{
|
|
|
|
|
if (ui_mode == UI_MENU) {
|
|
|
|
|
request_to_draw_cells_behind_menu();
|
|
|
|
|
erase_menu_buttons();
|
|
|
|
|
} else if (ui_mode == UI_NUMERIC) {
|
|
|
|
|
request_to_draw_cells_behind_numeric_input();
|
|
|
|
|
erase_numeric_input();
|
|
|
|
|
}
|
2020-06-16 02:23:10 +02:00
|
|
|
draw_frequencies();
|
2017-09-30 16:06:21 +02:00
|
|
|
}
|
|
|
|
|
|
Big code redisign (increase CELL draw size, more faster screen render), also save about 4-5kB flash size
Try remove all hardcoded values from code (use definition if set)
Some error fix
main.c:
Rewrite Shell, now it run on main thread and require less RAM (not need stack)
(possible run it as thread if define VNA_SHELL_THREAD
Remove not used trace_info[].scale_unit in set_trace_scale/get_trace_scale (it just divede on set and multiple on get, better use it for default scale set)
Replace some hardcoded values
MARKERS_MAX
SAVEAREA_MAX
TRACES_MAX
plot.c
Rewrite CELLWIDTH and CELLHEIGHT use, now possible set any CELL width and height (CELLWIDTH * CELLHEIGHT <= spi_buffer size)
Free RAM from shell stack use fore increase spi_buffer size now it have 2048 pixel (64x32)
Rewrite cell index and markmap use (now correct use cell size, and more faster), correct use CELLWIDTH and CELLHEIGHT in calculation
Fore set update area use invalidateRect (still need use some hardcoded values :( )
Rewrite cell_draw_line
Rewrite many hardcoded size definitions
Refrence point now draw as bitmap (less size, more costumable)
Fix drag marker (now correct search closest index in search_nearest_index)
Rewrite plot_into_index, now correct use size definitions, moe
ui.c
Small rewrite keyboard definitions, for use less flash size
Define KP_WIDTH, KP_HEIGHT for set key size
Better look some big font symvols
All:
use static fore some local functions (use less space on calls)
replace tabs on spaces (code style)
Use M_PI from math.h fore define pi value
Fix printf on print HEX values
2020-02-22 08:50:54 +01:00
|
|
|
static void
|
2017-09-30 16:06:21 +02:00
|
|
|
fetch_numeric_target(void)
|
|
|
|
|
{
|
|
|
|
|
switch (keypad_mode) {
|
|
|
|
|
case KM_START:
|
2017-09-30 17:56:43 +02:00
|
|
|
uistat.value = get_sweep_frequency(ST_START);
|
2017-09-30 16:06:21 +02:00
|
|
|
break;
|
|
|
|
|
case KM_STOP:
|
2017-09-30 17:56:43 +02:00
|
|
|
uistat.value = get_sweep_frequency(ST_STOP);
|
2017-09-30 16:06:21 +02:00
|
|
|
break;
|
|
|
|
|
case KM_CENTER:
|
2017-09-30 17:56:43 +02:00
|
|
|
uistat.value = get_sweep_frequency(ST_CENTER);
|
2017-09-30 16:06:21 +02:00
|
|
|
break;
|
|
|
|
|
case KM_SPAN:
|
2017-09-30 17:56:43 +02:00
|
|
|
uistat.value = get_sweep_frequency(ST_SPAN);
|
2017-09-30 16:06:21 +02:00
|
|
|
break;
|
|
|
|
|
case KM_CW:
|
2017-09-30 17:56:43 +02:00
|
|
|
uistat.value = get_sweep_frequency(ST_CW);
|
2017-09-30 16:06:21 +02:00
|
|
|
break;
|
|
|
|
|
case KM_SCALE:
|
2017-09-30 17:56:43 +02:00
|
|
|
uistat.value = get_trace_scale(uistat.current_trace) * 1000;
|
2017-09-30 16:06:21 +02:00
|
|
|
break;
|
|
|
|
|
case KM_REFPOS:
|
2017-09-30 17:56:43 +02:00
|
|
|
uistat.value = get_trace_refpos(uistat.current_trace) * 1000;
|
2017-09-30 16:06:21 +02:00
|
|
|
break;
|
|
|
|
|
case KM_EDELAY:
|
2017-09-30 17:56:43 +02:00
|
|
|
uistat.value = get_electrical_delay();
|
2017-09-30 16:06:21 +02:00
|
|
|
break;
|
2019-09-10 17:24:06 +02:00
|
|
|
case KM_VELOCITY_FACTOR:
|
2020-01-18 05:03:38 +01:00
|
|
|
uistat.value = velocity_factor * 100;
|
2019-09-10 17:24:06 +02:00
|
|
|
break;
|
2019-09-08 14:39:57 +02:00
|
|
|
case KM_SCALEDELAY:
|
|
|
|
|
uistat.value = get_trace_scale(uistat.current_trace) * 1e12;
|
|
|
|
|
break;
|
2017-09-30 16:06:21 +02:00
|
|
|
}
|
2020-03-21 00:03:09 +01:00
|
|
|
|
2019-08-10 07:15:35 +02:00
|
|
|
{
|
|
|
|
|
uint32_t x = uistat.value;
|
|
|
|
|
int n = 0;
|
|
|
|
|
for (; x >= 10 && n < 9; n++)
|
|
|
|
|
x /= 10;
|
|
|
|
|
uistat.digit = n;
|
|
|
|
|
}
|
2020-03-05 20:36:44 +01:00
|
|
|
// uistat.previous_value = uistat.value;
|
2017-09-30 16:06:21 +02:00
|
|
|
}
|
|
|
|
|
|
Big code redisign (increase CELL draw size, more faster screen render), also save about 4-5kB flash size
Try remove all hardcoded values from code (use definition if set)
Some error fix
main.c:
Rewrite Shell, now it run on main thread and require less RAM (not need stack)
(possible run it as thread if define VNA_SHELL_THREAD
Remove not used trace_info[].scale_unit in set_trace_scale/get_trace_scale (it just divede on set and multiple on get, better use it for default scale set)
Replace some hardcoded values
MARKERS_MAX
SAVEAREA_MAX
TRACES_MAX
plot.c
Rewrite CELLWIDTH and CELLHEIGHT use, now possible set any CELL width and height (CELLWIDTH * CELLHEIGHT <= spi_buffer size)
Free RAM from shell stack use fore increase spi_buffer size now it have 2048 pixel (64x32)
Rewrite cell index and markmap use (now correct use cell size, and more faster), correct use CELLWIDTH and CELLHEIGHT in calculation
Fore set update area use invalidateRect (still need use some hardcoded values :( )
Rewrite cell_draw_line
Rewrite many hardcoded size definitions
Refrence point now draw as bitmap (less size, more costumable)
Fix drag marker (now correct search closest index in search_nearest_index)
Rewrite plot_into_index, now correct use size definitions, moe
ui.c
Small rewrite keyboard definitions, for use less flash size
Define KP_WIDTH, KP_HEIGHT for set key size
Better look some big font symvols
All:
use static fore some local functions (use less space on calls)
replace tabs on spaces (code style)
Use M_PI from math.h fore define pi value
Fix printf on print HEX values
2020-02-22 08:50:54 +01:00
|
|
|
static void
|
|
|
|
|
set_numeric_value(void)
|
2017-09-30 16:06:21 +02:00
|
|
|
{
|
|
|
|
|
switch (keypad_mode) {
|
|
|
|
|
case KM_START:
|
2017-09-30 17:56:43 +02:00
|
|
|
set_sweep_frequency(ST_START, uistat.value);
|
2017-09-30 16:06:21 +02:00
|
|
|
break;
|
|
|
|
|
case KM_STOP:
|
2017-09-30 17:56:43 +02:00
|
|
|
set_sweep_frequency(ST_STOP, uistat.value);
|
2017-09-30 16:06:21 +02:00
|
|
|
break;
|
|
|
|
|
case KM_CENTER:
|
2017-09-30 17:56:43 +02:00
|
|
|
set_sweep_frequency(ST_CENTER, uistat.value);
|
2017-09-30 16:06:21 +02:00
|
|
|
break;
|
|
|
|
|
case KM_SPAN:
|
2017-09-30 17:56:43 +02:00
|
|
|
set_sweep_frequency(ST_SPAN, uistat.value);
|
2017-09-30 16:06:21 +02:00
|
|
|
break;
|
|
|
|
|
case KM_CW:
|
2017-09-30 17:56:43 +02:00
|
|
|
set_sweep_frequency(ST_CW, uistat.value);
|
2017-09-30 16:06:21 +02:00
|
|
|
break;
|
|
|
|
|
case KM_SCALE:
|
2017-09-30 17:56:43 +02:00
|
|
|
set_trace_scale(uistat.current_trace, uistat.value / 1000.0);
|
2017-09-30 16:06:21 +02:00
|
|
|
break;
|
|
|
|
|
case KM_REFPOS:
|
2017-09-30 17:56:43 +02:00
|
|
|
set_trace_refpos(uistat.current_trace, uistat.value / 1000.0);
|
2017-09-30 16:06:21 +02:00
|
|
|
break;
|
|
|
|
|
case KM_EDELAY:
|
2017-09-30 17:56:43 +02:00
|
|
|
set_electrical_delay(uistat.value);
|
2017-09-30 16:06:21 +02:00
|
|
|
break;
|
2019-09-10 17:24:06 +02:00
|
|
|
case KM_VELOCITY_FACTOR:
|
2020-01-26 18:56:45 +01:00
|
|
|
velocity_factor = uistat.value/100.0;
|
2019-09-10 17:24:06 +02:00
|
|
|
break;
|
2017-09-30 16:06:21 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
Big code redisign (increase CELL draw size, more faster screen render), also save about 4-5kB flash size
Try remove all hardcoded values from code (use definition if set)
Some error fix
main.c:
Rewrite Shell, now it run on main thread and require less RAM (not need stack)
(possible run it as thread if define VNA_SHELL_THREAD
Remove not used trace_info[].scale_unit in set_trace_scale/get_trace_scale (it just divede on set and multiple on get, better use it for default scale set)
Replace some hardcoded values
MARKERS_MAX
SAVEAREA_MAX
TRACES_MAX
plot.c
Rewrite CELLWIDTH and CELLHEIGHT use, now possible set any CELL width and height (CELLWIDTH * CELLHEIGHT <= spi_buffer size)
Free RAM from shell stack use fore increase spi_buffer size now it have 2048 pixel (64x32)
Rewrite cell index and markmap use (now correct use cell size, and more faster), correct use CELLWIDTH and CELLHEIGHT in calculation
Fore set update area use invalidateRect (still need use some hardcoded values :( )
Rewrite cell_draw_line
Rewrite many hardcoded size definitions
Refrence point now draw as bitmap (less size, more costumable)
Fix drag marker (now correct search closest index in search_nearest_index)
Rewrite plot_into_index, now correct use size definitions, moe
ui.c
Small rewrite keyboard definitions, for use less flash size
Define KP_WIDTH, KP_HEIGHT for set key size
Better look some big font symvols
All:
use static fore some local functions (use less space on calls)
replace tabs on spaces (code style)
Use M_PI from math.h fore define pi value
Fix printf on print HEX values
2020-02-22 08:50:54 +01:00
|
|
|
static void
|
2017-09-30 16:06:21 +02:00
|
|
|
draw_numeric_area(void)
|
|
|
|
|
{
|
|
|
|
|
char buf[10];
|
Increase screen render (in some cases up to 2x speedup), decrease stack usage (code size less on 1500 bytes)
Write simple profiling definitions
START_PROFILE
STOP_PROFILE
Use it for detect sys tick amount and output to screen
main.c
Reduce VNA_SHELL_MAX_LENGTH to 48, and made shell_line as static (reduce stack usage)
Remove BaseSequentialStream *chp from command calls (use static shell_stream), it reduce code size and stack usage
Use VNA_SHELL_FUNCTION definition for all commands
Remove chMtxLock(&mutex);chMtxUnlock(&mutex); from commands, and define command flag for use it in calls
Apply default scale from trace_info on trace change
Led blink outside from main sweep cycle (better look, and less noise)
Some size fixes
chprintf.c
Implement small memory stream object, only put function and plot_printf(char *str, int size, const char *fmt, ...)
Use it in all code (little increase speed, and huge decrease size)
Restore USE_EXCEPTIONS_STACKSIZE = 0x180 (possible not need, but not good tested)
plot.c
Made huge screen render profile (add some comments)
Not use cell clipping on draw cell data (use constants increase speed, decrease stack usage (not need put it to stack))
Clip cell if need only on screen flush
Use new plot_printf, remove chsnprintf usage
Apply code style
============================================================================================================
Interesting fact
Usage memset(spi_buffer, DEFAULT_BG_COLOR, (h*CELLWIDTH)*sizeof(uint16_t)); dramatically decrease render speed
possibly it fill buffer by 8 bit data, so slow
Usage
uint32_t *p = (uint32_t *)spi_buffer;
while (count--) {
p[0] = DEFAULT_BG_COLOR|(DEFAULT_BG_COLOR<<16);
p[1] = DEFAULT_BG_COLOR|(DEFAULT_BG_COLOR<<16);
p[2] = DEFAULT_BG_COLOR|(DEFAULT_BG_COLOR<<16);
p[3] = DEFAULT_BG_COLOR|(DEFAULT_BG_COLOR<<16);
p+=4;
}
gives x10 speed perfomance
Draw polar and smit grid very slow (but i don`t know how increase it except use bitmaps, but it need about 5-8k flash size and file prepare)
On long lines render slow down, but clipping use more calculation, and not give good result
Need made stack usage check
2020-02-24 20:47:52 +01:00
|
|
|
plot_printf(buf, sizeof buf, "%9d", uistat.value);
|
2017-09-30 16:06:21 +02:00
|
|
|
draw_numeric_input(buf);
|
|
|
|
|
}
|
|
|
|
|
|
Big code redisign (increase CELL draw size, more faster screen render), also save about 4-5kB flash size
Try remove all hardcoded values from code (use definition if set)
Some error fix
main.c:
Rewrite Shell, now it run on main thread and require less RAM (not need stack)
(possible run it as thread if define VNA_SHELL_THREAD
Remove not used trace_info[].scale_unit in set_trace_scale/get_trace_scale (it just divede on set and multiple on get, better use it for default scale set)
Replace some hardcoded values
MARKERS_MAX
SAVEAREA_MAX
TRACES_MAX
plot.c
Rewrite CELLWIDTH and CELLHEIGHT use, now possible set any CELL width and height (CELLWIDTH * CELLHEIGHT <= spi_buffer size)
Free RAM from shell stack use fore increase spi_buffer size now it have 2048 pixel (64x32)
Rewrite cell index and markmap use (now correct use cell size, and more faster), correct use CELLWIDTH and CELLHEIGHT in calculation
Fore set update area use invalidateRect (still need use some hardcoded values :( )
Rewrite cell_draw_line
Rewrite many hardcoded size definitions
Refrence point now draw as bitmap (less size, more costumable)
Fix drag marker (now correct search closest index in search_nearest_index)
Rewrite plot_into_index, now correct use size definitions, moe
ui.c
Small rewrite keyboard definitions, for use less flash size
Define KP_WIDTH, KP_HEIGHT for set key size
Better look some big font symvols
All:
use static fore some local functions (use less space on calls)
replace tabs on spaces (code style)
Use M_PI from math.h fore define pi value
Fix printf on print HEX values
2020-02-22 08:50:54 +01:00
|
|
|
static void
|
2016-12-04 08:19:31 +01:00
|
|
|
ui_mode_menu(void)
|
|
|
|
|
{
|
2020-03-21 00:03:09 +01:00
|
|
|
if (ui_mode == UI_MENU)
|
2016-12-04 08:19:31 +01:00
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
ui_mode = UI_MENU;
|
2017-01-02 07:45:25 +01:00
|
|
|
/* narrowen plotting area */
|
2020-02-26 21:30:50 +01:00
|
|
|
area_width = AREA_WIDTH_NORMAL - MENU_BUTTON_WIDTH;
|
Big code redisign (increase CELL draw size, more faster screen render), also save about 4-5kB flash size
Try remove all hardcoded values from code (use definition if set)
Some error fix
main.c:
Rewrite Shell, now it run on main thread and require less RAM (not need stack)
(possible run it as thread if define VNA_SHELL_THREAD
Remove not used trace_info[].scale_unit in set_trace_scale/get_trace_scale (it just divede on set and multiple on get, better use it for default scale set)
Replace some hardcoded values
MARKERS_MAX
SAVEAREA_MAX
TRACES_MAX
plot.c
Rewrite CELLWIDTH and CELLHEIGHT use, now possible set any CELL width and height (CELLWIDTH * CELLHEIGHT <= spi_buffer size)
Free RAM from shell stack use fore increase spi_buffer size now it have 2048 pixel (64x32)
Rewrite cell index and markmap use (now correct use cell size, and more faster), correct use CELLWIDTH and CELLHEIGHT in calculation
Fore set update area use invalidateRect (still need use some hardcoded values :( )
Rewrite cell_draw_line
Rewrite many hardcoded size definitions
Refrence point now draw as bitmap (less size, more costumable)
Fix drag marker (now correct search closest index in search_nearest_index)
Rewrite plot_into_index, now correct use size definitions, moe
ui.c
Small rewrite keyboard definitions, for use less flash size
Define KP_WIDTH, KP_HEIGHT for set key size
Better look some big font symvols
All:
use static fore some local functions (use less space on calls)
replace tabs on spaces (code style)
Use M_PI from math.h fore define pi value
Fix printf on print HEX values
2020-02-22 08:50:54 +01:00
|
|
|
area_height = AREA_HEIGHT_NORMAL;
|
2016-12-04 08:19:31 +01:00
|
|
|
ensure_selection();
|
|
|
|
|
draw_menu();
|
|
|
|
|
}
|
|
|
|
|
|
Big code redisign (increase CELL draw size, more faster screen render), also save about 4-5kB flash size
Try remove all hardcoded values from code (use definition if set)
Some error fix
main.c:
Rewrite Shell, now it run on main thread and require less RAM (not need stack)
(possible run it as thread if define VNA_SHELL_THREAD
Remove not used trace_info[].scale_unit in set_trace_scale/get_trace_scale (it just divede on set and multiple on get, better use it for default scale set)
Replace some hardcoded values
MARKERS_MAX
SAVEAREA_MAX
TRACES_MAX
plot.c
Rewrite CELLWIDTH and CELLHEIGHT use, now possible set any CELL width and height (CELLWIDTH * CELLHEIGHT <= spi_buffer size)
Free RAM from shell stack use fore increase spi_buffer size now it have 2048 pixel (64x32)
Rewrite cell index and markmap use (now correct use cell size, and more faster), correct use CELLWIDTH and CELLHEIGHT in calculation
Fore set update area use invalidateRect (still need use some hardcoded values :( )
Rewrite cell_draw_line
Rewrite many hardcoded size definitions
Refrence point now draw as bitmap (less size, more costumable)
Fix drag marker (now correct search closest index in search_nearest_index)
Rewrite plot_into_index, now correct use size definitions, moe
ui.c
Small rewrite keyboard definitions, for use less flash size
Define KP_WIDTH, KP_HEIGHT for set key size
Better look some big font symvols
All:
use static fore some local functions (use less space on calls)
replace tabs on spaces (code style)
Use M_PI from math.h fore define pi value
Fix printf on print HEX values
2020-02-22 08:50:54 +01:00
|
|
|
static void
|
2017-09-30 16:06:21 +02:00
|
|
|
ui_mode_numeric(int _keypad_mode)
|
|
|
|
|
{
|
2020-03-21 00:03:09 +01:00
|
|
|
if (ui_mode == UI_NUMERIC)
|
2017-09-30 16:06:21 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
leave_ui_mode();
|
2020-03-21 00:03:09 +01:00
|
|
|
|
2017-09-30 16:06:21 +02:00
|
|
|
// keypads array
|
|
|
|
|
keypad_mode = _keypad_mode;
|
|
|
|
|
ui_mode = UI_NUMERIC;
|
|
|
|
|
area_width = AREA_WIDTH_NORMAL;
|
2020-03-30 19:01:51 +02:00
|
|
|
area_height = LCD_HEIGHT-NUM_INPUT_HEIGHT;//AREA_HEIGHT_NORMAL - 32;
|
2017-09-30 16:06:21 +02:00
|
|
|
|
|
|
|
|
draw_numeric_area_frame();
|
|
|
|
|
fetch_numeric_target();
|
|
|
|
|
draw_numeric_area();
|
|
|
|
|
}
|
|
|
|
|
|
Big code redisign (increase CELL draw size, more faster screen render), also save about 4-5kB flash size
Try remove all hardcoded values from code (use definition if set)
Some error fix
main.c:
Rewrite Shell, now it run on main thread and require less RAM (not need stack)
(possible run it as thread if define VNA_SHELL_THREAD
Remove not used trace_info[].scale_unit in set_trace_scale/get_trace_scale (it just divede on set and multiple on get, better use it for default scale set)
Replace some hardcoded values
MARKERS_MAX
SAVEAREA_MAX
TRACES_MAX
plot.c
Rewrite CELLWIDTH and CELLHEIGHT use, now possible set any CELL width and height (CELLWIDTH * CELLHEIGHT <= spi_buffer size)
Free RAM from shell stack use fore increase spi_buffer size now it have 2048 pixel (64x32)
Rewrite cell index and markmap use (now correct use cell size, and more faster), correct use CELLWIDTH and CELLHEIGHT in calculation
Fore set update area use invalidateRect (still need use some hardcoded values :( )
Rewrite cell_draw_line
Rewrite many hardcoded size definitions
Refrence point now draw as bitmap (less size, more costumable)
Fix drag marker (now correct search closest index in search_nearest_index)
Rewrite plot_into_index, now correct use size definitions, moe
ui.c
Small rewrite keyboard definitions, for use less flash size
Define KP_WIDTH, KP_HEIGHT for set key size
Better look some big font symvols
All:
use static fore some local functions (use less space on calls)
replace tabs on spaces (code style)
Use M_PI from math.h fore define pi value
Fix printf on print HEX values
2020-02-22 08:50:54 +01:00
|
|
|
static void
|
2016-12-04 08:19:31 +01:00
|
|
|
ui_mode_keypad(int _keypad_mode)
|
2016-11-18 11:26:53 +01:00
|
|
|
{
|
2020-03-21 00:03:09 +01:00
|
|
|
if (ui_mode == UI_KEYPAD)
|
2016-12-04 08:19:31 +01:00
|
|
|
return;
|
|
|
|
|
|
2017-02-03 13:18:33 +01:00
|
|
|
// keypads array
|
|
|
|
|
keypad_mode = _keypad_mode;
|
2020-07-09 10:59:33 +02:00
|
|
|
keypads = keypads_mode_tbl[keypad_mode].keypad_type;
|
2017-02-03 13:18:33 +01:00
|
|
|
int i;
|
2020-07-05 11:33:40 +02:00
|
|
|
for (i = 0; keypads[i+1].c != KP_NONE; i++)
|
2017-02-03 13:18:33 +01:00
|
|
|
;
|
|
|
|
|
keypads_last_index = i;
|
|
|
|
|
|
2016-12-04 08:19:31 +01:00
|
|
|
ui_mode = UI_KEYPAD;
|
2020-02-27 18:53:45 +01:00
|
|
|
area_width = AREA_WIDTH_NORMAL - MENU_BUTTON_WIDTH;
|
2020-07-13 05:56:49 +02:00
|
|
|
area_height = LCD_HEIGHT-NUM_INPUT_HEIGHT;
|
2016-12-04 08:19:31 +01:00
|
|
|
draw_menu();
|
|
|
|
|
draw_keypad();
|
2017-09-30 16:58:31 +02:00
|
|
|
draw_numeric_area_frame();
|
2016-12-04 08:19:31 +01:00
|
|
|
draw_numeric_input("");
|
2016-11-18 11:26:53 +01:00
|
|
|
}
|
|
|
|
|
|
Big code redisign (increase CELL draw size, more faster screen render), also save about 4-5kB flash size
Try remove all hardcoded values from code (use definition if set)
Some error fix
main.c:
Rewrite Shell, now it run on main thread and require less RAM (not need stack)
(possible run it as thread if define VNA_SHELL_THREAD
Remove not used trace_info[].scale_unit in set_trace_scale/get_trace_scale (it just divede on set and multiple on get, better use it for default scale set)
Replace some hardcoded values
MARKERS_MAX
SAVEAREA_MAX
TRACES_MAX
plot.c
Rewrite CELLWIDTH and CELLHEIGHT use, now possible set any CELL width and height (CELLWIDTH * CELLHEIGHT <= spi_buffer size)
Free RAM from shell stack use fore increase spi_buffer size now it have 2048 pixel (64x32)
Rewrite cell index and markmap use (now correct use cell size, and more faster), correct use CELLWIDTH and CELLHEIGHT in calculation
Fore set update area use invalidateRect (still need use some hardcoded values :( )
Rewrite cell_draw_line
Rewrite many hardcoded size definitions
Refrence point now draw as bitmap (less size, more costumable)
Fix drag marker (now correct search closest index in search_nearest_index)
Rewrite plot_into_index, now correct use size definitions, moe
ui.c
Small rewrite keyboard definitions, for use less flash size
Define KP_WIDTH, KP_HEIGHT for set key size
Better look some big font symvols
All:
use static fore some local functions (use less space on calls)
replace tabs on spaces (code style)
Use M_PI from math.h fore define pi value
Fix printf on print HEX values
2020-02-22 08:50:54 +01:00
|
|
|
static void
|
2016-12-04 08:19:31 +01:00
|
|
|
ui_mode_normal(void)
|
2016-11-18 11:26:53 +01:00
|
|
|
{
|
2020-03-21 00:03:09 +01:00
|
|
|
if (ui_mode == UI_NORMAL)
|
2016-12-04 08:19:31 +01:00
|
|
|
return;
|
|
|
|
|
|
Big code redisign (increase CELL draw size, more faster screen render), also save about 4-5kB flash size
Try remove all hardcoded values from code (use definition if set)
Some error fix
main.c:
Rewrite Shell, now it run on main thread and require less RAM (not need stack)
(possible run it as thread if define VNA_SHELL_THREAD
Remove not used trace_info[].scale_unit in set_trace_scale/get_trace_scale (it just divede on set and multiple on get, better use it for default scale set)
Replace some hardcoded values
MARKERS_MAX
SAVEAREA_MAX
TRACES_MAX
plot.c
Rewrite CELLWIDTH and CELLHEIGHT use, now possible set any CELL width and height (CELLWIDTH * CELLHEIGHT <= spi_buffer size)
Free RAM from shell stack use fore increase spi_buffer size now it have 2048 pixel (64x32)
Rewrite cell index and markmap use (now correct use cell size, and more faster), correct use CELLWIDTH and CELLHEIGHT in calculation
Fore set update area use invalidateRect (still need use some hardcoded values :( )
Rewrite cell_draw_line
Rewrite many hardcoded size definitions
Refrence point now draw as bitmap (less size, more costumable)
Fix drag marker (now correct search closest index in search_nearest_index)
Rewrite plot_into_index, now correct use size definitions, moe
ui.c
Small rewrite keyboard definitions, for use less flash size
Define KP_WIDTH, KP_HEIGHT for set key size
Better look some big font symvols
All:
use static fore some local functions (use less space on calls)
replace tabs on spaces (code style)
Use M_PI from math.h fore define pi value
Fix printf on print HEX values
2020-02-22 08:50:54 +01:00
|
|
|
area_width = AREA_WIDTH_NORMAL;
|
|
|
|
|
area_height = AREA_HEIGHT_NORMAL;
|
2017-09-30 16:06:21 +02:00
|
|
|
leave_ui_mode();
|
|
|
|
|
ui_mode = UI_NORMAL;
|
2016-11-18 11:26:53 +01:00
|
|
|
}
|
|
|
|
|
|
2019-11-09 03:20:22 +01:00
|
|
|
static void
|
|
|
|
|
lever_move_marker(int status)
|
|
|
|
|
{
|
|
|
|
|
do {
|
|
|
|
|
if (active_marker >= 0 && markers[active_marker].enabled) {
|
|
|
|
|
if ((status & EVT_DOWN) && markers[active_marker].index > 0) {
|
|
|
|
|
markers[active_marker].index--;
|
|
|
|
|
}
|
2020-03-14 19:23:02 +01:00
|
|
|
if ((status & EVT_UP) && markers[active_marker].index < sweep_points-1) {
|
2019-11-09 03:20:22 +01:00
|
|
|
markers[active_marker].index++;
|
|
|
|
|
}
|
2020-03-22 17:18:40 +01:00
|
|
|
markers[active_marker].frequency = frequencies[markers[active_marker].index];
|
|
|
|
|
redraw_marker(active_marker);
|
2019-11-09 03:20:22 +01:00
|
|
|
}
|
|
|
|
|
status = btn_wait_release();
|
|
|
|
|
} while (status != 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
lever_search_marker(int status)
|
|
|
|
|
{
|
Big code redisign (increase CELL draw size, more faster screen render), also save about 4-5kB flash size
Try remove all hardcoded values from code (use definition if set)
Some error fix
main.c:
Rewrite Shell, now it run on main thread and require less RAM (not need stack)
(possible run it as thread if define VNA_SHELL_THREAD
Remove not used trace_info[].scale_unit in set_trace_scale/get_trace_scale (it just divede on set and multiple on get, better use it for default scale set)
Replace some hardcoded values
MARKERS_MAX
SAVEAREA_MAX
TRACES_MAX
plot.c
Rewrite CELLWIDTH and CELLHEIGHT use, now possible set any CELL width and height (CELLWIDTH * CELLHEIGHT <= spi_buffer size)
Free RAM from shell stack use fore increase spi_buffer size now it have 2048 pixel (64x32)
Rewrite cell index and markmap use (now correct use cell size, and more faster), correct use CELLWIDTH and CELLHEIGHT in calculation
Fore set update area use invalidateRect (still need use some hardcoded values :( )
Rewrite cell_draw_line
Rewrite many hardcoded size definitions
Refrence point now draw as bitmap (less size, more costumable)
Fix drag marker (now correct search closest index in search_nearest_index)
Rewrite plot_into_index, now correct use size definitions, moe
ui.c
Small rewrite keyboard definitions, for use less flash size
Define KP_WIDTH, KP_HEIGHT for set key size
Better look some big font symvols
All:
use static fore some local functions (use less space on calls)
replace tabs on spaces (code style)
Use M_PI from math.h fore define pi value
Fix printf on print HEX values
2020-02-22 08:50:54 +01:00
|
|
|
int i = -1;
|
2019-11-09 03:20:22 +01:00
|
|
|
if (active_marker >= 0) {
|
Big code redisign (increase CELL draw size, more faster screen render), also save about 4-5kB flash size
Try remove all hardcoded values from code (use definition if set)
Some error fix
main.c:
Rewrite Shell, now it run on main thread and require less RAM (not need stack)
(possible run it as thread if define VNA_SHELL_THREAD
Remove not used trace_info[].scale_unit in set_trace_scale/get_trace_scale (it just divede on set and multiple on get, better use it for default scale set)
Replace some hardcoded values
MARKERS_MAX
SAVEAREA_MAX
TRACES_MAX
plot.c
Rewrite CELLWIDTH and CELLHEIGHT use, now possible set any CELL width and height (CELLWIDTH * CELLHEIGHT <= spi_buffer size)
Free RAM from shell stack use fore increase spi_buffer size now it have 2048 pixel (64x32)
Rewrite cell index and markmap use (now correct use cell size, and more faster), correct use CELLWIDTH and CELLHEIGHT in calculation
Fore set update area use invalidateRect (still need use some hardcoded values :( )
Rewrite cell_draw_line
Rewrite many hardcoded size definitions
Refrence point now draw as bitmap (less size, more costumable)
Fix drag marker (now correct search closest index in search_nearest_index)
Rewrite plot_into_index, now correct use size definitions, moe
ui.c
Small rewrite keyboard definitions, for use less flash size
Define KP_WIDTH, KP_HEIGHT for set key size
Better look some big font symvols
All:
use static fore some local functions (use less space on calls)
replace tabs on spaces (code style)
Use M_PI from math.h fore define pi value
Fix printf on print HEX values
2020-02-22 08:50:54 +01:00
|
|
|
if (status & EVT_DOWN)
|
|
|
|
|
i = marker_search_left(markers[active_marker].index);
|
|
|
|
|
else if (status & EVT_UP)
|
|
|
|
|
i = marker_search_right(markers[active_marker].index);
|
2020-03-22 17:18:40 +01:00
|
|
|
if (i != -1){
|
Big code redisign (increase CELL draw size, more faster screen render), also save about 4-5kB flash size
Try remove all hardcoded values from code (use definition if set)
Some error fix
main.c:
Rewrite Shell, now it run on main thread and require less RAM (not need stack)
(possible run it as thread if define VNA_SHELL_THREAD
Remove not used trace_info[].scale_unit in set_trace_scale/get_trace_scale (it just divede on set and multiple on get, better use it for default scale set)
Replace some hardcoded values
MARKERS_MAX
SAVEAREA_MAX
TRACES_MAX
plot.c
Rewrite CELLWIDTH and CELLHEIGHT use, now possible set any CELL width and height (CELLWIDTH * CELLHEIGHT <= spi_buffer size)
Free RAM from shell stack use fore increase spi_buffer size now it have 2048 pixel (64x32)
Rewrite cell index and markmap use (now correct use cell size, and more faster), correct use CELLWIDTH and CELLHEIGHT in calculation
Fore set update area use invalidateRect (still need use some hardcoded values :( )
Rewrite cell_draw_line
Rewrite many hardcoded size definitions
Refrence point now draw as bitmap (less size, more costumable)
Fix drag marker (now correct search closest index in search_nearest_index)
Rewrite plot_into_index, now correct use size definitions, moe
ui.c
Small rewrite keyboard definitions, for use less flash size
Define KP_WIDTH, KP_HEIGHT for set key size
Better look some big font symvols
All:
use static fore some local functions (use less space on calls)
replace tabs on spaces (code style)
Use M_PI from math.h fore define pi value
Fix printf on print HEX values
2020-02-22 08:50:54 +01:00
|
|
|
markers[active_marker].index = i;
|
2020-03-22 17:18:40 +01:00
|
|
|
redraw_marker(active_marker);
|
|
|
|
|
}
|
2019-11-09 03:20:22 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ex. 10942 -> 10000
|
|
|
|
|
// 6791 -> 5000
|
|
|
|
|
// 341 -> 200
|
|
|
|
|
static uint32_t
|
|
|
|
|
step_round(uint32_t v)
|
|
|
|
|
{
|
|
|
|
|
// decade step
|
|
|
|
|
uint32_t x = 1;
|
2020-02-26 21:30:50 +01:00
|
|
|
for (x = 1; x*10 < v; x*= 10)
|
2019-11-09 03:20:22 +01:00
|
|
|
;
|
2020-03-21 00:03:09 +01:00
|
|
|
|
2019-11-09 03:20:22 +01:00
|
|
|
// 1-2-5 step
|
|
|
|
|
if (x * 2 > v)
|
|
|
|
|
return x;
|
|
|
|
|
else if (x * 5 > v)
|
|
|
|
|
return x * 2;
|
2020-03-21 00:03:09 +01:00
|
|
|
else
|
2019-11-09 03:20:22 +01:00
|
|
|
return x * 5;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
lever_zoom_span(int status)
|
|
|
|
|
{
|
2019-11-17 02:54:39 +01:00
|
|
|
uint32_t span = get_sweep_frequency(ST_SPAN);
|
2019-11-09 03:20:22 +01:00
|
|
|
if (status & EVT_UP) {
|
|
|
|
|
span = step_round(span - 1);
|
|
|
|
|
} else if (status & EVT_DOWN) {
|
2019-11-17 02:54:39 +01:00
|
|
|
span = step_round(span + 1);
|
2019-11-09 03:20:22 +01:00
|
|
|
span = step_round(span * 3);
|
|
|
|
|
}
|
2020-01-26 18:56:45 +01:00
|
|
|
set_sweep_frequency(ST_SPAN, span);
|
2019-11-09 03:20:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2020-02-22 14:41:50 +01:00
|
|
|
lever_move(int status, int mode)
|
2019-11-09 03:20:22 +01:00
|
|
|
{
|
2020-02-22 14:41:50 +01:00
|
|
|
uint32_t center = get_sweep_frequency(mode);
|
2019-11-09 03:20:22 +01:00
|
|
|
uint32_t span = get_sweep_frequency(ST_SPAN);
|
|
|
|
|
span = step_round(span / 3);
|
|
|
|
|
if (status & EVT_UP) {
|
2020-02-22 14:41:50 +01:00
|
|
|
set_sweep_frequency(mode, center + span);
|
2019-11-09 03:20:22 +01:00
|
|
|
} else if (status & EVT_DOWN) {
|
2020-02-22 14:41:50 +01:00
|
|
|
set_sweep_frequency(mode, center - span);
|
2019-11-09 03:20:22 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-01 00:50:46 +01:00
|
|
|
#define STEPRATIO 0.2
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
lever_edelay(int status)
|
|
|
|
|
{
|
|
|
|
|
float value = get_electrical_delay();
|
|
|
|
|
float ratio = STEPRATIO;
|
|
|
|
|
if (value < 0)
|
|
|
|
|
ratio = -ratio;
|
|
|
|
|
if (status & EVT_UP) {
|
|
|
|
|
value = (1 - ratio) * value;
|
|
|
|
|
} else if (status & EVT_DOWN) {
|
|
|
|
|
value = (1 + ratio) * value;
|
|
|
|
|
}
|
|
|
|
|
set_electrical_delay(value);
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-27 10:46:26 +02:00
|
|
|
static void
|
2016-12-04 08:19:31 +01:00
|
|
|
ui_process_normal(void)
|
2016-11-18 11:26:53 +01:00
|
|
|
{
|
|
|
|
|
int status = btn_check();
|
|
|
|
|
if (status != 0) {
|
|
|
|
|
if (status & EVT_BUTTON_SINGLE_CLICK) {
|
2016-12-04 08:19:31 +01:00
|
|
|
ui_mode_menu();
|
2016-11-18 11:26:53 +01:00
|
|
|
} else {
|
2020-02-27 18:53:45 +01:00
|
|
|
switch (uistat.lever_mode) {
|
2019-11-09 03:20:22 +01:00
|
|
|
case LM_MARKER: lever_move_marker(status); break;
|
|
|
|
|
case LM_SEARCH: lever_search_marker(status); break;
|
2020-02-22 14:41:50 +01:00
|
|
|
case LM_CENTER:
|
|
|
|
|
lever_move(status, FREQ_IS_STARTSTOP() ? ST_START : ST_CENTER);
|
|
|
|
|
break;
|
|
|
|
|
case LM_SPAN:
|
|
|
|
|
if (FREQ_IS_STARTSTOP())
|
|
|
|
|
lever_move(status, ST_STOP);
|
|
|
|
|
else
|
2020-03-01 00:50:46 +01:00
|
|
|
lever_zoom_span(status);
|
|
|
|
|
break;
|
|
|
|
|
case LM_EDELAY:
|
|
|
|
|
lever_edelay(status);
|
2020-02-22 14:41:50 +01:00
|
|
|
break;
|
2019-11-09 03:20:22 +01:00
|
|
|
}
|
2016-12-04 08:19:31 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-27 10:46:26 +02:00
|
|
|
static void
|
2016-12-04 08:19:31 +01:00
|
|
|
ui_process_menu(void)
|
|
|
|
|
{
|
|
|
|
|
int status = btn_check();
|
|
|
|
|
if (status != 0) {
|
|
|
|
|
if (status & EVT_BUTTON_SINGLE_CLICK) {
|
|
|
|
|
menu_invoke(selection);
|
|
|
|
|
} else {
|
2016-12-11 09:26:33 +01:00
|
|
|
do {
|
2019-10-08 16:59:49 +02:00
|
|
|
if (status & EVT_UP) {
|
|
|
|
|
// close menu if next item is sentinel
|
|
|
|
|
if (menu_stack[menu_current_level][selection+1].type == MT_NONE)
|
|
|
|
|
goto menuclose;
|
2016-12-11 09:26:33 +01:00
|
|
|
selection++;
|
|
|
|
|
}
|
2019-10-08 16:59:49 +02:00
|
|
|
if (status & EVT_DOWN) {
|
|
|
|
|
if (selection == 0)
|
|
|
|
|
goto menuclose;
|
2016-12-11 09:26:33 +01:00
|
|
|
selection--;
|
|
|
|
|
}
|
Big code redisign (increase CELL draw size, more faster screen render), also save about 4-5kB flash size
Try remove all hardcoded values from code (use definition if set)
Some error fix
main.c:
Rewrite Shell, now it run on main thread and require less RAM (not need stack)
(possible run it as thread if define VNA_SHELL_THREAD
Remove not used trace_info[].scale_unit in set_trace_scale/get_trace_scale (it just divede on set and multiple on get, better use it for default scale set)
Replace some hardcoded values
MARKERS_MAX
SAVEAREA_MAX
TRACES_MAX
plot.c
Rewrite CELLWIDTH and CELLHEIGHT use, now possible set any CELL width and height (CELLWIDTH * CELLHEIGHT <= spi_buffer size)
Free RAM from shell stack use fore increase spi_buffer size now it have 2048 pixel (64x32)
Rewrite cell index and markmap use (now correct use cell size, and more faster), correct use CELLWIDTH and CELLHEIGHT in calculation
Fore set update area use invalidateRect (still need use some hardcoded values :( )
Rewrite cell_draw_line
Rewrite many hardcoded size definitions
Refrence point now draw as bitmap (less size, more costumable)
Fix drag marker (now correct search closest index in search_nearest_index)
Rewrite plot_into_index, now correct use size definitions, moe
ui.c
Small rewrite keyboard definitions, for use less flash size
Define KP_WIDTH, KP_HEIGHT for set key size
Better look some big font symvols
All:
use static fore some local functions (use less space on calls)
replace tabs on spaces (code style)
Use M_PI from math.h fore define pi value
Fix printf on print HEX values
2020-02-22 08:50:54 +01:00
|
|
|
draw_menu();
|
2020-05-25 12:29:34 +02:00
|
|
|
chThdSleepMilliseconds(200);
|
2016-12-11 09:26:33 +01:00
|
|
|
status = btn_wait_release();
|
|
|
|
|
} while (status != 0);
|
2016-12-04 08:19:31 +01:00
|
|
|
}
|
|
|
|
|
}
|
2019-10-08 16:59:49 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
menuclose:
|
|
|
|
|
ui_mode_normal();
|
2016-12-04 08:19:31 +01:00
|
|
|
}
|
2016-12-17 12:33:04 +01:00
|
|
|
|
2019-08-27 10:46:26 +02:00
|
|
|
static int
|
2020-03-21 00:03:09 +01:00
|
|
|
keypad_click(int key)
|
2016-12-17 12:33:04 +01:00
|
|
|
{
|
2017-02-02 23:28:20 +01:00
|
|
|
int c = keypads[key].c;
|
2019-08-10 07:15:35 +02:00
|
|
|
if ((c >= KP_X1 && c <= KP_G) || c == KP_N || c == KP_P) {
|
2020-02-11 09:54:05 +01:00
|
|
|
int32_t scale = 1;
|
2019-08-10 07:15:35 +02:00
|
|
|
if (c >= KP_X1 && c <= KP_G) {
|
|
|
|
|
int n = c - KP_X1;
|
|
|
|
|
while (n-- > 0)
|
|
|
|
|
scale *= 1000;
|
|
|
|
|
} else if (c == KP_N) {
|
2016-12-17 12:33:04 +01:00
|
|
|
scale *= 1000;
|
2019-08-10 07:15:35 +02:00
|
|
|
}
|
2016-12-17 12:33:04 +01:00
|
|
|
/* numeric input done */
|
2020-02-11 09:54:05 +01:00
|
|
|
double value = my_atof(kp_buf) * scale;
|
2016-12-17 12:33:04 +01:00
|
|
|
switch (keypad_mode) {
|
|
|
|
|
case KM_START:
|
|
|
|
|
set_sweep_frequency(ST_START, value);
|
|
|
|
|
break;
|
|
|
|
|
case KM_STOP:
|
|
|
|
|
set_sweep_frequency(ST_STOP, value);
|
|
|
|
|
break;
|
|
|
|
|
case KM_CENTER:
|
|
|
|
|
set_sweep_frequency(ST_CENTER, value);
|
|
|
|
|
break;
|
|
|
|
|
case KM_SPAN:
|
|
|
|
|
set_sweep_frequency(ST_SPAN, value);
|
|
|
|
|
break;
|
|
|
|
|
case KM_CW:
|
|
|
|
|
set_sweep_frequency(ST_CW, value);
|
|
|
|
|
break;
|
|
|
|
|
case KM_SCALE:
|
|
|
|
|
set_trace_scale(uistat.current_trace, value);
|
|
|
|
|
break;
|
2017-01-17 15:06:32 +01:00
|
|
|
case KM_REFPOS:
|
|
|
|
|
set_trace_refpos(uistat.current_trace, value);
|
|
|
|
|
break;
|
|
|
|
|
case KM_EDELAY:
|
2019-08-10 07:15:35 +02:00
|
|
|
set_electrical_delay(value); // pico seconds
|
2017-01-17 15:06:32 +01:00
|
|
|
break;
|
2019-09-10 17:24:06 +02:00
|
|
|
case KM_VELOCITY_FACTOR:
|
2020-01-18 05:03:38 +01:00
|
|
|
velocity_factor = value / 100.0;
|
2019-09-10 17:24:06 +02:00
|
|
|
break;
|
2019-09-08 14:39:57 +02:00
|
|
|
case KM_SCALEDELAY:
|
|
|
|
|
set_trace_scale(uistat.current_trace, value * 1e-12); // pico second
|
|
|
|
|
break;
|
2016-12-17 12:33:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return KP_DONE;
|
2020-03-21 00:03:09 +01:00
|
|
|
} else if (c <= 9 && kp_index < NUMINPUT_LEN) {
|
2016-12-17 12:33:04 +01:00
|
|
|
kp_buf[kp_index++] = '0' + c;
|
2020-03-21 00:03:09 +01:00
|
|
|
} else if (c == KP_PERIOD && kp_index < NUMINPUT_LEN) {
|
2016-12-17 12:33:04 +01:00
|
|
|
// check period in former input
|
|
|
|
|
int j;
|
|
|
|
|
for (j = 0; j < kp_index && kp_buf[j] != '.'; j++)
|
|
|
|
|
;
|
|
|
|
|
// append period if there are no period
|
|
|
|
|
if (kp_index == j)
|
|
|
|
|
kp_buf[kp_index++] = '.';
|
2019-10-11 14:22:00 +02:00
|
|
|
} else if (c == KP_MINUS) {
|
|
|
|
|
if (kp_index == 0)
|
|
|
|
|
kp_buf[kp_index++] = '-';
|
2016-12-17 12:33:04 +01:00
|
|
|
} else if (c == KP_BS) {
|
|
|
|
|
if (kp_index == 0) {
|
|
|
|
|
return KP_CANCEL;
|
|
|
|
|
}
|
|
|
|
|
--kp_index;
|
|
|
|
|
}
|
|
|
|
|
kp_buf[kp_index] = '\0';
|
|
|
|
|
draw_numeric_input(kp_buf);
|
|
|
|
|
return KP_CONTINUE;
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-27 10:46:26 +02:00
|
|
|
static int
|
2017-01-01 07:03:41 +01:00
|
|
|
keypad_apply_touch(void)
|
2016-12-17 12:33:04 +01:00
|
|
|
{
|
2017-01-01 07:03:41 +01:00
|
|
|
int touch_x, touch_y;
|
2016-12-17 12:33:04 +01:00
|
|
|
int i = 0;
|
2017-01-01 07:03:41 +01:00
|
|
|
|
|
|
|
|
touch_position(&touch_x, &touch_y);
|
|
|
|
|
|
2020-07-05 11:33:40 +02:00
|
|
|
while (keypads[i].c != KP_NONE) {
|
Big code redisign (increase CELL draw size, more faster screen render), also save about 4-5kB flash size
Try remove all hardcoded values from code (use definition if set)
Some error fix
main.c:
Rewrite Shell, now it run on main thread and require less RAM (not need stack)
(possible run it as thread if define VNA_SHELL_THREAD
Remove not used trace_info[].scale_unit in set_trace_scale/get_trace_scale (it just divede on set and multiple on get, better use it for default scale set)
Replace some hardcoded values
MARKERS_MAX
SAVEAREA_MAX
TRACES_MAX
plot.c
Rewrite CELLWIDTH and CELLHEIGHT use, now possible set any CELL width and height (CELLWIDTH * CELLHEIGHT <= spi_buffer size)
Free RAM from shell stack use fore increase spi_buffer size now it have 2048 pixel (64x32)
Rewrite cell index and markmap use (now correct use cell size, and more faster), correct use CELLWIDTH and CELLHEIGHT in calculation
Fore set update area use invalidateRect (still need use some hardcoded values :( )
Rewrite cell_draw_line
Rewrite many hardcoded size definitions
Refrence point now draw as bitmap (less size, more costumable)
Fix drag marker (now correct search closest index in search_nearest_index)
Rewrite plot_into_index, now correct use size definitions, moe
ui.c
Small rewrite keyboard definitions, for use less flash size
Define KP_WIDTH, KP_HEIGHT for set key size
Better look some big font symvols
All:
use static fore some local functions (use less space on calls)
replace tabs on spaces (code style)
Use M_PI from math.h fore define pi value
Fix printf on print HEX values
2020-02-22 08:50:54 +01:00
|
|
|
int x = KP_GET_X(keypads[i].x);
|
|
|
|
|
int y = KP_GET_Y(keypads[i].y);
|
2020-02-26 21:30:50 +01:00
|
|
|
if (x < touch_x && touch_x < x+KP_WIDTH && y < touch_y && touch_y < y+KP_HEIGHT) {
|
2017-02-02 23:28:20 +01:00
|
|
|
// draw focus
|
2016-12-17 12:33:04 +01:00
|
|
|
selection = i;
|
|
|
|
|
draw_keypad();
|
|
|
|
|
touch_wait_release();
|
2017-02-02 23:28:20 +01:00
|
|
|
// erase focus
|
2017-02-02 21:58:50 +01:00
|
|
|
selection = -1;
|
2017-02-02 23:28:20 +01:00
|
|
|
draw_keypad();
|
|
|
|
|
return i;
|
2016-12-17 12:33:04 +01:00
|
|
|
}
|
|
|
|
|
i++;
|
|
|
|
|
}
|
2017-02-02 23:28:20 +01:00
|
|
|
return -1;
|
2016-12-17 12:33:04 +01:00
|
|
|
}
|
|
|
|
|
|
2019-08-27 10:46:26 +02:00
|
|
|
static void
|
2020-05-25 12:29:34 +02:00
|
|
|
numeric_apply_touch(int touch_x, int touch_y)
|
2017-10-01 01:59:33 +02:00
|
|
|
{
|
|
|
|
|
if (touch_x < 64) {
|
|
|
|
|
ui_mode_normal();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (touch_x > 64+9*20+8+8) {
|
|
|
|
|
ui_mode_keypad(keypad_mode);
|
|
|
|
|
ui_process_keypad();
|
|
|
|
|
return;
|
|
|
|
|
}
|
2019-08-10 07:15:35 +02:00
|
|
|
|
2020-03-30 19:01:51 +02:00
|
|
|
if (touch_y > LCD_HEIGHT-40) {
|
2019-08-10 07:15:35 +02:00
|
|
|
int n = 9 - (touch_x - 64) / 20;
|
|
|
|
|
uistat.digit = n;
|
|
|
|
|
uistat.digit_mode = TRUE;
|
2017-10-01 04:14:41 +02:00
|
|
|
} else {
|
2019-08-10 07:15:35 +02:00
|
|
|
int step, n;
|
|
|
|
|
if (touch_y < 100) {
|
|
|
|
|
step = 1;
|
|
|
|
|
} else {
|
|
|
|
|
step = -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (n = uistat.digit; n > 0; n--)
|
|
|
|
|
step *= 10;
|
|
|
|
|
uistat.value += step;
|
2017-10-01 04:14:41 +02:00
|
|
|
}
|
|
|
|
|
draw_numeric_area();
|
2020-03-21 00:03:09 +01:00
|
|
|
|
2017-10-01 04:14:41 +02:00
|
|
|
touch_wait_release();
|
|
|
|
|
uistat.digit_mode = FALSE;
|
|
|
|
|
draw_numeric_area();
|
2020-03-21 00:03:09 +01:00
|
|
|
|
2017-10-01 01:59:33 +02:00
|
|
|
return;
|
|
|
|
|
}
|
2017-09-30 16:06:21 +02:00
|
|
|
|
2019-08-27 10:46:26 +02:00
|
|
|
static void
|
2017-09-30 16:06:21 +02:00
|
|
|
ui_process_numeric(void)
|
|
|
|
|
{
|
|
|
|
|
int status = btn_check();
|
2017-10-01 01:59:33 +02:00
|
|
|
|
2017-09-30 16:06:21 +02:00
|
|
|
if (status != 0) {
|
|
|
|
|
if (status == EVT_BUTTON_SINGLE_CLICK) {
|
|
|
|
|
status = btn_wait_release();
|
|
|
|
|
if (uistat.digit_mode) {
|
|
|
|
|
if (status & (EVT_BUTTON_SINGLE_CLICK | EVT_BUTTON_DOWN_LONG)) {
|
|
|
|
|
uistat.digit_mode = FALSE;
|
|
|
|
|
draw_numeric_area();
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (status & EVT_BUTTON_DOWN_LONG) {
|
|
|
|
|
uistat.digit_mode = TRUE;
|
|
|
|
|
draw_numeric_area();
|
|
|
|
|
} else if (status & EVT_BUTTON_SINGLE_CLICK) {
|
|
|
|
|
set_numeric_value();
|
|
|
|
|
ui_mode_normal();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
do {
|
|
|
|
|
if (uistat.digit_mode) {
|
2017-09-30 16:58:31 +02:00
|
|
|
if (status & EVT_DOWN) {
|
Big code redisign (increase CELL draw size, more faster screen render), also save about 4-5kB flash size
Try remove all hardcoded values from code (use definition if set)
Some error fix
main.c:
Rewrite Shell, now it run on main thread and require less RAM (not need stack)
(possible run it as thread if define VNA_SHELL_THREAD
Remove not used trace_info[].scale_unit in set_trace_scale/get_trace_scale (it just divede on set and multiple on get, better use it for default scale set)
Replace some hardcoded values
MARKERS_MAX
SAVEAREA_MAX
TRACES_MAX
plot.c
Rewrite CELLWIDTH and CELLHEIGHT use, now possible set any CELL width and height (CELLWIDTH * CELLHEIGHT <= spi_buffer size)
Free RAM from shell stack use fore increase spi_buffer size now it have 2048 pixel (64x32)
Rewrite cell index and markmap use (now correct use cell size, and more faster), correct use CELLWIDTH and CELLHEIGHT in calculation
Fore set update area use invalidateRect (still need use some hardcoded values :( )
Rewrite cell_draw_line
Rewrite many hardcoded size definitions
Refrence point now draw as bitmap (less size, more costumable)
Fix drag marker (now correct search closest index in search_nearest_index)
Rewrite plot_into_index, now correct use size definitions, moe
ui.c
Small rewrite keyboard definitions, for use less flash size
Define KP_WIDTH, KP_HEIGHT for set key size
Better look some big font symvols
All:
use static fore some local functions (use less space on calls)
replace tabs on spaces (code style)
Use M_PI from math.h fore define pi value
Fix printf on print HEX values
2020-02-22 08:50:54 +01:00
|
|
|
if (uistat.digit < 8)
|
2017-09-30 16:58:31 +02:00
|
|
|
uistat.digit++;
|
Big code redisign (increase CELL draw size, more faster screen render), also save about 4-5kB flash size
Try remove all hardcoded values from code (use definition if set)
Some error fix
main.c:
Rewrite Shell, now it run on main thread and require less RAM (not need stack)
(possible run it as thread if define VNA_SHELL_THREAD
Remove not used trace_info[].scale_unit in set_trace_scale/get_trace_scale (it just divede on set and multiple on get, better use it for default scale set)
Replace some hardcoded values
MARKERS_MAX
SAVEAREA_MAX
TRACES_MAX
plot.c
Rewrite CELLWIDTH and CELLHEIGHT use, now possible set any CELL width and height (CELLWIDTH * CELLHEIGHT <= spi_buffer size)
Free RAM from shell stack use fore increase spi_buffer size now it have 2048 pixel (64x32)
Rewrite cell index and markmap use (now correct use cell size, and more faster), correct use CELLWIDTH and CELLHEIGHT in calculation
Fore set update area use invalidateRect (still need use some hardcoded values :( )
Rewrite cell_draw_line
Rewrite many hardcoded size definitions
Refrence point now draw as bitmap (less size, more costumable)
Fix drag marker (now correct search closest index in search_nearest_index)
Rewrite plot_into_index, now correct use size definitions, moe
ui.c
Small rewrite keyboard definitions, for use less flash size
Define KP_WIDTH, KP_HEIGHT for set key size
Better look some big font symvols
All:
use static fore some local functions (use less space on calls)
replace tabs on spaces (code style)
Use M_PI from math.h fore define pi value
Fix printf on print HEX values
2020-02-22 08:50:54 +01:00
|
|
|
else
|
2017-10-01 01:59:33 +02:00
|
|
|
goto exit;
|
2017-09-30 16:06:21 +02:00
|
|
|
}
|
2017-09-30 16:58:31 +02:00
|
|
|
if (status & EVT_UP) {
|
Big code redisign (increase CELL draw size, more faster screen render), also save about 4-5kB flash size
Try remove all hardcoded values from code (use definition if set)
Some error fix
main.c:
Rewrite Shell, now it run on main thread and require less RAM (not need stack)
(possible run it as thread if define VNA_SHELL_THREAD
Remove not used trace_info[].scale_unit in set_trace_scale/get_trace_scale (it just divede on set and multiple on get, better use it for default scale set)
Replace some hardcoded values
MARKERS_MAX
SAVEAREA_MAX
TRACES_MAX
plot.c
Rewrite CELLWIDTH and CELLHEIGHT use, now possible set any CELL width and height (CELLWIDTH * CELLHEIGHT <= spi_buffer size)
Free RAM from shell stack use fore increase spi_buffer size now it have 2048 pixel (64x32)
Rewrite cell index and markmap use (now correct use cell size, and more faster), correct use CELLWIDTH and CELLHEIGHT in calculation
Fore set update area use invalidateRect (still need use some hardcoded values :( )
Rewrite cell_draw_line
Rewrite many hardcoded size definitions
Refrence point now draw as bitmap (less size, more costumable)
Fix drag marker (now correct search closest index in search_nearest_index)
Rewrite plot_into_index, now correct use size definitions, moe
ui.c
Small rewrite keyboard definitions, for use less flash size
Define KP_WIDTH, KP_HEIGHT for set key size
Better look some big font symvols
All:
use static fore some local functions (use less space on calls)
replace tabs on spaces (code style)
Use M_PI from math.h fore define pi value
Fix printf on print HEX values
2020-02-22 08:50:54 +01:00
|
|
|
if (uistat.digit > 0)
|
2017-09-30 16:58:31 +02:00
|
|
|
uistat.digit--;
|
Big code redisign (increase CELL draw size, more faster screen render), also save about 4-5kB flash size
Try remove all hardcoded values from code (use definition if set)
Some error fix
main.c:
Rewrite Shell, now it run on main thread and require less RAM (not need stack)
(possible run it as thread if define VNA_SHELL_THREAD
Remove not used trace_info[].scale_unit in set_trace_scale/get_trace_scale (it just divede on set and multiple on get, better use it for default scale set)
Replace some hardcoded values
MARKERS_MAX
SAVEAREA_MAX
TRACES_MAX
plot.c
Rewrite CELLWIDTH and CELLHEIGHT use, now possible set any CELL width and height (CELLWIDTH * CELLHEIGHT <= spi_buffer size)
Free RAM from shell stack use fore increase spi_buffer size now it have 2048 pixel (64x32)
Rewrite cell index and markmap use (now correct use cell size, and more faster), correct use CELLWIDTH and CELLHEIGHT in calculation
Fore set update area use invalidateRect (still need use some hardcoded values :( )
Rewrite cell_draw_line
Rewrite many hardcoded size definitions
Refrence point now draw as bitmap (less size, more costumable)
Fix drag marker (now correct search closest index in search_nearest_index)
Rewrite plot_into_index, now correct use size definitions, moe
ui.c
Small rewrite keyboard definitions, for use less flash size
Define KP_WIDTH, KP_HEIGHT for set key size
Better look some big font symvols
All:
use static fore some local functions (use less space on calls)
replace tabs on spaces (code style)
Use M_PI from math.h fore define pi value
Fix printf on print HEX values
2020-02-22 08:50:54 +01:00
|
|
|
else
|
2017-10-01 01:59:33 +02:00
|
|
|
goto exit;
|
2017-09-30 16:06:21 +02:00
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
int32_t step = 1;
|
|
|
|
|
int n;
|
|
|
|
|
for (n = uistat.digit; n > 0; n--)
|
|
|
|
|
step *= 10;
|
Big code redisign (increase CELL draw size, more faster screen render), also save about 4-5kB flash size
Try remove all hardcoded values from code (use definition if set)
Some error fix
main.c:
Rewrite Shell, now it run on main thread and require less RAM (not need stack)
(possible run it as thread if define VNA_SHELL_THREAD
Remove not used trace_info[].scale_unit in set_trace_scale/get_trace_scale (it just divede on set and multiple on get, better use it for default scale set)
Replace some hardcoded values
MARKERS_MAX
SAVEAREA_MAX
TRACES_MAX
plot.c
Rewrite CELLWIDTH and CELLHEIGHT use, now possible set any CELL width and height (CELLWIDTH * CELLHEIGHT <= spi_buffer size)
Free RAM from shell stack use fore increase spi_buffer size now it have 2048 pixel (64x32)
Rewrite cell index and markmap use (now correct use cell size, and more faster), correct use CELLWIDTH and CELLHEIGHT in calculation
Fore set update area use invalidateRect (still need use some hardcoded values :( )
Rewrite cell_draw_line
Rewrite many hardcoded size definitions
Refrence point now draw as bitmap (less size, more costumable)
Fix drag marker (now correct search closest index in search_nearest_index)
Rewrite plot_into_index, now correct use size definitions, moe
ui.c
Small rewrite keyboard definitions, for use less flash size
Define KP_WIDTH, KP_HEIGHT for set key size
Better look some big font symvols
All:
use static fore some local functions (use less space on calls)
replace tabs on spaces (code style)
Use M_PI from math.h fore define pi value
Fix printf on print HEX values
2020-02-22 08:50:54 +01:00
|
|
|
if (status & EVT_DOWN)
|
2017-09-30 17:56:43 +02:00
|
|
|
uistat.value += step;
|
Big code redisign (increase CELL draw size, more faster screen render), also save about 4-5kB flash size
Try remove all hardcoded values from code (use definition if set)
Some error fix
main.c:
Rewrite Shell, now it run on main thread and require less RAM (not need stack)
(possible run it as thread if define VNA_SHELL_THREAD
Remove not used trace_info[].scale_unit in set_trace_scale/get_trace_scale (it just divede on set and multiple on get, better use it for default scale set)
Replace some hardcoded values
MARKERS_MAX
SAVEAREA_MAX
TRACES_MAX
plot.c
Rewrite CELLWIDTH and CELLHEIGHT use, now possible set any CELL width and height (CELLWIDTH * CELLHEIGHT <= spi_buffer size)
Free RAM from shell stack use fore increase spi_buffer size now it have 2048 pixel (64x32)
Rewrite cell index and markmap use (now correct use cell size, and more faster), correct use CELLWIDTH and CELLHEIGHT in calculation
Fore set update area use invalidateRect (still need use some hardcoded values :( )
Rewrite cell_draw_line
Rewrite many hardcoded size definitions
Refrence point now draw as bitmap (less size, more costumable)
Fix drag marker (now correct search closest index in search_nearest_index)
Rewrite plot_into_index, now correct use size definitions, moe
ui.c
Small rewrite keyboard definitions, for use less flash size
Define KP_WIDTH, KP_HEIGHT for set key size
Better look some big font symvols
All:
use static fore some local functions (use less space on calls)
replace tabs on spaces (code style)
Use M_PI from math.h fore define pi value
Fix printf on print HEX values
2020-02-22 08:50:54 +01:00
|
|
|
if (status & EVT_UP)
|
2017-09-30 17:56:43 +02:00
|
|
|
uistat.value -= step;
|
2017-09-30 16:06:21 +02:00
|
|
|
}
|
Big code redisign (increase CELL draw size, more faster screen render), also save about 4-5kB flash size
Try remove all hardcoded values from code (use definition if set)
Some error fix
main.c:
Rewrite Shell, now it run on main thread and require less RAM (not need stack)
(possible run it as thread if define VNA_SHELL_THREAD
Remove not used trace_info[].scale_unit in set_trace_scale/get_trace_scale (it just divede on set and multiple on get, better use it for default scale set)
Replace some hardcoded values
MARKERS_MAX
SAVEAREA_MAX
TRACES_MAX
plot.c
Rewrite CELLWIDTH and CELLHEIGHT use, now possible set any CELL width and height (CELLWIDTH * CELLHEIGHT <= spi_buffer size)
Free RAM from shell stack use fore increase spi_buffer size now it have 2048 pixel (64x32)
Rewrite cell index and markmap use (now correct use cell size, and more faster), correct use CELLWIDTH and CELLHEIGHT in calculation
Fore set update area use invalidateRect (still need use some hardcoded values :( )
Rewrite cell_draw_line
Rewrite many hardcoded size definitions
Refrence point now draw as bitmap (less size, more costumable)
Fix drag marker (now correct search closest index in search_nearest_index)
Rewrite plot_into_index, now correct use size definitions, moe
ui.c
Small rewrite keyboard definitions, for use less flash size
Define KP_WIDTH, KP_HEIGHT for set key size
Better look some big font symvols
All:
use static fore some local functions (use less space on calls)
replace tabs on spaces (code style)
Use M_PI from math.h fore define pi value
Fix printf on print HEX values
2020-02-22 08:50:54 +01:00
|
|
|
draw_numeric_area();
|
2017-09-30 16:06:21 +02:00
|
|
|
status = btn_wait_release();
|
|
|
|
|
} while (status != 0);
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-10-01 01:59:33 +02:00
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
exit:
|
|
|
|
|
// cancel operation
|
|
|
|
|
ui_mode_normal();
|
2017-09-30 16:06:21 +02:00
|
|
|
}
|
|
|
|
|
|
Big code redisign (increase CELL draw size, more faster screen render), also save about 4-5kB flash size
Try remove all hardcoded values from code (use definition if set)
Some error fix
main.c:
Rewrite Shell, now it run on main thread and require less RAM (not need stack)
(possible run it as thread if define VNA_SHELL_THREAD
Remove not used trace_info[].scale_unit in set_trace_scale/get_trace_scale (it just divede on set and multiple on get, better use it for default scale set)
Replace some hardcoded values
MARKERS_MAX
SAVEAREA_MAX
TRACES_MAX
plot.c
Rewrite CELLWIDTH and CELLHEIGHT use, now possible set any CELL width and height (CELLWIDTH * CELLHEIGHT <= spi_buffer size)
Free RAM from shell stack use fore increase spi_buffer size now it have 2048 pixel (64x32)
Rewrite cell index and markmap use (now correct use cell size, and more faster), correct use CELLWIDTH and CELLHEIGHT in calculation
Fore set update area use invalidateRect (still need use some hardcoded values :( )
Rewrite cell_draw_line
Rewrite many hardcoded size definitions
Refrence point now draw as bitmap (less size, more costumable)
Fix drag marker (now correct search closest index in search_nearest_index)
Rewrite plot_into_index, now correct use size definitions, moe
ui.c
Small rewrite keyboard definitions, for use less flash size
Define KP_WIDTH, KP_HEIGHT for set key size
Better look some big font symvols
All:
use static fore some local functions (use less space on calls)
replace tabs on spaces (code style)
Use M_PI from math.h fore define pi value
Fix printf on print HEX values
2020-02-22 08:50:54 +01:00
|
|
|
static void
|
2016-12-04 08:19:31 +01:00
|
|
|
ui_process_keypad(void)
|
|
|
|
|
{
|
2016-12-17 12:33:04 +01:00
|
|
|
int status;
|
2020-03-07 21:37:39 +01:00
|
|
|
adc_stop();
|
2016-12-17 12:33:04 +01:00
|
|
|
|
2020-07-05 11:33:40 +02:00
|
|
|
kp_index = 0; // Hide input index in keyboard mode
|
2016-12-04 08:19:31 +01:00
|
|
|
while (TRUE) {
|
2016-12-17 12:33:04 +01:00
|
|
|
status = btn_check();
|
2016-12-11 09:26:33 +01:00
|
|
|
if (status & (EVT_UP|EVT_DOWN)) {
|
|
|
|
|
do {
|
2020-07-14 20:30:27 +02:00
|
|
|
if (status & EVT_DOWN)
|
Big code redisign (increase CELL draw size, more faster screen render), also save about 4-5kB flash size
Try remove all hardcoded values from code (use definition if set)
Some error fix
main.c:
Rewrite Shell, now it run on main thread and require less RAM (not need stack)
(possible run it as thread if define VNA_SHELL_THREAD
Remove not used trace_info[].scale_unit in set_trace_scale/get_trace_scale (it just divede on set and multiple on get, better use it for default scale set)
Replace some hardcoded values
MARKERS_MAX
SAVEAREA_MAX
TRACES_MAX
plot.c
Rewrite CELLWIDTH and CELLHEIGHT use, now possible set any CELL width and height (CELLWIDTH * CELLHEIGHT <= spi_buffer size)
Free RAM from shell stack use fore increase spi_buffer size now it have 2048 pixel (64x32)
Rewrite cell index and markmap use (now correct use cell size, and more faster), correct use CELLWIDTH and CELLHEIGHT in calculation
Fore set update area use invalidateRect (still need use some hardcoded values :( )
Rewrite cell_draw_line
Rewrite many hardcoded size definitions
Refrence point now draw as bitmap (less size, more costumable)
Fix drag marker (now correct search closest index in search_nearest_index)
Rewrite plot_into_index, now correct use size definitions, moe
ui.c
Small rewrite keyboard definitions, for use less flash size
Define KP_WIDTH, KP_HEIGHT for set key size
Better look some big font symvols
All:
use static fore some local functions (use less space on calls)
replace tabs on spaces (code style)
Use M_PI from math.h fore define pi value
Fix printf on print HEX values
2020-02-22 08:50:54 +01:00
|
|
|
if (--selection < 0)
|
2017-02-03 13:18:33 +01:00
|
|
|
selection = keypads_last_index;
|
2020-07-14 20:30:27 +02:00
|
|
|
if (status & EVT_UP)
|
Big code redisign (increase CELL draw size, more faster screen render), also save about 4-5kB flash size
Try remove all hardcoded values from code (use definition if set)
Some error fix
main.c:
Rewrite Shell, now it run on main thread and require less RAM (not need stack)
(possible run it as thread if define VNA_SHELL_THREAD
Remove not used trace_info[].scale_unit in set_trace_scale/get_trace_scale (it just divede on set and multiple on get, better use it for default scale set)
Replace some hardcoded values
MARKERS_MAX
SAVEAREA_MAX
TRACES_MAX
plot.c
Rewrite CELLWIDTH and CELLHEIGHT use, now possible set any CELL width and height (CELLWIDTH * CELLHEIGHT <= spi_buffer size)
Free RAM from shell stack use fore increase spi_buffer size now it have 2048 pixel (64x32)
Rewrite cell index and markmap use (now correct use cell size, and more faster), correct use CELLWIDTH and CELLHEIGHT in calculation
Fore set update area use invalidateRect (still need use some hardcoded values :( )
Rewrite cell_draw_line
Rewrite many hardcoded size definitions
Refrence point now draw as bitmap (less size, more costumable)
Fix drag marker (now correct search closest index in search_nearest_index)
Rewrite plot_into_index, now correct use size definitions, moe
ui.c
Small rewrite keyboard definitions, for use less flash size
Define KP_WIDTH, KP_HEIGHT for set key size
Better look some big font symvols
All:
use static fore some local functions (use less space on calls)
replace tabs on spaces (code style)
Use M_PI from math.h fore define pi value
Fix printf on print HEX values
2020-02-22 08:50:54 +01:00
|
|
|
if (++selection > keypads_last_index)
|
2017-02-02 23:28:20 +01:00
|
|
|
selection = 0;
|
Big code redisign (increase CELL draw size, more faster screen render), also save about 4-5kB flash size
Try remove all hardcoded values from code (use definition if set)
Some error fix
main.c:
Rewrite Shell, now it run on main thread and require less RAM (not need stack)
(possible run it as thread if define VNA_SHELL_THREAD
Remove not used trace_info[].scale_unit in set_trace_scale/get_trace_scale (it just divede on set and multiple on get, better use it for default scale set)
Replace some hardcoded values
MARKERS_MAX
SAVEAREA_MAX
TRACES_MAX
plot.c
Rewrite CELLWIDTH and CELLHEIGHT use, now possible set any CELL width and height (CELLWIDTH * CELLHEIGHT <= spi_buffer size)
Free RAM from shell stack use fore increase spi_buffer size now it have 2048 pixel (64x32)
Rewrite cell index and markmap use (now correct use cell size, and more faster), correct use CELLWIDTH and CELLHEIGHT in calculation
Fore set update area use invalidateRect (still need use some hardcoded values :( )
Rewrite cell_draw_line
Rewrite many hardcoded size definitions
Refrence point now draw as bitmap (less size, more costumable)
Fix drag marker (now correct search closest index in search_nearest_index)
Rewrite plot_into_index, now correct use size definitions, moe
ui.c
Small rewrite keyboard definitions, for use less flash size
Define KP_WIDTH, KP_HEIGHT for set key size
Better look some big font symvols
All:
use static fore some local functions (use less space on calls)
replace tabs on spaces (code style)
Use M_PI from math.h fore define pi value
Fix printf on print HEX values
2020-02-22 08:50:54 +01:00
|
|
|
draw_keypad();
|
2020-07-05 11:33:40 +02:00
|
|
|
status = btn_wait_release();
|
|
|
|
|
} while (status != 0);
|
2016-12-04 08:19:31 +01:00
|
|
|
}
|
2016-12-11 09:26:33 +01:00
|
|
|
|
2020-07-05 11:33:40 +02:00
|
|
|
else if (status == EVT_BUTTON_SINGLE_CLICK) {
|
2016-12-17 12:33:04 +01:00
|
|
|
if (keypad_click(selection))
|
|
|
|
|
/* exit loop on done or cancel */
|
2020-03-21 00:03:09 +01:00
|
|
|
break;
|
2016-11-18 11:26:53 +01:00
|
|
|
}
|
2016-12-04 08:19:31 +01:00
|
|
|
|
2020-07-05 11:33:40 +02:00
|
|
|
else if (touch_check() == EVT_TOUCH_PRESSED) {
|
2017-02-02 23:28:20 +01:00
|
|
|
int key = keypad_apply_touch();
|
|
|
|
|
if (key >= 0 && keypad_click(key))
|
2016-12-17 12:33:04 +01:00
|
|
|
/* exit loop on done or cancel */
|
2019-08-10 07:15:35 +02:00
|
|
|
break;
|
2016-12-17 12:33:04 +01:00
|
|
|
}
|
2016-12-04 08:19:31 +01:00
|
|
|
}
|
|
|
|
|
|
2017-09-17 11:52:02 +02:00
|
|
|
redraw_frame();
|
|
|
|
|
request_to_redraw_grid();
|
2016-12-04 08:19:31 +01:00
|
|
|
ui_mode_normal();
|
2017-09-15 21:11:18 +02:00
|
|
|
//redraw_all();
|
2017-02-02 23:28:20 +01:00
|
|
|
touch_start_watchdog();
|
2016-12-04 08:19:31 +01:00
|
|
|
}
|
|
|
|
|
|
2019-08-27 10:46:26 +02:00
|
|
|
static void
|
2016-12-17 10:32:27 +01:00
|
|
|
ui_process_lever(void)
|
2016-12-04 08:19:31 +01:00
|
|
|
{
|
|
|
|
|
switch (ui_mode) {
|
|
|
|
|
case UI_NORMAL:
|
|
|
|
|
ui_process_normal();
|
2020-03-21 00:03:09 +01:00
|
|
|
break;
|
2016-12-04 08:19:31 +01:00
|
|
|
case UI_MENU:
|
|
|
|
|
ui_process_menu();
|
2020-03-21 00:03:09 +01:00
|
|
|
break;
|
2017-09-30 16:06:21 +02:00
|
|
|
case UI_NUMERIC:
|
|
|
|
|
ui_process_numeric();
|
2020-03-21 00:03:09 +01:00
|
|
|
break;
|
2016-12-04 08:19:31 +01:00
|
|
|
case UI_KEYPAD:
|
|
|
|
|
ui_process_keypad();
|
2020-03-21 00:03:09 +01:00
|
|
|
break;
|
2016-11-18 11:26:53 +01:00
|
|
|
}
|
2016-12-17 10:32:27 +01:00
|
|
|
}
|
|
|
|
|
|
2019-08-27 10:46:26 +02:00
|
|
|
static void
|
|
|
|
|
drag_marker(int t, int m)
|
2017-01-03 08:39:00 +01:00
|
|
|
{
|
|
|
|
|
/* wait touch release */
|
|
|
|
|
do {
|
|
|
|
|
int touch_x, touch_y;
|
|
|
|
|
int index;
|
|
|
|
|
touch_position(&touch_x, &touch_y);
|
2017-02-02 21:40:57 +01:00
|
|
|
touch_x -= OFFSETX;
|
|
|
|
|
touch_y -= OFFSETY;
|
|
|
|
|
index = search_nearest_index(touch_x, touch_y, t);
|
2017-01-03 08:39:00 +01:00
|
|
|
if (index >= 0) {
|
|
|
|
|
markers[m].index = index;
|
2017-09-17 13:19:12 +02:00
|
|
|
markers[m].frequency = frequencies[index];
|
2020-03-09 20:28:05 +01:00
|
|
|
redraw_marker(m);
|
2017-01-03 08:39:00 +01:00
|
|
|
}
|
2020-03-21 00:03:09 +01:00
|
|
|
} while (touch_check()!= EVT_TOUCH_RELEASED);
|
2017-01-03 08:39:00 +01:00
|
|
|
}
|
|
|
|
|
|
2019-08-27 10:46:26 +02:00
|
|
|
static int
|
2020-05-25 12:29:34 +02:00
|
|
|
touch_pickup_marker(int touch_x, int touch_y)
|
2017-01-03 08:39:00 +01:00
|
|
|
{
|
|
|
|
|
int m, t;
|
2017-02-02 21:40:57 +01:00
|
|
|
touch_x -= OFFSETX;
|
|
|
|
|
touch_y -= OFFSETY;
|
2017-01-03 08:39:00 +01:00
|
|
|
|
Big code redisign (increase CELL draw size, more faster screen render), also save about 4-5kB flash size
Try remove all hardcoded values from code (use definition if set)
Some error fix
main.c:
Rewrite Shell, now it run on main thread and require less RAM (not need stack)
(possible run it as thread if define VNA_SHELL_THREAD
Remove not used trace_info[].scale_unit in set_trace_scale/get_trace_scale (it just divede on set and multiple on get, better use it for default scale set)
Replace some hardcoded values
MARKERS_MAX
SAVEAREA_MAX
TRACES_MAX
plot.c
Rewrite CELLWIDTH and CELLHEIGHT use, now possible set any CELL width and height (CELLWIDTH * CELLHEIGHT <= spi_buffer size)
Free RAM from shell stack use fore increase spi_buffer size now it have 2048 pixel (64x32)
Rewrite cell index and markmap use (now correct use cell size, and more faster), correct use CELLWIDTH and CELLHEIGHT in calculation
Fore set update area use invalidateRect (still need use some hardcoded values :( )
Rewrite cell_draw_line
Rewrite many hardcoded size definitions
Refrence point now draw as bitmap (less size, more costumable)
Fix drag marker (now correct search closest index in search_nearest_index)
Rewrite plot_into_index, now correct use size definitions, moe
ui.c
Small rewrite keyboard definitions, for use less flash size
Define KP_WIDTH, KP_HEIGHT for set key size
Better look some big font symvols
All:
use static fore some local functions (use less space on calls)
replace tabs on spaces (code style)
Use M_PI from math.h fore define pi value
Fix printf on print HEX values
2020-02-22 08:50:54 +01:00
|
|
|
for (m = 0; m < MARKERS_MAX; m++) {
|
2017-01-03 08:39:00 +01:00
|
|
|
if (!markers[m].enabled)
|
|
|
|
|
continue;
|
|
|
|
|
|
Big code redisign (increase CELL draw size, more faster screen render), also save about 4-5kB flash size
Try remove all hardcoded values from code (use definition if set)
Some error fix
main.c:
Rewrite Shell, now it run on main thread and require less RAM (not need stack)
(possible run it as thread if define VNA_SHELL_THREAD
Remove not used trace_info[].scale_unit in set_trace_scale/get_trace_scale (it just divede on set and multiple on get, better use it for default scale set)
Replace some hardcoded values
MARKERS_MAX
SAVEAREA_MAX
TRACES_MAX
plot.c
Rewrite CELLWIDTH and CELLHEIGHT use, now possible set any CELL width and height (CELLWIDTH * CELLHEIGHT <= spi_buffer size)
Free RAM from shell stack use fore increase spi_buffer size now it have 2048 pixel (64x32)
Rewrite cell index and markmap use (now correct use cell size, and more faster), correct use CELLWIDTH and CELLHEIGHT in calculation
Fore set update area use invalidateRect (still need use some hardcoded values :( )
Rewrite cell_draw_line
Rewrite many hardcoded size definitions
Refrence point now draw as bitmap (less size, more costumable)
Fix drag marker (now correct search closest index in search_nearest_index)
Rewrite plot_into_index, now correct use size definitions, moe
ui.c
Small rewrite keyboard definitions, for use less flash size
Define KP_WIDTH, KP_HEIGHT for set key size
Better look some big font symvols
All:
use static fore some local functions (use less space on calls)
replace tabs on spaces (code style)
Use M_PI from math.h fore define pi value
Fix printf on print HEX values
2020-02-22 08:50:54 +01:00
|
|
|
for (t = 0; t < TRACES_MAX; t++) {
|
2017-01-03 08:39:00 +01:00
|
|
|
int x, y;
|
|
|
|
|
if (!trace[t].enabled)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
marker_position(m, t, &x, &y);
|
2020-03-21 00:03:09 +01:00
|
|
|
x -= touch_x;
|
|
|
|
|
y -= touch_y;
|
|
|
|
|
if ((x * x + y * y) < 20 * 20) {
|
2017-01-05 01:04:28 +01:00
|
|
|
if (active_marker != m) {
|
2017-09-17 13:19:12 +02:00
|
|
|
previous_marker = active_marker;
|
2017-01-05 01:04:28 +01:00
|
|
|
active_marker = m;
|
2020-03-09 20:28:05 +01:00
|
|
|
redraw_marker(active_marker);
|
2017-01-05 01:04:28 +01:00
|
|
|
}
|
2017-09-17 12:02:19 +02:00
|
|
|
// select trace
|
|
|
|
|
uistat.current_trace = t;
|
2020-02-22 14:41:50 +01:00
|
|
|
select_lever_mode(LM_MARKER);
|
2020-03-21 00:03:09 +01:00
|
|
|
|
2017-01-05 01:04:28 +01:00
|
|
|
// drag marker until release
|
2017-01-03 08:39:00 +01:00
|
|
|
drag_marker(t, m);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-01 11:29:25 +02:00
|
|
|
#ifdef __USE_SD_CARD__
|
|
|
|
|
//*****************************************************************************
|
|
|
|
|
// Bitmap file header for 320x240 image 16bpp (v4 format allow set RGB mask)
|
|
|
|
|
//*****************************************************************************
|
|
|
|
|
static const uint8_t bmp_header_v4[14+56] = {
|
|
|
|
|
// BITMAPFILEHEADER (14 byte size)
|
|
|
|
|
0x42, 0x4D, // BM signature
|
|
|
|
|
0x46, 0x58, 0x02, 0x00, // File size = 320*240*2 + 14 + 56 = 0x00025846
|
|
|
|
|
0x00, 0x00, // reserved
|
|
|
|
|
0x00, 0x00, // reserved
|
|
|
|
|
0x46, 0x00, 0x00, 0x00, // Size of all headers = 14+56
|
|
|
|
|
// BITMAPINFOv4 (56 byte size)
|
|
|
|
|
0x38, 0x00, 0x00, 0x00, // Data offset after this point (56 = 0x38)
|
|
|
|
|
0x40, 0x01, 0x00, 0x00, // Width = 320 = 0x00000140
|
|
|
|
|
0xF0, 0x00, 0x00, 0x00, // Height = 240 = 0x000000F0
|
|
|
|
|
0x01, 0x00, // Planes
|
|
|
|
|
0x10, 0x00, // 16bpp
|
|
|
|
|
0x03, 0x00, 0x00, 0x00, // Compression (BI_BITFIELDS)
|
|
|
|
|
0x00, 0x58, 0x02, 0x00, // Bitmap size = 320*240*2 = 0x00025800
|
|
|
|
|
0xC4, 0x0E, 0x00, 0x00, // x Resolution (96 DPI = 96 * 39.3701 inches per metre = 0x0EC4)
|
|
|
|
|
0xC4, 0x0E, 0x00, 0x00, // y Resolution (96 DPI = 96 * 39.3701 inches per metre = 0x0EC4)
|
|
|
|
|
0x00, 0x00, 0x00, 0x00, // Palette size
|
|
|
|
|
0x00, 0x00, 0x00, 0x00, // Palette used
|
|
|
|
|
// Extend v4 header data (color mask for RGB565)
|
|
|
|
|
0x00, 0xF8, 0x00, 0x00, // R mask = 0b11111000 00000000
|
|
|
|
|
0xE0, 0x07, 0x00, 0x00, // G mask = 0b00000111 11100000
|
|
|
|
|
0x1F, 0x00, 0x00, 0x00, // B mask = 0b00000000 00011111
|
|
|
|
|
0x00, 0x00, 0x00, 0x00 // A mask = 0b00000000 00000000
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
made_screenshot(int touch_x, int touch_y)
|
|
|
|
|
{
|
|
|
|
|
int y, i;
|
|
|
|
|
UINT size;
|
|
|
|
|
if (touch_y < HEIGHT || touch_x < FREQUENCIES_XPOS3 || touch_x > FREQUENCIES_XPOS2)
|
|
|
|
|
return FALSE;
|
|
|
|
|
touch_wait_release();
|
|
|
|
|
// uint32_t time = chVTGetSystemTimeX();
|
|
|
|
|
// shell_printf("Screenshot\r\n");
|
|
|
|
|
FRESULT res = f_mount(fs_volume, "", 1);
|
|
|
|
|
// fs_volume, fs_file and fs_filename stored at end of spi_buffer!!!!!
|
|
|
|
|
uint16_t *buf = spi_buffer;
|
|
|
|
|
// shell_printf("Mount = %d\r\n", res);
|
|
|
|
|
if (res != FR_OK)
|
|
|
|
|
return TRUE;
|
|
|
|
|
#if FF_USE_LFN >= 1
|
|
|
|
|
uint32_t tr = rtc_get_tr_bcd(); // TR read first
|
|
|
|
|
uint32_t dr = rtc_get_dr_bcd(); // DR read second
|
|
|
|
|
plot_printf(fs_filename, FF_LFN_BUF, "VNA_%06X_%06X.bmp", dr, tr);
|
|
|
|
|
#else
|
|
|
|
|
plot_printf(fs_filename, FF_LFN_BUF, "%08X.bmp", rtc_get_FAT());
|
|
|
|
|
#endif
|
|
|
|
|
res = f_open(fs_file, fs_filename, FA_CREATE_ALWAYS | FA_READ | FA_WRITE);
|
|
|
|
|
// shell_printf("Open %s, result = %d\r\n", fs_filename, res);
|
|
|
|
|
if (res == FR_OK){
|
|
|
|
|
res = f_write(fs_file, bmp_header_v4, sizeof(bmp_header_v4), &size);
|
|
|
|
|
for (y = LCD_HEIGHT-1; y >= 0 && res == FR_OK; y--) {
|
|
|
|
|
ili9341_read_memory(0, y, LCD_WIDTH, 1, LCD_WIDTH, buf);
|
|
|
|
|
for (i = 0; i < LCD_WIDTH; i++)
|
|
|
|
|
buf[i] = __REVSH(buf[i]); // swap byte order (example 0x10FF to 0xFF10)
|
|
|
|
|
res = f_write(fs_file, buf, LCD_WIDTH*sizeof(uint16_t), &size);
|
|
|
|
|
}
|
|
|
|
|
res = f_close(fs_file);
|
|
|
|
|
// shell_printf("Close %d\r\n", res);
|
|
|
|
|
// testLog();
|
|
|
|
|
}
|
|
|
|
|
// 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);
|
|
|
|
|
ili9341_fill(LCD_WIDTH/2-96, LCD_HEIGHT/2-30, 96*2, 60, config.menu_normal_color);
|
|
|
|
|
ili9341_set_foreground(DEFAULT_MENU_TEXT_COLOR);
|
|
|
|
|
ili9341_set_background(config.menu_normal_color);
|
|
|
|
|
ili9341_drawstring("SCREENSHOT", LCD_WIDTH/2-5*FONT_WIDTH, LCD_HEIGHT/2-20);
|
|
|
|
|
ili9341_drawstring(res == FR_OK ? fs_filename : " Fail write ", LCD_WIDTH/2-76, LCD_HEIGHT/2);
|
|
|
|
|
request_to_redraw_grid();
|
|
|
|
|
chThdSleepMilliseconds(2000);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2020-02-22 14:41:50 +01:00
|
|
|
static int
|
2020-05-25 12:29:34 +02:00
|
|
|
touch_lever_mode_select(int touch_x, int touch_y)
|
2020-02-22 14:41:50 +01:00
|
|
|
{
|
|
|
|
|
if (touch_y > HEIGHT) {
|
2020-02-26 21:30:50 +01:00
|
|
|
select_lever_mode(touch_x < FREQUENCIES_XPOS2 ? LM_CENTER : LM_SPAN);
|
2020-02-22 14:41:50 +01:00
|
|
|
return TRUE;
|
|
|
|
|
}
|
2020-03-07 12:54:51 +01:00
|
|
|
if (touch_y < 25) {
|
2020-03-01 01:29:28 +01:00
|
|
|
if (touch_x < FREQUENCIES_XPOS2 && get_electrical_delay() != 0.0) {
|
2020-03-01 00:50:46 +01:00
|
|
|
select_lever_mode(LM_EDELAY);
|
2020-03-21 00:03:09 +01:00
|
|
|
} else {
|
2020-03-01 00:50:46 +01:00
|
|
|
select_lever_mode(LM_MARKER);
|
2020-03-21 00:03:09 +01:00
|
|
|
}
|
2020-02-22 14:41:50 +01:00
|
|
|
return TRUE;
|
|
|
|
|
}
|
2020-02-26 21:30:50 +01:00
|
|
|
return FALSE;
|
|
|
|
|
}
|
2017-01-03 08:39:00 +01:00
|
|
|
|
2019-08-27 10:46:26 +02:00
|
|
|
static
|
2016-12-17 10:32:27 +01:00
|
|
|
void ui_process_touch(void)
|
|
|
|
|
{
|
2020-03-07 21:37:39 +01:00
|
|
|
adc_stop();
|
2020-05-25 12:29:34 +02:00
|
|
|
int touch_x, touch_y;
|
2016-12-17 12:33:04 +01:00
|
|
|
int status = touch_check();
|
2017-10-01 04:14:41 +02:00
|
|
|
if (status == EVT_TOUCH_PRESSED || status == EVT_TOUCH_DOWN) {
|
2020-05-25 12:36:23 +02:00
|
|
|
touch_position(&touch_x, &touch_y);
|
|
|
|
|
switch (ui_mode) {
|
2016-12-17 12:33:04 +01:00
|
|
|
case UI_NORMAL:
|
2020-03-12 17:53:58 +01:00
|
|
|
// Try drag marker
|
2020-05-25 12:29:34 +02:00
|
|
|
if (touch_pickup_marker(touch_x, touch_y))
|
2017-01-03 08:39:00 +01:00
|
|
|
break;
|
2020-07-01 11:29:25 +02:00
|
|
|
#ifdef __USE_SD_CARD__
|
|
|
|
|
if (made_screenshot(touch_x, touch_y))
|
|
|
|
|
break;
|
|
|
|
|
#endif
|
2020-03-12 17:53:58 +01:00
|
|
|
// Try select lever mode (top and bottom screen)
|
2020-05-25 12:29:34 +02:00
|
|
|
if (touch_lever_mode_select(touch_x, touch_y)) {
|
2020-02-22 14:41:50 +01:00
|
|
|
touch_wait_release();
|
|
|
|
|
break;
|
2017-01-03 08:39:00 +01:00
|
|
|
}
|
2020-03-12 17:53:58 +01:00
|
|
|
// switch menu mode after release
|
2016-12-17 12:33:04 +01:00
|
|
|
touch_wait_release();
|
2020-03-12 17:53:58 +01:00
|
|
|
selection = -1; // hide keyboard mode selection
|
2016-12-17 12:33:04 +01:00
|
|
|
ui_mode_menu();
|
|
|
|
|
break;
|
|
|
|
|
case UI_MENU:
|
2020-05-25 12:29:34 +02:00
|
|
|
menu_apply_touch(touch_x, touch_y);
|
2016-12-17 10:32:27 +01:00
|
|
|
break;
|
2017-10-01 01:59:33 +02:00
|
|
|
|
|
|
|
|
case UI_NUMERIC:
|
2020-05-25 12:29:34 +02:00
|
|
|
numeric_apply_touch(touch_x, touch_y);
|
2017-10-01 01:59:33 +02:00
|
|
|
break;
|
2016-12-17 10:32:27 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
touch_start_watchdog();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
ui_process(void)
|
|
|
|
|
{
|
2020-03-05 20:36:44 +01:00
|
|
|
if (operation_requested&OP_LEVER)
|
2016-12-17 10:32:27 +01:00
|
|
|
ui_process_lever();
|
2020-03-05 20:36:44 +01:00
|
|
|
if (operation_requested&OP_TOUCH)
|
2016-12-17 10:32:27 +01:00
|
|
|
ui_process_touch();
|
|
|
|
|
operation_requested = OP_NONE;
|
2016-11-18 11:26:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Triggered when the button is pressed or released. The LED4 is set to ON.*/
|
2020-03-21 00:03:09 +01:00
|
|
|
static void extcb1(EXTDriver *extp, expchannel_t channel)
|
|
|
|
|
{
|
2016-11-18 11:26:53 +01:00
|
|
|
(void)extp;
|
|
|
|
|
(void)channel;
|
2020-03-05 20:36:44 +01:00
|
|
|
operation_requested|=OP_LEVER;
|
2016-11-30 12:17:55 +01:00
|
|
|
//cur_button = READ_PORT() & BUTTON_MASK;
|
2016-11-18 11:26:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static const EXTConfig extcfg = {
|
|
|
|
|
{
|
|
|
|
|
{EXT_CH_MODE_DISABLED, NULL},
|
|
|
|
|
{EXT_CH_MODE_RISING_EDGE | EXT_CH_MODE_AUTOSTART | EXT_MODE_GPIOA, extcb1},
|
|
|
|
|
{EXT_CH_MODE_RISING_EDGE | EXT_CH_MODE_AUTOSTART | EXT_MODE_GPIOA, extcb1},
|
|
|
|
|
{EXT_CH_MODE_RISING_EDGE | EXT_CH_MODE_AUTOSTART | EXT_MODE_GPIOA, extcb1},
|
|
|
|
|
{EXT_CH_MODE_DISABLED, NULL},
|
|
|
|
|
{EXT_CH_MODE_DISABLED, NULL},
|
|
|
|
|
{EXT_CH_MODE_DISABLED, NULL},
|
|
|
|
|
{EXT_CH_MODE_DISABLED, NULL},
|
|
|
|
|
{EXT_CH_MODE_DISABLED, NULL},
|
|
|
|
|
{EXT_CH_MODE_DISABLED, NULL},
|
|
|
|
|
{EXT_CH_MODE_DISABLED, NULL},
|
|
|
|
|
{EXT_CH_MODE_DISABLED, NULL},
|
|
|
|
|
{EXT_CH_MODE_DISABLED, NULL},
|
|
|
|
|
{EXT_CH_MODE_DISABLED, NULL},
|
|
|
|
|
{EXT_CH_MODE_DISABLED, NULL},
|
|
|
|
|
{EXT_CH_MODE_DISABLED, NULL},
|
|
|
|
|
{EXT_CH_MODE_DISABLED, NULL},
|
|
|
|
|
{EXT_CH_MODE_DISABLED, NULL},
|
|
|
|
|
{EXT_CH_MODE_DISABLED, NULL},
|
|
|
|
|
{EXT_CH_MODE_DISABLED, NULL},
|
|
|
|
|
{EXT_CH_MODE_DISABLED, NULL},
|
|
|
|
|
{EXT_CH_MODE_DISABLED, NULL},
|
|
|
|
|
{EXT_CH_MODE_DISABLED, NULL}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2020-05-25 12:29:34 +02:00
|
|
|
// Touch panel timer check (check press frequency 20Hz)
|
2016-12-06 19:34:33 +01:00
|
|
|
static const GPTConfig gpt3cfg = {
|
2020-07-15 13:34:50 +02:00
|
|
|
200, /* 200Hz timer clock.*/
|
2016-12-06 19:34:33 +01:00
|
|
|
NULL, /* Timer callback.*/
|
2016-12-17 05:16:56 +01:00
|
|
|
0x0020, /* CR2:MMS=02 to output TRGO */
|
2016-12-06 19:34:33 +01:00
|
|
|
0
|
|
|
|
|
};
|
|
|
|
|
|
2020-02-23 03:37:41 +01:00
|
|
|
#if 0
|
Big code redisign (increase CELL draw size, more faster screen render), also save about 4-5kB flash size
Try remove all hardcoded values from code (use definition if set)
Some error fix
main.c:
Rewrite Shell, now it run on main thread and require less RAM (not need stack)
(possible run it as thread if define VNA_SHELL_THREAD
Remove not used trace_info[].scale_unit in set_trace_scale/get_trace_scale (it just divede on set and multiple on get, better use it for default scale set)
Replace some hardcoded values
MARKERS_MAX
SAVEAREA_MAX
TRACES_MAX
plot.c
Rewrite CELLWIDTH and CELLHEIGHT use, now possible set any CELL width and height (CELLWIDTH * CELLHEIGHT <= spi_buffer size)
Free RAM from shell stack use fore increase spi_buffer size now it have 2048 pixel (64x32)
Rewrite cell index and markmap use (now correct use cell size, and more faster), correct use CELLWIDTH and CELLHEIGHT in calculation
Fore set update area use invalidateRect (still need use some hardcoded values :( )
Rewrite cell_draw_line
Rewrite many hardcoded size definitions
Refrence point now draw as bitmap (less size, more costumable)
Fix drag marker (now correct search closest index in search_nearest_index)
Rewrite plot_into_index, now correct use size definitions, moe
ui.c
Small rewrite keyboard definitions, for use less flash size
Define KP_WIDTH, KP_HEIGHT for set key size
Better look some big font symvols
All:
use static fore some local functions (use less space on calls)
replace tabs on spaces (code style)
Use M_PI from math.h fore define pi value
Fix printf on print HEX values
2020-02-22 08:50:54 +01:00
|
|
|
static void
|
2016-12-06 19:34:33 +01:00
|
|
|
test_touch(int *x, int *y)
|
|
|
|
|
{
|
2016-12-17 05:16:56 +01:00
|
|
|
adc_stop(ADC1);
|
|
|
|
|
|
|
|
|
|
*x = touch_measure_x();
|
2016-12-17 10:32:27 +01:00
|
|
|
*y = touch_measure_y();
|
2016-12-17 05:16:56 +01:00
|
|
|
|
2016-12-17 10:32:27 +01:00
|
|
|
touch_start_watchdog();
|
|
|
|
|
}
|
2020-02-23 03:37:41 +01:00
|
|
|
#endif
|
2016-12-17 10:32:27 +01:00
|
|
|
|
|
|
|
|
void
|
|
|
|
|
handle_touch_interrupt(void)
|
|
|
|
|
{
|
2020-03-05 20:36:44 +01:00
|
|
|
operation_requested|= OP_TOUCH;
|
2016-12-06 19:34:33 +01:00
|
|
|
}
|
|
|
|
|
|
2016-11-18 11:26:53 +01:00
|
|
|
void
|
|
|
|
|
ui_init()
|
|
|
|
|
{
|
2016-12-17 05:16:56 +01:00
|
|
|
adc_init();
|
2020-03-21 00:03:09 +01:00
|
|
|
|
2016-11-18 11:26:53 +01:00
|
|
|
/*
|
|
|
|
|
* Activates the EXT driver 1.
|
|
|
|
|
*/
|
|
|
|
|
extStart(&EXTD1, &extcfg);
|
2016-12-06 19:34:33 +01:00
|
|
|
|
2016-12-11 09:26:33 +01:00
|
|
|
#if 1
|
2016-12-06 19:34:33 +01:00
|
|
|
gptStart(&GPTD3, &gpt3cfg);
|
|
|
|
|
gptPolledDelay(&GPTD3, 10); /* Small delay.*/
|
|
|
|
|
|
2016-12-11 09:26:33 +01:00
|
|
|
gptStartContinuous(&GPTD3, 10);
|
|
|
|
|
#endif
|
2016-12-06 19:34:33 +01:00
|
|
|
|
2016-12-17 10:32:27 +01:00
|
|
|
touch_start_watchdog();
|
2016-11-18 11:26:53 +01:00
|
|
|
}
|