Merge remote-tracking branch 'origin/DiSlord_test_branch'

pull/4/head
erikkaashoek 6 years ago
commit 58cea9e6d2

@ -495,7 +495,6 @@ void ili9341_read_memory(int x, int y, int w, int h, int len, uint16_t *out)
// Skip SPI rx buffer // Skip SPI rx buffer
while (SPI_RX_IS_NOT_EMPTY) (void)SPI_READ_DATA; while (SPI_RX_IS_NOT_EMPTY) (void)SPI_READ_DATA;
// Init Rx DMA buffer, size, mode (spi and mem data size is 8 bit) // Init Rx DMA buffer, size, mode (spi and mem data size is 8 bit)
chSysLock();
dmaStreamSetMemory0(dmarx, rgbbuf); dmaStreamSetMemory0(dmarx, rgbbuf);
dmaStreamSetTransactionSize(dmarx, data_size); dmaStreamSetTransactionSize(dmarx, data_size);
dmaStreamSetMode(dmarx, rxdmamode | STM32_DMA_CR_PSIZE_BYTE | STM32_DMA_CR_MSIZE_BYTE | dmaStreamSetMode(dmarx, rxdmamode | STM32_DMA_CR_PSIZE_BYTE | STM32_DMA_CR_MSIZE_BYTE |
@ -506,22 +505,11 @@ void ili9341_read_memory(int x, int y, int w, int h, int len, uint16_t *out)
dmaStreamSetMode(dmatx, txdmamode | STM32_DMA_CR_PSIZE_BYTE | STM32_DMA_CR_MSIZE_BYTE); dmaStreamSetMode(dmatx, txdmamode | STM32_DMA_CR_PSIZE_BYTE | STM32_DMA_CR_MSIZE_BYTE);
// Start DMA exchange // Start DMA exchange
dmaStreamEnable(dmatx);
dmaStreamEnable(dmarx); dmaStreamEnable(dmarx);
dmaStreamEnable(dmatx);
// Wait DMA completion // Wait DMA completion
dmaWaitCompletion(dmatx); dmaWaitCompletion(dmatx);
#if 0
int count = 0;
while ((dmarx)->channel->CNDTR > 0U) {
chThdSleepMicroseconds(100);
if (count++ > 10)
break;
}
dmaStreamDisable(dmarx);
#else
dmaWaitCompletion(dmarx); dmaWaitCompletion(dmarx);
#endif
chSysUnlock();
CS_HIGH; CS_HIGH;
// Parce recived data // Parce recived data

@ -153,7 +153,7 @@ static THD_FUNCTION(Thread1, arg)
} }
// Run Shell command in sweep thread // Run Shell command in sweep thread
if (shell_function) { if (shell_function) {
operation_requested = false; // otherwise commands will be aborted operation_requested = OP_NONE; // otherwise commands will be aborted
shell_function(shell_nargs - 1, &shell_args[1]); shell_function(shell_nargs - 1, &shell_args[1]);
shell_function = 0; shell_function = 0;
osalThreadSleepMilliseconds(10); osalThreadSleepMilliseconds(10);

123
plot.c

@ -30,6 +30,7 @@ int fullscreen = true;
#endif #endif
static void cell_draw_marker_info(int x0, int y0); static void cell_draw_marker_info(int x0, int y0);
static void draw_battery_status(void); static void draw_battery_status(void);
static void update_waterfall(void);
void cell_draw_test_info(int x0, int y0); void cell_draw_test_info(int x0, int y0);
void frequency_string(char *buf, size_t len, int32_t freq); void frequency_string(char *buf, size_t len, int32_t freq);
@ -1595,108 +1596,12 @@ draw_all_cells(bool flush_markmap)
// clear map for next plotting // clear map for next plotting
clear_markmap(); clear_markmap();
} }
// START_PROFILE
#ifdef __SCROLL__ #ifdef __SCROLL__
int w = area_width; if (waterfall)
if (w < 5) w = 5; update_waterfall();
if (waterfall) {
for (m = 226; m >= HEIGHT+3; m -= 1) { // Scroll down
uint16_t *buf = &spi_buffer[0];
ili9341_read_memory(6*5, m, w, 1, w, buf);
ili9341_bulk(6*5,m+1, w,1);
}
for (int i=0; i<290; i++) { // Add new topline
#if 0
int k = (actual_t[i]+120 + 10)* 3 / 2;
unsigned int r=0,g=0,b=0;
if (k < 64)
r = k*4;
else if (k<128) {
r = 255;
g = (k-64)*4;
} else {
r = 255;
g = 255;
b = (k-128)*4;
}
#else
if (w_min > (int)min_level)
w_min = (int)min_level;
if (w_max < (int)peakLevel)
w_max = (int)peakLevel;
/*
def rgb(minimum, maximum, value):
minimum, maximum = float(minimum), float(maximum)
ratio = 2 * (value-minimum) / (maximum - minimum)
b = int(max(0, 255*(1 - ratio)))
r = int(max(0, 255*(ratio - 1)))
g = 255 - b - r
return r, g, b
*/
int r,g,b;
#if 0
int ratio = (int)(1024 * (actual_t[i] - w_min) / (w_max - w_min));
r = ratio - 512;
if (r<0) r=0;
b = (1024 - ratio*4) - 512;
if (b<0) b=0;
g = 512-r-b;
if (r>255) r=255;
if (g>255) g=255;
if (b>255) b=255;
#define gamma_correct(X,L) X = (L + X * (255 - L)/255 )
gamma_correct(r,160);
gamma_correct(g,160);
gamma_correct(b,160);
#endif
#if 1
float ratio = (int)(510.0 * (actual_t[i] - w_min) / (w_max - w_min));
// ratio = (i*2); // Uncomment for testing the waterfall colors
b = 255 - ratio;
if (b > 255) b = 255;
if (b < 0) b = 0;
r = ratio - 255;
if (r > 255) r = 255;
if (r < 0) r = 0;
// g = 255 - b; // if red is too weak to be seen.....
g = 255 - b - r;
#if 1
#define gamma_correct(X) X = (X < 64 ? X * 2 : X < 128 ? 128 + (X-64) : X < 192 ? 192 + (X - 128)/2 : 225 + (X - 192) / 4)
gamma_correct(r);
gamma_correct(g);
gamma_correct(b);
#endif
#endif
#if 0
int k = (actual_t[i]+120)* 2 * 8;
k &= 255;
unsigned int r=0,g=0,b=0;
if (k < 64) {
b = 255;
g = k*2 + 128;
} else if (k < 128) {
g = 255;
b = 255 - (k-64)*2;
} else if (k < 192) {
g = 255;
r = (k-128)*2 + 128;
} else
{
g = 255 - (k-192)*2;
r = 255;
}
#endif
#endif
spi_buffer[i] = RGB565(r,g,b);
}
ili9341_bulk(6*5,HEIGHT+3, w,1);
}
#endif #endif
// STOP_PROFILE
} }
void void
@ -2066,7 +1971,7 @@ static void cell_draw_marker_info(int x0, int y0)
if (i == active_marker) { if (i == active_marker) {
// ili9341_set_foreground(DEFAULT_BG_COLOR); // ili9341_set_foreground(DEFAULT_BG_COLOR);
// ili9341_set_background(marker_color(markers[i].mtype)); // ili9341_set_background(marker_color(markers[i].mtype));
buf[k++] = '\033'; // Right arrow (?) buf[k++] = S_SARROW[0];
} else { } else {
// ili9341_set_background(DEFAULT_BG_COLOR); // ili9341_set_background(DEFAULT_BG_COLOR);
// ili9341_set_foreground(marker_color(markers[i].mtype)); // ili9341_set_foreground(marker_color(markers[i].mtype));
@ -2273,6 +2178,20 @@ redraw_frame(void)
draw_cal_status(); draw_cal_status();
} }
static void update_waterfall(void){
int i;
int w_width = area_width < 290 ? area_width : 290;
for (i = HEIGHT_NOSCROLL-1; i >=HEIGHT_SCROLL+2; i--) { // Scroll down
ili9341_read_memory(OFFSETX, i , w_width, 1, w_width*1, spi_buffer);
ili9341_bulk(OFFSETX, i+1, w_width, 1);
}
index_t *index = trace_index[TRACE_ACTUAL];
for (i=0; i< w_width; i++) { // Add new topline
uint16_t y = CELL_Y(index[i]);
spi_buffer[i] = RGB565(255-y, y, (128-y)&0xFF);
}
ili9341_bulk(OFFSETX, HEIGHT_SCROLL+2, w_width, 1);
}
int get_waterfall(void) int get_waterfall(void)
{ {
@ -2284,7 +2203,7 @@ toggle_waterfall(void)
{ {
if (!waterfall) { if (!waterfall) {
_height = HEIGHT_SCROLL; _height = HEIGHT_SCROLL;
ili9341_fill(5*5, HEIGHT, LCD_WIDTH - 5*5, 236-HEIGHT, 0); // ili9341_fill(OFFSETX, HEIGHT_SCROLL, LCD_WIDTH - OFFSETX, HEIGHT_NOSCROLL - HEIGHT_SCROLL, 0);
waterfall = true; waterfall = true;
fullscreen = false; fullscreen = false;
w_min = (int)min_level; w_min = (int)min_level;

Loading…
Cancel
Save

Powered by TurnKey Linux.