Add LCD command for debug (disabled as default)

Add defines for more easy change to 48kHz ADC
Add commented touch calibration settings for 4`LCD
This commit is contained in:
DiSlord 2020-07-17 17:36:14 +03:00
parent 3d927881af
commit bed63ca84b
3 changed files with 36 additions and 3 deletions

23
main.c
View file

@ -69,6 +69,7 @@ static volatile vna_shellcmd_t shell_function = 0;
#define ENABLE_COLOR_COMMAND #define ENABLE_COLOR_COMMAND
// Enable I2C command for send data to AIC3204, used for debug // Enable I2C command for send data to AIC3204, used for debug
//#define ENABLE_I2C_COMMAND //#define ENABLE_I2C_COMMAND
//#define ENABLE_LCD_COMMAND
static void apply_CH0_error_term_at(int i); static void apply_CH0_error_term_at(int i);
static void apply_CH1_error_term_at(int i); static void apply_CH1_error_term_at(int i);
@ -716,7 +717,7 @@ config_t config = {
.trace_color = { DEFAULT_TRACE_1_COLOR, DEFAULT_TRACE_2_COLOR, DEFAULT_TRACE_3_COLOR, DEFAULT_TRACE_4_COLOR }, .trace_color = { DEFAULT_TRACE_1_COLOR, DEFAULT_TRACE_2_COLOR, DEFAULT_TRACE_3_COLOR, DEFAULT_TRACE_4_COLOR },
// .touch_cal = { 693, 605, 124, 171 }, // 2.4 inch LCD panel // .touch_cal = { 693, 605, 124, 171 }, // 2.4 inch LCD panel
.touch_cal = { 338, 522, 153, 192 }, // 2.8 inch LCD panel .touch_cal = { 338, 522, 153, 192 }, // 2.8 inch LCD panel
// .touch_cal = { 252, 450, 111, 150 }, //4.0" LCD // .touch_cal = { 272, 521, 114, 153 }, //4.0" LCD
.harmonic_freq_threshold = FREQUENCY_THRESHOLD, .harmonic_freq_threshold = FREQUENCY_THRESHOLD,
.vbat_offset = 500, .vbat_offset = 500,
.bandwidth = BANDWIDTH_1000 .bandwidth = BANDWIDTH_1000
@ -2233,6 +2234,18 @@ VNA_SHELL_FUNCTION(cmd_i2c){
} }
#endif #endif
#ifdef ENABLE_LCD_COMMAND
VNA_SHELL_FUNCTION(cmd_lcd){
uint8_t d[VNA_SHELL_MAX_ARGUMENTS];
if (argc == 0) return;
for (int i=0;i<argc;i++)
d[i] = my_atoui(argv[i]);
uint32_t ret = lcd_send_command(d[0], argc-1, &d[1]);
shell_printf("ret = 0x%08X\r\n", ret);
chThdSleepMilliseconds(5);
}
#endif
#ifdef ENABLE_THREADS_COMMAND #ifdef ENABLE_THREADS_COMMAND
#if CH_CFG_USE_REGISTRY == FALSE #if CH_CFG_USE_REGISTRY == FALSE
#error "Threads Requite enabled CH_CFG_USE_REGISTRY in chconf.h" #error "Threads Requite enabled CH_CFG_USE_REGISTRY in chconf.h"
@ -2331,6 +2344,9 @@ static const VNAShellCommand commands[] =
#ifdef ENABLE_I2C_COMMAND #ifdef ENABLE_I2C_COMMAND
{"i2c" , cmd_i2c , CMD_WAIT_MUTEX}, {"i2c" , cmd_i2c , CMD_WAIT_MUTEX},
#endif #endif
#ifdef ENABLE_LCD_COMMAND
{"lcd" , cmd_lcd , CMD_WAIT_MUTEX},
#endif
#ifdef ENABLE_THREADS_COMMAND #ifdef ENABLE_THREADS_COMMAND
{"threads" , cmd_threads , 0}, {"threads" , cmd_threads , 0},
#endif #endif
@ -2402,6 +2418,11 @@ static void VNAShell_executeLine(char *line)
// Parse and execute line // Parse and execute line
char *lp = line, *ep; char *lp = line, *ep;
shell_nargs = 0; shell_nargs = 0;
#if 0 // debug console log
ili9341_fill(0, FREQUENCIES_YPOS, LCD_WIDTH, FONT_GET_HEIGHT, DEFAULT_BG_COLOR);
ili9341_drawstring(lp, FREQUENCIES_XPOS1, FREQUENCIES_YPOS);
osalThreadSleepMilliseconds(1000);
#endif
while (*lp != 0) { while (*lp != 0) {
// Skipping white space and tabs at string begin. // Skipping white space and tabs at string begin.
while (*lp == ' ' || *lp == '\t') lp++; while (*lp == ' ' || *lp == '\t') lp++;

View file

@ -38,6 +38,8 @@
#define FREQUENCY_THRESHOLD 300000100U #define FREQUENCY_THRESHOLD 300000100U
// Frequency offset (sin_cos table in dsp.c generated for 6k, 8k, 10k, if change need create new table ) // Frequency offset (sin_cos table in dsp.c generated for 6k, 8k, 10k, if change need create new table )
#define FREQUENCY_OFFSET 8000 #define FREQUENCY_OFFSET 8000
//For 48kHz
//#define FREQUENCY_OFFSET 5000
// Use real time build table (undef for use constant) // Use real time build table (undef for use constant)
//#define USE_VARIABLE_OFFSET //#define USE_VARIABLE_OFFSET
// Speed of light const // Speed of light const
@ -140,12 +142,20 @@ extern const char *info_about[];
// Bandwidth depend from AUDIO_SAMPLES_COUNT and audio ADC frequency // Bandwidth depend from AUDIO_SAMPLES_COUNT and audio ADC frequency
// for AUDIO_SAMPLES_COUNT = 48 and ADC = 96kHz one measure give 96000/48=2000Hz // for AUDIO_SAMPLES_COUNT = 48 and ADC = 96kHz one measure give 96000/48=2000Hz
// define additional measure count // define additional measure count
#if AUDIO_ADC_FREQ/AUDIO_SAMPLES_COUNT == 2000
#define BANDWIDTH_2000 ( 1 - 1) #define BANDWIDTH_2000 ( 1 - 1)
#define BANDWIDTH_1000 ( 2 - 1) #define BANDWIDTH_1000 ( 2 - 1)
#define BANDWIDTH_333 ( 6 - 1) #define BANDWIDTH_333 ( 6 - 1)
#define BANDWIDTH_100 ( 20 - 1) #define BANDWIDTH_100 ( 20 - 1)
#define BANDWIDTH_30 ( 66 - 1) #define BANDWIDTH_30 ( 66 - 1)
#define BANDWIDTH_10 (200 - 1) #define BANDWIDTH_10 (200 - 1)
#elif AUDIO_ADC_FREQ/AUDIO_SAMPLES_COUNT == 1000
#define BANDWIDTH_1000 ( 1 - 1)
#define BANDWIDTH_333 ( 3 - 1)
#define BANDWIDTH_100 ( 10 - 1)
#define BANDWIDTH_30 ( 33 - 1)
#define BANDWIDTH_10 (100 - 1)
#endif
#ifdef ENABLED_DUMP #ifdef ENABLED_DUMP
extern int16_t ref_buf[]; extern int16_t ref_buf[];

4
ui.c
View file

@ -43,7 +43,7 @@ uistat_t uistat = {
#define BUTTON_DOWN_LONG_TICKS 5000 /* 500ms */ #define BUTTON_DOWN_LONG_TICKS 5000 /* 500ms */
#define BUTTON_DOUBLE_TICKS 2500 /* 250ms */ #define BUTTON_DOUBLE_TICKS 2500 /* 250ms */
#define BUTTON_REPEAT_TICKS 200 /* 20ms */ #define BUTTON_REPEAT_TICKS 100 /* 10ms */
#define BUTTON_DEBOUNCE_TICKS 400 /* 40ms */ #define BUTTON_DEBOUNCE_TICKS 400 /* 40ms */
/* lever switch assignment */ /* lever switch assignment */
@ -1136,7 +1136,9 @@ const menuitem_t menu_transform[] = {
}; };
const menuitem_t menu_bandwidth[] = { const menuitem_t menu_bandwidth[] = {
#ifdef BANDWIDTH_2000
{ MT_ADV_CALLBACK, BANDWIDTH_2000, "2 kHz", menu_bandwidth_acb }, { MT_ADV_CALLBACK, BANDWIDTH_2000, "2 kHz", menu_bandwidth_acb },
#endif
{ MT_ADV_CALLBACK, BANDWIDTH_1000, "1 kHz", menu_bandwidth_acb }, { MT_ADV_CALLBACK, BANDWIDTH_1000, "1 kHz", menu_bandwidth_acb },
{ MT_ADV_CALLBACK, BANDWIDTH_333, "333 Hz", 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_100, "100 Hz", menu_bandwidth_acb },