Skip to content

Commit e91689f

Browse files
committed
add adjust maxagc/iqbal/cwtone and aux infomation
1 parent b1a3492 commit e91689f

File tree

4 files changed

+114
-27
lines changed

4 files changed

+114
-27
lines changed

display.c

Lines changed: 70 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,7 @@ typedef struct {
590590
#define FLAG_SPDISP (1<<0)
591591
#define FLAG_POWER (1<<1)
592592
#define FLAG_UI (1<<2)
593+
#define FLAG_AUX_INFO (1<<3)
593594

594595

595596
spectrumdisplay_t spdispinfo;
@@ -1304,15 +1305,13 @@ draw_aux_info(void)
13041305
uint16_t bg = BG_NORMAL;
13051306
uint16_t fg = FG_NORMAL;
13061307

1307-
ili9341_fill(0, y, 184, 24, 0x0000);
1308-
13091308
if (uistat.mode == AGC_MAXGAIN) {
13101309
fg = BG_NORMAL; bg = FG_NORMAL;
13111310
}
13121311

1313-
ili9341_drawstring_5x7("AGC MAX ", x, y, fg, bg);
1314-
x += 40;
1315-
itoap(config.agc.maximum_gain, str, 5, ' ');
1312+
ili9341_drawstring_5x7("AGCMAX", x, y, fg, bg);
1313+
x += 30;
1314+
itoap(config.agc.maximum_gain, str, 6, ' ');
13161315
ili9341_drawstring_5x7(str, x, y, fg, bg);
13171316

13181317
y += 8;
@@ -1322,8 +1321,8 @@ draw_aux_info(void)
13221321
fg = BG_NORMAL; bg = FG_NORMAL;
13231322
}
13241323

1325-
ili9341_drawstring_5x7("CWTONE ", x, y, fg, bg);
1326-
x += 35;
1324+
ili9341_drawstring_5x7("CWTONE", x, y, fg, bg);
1325+
x += 30;
13271326
itoap(uistat.cw_tone_freq, str, 4, ' ');
13281327
ili9341_drawstring_5x7(str, x, y, fg, bg);
13291328
x += 20;
@@ -1336,11 +1335,57 @@ draw_aux_info(void)
13361335
fg = BG_NORMAL; bg = FG_NORMAL;
13371336
}
13381337

1339-
ili9341_drawstring_5x7("IQBAL ", x, y, fg, bg);
1340-
x += 35;
1338+
ili9341_drawstring_5x7("IQBAL ", x, y, fg, bg);
1339+
x += 30;
13411340
itoap(uistat.iqbal, str, 6, ' ');
13421341
ili9341_drawstring_5x7(str, x, y, fg, bg);
13431342
x += 20;
1343+
1344+
// show statistics
1345+
fg = FG_NORMAL; bg = BG_NORMAL;
1346+
y = 48;
1347+
x = 65;
1348+
ili9341_drawstring_5x7("BATT", x, y, fg, bg);
1349+
x += 20;
1350+
itoap(stat.battery, str, 5, ' ');
1351+
ili9341_drawstring_5x7(str, x, y, fg, bg);
1352+
y += 8;
1353+
x = 65;
1354+
ili9341_drawstring_5x7("TEMP", x, y, fg, bg);
1355+
x += 20;
1356+
itoap(stat.temperature, str, 5, ' ');
1357+
ili9341_drawstring_5x7(str, x, y, fg, bg);
1358+
y += 8;
1359+
x = 65;
1360+
ili9341_drawstring_5x7("VREF", x, y, fg, bg);
1361+
x += 20;
1362+
itoap(stat.vref, str, 5, ' ');
1363+
ili9341_drawstring_5x7(str, x, y, fg, bg);
1364+
1365+
fg = FG_NORMAL; bg = BG_NORMAL;
1366+
y = 48;
1367+
x = 115;
1368+
ili9341_drawstring_5x7("RMS", x, y, fg, bg);
1369+
x += 15;
1370+
itoap(stat.rms[0], str, 5, ' ');
1371+
ili9341_drawstring_5x7(str, x, y, fg, bg);
1372+
y += 8;
1373+
x = 115;
1374+
ili9341_drawstring_5x7("FPS", x, y, fg, bg);
1375+
x += 15;
1376+
itoap(stat.fps, str, 5, ' ');
1377+
ili9341_drawstring_5x7(str, x, y, fg, bg);
1378+
y += 8;
1379+
x = 115;
1380+
ili9341_drawstring_5x7("OVF", x, y, fg, bg);
1381+
x += 15;
1382+
itoap(stat.overflow, str, 5, ' ');
1383+
ili9341_drawstring_5x7(str, x, y, fg, bg);
1384+
}
1385+
1386+
void clear_aux_info(void)
1387+
{
1388+
ili9341_fill(0, 48, 184, 24, 0x0000);
13441389
}
13451390

13461391
void
@@ -1374,6 +1419,11 @@ disp_process(void)
13741419
spdispinfo.update_flag &= ~FLAG_SPDISP;
13751420
}
13761421

1422+
if (spdispinfo.update_flag & FLAG_AUX_INFO) {
1423+
clear_aux_info();
1424+
spdispinfo.update_flag &= ~FLAG_AUX_INFO;
1425+
}
1426+
13771427
if (spdispinfo.update_flag & FLAG_UI) {
13781428
draw_tick();
13791429
if (uistat.mode == CHANNEL)
@@ -1389,6 +1439,10 @@ disp_process(void)
13891439

13901440
if (spdispinfo.update_flag & FLAG_POWER) {
13911441
draw_power();
1442+
1443+
//if (uistat.mode == AGC_MAXGAIN || uistat.mode == CWTONE || uistat.mode == IQBAL)
1444+
//draw_aux_info();
1445+
13921446
spdispinfo.update_flag &= ~FLAG_POWER;
13931447
}
13941448
}
@@ -1404,7 +1458,13 @@ disp_update_power(void)
14041458
{
14051459
spdispinfo.update_flag |= FLAG_POWER;
14061460
}
1407-
1461+
1462+
void
1463+
disp_clear_aux(void)
1464+
{
1465+
spdispinfo.update_flag |= FLAG_AUX_INFO;
1466+
}
1467+
14081468
void
14091469
disp_init(void)
14101470
{

main.c

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,11 @@
1313

1414
#include <stm32f303xc.h>
1515

16-
17-
static struct {
18-
int32_t rms[2];
19-
int16_t ave[2];
20-
int16_t min[2];
21-
int16_t max[2];
22-
23-
uint32_t callback_count;
24-
int32_t last_counter_value;
25-
int32_t interval_cycles;
26-
int32_t busy_cycles;
27-
28-
uint16_t fps_count;
29-
uint16_t fps;
30-
uint16_t overflow_count;
31-
uint16_t overflow;
32-
} stat;
16+
stat_t stat;
3317

3418
static void calc_stat(void);
3519
static void measure_power_dbm(void);
20+
static void measure_adc(void);
3621

3722
static THD_WORKING_AREA(waThread1, 128);
3823
static __attribute__((noreturn)) THD_FUNCTION(Thread1, arg)
@@ -54,6 +39,9 @@ static __attribute__((noreturn)) THD_FUNCTION(Thread1, arg)
5439
stat.overflow = stat.overflow_count;
5540
stat.overflow_count = 0;
5641
count = 0;
42+
43+
measure_adc();
44+
disp_update();
5745
}
5846
}
5947
}
@@ -425,6 +413,13 @@ uint16_t adc_single_read(ADC_TypeDef *adc, uint32_t chsel)
425413
#define ADC1_CHANNEL_BAT 17
426414
#define ADC1_CHANNEL_VREF 18
427415

416+
static void measure_adc(void)
417+
{
418+
stat.temperature = adc_single_read(ADC1, ADC1_CHANNEL_TEMP);
419+
stat.battery = adc_single_read(ADC1, ADC1_CHANNEL_BAT);
420+
stat.vref = adc_single_read(ADC1, ADC1_CHANNEL_VREF);
421+
}
422+
428423
static void cmd_stat(BaseSequentialStream *chp, int argc, char *argv[])
429424
{
430425
(void)argc;

nanosdr.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,30 @@
2222
* main.c
2323
*/
2424

25+
26+
typedef struct {
27+
int32_t rms[2];
28+
int16_t ave[2];
29+
int16_t min[2];
30+
int16_t max[2];
31+
32+
uint32_t callback_count;
33+
int32_t last_counter_value;
34+
int32_t interval_cycles;
35+
int32_t busy_cycles;
36+
37+
uint16_t fps_count;
38+
uint16_t fps;
39+
uint16_t overflow_count;
40+
uint16_t overflow;
41+
42+
uint16_t vref;
43+
uint16_t temperature;
44+
uint16_t battery;
45+
} stat_t;
46+
2547
extern int16_t measured_power_dbm;
48+
extern stat_t stat;
2649

2750
void set_agc_mode(int agcmode);
2851

@@ -202,6 +225,7 @@ void disp_process(void);
202225
void disp_fetch_samples(int bufid, int type, int16_t *buf0, int16_t *buf1, size_t len);
203226
void disp_update(void);
204227
void disp_update_power(void);
228+
void disp_clear_aux(void);
205229

206230
void set_window_function(int wf_type);
207231

ui.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,15 +282,23 @@ ui_process(void)
282282
} else {
283283
if (tick < 0) {
284284
uistat.mode--;
285+
286+
if (uistat.mode == IQBAL || uistat.mode == RFGAIN)
287+
disp_clear_aux();
288+
285289
// skip rfgain if agc is enabled
286290
if (uistat.agcmode != 0 && uistat.mode == RFGAIN)
287291
uistat.mode--;
288292
}
289293
if (tick > 0) {
290294
uistat.mode++;
295+
291296
// skip rfgain if agc is enabled
292297
if (uistat.agcmode != 0 && uistat.mode == RFGAIN)
293298
uistat.mode++;
299+
300+
if (uistat.mode == AGC_MAXGAIN || uistat.mode == SPDISP)
301+
disp_clear_aux();
294302
}
295303
uistat.mode = uistat.mode % MODE_MAX;
296304
}

0 commit comments

Comments
 (0)