All except waterfall working

tinySA
erikkaashoek 6 years ago
parent 4353721ec5
commit f2137f4f97

File diff suppressed because it is too large Load Diff

@ -120,7 +120,7 @@ CSRC = $(STARTUPSRC) \
$(BOARDSRC) \
$(STREAMSSRC) \
usbcfg.c \
main.c plot.c ui.c ili9341.c numfont20x22.c Font5x7.c flash.c adc.c si4432.c
main.c plot.c ui.c ili9341.c numfont20x22.c Font5x7.c flash.c adc.c si4432.c Font7x13b.c
# C++ sources that can be compiled in ARM or THUMB mode depending on the global
# setting.

@ -147,7 +147,7 @@
*
* @note The default is @p TRUE.
*/
#define CH_CFG_USE_REGISTRY FALSE
#define CH_CFG_USE_REGISTRY TRUE
/**
* @brief Threads synchronization APIs.

@ -383,7 +383,7 @@ void ili9341_bulk(int x, int y, int w, int h)
SPI_WRITE_16BIT(*buf++);
}
}
#else
static uint8_t ssp_sendrecvdata(void)
{
// Start RX clock (by sending data)
@ -417,7 +417,7 @@ void ili9341_read_memory(int x, int y, int w, int h, int len, uint16_t *out)
}
CS_HIGH;
}
#else
//
// Use DMA for send data
//
@ -469,7 +469,7 @@ void ili9341_bulk(int x, int y, int w, int h)
STM32_DMA_CR_MSIZE_HWORD | STM32_DMA_CR_MINC);
dmaStreamFlush(w * h);
}
#if 0 // Read DMA hangs
// Copy screen data to buffer
// 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)
@ -516,6 +516,7 @@ void ili9341_read_memory(int x, int y, int w, int h, int len, uint16_t *out)
}
}
#endif
#endif
void ili9341_clear_screen(void)
{
@ -567,6 +568,12 @@ static void blit16BitWidthBitmap(uint16_t x, uint16_t y, uint16_t width, uint16_
ili9341_bulk(x, y, width, height);
}
int ili9341_size = 1;
void ili9341_charsize(int s)
{
ili9341_size = s;
}
void ili9341_drawchar(uint8_t ch, int x, int y)
{
blit8BitWidthBitmap(x, y, FONT_GET_WIDTH(ch), FONT_GET_HEIGHT, FONT_GET_DATA(ch));

@ -71,7 +71,7 @@ static volatile vna_shellcmd_t shell_function = 0;
//#define ENABLED_DUMP
// Allow get threads debug info
//#define ENABLE_THREADS_COMMAND
#define ENABLE_THREADS_COMMAND
// RTC time not used
//#define ENABLE_TIME_COMMAND
// Enable vbat_offset command, allow change battery voltage correction in config
@ -117,7 +117,7 @@ const char *info_about[]={
0 // sentinel
};
static THD_WORKING_AREA(waThread1, 700);
static THD_WORKING_AREA(waThread1, 750);
static THD_FUNCTION(Thread1, arg)
{
(void)arg;
@ -786,7 +786,8 @@ config_t config = {
.harmonic_freq_threshold = 300000000,
#endif
.vbat_offset = 500,
.level_offset = 0
.low_level_offset = 0,
.high_level_offset = 0,
};
properties_t current_props;
@ -2221,6 +2222,14 @@ VNA_SHELL_FUNCTION(cmd_o)
setFreq(VFO, value);
}
VNA_SHELL_FUNCTION(cmd_d)
{
(void) argc;
int32_t a = my_atoi(argv[0]);
settingDrive = a;
}
VNA_SHELL_FUNCTION(cmd_a)
{
(void)argc;
@ -2289,8 +2298,12 @@ VNA_SHELL_FUNCTION(cmd_p)
int a = my_atoi(argv[1]);
if (p==5)
SetAttenuation(-a);
// if (p==6)
// SetMode(a);
if (p==6)
if (a != GetMode())
SetMode(a);
if (p==1)
if (get_refer_output() != a)
set_refer_output(a);
}
VNA_SHELL_FUNCTION(cmd_w)
@ -2384,6 +2397,7 @@ static const VNAShellCommand commands[] =
{ "p", cmd_p, 0 },
{ "w", cmd_w, 0 },
{ "o", cmd_o, 0 },
{ "d", cmd_d, 0 },
#ifdef ENABLE_THREADS_COMMAND
{"threads" , cmd_threads , 0},
#endif
@ -2539,12 +2553,12 @@ static const I2CConfig i2ccfg = {
.cr1 = 0, // CR1 register initialization.
.cr2 = 0 // CR2 register initialization.
};
#endif
static DACConfig dac1cfg1 = {
//init: 2047U,
init: 1922U,
datamode: DAC_DHRM_12BIT_RIGHT
};
#endif
// Main thread stack size defined in makefile USE_PROCESS_STACKSIZE = 0x200
@ -2587,9 +2601,9 @@ int main(void)
/* restore config */
config_recall();
caldata_recall(0); // must be done to setup the scanning stuff
/* restore frequencies and calibration 0 slot properties from flash memory */
caldata_recall(0);
#ifdef __VNA__
dac1cfg1.init = config.dac_value;
/*

@ -210,6 +210,7 @@ extern int16_t area_height;
// font
extern const uint8_t x5x7_bits [];
extern const uint16_t x7x13b_bits [];
#define FONT_GET_DATA(ch) (&x5x7_bits[ch*7])
#define FONT_GET_WIDTH(ch) (8-(x5x7_bits[ch*7]&7))
#define FONT_MAX_WIDTH 7
@ -276,13 +277,15 @@ typedef struct config {
uint32_t harmonic_freq_threshold;
#endif
uint16_t vbat_offset;
int16_t level_offset;
uint8_t _reserved[24];
int16_t low_level_offset;
int16_t high_level_offset;
uint8_t _reserved[22];
uint32_t checksum;
} config_t;
extern config_t config;
#define settingLevelOffset config.level_offset
//#define settingLevelOffset config.level_offset
int settingLevelOffset(void);
void set_trace_type(int t, int type);
void set_trace_channel(int t, int channel);
@ -492,9 +495,9 @@ extern properties_t current_props;
#define FREQ_IS_STARTSTOP() (!(config.freq_mode&FREQ_MODE_CENTER_SPAN))
#define FREQ_IS_CENTERSPAN() (config.freq_mode&FREQ_MODE_CENTER_SPAN)
#define FREQ_IS_CW() (frequency0 == frequency1)
int caldata_recall(int id);
#ifdef __VNA__
int caldata_save(int id);
int caldata_recall(int id);
const properties_t *caldata_ref(int id);
#endif
int config_save(void);

105
plot.c

@ -32,7 +32,7 @@ int fullscreen = true;
#endif
static void cell_draw_marker_info(int x0, int y0);
static void draw_battery_status(void);
void cell_draw_test_info(int m, int n, int w, int h);
void cell_draw_test_info(int x0, int y0);
static void frequency_string(char *buf, size_t len, int32_t freq);
static int16_t grid_offset;
@ -1394,7 +1394,8 @@ draw_cell(int m, int n)
// Check marker icon on cell
if (x + MARKER_WIDTH >= 0 && x - MARKER_WIDTH < CELLWIDTH &&
y + MARKER_HEIGHT >= 0 && y - MARKER_HEIGHT < CELLHEIGHT)
draw_marker(x, y, config.trace_color[t], i);
draw_marker(x, y, marker_color[markers[i].mtype], i);
// draw_marker(x, y, config.trace_color[t], i);
}
}
#endif
@ -1403,7 +1404,7 @@ draw_cell(int m, int n)
if (n == 0)
cell_draw_marker_info(x0, y0);
#endif
cell_draw_test_info(m, n, w, h);
cell_draw_test_info(x0, y0);
// PULSE;
// Draw reference position (<10 system ticks for all screen calls)
for (t = 0; t < TRACES_MAX; t++) {
@ -1456,7 +1457,7 @@ draw_all_cells(bool flush_markmap)
}
#ifdef __SCROLL__
if (waterfall) {
for (m = 226; m >= HEIGHT; m -= 1) { // Scroll down
for (m = 226; m >= HEIGHT+3; m -= 1) { // Scroll down
uint16_t *buf = &spi_buffer[0];
ili9341_read_memory(5*5, m, area_width, 1, area_width, buf);
ili9341_bulk(5*5,m+1, area_width,1);
@ -1496,7 +1497,7 @@ draw_all_cells(bool flush_markmap)
#endif
spi_buffer[i] = RGB565(r,g,b);
}
ili9341_bulk(5*5,HEIGHT, 290,1);
ili9341_bulk(5*5,HEIGHT+3, 290,1);
}
#endif
}
@ -1578,6 +1579,35 @@ cell_drawchar(uint8_t ch, int x, int y)
return ch_size;
}
static int
cell_drawchar_size(uint8_t ch, int x, int y, int size)
{
uint8_t bits;
int c, r, ch_size;
const uint8_t *char_buf = FONT_GET_DATA(ch);
ch_size = FONT_GET_WIDTH(ch);
// if (y <= -FONT_GET_HEIGHT || y >= CELLHEIGHT || x <= -ch_size || x >= CELLWIDTH)
// return ch_size;
if (x <= -ch_size*size)
return ch_size*size;
for (c = 0; c < FONT_GET_HEIGHT; c++) {
for (int i=0; i < size; i++) {
bits = *char_buf;
if ((y + c*size+i) < 0 || (y + c*size+i) >= CELLHEIGHT)
continue;
for (r = 0; r < ch_size; r++) {
for (int j = 0; j < size; j++) {
if ((x+r*size + j) >= 0 && (x+r*size+j) < CELLWIDTH && (0x80 & bits))
cell_buffer[(y+c*size+i)*CELLWIDTH + (x+r*size+j)] = foreground_color;
}
bits <<= 1;
}
}
char_buf++;
}
return ch_size*size;
}
void
cell_drawstring(char *str, int x, int y)
{
@ -1590,6 +1620,54 @@ cell_drawstring(char *str, int x, int y)
}
}
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);
}
}
static int
cell_drawchar_7x13(uint8_t ch, int x, int y)
{
uint16_t bits;
int c, r, ch_size;
ch_size = 7;
// if (y <= -FONT_GET_HEIGHT || y >= CELLHEIGHT || x <= -ch_size || x >= CELLWIDTH)
// return ch_size;
if (x <= -ch_size)
return ch_size;
for (c = 0; c < 13; c++) {
bits = x7x13b_bits[(ch * 13) + c];
if ((y + c) < 0 || (y + c) >= CELLHEIGHT)
continue;
for (r = 0; r < ch_size; r++) {
if ((x+r) >= 0 && (x+r) < CELLWIDTH && (0x8000 & bits))
cell_buffer[(y+c)*CELLWIDTH + (x+r)] = foreground_color;
bits <<= 1;
}
}
return ch_size;
}
void
cell_drawstring_7x13(char *str, int x, int y)
{
if (y <= -13 || y >= CELLHEIGHT)
return;
while (*str) {
if (x >= CELLWIDTH)
return;
x += cell_drawchar_7x13(*str++, x, y);
}
}
#ifdef __VNA__
static void
cell_draw_marker_info(int x0, int y0)
@ -1737,8 +1815,13 @@ static void cell_draw_marker_info(int x0, int y0)
for (t = TRACE_ACTUAL; t <= TRACE_ACTUAL; t++) { // Only show info on actual trace
if (!trace[t].enabled)
continue;
#if 1
int xpos = 1 + (j%2)*(WIDTH/2) + CELLOFFSETX - x0;
int ypos = 1 + (j/2)*(FONT_GET_HEIGHT+1) - y0;
int ypos = 1 + (j/2)*(13) - y0;
#else
int xpos = 1 + CELLOFFSETX - x0;
int ypos = 1 + j*(FONT_GET_HEIGHT*2+1) - y0;
#endif
int k = 0;
if (i == active_marker)
buf[k++] = '\033'; // Right arrow (?)
@ -1748,12 +1831,12 @@ static void cell_draw_marker_info(int x0, int y0)
buf[k++] = marker_letter[markers[i].mtype];
buf[k++] = 0;
ili9341_set_foreground(marker_color[markers[i].mtype]);
cell_drawstring(buf, xpos, ypos);
cell_drawstring_7x13(buf, xpos, ypos);
trace_get_value_string(
t, buf, sizeof buf,
idx, measured[trace[t].channel], frequencies, sweep_points, ridx, markers[i].mtype);
// cell_drawstring_7x13(w, h, buf, xpos+2*7, ypos, config.trace_color[t]);
cell_drawstring(buf, xpos+2*7, ypos);
cell_drawstring_7x13(buf, xpos+4*7, ypos);
j++;
}
}
@ -1780,14 +1863,16 @@ static void frequency_string(char *buf, size_t len, int32_t freq)
}
#endif
#ifdef __SA__
/*
if (freq < 1000) {
plot_printf(buf, len, "%dHz", (int)freq);
} else if (freq < 1000000) {
plot_printf(buf, len, "%d.%03dkHz",
(int)(freq / 1000),
(int)(freq % 1000));
} else {
plot_printf(buf, len, "%d.%03dMHz",
} else
*/ {
plot_printf(buf, len, "%d.%03",
(int)(freq / 1000000),
(int)((freq / 1000) % 1000));
}

@ -82,7 +82,7 @@ int settingLNA = false;
int extraVFO = false;
uint32_t minFreq = 0;
uint32_t maxFreq = 350000000;
uint32_t maxFreq = 520000000;
void set_refer_output(int v)
{
@ -176,13 +176,26 @@ int GetSubtractStorage(void)
extern float peakLevel;
void SetPowerLevel(int o)
{
if (o != 100)
settingLevelOffset = o - peakLevel - settingAttenuate + settingLevelOffset;
if (o != 100) {
if (settingMode & 1)
config.high_level_offset = o - peakLevel - settingAttenuate + settingLevelOffset();
else
settingLevelOffset = 0;
config.low_level_offset = o - peakLevel - settingAttenuate + settingLevelOffset();
}
else {
config.low_level_offset = 0;
config.high_level_offset = 0;
}
dirty = true;
}
int settingLevelOffset(void)
{
if (settingMode & 1)
return(config.high_level_offset);
return(config.low_level_offset);
}
void SetRBW(int v)
{
settingBandwidth = v;
@ -594,7 +607,7 @@ float perform(bool break_on_operation, int i, int32_t f, int extraV)
if (extraV)
setFreq (0, local_IF + lf - refferFreq[settingRefer]); // Offset so fundamental of reffer is visible
setFreq (1, local_IF + lf);
float subRSSI = SI4432_RSSI(lf, (settingMode & 1))+settingLevelOffset+settingAttenuate;
float subRSSI = SI4432_RSSI(lf, (settingMode & 1))+settingLevelOffset()+settingAttenuate;
if (RSSI < subRSSI)
RSSI = subRSSI;
t++;
@ -957,28 +970,28 @@ static void test_acquire(int i)
extern void cell_drawstring_5x7(int w, int h, char *str, int x, int y, uint16_t fg);
extern void cell_drawstring_7x13(int w, int h, char *str, int x, int y, uint16_t fg);
void cell_drawstring(char *str, int x, int y);
void cell_draw_test_info(int m, int n, int w, int h)
static char self_test_status_buf[35];
void cell_draw_test_info(int x0, int y0)
{
#define INFO_SPACING 13
char buf[35];
// char self_test_status_buf[35];
if (!show_test_info)
return;
for (int i = -1; i < TEST_COUNT+1; i++) {
int xpos = 25;
int ypos = 40+i*INFO_SPACING;
xpos -= m * CELLWIDTH -CELLOFFSETX;
ypos -= n * CELLHEIGHT;
int xpos = 25 - x0;
int ypos = 40+i*INFO_SPACING - y0;
unsigned int color = RGBHEX(0xFFFFFF);
if (i == -1) {
plot_printf(buf, sizeof buf, "Self test status:");
plot_printf(self_test_status_buf, sizeof self_test_status_buf, "Self test status:");
} else if (i == TEST_COUNT) {
if (test_wait)
plot_printf(buf, sizeof buf, "Touch screen to continue");
plot_printf(self_test_status_buf, sizeof self_test_status_buf, "Touch screen to continue");
else
buf[0] = 0;
self_test_status_buf[0] = 0;
} else {
plot_printf(buf, sizeof buf, "Test %d: %s%s", i+1, test_fail_cause[i], test_text[test_status[i]] );
plot_printf(self_test_status_buf, sizeof self_test_status_buf, "Test %d: %s%s", i+1, test_fail_cause[i], test_text[test_status[i]] );
if (test_status[i] == TS_PASS)
color = RGBHEX(0x00FF00);
else if (test_status[i] == TS_CRITICAL)
@ -988,7 +1001,8 @@ void cell_draw_test_info(int m, int n, int w, int h)
else
color = RGBHEX(0x0000FF);
}
cell_drawstring(buf, xpos, ypos, color);
ili9341_set_foreground(color);
cell_drawstring(self_test_status_buf, xpos, ypos);
}
}
@ -1137,7 +1151,7 @@ void self_test(void)
break;
case TP_10MHZEXTRA: // Swept receiver
extraVFO = true; //Sweep BPF
// Fall through intended!!!!!!
goto common;
case TP_10MHZ: // 10MHz input
common:
set_refer_output(2);

@ -2208,11 +2208,16 @@ void ui_process_touch(void)
touch_start_watchdog();
}
static int previous_button_state = 0;
void
ui_process(void)
{
if (operation_requested&OP_LEVER)
int button_state = READ_PORT() & BUTTON_MASK;
if (operation_requested&OP_LEVER || previous_button_state != button_state) {
ui_process_lever();
previous_button_state = button_state;
}
if (operation_requested&OP_TOUCH)
ui_process_touch();
operation_requested = OP_NONE;

@ -200,6 +200,7 @@ void menu_autosettings_cb(int item, uint8_t data)
set_refer_output(1);
SetAttenuation(0);
SetPowerLevel(100); // Reset
SetClearStorage();
SetRBW(0);
dirty = true;
menu_move_back();
@ -751,7 +752,7 @@ static void fetch_numeric_target(void)
uistat.value = settingAttenuate;
break;
case KM_ACTUALPOWER:
uistat.value = settingLevelOffset;
uistat.value = settingLevelOffset();
break;
case KM_IF:
uistat.value = frequency_IF;

Loading…
Cancel
Save

Powered by TurnKey Linux.