add cal status indicator

This commit is contained in:
TT 2016-11-18 00:53:40 +09:00
parent 04d1ec19ab
commit 052460d145
5 changed files with 62 additions and 7 deletions

4
dsp.c
View file

@ -133,8 +133,8 @@ void calclate_gamma(float *gamma)
acc_i += (float)(s0 * ri); acc_i += (float)(s0 * ri);
acc_ref += (float)rr*rr + (float)ri*ri; acc_ref += (float)rr*rr + (float)ri*ri;
} }
rn = sqrtf(acc_ref / len) * 2e3 * len; //rn = sqrtf(acc_ref / len) * 2e3 * len;
//rn = acc_ref; rn = acc_ref / 10;
gamma[0] = -acc_r / rn; gamma[0] = -acc_r / rn;
gamma[1] = -acc_i / rn; gamma[1] = -acc_i / rn;
} }

View file

@ -64,6 +64,8 @@ const uint32_t saveareas[] =
#define FLASH_PAGESIZE 0x800 #define FLASH_PAGESIZE 0x800
int16_t lastsaveid = 0;
int int
caldata_save(int id) caldata_save(int id)
@ -98,6 +100,8 @@ caldata_save(int id)
/* after saving data, make active configuration points to flash */ /* after saving data, make active configuration points to flash */
active = (config_t*)saveareas[id]; active = (config_t*)saveareas[id];
lastsaveid = id;
return 0; return 0;
} }
@ -118,6 +122,7 @@ caldata_recall(int id)
/* active configuration points to save data on flash memory */ /* active configuration points to save data on flash memory */
active = src; active = src;
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(config_t)); memcpy(dst, src, sizeof(config_t));

10
main.c
View file

@ -368,7 +368,7 @@ ensure_edit_config(void)
if (active == &current_config) if (active == &current_config)
return; return;
memcpy(&current_config, active, sizeof(config_t)); //memcpy(&current_config, active, sizeof(config_t));
active = &current_config; active = &current_config;
} }
@ -742,15 +742,19 @@ static void cmd_cal(BaseSequentialStream *chp, int argc, char *argv[])
} }
cal_status |= CALSTAT_APPLY; cal_status |= CALSTAT_APPLY;
draw_cal_status();
return; return;
} else if (strcmp(cmd, "on") == 0) { } else if (strcmp(cmd, "on") == 0) {
cal_status |= CALSTAT_APPLY; cal_status |= CALSTAT_APPLY;
draw_cal_status();
return; return;
} else if (strcmp(cmd, "off") == 0) { } else if (strcmp(cmd, "off") == 0) {
cal_status &= ~CALSTAT_APPLY; cal_status &= ~CALSTAT_APPLY;
draw_cal_status();
return; return;
} else if (strcmp(cmd, "reset") == 0) { } else if (strcmp(cmd, "reset") == 0) {
cal_status = 0; cal_status = 0;
draw_cal_status();
return; return;
} else if (strcmp(cmd, "data") == 0) { } else if (strcmp(cmd, "data") == 0) {
chprintf(chp, "%f %f\r\n", cal_data[CAL_LOAD][0][0], cal_data[CAL_LOAD][0][1]); chprintf(chp, "%f %f\r\n", cal_data[CAL_LOAD][0][0], cal_data[CAL_LOAD][0][1]);
@ -776,6 +780,7 @@ static void cmd_save(BaseSequentialStream *chp, int argc, char *argv[])
if (id < 0 || id >= SAVEAREA_MAX) if (id < 0 || id >= SAVEAREA_MAX)
goto usage; goto usage;
caldata_save(id); caldata_save(id);
draw_cal_status();
return; return;
usage: usage:
@ -796,13 +801,14 @@ static void cmd_recall(BaseSequentialStream *chp, int argc, char *argv[])
if (caldata_recall(id) == 0) { if (caldata_recall(id) == 0) {
// success // success
set_sweep(freq_start, freq_stop); set_sweep(freq_start, freq_stop);
draw_cal_status();
} }
resume_sweep(); resume_sweep();
return; return;
usage: usage:
chprintf(chp, "save {id}\r\n"); chprintf(chp, "recall {id}\r\n");
} }

View file

@ -136,6 +136,8 @@ void trace_get_info(int t, char *buf, int len);
void plot_into_index(float measured[2][101][2]); void plot_into_index(float measured[2][101][2]);
void draw_cell_all(void); void draw_cell_all(void);
void draw_cal_status(void);
/* /*
* main.c * main.c
@ -191,13 +193,14 @@ typedef struct {
#define CONFIG_MAGIC 0x436f4e45 /* 'CoNF' */ #define CONFIG_MAGIC 0x436f4e45 /* 'CoNF' */
extern int16_t lastsaveid;
extern config_t *active; extern config_t *active;
extern config_t current_config; extern config_t current_config;
#define freq_start active->_freq_start #define freq_start active->_freq_start
#define freq_stop active->_freq_stop #define freq_stop active->_freq_stop
#define sweep_points active->_sweep_points #define sweep_points active->_sweep_points
#define cal_status active->_cal_status #define cal_status current_config._cal_status
#define frequencies active->_frequencies #define frequencies active->_frequencies
#define cal_data active->_cal_data #define cal_data active->_cal_data

45
plot.c
View file

@ -993,23 +993,64 @@ void
draw_frequencies(void) draw_frequencies(void)
{ {
char buf[24]; char buf[24];
chsnprintf(buf, 24, "START%3d.%03d %03d MHz", chsnprintf(buf, 24, "START %d.%03d %03d MHz ",
(int)(fstart / 1000000), (int)(fstart / 1000000),
(int)((fstart / 1000) % 1000), (int)((fstart / 1000) % 1000),
(int)(fstart % 1000)); (int)(fstart % 1000));
ili9341_drawstring_5x7(buf, OFFSETX, 233, 0xffff, 0x0000); ili9341_drawstring_5x7(buf, OFFSETX, 233, 0xffff, 0x0000);
chsnprintf(buf, 24, "STOP %3d.%03d %03d MHz", chsnprintf(buf, 24, "STOP %d.%03d %03d MHz",
(int)(fstop / 1000000), (int)(fstop / 1000000),
(int)((fstop / 1000) % 1000), (int)((fstop / 1000) % 1000),
(int)(fstop % 1000)); (int)(fstop % 1000));
ili9341_drawstring_5x7(buf, 205, 233, 0xffff, 0x0000); ili9341_drawstring_5x7(buf, 205, 233, 0xffff, 0x0000);
} }
void
draw_cal_status(void)
{
int x = 0;
int y = 100;
#define YSTEP 7
ili9341_fill(0, y, 10, 6*YSTEP, 0x0000);
if (cal_status & CALSTAT_APPLY) {
char c[3] = "C0";
if (active == &current_config)
c[1] = '*';
else
c[1] += lastsaveid;
ili9341_drawstring_5x7(c, x, y, 0xffff, 0x0000);
y += YSTEP;
if (cal_status & CALSTAT_ED) {
ili9341_drawstring_5x7("D", x, y, 0xffff, 0x0000);
y += YSTEP;
}
if (cal_status & CALSTAT_ER) {
ili9341_drawstring_5x7("R", x, y, 0xffff, 0x0000);
y += YSTEP;
}
if (cal_status & CALSTAT_ES) {
ili9341_drawstring_5x7("S", x, y, 0xffff, 0x0000);
y += YSTEP;
}
if (cal_status & CALSTAT_ET) {
ili9341_drawstring_5x7("T", x, y, 0xffff, 0x0000);
y += YSTEP;
}
if (cal_status & CALSTAT_EX) {
ili9341_drawstring_5x7("X", x, y, 0xffff, 0x0000);
y += YSTEP;
}
}
}
void void
redraw(void) redraw(void)
{ {
ili9341_fill(0, 0, 320, 240, 0); ili9341_fill(0, 0, 320, 240, 0);
draw_frequencies(); draw_frequencies();
draw_cal_status();
} }
void void