Merge DiSlord improvements

Removed_REF_marker
erikkaashoek 5 years ago
parent 31655a8102
commit daf86346c6

@ -26,8 +26,6 @@
#include "spi.h" #include "spi.h"
// Allow enable DMA for read display data // Allow enable DMA for read display data
#ifdef TINYSA4 #ifdef TINYSA4
#define __USE_DISPLAY_DMA_RX__ #define __USE_DISPLAY_DMA_RX__
@ -58,10 +56,10 @@
#define LCD_SPI_RX_SPEED SPI_BR_DIV4 #define LCD_SPI_RX_SPEED SPI_BR_DIV4
#endif #endif
uint16_t spi_buffer[SPI_BUFFER_SIZE]; pixel_t spi_buffer[SPI_BUFFER_SIZE];
// Default foreground & background colors // Default foreground & background colors
uint16_t foreground_color = 0; pixel_t foreground_color = 0;
uint16_t background_color = 0; pixel_t background_color = 0;
// Display width and height definition // Display width and height definition
#define ILI9341_WIDTH LCD_WIDTH #define ILI9341_WIDTH LCD_WIDTH
@ -357,11 +355,8 @@ void set_SPI_mode(uint16_t mode){
static void send_command(uint8_t cmd, uint8_t len, const uint8_t *data) static void send_command(uint8_t cmd, uint8_t len, const uint8_t *data)
{ {
// Uncomment on low speed SPI (possible get here before previous tx complete) // Uncomment on low speed SPI (possible get here before previous tx complete)
#ifndef TINYSA4 // while (SPI_IN_TX_RX(LCD_SPI));
while (SPI_IN_TX_RX(LCD_SPI));
#endif
#ifdef TINYSA4 #ifdef TINYSA4
// while (SPI_IN_TX_RX);
set_SPI_mode(SPI_MODE_LCD); set_SPI_mode(SPI_MODE_LCD);
#endif #endif
LCD_CS_LOW; LCD_CS_LOW;
@ -517,7 +512,9 @@ static void ili9341_setWindow(int x, int y, int w, int h){
send_command(ILI9341_PAGE_ADDRESS_SET, 4, (uint8_t *)&yy); send_command(ILI9341_PAGE_ADDRESS_SET, 4, (uint8_t *)&yy);
} }
void ili9341_bulk_8bit(int x, int y, int w, int h, uint16_t *palette) #if 0
// Test code for palette mode
void ili9341_bulk_8bit(int x, int y, int w, int h, pixel_t *palette)
{ {
ili9341_setWindow(x, y ,w, h); ili9341_setWindow(x, y ,w, h);
send_command(ILI9341_MEMORY_WRITE, 0, NULL); send_command(ILI9341_MEMORY_WRITE, 0, NULL);
@ -528,27 +525,62 @@ void ili9341_bulk_8bit(int x, int y, int w, int h, uint16_t *palette)
spi_TxWord(palette[*buf++]); spi_TxWord(palette[*buf++]);
// LCD_CS_HIGH; // LCD_CS_HIGH;
} }
#endif
#if DISPLAY_CELL_BUFFER_COUNT != 1
#define LCD_BUFFER_1 0x01
#define LCD_DMA_RUN 0x02
static uint8_t LCD_dma_status = 0;
#endif
pixel_t *ili9341_get_cell_buffer(void){
#if DISPLAY_CELL_BUFFER_COUNT == 1
return spi_buffer;
#else
return &spi_buffer[(LCD_dma_status&LCD_BUFFER_1) ? SPI_BUFFER_SIZE/2 : 0];
#endif
}
#ifndef __USE_DISPLAY_DMA__ #ifndef __USE_DISPLAY_DMA__
void ili9341_fill(int x, int y, int w, int h, uint16_t color) void ili9341_fill(int x, int y, int w, int h, pixel_t color)
{ {
ili9341_setWindow(x, y ,w, h); ili9341_setWindow(x, y ,w, h);
send_command(ILI9341_MEMORY_WRITE, 0, NULL); send_command(ILI9341_MEMORY_WRITE, 0, NULL);
int32_t len = w * h; uint32_t len = w * h;
while (len-- > 0) do {
spi_TxWord(color); while (SPI_TX_IS_NOT_EMPTY(LCD_SPI))
// LCD_CS_HIGH; ;
SPI_WRITE_16BIT(LCD_SPI, color);
}while(--len);
#ifdef __REMOTE_DESKTOP__
if (auto_capture) {
send_region("fill", x,y,w,h);
send_buffer((uint8_t *)&background_color, 2);
}
#endif
} }
void ili9341_bulk(int x, int y, int w, int h) void ili9341_bulk(int x, int y, int w, int h)
{ {
ili9341_setWindow(x, y ,w, h); ili9341_setWindow(x, y ,w, h);
send_command(ILI9341_MEMORY_WRITE, 0, NULL); send_command(ILI9341_MEMORY_WRITE, 0, NULL);
int32_t len = w * h; spi_TxBuffer((uint8_t *)spi_buffer, w * h * sizeof(pixel_t));
while (len-- > 0) #ifdef __REMOTE_DESKTOP__
spi_TxWord(*buf++); if (auto_capture) {
// LCD_CS_HIGH; send_region("bulk", x,y,w,h);
send_buffer((uint8_t *)buffer, w *h * sizeof(pixel_t));
}
#endif
}
void ili9341_bulk_continue(int x, int y, int w, int h){
ili9341_bulk(x, y, w, h);
} }
void ili9341_bulk_finish(void){
while (SPI_IS_BUSY(LCD_SPI)); // Wait tx
}
#else #else
// //
// Use DMA for send data // Use DMA for send data
@ -563,36 +595,57 @@ void ili9341_fill(int x, int y, int w, int h)
dmaStreamSetMode(dmatx, txdmamode | STM32_DMA_CR_PSIZE_HWORD | STM32_DMA_CR_MSIZE_HWORD); dmaStreamSetMode(dmatx, txdmamode | STM32_DMA_CR_PSIZE_HWORD | STM32_DMA_CR_MSIZE_HWORD);
#ifdef __REMOTE_DESKTOP__ #ifdef __REMOTE_DESKTOP__
if (auto_capture) { if (auto_capture) {
send_region("fill", x,y,w,h); send_region("fill", x, y, w, h);
send_buffer((uint8_t *)&background_color, 2); send_buffer((uint8_t *)&background_color, sizeof(pixel_t));
} }
#endif #endif
dmaStreamFlush(w * h); dmaStreamFlush(w * h);
} }
// Copy spi_buffer to region void ili9341_bulk_finish(void){
void ili9341_bulk(int x, int y, int w, int h) dmaWaitCompletion(dmatx); // Wait DMA
{ while (SPI_IN_TX_RX(LCD_SPI)); // Wait tx
}
static void ili9341_DMA_bulk(int x, int y, int w, int h, pixel_t *buffer){
ili9341_setWindow(x, y ,w, h); ili9341_setWindow(x, y ,w, h);
send_command(ILI9341_MEMORY_WRITE, 0, NULL); send_command(ILI9341_MEMORY_WRITE, 0, NULL);
// Init Tx DMA mem->spi, set size, mode (spi and mem data size is 16 bit) dmaStreamSetMemory0(dmatx, buffer);
dmaStreamSetMemory0(dmatx, spi_buffer); dmaStreamSetMode(dmatx, txdmamode | STM32_DMA_CR_PSIZE_HWORD | STM32_DMA_CR_MSIZE_HWORD | STM32_DMA_CR_MINC);
dmaStreamSetMode(dmatx, txdmamode | STM32_DMA_CR_PSIZE_HWORD | dmaStreamSetTransactionSize(dmatx, w * h);
STM32_DMA_CR_MSIZE_HWORD | STM32_DMA_CR_MINC); dmaStreamEnable(dmatx);
#ifdef __REMOTE_DESKTOP__ #ifdef __REMOTE_DESKTOP__
if (auto_capture) { if (auto_capture) {
send_region("bulk", x,y,w,h); send_region("bulk", x, y, w, h);
send_buffer((uint8_t *)spi_buffer, w*h*2); send_buffer((uint8_t *)buffer, w *h * sizeof(pixel_t));
} }
#endif #endif
dmaStreamFlush(w * h); }
// Copy spi_buffer to region
void ili9341_bulk(int x, int y, int w, int h)
{
ili9341_DMA_bulk(x, y ,w, h, spi_buffer); // Send data
ili9341_bulk_finish(); // Wait
} }
#endif #endif
// Copy part of spi_buffer to region, no wait completion after if buffer count !=1
void ili9341_bulk_continue(int x, int y, int w, int h)
{
#if DISPLAY_CELL_BUFFER_COUNT == 1
ili9341_bulk(x, y, w, h);
#else
ili9341_bulk_finish(); // Wait DMA
ili9341_DMA_bulk(x, y , w, h, ili9341_get_cell_buffer()); // Send new cell data
LCD_dma_status^=LCD_BUFFER_1; // Switch buffer
#endif
}
#ifndef __USE_DISPLAY_DMA_RX__ #ifndef __USE_DISPLAY_DMA_RX__
void ili9341_read_memory(int x, int y, int w, int h, int len, uint16_t *out) void ili9341_read_memory(int x, int y, int w, int h, int len, pixel_t *out)
{ {
ili9341_setWindow(x, y ,w, h); ili9341_setWindow(x, y ,w, h);
send_command(ILI9341_MEMORY_READ, 0, NULL); send_command(ILI9341_MEMORY_READ, 0, NULL);
@ -627,7 +680,7 @@ void ili9341_read_memory(int x, int y, int w, int h, int len, uint16_t *out)
#else #else
// Copy screen data to buffer // Copy screen data to buffer
// Warning!!! buffer size must be greater then 3*len + 1 bytes // Warning!!! buffer size must be greater then 3*len + 1 bytes
void ili9341_read_memory(int x, int y, int w, int h, int len, uint16_t *out) void ili9341_read_memory(int x, int y, int w, int h, int len, pixel_t *out)
{ {
uint16_t dummy_tx = 0; uint16_t dummy_tx = 0;
uint8_t *rgbbuf = (uint8_t *)out; uint8_t *rgbbuf = (uint8_t *)out;
@ -719,7 +772,7 @@ void ili9341_set_rotation(uint8_t r)
} }
static uint8_t bit_align = 0; static uint8_t bit_align = 0;
void blit8BitWidthBitmap(uint16_t x, uint16_t y, uint16_t width, uint16_t height, void ili9341_blitBitmap(uint16_t x, uint16_t y, uint16_t width, uint16_t height,
const uint8_t *b) const uint8_t *b)
{ {
uint16_t *buf = spi_buffer; uint16_t *buf = spi_buffer;
@ -735,25 +788,9 @@ void blit8BitWidthBitmap(uint16_t x, uint16_t y, uint16_t width, uint16_t height
ili9341_bulk(x, y, width, height); ili9341_bulk(x, y, width, height);
} }
#if 0
void blit16BitWidthBitmap(uint16_t x, uint16_t y, uint16_t width, uint16_t height,
const uint16_t *bitmap)
{
uint16_t *buf = spi_buffer;
for (uint16_t c = 0; c < height; c++) {
uint16_t bits = *bitmap++;
for (uint16_t r = 0; r < width; r++) {
*buf++ = (0x8000 & bits) ? foreground_color : background_color;
bits <<= 1;
}
}
ili9341_bulk(x, y, width, height);
}
#endif
void ili9341_drawchar(uint8_t ch, int x, int y) void ili9341_drawchar(uint8_t ch, int x, int y)
{ {
blit8BitWidthBitmap(x, y, FONT_GET_WIDTH(ch), FONT_GET_HEIGHT, FONT_GET_DATA(ch)); ili9341_blitBitmap(x, y, FONT_GET_WIDTH(ch), FONT_GET_HEIGHT, FONT_GET_DATA(ch));
} }
void ili9341_drawstring(const char *str, int x, int y) void ili9341_drawstring(const char *str, int x, int y)
@ -764,7 +801,7 @@ void ili9341_drawstring(const char *str, int x, int y)
if (ch == '\n') {x = x_pos; y+=FONT_STR_HEIGHT; continue;} if (ch == '\n') {x = x_pos; y+=FONT_STR_HEIGHT; continue;}
const uint8_t *char_buf = FONT_GET_DATA(ch); const uint8_t *char_buf = FONT_GET_DATA(ch);
uint16_t w = FONT_GET_WIDTH(ch); uint16_t w = FONT_GET_WIDTH(ch);
blit8BitWidthBitmap(x, y, w, FONT_GET_HEIGHT, char_buf); ili9341_blitBitmap(x, y, w, FONT_GET_HEIGHT, char_buf);
x += w; x += w;
} }
} }
@ -777,7 +814,7 @@ void ili9341_drawstring_7x13(const char *str, int x, int y)
if (ch == '\n') {x = x_pos; y+=bFONT_STR_HEIGHT; continue;} if (ch == '\n') {x = x_pos; y+=bFONT_STR_HEIGHT; continue;}
const uint8_t *char_buf = bFONT_GET_DATA(ch); const uint8_t *char_buf = bFONT_GET_DATA(ch);
uint16_t w = bFONT_GET_WIDTH(ch); uint16_t w = bFONT_GET_WIDTH(ch);
blit8BitWidthBitmap(x, y, w, bFONT_GET_HEIGHT, char_buf); ili9341_blitBitmap(x, y, w, bFONT_GET_HEIGHT, char_buf);
x += w; x += w;
} }
} }
@ -792,7 +829,7 @@ void ili9341_drawstring_10x14(const char *str, int x, int y)
const uint8_t *char_buf = wFONT_GET_DATA(ch); const uint8_t *char_buf = wFONT_GET_DATA(ch);
uint16_t w = wFONT_GET_WIDTH(ch); uint16_t w = wFONT_GET_WIDTH(ch);
bit_align = (w<=8) ? 1 : 0; bit_align = (w<=8) ? 1 : 0;
blit8BitWidthBitmap(x, y, w, wFONT_GET_HEIGHT, char_buf); ili9341_blitBitmap(x, y, w, wFONT_GET_HEIGHT, char_buf);
x += w; x += w;
} }
bit_align = 0; bit_align = 0;
@ -834,7 +871,7 @@ void ili9341_drawstring_size(const char *str, int x, int y, uint8_t size)
void ili9341_drawfont(uint8_t ch, int x, int y) void ili9341_drawfont(uint8_t ch, int x, int y)
{ {
blit8BitWidthBitmap(x, y, NUM_FONT_GET_WIDTH, NUM_FONT_GET_HEIGHT, ili9341_blitBitmap(x, y, NUM_FONT_GET_WIDTH, NUM_FONT_GET_HEIGHT,
NUM_FONT_GET_DATA(ch)); NUM_FONT_GET_DATA(ch));
} }

187
main.c

@ -1019,9 +1019,9 @@ config_t config = {
// NanoVNA Default settings // NanoVNA Default settings
static const trace_t def_trace[TRACES_MAX] = {//enable, type, channel, reserved, scale, refpos static const trace_t def_trace[TRACES_MAX] = {//enable, type, channel, reserved, scale, refpos
{ 0, TRC_LOGMAG, 0, 0, 10.0, (float) NGRIDY+1 }, //Temp [TRACE_TEMP] = { 0}, //Temp
{ 0, TRC_LOGMAG, 1, 0, 10.0, (float) NGRIDY+1 }, //Stored [TRACE_STORED] = { 0}, //Stored
{ 1, TRC_LOGMAG, 2, 0, 10.0, (float) NGRIDY+1 } //Actual [TRACE_ACTUAL] = { 1} //Actual
}; };
static const marker_t def_markers[MARKERS_MAX] = { static const marker_t def_markers[MARKERS_MAX] = {
@ -1049,6 +1049,8 @@ void load_LCD_properties(void)
//============================================= //=============================================
setting._electrical_delay = 0.0; setting._electrical_delay = 0.0;
#endif #endif
setting.trace_scale = 10.0;
setting.trace_refpos = 0;
memcpy(setting._trace, def_trace, sizeof(def_trace)); memcpy(setting._trace, def_trace, sizeof(def_trace));
memcpy(setting._markers, def_markers, sizeof(def_markers)); memcpy(setting._markers, def_markers, sizeof(def_markers));
#ifdef __VNA__ #ifdef __VNA__
@ -1064,10 +1066,10 @@ void load_LCD_properties(void)
//setting.checksum = 0; //setting.checksum = 0;
} }
#ifdef __VNA__
void void
ensure_edit_config(void) ensure_edit_config(void)
{ {
#ifdef __VNA__
if (active_props == &current_props) if (active_props == &current_props)
return; return;
@ -1075,8 +1077,8 @@ ensure_edit_config(void)
active_props = &current_props; active_props = &current_props;
// move to uncal state // move to uncal state
cal_status = 0; cal_status = 0;
#endif
} }
#endif
#include "sa_core.c" #include "sa_core.c"
#ifdef __AUDIO__ #ifdef __AUDIO__
@ -1273,81 +1275,57 @@ update_frequencies(void)
void void
set_sweep_frequency(int type, freq_t freq) set_sweep_frequency(int type, freq_t freq)
{ {
#ifdef __VNA__
int cal_applied = cal_status & CALSTAT_APPLY;
#endif
// Check frequency for out of bounds (minimum SPAN can be any value) // Check frequency for out of bounds (minimum SPAN can be any value)
if (type != ST_SPAN && freq < START_MIN) if (type != ST_SPAN && freq < START_MIN)
freq = START_MIN; freq = START_MIN;
if (freq > STOP_MAX) if (freq > STOP_MAX)
freq = STOP_MAX; freq = STOP_MAX;
// CW mode if span freq = 0 bool cw_mode = FREQ_IS_CW(); // remember old mode
if (type == ST_SPAN && freq == 0){ freq_t center, span;
type = ST_CW;
freq = setting.frequency0 / 2 + setting.frequency1 / 2;
}
ensure_edit_config();
switch (type) { switch (type) {
case ST_START: case ST_START:
setting.freq_mode &= ~FREQ_MODE_CENTER_SPAN; setting.freq_mode &= ~FREQ_MODE_CENTER_SPAN;
if (setting.frequency0 != freq) { setting.frequency0 = freq;
setting.frequency0 = freq; // if start > stop then make start = stop
// if start > stop then make start = stop if (setting.frequency1 < freq) setting.frequency1 = freq;
if (setting.frequency1 < freq) setting.frequency1 = freq;
}
break; break;
case ST_STOP: case ST_STOP:
setting.freq_mode &= ~FREQ_MODE_CENTER_SPAN; setting.freq_mode &= ~FREQ_MODE_CENTER_SPAN;
if (setting.frequency1 != freq) { setting.frequency1 = freq;
setting.frequency1 = freq; // if start > stop then make start = stop
// if start > stop then make start = stop if (setting.frequency0 > freq) setting.frequency0 = freq;
if (setting.frequency0 > freq) setting.frequency0 = freq;
}
break; break;
case ST_CENTER: case ST_CENTER:
setting.freq_mode |= FREQ_MODE_CENTER_SPAN; setting.freq_mode |= FREQ_MODE_CENTER_SPAN;
freq_t center = setting.frequency0 / 2 + setting.frequency1 / 2; center = setting.frequency0/2 + setting.frequency1/2;
if (center != freq) { span = (setting.frequency1 - setting.frequency0)/2;
freq_t span = setting.frequency1 - setting.frequency0; if (freq < START_MIN + span)
if (freq < START_MIN + span / 2) { span = (freq - START_MIN);
span = (freq - START_MIN) * 2; if (freq > STOP_MAX - span)
} span = (STOP_MAX - freq);
if (freq > STOP_MAX - span / 2) { setting.frequency0 = freq - span;
span = (STOP_MAX - freq) * 2; setting.frequency1 = freq + span;
}
setting.frequency0 = freq - span / 2;
setting.frequency1 = freq + span / 2;
}
break; break;
case ST_SPAN: case ST_SPAN:
setting.freq_mode |= FREQ_MODE_CENTER_SPAN; setting.freq_mode |= FREQ_MODE_CENTER_SPAN;
if (setting.frequency1 - setting.frequency0 != freq) { center = setting.frequency0/2 + setting.frequency1/2;
freq_t center = setting.frequency0 / 2 + setting.frequency1 / 2; span = freq/2;
if (center < START_MIN + freq / 2) { if (center < START_MIN + span)
center = START_MIN + freq / 2; center = START_MIN + span;
} if (center > STOP_MAX - span)
if (center > STOP_MAX - freq / 2) { center = STOP_MAX - span;
center = STOP_MAX - freq / 2; setting.frequency0 = center - span;
} setting.frequency1 = center + span;
setting.frequency0 = center - freq / 2;
setting.frequency1 = center + freq / 2;
}
break; break;
case ST_CW: case ST_CW:
setting.freq_mode |= FREQ_MODE_CENTER_SPAN; setting.freq_mode |= FREQ_MODE_CENTER_SPAN;
if (setting.frequency0 != freq || setting.frequency1 != freq) { setting.frequency0 = freq;
setting.frequency0 = freq; setting.frequency1 = freq;
setting.frequency1 = freq;
setting.sweep_time_us = 0; // use minimum as start
}
break; break;
} }
if (!cw_mode && FREQ_IS_CW()) // switch to CW mode
setting.sweep_time_us = 0; // use minimum as start
update_frequencies(); update_frequencies();
#ifdef __VNA__
if (cal_auto_interpolate && cal_applied)
cal_interpolate(lastsaveid);
#endif
} }
freq_t freq_t
@ -1825,91 +1803,24 @@ VNA_SHELL_FUNCTION(cmd_recall)
shell_printf("recall {id}\r\n"); shell_printf("recall {id}\r\n");
} }
static const struct {
const char *name;
uint16_t refpos;
float scale_unit;
} trace_info[] = {
{ "LOGMAG", NGRIDY, 10.0 },
#ifdef __VNA__
{ "PHASE", NGRIDY/2, 90.0 },
{ "DELAY", NGRIDY/2, 1e-9 },
{ "SMITH", 0, 1.00 },
{ "POLAR", 0, 1.00 },
{ "LINEAR", 0, 0.125},
{ "SWR", 0, 0.25 },
{ "REAL", NGRIDY/2, 0.25 },
{ "IMAG", NGRIDY/2, 0.25 },
{ "R", NGRIDY/2, 100.0 },
{ "X", NGRIDY/2, 100.0 }
#endif
};
#ifdef __VNA__
static const char * const trc_channel_name[] = {
"CH0", "CH1"
};
#endif
const char * const trc_channel_name[] = { const char * const trc_channel_name[] = {
"ACTUAL", "STORED", "COMPUTED" [TRACE_ACTUAL] = "ACTUAL",
[TRACE_STORED] = "STORED",
[TRACE_TEMP] = "COMPUTED",
}; };
const char *get_trace_typename(int t)
{
return trace_info[trace[t].type].name;
}
void set_trace_type(int t, int type)
{
int enabled = type != TRC_OFF;
int force = FALSE;
if (trace[t].enabled != enabled) {
trace[t].enabled = enabled;
force = TRUE;
}
if (trace[t].type != type) {
trace[t].type = type;
// Set default trace refpos
trace[t].refpos = trace_info[type].refpos;
// Set default trace scale
trace[t].scale = trace_info[type].scale_unit;
force = TRUE;
}
if (force) {
plot_into_index(measured);
redraw_request |= REDRAW_AREA;
}
}
void set_trace_scale(float scale) void set_trace_scale(float scale)
{ {
if (trace[TRACE_ACTUAL].scale != scale){ if (setting.trace_scale == scale) return;
trace[TRACE_ACTUAL].scale = scale; setting.trace_scale = scale;
trace[TRACE_STORED].scale = scale; redraw_request |= REDRAW_AREA | REDRAW_CAL_STATUS;
trace[TRACE_TEMP].scale = scale;
redraw_request |= REDRAW_AREA | REDRAW_CAL_STATUS;
}
}
float get_trace_scale(int t)
{
return trace[t].scale;
} }
void set_trace_refpos(float refpos) void set_trace_refpos(float refpos)
{ {
if (trace[TRACE_ACTUAL].refpos != refpos){ if (setting.trace_refpos == refpos) return;
trace[TRACE_ACTUAL].refpos = refpos; setting.trace_refpos = refpos;
trace[TRACE_STORED].refpos = refpos; redraw_request |= REDRAW_AREA | REDRAW_CAL_STATUS;
trace[TRACE_TEMP].refpos = refpos;
redraw_request |= REDRAW_AREA | REDRAW_CAL_STATUS;
}
}
float get_trace_refpos(int t)
{
return trace[t].refpos;
} }
VNA_SHELL_FUNCTION(cmd_trace) VNA_SHELL_FUNCTION(cmd_trace)
@ -1919,9 +1830,9 @@ VNA_SHELL_FUNCTION(cmd_trace)
for (t = 0; t < TRACES_MAX; t++) { for (t = 0; t < TRACES_MAX; t++) {
if (trace[t].enabled) { if (trace[t].enabled) {
const char *type = unit_string[setting.unit]; // get_trace_typename(t); const char *type = unit_string[setting.unit]; // get_trace_typename(t);
const char *channel = trc_channel_name[trace[t].channel]; const char *channel = trc_channel_name[t];
float scale = get_trace_scale(t); float scale = get_trace_scale();
float refpos = get_trace_refpos(t); float refpos = get_trace_refpos();
shell_printf("%d %s %s %f %f\r\n", t, type, channel, scale, refpos); shell_printf("%d %s %s %f %f\r\n", t, type, channel, scale, refpos);
} }
} }
@ -1932,8 +1843,8 @@ VNA_SHELL_FUNCTION(cmd_trace)
t = my_atoi(argv[0]); t = my_atoi(argv[0]);
if (argc != 1 || t < 0 || t >= TRACES_MAX) if (argc != 1 || t < 0 || t >= TRACES_MAX)
goto usage; goto usage;
const char *type = get_trace_typename(t); const char *type = "LOGMAG";//unit_string[setting.unit];
const char *channel = trc_channel_name[trace[t].channel]; const char *channel = trc_channel_name[t];
shell_printf("%d %s %s\r\n", t, type, channel); shell_printf("%d %s %s\r\n", t, type, channel);
return; return;
} }

@ -103,16 +103,16 @@
#define MARKER_COUNT 4 #define MARKER_COUNT 4
#define TRACES_MAX 3 #define TRACES_MAX 3
//#define TRACE_AGE 3 #define TRACE_ACTUAL 0
#define TRACE_ACTUAL 2
#define TRACE_STORED 1 #define TRACE_STORED 1
#define TRACE_TEMP 0 #define TRACE_TEMP 2
//#define TRACE_AGE 3
#define TRACE_INVALID -1 #define TRACE_INVALID -1
// #define age_t measured[TRACE_AGE]
#define stored_t measured[TRACE_STORED]
#define actual_t measured[TRACE_ACTUAL] #define actual_t measured[TRACE_ACTUAL]
#define stored_t measured[TRACE_STORED]
#define temp_t measured[TRACE_TEMP] #define temp_t measured[TRACE_TEMP]
// #define age_t measured[TRACE_AGE]
#ifdef TINYSA3 #ifdef TINYSA3
typedef uint32_t freq_t; typedef uint32_t freq_t;
@ -423,9 +423,6 @@ extern uint16_t graph_bottom;
#define WIDTH (LCD_WIDTH - 1 - OFFSETX) #define WIDTH (LCD_WIDTH - 1 - OFFSETX)
#define HEIGHT (GRIDY*NGRIDY) #define HEIGHT (GRIDY*NGRIDY)
#define CELLWIDTH (32)
#define CELLHEIGHT (32)
#define FREQUENCIES_XPOS1 OFFSETX #define FREQUENCIES_XPOS1 OFFSETX
#define FREQUENCIES_XPOS2 (LCD_WIDTH-120) #define FREQUENCIES_XPOS2 (LCD_WIDTH-120)
#define FREQUENCIES_YPOS (LCD_HEIGHT-8) #define FREQUENCIES_YPOS (LCD_HEIGHT-8)
@ -568,11 +565,6 @@ float value(float);
typedef struct trace { typedef struct trace {
uint8_t enabled; uint8_t enabled;
uint8_t type;
uint8_t channel;
uint8_t reserved;
float scale;
float refpos;
} trace_t; } trace_t;
#define FREQ_MODE_START_STOP 0x0 #define FREQ_MODE_START_STOP 0x0
@ -633,13 +625,6 @@ extern config_t config;
//#define settingLevelOffset config.level_offset //#define settingLevelOffset config.level_offset
float get_level_offset(void); float get_level_offset(void);
void set_trace_type(int t, int type);
void set_trace_channel(int t, int channel);
void set_trace_scale(float scale);
void set_trace_refpos(float refpos);
float get_trace_scale(int t);
float get_trace_refpos(int t);
const char *get_trace_typename(int t);
extern int in_selftest; extern int in_selftest;
extern int display_test(void); extern int display_test(void);
@ -723,14 +708,35 @@ extern volatile uint8_t redraw_request;
/* /*
* ili9341.c * ili9341.c
*/ */
// Set display buffers count for cell render (if use 2 and DMA, possible send data and prepare new in some time)
#ifdef __USE_DISPLAY_DMA__
// Cell size = sizeof(spi_buffer), but need wait while cell cata send to LCD
//#define DISPLAY_CELL_BUFFER_COUNT 1
// Cell size = sizeof(spi_buffer)/2, while one cell send to LCD by DMA, CPU render to next cell
#define DISPLAY_CELL_BUFFER_COUNT 2
#else
// Always one if no DMA mode
#define DISPLAY_CELL_BUFFER_COUNT 1
#endif
// One pixel size
typedef uint16_t pixel_t;
//#define CELLWIDTH (64/DISPLAY_CELL_BUFFER_COUNT)
//#define CELLHEIGHT (32)
#define CELLWIDTH (16)
#define CELLHEIGHT (16)
// Define size of screen buffer in pixels (one pixel 16bit size)
#define SPI_BUFFER_SIZE (CELLWIDTH*CELLHEIGHT*DISPLAY_CELL_BUFFER_COUNT*2)
// SPI bus revert byte order // SPI bus revert byte order
// 16-bit gggBBBbb RRRrrGGG // 16-bit gggBBBbb RRRrrGGG
#define RGB565(r,g,b) ( (((g)&0x1c)<<11) | (((b)&0xf8)<<5) | ((r)&0xf8) | (((g)&0xe0)>>5) ) #define RGB565(r,g,b) ( (((g)&0x1c)<<11) | (((b)&0xf8)<<5) | ((r)&0xf8) | (((g)&0xe0)>>5) )
#define RGBHEX(hex) ( (((hex)&0x001c00)<<3) | (((hex)&0x0000f8)<<5) | (((hex)&0xf80000)>>16) | (((hex)&0x00e000)>>13) ) #define RGBHEX(hex) ( (((hex)&0x001c00)<<3) | (((hex)&0x0000f8)<<5) | (((hex)&0xf80000)>>16) | (((hex)&0x00e000)>>13) )
#define HEXRGB(hex) ( (((hex)>>3)&0x001c00) | (((hex)>>5)&0x0000f8) | (((hex)<<16)&0xf80000) | (((hex)<<13)&0x00e000) ) #define HEXRGB(hex) ( (((hex)>>3)&0x001c00) | (((hex)>>5)&0x0000f8) | (((hex)<<16)&0xf80000) | (((hex)<<13)&0x00e000) )
// Define size of screen buffer in pixels (one pixel 16bit size)
#define SPI_BUFFER_SIZE (CELLWIDTH*CELLHEIGHT)
#ifdef TINYSA4 #ifdef TINYSA4
#define LCD_WIDTH 480 #define LCD_WIDTH 480
@ -778,9 +784,9 @@ extern volatile uint8_t redraw_request;
[LCD_MENU_COLOR ] = RGB565(230,230,230), \ [LCD_MENU_COLOR ] = RGB565(230,230,230), \
[LCD_MENU_TEXT_COLOR ] = RGB565( 0, 0, 0), \ [LCD_MENU_TEXT_COLOR ] = RGB565( 0, 0, 0), \
[LCD_MENU_ACTIVE_COLOR] = RGB565(210,210,210), \ [LCD_MENU_ACTIVE_COLOR] = RGB565(210,210,210), \
[LCD_TRACE_1_COLOR ] = RGB565(255, 0, 0), \ [LCD_TRACE_1_COLOR ] = RGB565(255,255, 0), \
[LCD_TRACE_2_COLOR ] = RGB565( 0,255, 0), \ [LCD_TRACE_2_COLOR ] = RGB565( 0,255, 0), \
[LCD_TRACE_3_COLOR ] = RGB565(255,255, 0), \ [LCD_TRACE_3_COLOR ] = RGB565(255, 0, 0), \
[LCD_TRACE_4_COLOR ] = RGB565(255, 0,255), \ [LCD_TRACE_4_COLOR ] = RGB565(255, 0,255), \
[LCD_NORMAL_BAT_COLOR ] = RGB565( 31,227, 0), \ [LCD_NORMAL_BAT_COLOR ] = RGB565( 31,227, 0), \
[LCD_LOW_BAT_COLOR ] = RGB565(255, 0, 0), \ [LCD_LOW_BAT_COLOR ] = RGB565(255, 0, 0), \
@ -819,15 +825,17 @@ extern uint16_t spi_buffer[SPI_BUFFER_SIZE];
void ili9341_init(void); void ili9341_init(void);
void ili9341_test(int mode); void ili9341_test(int mode);
void ili9341_bulk(int x, int y, int w, int h); void ili9341_bulk(int x, int y, int w, int h); // send data to display, in DMA mode use it, but wait DMA complete
void ili9341_bulk_continue(int x, int y, int w, int h); // send data to display, in DMA mode use it, no wait DMA complete
void ili9341_bulk_finish(void); // wait DMA complete (need call at end)
void ili9341_fill(int x, int y, int w, int h); void ili9341_fill(int x, int y, int w, int h);
pixel_t *ili9341_get_cell_buffer(void); // get buffer for cell render
void ili9341_set_foreground(uint16_t fg_idx); void ili9341_set_foreground(uint16_t fg_idx);
void ili9341_set_background(uint16_t bg_idx); void ili9341_set_background(uint16_t bg_idx);
void ili9341_clear_screen(void); void ili9341_clear_screen(void);
void blit8BitWidthBitmap(uint16_t x, uint16_t y, uint16_t width, uint16_t height, const uint8_t *bitmap); void ili9341_blitBitmap(uint16_t x, uint16_t y, uint16_t width, uint16_t height, const uint8_t *bitmap);
void blit16BitWidthBitmap(uint16_t x, uint16_t y, uint16_t width, uint16_t height, const uint16_t *bitmap);
void ili9341_drawchar(uint8_t ch, int x, int y); void ili9341_drawchar(uint8_t ch, int x, int y);
void ili9341_drawstring(const char *str, int x, int y); void ili9341_drawstring(const char *str, int x, int y);
void ili9341_drawstring_7x13(const char *str, int x, int y); void ili9341_drawstring_7x13(const char *str, int x, int y);
@ -836,7 +844,7 @@ void ili9341_drawstringV(const char *str, int x, int y);
int ili9341_drawchar_size(uint8_t ch, int x, int y, uint8_t size); int ili9341_drawchar_size(uint8_t ch, int x, int y, uint8_t size);
void ili9341_drawstring_size(const char *str, int x, int y, uint8_t size); void ili9341_drawstring_size(const char *str, int x, int y, uint8_t size);
void ili9341_drawfont(uint8_t ch, int x, int y); void ili9341_drawfont(uint8_t ch, int x, int y);
void ili9341_read_memory(int x, int y, int w, int h, int len, uint16_t* out); void ili9341_read_memory(int x, int y, int w, int h, int len, pixel_t* out);
void ili9341_line(int x0, int y0, int x1, int y1); void ili9341_line(int x0, int y0, int x1, int y1);
void show_version(void); void show_version(void);
@ -896,9 +904,13 @@ typedef struct setting
int decay; // KM_DECAY < 1000000 int decay; // KM_DECAY < 1000000
int attack; // KM_ATTACK < 20000 int attack; // KM_ATTACK < 20000
#ifdef TINYSA4
int32_t slider_position;
freq_t slider_span; freq_t slider_span;
long_t slider_position; #else
int32_t slider_position;
int32_t slider_span;
#endif
uint32_t rbw_x10; uint32_t rbw_x10;
uint32_t vbw_x10; uint32_t vbw_x10;
@ -918,6 +930,8 @@ typedef struct setting
freq_t frequency1; freq_t frequency1;
freq_t frequency_IF; freq_t frequency_IF;
float trace_scale;
float trace_refpos;
trace_t _trace[TRACES_MAX]; trace_t _trace[TRACES_MAX];
marker_t _markers[MARKERS_MAX]; marker_t _markers[MARKERS_MAX];
@ -942,6 +956,11 @@ extern setting_t setting;
void reset_settings(int m); void reset_settings(int m);
void set_trace_scale(float scale);
void set_trace_refpos(float refpos);
#define get_trace_scale() setting.trace_scale
#define get_trace_refpos() setting.trace_refpos
#define S_IS_AUTO(x) ((x)&2) #define S_IS_AUTO(x) ((x)&2)
#define S_STATE(X) ((X)&1) #define S_STATE(X) ((X)&1)
enum { S_OFF=0, S_ON=1, S_AUTO_OFF=2, S_AUTO_ON=3 }; enum { S_OFF=0, S_ON=1, S_AUTO_OFF=2, S_AUTO_ON=3 };

1076
plot.c

File diff suppressed because it is too large Load Diff

77
ui.c

@ -105,6 +105,10 @@ static const uint8_t slider_bitmap[]=
#define BUTTON_ICON_GROUP 4 #define BUTTON_ICON_GROUP 4
#define BUTTON_ICON_GROUP_CHECKED 5 #define BUTTON_ICON_GROUP_CHECKED 5
#define CHECK_ICON(S) ((S) ? BUTTON_ICON_CHECK : BUTTON_ICON_NOCHECK)
#define GROUP_ICON(S) ((S) ? BUTTON_ICON_GROUP_CHECKED : BUTTON_ICON_GROUP)
#define AUTO_ICON(S) (S>=2?BUTTON_ICON_CHECK_AUTO:S) // Depends on order of ICONs!!!!!
#define BUTTON_BORDER_NONE 0x00 #define BUTTON_BORDER_NONE 0x00
#define BUTTON_BORDER_WIDTH_MASK 0x0F #define BUTTON_BORDER_WIDTH_MASK 0x0F
@ -794,7 +798,6 @@ menu_velocity_cb(int item, uint8_t data)
ui_process_numeric(); ui_process_numeric();
} else { } else {
ui_mode_keypad(KM_VELOCITY_FACTOR); ui_mode_keypad(KM_VELOCITY_FACTOR);
ui_process_keypad();
} }
} }
@ -839,7 +842,6 @@ menu_scale_cb(int item, uint8_t data)
ui_process_numeric(); ui_process_numeric();
} else { } else {
ui_mode_keypad(data); ui_mode_keypad(data);
ui_process_keypad();
} }
} }
@ -858,7 +860,6 @@ menu_stimulus_cb(int item, uint8_t data)
ui_process_numeric(); ui_process_numeric();
} else { } else {
ui_mode_keypad(item); ui_mode_keypad(item);
ui_process_keypad();
} }
break; break;
case 5: /* PAUSE */ case 5: /* PAUSE */
@ -1294,7 +1295,8 @@ static void
ensure_selection(void) ensure_selection(void)
{ {
const menuitem_t *menu = menu_stack[menu_current_level]; const menuitem_t *menu = menu_stack[menu_current_level];
int i=0; if (selection < 0) {selection = -1; return;}
int i;
if (MT_MASK(menu[0].type) == MT_TITLE && selection == 0) { if (MT_MASK(menu[0].type) == MT_TITLE && selection == 0) {
selection = 1; selection = 1;
return; return;
@ -1311,10 +1313,11 @@ menu_move_back(bool leave_ui)
if (menu_current_level == 0) if (menu_current_level == 0)
return; return;
erase_menu_buttons(); erase_menu_buttons();
if ( menu_is_form(menu_stack[menu_current_level ]) &&
!menu_is_form(menu_stack[menu_current_level-1]))
redraw_request|=REDRAW_AREA|REDRAW_BATTERY|REDRAW_FREQUENCY|REDRAW_CAL_STATUS; // redraw all if switch from form to normal menu mode
menu_current_level--; menu_current_level--;
if (selection >= 0) selection = -1;
selection = 0;
ensure_selection();
if (leave_ui){ if (leave_ui){
ui_mode_normal(); ui_mode_normal();
@ -1412,7 +1415,6 @@ menu_invoke(int item)
kp_help_text = "240..960Mhz"; kp_help_text = "240..960Mhz";
} }
ui_mode_keypad(menu->data); ui_mode_keypad(menu->data);
ui_process_keypad();
redraw_request |= REDRAW_CAL_STATUS; redraw_request |= REDRAW_CAL_STATUS;
break; break;
} }
@ -1866,13 +1868,13 @@ draw_menu_buttons(const menuitem_t *menu)
ili9341_set_background(button.bg); ili9341_set_background(button.bg);
uint16_t text_offs = button_start + 6; uint16_t text_offs = button_start + 6;
if (button.icon >=0){ if (button.icon >=0){
blit8BitWidthBitmap(button_start+3, y+(MENU_BUTTON_HEIGHT-ICON_HEIGHT)/2, ICON_WIDTH, ICON_HEIGHT, &check_box[button.icon*2*ICON_HEIGHT]); ili9341_blitBitmap(button_start+3, y+(MENU_BUTTON_HEIGHT-ICON_HEIGHT)/2, ICON_WIDTH, ICON_HEIGHT, &check_box[button.icon*2*ICON_HEIGHT]);
text_offs = button_start+6+ICON_WIDTH+1; text_offs = button_start+6+ICON_WIDTH+1;
} }
#ifdef __ICONS__ #ifdef __ICONS__
if (menu[i].type & MT_ICON) { if (menu[i].type & MT_ICON) {
blit8BitWidthBitmap(button_start+MENU_FORM_WIDTH-2*FORM_ICON_WIDTH-8,y+(button_height-FORM_ICON_HEIGHT)/2,FORM_ICON_WIDTH,FORM_ICON_HEIGHT,& left_icons[((menu[i].data >>4)&0xf)*2*FORM_ICON_HEIGHT]); ili9341_blitBitmap(button_start+MENU_FORM_WIDTH-2*FORM_ICON_WIDTH-8,y+(button_height-FORM_ICON_HEIGHT)/2,FORM_ICON_WIDTH,FORM_ICON_HEIGHT,& left_icons[((menu[i].data >>4)&0xf)*2*FORM_ICON_HEIGHT]);
blit8BitWidthBitmap(button_start+MENU_FORM_WIDTH- FORM_ICON_WIDTH-8,y+(button_height-FORM_ICON_HEIGHT)/2,FORM_ICON_WIDTH,FORM_ICON_HEIGHT,&right_icons[((menu[i].data >>0)&0xf)*2*FORM_ICON_HEIGHT]); ili9341_blitBitmap(button_start+MENU_FORM_WIDTH- FORM_ICON_WIDTH-8,y+(button_height-FORM_ICON_HEIGHT)/2,FORM_ICON_WIDTH,FORM_ICON_HEIGHT,&right_icons[((menu[i].data >>0)&0xf)*2*FORM_ICON_HEIGHT]);
} }
#endif #endif
int local_slider_positions = 0; int local_slider_positions = 0;
@ -1901,7 +1903,7 @@ draw_menu_buttons(const menuitem_t *menu)
draw_slider: draw_slider:
if (local_slider_positions < button_start) if (local_slider_positions < button_start)
local_slider_positions = button_start; local_slider_positions = button_start;
blit8BitWidthBitmap(local_slider_positions - 4, y, 7, 5, slider_bitmap); ili9341_blitBitmap(local_slider_positions - 4, y, 7, 5, slider_bitmap);
} else if (menu[i].data == KM_HIGHOUTLEVEL) { } else if (menu[i].data == KM_HIGHOUTLEVEL) {
local_slider_positions = ((get_level() - level_min() ) * (MENU_FORM_WIDTH-8)) / level_range() + OFFSETX+4; local_slider_positions = ((get_level() - level_min() ) * (MENU_FORM_WIDTH-8)) / level_range() + OFFSETX+4;
goto draw_slider; goto draw_slider;
@ -1918,7 +1920,7 @@ draw_menu_buttons(const menuitem_t *menu)
ili9341_set_background(button.bg); ili9341_set_background(button.bg);
uint16_t text_offs = button_start + 7; uint16_t text_offs = button_start + 7;
if (button.icon >=0){ if (button.icon >=0){
blit8BitWidthBitmap(button_start+2, y+(MENU_BUTTON_HEIGHT-ICON_HEIGHT)/2, ICON_WIDTH, ICON_HEIGHT, &check_box[button.icon*2*ICON_HEIGHT]); ili9341_blitBitmap(button_start+2, y+(MENU_BUTTON_HEIGHT-ICON_HEIGHT)/2, ICON_WIDTH, ICON_HEIGHT, &check_box[button.icon*2*ICON_HEIGHT]);
text_offs = button_start+2+ICON_WIDTH; text_offs = button_start+2+ICON_WIDTH;
} }
int lines = menu_is_multiline(button.text); int lines = menu_is_multiline(button.text);
@ -2349,6 +2351,7 @@ ui_mode_keypad(int _keypad_mode)
draw_menu(); draw_menu();
draw_keypad(); draw_keypad();
draw_numeric_area_frame(); draw_numeric_area_frame();
ui_process_keypad();
} }
void void
@ -2724,11 +2727,8 @@ ui_process_keypad(void)
if (current_menu_is_form()) { if (current_menu_is_form()) {
ui_mode_menu(); //Reactivate menu after keypad ui_mode_menu(); //Reactivate menu after keypad
selection = -1; selection = -1;
ensure_selection();
// redraw_request|= REDRAW_BATTERY; // Only redraw battery
} else { } else {
ui_mode_normal(); ui_mode_normal();
// request_to_redraw_grid();
} }
//redraw_all(); //redraw_all();
} }
@ -2826,38 +2826,28 @@ static int
touch_lever_mode_select(int touch_x, int touch_y) touch_lever_mode_select(int touch_x, int touch_y)
{ {
if (touch_y > HEIGHT) { if (touch_y > HEIGHT) {
if (touch_x < FREQUENCIES_XPOS2 -50 && uistat.lever_mode == LM_CENTER) { touch_wait_release();
touch_wait_release(); // Touch on left frequency field side
if (setting.freq_mode & FREQ_MODE_CENTER_SPAN) if (touch_x < FREQUENCIES_XPOS2 - 50) {
ui_mode_keypad(KM_CENTER); if (uistat.lever_mode == LM_CENTER){
else ui_mode_keypad(FREQ_IS_CENTERSPAN() ? KM_CENTER : KM_START);
ui_mode_keypad(KM_START); return TRUE;
ui_process_keypad(); }
return TRUE;
} }
if (touch_x > FREQUENCIES_XPOS2 - 50 && touch_x < FREQUENCIES_XPOS2 +50) { else if (touch_x < FREQUENCIES_XPOS2 + 50) {
touch_wait_release(); // toggle frequency mode start/stop <=> center/span
if (FREQ_IS_STARTSTOP()) setting.freq_mode^= FREQ_MODE_CENTER_SPAN;
setting.freq_mode |= FREQ_MODE_CENTER_SPAN;
else if (FREQ_IS_CENTERSPAN())
setting.freq_mode &= ~FREQ_MODE_CENTER_SPAN;
redraw_request |= REDRAW_FREQUENCY; redraw_request |= REDRAW_FREQUENCY;
return true; return true;
} }
if (touch_x >= FREQUENCIES_XPOS2 +50 && uistat.lever_mode == LM_SPAN) { else if (uistat.lever_mode == LM_SPAN) {
touch_wait_release(); ui_mode_keypad(FREQ_IS_CW() ? KM_SWEEP_TIME : (FREQ_IS_CENTERSPAN() ? KM_SPAN : KM_STOP));
if (setting.freq_mode & FREQ_MODE_CENTER_SPAN)
ui_mode_keypad(KM_SPAN);
else
ui_mode_keypad(KM_STOP);
ui_process_keypad();
return TRUE; return TRUE;
} }
select_lever_mode(touch_x < FREQUENCIES_XPOS2 ? LM_CENTER : LM_SPAN); select_lever_mode(touch_x < FREQUENCIES_XPOS2 ? LM_CENTER : LM_SPAN);
touch_wait_release();
return TRUE; return TRUE;
} }
if (touch_x <OFFSETX) if (touch_x < OFFSETX)
{ {
return invoke_quick_menu(touch_y); return invoke_quick_menu(touch_y);
} }
@ -2943,7 +2933,6 @@ void ui_process_touch(void)
// switch menu mode after release // switch menu mode after release
touch_wait_release(); touch_wait_release();
selection = -1; // hide keyboard mode selection selection = -1; // hide keyboard mode selection
ensure_selection();
ui_mode_menu(); ui_mode_menu();
break; break;
case UI_MENU: case UI_MENU:
@ -2953,11 +2942,11 @@ void ui_process_touch(void)
} }
} }
static int previous_button_state = 0; static uint16_t previous_button_state = 0;
#ifdef __REMOTE_DESKTOP__ #ifdef __REMOTE_DESKTOP__
static int previous_mouse_state = 0; static uint16_t previous_mouse_state = 0;
static int previous_mouse_x = 0; static int16_t previous_mouse_x = 0;
static int previous_mouse_y = 0; static int16_t previous_mouse_y = 0;
#endif #endif
void void

@ -495,14 +495,12 @@ static const menuitem_t menu_modulation[];
static const menuitem_t menu_top[]; static const menuitem_t menu_top[];
static const menuitem_t menu_reffer[]; static const menuitem_t menu_reffer[];
static const menuitem_t menu_modulation[]; static const menuitem_t menu_modulation[];
static const menuitem_t menu_drive_wide[]; //static const menuitem_t menu_drive_wide[];
#ifdef TINYSA4 #ifdef TINYSA4
static const menuitem_t menu_settings3[]; static const menuitem_t menu_settings3[];
#endif #endif
static const menuitem_t menu_sweep[]; static const menuitem_t menu_sweep[];
#define AUTO_ICON(S) (S>=2?BUTTON_ICON_CHECK_AUTO:S) // Depends on order of ICONs!!!!!
static UI_FUNCTION_ADV_CALLBACK(menu_sweep_acb) static UI_FUNCTION_ADV_CALLBACK(menu_sweep_acb)
{ {
(void)data; (void)data;
@ -883,7 +881,6 @@ static UI_FUNCTION_ADV_CALLBACK(menu_measure_acb)
markers[0].mtype = M_REFERENCE | M_TRACKING; markers[0].mtype = M_REFERENCE | M_TRACKING;
kp_help_text = "Frequency of fundamental"; kp_help_text = "Frequency of fundamental";
ui_mode_keypad(KM_CENTER); ui_mode_keypad(KM_CENTER);
ui_process_keypad();
set_sweep_frequency(ST_START, 0); set_sweep_frequency(ST_START, 0);
set_sweep_frequency(ST_STOP, uistat.value*5); set_sweep_frequency(ST_STOP, uistat.value*5);
set_measurement(M_IMD); set_measurement(M_IMD);
@ -898,11 +895,9 @@ static UI_FUNCTION_ADV_CALLBACK(menu_measure_acb)
markers[1].mtype = M_TRACKING; markers[1].mtype = M_TRACKING;
kp_help_text = "Frequency of left signal"; kp_help_text = "Frequency of left signal";
ui_mode_keypad(KM_CENTER); ui_mode_keypad(KM_CENTER);
ui_process_keypad();
int left = uistat.value; int left = uistat.value;
kp_help_text = "Right signal"; kp_help_text = "Right signal";
ui_mode_keypad(KM_CENTER); ui_mode_keypad(KM_CENTER);
ui_process_keypad();
int right = uistat.value; int right = uistat.value;
set_sweep_frequency(ST_CENTER, (left+right)/2); set_sweep_frequency(ST_CENTER, (left+right)/2);
set_sweep_frequency(ST_SPAN, (right - left)*5); set_sweep_frequency(ST_SPAN, (right - left)*5);
@ -920,10 +915,8 @@ static UI_FUNCTION_ADV_CALLBACK(menu_measure_acb)
markers[1].mtype = M_DELTA | M_NOISE; markers[1].mtype = M_DELTA | M_NOISE;
kp_help_text = "Frequency of signal"; kp_help_text = "Frequency of signal";
ui_mode_keypad(KM_CENTER); ui_mode_keypad(KM_CENTER);
ui_process_keypad();
kp_help_text = "Frequency offset"; kp_help_text = "Frequency offset";
ui_mode_keypad(KM_SPAN); ui_mode_keypad(KM_SPAN);
ui_process_keypad();
set_sweep_frequency(ST_SPAN, uistat.value*4); set_sweep_frequency(ST_SPAN, uistat.value*4);
set_measurement(M_PHASE_NOISE); set_measurement(M_PHASE_NOISE);
set_average(4); set_average(4);
@ -937,10 +930,8 @@ static UI_FUNCTION_ADV_CALLBACK(menu_measure_acb)
markers[2].mtype = M_DELTA; markers[2].mtype = M_DELTA;
kp_help_text = "Frequency of signal"; kp_help_text = "Frequency of signal";
ui_mode_keypad(KM_CENTER); ui_mode_keypad(KM_CENTER);
ui_process_keypad();
kp_help_text = "Width of signal"; kp_help_text = "Width of signal";
ui_mode_keypad(KM_SPAN); ui_mode_keypad(KM_SPAN);
ui_process_keypad();
set_sweep_frequency(ST_SPAN, uistat.value*4); set_sweep_frequency(ST_SPAN, uistat.value*4);
set_measurement(M_STOP_BAND); set_measurement(M_STOP_BAND);
// SetAverage(4); // SetAverage(4);
@ -956,10 +947,8 @@ static UI_FUNCTION_ADV_CALLBACK(menu_measure_acb)
markers[2].mtype = M_DELTA; markers[2].mtype = M_DELTA;
// kp_help_text = "Frequency of signal"; // kp_help_text = "Frequency of signal";
// ui_mode_keypad(KM_CENTER); // ui_mode_keypad(KM_CENTER);
// ui_process_keypad();
// kp_help_text = "Width of signal"; // kp_help_text = "Width of signal";
// ui_mode_keypad(KM_SPAN); // ui_mode_keypad(KM_SPAN);
// ui_process_keypad();
// set_sweep_frequency(ST_SPAN, uistat.value*2); // set_sweep_frequency(ST_SPAN, uistat.value*2);
set_measurement(M_PASS_BAND); set_measurement(M_PASS_BAND);
// SetAverage(4); // SetAverage(4);
@ -980,11 +969,9 @@ static UI_FUNCTION_ADV_CALLBACK(menu_measure_acb)
markers[0].mtype = M_REFERENCE;// | M_TRACKING; markers[0].mtype = M_REFERENCE;// | M_TRACKING;
kp_help_text = "Frequency of signal"; kp_help_text = "Frequency of signal";
ui_mode_keypad(KM_CENTER); ui_mode_keypad(KM_CENTER);
ui_process_keypad();
center = uistat.value; center = uistat.value;
kp_help_text = "Modulation frequency, 3 .. 10 kHz"; kp_help_text = "Modulation frequency: 3 .. 10kHz";
ui_mode_keypad(KM_SPAN); ui_mode_keypad(KM_SPAN);
ui_process_keypad();
// if (uistat.value < 3000) // if (uistat.value < 3000)
// break; // break;
span = uistat.value; span = uistat.value;
@ -1005,18 +992,15 @@ static UI_FUNCTION_ADV_CALLBACK(menu_measure_acb)
markers[0].mtype = M_REFERENCE; markers[0].mtype = M_REFERENCE;
kp_help_text = "Frequency of signal"; kp_help_text = "Frequency of signal";
ui_mode_keypad(KM_CENTER); ui_mode_keypad(KM_CENTER);
ui_process_keypad();
set_marker_frequency(0, uistat.value); set_marker_frequency(0, uistat.value);
kp_help_text = "Modulation frequency: 1 .. 2.5kHz"; kp_help_text = "Modulation frequency: 1 .. 2.5kHz";
ui_mode_keypad(KM_SPAN); ui_mode_keypad(KM_SPAN);
ui_process_keypad();
if (uistat.value < 1000 || uistat.value > 2500) if (uistat.value < 1000 || uistat.value > 2500)
break; break;
set_RBW(uistat.value/100); set_RBW(uistat.value/100);
// actual_rbw_x10 // actual_rbw_x10
kp_help_text = "Frequency deviation: 3 .. 500kHz"; kp_help_text = "Frequency deviation: 3 .. 500kHz";
ui_mode_keypad(KM_SPAN); ui_mode_keypad(KM_SPAN);
ui_process_keypad();
if (uistat.value < 12000) if (uistat.value < 12000)
uistat.value = 12000; // minimum span uistat.value = 12000; // minimum span
set_sweep_frequency(ST_SPAN, uistat.value*4); set_sweep_frequency(ST_SPAN, uistat.value*4);
@ -1097,7 +1081,6 @@ static UI_FUNCTION_ADV_CALLBACK(menu_storage_acb)
if (setting.subtract_stored) { if (setting.subtract_stored) {
kp_help_text = "Ref level"; kp_help_text = "Ref level";
ui_mode_keypad(KM_REFLEVEL); ui_mode_keypad(KM_REFLEVEL);
ui_process_keypad();
// setting.normalize_level = uistat.value; // setting.normalize_level = uistat.value;
} else } else
set_auto_reflevel(true); set_auto_reflevel(true);
@ -2133,13 +2116,18 @@ static const menuitem_t menu_top[] = {
#define ACTIVE_COLOR RGBHEX(0x007FFF) #define ACTIVE_COLOR RGBHEX(0x007FFF)
int menu_is_form(const menuitem_t *menu) static bool menu_is_form(const menuitem_t *menu)
{ {
#if 1
// Not good set only one item as form and others as normal
return menu[0].type & MT_FORM;
#else
int i; int i;
for (i = 0; MT_MASK(menu[i].type) != MT_NONE; i++) for (i = 0; MT_MASK(menu[i].type) != MT_NONE; i++)
if (menu[i].type & MT_FORM) if (menu[i].type & MT_FORM)
return (true); return (true);
return(false); return(false);
#endif
} }
static void menu_item_modify_attribute( static void menu_item_modify_attribute(
@ -2530,7 +2518,6 @@ int invoke_quick_menu(int y)
if (y < quick_menu_y[i]) { if (y < quick_menu_y[i]) {
if ((uint32_t)quick_menu[i] < KM_NONE) { if ((uint32_t)quick_menu[i] < KM_NONE) {
ui_mode_keypad((int)quick_menu[i]); ui_mode_keypad((int)quick_menu[i]);
ui_process_keypad();
} else { } else {
selection = -1; selection = -1;
menu_current_level = 0; menu_current_level = 0;
@ -2562,9 +2549,7 @@ void draw_cal_status(void)
int x = 0; int x = 0;
int y = OFFSETY; int y = OFFSETY;
unsigned int color; unsigned int color;
int rounding = false; const bool rounding = !UNIT_IS_LINEAR(setting.unit);
if (!UNIT_IS_LINEAR(setting.unit))
rounding = true;
const char * const unit = unit_string[setting.unit]; const char * const unit = unit_string[setting.unit];
redraw_cal_status: redraw_cal_status:
buf[6]=0; buf[6]=0;

Loading…
Cancel
Save

Powered by TurnKey Linux.