Remove test code

Optimize size trace command function
This commit is contained in:
ВшЫдщкв 2020-01-19 16:14:22 +03:00
parent 6f666cf31b
commit 90dc36418d
2 changed files with 30 additions and 81 deletions

View file

@ -338,58 +338,6 @@ void ili9341_init(void)
p += 2 + p[1];
chThdSleepMilliseconds(5);
}
/*
int x1, y1, x2, y2;
x1 = y1 = 0;
y2 = 240 - 1;
for(x2=0; x2<320; x2+=6) ili9341_line(x1, y1, x2, y2);
x2 = 320 - 1;
for(y2=0; y2<240; y2+=6) ili9341_line(x1, y1, x2, y2);
chThdSleepMilliseconds(2000);*/
/*
char buf[64];
ili9341_fill(0,0, 320, 240, 255);
systime_t time = chVTGetSystemTimeX();
for (int c=0;c<255;c+=5)
ili9341_fill(0,0, 320, 240, RGB565(0,0,c));
chThdSleepMilliseconds(1000);
for (int c=0;c<255;c+=5)
ili9341_fill(0,0, 320, 240, RGB565(0,c,0));
chThdSleepMilliseconds(1000);
for (int c=0;c<255;c+=5)
ili9341_fill(0,0, 320, 240, RGB565(c,0,0));
chThdSleepMilliseconds(1000);
time = chVTGetSystemTimeX() - time;
chsnprintf(buf, sizeof buf, "Fill Time %d", time);
ili9341_drawstring(buf, 10,10);
chThdSleepMilliseconds(2000);
// time = chVTGetSystemTimeX();
// for (int c=0;c<50;c++)
// show_version();
// time = chVTGetSystemTimeX() - time;
// chsnprintf(buf, sizeof buf, "Fill Time %d", time);
chsnprintf(buf, sizeof buf, "0123456789123456789");
setForegroundColor(RGB565(255,0,0));
ili9341_drawstring(buf, 0, 0);
setForegroundColor(RGB565(0,255,0));
ili9341_drawstring(buf, 0, 8);
setForegroundColor(RGB565(0,0,255));
ili9341_drawstring(buf, 0, 16);
ili9341_drawstring(buf, 0, 24);
ili9341_drawstring(buf, 0, 32);
ili9341_fill(0, 64, 320, 64, 0);
chThdSleepMilliseconds(2000);
ili9341_read_memory(0, 0, 32, 16, 512, spi_buffer);
ili9341_bulk(32, 64, 32, 16);
ili9341_read_memory(0, 16, 32, 16, 512, spi_buffer);
ili9341_bulk(32, 64+16, 32, 16);
chThdSleepMilliseconds(5000);/**/
/**/
}
#ifndef __USE_DISPLAY_DMA__

59
main.c
View file

@ -1541,6 +1541,11 @@ my_atof(const char *p)
return x;
}
typedef struct {
char *tracename;
uint8_t type;
} type_list;
static void cmd_trace(BaseSequentialStream *chp, int argc, char *argv[])
{
int t;
@ -1575,34 +1580,29 @@ static void cmd_trace(BaseSequentialStream *chp, int argc, char *argv[])
chprintf(chp, "%d %s %s\r\n", t, type, channel);
return;
}
if (argc > 1) {
if (strcmp(argv[1], "logmag") == 0) {
set_trace_type(t, TRC_LOGMAG);
} else if (strcmp(argv[1], "phase") == 0) {
set_trace_type(t, TRC_PHASE);
} else if (strcmp(argv[1], "polar") == 0) {
set_trace_type(t, TRC_POLAR);
} else if (strcmp(argv[1], "smith") == 0) {
set_trace_type(t, TRC_SMITH);
} else if (strcmp(argv[1], "delay") == 0) {
set_trace_type(t, TRC_DELAY);
} else if (strcmp(argv[1], "linear") == 0) {
set_trace_type(t, TRC_LINEAR);
} else if (strcmp(argv[1], "swr") == 0) {
set_trace_type(t, TRC_SWR);
} else if (strcmp(argv[1], "real") == 0) {
set_trace_type(t, TRC_REAL);
} else if (strcmp(argv[1], "imag") == 0) {
set_trace_type(t, TRC_IMAG);
} else if (strcmp(argv[1], "r") == 0) {
set_trace_type(t, TRC_R);
} else if (strcmp(argv[1], "x") == 0) {
set_trace_type(t, TRC_X);
} else if (strcmp(argv[1], "linear") == 0) {
set_trace_type(t, TRC_LINEAR);
} else if (strcmp(argv[1], "off") == 0) {
set_trace_type(t, TRC_OFF);
} else if (strcmp(argv[1], "scale") == 0 && argc >= 3) {
static const type_list t_list[] = {
{"logmag", TRC_LOGMAG},
{"phase", TRC_PHASE},
{"polar", TRC_POLAR},
{"smith", TRC_SMITH},
{"delay", TRC_DELAY},
{"linear", TRC_LINEAR},
{"swr", TRC_SWR},
{"real", TRC_REAL},
{"imag", TRC_IMAG},
{"r", TRC_R},
{"x", TRC_X},
{"off", TRC_OFF},
};
for (uint16_t i=0; i<sizeof(t_list)/sizeof(type_list); i++){
if (strcmp(argv[1], t_list[i].tracename) == 0) {
set_trace_type(t, t_list[i].type);
goto check_ch_num;
}
}
if (strcmp(argv[1], "scale") == 0 && argc >= 3) {
//trace[t].scale = my_atof(argv[2]);
set_trace_scale(t, my_atof(argv[2]));
goto exit;
@ -1614,16 +1614,17 @@ static void cmd_trace(BaseSequentialStream *chp, int argc, char *argv[])
goto usage;
}
}
check_ch_num:
if (argc > 2) {
int src = atoi(argv[2]);
if (src != 0 && src != 1)
goto usage;
trace[t].channel = src;
}
}
exit:
return;
usage:
chprintf(chp, "trace {0|1|2|3|all} [logmag|phase|smith|linear|delay|swr|real|imag|r|x|off] [src]\r\n");
chprintf(chp, "trace {0|1|2|3|all} [logmag|phase|polar|smith|linear|delay|swr|real|imag|r|x|off] [src]\r\n");
chprintf(chp, "trace {0|1|2|3} {scale|refpos} {value}\r\n");
}