Merge branch 'master' into tinySA-V4

Removed_REF_marker
erikkaashoek 5 years ago
commit 58be2b410c

@ -75,16 +75,11 @@ checksum(const void *start, size_t len)
return value; return value;
} }
#define FLASH_PAGESIZE 0x800
const uint32_t save_config_area = SAVE_CONFIG_ADDR;
int int
config_save(void) config_save(void)
{ {
uint16_t *src = (uint16_t*)&config; uint16_t *src = (uint16_t*)&config;
uint16_t *dst = (uint16_t*)save_config_area; uint16_t *dst = (uint16_t*)SAVE_CONFIG_ADDR;
int count = sizeof(config_t) / sizeof(uint16_t); int count = sizeof(config_t) / sizeof(uint16_t);
config.magic = CONFIG_MAGIC; config.magic = CONFIG_MAGIC;
@ -107,7 +102,7 @@ config_save(void)
int int
config_recall(void) config_recall(void)
{ {
const config_t *src = (const config_t*)save_config_area; const config_t *src = (const config_t*)SAVE_CONFIG_ADDR;
void *dst = &config; void *dst = &config;
if (src->magic != CONFIG_MAGIC) if (src->magic != CONFIG_MAGIC)
@ -120,31 +115,19 @@ config_recall(void)
return 0; return 0;
} }
const uint32_t saveareas[SAVEAREA_MAX] =
{ //int16_t lastsaveid = 0;
SAVE_PROP_CONFIG_0_ADDR,
SAVE_PROP_CONFIG_1_ADDR,
SAVE_PROP_CONFIG_2_ADDR,
SAVE_PROP_CONFIG_3_ADDR,
SAVE_PROP_CONFIG_4_ADDR,
SAVE_PROP_CONFIG_5_ADDR,
SAVE_PROP_CONFIG_6_ADDR,
SAVE_PROP_CONFIG_7_ADDR,
SAVE_PROP_CONFIG_8_ADDR,
};
int16_t lastsaveid = 0;
int int
caldata_save(int id) caldata_save(uint16_t id)
{ {
if (id >= SAVEAREA_MAX)
return -1;
uint16_t *src = (uint16_t*)&setting; uint16_t *src = (uint16_t*)&setting;
uint16_t *dst; uint16_t *dst;
int count = sizeof(setting_t) / sizeof(uint16_t); int count = sizeof(setting_t) / sizeof(uint16_t);
if (id < 0 || id >= SAVEAREA_MAX) dst = (uint16_t*)(SAVE_PROP_CONFIG_ADDR + id * SAVE_PROP_CONFIG_SIZE);
return -1;
dst = (uint16_t*)saveareas[id];
setting.magic = CONFIG_MAGIC; setting.magic = CONFIG_MAGIC;
setting.checksum = checksum( setting.checksum = checksum(
@ -160,13 +143,12 @@ caldata_save(int id)
p += FLASH_PAGESIZE; p += FLASH_PAGESIZE;
} }
/* write to flash */ /* write settings to flash */
while (count-- > 0) { while (count-- > 0) {
flash_program_half_word((uint32_t)dst, *src++); flash_program_half_word((uint32_t)dst, *src++);
dst++; dst++;
} }
// Flash stored trace to flash
// Flash stored trace
count = sizeof(stored_t) / sizeof(uint16_t); count = sizeof(stored_t) / sizeof(uint16_t);
src = (uint16_t*)&stored_t[0]; src = (uint16_t*)&stored_t[0];
while (count-- > 0) { while (count-- > 0) {
@ -176,22 +158,22 @@ caldata_save(int id)
/* after saving data, make active configuration points to flash */ /* after saving data, make active configuration points to flash */
// active_props = (setting_t*)saveareas[id]; // active_props = (setting_t*)saveareas[id];
lastsaveid = id; // lastsaveid = id;
return 0; return 0;
} }
int int
caldata_recall(int id) caldata_recall(uint16_t id)
{ {
setting_t *src; setting_t *src;
void *dst = &setting; void *dst = &setting;
if (id < 0 || id >= SAVEAREA_MAX) if (id >= SAVEAREA_MAX)
return -1; return -1;
// point to saved area on the flash memory // point to saved area on the flash memory
src = (setting_t*)saveareas[id]; src = (setting_t*)(SAVE_PROP_CONFIG_ADDR + id * SAVE_PROP_CONFIG_SIZE);
if (src->magic != CONFIG_MAGIC) if (src->magic != CONFIG_MAGIC)
return -1; return -1;
@ -200,7 +182,7 @@ caldata_recall(int id)
/* active configuration points to save data on flash memory */ /* active configuration points to save data on flash memory */
// active_props = src; // active_props = src;
lastsaveid = id; // lastsaveid = id;
/* duplicated saved data onto sram to be able to modify marker/trace */ /* duplicated saved data onto sram to be able to modify marker/trace */
memcpy(dst, src, sizeof(setting_t)); memcpy(dst, src, sizeof(setting_t));
@ -229,16 +211,14 @@ caldata_ref(int id)
} }
#endif #endif
const uint32_t save_config_prop_area_size = SAVE_CONFIG_AREA_SIZE;
void void
clear_all_config_prop_data(void) clear_all_config_prop_data(void)
{ {
flash_unlock(); flash_unlock();
/* erase flash pages */ /* erase flash pages */
void *p = (void*)save_config_area; void *p = (void*)SAVE_CONFIG_ADDR;
void *tail = p + save_config_prop_area_size; void *tail = p + SAVE_CONFIG_AREA_SIZE;
while (p < tail) { while (p < tail) {
flash_erase_page((uint32_t)p); flash_erase_page((uint32_t)p);
p += FLASH_PAGESIZE; p += FLASH_PAGESIZE;

@ -443,8 +443,8 @@ typedef struct config {
uint32_t harmonic_freq_threshold; uint32_t harmonic_freq_threshold;
#endif #endif
uint16_t vbat_offset; uint16_t vbat_offset;
int16_t low_level_offset; float low_level_offset;
int16_t high_level_offset; float high_level_offset;
uint32_t correction_frequency[CORRECTION_POINTS]; uint32_t correction_frequency[CORRECTION_POINTS];
float correction_value[CORRECTION_POINTS]; float correction_value[CORRECTION_POINTS];
uint32_t deviceid; uint32_t deviceid;
@ -454,7 +454,7 @@ typedef struct config {
extern config_t config; extern config_t config;
//#define settingLevelOffset config.level_offset //#define settingLevelOffset config.level_offset
int get_level_offset(void); float get_level_offset(void);
void set_trace_type(int t, int type); void set_trace_type(int t, int type);
void set_trace_channel(int t, int channel); void set_trace_channel(int t, int channel);
@ -706,6 +706,9 @@ extern const float unit_scale_value[];
extern const char * const unit_scale_text[]; extern const char * const unit_scale_text[];
#if 1 #if 1
// Flash save area - flash7 : org = 0x0801B000, len = 20k in *.ld file
// 2k - for config save
// 9 * 2k for setting_t + stored trace
#define SAVEAREA_MAX 9 #define SAVEAREA_MAX 9
// config save area (see flash7 area start) // config save area (see flash7 area start)
#define SAVE_CONFIG_ADDR 0x0803B000 #define SAVE_CONFIG_ADDR 0x0803B000
@ -726,6 +729,7 @@ extern const char * const unit_scale_text[];
// Used for erase all config/prop data see flash7 area size // Used for erase all config/prop data see flash7 area size
#define SAVE_CONFIG_AREA_SIZE (SAVE_CONFIG_SIZE + SAVEAREA_MAX*SAVE_PROP_SIZE) // Should include all save slots #define SAVE_CONFIG_AREA_SIZE (SAVE_CONFIG_SIZE + SAVEAREA_MAX*SAVE_PROP_SIZE) // Should include all save slots
#else #else
#define SAVEAREA_MAX 4 #define SAVEAREA_MAX 4
// Begin addr 0x0801C000 // Begin addr 0x0801C000
@ -809,8 +813,8 @@ extern int16_t lastsaveid;
#define FREQ_IS_STARTSTOP() (!(setting.freq_mode&FREQ_MODE_CENTER_SPAN)) #define FREQ_IS_STARTSTOP() (!(setting.freq_mode&FREQ_MODE_CENTER_SPAN))
#define FREQ_IS_CENTERSPAN() (setting.freq_mode&FREQ_MODE_CENTER_SPAN) #define FREQ_IS_CENTERSPAN() (setting.freq_mode&FREQ_MODE_CENTER_SPAN)
#define FREQ_IS_CW() (setting.frequency0 == setting.frequency1) #define FREQ_IS_CW() (setting.frequency0 == setting.frequency1)
int caldata_recall(int id); int caldata_recall(uint16_t id);
int caldata_save(int id); int caldata_save(uint16_t id);
//const properties_t *caldata_ref(int id); //const properties_t *caldata_ref(int id);
int config_save(void); int config_save(void);
int config_recall(void); int config_recall(void);

@ -845,13 +845,10 @@ extern const char *unit_string[];
static void trace_get_value_string( static void trace_get_value_string(
int t, char *buf, int len, int t, char *buf, int len,
int i, float coeff[POINTS_COUNT], int i, float coeff[POINTS_COUNT],
uint32_t freq[POINTS_COUNT], int ri, int mtype,
int point_count, uint32_t i_freq, uint32_t ref_freq)
int ri, int mtype)
{ {
(void) t; (void) t;
(void)freq;
(void) point_count;
float v; float v;
char buf2[16]; char buf2[16];
char buf3[8]; char buf3[8];
@ -864,17 +861,17 @@ static void trace_get_value_string(
*ptr2++ = S_DELTA[0]; *ptr2++ = S_DELTA[0];
unit_index = setting.unit+5; unit_index = setting.unit+5;
if (ri > i) { if (ri > i) {
dfreq = frequencies[ri] - frequencies[i]; dfreq = ref_freq - i_freq;
ii = ri - i; ii = ri - i;
*ptr2++ = '-'; *ptr2++ = '-';
} else { } else {
dfreq = frequencies[i] - frequencies[ri]; dfreq = i_freq - ref_freq;
ii = i - ri; ii = i - ri;
*ptr2++ = '+'; *ptr2++ = '+';
} }
rlevel = value(coeff[ri]); rlevel = value(coeff[ri]);
} else { } else {
dfreq = frequencies[i]; dfreq = i_freq;
} }
if (FREQ_IS_CW()) { if (FREQ_IS_CW()) {
float t = ii*(setting.actual_sweep_time_us)/(sweep_points - 1); float t = ii*(setting.actual_sweep_time_us)/(sweep_points - 1);
@ -2112,7 +2109,7 @@ static void cell_draw_marker_info(int x0, int y0)
// cell_drawstring_7x13(buf, xpos, ypos); // cell_drawstring_7x13(buf, xpos, ypos);
trace_get_value_string( trace_get_value_string(
t, &buf[k], (sizeof buf) - k, t, &buf[k], (sizeof buf) - k,
idx, measured[trace[t].channel], frequencies, sweep_points, ridx, markers[i].mtype); idx, measured[trace[t].channel], ridx, markers[i].mtype,markers[i].frequency, markers[ref_marker].frequency);
if (/* strlen(buf)*7> WIDTH/2 && */active > 1) if (/* strlen(buf)*7> WIDTH/2 && */active > 1)
cell_drawstring(buf, xpos, ypos); cell_drawstring(buf, xpos, ypos);
else else

@ -175,8 +175,8 @@ VNA_SHELL_FUNCTION(cmd_levelchange)
VNA_SHELL_FUNCTION(cmd_leveloffset) VNA_SHELL_FUNCTION(cmd_leveloffset)
{ {
if (argc == 0) { if (argc == 0) {
shell_printf("leveloffset low %.1f\r\n", (float) config.low_level_offset); shell_printf("leveloffset low %.1f\r\n", config.low_level_offset);
shell_printf("leveloffset high %.1f\r\n", (float)config.high_level_offset); shell_printf("leveloffset high %.1f\r\n", config.high_level_offset);
return; return;
} else if (argc == 2) { } else if (argc == 2) {
float v = my_atof(argv[1]); float v = my_atof(argv[1]);
@ -612,6 +612,8 @@ VNA_SHELL_FUNCTION(cmd_scanraw)
old_points = points; old_points = points;
} }
operation_requested = false; operation_requested = false;
dirty = true;
for (uint32_t i = 0; i<points; i++) { for (uint32_t i = 0; i<points; i++) {
int val = perform(false, i, start +(uint32_t)(f_step * i), false) + float_TO_PURE_RSSI(EXT_ZERO_LEVEL); int val = perform(false, i, start +(uint32_t)(f_step * i), false) + float_TO_PURE_RSSI(EXT_ZERO_LEVEL);
if (operation_requested) // break on operation in perform if (operation_requested) // break on operation in perform

@ -491,11 +491,12 @@ void set_actual_power(float o) // Set peak level to known value
config.low_level_offset = new_offset; config.low_level_offset = new_offset;
#endif #endif
} }
dirty = true;
config_save(); config_save();
// dirty = true; // No HW update required, only status panel refresh // dirty = true; // No HW update required, only status panel refresh
} }
int get_level_offset(void) float get_level_offset(void)
{ {
if (setting.mode == M_HIGH) { if (setting.mode == M_HIGH) {
if (config.high_level_offset == 100) // Offset of 100 means not calibrated if (config.high_level_offset == 100) // Offset of 100 means not calibrated
@ -618,6 +619,21 @@ void toggle_AGC(void)
dirty = true; dirty = true;
} }
void auto_set_AGC_LNA(int auto_set) // Adapt the AGC setting if needed
{
static unsigned char old_v;
unsigned char v;
if (auto_set)
v = 0x60; // Enable AGC and disable LNA
else
v = 0x40; // Disable AGC and enable LNA
if (old_v != v) {
SI4432_Sel = SI4432_RX ;
SI4432_Write_Byte(SI4432_AGC_OVERRIDE, v);
old_v = v;
}
}
void set_unit(int u) void set_unit(int u)
{ {
if (setting.unit == u) if (setting.unit == u)
@ -1476,16 +1492,10 @@ pureRSSI_t perform(bool break_on_operation, int i, uint32_t f, int tracking)
} }
if (setting.mode == M_LOW && S_IS_AUTO(setting.agc) && UNIT_IS_LOG(setting.unit)) { // If in low input mode with auto AGC and log unit if (setting.mode == M_LOW && S_IS_AUTO(setting.agc) && UNIT_IS_LOG(setting.unit)) { // If in low input mode with auto AGC and log unit
unsigned char v; // Adapt the AGC setting if needed
static unsigned char old_v;
if (f < 500000) if (f < 500000)
v = 0x50; // Disable AGC and enable LNA auto_set_AGC_LNA(false);
else else
v = 0x60; // Enable AGC and disable LNA auto_set_AGC_LNA(true);
if (old_v != v) {
SI4432_Write_Byte(SI4432_AGC_OVERRIDE, v);
old_v = v;
}
} }
// ----------------------------------------------------- modulation for output modes --------------------------------------- // ----------------------------------------------------- modulation for output modes ---------------------------------------
@ -1998,18 +2008,11 @@ sweep_again: // stay in sweep loop when output mo
// ---------------------------------- auto AGC ---------------------------------- // ---------------------------------- auto AGC ----------------------------------
if (!in_selftest && MODE_INPUT(setting.mode) && S_IS_AUTO(setting.agc) && UNIT_IS_LINEAR(setting.unit)) { // Auto AGC in linear mode if (!in_selftest && MODE_INPUT(setting.mode) && S_IS_AUTO(setting.agc) && UNIT_IS_LINEAR(setting.unit)) { // Auto AGC in linear mode
unsigned char v;
static unsigned char old_v;
float actual_max_level = actual_t[max_index[0]] - get_attenuation(); float actual_max_level = actual_t[max_index[0]] - get_attenuation();
if (actual_max_level > - 45) if (actual_max_level > - 45)
v = 0x50; // Disable AGC and enable LNA auto_set_AGC_LNA(false);
else else
v = 0x60; // Enable AGC and disable LNA auto_set_AGC_LNA(TRUE);
if (old_v != v) {
SI4432_Write_Byte(SI4432_AGC_OVERRIDE, v);
old_v = v;
}
} }
@ -2070,6 +2073,19 @@ sweep_again: // stay in sweep loop when output mo
if (markers[m].enabled && markers[m].mtype & M_TRACKING) { // Available marker found if (markers[m].enabled && markers[m].mtype & M_TRACKING) { // Available marker found
markers[m].index = max_index[i]; markers[m].index = max_index[i];
markers[m].frequency = frequencies[markers[m].index]; markers[m].frequency = frequencies[markers[m].index];
#if 1 // Hyperbolic interpolation, can be removed to save memory
const int idx = markers[m].index;
if (idx > 0 && idx < sweep_points-1)
{
const float y1 = actual_t[idx - 1];
const float y2 = actual_t[idx + 0];
const float y3 = actual_t[idx + 1];
const float d = 0.5f * (y1 - y3) / ((y1 - (2 * y2) + y3) + 1e-12f);
//const float bin = (float)idx + d;
const int32_t delta_Hz = abs((int64_t)frequencies[idx + 0] - frequencies[idx + 1]);
markers[m].frequency += (int32_t)(delta_Hz * d);
}
#endif
m++; m++;
break; // Next maximum break; // Next maximum
} }

@ -640,7 +640,7 @@ void SI4432_Sub_Init(void)
// SI4432_Write_3_Byte(SI4432_IF_FILTER_BW, 0x81, 0x3C, 0x02) ; // <---------- // SI4432_Write_3_Byte(SI4432_IF_FILTER_BW, 0x81, 0x3C, 0x02) ; // <----------
// SI4432_Write_Byte(SI4432_IF_FILTER_BW, 0x81) ; // <---------- // SI4432_Write_Byte(SI4432_IF_FILTER_BW, 0x81) ; // <----------
SI4432_Write_Byte(SI4432_AFC_LOOP_GEARSHIFT_OVERRIDE, 0x00) ; SI4432_Write_Byte(SI4432_AFC_LOOP_GEARSHIFT_OVERRIDE, 0x00) ;
// SI4432_Write_Byte(SI4432_AFC_TIMING_CONTROL, 0x02) ; // <---------- SI4432_Write_Byte(SI4432_AFC_TIMING_CONTROL, 0x02) ;
SI4432_Write_Byte(SI4432_CLOCK_RECOVERY_GEARSHIFT, 0x03) ; SI4432_Write_Byte(SI4432_CLOCK_RECOVERY_GEARSHIFT, 0x03) ;
// SI4432_Write_Byte(SI4432_CLOCK_RECOVERY_OVERSAMPLING, 0x78) ; // <---------- // SI4432_Write_Byte(SI4432_CLOCK_RECOVERY_OVERSAMPLING, 0x78) ; // <----------
// SI4432_Write_3_Byte(SI4432_CLOCK_RECOVERY_OFFSET2, 0x01, 0x11, 0x11) ; // <---------- // SI4432_Write_3_Byte(SI4432_CLOCK_RECOVERY_OFFSET2, 0x01, 0x11, 0x11) ; // <----------

162
ui.c

@ -69,7 +69,7 @@ volatile uint8_t operation_requested = OP_NONE;
int8_t previous_marker = -1; int8_t previous_marker = -1;
enum { enum {
UI_NORMAL, UI_MENU, UI_NUMERIC, UI_KEYPAD UI_NORMAL, UI_MENU, UI_KEYPAD
}; };
#ifdef __VNA__ #ifdef __VNA__
@ -138,13 +138,11 @@ static int16_t last_touch_y;
void ui_mode_normal(void); void ui_mode_normal(void);
//static void ui_mode_menu(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 ui_mode_keypad(int _keypad_mode);
// static void draw_menu(void); // static void draw_menu(void);
static void leave_ui_mode(void); static void leave_ui_mode(void);
static void erase_menu_buttons(void); static void erase_menu_buttons(void);
static void ui_process_keypad(void); static void ui_process_keypad(void);
static void ui_process_numeric(void);
static void choose_active_marker(void); static void choose_active_marker(void);
static void menu_move_back(void); static void menu_move_back(void);
static void menu_move_back_and_leave_ui(void); static void menu_move_back_and_leave_ui(void);
@ -1256,7 +1254,6 @@ menu_move_top(void)
static void static void
menu_invoke(int item) menu_invoke(int item)
{ {
int status;
const menuitem_t *menu = menu_stack[menu_current_level]; const menuitem_t *menu = menu_stack[menu_current_level];
menu = &menu[item]; menu = &menu[item];
@ -1289,11 +1286,6 @@ menu_invoke(int item)
break; break;
case MT_KEYPAD: case MT_KEYPAD:
status = btn_wait_release();
if (status & EVT_BUTTON_DOWN_LONG) {
ui_mode_numeric(menu->data);
// ui_process_numeric();
} else {
if (menu->type & MT_FORM) { if (menu->type & MT_FORM) {
area_width = AREA_WIDTH_NORMAL - MENU_BUTTON_WIDTH; area_width = AREA_WIDTH_NORMAL - MENU_BUTTON_WIDTH;
redraw_frame(); // Remove form numbers redraw_frame(); // Remove form numbers
@ -1307,7 +1299,6 @@ menu_invoke(int item)
} }
ui_mode_keypad(menu->data); ui_mode_keypad(menu->data);
ui_process_keypad(); ui_process_keypad();
}
redraw_request |= REDRAW_CAL_STATUS; redraw_request |= REDRAW_CAL_STATUS;
break; break;
} }
@ -1513,12 +1504,6 @@ draw_numeric_input(const char *buf)
else// if (c >= '0' && c <= '9') else// if (c >= '0' && c <= '9')
c = c - '0'; c = c - '0';
if (ui_mode == UI_NUMERIC && uistat.digit == 8-i) {
fg = DEFAULT_SPEC_INPUT_COLOR;
focused = TRUE;
// if (uistat.digit_mode)
// bg = DEFAULT_MENU_COLOR;
}
ili9341_set_foreground(fg); ili9341_set_foreground(fg);
ili9341_set_background(bg); ili9341_set_background(bg);
if (c >= 0) // c is number if (c >= 0) // c is number
@ -1834,10 +1819,11 @@ menu_select_touch(int i)
keypad_mode = v; keypad_mode = v;
fetch_numeric_target(); fetch_numeric_target();
float m = 1.0; float m = 1.0;
if (touch_x < LCD_WIDTH/2 - 10) { #define TOUCH_DEAD_ZONE 5
m = 1/pow(10, ((LCD_WIDTH/2 - 10) - touch_x)/1000.0); if (touch_x < LCD_WIDTH/2 - TOUCH_DEAD_ZONE) {
m = 1 / (1 + pow(10, -6 + ((LCD_WIDTH/2 - TOUCH_DEAD_ZONE) - touch_x)/20.0));
} else if (touch_x > LCD_WIDTH/2 + 10) { } else if (touch_x > LCD_WIDTH/2 + 10) {
m = pow(10, (touch_x - (LCD_WIDTH/2 + 10))/1000.0); m = 1 + pow(10, -6 + (touch_x - (LCD_WIDTH/2 + TOUCH_DEAD_ZONE))/20.0);
} }
uistat.value *= m; uistat.value *= m;
set_numeric_value(); set_numeric_value();
@ -1931,9 +1917,6 @@ leave_ui_mode()
// if (ui_mode == UI_MENU) { // if (ui_mode == UI_MENU) {
// request_to_draw_cells_behind_menu(); // request_to_draw_cells_behind_menu();
// erase_menu_buttons(); // erase_menu_buttons();
// } else if (ui_mode == UI_NUMERIC) {
// request_to_draw_cells_behind_numeric_input();
// erase_numeric_input();
// } // }
// Erase bottom area (not redraw on area update) // Erase bottom area (not redraw on area update)
if (MENU_BUTTON_HEIGHT*MENU_BUTTON_MAX - area_height > 0) if (MENU_BUTTON_HEIGHT*MENU_BUTTON_MAX - area_height > 0)
@ -2024,14 +2007,6 @@ set_numeric_value(void)
} }
#endif #endif
static void
draw_numeric_area(void)
{
char buf[10];
plot_printf(buf, sizeof buf, "%9d", ((int32_t)uistat.value));
draw_numeric_input(buf);
}
void void
ui_mode_menu(void) ui_mode_menu(void)
{ {
@ -2046,25 +2021,6 @@ ui_mode_menu(void)
draw_menu(); draw_menu();
} }
static void
ui_mode_numeric(int _keypad_mode)
{
if (ui_mode == UI_NUMERIC)
return;
leave_ui_mode();
// keypads array
keypad_mode = _keypad_mode;
ui_mode = UI_NUMERIC;
area_width = AREA_WIDTH_NORMAL;
area_height = LCD_HEIGHT-NUM_INPUT_HEIGHT;//AREA_HEIGHT_NORMAL - 32;
draw_numeric_area_frame();
fetch_numeric_target();
draw_numeric_area();
}
static void static void
ui_mode_keypad(int _keypad_mode) ui_mode_keypad(int _keypad_mode)
{ {
@ -2412,107 +2368,6 @@ keypad_apply_touch(void)
return -1; return -1;
} }
static void
numeric_apply_touch(void)
{
int touch_x, touch_y;
touch_position(&touch_x, &touch_y);
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;
}
if (touch_y > LCD_HEIGHT-40) {
int n = 9 - (touch_x - 64) / 20;
uistat.digit = n;
uistat.digit_mode = TRUE;
} else {
int step, n;
if (touch_y < 100) {
step = 1;
} else {
step = -1;
}
for (n = uistat.digit; n > 0; n--)
step *= 10;
uistat.value += step;
}
draw_numeric_area();
touch_wait_release();
uistat.digit_mode = FALSE;
draw_numeric_area();
return;
}
static void
ui_process_numeric(void)
{
int status = btn_check();
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) {
if (status & EVT_DOWN) {
if (uistat.digit < 8)
uistat.digit++;
else
goto exit;
}
if (status & EVT_UP) {
if (uistat.digit > 0)
uistat.digit--;
else
goto exit;
}
} else {
int32_t step = 1;
int n;
for (n = uistat.digit; n > 0; n--)
step *= 10;
if (status & EVT_DOWN)
uistat.value += step;
if (status & EVT_UP)
uistat.value -= step;
}
draw_numeric_area();
status = btn_wait_release();
} while (status != 0);
}
}
return;
exit:
// cancel operation
ui_mode_normal();
}
static void static void
ui_process_keypad(void) ui_process_keypad(void)
{ {
@ -2573,9 +2428,6 @@ ui_process_lever(void)
case UI_MENU: case UI_MENU:
ui_process_menu(); ui_process_menu();
break; break;
case UI_NUMERIC:
ui_process_numeric();
break;
case UI_KEYPAD: case UI_KEYPAD:
ui_process_keypad(); ui_process_keypad();
break; break;
@ -2731,10 +2583,6 @@ void ui_process_touch(void)
case UI_MENU: case UI_MENU:
menu_apply_touch(); menu_apply_touch();
break; break;
case UI_NUMERIC:
numeric_apply_touch();
break;
} }
} }
touch_start_watchdog(); touch_start_watchdog();

@ -1587,11 +1587,21 @@ static const menuitem_t menu_config[] = {
{ MT_NONE, 0, NULL, NULL } // sentinel { MT_NONE, 0, NULL, NULL } // sentinel
}; };
static const menuitem_t menu_display[] = { static const menuitem_t menu_storage[] = {
{ MT_ADV_CALLBACK,0, "PAUSE\nSWEEP", menu_pause_acb},
{ MT_ADV_CALLBACK,0, "STORE\nTRACE", menu_storage_acb}, { MT_ADV_CALLBACK,0, "STORE\nTRACE", menu_storage_acb},
{ MT_ADV_CALLBACK,1, "CLEAR\nSTORED", menu_storage_acb}, { MT_ADV_CALLBACK,1, "CLEAR\nSTORED", menu_storage_acb},
{ MT_ADV_CALLBACK,2, "SUBTRACT\nSTORED",menu_storage_acb}, { MT_ADV_CALLBACK,2, "SUBTRACT\nSTORED",menu_storage_acb},
{ MT_CANCEL, 0, S_LARROW" BACK", NULL },
{ MT_NONE, 0, NULL, NULL } // sentinel
};
static const menuitem_t menu_display[] = {
{ MT_ADV_CALLBACK,0, "PAUSE\nSWEEP", menu_pause_acb},
{ MT_SUBMENU, 0, "CALC", menu_average},
{ MT_SUBMENU, 0, "STORAGE", menu_storage},
// { MT_ADV_CALLBACK,0, "STORE\nTRACE", menu_storage_acb},
// { MT_ADV_CALLBACK,1, "CLEAR\nSTORED", menu_storage_acb},
// { MT_ADV_CALLBACK,2, "SUBTRACT\nSTORED",menu_storage_acb},
{ MT_ADV_CALLBACK,3, "NORMALIZE", menu_storage_acb}, { MT_ADV_CALLBACK,3, "NORMALIZE", menu_storage_acb},
{ MT_ADV_CALLBACK,4, "WATER\nFALL", menu_waterfall_acb}, { MT_ADV_CALLBACK,4, "WATER\nFALL", menu_waterfall_acb},
{ MT_SUBMENU, 0, "SWEEP\nSETTINGS", menu_sweep_speed}, { MT_SUBMENU, 0, "SWEEP\nSETTINGS", menu_sweep_speed},
@ -1631,7 +1641,7 @@ static const menuitem_t menu_level[] = {
//{ MT_SUBMENU, 0, "SCALE/DIV", menu_scale_per}, //{ MT_SUBMENU, 0, "SCALE/DIV", menu_scale_per},
{ MT_KEYPAD, KM_SCALE, "SCALE/DIV", NULL}, { MT_KEYPAD, KM_SCALE, "SCALE/DIV", NULL},
{ MT_SUBMENU, 0, "ATTENUATE", menu_atten}, { MT_SUBMENU, 0, "ATTENUATE", menu_atten},
{ MT_SUBMENU,0, "CALC", menu_average}, // { MT_SUBMENU,0, "CALC", menu_average},
{ MT_SUBMENU, 0, "UNIT", menu_unit}, { MT_SUBMENU, 0, "UNIT", menu_unit},
{ MT_KEYPAD, KM_OFFSET, "EXTERNAL\nAMP",NULL}, { MT_KEYPAD, KM_OFFSET, "EXTERNAL\nAMP",NULL},
{ MT_SUBMENU, 0, "TRIGGER", menu_trigger}, { MT_SUBMENU, 0, "TRIGGER", menu_trigger},

Loading…
Cancel
Save

Powered by TurnKey Linux.