diff --git a/NANOVNA_STM32_F072/mcuconf.h b/NANOVNA_STM32_F072/mcuconf.h index 1d4b073..99f4609 100644 --- a/NANOVNA_STM32_F072/mcuconf.h +++ b/NANOVNA_STM32_F072/mcuconf.h @@ -175,7 +175,7 @@ * I2S driver system settings. */ #define STM32_I2S_USE_SPI1 FALSE -#define STM32_I2S_USE_SPI2 TRUE +#define STM32_I2S_USE_SPI2 FALSE #define STM32_I2S_SPI1_MODE (STM32_I2S_MODE_MASTER | \ STM32_I2S_MODE_RX) #define STM32_I2S_SPI2_MODE (STM32_I2S_MODE_SLAVE | \ @@ -222,7 +222,7 @@ /* * SPI driver system settings. */ -#define STM32_SPI_USE_SPI1 TRUE +#define STM32_SPI_USE_SPI1 FALSE #define STM32_SPI_USE_SPI2 FALSE #define STM32_SPI_USE_SPI3 FALSE #define STM32_SPI_SPI1_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 2) diff --git a/NANOVNA_STM32_F303/mcuconf.h b/NANOVNA_STM32_F303/mcuconf.h index c0d4001..391e522 100644 --- a/NANOVNA_STM32_F303/mcuconf.h +++ b/NANOVNA_STM32_F303/mcuconf.h @@ -226,7 +226,7 @@ /* * SPI driver system settings. */ -#define STM32_SPI_USE_SPI1 TRUE +#define STM32_SPI_USE_SPI1 FALSE #define STM32_SPI_USE_SPI2 FALSE #define STM32_SPI_USE_SPI3 FALSE #define STM32_SPI_SPI1_RX_DMA_STREAM STM32_DMA_STREAM_ID(1, 2) diff --git a/adc.c b/adc.c index a55b4a8..d61068f 100644 --- a/adc.c +++ b/adc.c @@ -80,7 +80,7 @@ int16_t adc_vbat_read(void) // Vbat measure averange count = 2^VBAT_AVERAGE #define VBAT_AVERAGE 4 // Measure vbat every 5 second -#define VBAT_MEASURE_INTERVAL 50000 +#define VBAT_MEASURE_INTERVAL S2ST(5) static int16_t vbat_raw = 0; static systime_t vbat_time = -VBAT_MEASURE_INTERVAL-1; diff --git a/adc_F303.c b/adc_F303.c index 8cbfdc7..9691b80 100644 --- a/adc_F303.c +++ b/adc_F303.c @@ -96,7 +96,7 @@ int16_t adc_vbat_read(void) // Vbat measure averange count = 2^VBAT_AVERAGE #define VBAT_AVERAGE 4 // Measure vbat every 5 second -#define VBAT_MEASURE_INTERVAL 50000 +#define VBAT_MEASURE_INTERVAL S2ST(5) static int16_t vbat_raw = 0; static systime_t vbat_time = -VBAT_MEASURE_INTERVAL-1; diff --git a/halconf.h b/halconf.h index b3767eb..7077bb3 100644 --- a/halconf.h +++ b/halconf.h @@ -150,7 +150,7 @@ * @brief Enables the SPI subsystem. */ #if !defined(HAL_USE_SPI) || defined(__DOXYGEN__) -#define HAL_USE_SPI TRUE +#define HAL_USE_SPI FALSE #endif /** diff --git a/ili9341.c b/ili9341.c index 0c78c00..78d7257 100644 --- a/ili9341.c +++ b/ili9341.c @@ -23,7 +23,7 @@ #ifdef TINYSA4 #include "si4432.h" #endif - +#include "chprintf.h" #include "spi.h" // Pin macros for LCD @@ -841,6 +841,50 @@ void ili9341_drawstring_10x14(const char *str, int x, int y) #endif } +typedef struct { + const void *vmt; + int16_t start_x; + int16_t start_y; + int16_t x; + int16_t y; +} lcdPrintStream; + +static msg_t lcd_put(void *ip, uint8_t ch) { + lcdPrintStream *ps = ip; + if (ch == '\n') {ps->x = ps->start_x; ps->y+=FONT_STR_HEIGHT; return MSG_OK;} + uint16_t w = FONT_GET_WIDTH(ch); + ili9341_blitBitmap(ps->x, ps->y, w, FONT_GET_HEIGHT, FONT_GET_DATA(ch)); + ps->x+= w; + return MSG_OK; +} + +#if 0 +static msg_t lcd_put_7x13(void *ip, uint8_t ch) { + lcdPrintStream *ps = ip; + if (ch == '\n') {ps->x = ps->start_x; ps->y+=FONT_STR_HEIGHT; return MSG_OK;} + uint16_t w = FONT_GET_WIDTH(ch); + ili9341_blitBitmap(ps->x, ps->y, w, FONT_GET_HEIGHT, FONT_GET_DATA(ch)); + ps->x+= w; + return MSG_OK; +} +#endif + +// Simple print in buffer function +int lcd_printf(int16_t x, int16_t y, const char *fmt, ...) { + // Init small lcd print stream + struct lcd_printStreamVMT { + _base_sequential_stream_methods + } lcd_vmt = {NULL, NULL, lcd_put, NULL}; + lcdPrintStream ps = {&lcd_vmt, x, y, x, y}; + // Performing the print operation using the common code. + va_list ap; + va_start(ap, fmt); + int retval = chvprintf((BaseSequentialStream *)(void *)&ps, fmt, ap); + va_end(ap); + // Return number of bytes that would have been written. + return retval; +} + void ili9341_drawstringV(const char *str, int x, int y) { ili9341_set_rotation(DISPLAY_ROTATION_270); diff --git a/main.c b/main.c index a6cf428..43bf6b1 100644 --- a/main.c +++ b/main.c @@ -2046,9 +2046,8 @@ static const I2CConfig i2ccfg = { }; #endif -static DACConfig dac1cfg1 = { - //init: 2047U, - init: 1922U, +static const DACConfig dac1cfg1 = { + init: 0, datamode: DAC_DHRM_12BIT_RIGHT }; @@ -2224,18 +2223,7 @@ int main(void) shell_init_connection(); -#ifdef TINYSA4 - dac1cfg1.init = config.dac_value; -#else - dac1cfg1.init = 0; -#endif -/* - * Starting DAC1 driver, setting up the output pin as analog as suggested - * by the Reference Manual. - */ - dacStart(&DACD2, &dac1cfg1); - dacStart(&DACD1, &dac1cfg1); set_sweep_points(POINTS_COUNT); @@ -2279,11 +2267,16 @@ int main(void) ui_mode_normal(); /* - * Set LCD display brightness + * Set LCD display brightness (use DAC2 for control) + * Starting DAC1 driver, setting up the output pin as analog as suggested by the Reference Manual. */ #ifdef __LCD_BRIGHTNESS__ lcd_setBrightness(config._brightness); + #else + dacStart(&DACD2, &dac1cfg1); + dacPutChannelX(&DACD2, 0, config.dac_value); #endif + dacStart(&DACD1, &dac1cfg1); chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO-1, Thread1, NULL); @@ -2351,27 +2344,25 @@ void hard_fault_handler_c(uint32_t *sp) uint32_t psr = sp[7]; int y = 0; int x = OFFSETX + 1; - static char buf[96]; ili9341_set_background(LCD_BG_COLOR); ili9341_set_foreground(LCD_FG_COLOR); - - plot_printf(buf, sizeof(buf), "SP 0x%08x", (uint32_t)sp);ili9341_drawstring(buf, x, y+=FONT_STR_HEIGHT); - plot_printf(buf, sizeof(buf), "R0 0x%08x", r0);ili9341_drawstring(buf, x, y+=FONT_STR_HEIGHT); - plot_printf(buf, sizeof(buf), "R1 0x%08x", r1);ili9341_drawstring(buf, x, y+=FONT_STR_HEIGHT); - plot_printf(buf, sizeof(buf), "R2 0x%08x", r2);ili9341_drawstring(buf, x, y+=FONT_STR_HEIGHT); - plot_printf(buf, sizeof(buf), "R3 0x%08x", r3);ili9341_drawstring(buf, x, y+=FONT_STR_HEIGHT); - plot_printf(buf, sizeof(buf), "R4 0x%08x", r4);ili9341_drawstring(buf, x, y+=FONT_STR_HEIGHT); - plot_printf(buf, sizeof(buf), "R5 0x%08x", r5);ili9341_drawstring(buf, x, y+=FONT_STR_HEIGHT); - plot_printf(buf, sizeof(buf), "R6 0x%08x", r6);ili9341_drawstring(buf, x, y+=FONT_STR_HEIGHT); - plot_printf(buf, sizeof(buf), "R7 0x%08x", r7);ili9341_drawstring(buf, x, y+=FONT_STR_HEIGHT); - plot_printf(buf, sizeof(buf), "R8 0x%08x", r8);ili9341_drawstring(buf, x, y+=FONT_STR_HEIGHT); - plot_printf(buf, sizeof(buf), "R9 0x%08x", r9);ili9341_drawstring(buf, x, y+=FONT_STR_HEIGHT); - plot_printf(buf, sizeof(buf), "R10 0x%08x", r10);ili9341_drawstring(buf, x, y+=FONT_STR_HEIGHT); - plot_printf(buf, sizeof(buf), "R11 0x%08x", r11);ili9341_drawstring(buf, x, y+=FONT_STR_HEIGHT); - plot_printf(buf, sizeof(buf), "R12 0x%08x", r12);ili9341_drawstring(buf, x, y+=FONT_STR_HEIGHT); - plot_printf(buf, sizeof(buf), "LR 0x%08x", lr);ili9341_drawstring(buf, x, y+=FONT_STR_HEIGHT); - plot_printf(buf, sizeof(buf), "PC 0x%08x", pc);ili9341_drawstring(buf, x, y+=FONT_STR_HEIGHT); - plot_printf(buf, sizeof(buf), "PSR 0x%08x", psr);ili9341_drawstring(buf, x, y+=FONT_STR_HEIGHT); + lcd_printf(x, y+=FONT_STR_HEIGHT, "SP 0x%08x", (uint32_t)sp); + lcd_printf(x, y+=FONT_STR_HEIGHT, "R0 0x%08x", r0); + lcd_printf(x, y+=FONT_STR_HEIGHT, "R1 0x%08x", r1); + lcd_printf(x, y+=FONT_STR_HEIGHT, "R2 0x%08x", r2); + lcd_printf(x, y+=FONT_STR_HEIGHT, "R3 0x%08x", r3); + lcd_printf(x, y+=FONT_STR_HEIGHT, "R4 0x%08x", r4); + lcd_printf(x, y+=FONT_STR_HEIGHT, "R5 0x%08x", r5); + lcd_printf(x, y+=FONT_STR_HEIGHT, "R6 0x%08x", r6); + lcd_printf(x, y+=FONT_STR_HEIGHT, "R7 0x%08x", r7); + lcd_printf(x, y+=FONT_STR_HEIGHT, "R8 0x%08x", r8); + lcd_printf(x, y+=FONT_STR_HEIGHT, "R9 0x%08x", r9); + lcd_printf(x, y+=FONT_STR_HEIGHT, "R10 0x%08x", r10); + lcd_printf(x, y+=FONT_STR_HEIGHT, "R11 0x%08x", r11); + lcd_printf(x, y+=FONT_STR_HEIGHT, "R12 0x%08x", r12); + lcd_printf(x, y+=FONT_STR_HEIGHT, "LR 0x%08x", lr); + lcd_printf(x, y+=FONT_STR_HEIGHT, "PC 0x%08x", pc); + lcd_printf(x, y+=FONT_STR_HEIGHT, "PSR 0x%08x", psr); #ifdef ENABLE_THREADS_COMMAND thread_t *tp; tp = chRegFirstThread(); @@ -2385,11 +2376,10 @@ void hard_fault_handler_c(uint32_t *sp) #else uint32_t stklimit = 0U; #endif - plot_printf(buf, sizeof(buf), "%08x|%08x|%08x|%08x|%4u|%4u|%9s|%12s", + lcd_printf(x, y+=FONT_STR_HEIGHT, "%08x|%08x|%08x|%08x|%4u|%4u|%9s|%12s", stklimit, (uint32_t)tp->ctx.sp, max_stack_use, (uint32_t)tp, (uint32_t)tp->refs - 1, (uint32_t)tp->prio, states[tp->state], tp->name == NULL ? "" : tp->name); - ili9341_drawstring(buf, x, y+=FONT_STR_HEIGHT); tp = chRegNextThread(tp); } while (tp != NULL); #endif diff --git a/nanovna.h b/nanovna.h index 213b880..3c746d6 100644 --- a/nanovna.h +++ b/nanovna.h @@ -18,7 +18,7 @@ */ #include "ch.h" -//#ifdef TINYSA_F303 +#ifdef TINYSA_F303 #include "adc_F303.h" #ifdef TINYSA_F072 #error "Remove comment for #ifdef TINYSA_F303" @@ -27,7 +27,7 @@ #define TINYSA4 #endif #define TINYSA4_PROTO -//#endif +#endif #ifdef TINYSA_F072 #ifdef TINYSA_F303 @@ -962,6 +962,7 @@ void ili9341_drawchar(uint8_t ch, 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_10x14(const char *str, int x, int y); +int lcd_printf(int16_t x, int16_t y, const char *fmt, ...); void ili9341_drawstringV(const char *str, int x, int y); 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); @@ -1444,6 +1445,8 @@ enum { T_AUTO, T_NORMAL, T_SINGLE, T_DONE, T_UP, T_DOWN, T_MODE, T_PRE, T_POST, T_MID }; +//!!! Warning can show not correct results on CH_CFG_ST_FREQUENCY not round by 1000 or > 1000000UL +#define sa_ST2US(n) ((n)*(1000000UL/(CH_CFG_ST_FREQUENCY))) extern const uint8_t SI4432_RBW_count; extern void SI4432_Listen(int s); diff --git a/plot.c b/plot.c index 9af3490..e5ca346 100644 --- a/plot.c +++ b/plot.c @@ -631,8 +631,7 @@ static const uint8_t reference_bitmap[]={ #define X_MARKER_OFFSET 3 #define Y_MARKER_OFFSET 10 #define MARKER_BITMAP(i) (&marker_bitmap[(i)*MARKER_HEIGHT]) -static const uint8_t marker_bitmap[]= -{ +static const uint8_t marker_bitmap[]={ // Marker Back plate _BMP8(0b11111110), _BMP8(0b11111110), @@ -655,6 +654,7 @@ static const uint8_t marker_bitmap[]= _BMP8(0b00000000), _BMP8(0b00000000), _BMP8(0b00000000), +#if MARKERS_MAX >=2 // Marker 2 _BMP8(0b00000000), _BMP8(0b00111000), @@ -666,6 +666,8 @@ static const uint8_t marker_bitmap[]= _BMP8(0b00000000), _BMP8(0b00000000), _BMP8(0b00000000), +#endif +#if MARKERS_MAX >=3 // Marker 3 _BMP8(0b00000000), _BMP8(0b00111000), @@ -677,6 +679,8 @@ static const uint8_t marker_bitmap[]= _BMP8(0b00000000), _BMP8(0b00000000), _BMP8(0b00000000), +#endif +#if MARKERS_MAX >=4 // Marker 4 _BMP8(0b00000000), _BMP8(0b00001000), @@ -688,63 +692,69 @@ static const uint8_t marker_bitmap[]= _BMP8(0b00001000), _BMP8(0b00000000), _BMP8(0b00000000), -#if MARKER_COUNT > 4 +#endif +#if MARKERS_MAX >=5 // Marker 5 _BMP8(0b00000000), - _BMP8(0b11110000), - _BMP8(0b10000000), - _BMP8(0b11100000), - _BMP8(0b00010000), - _BMP8(0b00010000), - _BMP8(0b10010000), - _BMP8(0b01100000), + _BMP8(0b01111100), + _BMP8(0b01000000), + _BMP8(0b01111000), + _BMP8(0b00000100), + _BMP8(0b01000100), + _BMP8(0b00111000), _BMP8(0b00000000), _BMP8(0b00000000), + _BMP8(0b00000000), +#endif +#if MARKERS_MAX >=6 // Marker 6 _BMP8(0b00000000), - _BMP8(0b01100000), - _BMP8(0b10010000), - _BMP8(0b10000000), - _BMP8(0b11100000), - _BMP8(0b10010000), - _BMP8(0b10010000), - _BMP8(0b01100000), + _BMP8(0b00111100), + _BMP8(0b01000000), + _BMP8(0b01111000), + _BMP8(0b01000100), + _BMP8(0b01000100), + _BMP8(0b00111000), + _BMP8(0b00000000), _BMP8(0b00000000), _BMP8(0b00000000), +#endif +#if MARKERS_MAX >=7 // Marker 7 _BMP8(0b00000000), - _BMP8(0b11110000), + _BMP8(0b01111100), + _BMP8(0b01000100), + _BMP8(0b00000100), + _BMP8(0b00001000), + _BMP8(0b00010000), + _BMP8(0b00010000), _BMP8(0b00010000), - _BMP8(0b00100000), - _BMP8(0b00100000), - _BMP8(0b01000000), - _BMP8(0b01000000), - _BMP8(0b01000000), _BMP8(0b00000000), _BMP8(0b00000000), +#endif +#if MARKERS_MAX >=8 // Marker 8 _BMP8(0b00000000), - _BMP8(0b01100000), - _BMP8(0b10010000), - _BMP8(0b10010000), - _BMP8(0b01100000), - _BMP8(0b10010000), - _BMP8(0b10010000), - _BMP8(0b01100000), + _BMP8(0b00111000), + _BMP8(0b01000100), + _BMP8(0b00111000), + _BMP8(0b01000100), + _BMP8(0b01000100), + _BMP8(0b00111000), + _BMP8(0b00000000), _BMP8(0b00000000), _BMP8(0b00000000), - #endif }; + #elif _MARKER_SIZE_ == 1 #define MARKER_WIDTH 10 #define MARKER_HEIGHT 13 #define X_MARKER_OFFSET 4 #define Y_MARKER_OFFSET 13 #define MARKER_BITMAP(i) (&marker_bitmap[(i)*2*MARKER_HEIGHT]) -static const uint8_t marker_bitmap[]= -{ +static const uint8_t marker_bitmap[]={ // Marker Back plate _BMP16(0b1111111110000000), _BMP16(0b1111111110000000), @@ -773,20 +783,23 @@ static const uint8_t marker_bitmap[]= _BMP16(0b0000000000000000), _BMP16(0b0000000000000000), _BMP16(0b0000000000000000), +#if MARKERS_MAX >=2 // Marker 2 _BMP16(0b0000000000000000), _BMP16(0b0001111000000000), _BMP16(0b0011001100000000), _BMP16(0b0011001100000000), + _BMP16(0b0000001100000000), _BMP16(0b0000011000000000), - _BMP16(0b0000110000000000), - _BMP16(0b0001100000000000), + _BMP16(0b0001110000000000), _BMP16(0b0011000000000000), - _BMP16(0b0011111100000000), - _BMP16(0b0000000000000000), + _BMP16(0b0011000000000000), + _BMP16(0b0011111000000000), _BMP16(0b0000000000000000), _BMP16(0b0000000000000000), _BMP16(0b0000000000000000), +#endif +#if MARKERS_MAX >=3 // Marker 3 _BMP16(0b0000000000000000), _BMP16(0b0011111000000000), @@ -801,6 +814,8 @@ static const uint8_t marker_bitmap[]= _BMP16(0b0000000000000000), _BMP16(0b0000000000000000), _BMP16(0b0000000000000000), +#endif +#if MARKERS_MAX >=4 // Marker 4 _BMP16(0b0000000000000000), _BMP16(0b0000011000000000), @@ -815,60 +830,67 @@ static const uint8_t marker_bitmap[]= _BMP16(0b0000000000000000), _BMP16(0b0000000000000000), _BMP16(0b0000000000000000), -#if MARKER_COUNT>4 +#endif +#if MARKERS_MAX >=5 // Marker 5 _BMP16(0b0000000000000000), - _BMP16(0b11111100<<6), - _BMP16(0b11000000<<6), - _BMP16(0b11000000<<6), - _BMP16(0b11111000<<6), - _BMP16(0b11001100<<6), - _BMP16(0b00001100<<6), - _BMP16(0b00001100<<6), - _BMP16(0b11001100<<6), - _BMP16(0b01111000<<6), + _BMP16(0b0111111100000000), + _BMP16(0b0110000000000000), + _BMP16(0b0110000000000000), + _BMP16(0b0111111000000000), + _BMP16(0b0110001100000000), + _BMP16(0b0000001100000000), + _BMP16(0b0000001100000000), + _BMP16(0b0110001100000000), + _BMP16(0b0011111000000000), _BMP16(0b0000000000000000), _BMP16(0b0000000000000000), _BMP16(0b0000000000000000), +#endif +#if MARKERS_MAX >=6 // Marker 6 _BMP16(0b0000000000000000), - _BMP16(0b01111000<<6), - _BMP16(0b11001100<<6), - _BMP16(0b11000000<<6), - _BMP16(0b11000000<<6), - _BMP16(0b11111000<<6), - _BMP16(0b11001100<<6), - _BMP16(0b11001100<<6), - _BMP16(0b11001100<<6), - _BMP16(0b01111000<<6), + _BMP16(0b0011111000000000), + _BMP16(0b0110001100000000), + _BMP16(0b0110000000000000), + _BMP16(0b0110111000000000), + _BMP16(0b0111001100000000), + _BMP16(0b0110001100000000), + _BMP16(0b0110001100000000), + _BMP16(0b0110001100000000), + _BMP16(0b0011111000000000), _BMP16(0b0000000000000000), _BMP16(0b0000000000000000), _BMP16(0b0000000000000000), +#endif +#if MARKERS_MAX >=7 // Marker 7 _BMP16(0b0000000000000000), - _BMP16(0b11111100<<6), - _BMP16(0b00001100<<6), - _BMP16(0b00001100<<6), - _BMP16(0b00011000<<6), - _BMP16(0b00011000<<6), - _BMP16(0b00110000<<6), - _BMP16(0b00110000<<6), - _BMP16(0b01100000<<6), - _BMP16(0b01100000<<6), + _BMP16(0b0111111100000000), + _BMP16(0b0110001100000000), + _BMP16(0b0000001100000000), + _BMP16(0b0000011000000000), + _BMP16(0b0000110000000000), + _BMP16(0b0001100000000000), + _BMP16(0b0001100000000000), + _BMP16(0b0001100000000000), + _BMP16(0b0001100000000000), _BMP16(0b0000000000000000), _BMP16(0b0000000000000000), _BMP16(0b0000000000000000), +#endif +#if MARKERS_MAX >=8 // Marker 8 _BMP16(0b0000000000000000), - _BMP16(0b01111000<<6), - _BMP16(0b11001100<<6), - _BMP16(0b11001100<<6), - _BMP16(0b11001100<<6), - _BMP16(0b01111000<<6), - _BMP16(0b11001100<<6), - _BMP16(0b11001100<<6), - _BMP16(0b11001100<<6), - _BMP16(0b01111000<<6), + _BMP16(0b0011111000000000), + _BMP16(0b0110001100000000), + _BMP16(0b0110001100000000), + _BMP16(0b0011111000000000), + _BMP16(0b0110001100000000), + _BMP16(0b0110001100000000), + _BMP16(0b0110001100000000), + _BMP16(0b0110001100000000), + _BMP16(0b0011111000000000), _BMP16(0b0000000000000000), _BMP16(0b0000000000000000), _BMP16(0b0000000000000000), @@ -1294,77 +1316,8 @@ cell_drawchar_size(uint8_t ch, int x, int y, int size) } #endif -/* -void -cell_drawstring(char *str, int x, int y) -{ - if ((uint32_t)(y+FONT_GET_HEIGHT) >= CELLHEIGHT + FONT_GET_HEIGHT) - return; - while (*str) { - if (x >= CELLWIDTH) - return; - uint16_t ch = *str++; - uint16_t w = FONT_GET_WIDTH(ch); - cell_blit_bitmap(x, y, w, FONT_GET_HEIGHT, FONT_GET_DATA(ch)); - x += w; - } -} - -static void -cell_drawstring_7x13(char *str, int x, int y) -{ - if ((uint32_t)(y+bFONT_GET_HEIGHT) >= CELLHEIGHT + bFONT_GET_HEIGHT) - return; - while (*str) { - if (x >= CELLWIDTH) - return; - uint8_t ch = *str++; - uint16_t w = bFONT_GET_WIDTH(ch); - cell_blit_bitmap(x, y, w, bFONT_GET_HEIGHT, bFONT_GET_DATA(ch)); - x += w; - } -} - -#ifndef wFONT_GET_DATA -void -cell_drawstring_size(char *str, int x, int y, int size) -{ - if (y <= -FONT_GET_HEIGHT*2 || y >= CELLHEIGHT) - return; - while (*str) { - if (x >= CELLWIDTH) - return; - x += cell_drawchar_size(*str++, x, y, size); - } -} -#endif - -void -cell_drawstring_10x14(char *str, int x, int y) -{ -#ifdef wFONT_GET_DATA - if ((uint32_t)(y+wFONT_GET_HEIGHT) >= CELLHEIGHT + wFONT_GET_HEIGHT) - return; - while (*str) { - if (x >= CELLWIDTH) - return; - uint8_t ch = *str++; - uint16_t w = wFONT_GET_WIDTH(ch); - cell_blit_bitmap(x, y, w <=8 ? 9 : w, wFONT_GET_HEIGHT, wFONT_GET_DATA(ch)); - x+=w; - } -#else - cell_drawstring_size(str, x, y, 2); -#endif -} -*/ - -struct cellprintStreamVMT { - _base_sequential_stream_methods -}; - typedef struct { - const struct cellprintStreamVMT *vmt; + const void *vmt; int16_t x; int16_t y; } screenPrintStream; @@ -1378,7 +1331,6 @@ static msg_t cellPut(void *ip, uint8_t ch) { } return MSG_OK; } -static const struct cellprintStreamVMT cell_vmt_s = {NULL, NULL, cellPut, NULL}; static msg_t cellPut7x13(void *ip, uint8_t ch) { screenPrintStream *ps = ip; @@ -1389,10 +1341,8 @@ static msg_t cellPut7x13(void *ip, uint8_t ch) { } return MSG_OK; } -static const struct cellprintStreamVMT cell_vmt_b = {NULL, NULL, cellPut7x13, NULL}; //#define ENABLE_WIDE_FONT_ON_CELL - #ifdef ENABLE_WIDE_FONT_ON_CELL static msg_t cellPut10x14(void *ip, uint8_t ch) { screenPrintStream *ps = ip; @@ -1407,25 +1357,27 @@ static msg_t cellPut10x14(void *ip, uint8_t ch) { } return MSG_OK; } -static const struct cellprintStreamVMT cell_vmt_w = {NULL, NULL, cellPut10x14, NULL}; #endif // Simple print in buffer function int cell_printf(int16_t x, int16_t y, const char *fmt, ...) { // skip always if right if (x>=CELLWIDTH) return 0; - uint8_t font_type = *fmt++; - screenPrintStream ps; + // Init small cell print stream + struct cellprintStreamVMT { + _base_sequential_stream_methods + } cell_vmt = {NULL, NULL, NULL, NULL}; + screenPrintStream ps = {&cell_vmt, x, y}; // Select font and skip print if not on cell (at top/bottom) - switch (font_type){ + switch (*fmt++){ case _FONT_s: if ((uint32_t)(y+FONT_GET_HEIGHT) >= CELLHEIGHT + FONT_GET_HEIGHT) return 0; - ps.vmt = &cell_vmt_s; + cell_vmt.put = cellPut; break; #ifdef ENABLE_WIDE_FONT_ON_CELL case _FONT_w: if ((uint32_t)(y+FONT_GET_HEIGHT) >= CELLHEIGHT + FONT_GET_HEIGHT) return 0; - ps.vmt = &cell_vmt_w; + cell_vmt.put = cellPut10x14; break; #endif default: @@ -1433,14 +1385,11 @@ int cell_printf(int16_t x, int16_t y, const char *fmt, ...) { __attribute__ ((fallthrough)); // prevent warning case _FONT_b: if ((uint32_t)(y+bFONT_GET_HEIGHT) >= CELLHEIGHT + bFONT_GET_HEIGHT) return 0; - ps.vmt = &cell_vmt_b; + cell_vmt.put = cellPut7x13; break; } - va_list ap; - // Init small cell print stream - ps.x = x; - ps.y = y; // Performing the print operation using the common code. + va_list ap; va_start(ap, fmt); int retval = chvprintf((BaseSequentialStream *)(void *)&ps, fmt, ap); va_end(ap); @@ -1469,8 +1418,8 @@ static void trace_print_value_string( // Only used at one place int xpos, int ypos, bool bold, int mi, // Marker number - int ri, // reference Marker number - float coeff[POINTS_COUNT]) + int ri, // reference Marker number + float coeff[POINTS_COUNT]) { (void) bold; int mtype = markers[mi].mtype; @@ -1754,7 +1703,7 @@ draw_frequencies(void) // Draw battery level #define BATTERY_TOP_LEVEL 4200 -#define BATTERY_BOTTOM_LEVEL 3200 +#define BATTERY_BOTTOM_LEVEL 3300 #define BATTERY_WARNING_LEVEL 3300 #define BATTERY_MID_LEVEL 3600 diff --git a/sa_core.c b/sa_core.c index 5e08246..e761a7e 100644 --- a/sa_core.c +++ b/sa_core.c @@ -3441,7 +3441,7 @@ again: // Spur redu // i = 1; // Everything set so skip LO setting #define MODULATION_CYCLES_TEST 10000 if (in_selftest && modulation_count_iter++ >= 10000) { - start_of_sweep_timestamp = (chVTGetSystemTimeX() - start_of_sweep_timestamp)*MODULATION_STEPS*100/MODULATION_CYCLES_TEST; // uS per cycle + start_of_sweep_timestamp = sa_ST2US(chVTGetSystemTimeX() - start_of_sweep_timestamp)*MODULATION_STEPS/MODULATION_CYCLES_TEST; // uS per cycle return 0; } goto modulation_again; // Keep repeating sweep loop till user aborts by input @@ -3775,7 +3775,7 @@ static bool sweep(bool break_on_operation) } } } - systime_t local_sweep_time = (chVTGetSystemTimeX() - start_of_sweep_timestamp)*100 ; + systime_t local_sweep_time = sa_ST2US(chVTGetSystemTimeX() - start_of_sweep_timestamp); if (setting.actual_sweep_time_us > ONE_SECOND_TIME) local_sweep_time = setting.actual_sweep_time_us; if (show_bar && (( local_sweep_time > ONE_SECOND_TIME && (i & 0x07) == 0) || ( local_sweep_time > ONE_SECOND_TIME*10)) ) @@ -4116,7 +4116,7 @@ static volatile int dummy; // ---------------------- process measured actual sweep time ----------------- // For CW mode value calculated in SI4432_Fill if (setting.measure_sweep_time_us == 0) - setting.measure_sweep_time_us = (chVTGetSystemTimeX() - start_of_sweep_timestamp) * 100; + setting.measure_sweep_time_us = sa_ST2US(chVTGetSystemTimeX() - start_of_sweep_timestamp); // Update actual time on change on status panel uint32_t delta = abs((int)(setting.actual_sweep_time_us - setting.measure_sweep_time_us)); @@ -4218,7 +4218,7 @@ static volatile int dummy; } else if (actual_max_level > target_level && setting.attenuate_x2 < 60) { delta = actual_max_level - target_level; } - if ((chVTGetSystemTimeX() - sweep_elapsed > 10000 && ( delta < -5 || delta > +5)) || delta > 10 ) { + if ((chVTGetSystemTimeX() - sweep_elapsed > MS2ST(1000) && ( delta < -5 || delta > +5)) || delta > 10 ) { setting.attenuate_x2 += delta + delta; if (setting.attenuate_x2 < 0) setting.attenuate_x2= 0; @@ -4828,7 +4828,6 @@ static void test_acquire(int i) } int cell_printf(int16_t x, int16_t y, const char *fmt, ...); -static char self_test_status_buf[35]; void cell_draw_test_info(int x0, int y0) { #define INFO_SPACING 13 @@ -4840,27 +4839,28 @@ void cell_draw_test_info(int x0, int y0) i++; int xpos = 25 - x0; int ypos = 50+i*INFO_SPACING - y0; - unsigned int color = LCD_FG_COLOR; + pixel_t color; + if (i < 0) + color = LCD_FG_COLOR; + else if (test_status[i] == TS_PASS) + color = LCD_BRIGHT_COLOR_GREEN; + else if (test_status[i] == TS_CRITICAL) + color = LCD_TRACE_3_COLOR; // Yellow + else if (test_status[i] == TS_FAIL) + color = LCD_BRIGHT_COLOR_RED; + else + color = LCD_BRIGHT_COLOR_BLUE; + ili9341_set_foreground(color); if (i == -1) { - plot_printf(self_test_status_buf, sizeof self_test_status_buf, FONT_s"Self test status:"); + cell_printf(xpos, ypos, FONT_s"Self test status:"); } else if (test_case[i].kind == TC_END) { if (test_wait) - plot_printf(self_test_status_buf, sizeof self_test_status_buf, FONT_s"Touch screen to continue"); - else - self_test_status_buf[0] = 0; + cell_printf(xpos, ypos, FONT_s"Touch screen to continue"); + continue; } else { - plot_printf(self_test_status_buf, sizeof self_test_status_buf, FONT_s"Test %d: %s%s", i+1, test_fail_cause[i], test_text[test_status[i]] ); - if (test_status[i] == TS_PASS) - color = LCD_BRIGHT_COLOR_GREEN; - else if (test_status[i] == TS_CRITICAL) - color = LCD_TRACE_3_COLOR; // Yellow - else if (test_status[i] == TS_FAIL) - color = LCD_BRIGHT_COLOR_RED; - else - color = LCD_BRIGHT_COLOR_BLUE; + cell_printf(xpos, ypos, FONT_s"Test %d: %s%s", i+1, test_fail_cause[i], test_text[test_status[i]] ); + continue; } - ili9341_set_foreground(color); - cell_printf(xpos, ypos, self_test_status_buf); } while (test_case[i].kind != TC_END); } diff --git a/si4432.c b/si4432.c index 6fd8c27..88b07d0 100644 --- a/si4432.c +++ b/si4432.c @@ -593,7 +593,7 @@ void SI4432_trigger_fill(int s, uint8_t trigger_lvl, int up_direction, int trigg case ST_ARMING: if (i == sweep_points-1) { waiting = ST_WAITING; - setting.measure_sweep_time_us = (chVTGetSystemTimeX() - measure)*100; + setting.measure_sweep_time_us = sa_ST2US(chVTGetSystemTimeX() - measure); } break; case ST_WAITING: @@ -674,7 +674,7 @@ void SI4432_Fill(int s, int start) shiftInBuf(sel, SI4432_REG_RSSI, &age[start], sweep_points - start, t); #endif // __enable_irq(); - setting.measure_sweep_time_us = (chVTGetSystemTimeX() - measure)*100; + setting.measure_sweep_time_us = sa_ST2US(chVTGetSystemTimeX() - measure); buf_index = start; // Is used to skip 1st entry during level triggering buf_end = sweep_points - 1; buf_read = true; diff --git a/si4468.c b/si4468.c index dd3ff32..7f589f7 100644 --- a/si4468.c +++ b/si4468.c @@ -1276,7 +1276,7 @@ void SI446x_Fill(int s, int start) } while(1); __enable_irq(); - setting.measure_sweep_time_us = (chVTGetSystemTimeX() - measure)*100; + setting.measure_sweep_time_us = sa_ST2US(chVTGetSystemTimeX() - measure); buf_index = (start<=0 ? 0 : start); // Is used to skip 1st entry during level triggering buf_read = true; } diff --git a/ui.c b/ui.c index f3c5e35..1fb1527 100644 --- a/ui.c +++ b/ui.c @@ -64,7 +64,11 @@ static uint16_t last_button = 0b0000; static uint32_t last_button_down_ticks; static uint32_t last_button_repeat_ticks; -//static uint16_t menu_button_height = MENU_BUTTON_HEIGHT_N(MENU_BUTTON_MIN); +#define MENU_USE_AUTOHEIGHT +#ifdef MENU_USE_AUTOHEIGHT +static uint16_t menu_button_height = MENU_BUTTON_HEIGHT_N(MENU_BUTTON_MIN); +#endif + volatile uint8_t operation_requested = OP_NONE; int8_t previous_marker = MARKER_INVALID; @@ -641,6 +645,8 @@ enum { //#define MT_LEAVE 0x20 #define MT_MASK(x) (0xF & (x)) +#define MT_CUSTOM_LABEL 0 + // Call back functions for MT_CALLBACK type typedef void (*menuaction_cb_t)(int item, uint16_t data); #define UI_FUNCTION_CALLBACK(ui_function_name) void ui_function_name(int item, uint16_t data) @@ -820,7 +826,9 @@ ensure_selection(void) if (MT_MASK(menu[0].type) == MT_TITLE && selection == 0) selection = 1; if (i < MENU_BUTTON_MIN) i = MENU_BUTTON_MIN; if (i >= MENU_BUTTON_MAX) i = MENU_BUTTON_MAX; -// menu_button_height = MENU_BUTTON_HEIGHT_N(i); +#ifdef MENU_USE_AUTOHEIGHT + menu_button_height = MENU_BUTTON_HEIGHT_N(i); +#endif } static void @@ -1118,9 +1126,10 @@ static int menu_is_multiline(const char *label) { int n = 1; - while (*label) - if (*label++ == '\n') - n++; + if (label) + while (*label) + if (*label++ == '\n') + n++; return n; } @@ -1343,11 +1352,13 @@ static const uint8_t check_box[] = { static const char *step_text[5] = {"-10dB", "-1dB", "set", "+1dB", "+10dB"}; static char step_text_freq[5][10] = { "-100MHz", "-10MHz", "set", "+10MHz", "+100MHz" }; +#ifndef MENU_USE_AUTOHEIGHT #ifdef TINYSA4 #define menu_button_height ((menu[i].type & MT_FORM) || menu_is_multiline(menu[i].label) == 2 ? LCD_HEIGHT/10 : LCD_HEIGHT/12 ) #else #define menu_button_height ((menu[i].type & MT_FORM) || menu_is_multiline(menu[i].label) == 2 ? LCD_HEIGHT/8 : LCD_HEIGHT/10 ) #endif +#endif static void draw_menu_buttons(const menuitem_t *menu, int only) @@ -1390,24 +1401,26 @@ draw_menu_buttons(const menuitem_t *menu, int only) // Need replace this obsolete bad function on new MT_ADV_CALLBACK variant menu_item_modify_attribute(menu, i, &button); // before plot_printf to create status text - + char *text; // MT_ADV_CALLBACK - allow change button data in callback, more easy and correct if (MT_MASK(menu[i].type) == MT_ADV_CALLBACK){ menuaction_acb_t cb = (menuaction_acb_t)menu[i].reference; if (cb) (*cb)(i, menu[i].data, &button); + // Apply custom text, from button label and + if (menu[i].label != MT_CUSTOM_LABEL) + plot_printf(button.text, sizeof(button.text), menu[i].label, button.param_1.u); + text = button.text; } + else + text = menu[i].label; // Only keypad retrieves value if (menu[i].type & MT_FORM && MT_MASK(menu[i].type) == MT_KEYPAD) { keypad_mode = menu[i].data; fetch_numeric_target(); - button.param_1.text = uistat.text; + plot_printf(button.text, sizeof button.text, menu[i].label, uistat.text); + text = button.text; } - // Prepare button label - plot_printf(button.text, sizeof button.text, menu[i].label, button.param_1.u, button.param_2.u); - - int button_height = menu_button_height; - if (menu[i].type & MT_FORM) { int button_width = MENU_FORM_WIDTH; int button_start = (LCD_WIDTH - MENU_FORM_WIDTH)/2; // At center of screen @@ -1455,8 +1468,8 @@ draw_menu_buttons(const menuitem_t *menu, int only) goto draw_slider; } } -// ili9341_drawstring_size(button.text, text_offs, y+(button_height-2*FONT_GET_HEIGHT)/2-local_text_shift, 2); - ili9341_drawstring_10x14(button.text, text_offs, y+(button_height-wFONT_GET_HEIGHT)/2-local_text_shift); +// ili9341_drawstring_size(text, text_offs, y+(button_height-2*FONT_GET_HEIGHT)/2-local_text_shift, 2); + ili9341_drawstring_10x14(text, text_offs, y+(button_height-wFONT_GET_HEIGHT)/2-local_text_shift); } else { int button_width = MENU_BUTTON_WIDTH; int button_start = LCD_WIDTH - MENU_BUTTON_WIDTH; @@ -1466,12 +1479,12 @@ draw_menu_buttons(const menuitem_t *menu, int only) ili9341_blitBitmap(button_start+2, y+(button_height-ICON_HEIGHT)/2, ICON_WIDTH, ICON_HEIGHT, &check_box[button.icon*2*ICON_HEIGHT]); text_offs = button_start+2+ICON_WIDTH; } - int lines = menu_is_multiline(button.text); + int lines = menu_is_multiline(text); #define BIG_BUTTON_FONT 1 #ifdef BIG_BUTTON_FONT - ili9341_drawstring_7x13(button.text, text_offs, y+(button_height-lines*bFONT_GET_HEIGHT)/2); + ili9341_drawstring_7x13(text, text_offs, y+(button_height-lines*bFONT_GET_HEIGHT)/2); #else - ili9341_drawstring(button.text, text_offs, y+(button_height-linesFONT_GET_HEIGHT)/2); + ili9341_drawstring(text, text_offs, y+(button_height-linesFONT_GET_HEIGHT)/2); #endif } y += button_height; diff --git a/ui_sa.c b/ui_sa.c index 27b4206..26dfe9d 100644 --- a/ui_sa.c +++ b/ui_sa.c @@ -527,14 +527,13 @@ static UI_FUNCTION_ADV_CALLBACK(menu_sweep_acb) (void)item; if (b){ if (setting.level_sweep != 0 || get_sweep_frequency(ST_SPAN) != 0) { - plot_printf(uistat.text, sizeof uistat.text, "SW:%3.2fMHz %+ddB %.3Fs", + plot_printf(b->text, sizeof b->text, "SW:%3.2fMHz %+ddB %.3Fs", get_sweep_frequency(ST_SPAN) / 1000000.0, (int)setting.level_sweep, setting.sweep_time_us/(float)ONE_SECOND_TIME); - b->param_1.text = uistat.text; } else - b->param_1.text = "SWEEP: OFF"; + plot_printf(b->text, sizeof b->text, "SWEEP: OFF"); return; } menu_push_submenu(menu_sweep); @@ -547,11 +546,10 @@ static UI_FUNCTION_ADV_CALLBACK(menu_restart_acb){ if(b){ if (current_index >= 0 && setting.sweep) { float current_level = setting.level + ((float)current_index)* setting.level_sweep / (float)sweep_points; - plot_printf(uistat.text, sizeof uistat.text, "STOP %5.3QHz %+.1fdBm", frequencies[current_index], current_level); - b->param_1.text = uistat.text; - } else { - b->param_1.text = "START SWEEP"; + plot_printf(b->text, sizeof b->text, "STOP %5.3QHz %+.1fdBm", frequencies[current_index], current_level); } + else + plot_printf(b->text, sizeof b->text, "START SWEEP"); return; } setting.sweep = !setting.sweep; @@ -570,10 +568,9 @@ static UI_FUNCTION_ADV_CALLBACK(menu_curve_acb) (void)item; int old_m; if (b){ - plot_printf(uistat.text, sizeof uistat.text, "%8.3QHz %+4.1fdB", + plot_printf(b->text, sizeof b->text, "%8.3QHz %+4.1fdB", config.correction_frequency[current_curve][data], config.correction_value[current_curve][data]); - b->param_1.text = uistat.text; return; } switch(current_curve) { @@ -747,12 +744,10 @@ static UI_FUNCTION_ADV_CALLBACK(menu_load_preset_acb) (void)item; if(b){ setting_t *p = caldata_pointer(data); - char *t = (char *)spi_buffer; if (p) - plot_printf(t, 64, "%.6FHz\n%.6FHz", (float)p->frequency0, (float)p->frequency1);//\n%d-drstx8 + plot_printf(b->text, sizeof(b->text), "%.6FHz\n%.6FHz", (float)p->frequency0, (float)p->frequency1); else - plot_printf(t, 64, "EMPTY %d", (int)data); - b->param_1.text = t; + plot_printf(b->text, sizeof(b->text), "EMPTY %d", (int)data); return; } if (caldata_recall(data) == -1) { @@ -923,10 +918,9 @@ static UI_FUNCTION_ADV_CALLBACK(menu_smodulation_acb){ (void)data; if(b){ if (setting.modulation == MO_NONE || setting.modulation == MO_EXTERNAL) - b->param_1.text = menu_modulation_text[setting.modulation]; + plot_printf(b->text, sizeof b->text, "MOD: %s", menu_modulation_text[setting.modulation]); else { - plot_printf(uistat.text, sizeof uistat.text, "%5.3fkHz %s", setting.modulation_frequency / 1000.0, menu_modulation_text[setting.modulation]); - b->param_1.text = uistat.text; + plot_printf(b->text, sizeof b->text, "MOD: %5.3fkHz %s", setting.modulation_frequency / 1000.0, menu_modulation_text[setting.modulation]); } return; } @@ -1975,11 +1969,11 @@ static const menuitem_t menu_store_preset_high[8] = static const menuitem_t menu_load_preset_high[] = { - { MT_ADV_CALLBACK, 0, "LOAD\nSTARTUP",menu_load_preset_acb}, - { MT_ADV_CALLBACK, 5, "LOAD %s", menu_load_preset_acb}, - { MT_ADV_CALLBACK, 6, "LOAD %s", menu_load_preset_acb}, - { MT_ADV_CALLBACK, 7, "LOAD %s", menu_load_preset_acb}, - { MT_ADV_CALLBACK, 8, "LOAD %s", menu_load_preset_acb}, + { MT_ADV_CALLBACK, 0, "LOAD\nSTARTUP", menu_load_preset_acb}, + { MT_ADV_CALLBACK, 5, MT_CUSTOM_LABEL, menu_load_preset_acb}, + { MT_ADV_CALLBACK, 6, MT_CUSTOM_LABEL, menu_load_preset_acb}, + { MT_ADV_CALLBACK, 7, MT_CUSTOM_LABEL, menu_load_preset_acb}, + { MT_ADV_CALLBACK, 8, MT_CUSTOM_LABEL, menu_load_preset_acb}, { MT_SUBMENU, 0, "STORE" , menu_store_preset_high}, { MT_CANCEL, 255, S_LARROW" BACK", NULL }, { MT_NONE, 0, NULL, NULL } // sentinel @@ -2000,11 +1994,11 @@ static const menuitem_t menu_store_preset[] = static const menuitem_t menu_load_preset[] = { - { MT_ADV_CALLBACK, 0, "LOAD\nSTARTUP",menu_load_preset_acb}, - { MT_ADV_CALLBACK, 1, "%s" , menu_load_preset_acb}, - { MT_ADV_CALLBACK, 2, "%s" , menu_load_preset_acb}, - { MT_ADV_CALLBACK, 3, "%s" , menu_load_preset_acb}, - { MT_ADV_CALLBACK, 4, "%s" , menu_load_preset_acb}, + { MT_ADV_CALLBACK, 0, "LOAD\nSTARTUP", menu_load_preset_acb}, + { MT_ADV_CALLBACK, 1, MT_CUSTOM_LABEL, menu_load_preset_acb}, + { MT_ADV_CALLBACK, 2, MT_CUSTOM_LABEL, menu_load_preset_acb}, + { MT_ADV_CALLBACK, 3, MT_CUSTOM_LABEL, menu_load_preset_acb}, + { MT_ADV_CALLBACK, 4, MT_CUSTOM_LABEL, menu_load_preset_acb}, { MT_SUBMENU, 0, "STORE" , menu_store_preset}, { MT_CANCEL, 0, S_LARROW" BACK", NULL }, { MT_NONE, 0, NULL, NULL } // sentinel @@ -2059,10 +2053,10 @@ static const menuitem_t menu_lowoutputmode[] = { // { MT_FORM | MT_ADV_CALLBACK, 0, "MOD: %s", menu_smodulation_acb}, { MT_FORM | MT_KEYPAD, KM_CENTER, center_text, VARIANT("10kHz..350MHz","10kHz..850MHz")}, { MT_FORM | MT_KEYPAD, KM_LOWOUTLEVEL, "LEVEL: %s", low_level_help_text}, - { MT_FORM | MT_ADV_CALLBACK, 0, "MOD: %s", menu_smodulation_acb}, - { MT_FORM | MT_ADV_CALLBACK, 0, "%s", menu_sweep_acb}, + { MT_FORM | MT_ADV_CALLBACK, 0, MT_CUSTOM_LABEL, menu_smodulation_acb}, + { MT_FORM | MT_ADV_CALLBACK, 0, MT_CUSTOM_LABEL, menu_sweep_acb}, #ifdef __SWEEP_RESTART__ - { MT_FORM | MT_ADV_CALLBACK, 0, "%s", menu_restart_acb}, + { MT_FORM | MT_ADV_CALLBACK, 0, MT_CUSTOM_LABEL, menu_restart_acb}, #endif { MT_FORM | MT_KEYPAD, KM_EXT_GAIN, "EXTERNAL GAIN: %s", "-100..+100"}, #ifdef TINYSA4 @@ -2076,10 +2070,10 @@ static const menuitem_t menu_highoutputmode[] = { { MT_FORM | MT_ADV_CALLBACK, 0, "HIGH OUTPUT %s", menu_outputmode_acb}, { MT_FORM | MT_KEYPAD, KM_CENTER, center_text, VARIANT("240MHz..960MHz",range_text)}, { MT_FORM | MT_KEYPAD, KM_HIGHOUTLEVEL, "LEVEL: %s", low_level_help_text /* "-76..-6" */}, - { MT_FORM | MT_ADV_CALLBACK, 0, "MOD: %s", menu_smodulation_acb}, - { MT_FORM | MT_ADV_CALLBACK, 0, "%s", menu_sweep_acb}, + { MT_FORM | MT_ADV_CALLBACK, 0, MT_CUSTOM_LABEL, menu_smodulation_acb}, + { MT_FORM | MT_ADV_CALLBACK, 0, MT_CUSTOM_LABEL, menu_sweep_acb}, #ifdef __SWEEP_RESTART__ - { MT_FORM | MT_ADV_CALLBACK, 0, "%s", menu_restart_acb}, + { MT_FORM | MT_ADV_CALLBACK, 0, MT_CUSTOM_LABEL, menu_restart_acb}, #endif { MT_FORM | MT_KEYPAD, KM_EXT_GAIN, "EXTERNAL GAIN: %s", "-100..+100"}, #ifdef TINYSA4 @@ -2320,7 +2314,7 @@ static const menuitem_t menu_dfu[] = { #ifdef __HARMONIC__ static const menuitem_t menu_harmonic[] = { - { MT_ADV_CALLBACK, 0, "OFF", menu_harmonic_acb}, + { MT_ADV_CALLBACK, 0, "OFF", menu_harmonic_acb}, { MT_ADV_CALLBACK, 2, "2", menu_harmonic_acb}, { MT_ADV_CALLBACK, 3, "3", menu_harmonic_acb}, { MT_ADV_CALLBACK, 4, "4", menu_harmonic_acb}, @@ -2397,8 +2391,8 @@ static const menuitem_t menu_settings3[] = { #ifdef TINYSA4 // { MT_KEYPAD, KM_GRIDLINES, "MINIMUM\nGRIDLINES", "Enter minimum horizontal grid divisions"}, - { MT_ADV_CALLBACK, 0, "ADF OUT", menu_adf_out_acb}, - { MT_ADV_CALLBACK, 0, "ENABLE\nULTRA", menu_ultra_acb}, + { MT_ADV_CALLBACK, 0, "ADF OUT", menu_adf_out_acb}, + { MT_ADV_CALLBACK, 0, "ENABLE\nULTRA", menu_ultra_acb}, { MT_KEYPAD, KM_LPF, "ULTRA\nSTART", "Enter ULTRA mode start freq"}, // { MT_KEYPAD | MT_LOW, KM_IF2, "IF2 FREQ", "Set to zero for no IF2"}, { MT_KEYPAD, KM_R, "R", "Set R"}, @@ -2467,37 +2461,37 @@ static const menuitem_t menu_settings2[] = #ifdef TINYSA4 static const menuitem_t menu_curve3[] = { - { MT_FORM | MT_ADV_CALLBACK, 14, "%s", menu_curve_acb }, - { MT_FORM | MT_ADV_CALLBACK, 15, "%s", menu_curve_acb }, - { MT_FORM | MT_ADV_CALLBACK, 16, "%s", menu_curve_acb }, - { MT_FORM | MT_ADV_CALLBACK, 17, "%s", menu_curve_acb }, - { MT_FORM | MT_ADV_CALLBACK, 18, "%s", menu_curve_acb }, - { MT_FORM | MT_ADV_CALLBACK, 19, "%s", menu_curve_acb }, + { MT_FORM | MT_ADV_CALLBACK, 14, MT_CUSTOM_LABEL, menu_curve_acb }, + { MT_FORM | MT_ADV_CALLBACK, 15, MT_CUSTOM_LABEL, menu_curve_acb }, + { MT_FORM | MT_ADV_CALLBACK, 16, MT_CUSTOM_LABEL, menu_curve_acb }, + { MT_FORM | MT_ADV_CALLBACK, 17, MT_CUSTOM_LABEL, menu_curve_acb }, + { MT_FORM | MT_ADV_CALLBACK, 18, MT_CUSTOM_LABEL, menu_curve_acb }, + { MT_FORM | MT_ADV_CALLBACK, 19, MT_CUSTOM_LABEL, menu_curve_acb }, { MT_FORM | MT_CANCEL, 0, S_LARROW" BACK", NULL }, { MT_NONE, 0, NULL, NULL } // sentinel }; static const menuitem_t menu_curve2[] = { - { MT_FORM | MT_ADV_CALLBACK, 7, "%s", menu_curve_acb }, - { MT_FORM | MT_ADV_CALLBACK, 8, "%s", menu_curve_acb }, - { MT_FORM | MT_ADV_CALLBACK, 9, "%s", menu_curve_acb }, - { MT_FORM | MT_ADV_CALLBACK, 10, "%s", menu_curve_acb }, - { MT_FORM | MT_ADV_CALLBACK, 11, "%s", menu_curve_acb }, - { MT_FORM | MT_ADV_CALLBACK, 12, "%s", menu_curve_acb }, - { MT_FORM | MT_ADV_CALLBACK, 13, "%s", menu_curve_acb }, + { MT_FORM | MT_ADV_CALLBACK, 7, MT_CUSTOM_LABEL, menu_curve_acb }, + { MT_FORM | MT_ADV_CALLBACK, 8, MT_CUSTOM_LABEL, menu_curve_acb }, + { MT_FORM | MT_ADV_CALLBACK, 9, MT_CUSTOM_LABEL, menu_curve_acb }, + { MT_FORM | MT_ADV_CALLBACK, 10, MT_CUSTOM_LABEL, menu_curve_acb }, + { MT_FORM | MT_ADV_CALLBACK, 11, MT_CUSTOM_LABEL, menu_curve_acb }, + { MT_FORM | MT_ADV_CALLBACK, 12, MT_CUSTOM_LABEL, menu_curve_acb }, + { MT_FORM | MT_ADV_CALLBACK, 13, MT_CUSTOM_LABEL, menu_curve_acb }, { MT_FORM | MT_SUBMENU, 0, S_RARROW" MORE", menu_curve3}, { MT_FORM | MT_CANCEL, 0, S_LARROW" BACK", NULL }, { MT_NONE, 0, NULL, NULL } // sentinel }; static const menuitem_t menu_curve[] = { - { MT_FORM | MT_ADV_CALLBACK, 0, "%s", menu_curve_acb }, - { MT_FORM | MT_ADV_CALLBACK, 1, "%s", menu_curve_acb }, - { MT_FORM | MT_ADV_CALLBACK, 2, "%s", menu_curve_acb }, - { MT_FORM | MT_ADV_CALLBACK, 3, "%s", menu_curve_acb }, - { MT_FORM | MT_ADV_CALLBACK, 4, "%s", menu_curve_acb }, - { MT_FORM | MT_ADV_CALLBACK, 5, "%s", menu_curve_acb }, - { MT_FORM | MT_ADV_CALLBACK, 6, "%s", menu_curve_acb }, + { MT_FORM | MT_ADV_CALLBACK, 0, MT_CUSTOM_LABEL, menu_curve_acb }, + { MT_FORM | MT_ADV_CALLBACK, 1, MT_CUSTOM_LABEL, menu_curve_acb }, + { MT_FORM | MT_ADV_CALLBACK, 2, MT_CUSTOM_LABEL, menu_curve_acb }, + { MT_FORM | MT_ADV_CALLBACK, 3, MT_CUSTOM_LABEL, menu_curve_acb }, + { MT_FORM | MT_ADV_CALLBACK, 4, MT_CUSTOM_LABEL, menu_curve_acb }, + { MT_FORM | MT_ADV_CALLBACK, 5, MT_CUSTOM_LABEL, menu_curve_acb }, + { MT_FORM | MT_ADV_CALLBACK, 6, MT_CUSTOM_LABEL, menu_curve_acb }, { MT_FORM | MT_SUBMENU, 0, S_RARROW" MORE", menu_curve2}, { MT_FORM | MT_CANCEL, 0, S_LARROW" BACK", NULL }, { MT_NONE, 0, NULL, NULL } // sentinel @@ -2638,7 +2632,7 @@ static const menuitem_t menu_config[] = { { MT_SUBMENU, 0, S_RARROW" DFU", menu_dfu}, #endif #ifdef __LCD_BRIGHTNESS__ - { MT_CALLBACK, 0, "BRIGHTHESS", menu_brightness_cb}, + { MT_CALLBACK, 0, "BRIGHTNESS", menu_brightness_cb}, #endif { MT_CANCEL, 0, S_LARROW" BACK", NULL }, { MT_NONE, 0, NULL, NULL } // sentinel