Add table load store and trace load

pull/51/head
erikkaashoek 3 years ago
parent bd4f5a23ff
commit 51393252ea

@ -960,7 +960,7 @@ config_t config = {
.dac_value = 1922, .dac_value = 1922,
// .touch_cal = { 693, 605, 124, 171 }, // 2.4 inch LCD panel // .touch_cal = { 693, 605, 124, 171 }, // 2.4 inch LCD panel
#ifdef TINYSA3 #ifdef TINYSA3
.touch_cal = { 347, 495, 160, 205 }, // 2.8 inch LCD panel .touch_cal = { 534, 741, 3458, 3434 }, // 2.8 inch LCD panel
#endif #endif
#ifdef TINYSA4 #ifdef TINYSA4
.touch_cal = { 444, 715, 3552, 3499 }, // 4 inch panel .touch_cal = { 444, 715, 3552, 3499 }, // 4 inch panel

22
ui.c

@ -3638,6 +3638,7 @@ enum {
FMT_CMD_FILE, FMT_CMD_FILE,
FMT_CFG_FILE, FMT_CFG_FILE,
FMT_PRS_FILE, FMT_PRS_FILE,
FMT_TBL_FILE,
}; };
// Save file extension // Save file extension
@ -3650,6 +3651,7 @@ static const char *file_ext[] = {
[FMT_CMD_FILE] = "cmd", [FMT_CMD_FILE] = "cmd",
[FMT_CFG_FILE] = "cfg", [FMT_CFG_FILE] = "cfg",
[FMT_PRS_FILE] = "prs", [FMT_PRS_FILE] = "prs",
[FMT_TBL_FILE] = "tbl",
}; };
static void sa_save_file(uint8_t format); static void sa_save_file(uint8_t format);
@ -3893,6 +3895,10 @@ static const menuitem_t menu_limit_modify[] =
static const menuitem_t menu_limit_select[] = { static const menuitem_t menu_limit_select[] = {
{ MT_ADV_CALLBACK | MT_REPEATS, DATA_STARTS_REPEATS(0,LIMITS_MAX), MT_CUSTOM_LABEL, menu_limit_select_acb }, { MT_ADV_CALLBACK | MT_REPEATS, DATA_STARTS_REPEATS(0,LIMITS_MAX), MT_CUSTOM_LABEL, menu_limit_select_acb },
{ MT_CALLBACK, FMT_TBL_FILE, "TABLE"S_RARROW"\nSD", menu_sdcard_cb},
#ifdef __SD_FILE_BROWSER__
{ MT_CALLBACK, FMT_TBL_FILE, "SD"S_RARROW"\nTABLE", menu_sdcard_browse_cb },
#endif
{ MT_NONE, 0, NULL, menu_back} // next-> menu_back { MT_NONE, 0, NULL, menu_back} // next-> menu_back
}; };
#endif #endif
@ -4365,9 +4371,10 @@ static const menuitem_t menu_traces[] =
{ MT_ADV_CALLBACK,3, MT_CUSTOM_LABEL, menu_traces_acb}, // Calc { MT_ADV_CALLBACK,3, MT_CUSTOM_LABEL, menu_traces_acb}, // Calc
{ MT_ADV_CALLBACK,4, "NORMALIZE", menu_traces_acb}, { MT_ADV_CALLBACK,4, "NORMALIZE", menu_traces_acb},
{ MT_ADV_CALLBACK,5, MT_CUSTOM_LABEL, menu_traces_acb}, // Trace Math { MT_ADV_CALLBACK,5, MT_CUSTOM_LABEL, menu_traces_acb}, // Trace Math
{ MT_SUBMENU, 0, "COPY\n"S_RARROW"TRACE", menu_store_trace}, { MT_SUBMENU, 0, "TRACE\n"S_RARROW"TRACE", menu_store_trace},
#ifdef TINYSA4 #ifdef TINYSA4
{ MT_ADV_CALLBACK,6, "WRITE\n"S_RARROW"SD", menu_traces_acb}, { MT_ADV_CALLBACK,6, "TRACE\n"S_RARROW"SD", menu_traces_acb},
{ MT_CALLBACK, FMT_CSV_FILE, "SD"S_RARROW"\nTRACE", menu_sdcard_browse_cb },
#endif #endif
{ MT_NONE, 0, NULL, menu_back} // next-> menu_back { MT_NONE, 0, NULL, menu_back} // next-> menu_back
}; };
@ -6841,6 +6848,17 @@ static void sa_save_file(uint8_t format) {
res = f_write(fs_file, (char *)spi_buffer, buf - (char *)spi_buffer, &size); res = f_write(fs_file, (char *)spi_buffer, buf - (char *)spi_buffer, &size);
} }
break; break;
case FMT_TBL_FILE:
for (i = 0; i < LIMITS_MAX && res == FR_OK; i++) {
if (setting.limits[current_trace][i].enabled) {
char *buf = (char *)spi_buffer;
buf += plot_printf(buf, 100, "%U, ", setting.limits[current_trace][i].frequency);
buf += plot_printf(buf, 100, "%f ", setting.limits[current_trace][i].level);
buf += plot_printf(buf, 100, "\r\n");
res = f_write(fs_file, (char *)spi_buffer, buf - (char *)spi_buffer, &size);
}
}
break;
#ifdef __SD_CARD_DUMP_FIRMWARE__ #ifdef __SD_CARD_DUMP_FIRMWARE__
/* /*
* Dump firmware to SD card as bin file image * Dump firmware to SD card as bin file image

@ -113,6 +113,82 @@ repeat:
ili9341_set_foreground(LCD_FG_COLOR); ili9341_set_foreground(LCD_FG_COLOR);
ili9341_set_background(LCD_BG_COLOR); ili9341_set_background(LCD_BG_COLOR);
switch (keypad_mode) { switch (keypad_mode) {
case FMT_TBL_FILE:
{
const int buffer_size = 256;
const int line_size = 128;
char *buf_8 = (char *)spi_buffer; // must be greater then buffer_size + line_size
char *line = buf_8 + buffer_size;
uint16_t j = 0, i, count = 0;
while (f_read(fs_file, buf_8, buffer_size, &size) == FR_OK && size > 0) {
for (i = 0; i < size; i++) {
uint8_t c = buf_8[i];
if (c == '\r') { // New line (Enter)
line[j] = 0; j = 0;
char *args[16];
int nargs = parse_line(line, args, 16); // Parse line to 16 args
if (nargs < 2 || args[0][0] == '#' || args[0][0] == '!') continue; // No data or comment or settings
if (count >= LIMITS_MAX) {error = "Format err"; goto finish2;}
setting.limits[current_trace][count].frequency = my_atoui(args[0]);// Get frequency
setting.limits[current_trace][count].level = my_atof(args[1]); // Get frequency
setting.limits[current_trace][count].enabled = true; // Get frequency
count++;
}
else if (c < 0x20) continue; // Others (skip)
else if (j < line_size) line[j++] = (char)c; // Store
}
}
finish2:
for (; count < LIMITS_MAX; i++) {
setting.limits[current_trace][count].frequency = 0;
setting.limits[current_trace][count].level = 0;
setting.limits[current_trace][count].enabled = false;
count++;
}
break;
}
case FMT_CSV_FILE:
{
const int buffer_size = 256;
const int line_size = 128;
char *buf_8 = (char *)spi_buffer; // must be greater then buffer_size + line_size
char *line = buf_8 + buffer_size;
uint16_t j = 0, i, count = 0;
freq_t start = 0, stop = 0, f;
while (f_read(fs_file, buf_8, buffer_size, &size) == FR_OK && size > 0) {
for (i = 0; i < size; i++) {
uint8_t c = buf_8[i];
if (c == '\r') { // New line (Enter)
line[j] = 0; j = 0;
char *args[16];
int nargs = parse_line(line, args, 16); // Parse line to 16 args
if (nargs < 2 || args[0][0] == '#' || args[0][0] == '!') continue; // No data or comment or settings
f = my_atoui(args[0]); // Get frequency
if (count >= POINTS_COUNT || f > maxFreq) {error = "Format err"; goto finish;}
if (count == 0) {
start = f; // For index 0 set as start
setting.stored[current_trace] = true;
TRACE_ENABLE(1<<current_trace);
}
stop = f; // last set as stop
measured[current_trace][count] = my_atof(args[1]);
count++;
}
else if (c < 0x20) continue; // Others (skip)
else if (j < line_size) line[j++] = (char)c; // Store
}
}
finish:
if (count != 0) { // Points count not zero, so apply data to traces
// pause_sweep();
setting._sweep_points = count;
set_sweep_frequency(ST_START, start);
set_sweep_frequency(ST_STOP, stop);
// request_to_redraw(REDRAW_AREA);
}
break;
}
case FMT_CMD_FILE: case FMT_CMD_FILE:
{ {
const int buffer_size = 256; const int buffer_size = 256;

Loading…
Cancel
Save

Powered by TurnKey Linux.