mirror of
https://github.com/ttrftech/NanoVNA.git
synced 2026-01-03 07:00:01 +01:00
Removed battery
This commit is contained in:
commit
bd047b7b30
5
.gitignore
vendored
5
.gitignore
vendored
|
|
@ -8,4 +8,7 @@ python
|
|||
*.py
|
||||
*.ipynb
|
||||
TAGS
|
||||
.emacs-dirvars
|
||||
.emacs-dirvars
|
||||
.cproject
|
||||
*.project
|
||||
.settings/language.settings.xml
|
||||
4
adc.c
4
adc.c
|
|
@ -25,6 +25,7 @@
|
|||
#define ADC_TR(low, high) (((uint32_t)(high) << 16U) | \
|
||||
(uint32_t)(low))
|
||||
#define ADC_SMPR_SMP_1P5 0U /**< @brief 14 cycles conversion time */
|
||||
#define ADC_SMPR_SMP_239P5 7U /**< @brief 252 cycles conversion time. */
|
||||
#define ADC_CFGR1_RES_12BIT (0U << 3U)
|
||||
|
||||
void adc_init(void)
|
||||
|
|
@ -61,7 +62,7 @@ uint16_t adc_single_read(ADC_TypeDef *adc, uint32_t chsel)
|
|||
adc->ISR = adc->ISR;
|
||||
adc->IER = 0;
|
||||
adc->TR = ADC_TR(0, 0);
|
||||
adc->SMPR = ADC_SMPR_SMP_1P5;
|
||||
adc->SMPR = ADC_SMPR_SMP_239P5;
|
||||
adc->CFGR1 = ADC_CFGR1_RES_12BIT;
|
||||
adc->CHSELR = chsel;
|
||||
|
||||
|
|
@ -73,7 +74,6 @@ uint16_t adc_single_read(ADC_TypeDef *adc, uint32_t chsel)
|
|||
|
||||
return adc->DR;
|
||||
}
|
||||
|
||||
void adc_start_analog_watchdogd(ADC_TypeDef *adc, uint32_t chsel)
|
||||
{
|
||||
uint32_t cfgr1;
|
||||
|
|
|
|||
24
main.c
24
main.c
|
|
@ -59,15 +59,12 @@ int8_t stop_the_world = FALSE;
|
|||
|
||||
BaseSequentialStream *saved_chp;
|
||||
|
||||
static THD_WORKING_AREA(waThread1, 640-64);
|
||||
static THD_WORKING_AREA(waThread1, 640);
|
||||
static THD_FUNCTION(Thread1, arg)
|
||||
{
|
||||
(void)arg;
|
||||
chRegSetThreadName("sweep");
|
||||
|
||||
//FFT(measured[0],measured[1],101,0);
|
||||
|
||||
|
||||
while (1) {
|
||||
if (stop_the_world) {
|
||||
__WFI();
|
||||
|
|
@ -1473,17 +1470,6 @@ static void cmd_trace(BaseSequentialStream *chp, int argc, char *argv[])
|
|||
}
|
||||
return;
|
||||
}
|
||||
#if 0
|
||||
if (strcmp(argv[0], "tdr") == 0) {
|
||||
set_trace_type(1, TRC_TDR);
|
||||
trace[0].channel = 1; // Get data from S21 after doing the FFT
|
||||
set_trace_type(1, TRC_OFF);
|
||||
set_trace_type(2, TRC_OFF);
|
||||
set_trace_type(3, TRC_OFF);
|
||||
goto exit;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (strcmp(argv[0], "all") == 0 &&
|
||||
argc > 1 && strcmp(argv[1], "off") == 0) {
|
||||
set_trace_type(0, TRC_OFF);
|
||||
|
|
@ -1552,10 +1538,7 @@ static void cmd_trace(BaseSequentialStream *chp, int argc, char *argv[])
|
|||
usage:
|
||||
chprintf(chp, "trace {0|1|2|3|all} [logmag|phase|smith|linear|delay|swr|real|imag|r|x|off] [src]\r\n");
|
||||
chprintf(chp, "trace {0|1|2|3} {scale|refpos} {value}\r\n");
|
||||
#if 0
|
||||
chprintf(chp, "trace tdr\r\n");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void set_electrical_delay(float picoseconds)
|
||||
|
|
@ -1664,6 +1647,7 @@ static void cmd_touchtest(BaseSequentialStream *chp, int argc, char *argv[])
|
|||
|
||||
}
|
||||
|
||||
|
||||
static void cmd_frequencies(BaseSequentialStream *chp, int argc, char *argv[])
|
||||
{
|
||||
int i;
|
||||
|
|
@ -1816,7 +1800,7 @@ static void cmd_version(BaseSequentialStream *chp, int argc, char *argv[])
|
|||
chprintf(chp, "%s\r\n", NANOVNA_VERSION);
|
||||
}
|
||||
|
||||
static THD_WORKING_AREA(waThread2, /* cmd_* max stack size + alpha */410+64);
|
||||
static THD_WORKING_AREA(waThread2, /* cmd_* max stack size + alpha */410);
|
||||
|
||||
static const ShellCommand commands[] =
|
||||
{
|
||||
|
|
|
|||
15
nanovna.h
15
nanovna.h
|
|
@ -195,6 +195,7 @@ void set_trace_refpos(int t, float refpos);
|
|||
float get_trace_scale(int t);
|
||||
float get_trace_refpos(int t);
|
||||
const char *get_trace_typename(int t);
|
||||
void draw_battery_status(void);
|
||||
|
||||
void set_electrical_delay(float picoseconds);
|
||||
float get_electrical_delay(void);
|
||||
|
|
@ -231,6 +232,7 @@ void marker_position(int m, int t, int *x, int *y);
|
|||
int search_nearest_index(int x, int y, int t);
|
||||
|
||||
extern int8_t redraw_requested;
|
||||
extern int16_t vbat;
|
||||
|
||||
/*
|
||||
* ili9341.c
|
||||
|
|
@ -314,6 +316,8 @@ int config_recall(void);
|
|||
|
||||
void clear_all_config_prop_data(void);
|
||||
|
||||
int16_t adc_vbat_read(ADC_TypeDef *adc);
|
||||
|
||||
/*
|
||||
* ui.c
|
||||
*/
|
||||
|
|
@ -351,10 +355,21 @@ uint16_t adc_single_read(ADC_TypeDef *adc, uint32_t chsel);
|
|||
void adc_start_analog_watchdogd(ADC_TypeDef *adc, uint32_t chsel);
|
||||
void adc_stop(ADC_TypeDef *adc);
|
||||
void adc_interrupt(ADC_TypeDef *adc);
|
||||
int16_t adc_vbat_read(ADC_TypeDef *adc);
|
||||
|
||||
/*
|
||||
* misclinous
|
||||
*/
|
||||
#define PULSE do { palClearPad(GPIOC, GPIOC_LED); palSetPad(GPIOC, GPIOC_LED);} while(0)
|
||||
|
||||
// convert vbat [mV] to battery indicator
|
||||
static inline uint8_t vbat2bati(int16_t vbat)
|
||||
{
|
||||
if (vbat < 3200) return 0;
|
||||
if (vbat < 3450) return 25;
|
||||
if (vbat < 3700) return 50;
|
||||
if (vbat < 4100) return 75;
|
||||
return 100;
|
||||
}
|
||||
|
||||
/*EOF*/
|
||||
|
|
|
|||
70
plot.c
70
plot.c
|
|
@ -1497,6 +1497,76 @@ draw_cal_status(void)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
draw_battery_status(void)
|
||||
{
|
||||
int w = 10, h = 14;
|
||||
int x = 0, y = 0;
|
||||
int i, c;
|
||||
uint16_t *buf = spi_buffer;
|
||||
uint8_t vbati = vbat2bati(vbat);
|
||||
uint16_t col = vbati == 0 ? RGB565(0, 255, 0) : RGB565(0, 0, 240);
|
||||
memset(spi_buffer, 0, w * h * 2);
|
||||
|
||||
// battery head
|
||||
x = 3;
|
||||
buf[y * w + x++] = col;
|
||||
buf[y * w + x++] = col;
|
||||
buf[y * w + x++] = col;
|
||||
buf[y * w + x++] = col;
|
||||
|
||||
y++;
|
||||
x = 3;
|
||||
buf[y * w + x++] = col;
|
||||
x++; x++;
|
||||
buf[y * w + x++] = col;
|
||||
|
||||
y++;
|
||||
x = 1;
|
||||
for (i = 0; i < 8; i++)
|
||||
buf[y * w + x++] = col;
|
||||
|
||||
for (c = 0; c < 3; c++) {
|
||||
y++;
|
||||
x = 1;
|
||||
buf[y * w + x++] = col;
|
||||
x++; x++; x++; x++; x++; x++;
|
||||
buf[y * w + x++] = col;
|
||||
|
||||
y++;
|
||||
x = 1;
|
||||
buf[y * w + x++] = col;
|
||||
x++;
|
||||
for (i = 0; i < 4; i++)
|
||||
buf[y * w + x++] = ( ((c+1) * 25) >= (100 - vbati)) ? col : 0;
|
||||
x++;
|
||||
buf[y * w + x++] = col;
|
||||
|
||||
y++;
|
||||
x = 1;
|
||||
buf[y * w + x++] = col;
|
||||
x++;
|
||||
for (i = 0; i < 4; i++)
|
||||
buf[y * w + x++] = ( ((c+1) * 25) >= (100 - vbati)) ? col : 0;
|
||||
x++;
|
||||
buf[y * w + x++] = col;
|
||||
}
|
||||
|
||||
// battery foot
|
||||
y++;
|
||||
x = 1;
|
||||
buf[y * w + x++] = col;
|
||||
x++; x++; x++; x++; x++; x++;
|
||||
buf[y * w + x++] = col;
|
||||
|
||||
y++;
|
||||
x = 1;
|
||||
for (i = 0; i < 8; i++)
|
||||
buf[y * w + x++] = col;
|
||||
|
||||
ili9341_bulk(0, 1, w, h);
|
||||
}
|
||||
|
||||
void
|
||||
request_to_redraw_grid(void)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue