mirror of
https://github.com/ttrftech/NanoVNA.git
synced 2025-12-06 03:31:59 +01:00
style: uniform code style and untabify
This commit is contained in:
parent
a4821604a5
commit
0d407577f8
156
.clang-format
Normal file
156
.clang-format
Normal file
|
|
@ -0,0 +1,156 @@
|
|||
---
|
||||
Language: Cpp
|
||||
# BasedOnStyle: Google
|
||||
AccessModifierOffset: -1
|
||||
AlignAfterOpenBracket: Align
|
||||
AlignConsecutiveAssignments: false
|
||||
AlignConsecutiveDeclarations: false
|
||||
AlignEscapedNewlines: Left
|
||||
AlignOperands: true
|
||||
AlignTrailingComments: true
|
||||
AllowAllArgumentsOnNextLine: true
|
||||
AllowAllConstructorInitializersOnNextLine: true
|
||||
AllowAllParametersOfDeclarationOnNextLine: true
|
||||
AllowShortBlocksOnASingleLine: false
|
||||
AllowShortCaseLabelsOnASingleLine: false
|
||||
AllowShortFunctionsOnASingleLine: All
|
||||
AllowShortLambdasOnASingleLine: All
|
||||
AllowShortIfStatementsOnASingleLine: WithoutElse
|
||||
AllowShortLoopsOnASingleLine: true
|
||||
AlwaysBreakAfterDefinitionReturnType: None
|
||||
AlwaysBreakAfterReturnType: None
|
||||
AlwaysBreakBeforeMultilineStrings: true
|
||||
AlwaysBreakTemplateDeclarations: Yes
|
||||
BinPackArguments: true
|
||||
BinPackParameters: true
|
||||
BraceWrapping:
|
||||
AfterCaseLabel: false
|
||||
AfterClass: true
|
||||
AfterControlStatement: false
|
||||
AfterEnum: false
|
||||
AfterFunction: true
|
||||
AfterNamespace: false
|
||||
AfterObjCDeclaration: false
|
||||
AfterStruct: false
|
||||
AfterUnion: false
|
||||
AfterExternBlock: false
|
||||
BeforeCatch: false
|
||||
BeforeElse: false
|
||||
IndentBraces: false
|
||||
SplitEmptyFunction: true
|
||||
SplitEmptyRecord: true
|
||||
SplitEmptyNamespace: true
|
||||
BreakBeforeBinaryOperators: None
|
||||
BreakBeforeBraces: Attach
|
||||
BreakBeforeInheritanceComma: false
|
||||
BreakInheritanceList: BeforeColon
|
||||
BreakBeforeTernaryOperators: true
|
||||
BreakConstructorInitializersBeforeComma: false
|
||||
BreakConstructorInitializers: BeforeColon
|
||||
BreakAfterJavaFieldAnnotations: false
|
||||
BreakStringLiterals: true
|
||||
ColumnLimit: 90
|
||||
CommentPragmas: '^ IWYU pragma:'
|
||||
CompactNamespaces: false
|
||||
ConstructorInitializerAllOnOneLineOrOnePerLine: true
|
||||
ConstructorInitializerIndentWidth: 4
|
||||
ContinuationIndentWidth: 4
|
||||
Cpp11BracedListStyle: true
|
||||
DerivePointerAlignment: true
|
||||
DisableFormat: false
|
||||
ExperimentalAutoDetectBinPacking: false
|
||||
FixNamespaceComments: true
|
||||
ForEachMacros:
|
||||
- foreach
|
||||
- Q_FOREACH
|
||||
- BOOST_FOREACH
|
||||
IncludeBlocks: Regroup
|
||||
IncludeCategories:
|
||||
- Regex: '^<ext/.*\.h>'
|
||||
Priority: 2
|
||||
- Regex: '^<.*\.h>'
|
||||
Priority: 1
|
||||
- Regex: '^<.*'
|
||||
Priority: 2
|
||||
- Regex: '.*'
|
||||
Priority: 3
|
||||
IncludeIsMainRegex: '([-_](test|unittest))?$'
|
||||
IndentCaseLabels: true
|
||||
IndentPPDirectives: None
|
||||
IndentWidth: 2
|
||||
IndentWrappedFunctionNames: false
|
||||
JavaScriptQuotes: Leave
|
||||
JavaScriptWrapImports: true
|
||||
KeepEmptyLinesAtTheStartOfBlocks: false
|
||||
MacroBlockBegin: ''
|
||||
MacroBlockEnd: ''
|
||||
MaxEmptyLinesToKeep: 1
|
||||
NamespaceIndentation: None
|
||||
ObjCBinPackProtocolList: Never
|
||||
ObjCBlockIndentWidth: 2
|
||||
ObjCSpaceAfterProperty: false
|
||||
ObjCSpaceBeforeProtocolList: true
|
||||
PenaltyBreakAssignment: 2
|
||||
PenaltyBreakBeforeFirstCallParameter: 1
|
||||
PenaltyBreakComment: 300
|
||||
PenaltyBreakFirstLessLess: 120
|
||||
PenaltyBreakString: 1000
|
||||
PenaltyBreakTemplateDeclaration: 10
|
||||
PenaltyExcessCharacter: 1000000
|
||||
PenaltyReturnTypeOnItsOwnLine: 200
|
||||
PointerAlignment: Left
|
||||
RawStringFormats:
|
||||
- Language: Cpp
|
||||
Delimiters:
|
||||
- cc
|
||||
- CC
|
||||
- cpp
|
||||
- Cpp
|
||||
- CPP
|
||||
- 'c++'
|
||||
- 'C++'
|
||||
CanonicalDelimiter: ''
|
||||
BasedOnStyle: google
|
||||
- Language: TextProto
|
||||
Delimiters:
|
||||
- pb
|
||||
- PB
|
||||
- proto
|
||||
- PROTO
|
||||
EnclosingFunctions:
|
||||
- EqualsProto
|
||||
- EquivToProto
|
||||
- PARSE_PARTIAL_TEXT_PROTO
|
||||
- PARSE_TEST_PROTO
|
||||
- PARSE_TEXT_PROTO
|
||||
- ParseTextOrDie
|
||||
- ParseTextProtoOrDie
|
||||
CanonicalDelimiter: ''
|
||||
BasedOnStyle: google
|
||||
ReflowComments: true
|
||||
SortIncludes: true
|
||||
SortUsingDeclarations: true
|
||||
SpaceAfterCStyleCast: false
|
||||
SpaceAfterLogicalNot: false
|
||||
SpaceAfterTemplateKeyword: true
|
||||
SpaceBeforeAssignmentOperators: true
|
||||
SpaceBeforeCpp11BracedList: false
|
||||
SpaceBeforeCtorInitializerColon: true
|
||||
SpaceBeforeInheritanceColon: true
|
||||
SpaceBeforeParens: ControlStatements
|
||||
SpaceBeforeRangeBasedForLoopColon: true
|
||||
SpaceInEmptyParentheses: false
|
||||
SpacesBeforeTrailingComments: 2
|
||||
SpacesInAngles: false
|
||||
SpacesInContainerLiterals: true
|
||||
SpacesInCStyleCastParentheses: false
|
||||
SpacesInParentheses: false
|
||||
SpacesInSquareBrackets: false
|
||||
Standard: Auto
|
||||
StatementMacros:
|
||||
- Q_UNUSED
|
||||
- QT_REQUIRE_VERSION
|
||||
TabWidth: 4
|
||||
UseTab: Never
|
||||
...
|
||||
|
||||
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
|
|
@ -1,3 +1,4 @@
|
|||
{
|
||||
"C_Cpp.errorSquiggles": "Disabled"
|
||||
"C_Cpp.errorSquiggles": "Disabled",
|
||||
"cpplint.filters": ["-build/include_subdir", "-build/include_order", "-readability/casting", "-whitespace/comments"]
|
||||
}
|
||||
23
chprintf.c
23
chprintf.c
|
|
@ -83,7 +83,9 @@ static char *long_to_string_with_divisor(char *p,
|
|||
#define FREQ_NO_SPACE 2
|
||||
#define FREQ_PREFIX_SPACE 4
|
||||
|
||||
static char *ulong_freq(char *p, uint32_t freq, uint32_t precision){
|
||||
static char *
|
||||
ulong_freq(char *p, uint32_t freq, uint32_t precision)
|
||||
{
|
||||
uint8_t flag = FREQ_PSET;
|
||||
if (precision == 0)
|
||||
flag|=FREQ_PREFIX_SPACE;
|
||||
|
|
@ -108,16 +110,22 @@ static char *ulong_freq(char *p, uint32_t freq, uint32_t precision){
|
|||
freq += freq >> 1;
|
||||
freq += freq >> 4;
|
||||
freq += freq >> 8;
|
||||
freq+=freq>>16; // freq = 858993459*freq/1073741824 = freq * 0,799999999813735485076904296875
|
||||
freq += freq >> 16; // freq = 858993459*freq/1073741824 = freq *
|
||||
// 0,799999999813735485076904296875
|
||||
freq >>= 3; // freq/=8; freq = freq * 0,09999999997671693563461303710938
|
||||
c -= freq * 10; // freq*10 = (freq*4+freq)*2 = ((freq<<2)+freq)<<1
|
||||
while (c>=10) {freq++;c-=10;}
|
||||
while (c >= 10) {
|
||||
freq++;
|
||||
c -= 10;
|
||||
}
|
||||
#endif
|
||||
*--q = c + '0';
|
||||
if (freq==0)
|
||||
break;
|
||||
if (freq == 0) break;
|
||||
// Add spaces, calculate prefix
|
||||
if (format&1) {*--q = ' '; s++;}
|
||||
if (format & 1) {
|
||||
*--q = ' ';
|
||||
s++;
|
||||
}
|
||||
format >>= 1;
|
||||
} while (1);
|
||||
s = bigPrefix[s];
|
||||
|
|
@ -138,8 +146,7 @@ static char *ulong_freq(char *p, uint32_t freq, uint32_t precision){
|
|||
if (flag & FREQ_PSET) {
|
||||
c = '.';
|
||||
flag &= ~FREQ_PSET;
|
||||
}
|
||||
else if (flag&FREQ_NO_SPACE)
|
||||
} else if (flag & FREQ_NO_SPACE)
|
||||
c = *q++;
|
||||
}
|
||||
*p++ = c;
|
||||
|
|
|
|||
5
flash.c
5
flash.c
|
|
@ -141,7 +141,8 @@ caldata_save(int id)
|
|||
dst = (uint16_t*)saveareas[id];
|
||||
|
||||
current_props.magic = CONFIG_MAGIC;
|
||||
current_props.checksum = checksum(¤t_props, sizeof current_props - sizeof current_props.checksum);
|
||||
current_props.checksum = checksum(
|
||||
¤t_props, sizeof current_props - sizeof current_props.checksum);
|
||||
|
||||
flash_unlock();
|
||||
|
||||
|
|
@ -191,7 +192,7 @@ caldata_recall(int id)
|
|||
memcpy(dst, src, sizeof(properties_t));
|
||||
return 0;
|
||||
load_default:
|
||||
loadDefaultProps();
|
||||
load_default_properties();
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
|||
84
ili9341.c
84
ili9341.c
|
|
@ -129,7 +129,8 @@ uint16_t background_color=0;
|
|||
#define DISPLAY_ROTATION_270 (ILI9341_MADCTL_MX | ILI9341_MADCTL_BGR)
|
||||
#define DISPLAY_ROTATION_90 (ILI9341_MADCTL_MY | ILI9341_MADCTL_BGR)
|
||||
#define DISPLAY_ROTATION_0 (ILI9341_MADCTL_MV | ILI9341_MADCTL_BGR)
|
||||
#define DISPLAY_ROTATION_180 (ILI9341_MADCTL_MX | ILI9341_MADCTL_MY | ILI9341_MADCTL_MV | ILI9341_MADCTL_BGR)
|
||||
#define DISPLAY_ROTATION_180 (ILI9341_MADCTL_MX | ILI9341_MADCTL_MY \
|
||||
| ILI9341_MADCTL_MV | ILI9341_MADCTL_BGR)
|
||||
|
||||
//
|
||||
// Pin macros
|
||||
|
|
@ -179,14 +180,17 @@ uint16_t background_color=0;
|
|||
#define SPI_READ_DATA SPI1->DR
|
||||
|
||||
#ifdef __USE_DISPLAY_DMA__
|
||||
static const stm32_dma_stream_t *dmatx = STM32_DMA_STREAM(STM32_SPI_SPI1_TX_DMA_STREAM);
|
||||
static uint32_t txdmamode = STM32_DMA_CR_CHSEL(SPI1_TX_DMA_CHANNEL) // Select SPI1 Tx DMA
|
||||
static const stm32_dma_stream_t *dmatx =
|
||||
STM32_DMA_STREAM(STM32_SPI_SPI1_TX_DMA_STREAM);
|
||||
static uint32_t txdmamode =
|
||||
STM32_DMA_CR_CHSEL(SPI1_TX_DMA_CHANNEL) // Select SPI1 Tx DMA
|
||||
| STM32_DMA_CR_PL(STM32_SPI_SPI1_DMA_PRIORITY) // Set priority
|
||||
| STM32_DMA_CR_DIR_M2P // Memory to Spi
|
||||
| STM32_DMA_CR_DMEIE //
|
||||
| STM32_DMA_CR_TEIE;
|
||||
|
||||
static void spi_lld_serve_tx_interrupt(SPIDriver *spip, uint32_t flags) {
|
||||
static void spi_lld_serve_tx_interrupt(SPIDriver *spip, uint32_t flags)
|
||||
{
|
||||
(void)spip;
|
||||
(void)flags;
|
||||
}
|
||||
|
|
@ -199,12 +203,14 @@ static uint32_t rxdmamode = STM32_DMA_CR_CHSEL(SPI1_RX_DMA_CHANNEL)
|
|||
| STM32_DMA_CR_DMEIE
|
||||
| STM32_DMA_CR_TEIE;
|
||||
|
||||
static void spi_lld_serve_rx_interrupt(SPIDriver *spip, uint32_t flags) {
|
||||
static void spi_lld_serve_rx_interrupt(SPIDriver *spip, uint32_t flags)
|
||||
{
|
||||
(void)spip;
|
||||
(void)flags;
|
||||
}
|
||||
|
||||
static void dmaStreamFlush(uint32_t len){
|
||||
static void dmaStreamFlush(uint32_t len)
|
||||
{
|
||||
while (len) {
|
||||
// DMA data transfer limited by 65535
|
||||
uint16_t tx_size = len > 65535 ? 65535 : len;
|
||||
|
|
@ -251,11 +257,13 @@ static void __attribute__ ((noinline)) send_command(uint8_t cmd, uint8_t len, co
|
|||
DC_CMD;
|
||||
SPI_WRITE_8BIT(cmd);
|
||||
// Need wait transfer complete and set data bit
|
||||
while (SPI_IS_BUSY);
|
||||
while (SPI_IS_BUSY)
|
||||
;
|
||||
// Send command data (if need)
|
||||
DC_DATA;
|
||||
while (len-- > 0) {
|
||||
while (SPI_TX_IS_NOT_EMPTY);
|
||||
while (SPI_TX_IS_NOT_EMPTY)
|
||||
;
|
||||
SPI_WRITE_8BIT(*data++);
|
||||
}
|
||||
//CS_HIGH;
|
||||
|
|
@ -352,7 +360,8 @@ void ili9341_fill(int x, int y, int w, int h, int color)
|
|||
send_command(ILI9341_MEMORY_WRITE, 0, NULL);
|
||||
int32_t len = w * h;
|
||||
while (len-- > 0) {
|
||||
while (SPI_TX_IS_NOT_EMPTY);
|
||||
while (SPI_TX_IS_NOT_EMPTY)
|
||||
;
|
||||
SPI_WRITE_16BIT(color);
|
||||
}
|
||||
}
|
||||
|
|
@ -369,7 +378,8 @@ void ili9341_bulk(int x, int y, int w, int h)
|
|||
send_command(ILI9341_MEMORY_WRITE, 0, NULL);
|
||||
int32_t len = w * h;
|
||||
while (len-- > 0) {
|
||||
while (SPI_TX_IS_NOT_EMPTY);
|
||||
while (SPI_TX_IS_NOT_EMPTY)
|
||||
;
|
||||
SPI_WRITE_16BIT(*buf++);
|
||||
}
|
||||
}
|
||||
|
|
@ -426,7 +436,8 @@ void ili9341_fill(int x, int y, int w, int h, int color)
|
|||
dmaStreamFlush(w * h);
|
||||
}
|
||||
|
||||
void ili9341_bulk_8bit(int x, int y, int w, int h, uint16_t *palette){
|
||||
void ili9341_bulk_8bit(int x, int y, int w, int h, uint16_t *palette)
|
||||
{
|
||||
uint32_t xx = __REV16(x | ((x + w - 1) << 16));
|
||||
uint32_t yy = __REV16(y | ((y + h - 1) << 16));
|
||||
send_command(ILI9341_COLUMN_ADDRESS_SET, 4, (uint8_t *)&xx);
|
||||
|
|
@ -437,7 +448,8 @@ void ili9341_bulk_8bit(int x, int y, int w, int h, uint16_t *palette){
|
|||
int32_t len = w * h;
|
||||
while (len-- > 0) {
|
||||
uint16_t color = palette[*buf++];
|
||||
while (SPI_TX_IS_NOT_EMPTY);
|
||||
while (SPI_TX_IS_NOT_EMPTY)
|
||||
;
|
||||
SPI_WRITE_16BIT(color);
|
||||
}
|
||||
}
|
||||
|
|
@ -453,7 +465,8 @@ void ili9341_bulk(int x, int y, int w, int h)
|
|||
|
||||
// Init Tx DMA mem->spi, set size, mode (spi and mem data size is 16 bit)
|
||||
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 |
|
||||
STM32_DMA_CR_MSIZE_HWORD | STM32_DMA_CR_MINC);
|
||||
dmaStreamFlush(w * h);
|
||||
}
|
||||
|
||||
|
|
@ -470,12 +483,12 @@ void ili9341_read_memory(int x, int y, int w, int h, int len, uint16_t *out)
|
|||
send_command(ILI9341_PAGE_ADDRESS_SET, 4, (uint8_t *)&yy);
|
||||
send_command(ILI9341_MEMORY_READ, 0, NULL);
|
||||
// Skip SPI rx buffer
|
||||
while (SPI_RX_IS_NOT_EMPTY)
|
||||
(void) SPI_READ_DATA;
|
||||
while (SPI_RX_IS_NOT_EMPTY) (void)SPI_READ_DATA;
|
||||
// Init Rx DMA buffer, size, mode (spi and mem data size is 8 bit)
|
||||
dmaStreamSetMemory0(dmarx, rgbbuf);
|
||||
dmaStreamSetTransactionSize(dmarx, data_size);
|
||||
dmaStreamSetMode(dmarx, rxdmamode | STM32_DMA_CR_PSIZE_BYTE | STM32_DMA_CR_MSIZE_BYTE | STM32_DMA_CR_MINC);
|
||||
dmaStreamSetMode(dmarx, rxdmamode | STM32_DMA_CR_PSIZE_BYTE | STM32_DMA_CR_MSIZE_BYTE |
|
||||
STM32_DMA_CR_MINC);
|
||||
// Init dummy Tx DMA (for rx clock), size, mode (spi and mem data size is 8 bit)
|
||||
dmaStreamSetMemory0(dmatx, &dummy_tx);
|
||||
dmaStreamSetTransactionSize(dmatx, data_size);
|
||||
|
|
@ -504,19 +517,31 @@ void ili9341_read_memory(int x, int y, int w, int h, int len, uint16_t *out)
|
|||
}
|
||||
#endif
|
||||
|
||||
void clearScreen(void){
|
||||
void ili9341_clear_screen(void)
|
||||
{
|
||||
ili9341_fill(0, 0, ILI9341_WIDTH, ILI9341_HEIGHT, background_color);
|
||||
}
|
||||
|
||||
void setForegroundColor(uint16_t fg) {foreground_color = fg;}
|
||||
void setBackgroundColor(uint16_t bg) {background_color = bg;}
|
||||
void ili9341_set_foreground(uint16_t fg)
|
||||
{
|
||||
foreground_color = fg;
|
||||
}
|
||||
|
||||
void ili9341_setRotation(uint8_t r) {
|
||||
// static const uint8_t rotation_const[]={DISPLAY_ROTATION_0, DISPLAY_ROTATION_90, DISPLAY_ROTATION_180, DISPLAY_ROTATION_270};
|
||||
void ili9341_set_background(uint16_t bg)
|
||||
{
|
||||
background_color = bg;
|
||||
}
|
||||
|
||||
void ili9341_set_rotation(uint8_t r)
|
||||
{
|
||||
// static const uint8_t rotation_const[]={DISPLAY_ROTATION_0, DISPLAY_ROTATION_90,
|
||||
// DISPLAY_ROTATION_180, DISPLAY_ROTATION_270};
|
||||
send_command(ILI9341_MEMORY_ACCESS_CONTROL, 1, &r);
|
||||
}
|
||||
|
||||
void blit8BitWidthBitmap(uint16_t x, uint16_t y, uint16_t width, uint16_t height, const uint8_t *bitmap){
|
||||
void blit8BitWidthBitmap(uint16_t x, uint16_t y, uint16_t width, uint16_t height,
|
||||
const uint8_t *bitmap)
|
||||
{
|
||||
uint16_t *buf = spi_buffer;
|
||||
for (uint16_t c = 0; c < height; c++) {
|
||||
uint8_t bits = *bitmap++;
|
||||
|
|
@ -528,7 +553,9 @@ void blit8BitWidthBitmap(uint16_t x, uint16_t y, uint16_t width, uint16_t height
|
|||
ili9341_bulk(x, y, width, height);
|
||||
}
|
||||
|
||||
void blit16BitWidthBitmap(uint16_t x, uint16_t y, uint16_t width, uint16_t height, const uint16_t *bitmap){
|
||||
static 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++;
|
||||
|
|
@ -556,10 +583,11 @@ void ili9341_drawstring(const char *str, int x, int y)
|
|||
}
|
||||
}
|
||||
|
||||
void ili9341_drawstringV(const char *str, int x, int y){
|
||||
ili9341_setRotation(DISPLAY_ROTATION_270);
|
||||
void ili9341_drawstringV(const char *str, int x, int y)
|
||||
{
|
||||
ili9341_set_rotation(DISPLAY_ROTATION_270);
|
||||
ili9341_drawstring(str, ILI9341_HEIGHT-y, x);
|
||||
ili9341_setRotation(DISPLAY_ROTATION_0);
|
||||
ili9341_set_rotation(DISPLAY_ROTATION_0);
|
||||
}
|
||||
|
||||
int ili9341_drawchar_size(uint8_t ch, int x, int y, uint8_t size)
|
||||
|
|
@ -581,7 +609,8 @@ int ili9341_drawchar_size(uint8_t ch, int x, int y, uint8_t size)
|
|||
|
||||
void ili9341_drawfont(uint8_t ch, int x, int y)
|
||||
{
|
||||
blit16BitWidthBitmap(x, y, NUM_FONT_GET_WIDTH, NUM_FONT_GET_HEIGHT, NUM_FONT_GET_DATA(ch));
|
||||
blit16BitWidthBitmap(x, y, NUM_FONT_GET_WIDTH, NUM_FONT_GET_HEIGHT,
|
||||
NUM_FONT_GET_DATA(ch));
|
||||
}
|
||||
|
||||
void ili9341_drawstring_size(const char *str, int x, int y, uint8_t size)
|
||||
|
|
@ -601,6 +630,7 @@ static void ili9341_pixel(int x, int y, uint16_t color)
|
|||
#endif
|
||||
|
||||
#define SWAP(x, y) { int z = x; x = y; y = z; }
|
||||
|
||||
void ili9341_line(int x0, int y0, int x1, int y1)
|
||||
{
|
||||
#if 0
|
||||
|
|
|
|||
207
main.c
207
main.c
|
|
@ -26,15 +26,14 @@
|
|||
#include "fft.h"
|
||||
|
||||
#include <chprintf.h>
|
||||
//#include <stdlib.h>
|
||||
#include <string.h>
|
||||
//#include <ctype.h>
|
||||
#include <math.h>
|
||||
|
||||
/*
|
||||
* Shell settings
|
||||
*/
|
||||
// If need run shell as thread (use more amount of memory fore stack), after enable this need reduce spi_buffer size, by default shell run in main thread
|
||||
// If need run shell as thread (use more amount of memory fore stack), after
|
||||
// enable this need reduce spi_buffer size, by default shell run in main thread
|
||||
// #define VNA_SHELL_THREAD
|
||||
|
||||
static BaseSequentialStream *shell_stream = (BaseSequentialStream *)&SDU1;
|
||||
|
|
@ -47,9 +46,11 @@ static BaseSequentialStream *shell_stream = (BaseSequentialStream *)&SDU1;
|
|||
#define VNA_SHELL_MAX_ARGUMENTS 4
|
||||
// Shell max command line size
|
||||
#define VNA_SHELL_MAX_LENGTH 48
|
||||
|
||||
// Shell command functions prototypes
|
||||
typedef void (*vna_shellcmd_t)(int argc, char *argv[]);
|
||||
#define VNA_SHELL_FUNCTION(command_name) static void command_name(int argc, char *argv[])
|
||||
#define VNA_SHELL_FUNCTION(command_name) \
|
||||
static void command_name(int argc, char *argv[])
|
||||
|
||||
// Shell command line buffer, args, nargs, and function ptr
|
||||
static char shell_line[VNA_SHELL_MAX_LENGTH];
|
||||
|
|
@ -125,10 +126,10 @@ static THD_FUNCTION(Thread1, arg)
|
|||
}
|
||||
// Process UI inputs
|
||||
ui_process();
|
||||
// Process collected data, calculate trace coordinates and plot only if scan completed
|
||||
// Process collected data, calculate trace coordinates and plot only if scan
|
||||
// completed
|
||||
if (sweep_mode & SWEEP_ENABLE && completed) {
|
||||
if ((domain_mode & DOMAIN_MODE) == DOMAIN_TIME)
|
||||
transform_domain();
|
||||
if ((domain_mode & DOMAIN_MODE) == DOMAIN_TIME) transform_domain();
|
||||
// Prepare draw graphics, cache all lines, mark screen cells for redraw
|
||||
plot_into_index(measured);
|
||||
redraw_request |= REDRAW_CELLS | REDRAW_BATTERY;
|
||||
|
|
@ -142,7 +143,8 @@ static THD_FUNCTION(Thread1, arg)
|
|||
}
|
||||
}
|
||||
// plot trace and other indications as raster
|
||||
draw_all(completed); // flush markmap only if scan completed to prevent remaining traces
|
||||
draw_all(completed); // flush markmap only if scan completed to prevent
|
||||
// remaining traces
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -165,7 +167,8 @@ toggle_sweep(void)
|
|||
}
|
||||
|
||||
static float
|
||||
bessel0(float x) {
|
||||
bessel0(float x)
|
||||
{
|
||||
const float eps = 0.0001;
|
||||
|
||||
float ret = 0;
|
||||
|
|
@ -181,7 +184,8 @@ bessel0(float x) {
|
|||
}
|
||||
|
||||
static float
|
||||
kaiser_window(float k, float n, float beta) {
|
||||
kaiser_window(float k, float n, float beta)
|
||||
{
|
||||
if (beta == 0.0) return 1.0;
|
||||
float r = (2 * k) / (n - 1) - 1;
|
||||
return bessel0(beta * sqrt(1 - r * r)) / bessel0(beta);
|
||||
|
|
@ -222,7 +226,6 @@ transform_domain(void)
|
|||
break;
|
||||
}
|
||||
|
||||
|
||||
for (int ch = 0; ch < 2; ch++) {
|
||||
memcpy(tmp, measured[ch], sizeof(measured[0]));
|
||||
for (int i = 0; i < POINTS_COUNT; i++) {
|
||||
|
|
@ -260,7 +263,8 @@ transform_domain(void)
|
|||
}
|
||||
|
||||
// Shell commands output
|
||||
static int shell_printf(const char *fmt, ...) {
|
||||
static int shell_printf(const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
int formatted_bytes;
|
||||
va_start(ap, fmt);
|
||||
|
|
@ -330,7 +334,7 @@ static int
|
|||
adjust_gain(uint32_t newfreq)
|
||||
{
|
||||
int new_order = newfreq / FREQ_HARMONICS;
|
||||
int old_order = si5351_getFrequency() / FREQ_HARMONICS;
|
||||
int old_order = si5351_get_frequency() / FREQ_HARMONICS;
|
||||
if (new_order != old_order) {
|
||||
tlv320aic3204_set_gain(gain_table[new_order], gain_table[new_order]);
|
||||
return DELAY_GAIN_CHANGE;
|
||||
|
|
@ -345,7 +349,7 @@ int set_frequency(uint32_t freq)
|
|||
if (ds == DRIVE_STRENGTH_AUTO) {
|
||||
ds = freq > FREQ_HARMONICS ? SI5351_CLK_DRIVE_STRENGTH_8MA : SI5351_CLK_DRIVE_STRENGTH_2MA;
|
||||
}
|
||||
delay += si5351_set_frequency_with_offset(freq, ds);
|
||||
delay += si5351_set_frequency(freq, ds);
|
||||
return delay;
|
||||
}
|
||||
|
||||
|
|
@ -354,7 +358,8 @@ int set_frequency(uint32_t freq)
|
|||
// Rewrite universal standart str to value functions to more compact
|
||||
//
|
||||
// Convert string to int32
|
||||
static int32_t my_atoi(const char *p){
|
||||
static int32_t my_atoi(const char *p)
|
||||
{
|
||||
int32_t value = 0;
|
||||
uint32_t c;
|
||||
bool neg = false;
|
||||
|
|
@ -371,7 +376,8 @@ static int32_t my_atoi(const char *p){
|
|||
// 0o - for oct radix
|
||||
// 0b - for bin radix
|
||||
// default dec radix
|
||||
uint32_t my_atoui(const char *p) {
|
||||
uint32_t my_atoui(const char *p)
|
||||
{
|
||||
uint32_t value = 0, radix = 10, c;
|
||||
if (*p == '+') p++;
|
||||
if (*p == '0') {
|
||||
|
|
@ -435,12 +441,14 @@ my_atof(const char *p)
|
|||
// Example need search parameter "center" in "start|stop|center|span|cw" getStringIndex return 2
|
||||
// If not found return -1
|
||||
// Used for easy parse command arguments
|
||||
static int getStringIndex(char *v, const char *list){
|
||||
static int get_str_index(char *v, const char *list)
|
||||
{
|
||||
int i = 0;
|
||||
while (1) {
|
||||
char *p = v;
|
||||
while (1) {
|
||||
char c = *list; if (c == '|') c = 0;
|
||||
char c = *list;
|
||||
if (c == '|') c = 0;
|
||||
if (c == *p++) {
|
||||
// Found, return index
|
||||
if (c == 0) return i;
|
||||
|
|
@ -718,11 +726,18 @@ VNA_SHELL_FUNCTION(cmd_sample)
|
|||
if (argc != 1) goto usage;
|
||||
// 0 1 2
|
||||
static const char cmd_sample_list[] = "gamma|ampl|ref";
|
||||
switch (getStringIndex(argv[0], cmd_sample_list)){
|
||||
case 0:sample_func = calculate_gamma; return;
|
||||
case 1:sample_func = fetch_amplitude; return;
|
||||
case 2:sample_func = fetch_amplitude_ref; return;
|
||||
default:break;
|
||||
switch (get_str_index(argv[0], cmd_sample_list)) {
|
||||
case 0:
|
||||
sample_func = calculate_gamma;
|
||||
return;
|
||||
case 1:
|
||||
sample_func = fetch_amplitude;
|
||||
return;
|
||||
case 2:
|
||||
sample_func = fetch_amplitude_ref;
|
||||
return;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
usage:
|
||||
shell_printf("usage: sample {%s}\r\n", cmd_sample_list);
|
||||
|
|
@ -758,7 +773,8 @@ static const marker_t def_markers[MARKERS_MAX] = {
|
|||
};
|
||||
|
||||
// Load propeties default settings
|
||||
void loadDefaultProps(void){
|
||||
void load_default_properties(void)
|
||||
{
|
||||
//Magic add on caldata_save
|
||||
//current_props.magic = CONFIG_MAGIC;
|
||||
current_props._frequency0 = 50000; // start = 50kHz
|
||||
|
|
@ -872,18 +888,16 @@ VNA_SHELL_FUNCTION(cmd_scan)
|
|||
// Output data after if set (faster data recive)
|
||||
if (argc == 4) {
|
||||
uint16_t mask = my_atoui(argv[3]);
|
||||
if (mask)
|
||||
if (mask) {
|
||||
for (i = 0; i < points; i++) {
|
||||
if (mask&1)
|
||||
shell_printf("%u ", frequencies[i]);
|
||||
if (mask&2)
|
||||
shell_printf("%f %f ", measured[0][i][0], measured[0][i][1]);
|
||||
if (mask&4)
|
||||
shell_printf("%f %f ", measured[1][i][0], measured[1][i][1]);
|
||||
if (mask & 1) shell_printf("%u ", frequencies[i]);
|
||||
if (mask & 2) shell_printf("%f %f ", measured[0][i][0], measured[0][i][1]);
|
||||
if (mask & 4) shell_printf("%f %f ", measured[1][i][0], measured[1][i][1]);
|
||||
shell_printf("\r\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
update_marker_index(void)
|
||||
|
|
@ -969,8 +983,7 @@ set_sweep_frequency(int type, uint32_t freq)
|
|||
if (frequency0 != freq) {
|
||||
frequency0 = freq;
|
||||
// if start > stop then make start = stop
|
||||
if (frequency1 < freq)
|
||||
frequency1 = freq;
|
||||
if (frequency1 < freq) frequency1 = freq;
|
||||
}
|
||||
break;
|
||||
case ST_STOP:
|
||||
|
|
@ -978,8 +991,7 @@ set_sweep_frequency(int type, uint32_t freq)
|
|||
if (frequency1 != freq) {
|
||||
frequency1 = freq;
|
||||
// if start > stop then make start = stop
|
||||
if (frequency0 > freq)
|
||||
frequency0 = freq;
|
||||
if (frequency0 > freq) frequency0 = freq;
|
||||
}
|
||||
break;
|
||||
case ST_CENTER:
|
||||
|
|
@ -1028,7 +1040,11 @@ uint32_t
|
|||
get_sweep_frequency(int type)
|
||||
{
|
||||
// Obsolete, ensure correct start/stop, start always must be < stop
|
||||
if (frequency0>frequency1) {uint32_t t=frequency0; frequency0=frequency1; frequency1=t;}
|
||||
if (frequency0 > frequency1) {
|
||||
uint32_t t = frequency0;
|
||||
frequency0 = frequency1;
|
||||
frequency1 = t;
|
||||
}
|
||||
switch (type) {
|
||||
case ST_START: return frequency0;
|
||||
case ST_STOP: return frequency1;
|
||||
|
|
@ -1058,7 +1074,7 @@ VNA_SHELL_FUNCTION(cmd_sweep)
|
|||
// get enum ST_START, ST_STOP, ST_CENTER, ST_SPAN, ST_CW
|
||||
static const char sweep_cmd[] = "start|stop|center|span|cw";
|
||||
if (argc == 2 && value0 == 0) {
|
||||
int type = getStringIndex(argv[0], sweep_cmd);
|
||||
int type = get_str_index(argv[0], sweep_cmd);
|
||||
if (type == -1)
|
||||
goto usage;
|
||||
set_sweep_frequency(type, value1);
|
||||
|
|
@ -1415,16 +1431,34 @@ VNA_SHELL_FUNCTION(cmd_cal)
|
|||
redraw_request|=REDRAW_CAL_STATUS;
|
||||
// 0 1 2 3 4 5 6 7 8 9 10
|
||||
static const char cmd_cal_list[] = "load|open|short|thru|isoln|done|on|off|reset|data|in";
|
||||
switch (getStringIndex(argv[0], cmd_cal_list)){
|
||||
case 0:cal_collect(CAL_LOAD ); return;
|
||||
case 1:cal_collect(CAL_OPEN ); return;
|
||||
case 2:cal_collect(CAL_SHORT); return;
|
||||
case 3:cal_collect(CAL_THRU ); return;
|
||||
case 4:cal_collect(CAL_ISOLN); return;
|
||||
case 5:cal_done(); return;
|
||||
case 6:cal_status|= CALSTAT_APPLY;return;
|
||||
case 7:cal_status&=~CALSTAT_APPLY;return;
|
||||
case 8:cal_status = 0; return;
|
||||
switch (get_str_index(argv[0], cmd_cal_list)) {
|
||||
case 0:
|
||||
cal_collect(CAL_LOAD);
|
||||
return;
|
||||
case 1:
|
||||
cal_collect(CAL_OPEN);
|
||||
return;
|
||||
case 2:
|
||||
cal_collect(CAL_SHORT);
|
||||
return;
|
||||
case 3:
|
||||
cal_collect(CAL_THRU);
|
||||
return;
|
||||
case 4:
|
||||
cal_collect(CAL_ISOLN);
|
||||
return;
|
||||
case 5:
|
||||
cal_done();
|
||||
return;
|
||||
case 6:
|
||||
cal_status |= CALSTAT_APPLY;
|
||||
return;
|
||||
case 7:
|
||||
cal_status &= ~CALSTAT_APPLY;
|
||||
return;
|
||||
case 8:
|
||||
cal_status = 0;
|
||||
return;
|
||||
case 9:
|
||||
shell_printf("%f %f\r\n", cal_data[CAL_LOAD][0][0], cal_data[CAL_LOAD][0][1]);
|
||||
shell_printf("%f %f\r\n", cal_data[CAL_OPEN][0][0], cal_data[CAL_OPEN][0][1]);
|
||||
|
|
@ -1435,7 +1469,8 @@ VNA_SHELL_FUNCTION(cmd_cal)
|
|||
case 10:
|
||||
cal_interpolate((argc > 1) ? my_atoi(argv[1]) : 0);
|
||||
return;
|
||||
default:break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
shell_printf("usage: cal [%s]\r\n", cmd_cal_list);
|
||||
}
|
||||
|
|
@ -1595,7 +1630,7 @@ VNA_SHELL_FUNCTION(cmd_trace)
|
|||
#endif
|
||||
// enum TRC_LOGMAG, TRC_PHASE, TRC_DELAY, TRC_SMITH, TRC_POLAR, TRC_LINEAR, TRC_SWR, TRC_REAL, TRC_IMAG, TRC_R, TRC_X, TRC_OFF
|
||||
static const char cmd_type_list[] = "logmag|phase|delay|smith|polar|linear|swr|real|imag|r|x|off";
|
||||
int type = getStringIndex(argv[1], cmd_type_list);
|
||||
int type = get_str_index(argv[1], cmd_type_list);
|
||||
if (type >= 0) {
|
||||
set_trace_type(t, type);
|
||||
goto check_ch_num;
|
||||
|
|
@ -1603,7 +1638,7 @@ VNA_SHELL_FUNCTION(cmd_trace)
|
|||
// 0 1
|
||||
static const char cmd_scale_ref_list[] = "scale|refpos";
|
||||
if (argc >= 3) {
|
||||
switch (getStringIndex(argv[1], cmd_scale_ref_list)){
|
||||
switch (get_str_index(argv[1], cmd_scale_ref_list)) {
|
||||
case 0:
|
||||
//trace[t].scale = my_atof(argv[2]);
|
||||
set_trace_scale(t, my_atof(argv[2]));
|
||||
|
|
@ -1686,7 +1721,7 @@ VNA_SHELL_FUNCTION(cmd_marker)
|
|||
return;
|
||||
}
|
||||
static const char cmd_marker_list[] = "on|off";
|
||||
switch (getStringIndex(argv[1], cmd_marker_list)){
|
||||
switch (get_str_index(argv[1], cmd_marker_list)) {
|
||||
case 0: markers[t].enabled = TRUE; active_marker = t; return;
|
||||
case 1: markers[t].enabled =FALSE; if (active_marker == t) active_marker = -1; return;
|
||||
default:
|
||||
|
|
@ -1771,16 +1806,33 @@ VNA_SHELL_FUNCTION(cmd_transform)
|
|||
// 0 1 2 3 4 5 6 7
|
||||
static const char cmd_transform_list[] = "on|off|impulse|step|bandpass|minimum|normal|maximum";
|
||||
for (i = 0; i < argc; i++) {
|
||||
switch (getStringIndex(argv[i], cmd_transform_list)){
|
||||
case 0:set_domain_mode(DOMAIN_TIME);return;
|
||||
case 1:set_domain_mode(DOMAIN_FREQ);return;
|
||||
case 2:set_timedomain_func(TD_FUNC_LOWPASS_IMPULSE);return;
|
||||
case 3:set_timedomain_func(TD_FUNC_LOWPASS_STEP);return;
|
||||
case 4:set_timedomain_func(TD_FUNC_BANDPASS);return;
|
||||
case 5:set_timedomain_window(TD_WINDOW_MINIMUM);return;
|
||||
case 6:set_timedomain_window(TD_WINDOW_NORMAL);return;
|
||||
case 7:set_timedomain_window(TD_WINDOW_MAXIMUM);return;
|
||||
default: goto usage;
|
||||
switch (get_str_index(argv[i], cmd_transform_list)) {
|
||||
case 0:
|
||||
set_domain_mode(DOMAIN_TIME);
|
||||
return;
|
||||
case 1:
|
||||
set_domain_mode(DOMAIN_FREQ);
|
||||
return;
|
||||
case 2:
|
||||
set_timedomain_func(TD_FUNC_LOWPASS_IMPULSE);
|
||||
return;
|
||||
case 3:
|
||||
set_timedomain_func(TD_FUNC_LOWPASS_STEP);
|
||||
return;
|
||||
case 4:
|
||||
set_timedomain_func(TD_FUNC_BANDPASS);
|
||||
return;
|
||||
case 5:
|
||||
set_timedomain_window(TD_WINDOW_MINIMUM);
|
||||
return;
|
||||
case 6:
|
||||
set_timedomain_window(TD_WINDOW_NORMAL);
|
||||
return;
|
||||
case 7:
|
||||
set_timedomain_window(TD_WINDOW_MAXIMUM);
|
||||
return;
|
||||
default:
|
||||
goto usage;
|
||||
}
|
||||
}
|
||||
return;
|
||||
|
|
@ -2000,7 +2052,8 @@ VNA_SHELL_FUNCTION(cmd_color)
|
|||
#if CH_CFG_USE_REGISTRY == FALSE
|
||||
#error "Threads Requite enabled CH_CFG_USE_REGISTRY in chconf.h"
|
||||
#endif
|
||||
VNA_SHELL_FUNCTION(cmd_threads) {
|
||||
VNA_SHELL_FUNCTION(cmd_threads)
|
||||
{
|
||||
static const char *states[] = {CH_STATE_NAMES};
|
||||
thread_t *tp;
|
||||
(void)argc;
|
||||
|
|
@ -2116,7 +2169,8 @@ VNA_SHELL_FUNCTION(cmd_help)
|
|||
//
|
||||
// Read command line from shell_stream
|
||||
//
|
||||
static int VNAShell_readLine(char *line, int max_size){
|
||||
static int VNAShell_readLine(char *line, int max_size)
|
||||
{
|
||||
// Read line from input stream
|
||||
uint8_t c;
|
||||
char *ptr = line;
|
||||
|
|
@ -2154,30 +2208,31 @@ static int VNAShell_readLine(char *line, int max_size){
|
|||
//
|
||||
// Parse and run command line
|
||||
//
|
||||
static void VNAShell_executeLine(char *line){
|
||||
static void VNAShell_executeLine(char *line)
|
||||
{
|
||||
// Parse and execute line
|
||||
char *lp = line, *ep;
|
||||
shell_nargs = 0;
|
||||
while (*lp != 0) {
|
||||
// Skipping white space and tabs at string begin.
|
||||
while (*lp == ' ' || *lp == '\t') lp++;
|
||||
// If an argument starts with a double quote then its delimiter is another quote, else delimiter is white space.
|
||||
// If an argument starts with a double quote then its delimiter is another quote, else
|
||||
// delimiter is white space.
|
||||
ep = (*lp == '"') ? strpbrk(++lp, "\"") : strpbrk(lp, " \t");
|
||||
// Store in args string
|
||||
shell_args[shell_nargs++] = lp;
|
||||
// Stop, end of input string
|
||||
if ((lp = ep) == NULL)
|
||||
break;
|
||||
if ((lp = ep) == NULL) break;
|
||||
// Argument limits check
|
||||
if (shell_nargs > VNA_SHELL_MAX_ARGUMENTS) {
|
||||
shell_printf("too many arguments, max "define_to_STR(VNA_SHELL_MAX_ARGUMENTS)""VNA_SHELL_NEWLINE_STR);
|
||||
shell_printf("too many arguments, max " define_to_STR(
|
||||
VNA_SHELL_MAX_ARGUMENTS) "" VNA_SHELL_NEWLINE_STR);
|
||||
return;
|
||||
}
|
||||
// Set zero at the end of string and continue check
|
||||
*lp++ = 0;
|
||||
}
|
||||
if (shell_nargs == 0)
|
||||
return;
|
||||
if (shell_nargs == 0) return;
|
||||
// Execute line
|
||||
const VNAShellCommand *scp;
|
||||
for (scp = commands; scp->sc_name != NULL; scp++) {
|
||||
|
|
@ -2188,9 +2243,9 @@ static void VNAShell_executeLine(char *line){
|
|||
do {
|
||||
osalThreadSleepMilliseconds(100);
|
||||
} while (shell_function);
|
||||
}
|
||||
else
|
||||
} else {
|
||||
scp->sc_function(shell_nargs - 1, &shell_args[1]);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -2199,7 +2254,8 @@ static void VNAShell_executeLine(char *line){
|
|||
|
||||
#ifdef VNA_SHELL_THREAD
|
||||
static THD_WORKING_AREA(waThread2, /* cmd_* max stack size + alpha */442);
|
||||
THD_FUNCTION(myshellThread, p) {
|
||||
THD_FUNCTION(myshellThread, p)
|
||||
{
|
||||
(void)p;
|
||||
chRegSetThreadName("shell");
|
||||
shell_printf(VNA_SHELL_NEWLINE_STR"NanoVNA Shell"VNA_SHELL_NEWLINE_STR);
|
||||
|
|
@ -2343,7 +2399,7 @@ int main(void)
|
|||
assembly function. */
|
||||
void HardFault_Handler(void);
|
||||
|
||||
void hard_fault_handler_c(uint32_t *sp) __attribute__( ( naked ) );;
|
||||
void hard_fault_handler_c(uint32_t *sp) __attribute__((naked));
|
||||
|
||||
void HardFault_Handler(void)
|
||||
{
|
||||
|
|
@ -2356,5 +2412,6 @@ void HardFault_Handler(void)
|
|||
void hard_fault_handler_c(uint32_t *sp)
|
||||
{
|
||||
(void)sp;
|
||||
while (true) {}
|
||||
while (true) {
|
||||
}
|
||||
}
|
||||
|
|
|
|||
10
nanovna.h
10
nanovna.h
|
|
@ -93,7 +93,7 @@ uint32_t get_sweep_frequency(int type);
|
|||
double my_atof(const char *p);
|
||||
|
||||
void toggle_sweep(void);
|
||||
void loadDefaultProps(void);
|
||||
void load_default_properties(void);
|
||||
|
||||
#define SWEEP_ENABLE 0x01
|
||||
#define SWEEP_ONCE 0x02
|
||||
|
|
@ -328,15 +328,13 @@ extern uint16_t background_color;
|
|||
extern uint16_t spi_buffer[SPI_BUFFER_SIZE];
|
||||
|
||||
void ili9341_init(void);
|
||||
//void ili9341_setRotation(uint8_t r);
|
||||
void ili9341_test(int mode);
|
||||
void ili9341_bulk(int x, int y, int w, int h);
|
||||
void ili9341_fill(int x, int y, int w, int h, int color);
|
||||
void setForegroundColor(uint16_t fg);
|
||||
void setBackgroundColor(uint16_t fg);
|
||||
void clearScreen(void);
|
||||
void ili9341_set_foreground(uint16_t fg);
|
||||
void ili9341_set_background(uint16_t fg);
|
||||
void ili9341_clear_screen(void);
|
||||
void blit8BitWidthBitmap(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_drawstring(const char *str, int x, int y);
|
||||
void ili9341_drawstringV(const char *str, int x, int y);
|
||||
|
|
|
|||
|
|
@ -553,4 +553,3 @@ const uint16_t numfont16x22[] = {
|
|||
0b1111000000000000,
|
||||
0b1111000000000000,
|
||||
};
|
||||
|
||||
|
|
|
|||
184
plot.c
184
plot.c
|
|
@ -1,3 +1,23 @@
|
|||
/*
|
||||
* Copyright (c) 2014-2015, TAKAHASHI Tomohiro (TTRFTECH) edy555@gmail.com
|
||||
* All rights reserved.
|
||||
*
|
||||
* This is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* The software is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with GNU Radio; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
#include "ch.h"
|
||||
|
|
@ -15,8 +35,8 @@ int16_t area_width = AREA_WIDTH_NORMAL;
|
|||
int16_t area_height = AREA_HEIGHT_NORMAL;
|
||||
|
||||
// Cell render use spi buffer
|
||||
typedef uint16_t pixel;
|
||||
pixel *cell_buffer = (pixel *)spi_buffer;
|
||||
typedef uint16_t pixel_t;
|
||||
pixel_t *cell_buffer = (pixel_t *)spi_buffer;
|
||||
// Cell size
|
||||
// Depends from spi_buffer size, CELLWIDTH*CELLHEIGHT*sizeof(pixel) <= sizeof(spi_buffer)
|
||||
#define CELLWIDTH (64)
|
||||
|
|
@ -51,9 +71,10 @@ static index_t trace_index[TRACES_MAX][POINTS_COUNT];
|
|||
#define CELL_X(i) (int)(((i)>>16))
|
||||
#define CELL_Y(i) (int)(((i)&0xFFFF))
|
||||
|
||||
//#define floatToInt(v) ((int)(v))
|
||||
//#define float2int(v) ((int)(v))
|
||||
static int
|
||||
floatToInt(float v){
|
||||
float2int(float v)
|
||||
{
|
||||
if (v < 0) return v - 0.5;
|
||||
if (v > 0) return v + 0.5;
|
||||
return 0;
|
||||
|
|
@ -112,8 +133,7 @@ polar_grid(int x, int y)
|
|||
if (d == 0) return 1;
|
||||
|
||||
// vertical and horizontal axis
|
||||
if (x == 0 || y == 0)
|
||||
return 1;
|
||||
if (x == 0 || y == 0) return 1;
|
||||
|
||||
d = circle_inout(x, y, P_RADIUS / 5);
|
||||
if (d == 0) return 1;
|
||||
|
|
@ -124,8 +144,7 @@ polar_grid(int x, int y)
|
|||
if (d > 0) return 0;
|
||||
|
||||
// cross sloping lines
|
||||
if (x == y || x == -y)
|
||||
return 1;
|
||||
if (x == y || x == -y) return 1;
|
||||
|
||||
d = circle_inout(x, y, P_RADIUS * 3 / 5);
|
||||
if (d == 0) return 1;
|
||||
|
|
@ -151,23 +170,18 @@ smith_grid(int x, int y)
|
|||
|
||||
// outer circle
|
||||
d = circle_inout(x, y, P_RADIUS);
|
||||
if (d < 0)
|
||||
return 0;
|
||||
if (d == 0)
|
||||
return 1;
|
||||
if (d < 0) return 0;
|
||||
if (d == 0) return 1;
|
||||
|
||||
// horizontal axis
|
||||
if (y == 0)
|
||||
return 1;
|
||||
if (y == 0) return 1;
|
||||
|
||||
// shift circle center to right origin
|
||||
x -= P_RADIUS;
|
||||
|
||||
// Constant Reactance Circle: 2j : R/2 = P_RADIUS/2
|
||||
if (circle_inout(x, y+P_RADIUS/2, P_RADIUS/2) == 0)
|
||||
return 1;
|
||||
if (circle_inout(x, y-P_RADIUS/2, P_RADIUS/2) == 0)
|
||||
return 1;
|
||||
if (circle_inout(x, y + P_RADIUS / 2, P_RADIUS / 2) == 0) return 1;
|
||||
if (circle_inout(x, y - P_RADIUS / 2, P_RADIUS / 2) == 0) return 1;
|
||||
|
||||
// Constant Resistance Circle: 3 : R/4 = P_RADIUS/4
|
||||
d = circle_inout(x + P_RADIUS / 4, y, P_RADIUS / 4);
|
||||
|
|
@ -175,10 +189,8 @@ smith_grid(int x, int y)
|
|||
if (d == 0) return 1;
|
||||
|
||||
// Constant Reactance Circle: 1j : R = P_RADIUS
|
||||
if (circle_inout(x, y+P_RADIUS, P_RADIUS) == 0)
|
||||
return 1;
|
||||
if (circle_inout(x, y-P_RADIUS, P_RADIUS) == 0)
|
||||
return 1;
|
||||
if (circle_inout(x, y + P_RADIUS, P_RADIUS) == 0) return 1;
|
||||
if (circle_inout(x, y - P_RADIUS, P_RADIUS) == 0) return 1;
|
||||
|
||||
// Constant Resistance Circle: 1 : R/2
|
||||
d = circle_inout(x + P_RADIUS / 2, y, P_RADIUS / 2);
|
||||
|
|
@ -186,14 +198,11 @@ smith_grid(int x, int y)
|
|||
if (d == 0) return 1;
|
||||
|
||||
// Constant Reactance Circle: 1/2j : R*2
|
||||
if (circle_inout(x, y+P_RADIUS*2, P_RADIUS*2) == 0)
|
||||
return 1;
|
||||
if (circle_inout(x, y-P_RADIUS*2, P_RADIUS*2) == 0)
|
||||
return 1;
|
||||
if (circle_inout(x, y + P_RADIUS * 2, P_RADIUS * 2) == 0) return 1;
|
||||
if (circle_inout(x, y - P_RADIUS * 2, P_RADIUS * 2) == 0) return 1;
|
||||
|
||||
// Constant Resistance Circle: 1/3 : R*3/4
|
||||
if (circle_inout(x+P_RADIUS*3/4, y, P_RADIUS*3/4) == 0)
|
||||
return 1;
|
||||
if (circle_inout(x + P_RADIUS * 3 / 4, y, P_RADIUS * 3 / 4) == 0) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -355,8 +364,7 @@ static int
|
|||
rectangular_grid_x(int x)
|
||||
{
|
||||
x -= CELLOFFSETX;
|
||||
if (x < 0)
|
||||
return 0;
|
||||
if (x < 0) return 0;
|
||||
if (x == 0 || x == WIDTH)
|
||||
return 1;
|
||||
if ((((x + grid_offset) * 10) % grid_width) < 10)
|
||||
|
|
@ -466,7 +474,8 @@ swr(const float *v)
|
|||
}
|
||||
|
||||
static float
|
||||
resitance(const float *v) {
|
||||
resitance(const float *v)
|
||||
{
|
||||
float z0 = 50;
|
||||
float d = z0 / ((1-v[0])*(1-v[0])+v[1]*v[1]);
|
||||
float zr = ((1+v[0])*(1-v[0]) - v[1]*v[1]) * d;
|
||||
|
|
@ -474,7 +483,8 @@ resitance(const float *v) {
|
|||
}
|
||||
|
||||
static float
|
||||
reactance(const float *v) {
|
||||
reactance(const float *v)
|
||||
{
|
||||
float z0 = 50;
|
||||
float d = z0 / ((1-v[0])*(1-v[0])+v[1]*v[1]);
|
||||
float zi = 2*v[1] * d;
|
||||
|
|
@ -485,8 +495,8 @@ static void
|
|||
cartesian_scale(float re, float im, int *xp, int *yp, float scale)
|
||||
{
|
||||
//float scale = 4e-3;
|
||||
int x = floatToInt(re * P_RADIUS * scale);
|
||||
int y = floatToInt(im * P_RADIUS * scale);
|
||||
int x = float2int(re * P_RADIUS * scale);
|
||||
int y = float2int(im * P_RADIUS * scale);
|
||||
if (x < -P_RADIUS) x = -P_RADIUS;
|
||||
else if (x > P_RADIUS) x = P_RADIUS;
|
||||
if (y < -P_RADIUS) y = -P_RADIUS;
|
||||
|
|
@ -566,7 +576,7 @@ trace_into_index(int t, int i, float array[POINTS_COUNT][2])
|
|||
if (v < 0) v = 0;
|
||||
if (v > NGRIDY) v = NGRIDY;
|
||||
x = (i * (WIDTH) + (sweep_points-1)/2) / (sweep_points-1) + CELLOFFSETX;
|
||||
y = floatToInt(v * GRIDY);
|
||||
y = float2int(v * GRIDY);
|
||||
set_index:
|
||||
return INDEX(x, y);
|
||||
}
|
||||
|
|
@ -594,6 +604,7 @@ format_smith_value(char *buf, int len, const float coeff[2], uint32_t frequency)
|
|||
plot_printf(buf, len, "%.1fdB %.1f" S_DEGREE, v, phase(coeff));
|
||||
}
|
||||
break;
|
||||
|
||||
case MS_REIM:
|
||||
plot_printf(buf, len, "%F%+Fj", coeff[0], coeff[1]);
|
||||
break;
|
||||
|
|
@ -606,8 +617,7 @@ format_smith_value(char *buf, int len, const float coeff[2], uint32_t frequency)
|
|||
if (zi < 0) {// Capacity
|
||||
prefix = 'F';
|
||||
value = -1 / (2 * VNA_PI * frequency * zi);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
prefix = 'H';
|
||||
value = zi / (2 * VNA_PI * frequency);
|
||||
}
|
||||
|
|
@ -698,8 +708,7 @@ trace_get_value_string_delta(int t, char *buf, int len, float array[POINTS_COUNT
|
|||
case TRC_SWR:
|
||||
format = S_DELTA"%.3f";
|
||||
v = swr(coeff);
|
||||
if (v!=INFINITY)
|
||||
v-=swr(coeff_ref);
|
||||
if (v != INFINITY) v -= swr(coeff_ref);
|
||||
break;
|
||||
case TRC_SMITH:
|
||||
format_smith_value(buf, len, coeff, frequencies[index]);
|
||||
|
|
@ -753,12 +762,15 @@ trace_get_info(int t, char *buf, int len)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static float time_of_index(int idx) {
|
||||
static float time_of_index(int idx)
|
||||
{
|
||||
return 1.0 / (float)(frequencies[1] - frequencies[0]) / (float)FFT_SIZE * idx;
|
||||
}
|
||||
|
||||
static float distance_of_index(int idx) {
|
||||
float distance = ((float)idx * (float)SPEED_OF_LIGHT) / ( (float)(frequencies[1] - frequencies[0]) * (float)FFT_SIZE * 2.0);
|
||||
static float distance_of_index(int idx)
|
||||
{
|
||||
float distance = ((float)idx * (float)SPEED_OF_LIGHT) /
|
||||
((float)(frequencies[1] - frequencies[0]) * (float)FFT_SIZE * 2.0);
|
||||
return distance * velocity_factor;
|
||||
}
|
||||
|
||||
|
|
@ -788,7 +800,8 @@ force_set_markmap(void)
|
|||
}
|
||||
|
||||
void
|
||||
invalidateRect(int x0, int y0, int x1, int y1){
|
||||
invalidate_rect(int x0, int y0, int x1, int y1)
|
||||
{
|
||||
x0 /= CELLWIDTH;
|
||||
x1 /= CELLWIDTH;
|
||||
y0 /= CELLHEIGHT;
|
||||
|
|
@ -832,7 +845,7 @@ static inline void
|
|||
markmap_upperarea(void)
|
||||
{
|
||||
// Hardcoded, Text info from upper area
|
||||
invalidateRect(0, 0, AREA_WIDTH_NORMAL, 31);
|
||||
invalidate_rect(0, 0, AREA_WIDTH_NORMAL, 31);
|
||||
}
|
||||
|
||||
//
|
||||
|
|
@ -924,8 +937,7 @@ draw_refpos(int x, int y, int c)
|
|||
{
|
||||
int y0 = y, j;
|
||||
for (j = 0; j < REFERENCE_HEIGHT; j++, y0++) {
|
||||
if (y0 < 0 || y0 >= CELLHEIGHT)
|
||||
continue;
|
||||
if (y0 < 0 || y0 >= CELLHEIGHT) continue;
|
||||
int x0 = x;
|
||||
uint8_t bits = reference_bitmap[j];
|
||||
while (bits) {
|
||||
|
|
@ -997,8 +1009,7 @@ draw_marker(int x, int y, int c, int ch)
|
|||
uint8_t bits = marker_bitmap[ch * MARKER_HEIGHT + j];
|
||||
bool force_color = false;
|
||||
while (bits) {
|
||||
if (bits&0x80)
|
||||
force_color = true;
|
||||
if (bits & 0x80) force_color = true;
|
||||
if (x0 >= 0 && x0 < CELLWIDTH && y0 >= 0 && y0 < CELLHEIGHT) {
|
||||
if (bits & 0x80)
|
||||
cell_buffer[y0 * CELLWIDTH + x0] = c;
|
||||
|
|
@ -1023,7 +1034,7 @@ markmap_marker(int marker)
|
|||
index_t index = trace_index[t][markers[marker].index];
|
||||
int x = CELL_X(index) - X_MARKER_OFFSET;
|
||||
int y = CELL_Y(index) - Y_MARKER_OFFSET;
|
||||
invalidateRect(x, y, x+MARKER_WIDTH-1, y+MARKER_HEIGHT-1);
|
||||
invalidate_rect(x, y, x+MARKER_WIDTH-1, y+MARKER_HEIGHT-1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1211,7 +1222,7 @@ draw_cell(int m, int n)
|
|||
#error "CELLWIDTH % 8 should be == 0 for speed, or need rewrite cell cleanup"
|
||||
#endif
|
||||
// Set DEFAULT_BG_COLOR for 8 pixels in one cycle
|
||||
int count = h*CELLWIDTH / (16/sizeof(pixel));
|
||||
int count = h*CELLWIDTH / (16/sizeof(pixel_t));
|
||||
uint32_t *p = (uint32_t *)cell_buffer;
|
||||
while (count--) {
|
||||
p[0] = DEFAULT_BG_COLOR | (DEFAULT_BG_COLOR << 16);
|
||||
|
|
@ -1227,15 +1238,16 @@ draw_cell(int m, int n)
|
|||
c = config.grid_color;
|
||||
// Generate grid type list
|
||||
uint32_t trace_type = 0;
|
||||
for (t = 0; t < TRACES_MAX; t++)
|
||||
if (trace[t].enabled)
|
||||
for (t = 0; t < TRACES_MAX; t++) {
|
||||
if (trace[t].enabled) {
|
||||
trace_type |= (1 << trace[t].type);
|
||||
}
|
||||
}
|
||||
// Draw rectangular plot (40 system ticks for all screen calls)
|
||||
if (trace_type & RECTANGULAR_GRID_MASK) {
|
||||
for (x = 0; x < w; x++) {
|
||||
if (rectangular_grid_x(x + x0)) {
|
||||
for (y = 0; y < h; y++)
|
||||
cell_buffer[y * CELLWIDTH + x] = c;
|
||||
for (y = 0; y < h; y++) cell_buffer[y * CELLWIDTH + x] = c;
|
||||
}
|
||||
}
|
||||
for (y = 0; y < h; y++) {
|
||||
|
|
@ -1250,15 +1262,13 @@ draw_cell(int m, int n)
|
|||
if (trace_type & (1 << TRC_SMITH)) {
|
||||
for (y = 0; y < h; y++)
|
||||
for (x = 0; x < w; x++)
|
||||
if (smith_grid(x+x0, y+y0))
|
||||
cell_buffer[y * CELLWIDTH + x] = c;
|
||||
if (smith_grid(x + x0, y + y0)) cell_buffer[y * CELLWIDTH + x] = c;
|
||||
}
|
||||
// Polar greed line (800 system ticks for all screen calls)
|
||||
else if (trace_type & (1 << TRC_POLAR)) {
|
||||
for (y = 0; y < h; y++)
|
||||
for (x = 0; x < w; x++)
|
||||
if (polar_grid(x+x0, y+y0))
|
||||
cell_buffer[y * CELLWIDTH + x] = c;
|
||||
if (polar_grid(x + x0, y + y0)) cell_buffer[y * CELLWIDTH + x] = c;
|
||||
}
|
||||
#if 0
|
||||
else if (trace_type & (1 << TRC_ADMIT)) {
|
||||
|
|
@ -1271,18 +1281,21 @@ draw_cell(int m, int n)
|
|||
#endif
|
||||
#endif
|
||||
// PULSE;
|
||||
// Draw traces (50-600 system ticks for all screen calls, depend from lines count and size)
|
||||
// Draw traces (50-600 system ticks for all screen calls, depend from lines
|
||||
// count and size)
|
||||
#if 1
|
||||
for (t = 0; t < TRACES_MAX; t++) {
|
||||
if (!trace[t].enabled)
|
||||
continue;
|
||||
c = config.trace_color[t];
|
||||
// draw polar plot (check all points)
|
||||
i0 = 0; i1=0;
|
||||
i0 = 0;
|
||||
i1 = 0;
|
||||
uint32_t trace_type = (1 << trace[t].type);
|
||||
if (trace_type & ((1 << TRC_SMITH) | (1 << TRC_POLAR)))
|
||||
i1 = sweep_points - 1;
|
||||
else // draw rectangular plot (search index range in cell, save 50-70 system ticks for all screen calls)
|
||||
else // draw rectangular plot (search index range in cell, save 50-70
|
||||
// system ticks for all screen calls)
|
||||
search_index_range_x(x0, x0 + w, trace_index[t], &i0, &i1);
|
||||
index_t *index = trace_index[t];
|
||||
for (i = i0; i < i1; i++) {
|
||||
|
|
@ -1295,7 +1308,8 @@ draw_cell(int m, int n)
|
|||
}
|
||||
#else
|
||||
for (x = 0; x < area_width; x += 6)
|
||||
cell_drawline(x-x0, 0-y0, area_width-x-x0, area_height-y0, config.trace_color[0]);
|
||||
cell_drawline(x - x0, 0 - y0, area_width - x - x0, area_height - y0,
|
||||
config.trace_color[0]);
|
||||
#endif
|
||||
// PULSE;
|
||||
// draw marker symbols on each trace (<10 system ticks for all screen calls)
|
||||
|
|
@ -1310,7 +1324,8 @@ draw_cell(int m, int n)
|
|||
int x = CELL_X(index) - x0 - X_MARKER_OFFSET;
|
||||
int y = CELL_Y(index) - y0 - Y_MARKER_OFFSET;
|
||||
// Check marker icon on cell
|
||||
if (x+MARKER_WIDTH>=0 && x-MARKER_WIDTH<CELLWIDTH && y+MARKER_HEIGHT>=0 && y-MARKER_HEIGHT<CELLHEIGHT)
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
@ -1330,7 +1345,7 @@ draw_cell(int m, int n)
|
|||
continue;
|
||||
int x = 0 - x0 + CELLOFFSETX - REFERENCE_X_OFFSET;
|
||||
if (x + REFERENCE_WIDTH >= 0 && x - REFERENCE_WIDTH < CELLWIDTH) {
|
||||
int y = HEIGHT - floatToInt((get_trace_refpos(t) * GRIDY)) - y0 - REFERENCE_Y_OFFSET;
|
||||
int y = HEIGHT - float2int((get_trace_refpos(t) * GRIDY)) - y0 - REFERENCE_Y_OFFSET;
|
||||
if (y + REFERENCE_HEIGHT >= 0 && y - REFERENCE_HEIGHT < CELLHEIGHT)
|
||||
draw_refpos(x, y, config.trace_color[t]);
|
||||
}
|
||||
|
|
@ -1338,8 +1353,8 @@ draw_cell(int m, int n)
|
|||
// Need right clip cell render (25 system ticks for all screen calls)
|
||||
#if 1
|
||||
if (w < CELLWIDTH) {
|
||||
pixel *src = cell_buffer+CELLWIDTH;
|
||||
pixel *dst = cell_buffer+w;
|
||||
pixel_t *src = cell_buffer + CELLWIDTH;
|
||||
pixel_t *dst = cell_buffer + w;
|
||||
for (y = h; --y; src += CELLWIDTH - w)
|
||||
for (x = w; x--;)
|
||||
*dst++ = *src++;
|
||||
|
|
@ -1350,7 +1365,8 @@ draw_cell(int m, int n)
|
|||
}
|
||||
|
||||
static void
|
||||
draw_all_cells(bool flush_markmap){
|
||||
draw_all_cells(bool flush_markmap)
|
||||
{
|
||||
int m, n;
|
||||
// START_PROFILE
|
||||
for (m = 0; m < (area_width+CELLWIDTH-1) / CELLWIDTH; m++)
|
||||
|
|
@ -1412,7 +1428,7 @@ void
|
|||
request_to_draw_cells_behind_menu(void)
|
||||
{
|
||||
// Values Hardcoded from ui.c
|
||||
invalidateRect(320-70, 0, 319, 239);
|
||||
invalidate_rect(320-70, 0, 319, 239);
|
||||
redraw_request |= REDRAW_CELLS;
|
||||
}
|
||||
|
||||
|
|
@ -1420,7 +1436,7 @@ void
|
|||
request_to_draw_cells_behind_numeric_input(void)
|
||||
{
|
||||
// Values Hardcoded from ui.c
|
||||
invalidateRect(0, 240-32, 319, 239);
|
||||
invalidate_rect(0, 240-32, 319, 239);
|
||||
redraw_request |= REDRAW_CELLS;
|
||||
}
|
||||
|
||||
|
|
@ -1478,7 +1494,7 @@ cell_draw_marker_info(int x0, int y0)
|
|||
int xpos = 1 + (j%2)*(WIDTH/2) + CELLOFFSETX - x0;
|
||||
int ypos = 1 + (j/2)*(FONT_GET_HEIGHT+1) - y0;
|
||||
|
||||
setForegroundColor(config.trace_color[t]);
|
||||
ili9341_set_foreground(config.trace_color[t]);
|
||||
if (mk == active_marker)
|
||||
cell_drawstring(S_SARROW, xpos, ypos);
|
||||
xpos += 5;
|
||||
|
|
@ -1500,7 +1516,7 @@ cell_draw_marker_info(int x0, int y0)
|
|||
trace_get_value_string_delta(t, buf, sizeof buf, measured[trace[t].channel], markers[mk].index, markers[active_marker].index);
|
||||
else
|
||||
trace_get_value_string(t, buf, sizeof buf, measured[trace[t].channel], markers[mk].index);
|
||||
setForegroundColor(DEFAULT_FG_COLOR);
|
||||
ili9341_set_foreground(DEFAULT_FG_COLOR);
|
||||
cell_drawstring(buf, xpos, ypos);
|
||||
j++;
|
||||
}
|
||||
|
|
@ -1512,7 +1528,7 @@ cell_draw_marker_info(int x0, int y0)
|
|||
int ypos = 1 + (j/2)*(FONT_GET_HEIGHT+1) - y0;
|
||||
|
||||
plot_printf(buf, sizeof buf, S_DELTA"%d-%d:", active_marker+1, previous_marker+1);
|
||||
setForegroundColor(DEFAULT_FG_COLOR);
|
||||
ili9341_set_foreground(DEFAULT_FG_COLOR);
|
||||
cell_drawstring(buf, xpos, ypos);
|
||||
xpos += 27;
|
||||
if ((domain_mode & DOMAIN_MODE) == DOMAIN_FREQ) {
|
||||
|
|
@ -1532,7 +1548,7 @@ cell_draw_marker_info(int x0, int y0)
|
|||
int xpos = 1 + (j%2)*(WIDTH/2) + CELLOFFSETX - x0;
|
||||
int ypos = 1 + (j/2)*(FONT_GET_HEIGHT+1) - y0;
|
||||
|
||||
setForegroundColor(config.trace_color[t]);
|
||||
ili9341_set_foreground(config.trace_color[t]);
|
||||
if (t == uistat.current_trace)
|
||||
cell_drawstring(S_SARROW, xpos, ypos);
|
||||
xpos += 5;
|
||||
|
|
@ -1545,7 +1561,7 @@ cell_draw_marker_info(int x0, int y0)
|
|||
xpos += n * 5 + 2;
|
||||
//xpos += 60;
|
||||
trace_get_value_string(t, buf, sizeof buf, measured[trace[t].channel], idx);
|
||||
setForegroundColor(DEFAULT_FG_COLOR);
|
||||
ili9341_set_foreground(DEFAULT_FG_COLOR);
|
||||
cell_drawstring(buf, xpos, ypos);
|
||||
j++;
|
||||
}
|
||||
|
|
@ -1554,7 +1570,7 @@ cell_draw_marker_info(int x0, int y0)
|
|||
int xpos = (WIDTH/2+40) + CELLOFFSETX - x0;
|
||||
int ypos = 1 + (j/2)*(FONT_GET_HEIGHT+1) - y0;
|
||||
|
||||
setForegroundColor(DEFAULT_FG_COLOR);
|
||||
ili9341_set_foreground(DEFAULT_FG_COLOR);
|
||||
if (uistat.lever_mode == LM_MARKER)
|
||||
cell_drawstring(S_SARROW, xpos, ypos);
|
||||
xpos += 5;
|
||||
|
|
@ -1569,7 +1585,7 @@ cell_draw_marker_info(int x0, int y0)
|
|||
}
|
||||
cell_drawstring(buf, xpos, ypos);
|
||||
}
|
||||
setForegroundColor(DEFAULT_FG_COLOR);
|
||||
ili9341_set_foreground(DEFAULT_FG_COLOR);
|
||||
if (electrical_delay != 0) {
|
||||
// draw electrical delay
|
||||
int xpos = 21 + CELLOFFSETX - x0;
|
||||
|
|
@ -1605,8 +1621,8 @@ draw_frequencies(void)
|
|||
plot_printf(buf1, sizeof(buf1), " START 0s");
|
||||
plot_printf(buf2, sizeof(buf2), "STOP %Fs (%Fm)", time_of_index(sweep_points-1), distance_of_index(sweep_points-1));
|
||||
}
|
||||
setForegroundColor(DEFAULT_FG_COLOR);
|
||||
setBackgroundColor(DEFAULT_BG_COLOR);
|
||||
ili9341_set_foreground(DEFAULT_FG_COLOR);
|
||||
ili9341_set_background(DEFAULT_BG_COLOR);
|
||||
ili9341_fill(0, FREQUENCIES_YPOS, 320, FONT_GET_HEIGHT, DEFAULT_BG_COLOR);
|
||||
if (uistat.lever_mode == LM_CENTER)
|
||||
buf1[0] = S_SARROW[0];
|
||||
|
|
@ -1622,8 +1638,8 @@ draw_cal_status(void)
|
|||
int x = 0;
|
||||
int y = 100;
|
||||
char c[3];
|
||||
setForegroundColor(DEFAULT_FG_COLOR);
|
||||
setBackgroundColor(DEFAULT_BG_COLOR);
|
||||
ili9341_set_foreground(DEFAULT_FG_COLOR);
|
||||
ili9341_set_background(DEFAULT_BG_COLOR);
|
||||
ili9341_fill(0, y, OFFSETX, 6*(FONT_GET_HEIGHT+1), DEFAULT_BG_COLOR);
|
||||
if (cal_status & CALSTAT_APPLY) {
|
||||
c[0] = cal_status & CALSTAT_INTERPOLATED ? 'c' : 'C';
|
||||
|
|
@ -1657,8 +1673,8 @@ static void draw_battery_status(void)
|
|||
return;
|
||||
uint8_t string_buf[16];
|
||||
// Set battery color
|
||||
setForegroundColor(vbat < BATTERY_WARNING_LEVEL ? DEFAULT_LOW_BAT_COLOR : DEFAULT_NORMAL_BAT_COLOR);
|
||||
setBackgroundColor(DEFAULT_BG_COLOR);
|
||||
ili9341_set_foreground(vbat < BATTERY_WARNING_LEVEL ? DEFAULT_LOW_BAT_COLOR : DEFAULT_NORMAL_BAT_COLOR);
|
||||
ili9341_set_background(DEFAULT_BG_COLOR);
|
||||
// plot_printf(string_buf, sizeof string_buf, "V:%d", vbat);
|
||||
// ili9341_drawstringV(string_buf, 1, 60);
|
||||
// Prepare battery bitmap image
|
||||
|
|
@ -1689,8 +1705,8 @@ request_to_redraw_grid(void)
|
|||
void
|
||||
redraw_frame(void)
|
||||
{
|
||||
setBackgroundColor(DEFAULT_BG_COLOR);
|
||||
clearScreen();
|
||||
ili9341_set_background(DEFAULT_BG_COLOR);
|
||||
ili9341_clear_screen();
|
||||
draw_frequencies();
|
||||
draw_cal_status();
|
||||
}
|
||||
|
|
|
|||
70
si5351.c
70
si5351.c
|
|
@ -51,9 +51,13 @@ static int32_t current_offset = FREQUENCY_OFFSET;
|
|||
// Delay after set new PLL values, and send reset (on band 1 unstable if less then 900, on 4000-5000 no amplitude spike on change)
|
||||
#define DELAY_RESET_PLL 5000
|
||||
|
||||
uint32_t si5351_getFrequency(void) {return current_freq;}
|
||||
uint32_t si5351_get_frequency(void)
|
||||
{
|
||||
return current_freq;
|
||||
}
|
||||
|
||||
void si5351_set_frequency_offset(int32_t offset) {
|
||||
void si5351_set_frequency_offset(int32_t offset)
|
||||
{
|
||||
current_offset = offset;
|
||||
current_freq = 0; // reset freq, for
|
||||
}
|
||||
|
|
@ -275,7 +279,8 @@ si5351_setupMultisynth(uint8_t channel,
|
|||
|
||||
// Find better approximate values for n/d
|
||||
#define MAX_DENOMINATOR ((1 << 20) - 1)
|
||||
static inline void fractionalSolve(uint32_t *n, uint32_t *d){
|
||||
static inline void approximate_fraction(uint32_t *n, uint32_t *d)
|
||||
{
|
||||
// cf. https://github.com/python/cpython/blob/master/Lib/fractions.py#L227
|
||||
uint32_t denom = *d;
|
||||
if (denom > MAX_DENOMINATOR) {
|
||||
|
|
@ -303,18 +308,19 @@ si5351_set_frequency_fixedpll(uint8_t channel, uint64_t pllfreq, uint32_t freq,
|
|||
uint32_t denom = freq;
|
||||
uint32_t div = pllfreq / denom; // range: 8 ~ 1800
|
||||
uint32_t num = pllfreq % denom;
|
||||
fractionalSolve(&num, &denom);
|
||||
approximate_fraction(&num, &denom);
|
||||
si5351_setupMultisynth(channel, div, num, denom, rdiv, chctrl);
|
||||
}
|
||||
|
||||
// Setup PLL freq if Multisynth divider fixed = div (need get output = freq/mul)
|
||||
static void
|
||||
si5351_setupPLL_freq(uint32_t pllSource, uint32_t freq, uint32_t div, uint32_t mul){
|
||||
si5351_setupPLL_freq(uint32_t pllSource, uint32_t freq, uint32_t div, uint32_t mul)
|
||||
{
|
||||
uint32_t denom = XTALFREQ * mul;
|
||||
uint64_t pllfreq = (uint64_t)freq * div;
|
||||
uint32_t multi = pllfreq / denom;
|
||||
uint32_t num = pllfreq % denom;
|
||||
fractionalSolve(&num, &denom);
|
||||
approximate_fraction(&num, &denom);
|
||||
si5351_setupPLL(pllSource, multi, num, denom);
|
||||
}
|
||||
|
||||
|
|
@ -328,7 +334,8 @@ si5351_set_frequency_fixeddiv(uint8_t channel, uint32_t pll, uint32_t freq, uint
|
|||
}
|
||||
|
||||
void
|
||||
si5351_set_frequency(int channel, uint32_t freq, uint8_t drive_strength){
|
||||
si5351_set_frequency(int channel, uint32_t freq, uint8_t drive_strength)
|
||||
{
|
||||
if (freq <= 100000000) {
|
||||
si5351_setupPLL(SI5351_PLL_B, 32, 0, 1);
|
||||
si5351_set_frequency_fixedpll(channel, SI5351_PLL_B, PLLFREQ, freq, SI5351_R_DIV_1, drive_strength, 1);
|
||||
|
|
@ -361,7 +368,9 @@ si5351_set_frequency(int channel, uint32_t freq, uint8_t drive_strength){
|
|||
* | of = 50kHz-300MHz |of= 60- 90 |of= 90-180 |of=128-215 |of=166-234 |of=190-246 |
|
||||
* +-----------------------------------------------------------------------------------------------------------------------+
|
||||
*/
|
||||
static inline uint8_t si5351_getBand(uint32_t freq){
|
||||
static inline uint8_t
|
||||
si5351_get_band(uint32_t freq)
|
||||
{
|
||||
if (freq < 100000000U) return 1;
|
||||
if (freq < 150000000U) return 2;
|
||||
return 3;
|
||||
|
|
@ -375,7 +384,8 @@ static inline uint8_t si5351_getBand(uint32_t freq){
|
|||
* CLK2: fixed 8MHz
|
||||
*/
|
||||
int
|
||||
si5351_set_frequency_with_offset(uint32_t freq, uint8_t drive_strength){
|
||||
si5351_set_frequency(uint32_t freq, uint8_t drive_strength)
|
||||
{
|
||||
uint8_t band;
|
||||
int delay = DELAY_NORMAL;
|
||||
if (freq == current_freq)
|
||||
|
|
@ -402,8 +412,7 @@ si5351_set_frequency_with_offset(uint32_t freq, uint8_t drive_strength){
|
|||
} else if (freq >= config.harmonic_freq_threshold) {
|
||||
mul = 3;
|
||||
omul = 5;
|
||||
}
|
||||
else if (freq <= 500000U) {
|
||||
} else if (freq <= 500000U) {
|
||||
rdiv = SI5351_R_DIV_64;
|
||||
freq<<= 6;
|
||||
ofreq<<= 6;
|
||||
|
|
@ -412,37 +421,48 @@ si5351_set_frequency_with_offset(uint32_t freq, uint8_t drive_strength){
|
|||
freq<<= 3;
|
||||
ofreq<<= 3;
|
||||
}
|
||||
band = si5351_getBand(freq/mul);
|
||||
band = si5351_get_band(freq / mul);
|
||||
switch (band) {
|
||||
case 1:
|
||||
// Setup CH0 and CH1 constant PLLA freq at band change, and set CH2 freq = CLK2_FREQUENCY
|
||||
// Setup CH0 and CH1 constant PLLA freq at band change, and set CH2 freq =
|
||||
// CLK2_FREQUENCY
|
||||
if (current_band != 1) {
|
||||
si5351_setupPLL(SI5351_REG_PLL_A, PLL_N, 0, 1);
|
||||
si5351_set_frequency_fixedpll(2, XTALFREQ * PLL_N, CLK2_FREQUENCY, SI5351_R_DIV_1, SI5351_CLK_DRIVE_STRENGTH_2MA|SI5351_CLK_PLL_SELECT_A);
|
||||
si5351_set_frequency_fixedpll(
|
||||
2, XTALFREQ * PLL_N, CLK2_FREQUENCY, SI5351_R_DIV_1,
|
||||
SI5351_CLK_DRIVE_STRENGTH_2MA | SI5351_CLK_PLL_SELECT_A);
|
||||
delay = DELAY_BANDCHANGE_1;
|
||||
}
|
||||
else
|
||||
} else {
|
||||
delay = DELAY_BAND_1;
|
||||
}
|
||||
// Calculate and set CH0 and CH1 divider
|
||||
si5351_set_frequency_fixedpll(0, (uint64_t)omul * XTALFREQ * PLL_N, ofreq, rdiv, drive_strength|SI5351_CLK_PLL_SELECT_A);
|
||||
si5351_set_frequency_fixedpll(1, (uint64_t) mul * XTALFREQ * PLL_N, freq, rdiv, drive_strength|SI5351_CLK_PLL_SELECT_A);
|
||||
si5351_set_frequency_fixedpll(0, (uint64_t)omul * XTALFREQ * PLL_N, ofreq, rdiv,
|
||||
drive_strength | SI5351_CLK_PLL_SELECT_A);
|
||||
si5351_set_frequency_fixedpll(1, (uint64_t)mul * XTALFREQ * PLL_N, freq, rdiv,
|
||||
drive_strength | SI5351_CLK_PLL_SELECT_A);
|
||||
break;
|
||||
case 2: // fdiv = 6
|
||||
case 3: // fdiv = 4;
|
||||
fdiv = (band == 2) ? 6 : 4;
|
||||
// Setup CH0 and CH1 constant fdiv divider at change
|
||||
if (current_band != band) {
|
||||
si5351_setupMultisynth(0, fdiv, 0, 1, SI5351_R_DIV_1, drive_strength|SI5351_CLK_PLL_SELECT_A);
|
||||
si5351_setupMultisynth(1, fdiv, 0, 1, SI5351_R_DIV_1, drive_strength|SI5351_CLK_PLL_SELECT_B);
|
||||
si5351_setupMultisynth(0, fdiv, 0, 1, SI5351_R_DIV_1,
|
||||
drive_strength | SI5351_CLK_PLL_SELECT_A);
|
||||
si5351_setupMultisynth(1, fdiv, 0, 1, SI5351_R_DIV_1,
|
||||
drive_strength | SI5351_CLK_PLL_SELECT_B);
|
||||
delay = DELAY_BANDCHANGE_2;
|
||||
}
|
||||
else
|
||||
} else {
|
||||
delay = DELAY_BAND_2;
|
||||
}
|
||||
// Calculate and set CH0 and CH1 PLL freq
|
||||
si5351_setupPLL_freq(SI5351_REG_PLL_A, ofreq, fdiv, omul);// set PLLA freq = (ofreq/omul)*fdiv
|
||||
si5351_setupPLL_freq(SI5351_REG_PLL_B, freq, fdiv, mul);// set PLLB freq = ( freq/ mul)*fdiv
|
||||
si5351_setupPLL_freq(SI5351_REG_PLL_A, ofreq, fdiv,
|
||||
omul); // set PLLA freq = (ofreq/omul)*fdiv
|
||||
si5351_setupPLL_freq(SI5351_REG_PLL_B, freq, fdiv,
|
||||
mul); // set PLLB freq = ( freq/ mul)*fdiv
|
||||
// Calculate CH2 freq = CLK2_FREQUENCY, depend from calculated before CH1 PLLB = (freq/mul)*fdiv
|
||||
si5351_set_frequency_fixedpll(2, (uint64_t)freq*fdiv, CLK2_FREQUENCY*mul, SI5351_R_DIV_1, SI5351_CLK_DRIVE_STRENGTH_2MA|SI5351_CLK_PLL_SELECT_B);
|
||||
si5351_set_frequency_fixedpll(
|
||||
2, (uint64_t)freq * fdiv, CLK2_FREQUENCY * mul, SI5351_R_DIV_1,
|
||||
SI5351_CLK_DRIVE_STRENGTH_2MA | SI5351_CLK_PLL_SELECT_B);
|
||||
break;
|
||||
}
|
||||
if (current_band != band) {
|
||||
|
|
|
|||
6
si5351.h
6
si5351.h
|
|
@ -71,9 +71,7 @@
|
|||
void si5351_init(void);
|
||||
void si5351_disable_output(void);
|
||||
void si5351_enable_output(void);
|
||||
//void si5351_set_frequency(int channel, uint32_t freq, uint8_t drive_strength);
|
||||
|
||||
void si5351_set_frequency_offset(int32_t offset);
|
||||
int si5351_set_frequency_with_offset(uint32_t freq, uint8_t drive_strength);
|
||||
uint32_t si5351_getFrequency(void);
|
||||
|
||||
int si5351_set_frequency(uint32_t freq, uint8_t drive_strength);
|
||||
uint32_t si5351_get_frequency(void);
|
||||
|
|
|
|||
71
ui.c
71
ui.c
|
|
@ -288,13 +288,17 @@ touch_check(void)
|
|||
}
|
||||
|
||||
static inline void
|
||||
touch_wait_release(void) {
|
||||
while(touch_check()!=EVT_TOUCH_RELEASED);
|
||||
touch_wait_release(void)
|
||||
{
|
||||
while (touch_check() != EVT_TOUCH_RELEASED)
|
||||
;
|
||||
}
|
||||
|
||||
static inline void
|
||||
touch_wait_pressed(void) {
|
||||
while(touch_check()!=EVT_TOUCH_PRESSED);
|
||||
touch_wait_pressed(void)
|
||||
{
|
||||
while (touch_check() != EVT_TOUCH_PRESSED)
|
||||
;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -303,9 +307,9 @@ touch_cal_exec(void)
|
|||
int x1, x2, y1, y2;
|
||||
|
||||
adc_stop();
|
||||
setForegroundColor(DEFAULT_FG_COLOR);
|
||||
setBackgroundColor(DEFAULT_BG_COLOR);
|
||||
clearScreen();
|
||||
ili9341_set_foreground(DEFAULT_FG_COLOR);
|
||||
ili9341_set_background(DEFAULT_BG_COLOR);
|
||||
ili9341_clear_screen();
|
||||
ili9341_line(0, 0, 0, 32);
|
||||
ili9341_line(0, 0, 32, 0);
|
||||
ili9341_drawstring("TOUCH UPPER LEFT", 10, 10);
|
||||
|
|
@ -314,7 +318,7 @@ touch_cal_exec(void)
|
|||
x1 = last_touch_x;
|
||||
y1 = last_touch_y;
|
||||
|
||||
clearScreen();
|
||||
ili9341_clear_screen();
|
||||
ili9341_line(320-1, 240-1, 320-1, 240-32);
|
||||
ili9341_line(320-1, 240-1, 320-32, 240-1);
|
||||
ili9341_drawstring("TOUCH LOWER RIGHT", 230, 220);
|
||||
|
|
@ -340,9 +344,9 @@ touch_draw_test(void)
|
|||
|
||||
adc_stop();
|
||||
|
||||
setForegroundColor(DEFAULT_FG_COLOR);
|
||||
setBackgroundColor(DEFAULT_BG_COLOR);
|
||||
clearScreen();
|
||||
ili9341_set_foreground(DEFAULT_FG_COLOR);
|
||||
ili9341_set_background(DEFAULT_BG_COLOR);
|
||||
ili9341_clear_screen();
|
||||
ili9341_drawstring("TOUCH TEST: DRAG PANEL", OFFSETX, 233);
|
||||
|
||||
touch_wait_pressed();
|
||||
|
|
@ -372,10 +376,10 @@ show_version(void)
|
|||
{
|
||||
int x = 5, y = 5, i = 0;
|
||||
adc_stop();
|
||||
setForegroundColor(DEFAULT_FG_COLOR);
|
||||
setBackgroundColor(DEFAULT_BG_COLOR);
|
||||
ili9341_set_foreground(DEFAULT_FG_COLOR);
|
||||
ili9341_set_background(DEFAULT_BG_COLOR);
|
||||
|
||||
clearScreen();
|
||||
ili9341_clear_screen();
|
||||
uint16_t shift = 0b0000010000111110;
|
||||
ili9341_drawstring_size(info_about[i++], x , y, 4);
|
||||
while (info_about[i]) {
|
||||
|
|
@ -398,10 +402,10 @@ enter_dfu(void)
|
|||
adc_stop();
|
||||
|
||||
int x = 5, y = 5;
|
||||
setForegroundColor(DEFAULT_FG_COLOR);
|
||||
setBackgroundColor(DEFAULT_BG_COLOR);
|
||||
ili9341_set_foreground(DEFAULT_FG_COLOR);
|
||||
ili9341_set_background(DEFAULT_BG_COLOR);
|
||||
// leave a last message
|
||||
clearScreen();
|
||||
ili9341_clear_screen();
|
||||
ili9341_drawstring("DFU: Device Firmware Update Mode", x, y += 10);
|
||||
ili9341_drawstring("To exit DFU mode, please reset device yourself.", x, y += 10);
|
||||
|
||||
|
|
@ -606,7 +610,8 @@ menu_transform_cb(int item, uint8_t data)
|
|||
}
|
||||
|
||||
static void
|
||||
menu_velocity_cb(int item, uint8_t data){
|
||||
menu_velocity_cb(int item, uint8_t data)
|
||||
{
|
||||
(void)item;
|
||||
(void)data;
|
||||
if (btn_wait_release() & EVT_BUTTON_DOWN_LONG) {
|
||||
|
|
@ -1237,12 +1242,14 @@ draw_keypad(void)
|
|||
uint16_t bg = config.menu_normal_color;
|
||||
if (i == selection)
|
||||
bg = config.menu_active_color;
|
||||
setForegroundColor(DEFAULT_MENU_TEXT_COLOR);
|
||||
setBackgroundColor(bg);
|
||||
ili9341_set_foreground(DEFAULT_MENU_TEXT_COLOR);
|
||||
ili9341_set_background(bg);
|
||||
int x = KP_GET_X(keypads[i].x);
|
||||
int y = KP_GET_Y(keypads[i].y);
|
||||
ili9341_fill(x+2, y+2, KP_WIDTH-4, KP_HEIGHT-4, bg);
|
||||
ili9341_drawfont(keypads[i].c, x+(KP_WIDTH-NUM_FONT_GET_WIDTH)/2, y+(KP_HEIGHT-NUM_FONT_GET_HEIGHT)/2);
|
||||
ili9341_drawfont(keypads[i].c,
|
||||
x + (KP_WIDTH - NUM_FONT_GET_WIDTH) / 2,
|
||||
y + (KP_HEIGHT - NUM_FONT_GET_HEIGHT) / 2);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
|
@ -1251,8 +1258,8 @@ static void
|
|||
draw_numeric_area_frame(void)
|
||||
{
|
||||
ili9341_fill(0, 240-NUM_INPUT_HEIGHT, 320, NUM_INPUT_HEIGHT, config.menu_normal_color);
|
||||
setForegroundColor(DEFAULT_MENU_TEXT_COLOR);
|
||||
setBackgroundColor(config.menu_normal_color);
|
||||
ili9341_set_foreground(DEFAULT_MENU_TEXT_COLOR);
|
||||
ili9341_set_background(config.menu_normal_color);
|
||||
ili9341_drawstring(keypad_mode_label[keypad_mode], 10, 240-(FONT_GET_HEIGHT+NUM_INPUT_HEIGHT)/2);
|
||||
//ili9341_drawfont(KP_KEYPAD, 300, 216);
|
||||
}
|
||||
|
|
@ -1282,8 +1289,8 @@ draw_numeric_input(const char *buf)
|
|||
// if (uistat.digit_mode)
|
||||
// bg = DEFAULT_MENU_COLOR;
|
||||
}
|
||||
setForegroundColor(fg);
|
||||
setBackgroundColor(bg);
|
||||
ili9341_set_foreground(fg);
|
||||
ili9341_set_background(bg);
|
||||
if (c >= 0) // c is number
|
||||
ili9341_drawfont(c, x, 240-NUM_INPUT_HEIGHT+4);
|
||||
else if (focused) // c not number, but focused
|
||||
|
|
@ -1397,8 +1404,8 @@ draw_menu_buttons(const menuitem_t *menu)
|
|||
ili9341_fill(320-MENU_BUTTON_WIDTH, y, MENU_BUTTON_WIDTH, MENU_BUTTON_HEIGHT-2, bg);
|
||||
|
||||
menu_item_modify_attribute(menu, i, &fg, &bg);
|
||||
setForegroundColor(fg);
|
||||
setBackgroundColor(bg);
|
||||
ili9341_set_foreground(fg);
|
||||
ili9341_set_background(bg);
|
||||
if (menu_is_multiline(menu[i].label, &l1, &l2)) {
|
||||
ili9341_fill(320-MENU_BUTTON_WIDTH+3, y+5, MENU_BUTTON_WIDTH-6, 2+FONT_GET_HEIGHT+1+FONT_GET_HEIGHT+2, bg);
|
||||
ili9341_drawstring(l1, 320-MENU_BUTTON_WIDTH+5, y+7);
|
||||
|
|
@ -1839,9 +1846,9 @@ keypad_click(int key)
|
|||
}
|
||||
|
||||
return KP_DONE;
|
||||
} else if (c <= 9 && kp_index < NUMINPUT_LEN)
|
||||
} else if (c <= 9 && kp_index < NUMINPUT_LEN) {
|
||||
kp_buf[kp_index++] = '0' + c;
|
||||
else if (c == KP_PERIOD && kp_index < NUMINPUT_LEN) {
|
||||
} else if (c == KP_PERIOD && kp_index < NUMINPUT_LEN) {
|
||||
// check period in former input
|
||||
int j;
|
||||
for (j = 0; j < kp_index && kp_buf[j] != '.'; j++)
|
||||
|
|
@ -2125,8 +2132,9 @@ touch_lever_mode_select(void)
|
|||
if (touch_y < 25) {
|
||||
if (touch_x < FREQUENCIES_XPOS2 && get_electrical_delay() != 0.0) {
|
||||
select_lever_mode(LM_EDELAY);
|
||||
} else
|
||||
} else {
|
||||
select_lever_mode(LM_MARKER);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
|
|
@ -2178,7 +2186,8 @@ ui_process(void)
|
|||
}
|
||||
|
||||
/* Triggered when the button is pressed or released. The LED4 is set to ON.*/
|
||||
static void extcb1(EXTDriver *extp, expchannel_t channel) {
|
||||
static void extcb1(EXTDriver *extp, expchannel_t channel)
|
||||
{
|
||||
(void)extp;
|
||||
(void)channel;
|
||||
operation_requested|=OP_LEVER;
|
||||
|
|
|
|||
Loading…
Reference in a new issue