diff --git a/.clang-format b/.clang-format new file mode 100644 index 00000000..59ea9b25 --- /dev/null +++ b/.clang-format @@ -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: '^' + 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 +... + diff --git a/.vscode/settings.json b/.vscode/settings.json index 691a8f68..ee6833dc 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,4 @@ { - "C_Cpp.errorSquiggles": "Disabled" + "C_Cpp.errorSquiggles": "Disabled", + "cpplint.filters": ["-build/include_subdir", "-build/include_order", "-readability/casting", "-whitespace/comments"] } \ No newline at end of file diff --git a/Font5x7.c b/Font5x7.c index 87b91274..26a0a873 100644 --- a/Font5x7.c +++ b/Font5x7.c @@ -1,2442 +1,2442 @@ -/* - * Font size 5x7 pixels - * most font glyph have width 5 pixels - */ - -#include - -/* - * Check 1 byte of char bitmap data for get width - */ - -#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 -#define FONT_GET_HEIGHT 7 - -#define CHAR5x7_WIDTH_1px 0x07 -#define CHAR5x7_WIDTH_2px 0x06 -#define CHAR5x7_WIDTH_3px 0x05 -#define CHAR5x7_WIDTH_4px 0x04 -#define CHAR5x7_WIDTH_5px 0x03 -#define CHAR5x7_WIDTH_6px 0x02 -#define CHAR5x7_WIDTH_7px 0x01 -#define CHAR5x7_WIDTH_8px 0x00 - -/* Font character bitmap data. */ -const uint8_t x5x7_bits[127*7] = -{ - - /* Character (0x00): - width=5 - +--------+ - |**** | - |**** | - |**** | - |**** | - |**** | - |**** | - | | - +--------+ */ - 0b11110000|CHAR5x7_WIDTH_5px, - 0b11110000, - 0b11110000, - 0b11110000, - 0b11110000, - 0b11110000, - 0b00000000, - - /* Character (0x01): - width=5 - +--------+ - | | - | * | - | *** | - |***** | - | *** | - | * | - | | - +--------+ */ - 0b00000000|CHAR5x7_WIDTH_5px, - 0b00100000, - 0b01110000, - 0b11111000, - 0b01110000, - 0b00100000, - 0b00000000, - - /* Character (0x02): - width=5 - +--------+ - | * * | - |* * * | - | * * | - |* * * | - | * * | - |* * * | - | * * | - +--------+ */ - 0b01010000|CHAR5x7_WIDTH_5px, - 0b10101000, - 0b01010000, - 0b10101000, - 0b01010000, - 0b10101000, - 0b01010000, - - /* Character (0x03): - width=5 - +--------+ - |* * | - |*** | - |* * | - |* * | - | *** | - | * | - | * | - +--------+ */ - 0b10100000|CHAR5x7_WIDTH_5px, - 0b11100000, - 0b10100000, - 0b10100000, - 0b01110000, - 0b00100000, - 0b00100000, - - /* Character (0x04): - width=6 - +--------+ - | | - | * | - | * | - | * * | - | * * | - |* * | - |***** | - +--------+ */ - 0b00000000|CHAR5x7_WIDTH_6px, - 0b00100000, - 0b00100000, - 0b01010000, - 0b01010000, - 0b10001000, - 0b11111000, - - /* Character (0x05): - width=5 - +--------+ - |** | - |* | - |** | - | ** | - | * * | - | ** | - | * * | - +--------+ */ - 0b11000000|CHAR5x7_WIDTH_5px, - 0b10000000, - 0b11000000, - 0b01100000, - 0b01010000, - 0b01100000, - 0b01010000, - - /* Character (0x06): - width=5 - +--------+ - |* | - |* | - |** | - | ** | - | * | - | ** | - | * | - +--------+ */ - 0b10000000|CHAR5x7_WIDTH_5px, - 0b10000000, - 0b11000000, - 0b00110000, - 0b00100000, - 0b00110000, - 0b00100000, - - /* Character (0x07): - width=5 - +--------+ - | * | - | * * | - | * | - | | - | | - | | - | | - +--------+ */ - 0b00100000|CHAR5x7_WIDTH_5px, - 0b01010000, - 0b00100000, - 0b00000000, - 0b00000000, - 0b00000000, - 0b00000000, - - /* Character (0x08): - width=5 - +--------+ - | | - | * | - | *** | - | * | - | | - | *** | - | | - +--------+ */ - 0b00000000|CHAR5x7_WIDTH_5px, - 0b00100000, - 0b01110000, - 0b00100000, - 0b00000000, - 0b01110000, - 0b00000000, - - /* Character (0x09): - width=5 - +--------+ - |* * | - |** * | - |* ** | - |* * | - | * | - | * | - | ** | - +--------+ */ - 0b10010000|CHAR5x7_WIDTH_5px, - 0b11010000, - 0b10110000, - 0b10010000, - 0b00100000, - 0b00100000, - 0b00110000, - - /* Character (0x0a): - width=5 - +--------+ - |* * | - |* * | - |* * | - | * | - | *** | - | * | - | * | - +--------+ */ - 0b10100000|CHAR5x7_WIDTH_5px, - 0b10100000, - 0b10100000, - 0b01000000, - 0b01110000, - 0b00100000, - 0b00100000, - - /* Character (0x0b): - width=5 - +--------+ - | * | - | * | - | * | - |*** | - | | - | | - | | - +--------+ */ - 0b00100000|CHAR5x7_WIDTH_5px, - 0b00100000, - 0b00100000, - 0b11100000, - 0b00000000, - 0b00000000, - 0b00000000, - - /* Character (0x0c): - width=5 - +--------+ - | | - | | - | | - |*** | - | * | - | * | - | * | - +--------+ */ - 0b00000000|CHAR5x7_WIDTH_5px, - 0b00000000, - 0b00000000, - 0b11100000, - 0b00100000, - 0b00100000, - 0b00100000, - - /* Character (0x0d): - width=5 - +--------+ - | | - | | - | | - | *** | - | * | - | * | - | * | - +--------+ */ - 0b00000000|CHAR5x7_WIDTH_5px, - 0b00000000, - 0b00000000, - 0b00111000, - 0b00100000, - 0b00100000, - 0b00100000, - - /* Character (0x0e): - width=5 - +--------+ - | * | - | * | - | * | - | *** | - | | - | | - | | - +--------+ */ - 0b00100000|CHAR5x7_WIDTH_5px, - 0b00100000, - 0b00100000, - 0b00111000, - 0b00000000, - 0b00000000, - 0b00000000, - - /* Character (0x0f): - width=5 - +--------+ - | * | - | * | - | * | - |***** | - | * | - | * | - | * | - +--------+ */ - 0b00100000|CHAR5x7_WIDTH_5px, - 0b00100000, - 0b00100000, - 0b11111000, - 0b00100000, - 0b00100000, - 0b00100000, - - /* Character (0x10): - width=5 - +--------+ - | | - |***** | - | | - | | - | | - | | - | | - +--------+ */ - 0b00000000|CHAR5x7_WIDTH_5px, - 0b11111000, - 0b00000000, - 0b00000000, - 0b00000000, - 0b00000000, - 0b00000000, - - /* Character (0x11): - width=5 - +--------+ - | | - | | - |***** | - | | - | | - | | - | | - +--------+ */ - 0b00000000|CHAR5x7_WIDTH_5px, - 0b00000000, - 0b11111000, - 0b00000000, - 0b00000000, - 0b00000000, - 0b00000000, - - /* Character (0x12): - width=5 - +--------+ - | | - | | - | | - |***** | - | | - | | - | | - +--------+ */ - 0b00000000|CHAR5x7_WIDTH_5px, - 0b00000000, - 0b00000000, - 0b11111000, - 0b00000000, - 0b00000000, - 0b00000000, - - /* Character (0x13): - width=5 - +--------+ - | | - | | - | | - | | - |***** | - | | - | | - +--------+ */ - 0b00000000|CHAR5x7_WIDTH_5px, - 0b00000000, - 0b00000000, - 0b00000000, - 0b11111000, - 0b00000000, - 0b00000000, - - /* Character (0x14): - width=5 - +--------+ - | | - | | - | | - | | - | | - |***** | - | | - +--------+ */ - 0b00000000|CHAR5x7_WIDTH_5px, - 0b00000000, - 0b00000000, - 0b00000000, - 0b00000000, - 0b11111000, - 0b00000000, - - /* Character (0x15): - width=5 - +--------+ - | * | - | * | - | * | - | *** | - | * | - | * | - | * | - +--------+ */ - 0b00100000|CHAR5x7_WIDTH_5px, - 0b00100000, - 0b00100000, - 0b00111000, - 0b00100000, - 0b00100000, - 0b00100000, - - /* Character (0x16): - width=5 - +--------+ - | ** | - | *** | - | *** | - | *** | - | *** | - | *** | - | ** | - +--------+ */ - 0b00100000|CHAR5x7_WIDTH_5px, - 0b00100000, - 0b00100000, - 0b11100000, - 0b00100000, - 0b00100000, - 0b00100000, - - /* Character (0x17): - width=6 - +--------+ - | | - |** | - |**** | - |****** | - |**** | - |** | - | | - +--------+ */ - 0b00000000|CHAR5x7_WIDTH_6px, - 0b11000000, - 0b11110000, - 0b00011100, - 0b11110000, - 0b11000000, - 0b00000000, - - /* Character (0x18): - width=5 - +--------+ - |* | - |** | - |*** | - |**** | - |*** | - |** | - |* | - +--------+ */ - 0b10000000|CHAR5x7_WIDTH_4px, - 0b11000000, - 0b11100000, - 0b11110000, - 0b11100000, - 0b11000000, - 0b10000000, - - /* Character (0x19): - width=7 - +--------+ - | | - | ** ** | - |* ** * | - |* * * | - |* ** * | - | ** ** | - | | - +--------+ */ - 0b00000000|CHAR5x7_WIDTH_7px, - 0b01101100, - 0b10110010, - 0b10010010, - 0b10011010, - 0b01101100, - 0b00000000, - - /* Character (0x1a): - width=6 - +--------+ - | | - | * | - | * | - |***** | - | * | - | * | - | | - +--------+ */ - 0b00000000|CHAR5x7_WIDTH_6px, - 0b00100000, - 0b01000000, - 0b11111000, - 0b01000000, - 0b00100000, - 0b00000000, - - /* Character (0x1b): - width=6 - +--------+ - | | - | * | - | * | - |***** | - | * | - | * | - | | - +--------+ */ - 0b00000000|CHAR5x7_WIDTH_6px, - 0b00100000, - 0b00010000, - 0b11111000, - 0b00010000, - 0b00100000, - 0b00000000, - - /* Character (0x1c): - width=6 - +--------+ - | | - |***** | - | * * | - | * * | - | * * | - | * * | - |* ** | - +--------+ */ - 0b00000000|CHAR5x7_WIDTH_6px, - 0b11111000, - 0b01010000, - 0b01010000, - 0b01010000, - 0b01010000, - 0b10011000, - - /* Character (0x1d): - width=6 - +--------+ - | | - | | - |* * | - |* * | - |** ** | - |* * * | - |* | - +--------+ */ - 0b00000000|CHAR5x7_WIDTH_6px, - 0b00000000, - 0b10001000, - 0b10001000, - 0b11011000, - 0b10101000, - 0b10000000, - - /* Character (0x1e): - width=6 - +--------+ - | | - | *** | - |* * | - |* * | - |* * | - | * * | - |** ** | - +--------+ */ - 0b00000000|CHAR5x7_WIDTH_6px, - 0b01110000, - 0b10001000, - 0b10001000, - 0b10001000, - 0b01010000, - 0b11011000, - - /* Character (0x1f): - width=5 - +--------+ - | ** | - |* * | - |* * | - | ** | - | | - | | - | | - +--------+ */ - 0b01100000|CHAR5x7_WIDTH_5px, - 0b10010000, - 0b10010000, - 0b01100000, - 0b00000000, - 0b00000000, - 0b00000000, - - /* Character (0x20): ' ' - width=3 - +--------+ - | | - | | - | | - | | - | | - | | - | | - +--------+ */ - 0b00000000|CHAR5x7_WIDTH_4px, - 0b00000000, - 0b00000000, - 0b00000000, - 0b00000000, - 0b00000000, - 0b00000000, - - /* Character (0x21): '!' - width=3 - +--------+ - | * | - | * | - | * | - | * | - | * | - | | - | * | - +--------+ */ - 0b01000000|CHAR5x7_WIDTH_3px, - 0b01000000, - 0b01000000, - 0b01000000, - 0b01000000, - 0b00000000, - 0b01000000, - - /* Character (0x22): '"' - width=5 - +--------+ - | * * | - | * * | - | * * | - | | - | | - | | - | | - +--------+ */ - 0b01010000, - 0b01010000, - 0b01010000, - 0b00000000, - 0b00000000, - 0b00000000, - 0b00000000, - - /* Character (0x23): '#' - width=5 - +--------+ - | * * | - | * * | - |***** | - | * * | - |***** | - | * * | - | * * | - +--------+ */ - 0b01010000|CHAR5x7_WIDTH_6px, - 0b01010000, - 0b11111000, - 0b01010000, - 0b11111000, - 0b01010000, - 0b01010000, - - /* Character (0x24): '$' - width=5 - +--------+ - | * | - | **** | - |* * | - | *** | - | * * | - |**** | - | * | - +--------+ */ - 0b00100000|CHAR5x7_WIDTH_6px, - 0b01111000, - 0b10100000, - 0b01110000, - 0b00101000, - 0b11110000, - 0b00100000, - - /* Character (0x25): '%' - width=6 - +--------+ - |** | - |** * | - | * | - | * | - | * | - |* ** | - | ** | - +--------+ */ - 0b11000000|CHAR5x7_WIDTH_6px, - 0b11001000, - 0b00010000, - 0b00100000, - 0b01000000, - 0b10011000, - 0b00011000, - - /* Character (0x26): '&' - width=5 - +--------+ - | | - | * | - | * * | - | ** | - |* * * | - |* * | - | ** * | - +--------+ */ - 0b00000000|CHAR5x7_WIDTH_6px, - 0b00100000, - 0b01010000, - 0b01100000, - 0b10101000, - 0b10010000, - 0b01101000, - - /* Character (0x27): ''' - width=4 - +--------+ - | ** | - | * | - |* | - | | - | | - | | - | | - +--------+ */ - 0b01100000|CHAR5x7_WIDTH_4px, - 0b01000000, - 0b10000000, - 0b00000000, - 0b00000000, - 0b00000000, - 0b00000000, - - /* Character (0x28): '(' - width=4 - +--------+ - | * | - | * | - |* | - |* | - |* | - | * | - | * | - +--------+ */ - 0b00100000|CHAR5x7_WIDTH_4px, - 0b01000000, - 0b10000000, - 0b10000000, - 0b10000000, - 0b01000000, - 0b00100000, - - /* Character (0x29): ')' - width=5 - +--------+ - |* | - | * | - | * | - | * | - | * | - | * | - |* | - +--------+ */ - 0b10000000|CHAR5x7_WIDTH_4px, - 0b01000000, - 0b00100000, - 0b00100000, - 0b00100000, - 0b01000000, - 0b10000000, - - /* Character (0x2a): '*' - width=6 - +--------+ - | | - | * | - |* * * | - | *** | - |* * * | - | * | - | | - +--------+ */ - 0b00000000|CHAR5x7_WIDTH_6px, - 0b00100000, - 0b10101000, - 0b01110000, - 0b10101000, - 0b00100000, - 0b00000000, - - /* Character (0x2b): '+' - width=6 - +--------+ - | | - | * | - | * | - |***** | - | * | - | * | - | | - +--------+ */ - 0b00000000|CHAR5x7_WIDTH_6px, - 0b00100000, - 0b00100000, - 0b11111000, - 0b00100000, - 0b00100000, - 0b00000000, - - /* Character (0x2c): ',' - width=4 - +--------+ - | | - | | - | | - | | - |** | - | * | - |* | - +--------+ */ - 0b00000000|CHAR5x7_WIDTH_3px, - 0b00000000, - 0b00000000, - 0b00000000, - 0b11000000, - 0b01000000, - 0b10000000, - - /* Character (0x2d): '-' - width=5 - +--------+ - | | - | | - | | - |**** | - | | - | | - | | - +--------+ */ - 0b00000000|CHAR5x7_WIDTH_5px, - 0b00000000, - 0b00000000, - 0b11110000, - 0b00000000, - 0b00000000, - 0b00000000, - - /* Character (0x2e): '.' - width=3 - +--------+ - | | - | | - | | - | | - | | - |** | - |** | - +--------+ */ - 0b00000000|CHAR5x7_WIDTH_3px, - 0b00000000, - 0b00000000, - 0b00000000, - 0b00000000, - 0b11000000, - 0b11000000, - - /* Character (0x2f): '/' - width=4 - +--------+ - | * | - | * | - | * | - | * | - | * | - |* | - |* | - +--------+ */ - 0b00100000|CHAR5x7_WIDTH_4px, - 0b00100000, - 0b01000000, - 0b01000000, - 0b01000000, - 0b10000000, - 0b10000000, - - /* Character (0x30): '0' - width=5 - +--------+ - | ** | - |* * | - |* ** | - |** * | - |* * | - |* * | - | ** | - +--------+ */ - 0b01100000|CHAR5x7_WIDTH_5px, - 0b10010000, - 0b10110000, - 0b11010000, - 0b10010000, - 0b10010000, - 0b01100000, - - /* Character (0x31): '1' - width=5 - +--------+ - | * | - | ** | - | * | - | * | - | * | - | * | - | *** | - +--------+ */ - 0b00100000|CHAR5x7_WIDTH_5px, - 0b01100000, - 0b00100000, - 0b00100000, - 0b00100000, - 0b00100000, - 0b01110000, - - /* Character (0x32): '2' - width=5 - +--------+ - | ** | - |* * | - | * | - | * | - | * | - |* | - |**** | - +--------+ */ - 0b01100000|CHAR5x7_WIDTH_5px, - 0b10010000, - 0b00010000, - 0b00100000, - 0b01000000, - 0b10000000, - 0b11110000, - - /* Character (0x33): '3' - width=5 - +--------+ - | ** | - |* * | - | * | - | ** | - | * | - |* * | - | ** | - +--------+ */ - 0b01100000|CHAR5x7_WIDTH_5px, - 0b10010000, - 0b00010000, - 0b01100000, - 0b00010000, - 0b10010000, - 0b01100000, - - /* Character (0x34): '4' - width=5 - +--------+ - |* * | - |* * | - |* * | - |* * | - |**** | - | * | - | * | - +--------+ */ - 0b10010000|CHAR5x7_WIDTH_5px, - 0b10010000, - 0b10010000, - 0b10010000, - 0b11110000, - 0b00010000, - 0b00010000, - - /* Character (0x35): '5' - width=5 - +--------+ - |**** | - |* | - |*** | - | * | - | * | - |* * | - | ** | - +--------+ */ - 0b11110000|CHAR5x7_WIDTH_5px, - 0b10000000, - 0b11100000, - 0b00010000, - 0b00010000, - 0b10010000, - 0b01100000, - - /* Character (0x36): '6' - width=5 - +--------+ - | ** | - |* * | - |* | - |*** | - |* * | - |* * | - | ** | - +--------+ */ - 0b01100000|CHAR5x7_WIDTH_5px, - 0b10010000, - 0b10000000, - 0b11100000, - 0b10010000, - 0b10010000, - 0b01100000, - - /* Character (0x37): '7' - width=5 - +--------+ - |**** | - | * | - | * | - | * | - | * | - | * | - | * | - +--------+ */ - 0b11110000|CHAR5x7_WIDTH_5px, - 0b00010000, - 0b00100000, - 0b00100000, - 0b01000000, - 0b01000000, - 0b01000000, - - /* Character (0x38): '8' - width=5 - +--------+ - | ** | - |* * | - |* * | - | ** | - |* * | - |* * | - | ** | - +--------+ */ - 0b01100000|CHAR5x7_WIDTH_5px, - 0b10010000, - 0b10010000, - 0b01100000, - 0b10010000, - 0b10010000, - 0b01100000, - - /* Character (0x39): '9' - width=5 - +--------+ - | ** | - |* * | - |* * | - | *** | - | * | - |* * | - | ** | - +--------+ */ - 0b01100000|CHAR5x7_WIDTH_5px, - 0b10010000, - 0b10010000, - 0b01110000, - 0b00010000, - 0b10010000, - 0b01100000, - - /* Character (0x3a): ':' - width=3 - +--------+ - | | - |** | - |** | - | | - |** | - |** | - | | - +--------+ */ - 0b00000000|CHAR5x7_WIDTH_4px, - 0b11000000, - 0b11000000, - 0b00000000, - 0b11000000, - 0b11000000, - 0b00000000, - - /* Character (0x3b): ';' - width=4 - +--------+ - | | - | ** | - | ** | - | | - | ** | - | * | - |* | - +--------+ */ - 0b00000000|CHAR5x7_WIDTH_4px, - 0b01100000, - 0b01100000, - 0b00000000, - 0b01100000, - 0b01000000, - 0b10000000, - - /* Character (0x3c): '<' - width=5 - +--------+ - | | - | * | - | * | - |* | - | * | - | * | - | | - +--------+ */ - 0b00000000|CHAR5x7_WIDTH_5px, - 0b00100000, - 0b01000000, - 0b10000000, - 0b01000000, - 0b00100000, - 0b00000000, - - /* Character (0x3d): '=' - width=5 - +--------+ - | | - | | - |**** | - | | - |**** | - | | - | | - +--------+ */ - 0b00000000|CHAR5x7_WIDTH_5px, - 0b00000000, - 0b11110000, - 0b00000000, - 0b11110000, - 0b00000000, - 0b00000000, - - /* Character (0x3e): '>' - width=5 - +--------+ - | | - |* | - | * | - | * | - | * | - |* | - | | - +--------+ */ - 0b00000000|CHAR5x7_WIDTH_5px, - 0b10000000, - 0b01000000, - 0b00100000, - 0b01000000, - 0b10000000, - 0b00000000, - - /* Character (0x3f): '?' - width=5 - +--------+ - | ** | - |* * | - | * | - | * | - | * | - | | - | * | - +--------+ */ - 0b01100000|CHAR5x7_WIDTH_5px, - 0b10010000, - 0b00010000, - 0b00100000, - 0b01000000, - 0b00000000, - 0b01000000, - - /* Character (0x40): '@' - width=5 - +--------+ - | ** | - |* * | - |* ** | - |* ** | - |* | - |* | - | *** | - +--------+ */ - 0b01100000|CHAR5x7_WIDTH_5px, - 0b10010000, - 0b10110000, - 0b10110000, - 0b10000000, - 0b10000000, - 0b01110000, - - /* Character (0x41): 'A' - width=5 - +--------+ - | ** | - |* * | - |* * | - |* * | - |**** | - |* * | - |* * | - +--------+ */ - 0b01100000|CHAR5x7_WIDTH_5px, - 0b10010000, - 0b10010000, - 0b10010000, - 0b11110000, - 0b10010000, - 0b10010000, - - /* Character (0x42): 'B' - width=5 - +--------+ - |*** | - |* * | - |* * | - |*** | - |* * | - |* * | - |*** | - +--------+ */ - 0b11100000|CHAR5x7_WIDTH_5px, - 0b10010000, - 0b10010000, - 0b11100000, - 0b10010000, - 0b10010000, - 0b11100000, - - /* Character (0x43): 'C' - width=5 - +--------+ - | ** | - |* * | - |* | - |* | - |* | - |* * | - | ** | - +--------+ */ - 0b01100000|CHAR5x7_WIDTH_5px, - 0b10010000, - 0b10000000, - 0b10000000, - 0b10000000, - 0b10010000, - 0b01100000, - - /* Character (0x44): 'D' - width=5 - +--------+ - |*** | - |* * | - |* * | - |* * | - |* * | - |* * | - |*** | - +--------+ */ - 0b11100000|CHAR5x7_WIDTH_5px, - 0b10010000, - 0b10010000, - 0b10010000, - 0b10010000, - 0b10010000, - 0b11100000, - - /* Character (0x45): 'E' - width=5 - +--------+ - |**** | - |* | - |* | - |*** | - |* | - |* | - |**** | - +--------+ */ - 0b11110000|CHAR5x7_WIDTH_5px, - 0b10000000, - 0b10000000, - 0b11100000, - 0b10000000, - 0b10000000, - 0b11110000, - - /* Character (0x46): 'F' - width=5 - +--------+ - |**** | - |* | - |* | - |*** | - |* | - |* | - |* | - +--------+ */ - 0b11110000|CHAR5x7_WIDTH_5px, - 0b10000000, - 0b10000000, - 0b11100000, - 0b10000000, - 0b10000000, - 0b10000000, - - /* Character (0x47): 'G' - width=5 - +--------+ - | ** | - |* * | - |* | - |* ** | - |* * | - |* * | - | *** | - +--------+ */ - 0b01100000|CHAR5x7_WIDTH_5px, - 0b10010000, - 0b10000000, - 0b10110000, - 0b10010000, - 0b10010000, - 0b01110000, - - /* Character (0x48): 'H' - width=5 - +--------+ - |* * | - |* * | - |* * | - |**** | - |* * | - |* * | - |* * | - +--------+ */ - 0b10010000|CHAR5x7_WIDTH_5px, - 0b10010000, - 0b10010000, - 0b11110000, - 0b10010000, - 0b10010000, - 0b10010000, - - /* Character (0x49): 'I' - width=4 - +--------+ - |*** | - | * | - | * | - | * | - | * | - | * | - |*** | - +--------+ */ - 0b11100000|CHAR5x7_WIDTH_4px, - 0b01000000, - 0b01000000, - 0b01000000, - 0b01000000, - 0b01000000, - 0b11100000, - - /* Character (0x4a): 'J' - width=5 - +--------+ - | *** | - | * | - | * | - | * | - | * | - |* * | - | ** | - +--------+ */ - 0b01110000|CHAR5x7_WIDTH_5px, - 0b00010000, - 0b00010000, - 0b00010000, - 0b00010000, - 0b10010000, - 0b01100000, - - /* Character (0x4b): 'K' - width=5 - +--------+ - |* * | - |* * | - |* * | - |** | - |* * | - |* * | - |* * | - +--------+ */ - 0b10010000|CHAR5x7_WIDTH_5px, - 0b10010000, - 0b10010000, - 0b11100000, - 0b10010000, - 0b10010000, - 0b10010000, - - /* Character (0x4c): 'L' - width=5 - +--------+ - |* | - |* | - |* | - |* | - |* | - |* | - |**** | - +--------+ */ - 0b10000000|CHAR5x7_WIDTH_5px, - 0b10000000, - 0b10000000, - 0b10000000, - 0b10000000, - 0b10000000, - 0b11110000, - - /* Character (0x4d): 'M' - width=6 - +--------+ - |* * | - |** ** | - |* * * | - |* * * | - |* * | - |* * | - |* * | - +--------+ */ - 0b10001000|CHAR5x7_WIDTH_6px, - 0b11011000, - 0b10101000, - 0b10101000, - 0b10001000, - 0b10001000, - 0b10001000, - - /* Character (0x4e): 'N' - width=5 - +--------+ - |* * | - |* * | - |** * | - |* ** | - |* * | - |* * | - |* * | - +--------+ */ - 0b10010000|CHAR5x7_WIDTH_5px, - 0b10010000, - 0b11010000, - 0b10110000, - 0b10010000, - 0b10010000, - 0b10010000, - - /* Character (0x4f): 'O' - width=5 - +--------+ - | ** | - |* * | - |* * | - |* * | - |* * | - |* * | - | ** | - +--------+ */ - 0b01100000|CHAR5x7_WIDTH_5px, - 0b10010000, - 0b10010000, - 0b10010000, - 0b10010000, - 0b10010000, - 0b01100000, - - /* Character (0x50): 'P' - width=5 - +--------+ - |*** | - |* * | - |* * | - |*** | - |* | - |* | - |* | - +--------+ */ - 0b11100000|CHAR5x7_WIDTH_5px, - 0b10010000, - 0b10010000, - 0b11100000, - 0b10000000, - 0b10000000, - 0b10000000, - - /* Character (0x51): 'Q' - width=5 - +--------+ - | ** | - |* * | - |* * | - |* * | - |* * | - |* * | - | * * | - +--------+ */ - 0b01100000|CHAR5x7_WIDTH_5px, - 0b10010000, - 0b10010000, - 0b10010000, - 0b10010000, - 0b10100000, - 0b01010000, - - /* Character (0x52): 'R' - width=5 - +--------+ - |*** | - |* * | - |* * | - |*** | - |* * | - |* * | - |* * | - +--------+ */ - 0b11100000|CHAR5x7_WIDTH_5px, - 0b10010000, - 0b10010000, - 0b11100000, - 0b10010000, - 0b10010000, - 0b10010000, - - /* Character (0x53): 'S' - width=5 - +--------+ - | ** | - |* * | - |* | - | ** | - | * | - |* * | - | ** | - +--------+ */ - 0b01100000|CHAR5x7_WIDTH_5px, - 0b10010000, - 0b10000000, - 0b01100000, - 0b00010000, - 0b10010000, - 0b01100000, - - /* Character (0x54): 'T' - width=6 - +--------+ - |***** | - | * | - | * | - | * | - | * | - | * | - | * | - +--------+ */ - 0b11111000|CHAR5x7_WIDTH_6px, - 0b00100000, - 0b00100000, - 0b00100000, - 0b00100000, - 0b00100000, - 0b00100000, - - /* Character (0x55): 'U' - width=5 - +--------+ - |* * | - |* * | - |* * | - |* * | - |* * | - |* * | - | *** | - +--------+ */ - 0b10010000|CHAR5x7_WIDTH_5px, - 0b10010000, - 0b10010000, - 0b10010000, - 0b10010000, - 0b10010000, - 0b01110000, - - /* Character (0x56): 'V' - width=5 - +--------+ - |* * | - |* * | - |* * | - |* * | - |* * | - | ** | - | ** | - +--------+ */ - 0b10010000|CHAR5x7_WIDTH_5px, - 0b10010000, - 0b10010000, - 0b10010000, - 0b10010000, - 0b01100000, - 0b01100000, - - /* Character (0x57): 'W' - width=6 - +--------+ - |* * | - |* * | - |* * | - |* * * | - |* * * | - |* * * | - | * * | - +--------+ */ - 0b10001000|CHAR5x7_WIDTH_6px, - 0b10001000, - 0b10001000, - 0b10101000, - 0b10101000, - 0b10101000, - 0b01010000, - - /* Character (0x58): 'X' - width=6 - +--------+ - |* * | - |* * | - | * * | - | * | - | * * | - |* * | - |* * | - +--------+ */ - 0b10001000|CHAR5x7_WIDTH_6px, - 0b10001000, - 0b01010000, - 0b00100000, - 0b01010000, - 0b10001000, - 0b10001000, - - /* Character (0x59): 'Y' - width=6 - +--------+ - |* * | - |* * | - |* * | - | * * | - | * | - | * | - | * | - +--------+ */ - 0b10001000|CHAR5x7_WIDTH_6px, - 0b10001000, - 0b10001000, - 0b01010000, - 0b00100000, - 0b00100000, - 0b00100000, - - /* Character (0x5a): 'Z' - width=5 - +--------+ - |**** | - | * | - | * | - | * | - |* | - |* | - |**** | - +--------+ */ - 0b11110000|CHAR5x7_WIDTH_5px, - 0b00010000, - 0b00100000, - 0b01000000, - 0b10000000, - 0b10000000, - 0b11110000, - - /* Character (0x5b): '[' - width=4 - +--------+ - |*** | - |* | - |* | - |* | - |* | - |* | - |*** | - +--------+ */ - 0b11100000|CHAR5x7_WIDTH_4px, - 0b10000000, - 0b10000000, - 0b10000000, - 0b10000000, - 0b10000000, - 0b11100000, - - /* Character (0x5c): '\' - width=4 - +--------+ - |* | - |* | - | * | - | * | - | * | - | * | - | * | - +--------+ */ - 0b10000000|CHAR5x7_WIDTH_4px, - 0b10000000, - 0b01000000, - 0b01000000, - 0b01000000, - 0b00100000, - 0b00100000, - - /* Character (0x5d): ']' - width=4 - +--------+ - |*** | - | * | - | * | - | * | - | * | - | * | - |*** | - +--------+ */ - 0b11100000|CHAR5x7_WIDTH_4px, - 0b00100000, - 0b00100000, - 0b00100000, - 0b00100000, - 0b00100000, - 0b11100000, - - /* Character (0x5e): '^' - width=4 - +--------+ - | * | - |* * | - | | - | | - | | - | | - | | - +--------+ */ - 0b01000000|CHAR5x7_WIDTH_4px, - 0b10100000, - 0b00000000, - 0b00000000, - 0b00000000, - 0b00000000, - 0b00000000, - - /* Character (0x5f): '_' - width=5 - +--------+ - | | - | | - | | - | | - | | - | | - |***** | - +--------+ */ - 0b00000000|CHAR5x7_WIDTH_5px, - 0b00000000, - 0b00000000, - 0b00000000, - 0b00000000, - 0b00000000, - 0b11111000, - - /* Character (0x60): '`' - width=4 - +--------+ - |** | - | * | - | * | - | | - | | - | | - | | - +--------+ */ - 0b11000000|CHAR5x7_WIDTH_4px, - 0b01000000, - 0b00100000, - 0b00000000, - 0b00000000, - 0b00000000, - 0b00000000, - - /* Character (0x61): 'a' - width=5 - +--------+ - | | - | | - | *** | - |* * | - |* * | - |* ** | - | * * | - +--------+ */ - 0b00000000|CHAR5x7_WIDTH_5px, - 0b00000000, - 0b01110000, - 0b10010000, - 0b10010000, - 0b10110000, - 0b01010000, - - /* Character (0x62): 'b' - width=5 - +--------+ - |* | - |* | - |* * | - |** * | - |* * | - |* * | - |*** | - +--------+ */ - 0b10000000|CHAR5x7_WIDTH_5px, - 0b10000000, - 0b10100000, - 0b11010000, - 0b10010000, - 0b10010000, - 0b11100000, - - /* Character (0x63): 'c' - width=5 - +--------+ - | | - | | - | *** | - |* | - |* | - |* | - | *** | - +--------+ */ - 0b00000000|CHAR5x7_WIDTH_5px, - 0b00000000, - 0b01110000, - 0b10000000, - 0b10000000, - 0b10000000, - 0b01110000, - - /* Character (0x64): 'd' - width=5 - +--------+ - | * | - | * | - | * * | - |* ** | - |* * | - |* * | - | *** | - +--------+ */ - 0b00010000|CHAR5x7_WIDTH_5px, - 0b00010000, - 0b01010000, - 0b10110000, - 0b10010000, - 0b10010000, - 0b01110000, - - /* Character (0x65): 'e' - width=5 - +--------+ - | | - | | - | ** | - |* * | - |**** | - |* | - | *** | - +--------+ */ - 0b00000000|CHAR5x7_WIDTH_5px, - 0b00000000, - 0b01100000, - 0b10010000, - 0b11110000, - 0b10000000, - 0b01110000, - - /* Character (0x66): 'f' - width=5 - +--------+ - | * | - | * * | - | * | - |*** | - | * | - | * | - | * | - +--------+ */ - 0b00100000|CHAR5x7_WIDTH_5px, - 0b01010000, - 0b01000000, - 0b11100000, - 0b01000000, - 0b01000000, - 0b01000000, - - /* Character (0x67): 'g' - width=5 - +--------+ - | | - | | - | *** | - |* * | - | *** | - | * | - | ** | - +--------+ */ - 0b00000000|CHAR5x7_WIDTH_5px, - 0b00000000, - 0b01110000, - 0b10010000, - 0b01110000, - 0b00010000, - 0b01100000, - - /* Character (0x68): 'h' - width=5 - +--------+ - |* | - |* | - |* * | - |** * | - |* * | - |* * | - |* * | - +--------+ */ - 0b10000000|CHAR5x7_WIDTH_5px, - 0b10000000, - 0b10100000, - 0b11010000, - 0b10010000, - 0b10010000, - 0b10010000, - - /* Character (0x69): 'i' - width=4 - +--------+ - | * | - | | - |** | - | * | - | * | - | * | - |*** | - +--------+ */ - 0b01000000|CHAR5x7_WIDTH_4px, - 0b00000000, - 0b11000000, - 0b01000000, - 0b01000000, - 0b01000000, - 0b11100000, - - /* Character (0x6a): - width=4 - +--------+ - | * | - | | - | * | - | * | - | * | - |* * | - | * | - +--------+ */ - 0b00100000|CHAR5x7_WIDTH_4px, - 0b00000000, - 0b00100000, - 0b00100000, - 0b00100000, - 0b10100000, - 0b01000000, - - /* Character (0x6b): 'k' - width=5 - +--------+ - |* | - |* | - |* * | - |* * | - |** | - |* * | - |* * | - +--------+ */ - 0b10000000|CHAR5x7_WIDTH_5px, - 0b10000000, - 0b10010000, - 0b10100000, - 0b11000000, - 0b10100000, - 0b10010000, - - /* Character (0x6c): 'l' - width=4 - +--------+ - |** | - | * | - | * | - | * | - | * | - | * | - |*** | - +--------+ */ - 0b11000000|CHAR5x7_WIDTH_4px, - 0b01000000, - 0b01000000, - 0b01000000, - 0b01000000, - 0b01000000, - 0b11100000, - - /* Character (0x6d): 'm' - width=6 - +--------+ - | | - | | - |**** | - |* * * | - |* * * | - |* * * | - |* * * | - +--------+ */ - 0b00000000|CHAR5x7_WIDTH_6px, - 0b00000000, - 0b11110000, - 0b10101000, - 0b10101000, - 0b10101000, - 0b10101000, - - /* Character (0x6e): 'n' - width=5 - +--------+ - | | - | | - |* * | - |** * | - |* * | - |* * | - |* * | - +--------+ */ - 0b00000000|CHAR5x7_WIDTH_5px, - 0b00000000, - 0b10100000, - 0b11010000, - 0b10010000, - 0b10010000, - 0b10010000, - - /* Character (0x6f): 'o' - width=5 - +--------+ - | | - | | - | ** | - |* * | - |* * | - |* * | - | ** | - +--------+ */ - 0b00000000|CHAR5x7_WIDTH_5px, - 0b00000000, - 0b01100000, - 0b10010000, - 0b10010000, - 0b10010000, - 0b01100000, - - /* Character (0x70): 'p' - width=5 - +--------+ - | | - | | - |*** | - |* * | - |* * | - |*** | - |* | - +--------+ */ - 0b00000000|CHAR5x7_WIDTH_5px, - 0b00000000, - 0b11100000, - 0b10010000, - 0b10010000, - 0b11100000, - 0b10000000, - - /* Character (0x71): 'q' - width=5 - +--------+ - | | - | | - | *** | - |* * | - |* * | - | *** | - | * | - +--------+ */ - 0b00000000|CHAR5x7_WIDTH_5px, - 0b00000000, - 0b01110000, - 0b10010000, - 0b10010000, - 0b01110000, - 0b00010000, - - /* Character (0x72): 'r' - width=5 - +--------+ - | | - | | - |* * | - |** * | - |* | - |* | - |* | - +--------+ */ - 0b00000000|CHAR5x7_WIDTH_5px, - 0b00000000, - 0b10100000, - 0b11010000, - 0b10000000, - 0b10000000, - 0b10000000, - - /* Character (0x73): 's' - width=5 - +--------+ - | | - | | - | *** | - |* | - | ** | - | * | - |*** | - +--------+ */ - 0b00000000|CHAR5x7_WIDTH_5px, - 0b00000000, - 0b01110000, - 0b10000000, - 0b01100000, - 0b00010000, - 0b11100000, - - /* Character (0x74): 't' - width=5 - +--------+ - | * | - | * | - |*** | - | * | - | * | - | * | - | ** | - +--------+ */ - 0b01000000|CHAR5x7_WIDTH_5px, - 0b01000000, - 0b11100000, - 0b01000000, - 0b01000000, - 0b01000000, - 0b00110000, - - /* Character (0x75): 'u' - width=5 - +--------+ - | | - | | - |* * | - |* * | - |* * | - |* ** | - | * * | - +--------+ */ - 0b00000000|CHAR5x7_WIDTH_5px, - 0b00000000, - 0b10010000, - 0b10010000, - 0b10010000, - 0b10110000, - 0b01010000, - - /* Character (0x76): 'v' - width=5 - +--------+ - | | - | | - |* * | - |* * | - |* * | - | ** | - | ** | - +--------+ */ - 0b00000000|CHAR5x7_WIDTH_5px, - 0b00000000, - 0b10010000, - 0b10010000, - 0b10010000, - 0b01100000, - 0b01100000, - - /* Character (0x77): 'w' - width=6 - +--------+ - | | - | | - |* * | - |* * | - |* * * | - |* * * | - | * * | - +--------+ */ - 0b00000000|CHAR5x7_WIDTH_6px, - 0b00000000, - 0b10001000, - 0b10001000, - 0b10101000, - 0b10101000, - 0b01010000, - - /* Character (0x78): 'x' - width=5 - +--------+ - | | - | | - |* * | - |* * | - | ** | - |* * | - |* * | - +--------+ */ - 0b00000000|CHAR5x7_WIDTH_5px, - 0b00000000, - 0b10010000, - 0b10010000, - 0b01100000, - 0b10010000, - 0b10010000, - - /* Character (0x79): 'y' - width=5 - +--------+ - | | - | | - |* * | - |* * | - | *** | - | * | - |*** | - +--------+ */ - 0b00000000|CHAR5x7_WIDTH_5px, - 0b00000000, - 0b10010000, - 0b10010000, - 0b01110000, - 0b00010000, - 0b11100000, - - /* Character (0x7a): 'z' - width=5 - +--------+ - | | - | | - |**** | - | * | - | * | - |* | - |**** | - +--------+ */ - 0b00000000|CHAR5x7_WIDTH_5px, - 0b00000000, - 0b11110000, - 0b00100000, - 0b01000000, - 0b10000000, - 0b11110000, - - /* Character (0x7b): '{' - width=5 - +--------+ - | * | - | * | - | * | - |* | - | * | - | * | - | * | - +--------+ */ - 0b00100000|CHAR5x7_WIDTH_4px, - 0b01000000, - 0b01000000, - 0b10000000, - 0b01000000, - 0b01000000, - 0b00100000, - - /* Character (0x7c): '|' - width=5 - +--------+ - | * | - | * | - | * | - | * | - | * | - | * | - | * | - +--------+ */ - 0b00100000|CHAR5x7_WIDTH_4px, - 0b00100000, - 0b00100000, - 0b00100000, - 0b00100000, - 0b00100000, - 0b00100000, - - /* Character (0x7d): '}' - width=5 - +--------+ - |* | - | * | - | * | - | * | - | * | - | * | - |* | - +--------+ */ - 0b10000000|CHAR5x7_WIDTH_4px, - 0b01000000, - 0b01000000, - 0b00100000, - 0b01000000, - 0b01000000, - 0b10000000, - - /* Character (0x7e): '~' - width=5 - +--------+ - | | - | | - | * * | - |* * | - | | - | | - | | - +--------+ */ - 0b00000000|CHAR5x7_WIDTH_5px, - 0b00000000, - 0b01010000, - 0b10100000, - 0b00000000, - 0b00000000, - 0b00000000, -}; +/* + * Font size 5x7 pixels + * most font glyph have width 5 pixels + */ + +#include + +/* + * Check 1 byte of char bitmap data for get width + */ + +#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 +#define FONT_GET_HEIGHT 7 + +#define CHAR5x7_WIDTH_1px 0x07 +#define CHAR5x7_WIDTH_2px 0x06 +#define CHAR5x7_WIDTH_3px 0x05 +#define CHAR5x7_WIDTH_4px 0x04 +#define CHAR5x7_WIDTH_5px 0x03 +#define CHAR5x7_WIDTH_6px 0x02 +#define CHAR5x7_WIDTH_7px 0x01 +#define CHAR5x7_WIDTH_8px 0x00 + +/* Font character bitmap data. */ +const uint8_t x5x7_bits[127*7] = +{ + + /* Character (0x00): + width=5 + +--------+ + |**** | + |**** | + |**** | + |**** | + |**** | + |**** | + | | + +--------+ */ + 0b11110000|CHAR5x7_WIDTH_5px, + 0b11110000, + 0b11110000, + 0b11110000, + 0b11110000, + 0b11110000, + 0b00000000, + + /* Character (0x01): + width=5 + +--------+ + | | + | * | + | *** | + |***** | + | *** | + | * | + | | + +--------+ */ + 0b00000000|CHAR5x7_WIDTH_5px, + 0b00100000, + 0b01110000, + 0b11111000, + 0b01110000, + 0b00100000, + 0b00000000, + + /* Character (0x02): + width=5 + +--------+ + | * * | + |* * * | + | * * | + |* * * | + | * * | + |* * * | + | * * | + +--------+ */ + 0b01010000|CHAR5x7_WIDTH_5px, + 0b10101000, + 0b01010000, + 0b10101000, + 0b01010000, + 0b10101000, + 0b01010000, + + /* Character (0x03): + width=5 + +--------+ + |* * | + |*** | + |* * | + |* * | + | *** | + | * | + | * | + +--------+ */ + 0b10100000|CHAR5x7_WIDTH_5px, + 0b11100000, + 0b10100000, + 0b10100000, + 0b01110000, + 0b00100000, + 0b00100000, + + /* Character (0x04): + width=6 + +--------+ + | | + | * | + | * | + | * * | + | * * | + |* * | + |***** | + +--------+ */ + 0b00000000|CHAR5x7_WIDTH_6px, + 0b00100000, + 0b00100000, + 0b01010000, + 0b01010000, + 0b10001000, + 0b11111000, + + /* Character (0x05): + width=5 + +--------+ + |** | + |* | + |** | + | ** | + | * * | + | ** | + | * * | + +--------+ */ + 0b11000000|CHAR5x7_WIDTH_5px, + 0b10000000, + 0b11000000, + 0b01100000, + 0b01010000, + 0b01100000, + 0b01010000, + + /* Character (0x06): + width=5 + +--------+ + |* | + |* | + |** | + | ** | + | * | + | ** | + | * | + +--------+ */ + 0b10000000|CHAR5x7_WIDTH_5px, + 0b10000000, + 0b11000000, + 0b00110000, + 0b00100000, + 0b00110000, + 0b00100000, + + /* Character (0x07): + width=5 + +--------+ + | * | + | * * | + | * | + | | + | | + | | + | | + +--------+ */ + 0b00100000|CHAR5x7_WIDTH_5px, + 0b01010000, + 0b00100000, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + + /* Character (0x08): + width=5 + +--------+ + | | + | * | + | *** | + | * | + | | + | *** | + | | + +--------+ */ + 0b00000000|CHAR5x7_WIDTH_5px, + 0b00100000, + 0b01110000, + 0b00100000, + 0b00000000, + 0b01110000, + 0b00000000, + + /* Character (0x09): + width=5 + +--------+ + |* * | + |** * | + |* ** | + |* * | + | * | + | * | + | ** | + +--------+ */ + 0b10010000|CHAR5x7_WIDTH_5px, + 0b11010000, + 0b10110000, + 0b10010000, + 0b00100000, + 0b00100000, + 0b00110000, + + /* Character (0x0a): + width=5 + +--------+ + |* * | + |* * | + |* * | + | * | + | *** | + | * | + | * | + +--------+ */ + 0b10100000|CHAR5x7_WIDTH_5px, + 0b10100000, + 0b10100000, + 0b01000000, + 0b01110000, + 0b00100000, + 0b00100000, + + /* Character (0x0b): + width=5 + +--------+ + | * | + | * | + | * | + |*** | + | | + | | + | | + +--------+ */ + 0b00100000|CHAR5x7_WIDTH_5px, + 0b00100000, + 0b00100000, + 0b11100000, + 0b00000000, + 0b00000000, + 0b00000000, + + /* Character (0x0c): + width=5 + +--------+ + | | + | | + | | + |*** | + | * | + | * | + | * | + +--------+ */ + 0b00000000|CHAR5x7_WIDTH_5px, + 0b00000000, + 0b00000000, + 0b11100000, + 0b00100000, + 0b00100000, + 0b00100000, + + /* Character (0x0d): + width=5 + +--------+ + | | + | | + | | + | *** | + | * | + | * | + | * | + +--------+ */ + 0b00000000|CHAR5x7_WIDTH_5px, + 0b00000000, + 0b00000000, + 0b00111000, + 0b00100000, + 0b00100000, + 0b00100000, + + /* Character (0x0e): + width=5 + +--------+ + | * | + | * | + | * | + | *** | + | | + | | + | | + +--------+ */ + 0b00100000|CHAR5x7_WIDTH_5px, + 0b00100000, + 0b00100000, + 0b00111000, + 0b00000000, + 0b00000000, + 0b00000000, + + /* Character (0x0f): + width=5 + +--------+ + | * | + | * | + | * | + |***** | + | * | + | * | + | * | + +--------+ */ + 0b00100000|CHAR5x7_WIDTH_5px, + 0b00100000, + 0b00100000, + 0b11111000, + 0b00100000, + 0b00100000, + 0b00100000, + + /* Character (0x10): + width=5 + +--------+ + | | + |***** | + | | + | | + | | + | | + | | + +--------+ */ + 0b00000000|CHAR5x7_WIDTH_5px, + 0b11111000, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + + /* Character (0x11): + width=5 + +--------+ + | | + | | + |***** | + | | + | | + | | + | | + +--------+ */ + 0b00000000|CHAR5x7_WIDTH_5px, + 0b00000000, + 0b11111000, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + + /* Character (0x12): + width=5 + +--------+ + | | + | | + | | + |***** | + | | + | | + | | + +--------+ */ + 0b00000000|CHAR5x7_WIDTH_5px, + 0b00000000, + 0b00000000, + 0b11111000, + 0b00000000, + 0b00000000, + 0b00000000, + + /* Character (0x13): + width=5 + +--------+ + | | + | | + | | + | | + |***** | + | | + | | + +--------+ */ + 0b00000000|CHAR5x7_WIDTH_5px, + 0b00000000, + 0b00000000, + 0b00000000, + 0b11111000, + 0b00000000, + 0b00000000, + + /* Character (0x14): + width=5 + +--------+ + | | + | | + | | + | | + | | + |***** | + | | + +--------+ */ + 0b00000000|CHAR5x7_WIDTH_5px, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + 0b11111000, + 0b00000000, + + /* Character (0x15): + width=5 + +--------+ + | * | + | * | + | * | + | *** | + | * | + | * | + | * | + +--------+ */ + 0b00100000|CHAR5x7_WIDTH_5px, + 0b00100000, + 0b00100000, + 0b00111000, + 0b00100000, + 0b00100000, + 0b00100000, + + /* Character (0x16): + width=5 + +--------+ + | ** | + | *** | + | *** | + | *** | + | *** | + | *** | + | ** | + +--------+ */ + 0b00100000|CHAR5x7_WIDTH_5px, + 0b00100000, + 0b00100000, + 0b11100000, + 0b00100000, + 0b00100000, + 0b00100000, + + /* Character (0x17): + width=6 + +--------+ + | | + |** | + |**** | + |****** | + |**** | + |** | + | | + +--------+ */ + 0b00000000|CHAR5x7_WIDTH_6px, + 0b11000000, + 0b11110000, + 0b00011100, + 0b11110000, + 0b11000000, + 0b00000000, + + /* Character (0x18): + width=5 + +--------+ + |* | + |** | + |*** | + |**** | + |*** | + |** | + |* | + +--------+ */ + 0b10000000|CHAR5x7_WIDTH_4px, + 0b11000000, + 0b11100000, + 0b11110000, + 0b11100000, + 0b11000000, + 0b10000000, + + /* Character (0x19): + width=7 + +--------+ + | | + | ** ** | + |* ** * | + |* * * | + |* ** * | + | ** ** | + | | + +--------+ */ + 0b00000000|CHAR5x7_WIDTH_7px, + 0b01101100, + 0b10110010, + 0b10010010, + 0b10011010, + 0b01101100, + 0b00000000, + + /* Character (0x1a): + width=6 + +--------+ + | | + | * | + | * | + |***** | + | * | + | * | + | | + +--------+ */ + 0b00000000|CHAR5x7_WIDTH_6px, + 0b00100000, + 0b01000000, + 0b11111000, + 0b01000000, + 0b00100000, + 0b00000000, + + /* Character (0x1b): + width=6 + +--------+ + | | + | * | + | * | + |***** | + | * | + | * | + | | + +--------+ */ + 0b00000000|CHAR5x7_WIDTH_6px, + 0b00100000, + 0b00010000, + 0b11111000, + 0b00010000, + 0b00100000, + 0b00000000, + + /* Character (0x1c): + width=6 + +--------+ + | | + |***** | + | * * | + | * * | + | * * | + | * * | + |* ** | + +--------+ */ + 0b00000000|CHAR5x7_WIDTH_6px, + 0b11111000, + 0b01010000, + 0b01010000, + 0b01010000, + 0b01010000, + 0b10011000, + + /* Character (0x1d): + width=6 + +--------+ + | | + | | + |* * | + |* * | + |** ** | + |* * * | + |* | + +--------+ */ + 0b00000000|CHAR5x7_WIDTH_6px, + 0b00000000, + 0b10001000, + 0b10001000, + 0b11011000, + 0b10101000, + 0b10000000, + + /* Character (0x1e): + width=6 + +--------+ + | | + | *** | + |* * | + |* * | + |* * | + | * * | + |** ** | + +--------+ */ + 0b00000000|CHAR5x7_WIDTH_6px, + 0b01110000, + 0b10001000, + 0b10001000, + 0b10001000, + 0b01010000, + 0b11011000, + + /* Character (0x1f): + width=5 + +--------+ + | ** | + |* * | + |* * | + | ** | + | | + | | + | | + +--------+ */ + 0b01100000|CHAR5x7_WIDTH_5px, + 0b10010000, + 0b10010000, + 0b01100000, + 0b00000000, + 0b00000000, + 0b00000000, + + /* Character (0x20): ' ' + width=3 + +--------+ + | | + | | + | | + | | + | | + | | + | | + +--------+ */ + 0b00000000|CHAR5x7_WIDTH_4px, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + + /* Character (0x21): '!' + width=3 + +--------+ + | * | + | * | + | * | + | * | + | * | + | | + | * | + +--------+ */ + 0b01000000|CHAR5x7_WIDTH_3px, + 0b01000000, + 0b01000000, + 0b01000000, + 0b01000000, + 0b00000000, + 0b01000000, + + /* Character (0x22): '"' + width=5 + +--------+ + | * * | + | * * | + | * * | + | | + | | + | | + | | + +--------+ */ + 0b01010000, + 0b01010000, + 0b01010000, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + + /* Character (0x23): '#' + width=5 + +--------+ + | * * | + | * * | + |***** | + | * * | + |***** | + | * * | + | * * | + +--------+ */ + 0b01010000|CHAR5x7_WIDTH_6px, + 0b01010000, + 0b11111000, + 0b01010000, + 0b11111000, + 0b01010000, + 0b01010000, + + /* Character (0x24): '$' + width=5 + +--------+ + | * | + | **** | + |* * | + | *** | + | * * | + |**** | + | * | + +--------+ */ + 0b00100000|CHAR5x7_WIDTH_6px, + 0b01111000, + 0b10100000, + 0b01110000, + 0b00101000, + 0b11110000, + 0b00100000, + + /* Character (0x25): '%' + width=6 + +--------+ + |** | + |** * | + | * | + | * | + | * | + |* ** | + | ** | + +--------+ */ + 0b11000000|CHAR5x7_WIDTH_6px, + 0b11001000, + 0b00010000, + 0b00100000, + 0b01000000, + 0b10011000, + 0b00011000, + + /* Character (0x26): '&' + width=5 + +--------+ + | | + | * | + | * * | + | ** | + |* * * | + |* * | + | ** * | + +--------+ */ + 0b00000000|CHAR5x7_WIDTH_6px, + 0b00100000, + 0b01010000, + 0b01100000, + 0b10101000, + 0b10010000, + 0b01101000, + + /* Character (0x27): ''' + width=4 + +--------+ + | ** | + | * | + |* | + | | + | | + | | + | | + +--------+ */ + 0b01100000|CHAR5x7_WIDTH_4px, + 0b01000000, + 0b10000000, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + + /* Character (0x28): '(' + width=4 + +--------+ + | * | + | * | + |* | + |* | + |* | + | * | + | * | + +--------+ */ + 0b00100000|CHAR5x7_WIDTH_4px, + 0b01000000, + 0b10000000, + 0b10000000, + 0b10000000, + 0b01000000, + 0b00100000, + + /* Character (0x29): ')' + width=5 + +--------+ + |* | + | * | + | * | + | * | + | * | + | * | + |* | + +--------+ */ + 0b10000000|CHAR5x7_WIDTH_4px, + 0b01000000, + 0b00100000, + 0b00100000, + 0b00100000, + 0b01000000, + 0b10000000, + + /* Character (0x2a): '*' + width=6 + +--------+ + | | + | * | + |* * * | + | *** | + |* * * | + | * | + | | + +--------+ */ + 0b00000000|CHAR5x7_WIDTH_6px, + 0b00100000, + 0b10101000, + 0b01110000, + 0b10101000, + 0b00100000, + 0b00000000, + + /* Character (0x2b): '+' + width=6 + +--------+ + | | + | * | + | * | + |***** | + | * | + | * | + | | + +--------+ */ + 0b00000000|CHAR5x7_WIDTH_6px, + 0b00100000, + 0b00100000, + 0b11111000, + 0b00100000, + 0b00100000, + 0b00000000, + + /* Character (0x2c): ',' + width=4 + +--------+ + | | + | | + | | + | | + |** | + | * | + |* | + +--------+ */ + 0b00000000|CHAR5x7_WIDTH_3px, + 0b00000000, + 0b00000000, + 0b00000000, + 0b11000000, + 0b01000000, + 0b10000000, + + /* Character (0x2d): '-' + width=5 + +--------+ + | | + | | + | | + |**** | + | | + | | + | | + +--------+ */ + 0b00000000|CHAR5x7_WIDTH_5px, + 0b00000000, + 0b00000000, + 0b11110000, + 0b00000000, + 0b00000000, + 0b00000000, + + /* Character (0x2e): '.' + width=3 + +--------+ + | | + | | + | | + | | + | | + |** | + |** | + +--------+ */ + 0b00000000|CHAR5x7_WIDTH_3px, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + 0b11000000, + 0b11000000, + + /* Character (0x2f): '/' + width=4 + +--------+ + | * | + | * | + | * | + | * | + | * | + |* | + |* | + +--------+ */ + 0b00100000|CHAR5x7_WIDTH_4px, + 0b00100000, + 0b01000000, + 0b01000000, + 0b01000000, + 0b10000000, + 0b10000000, + + /* Character (0x30): '0' + width=5 + +--------+ + | ** | + |* * | + |* ** | + |** * | + |* * | + |* * | + | ** | + +--------+ */ + 0b01100000|CHAR5x7_WIDTH_5px, + 0b10010000, + 0b10110000, + 0b11010000, + 0b10010000, + 0b10010000, + 0b01100000, + + /* Character (0x31): '1' + width=5 + +--------+ + | * | + | ** | + | * | + | * | + | * | + | * | + | *** | + +--------+ */ + 0b00100000|CHAR5x7_WIDTH_5px, + 0b01100000, + 0b00100000, + 0b00100000, + 0b00100000, + 0b00100000, + 0b01110000, + + /* Character (0x32): '2' + width=5 + +--------+ + | ** | + |* * | + | * | + | * | + | * | + |* | + |**** | + +--------+ */ + 0b01100000|CHAR5x7_WIDTH_5px, + 0b10010000, + 0b00010000, + 0b00100000, + 0b01000000, + 0b10000000, + 0b11110000, + + /* Character (0x33): '3' + width=5 + +--------+ + | ** | + |* * | + | * | + | ** | + | * | + |* * | + | ** | + +--------+ */ + 0b01100000|CHAR5x7_WIDTH_5px, + 0b10010000, + 0b00010000, + 0b01100000, + 0b00010000, + 0b10010000, + 0b01100000, + + /* Character (0x34): '4' + width=5 + +--------+ + |* * | + |* * | + |* * | + |* * | + |**** | + | * | + | * | + +--------+ */ + 0b10010000|CHAR5x7_WIDTH_5px, + 0b10010000, + 0b10010000, + 0b10010000, + 0b11110000, + 0b00010000, + 0b00010000, + + /* Character (0x35): '5' + width=5 + +--------+ + |**** | + |* | + |*** | + | * | + | * | + |* * | + | ** | + +--------+ */ + 0b11110000|CHAR5x7_WIDTH_5px, + 0b10000000, + 0b11100000, + 0b00010000, + 0b00010000, + 0b10010000, + 0b01100000, + + /* Character (0x36): '6' + width=5 + +--------+ + | ** | + |* * | + |* | + |*** | + |* * | + |* * | + | ** | + +--------+ */ + 0b01100000|CHAR5x7_WIDTH_5px, + 0b10010000, + 0b10000000, + 0b11100000, + 0b10010000, + 0b10010000, + 0b01100000, + + /* Character (0x37): '7' + width=5 + +--------+ + |**** | + | * | + | * | + | * | + | * | + | * | + | * | + +--------+ */ + 0b11110000|CHAR5x7_WIDTH_5px, + 0b00010000, + 0b00100000, + 0b00100000, + 0b01000000, + 0b01000000, + 0b01000000, + + /* Character (0x38): '8' + width=5 + +--------+ + | ** | + |* * | + |* * | + | ** | + |* * | + |* * | + | ** | + +--------+ */ + 0b01100000|CHAR5x7_WIDTH_5px, + 0b10010000, + 0b10010000, + 0b01100000, + 0b10010000, + 0b10010000, + 0b01100000, + + /* Character (0x39): '9' + width=5 + +--------+ + | ** | + |* * | + |* * | + | *** | + | * | + |* * | + | ** | + +--------+ */ + 0b01100000|CHAR5x7_WIDTH_5px, + 0b10010000, + 0b10010000, + 0b01110000, + 0b00010000, + 0b10010000, + 0b01100000, + + /* Character (0x3a): ':' + width=3 + +--------+ + | | + |** | + |** | + | | + |** | + |** | + | | + +--------+ */ + 0b00000000|CHAR5x7_WIDTH_4px, + 0b11000000, + 0b11000000, + 0b00000000, + 0b11000000, + 0b11000000, + 0b00000000, + + /* Character (0x3b): ';' + width=4 + +--------+ + | | + | ** | + | ** | + | | + | ** | + | * | + |* | + +--------+ */ + 0b00000000|CHAR5x7_WIDTH_4px, + 0b01100000, + 0b01100000, + 0b00000000, + 0b01100000, + 0b01000000, + 0b10000000, + + /* Character (0x3c): '<' + width=5 + +--------+ + | | + | * | + | * | + |* | + | * | + | * | + | | + +--------+ */ + 0b00000000|CHAR5x7_WIDTH_5px, + 0b00100000, + 0b01000000, + 0b10000000, + 0b01000000, + 0b00100000, + 0b00000000, + + /* Character (0x3d): '=' + width=5 + +--------+ + | | + | | + |**** | + | | + |**** | + | | + | | + +--------+ */ + 0b00000000|CHAR5x7_WIDTH_5px, + 0b00000000, + 0b11110000, + 0b00000000, + 0b11110000, + 0b00000000, + 0b00000000, + + /* Character (0x3e): '>' + width=5 + +--------+ + | | + |* | + | * | + | * | + | * | + |* | + | | + +--------+ */ + 0b00000000|CHAR5x7_WIDTH_5px, + 0b10000000, + 0b01000000, + 0b00100000, + 0b01000000, + 0b10000000, + 0b00000000, + + /* Character (0x3f): '?' + width=5 + +--------+ + | ** | + |* * | + | * | + | * | + | * | + | | + | * | + +--------+ */ + 0b01100000|CHAR5x7_WIDTH_5px, + 0b10010000, + 0b00010000, + 0b00100000, + 0b01000000, + 0b00000000, + 0b01000000, + + /* Character (0x40): '@' + width=5 + +--------+ + | ** | + |* * | + |* ** | + |* ** | + |* | + |* | + | *** | + +--------+ */ + 0b01100000|CHAR5x7_WIDTH_5px, + 0b10010000, + 0b10110000, + 0b10110000, + 0b10000000, + 0b10000000, + 0b01110000, + + /* Character (0x41): 'A' + width=5 + +--------+ + | ** | + |* * | + |* * | + |* * | + |**** | + |* * | + |* * | + +--------+ */ + 0b01100000|CHAR5x7_WIDTH_5px, + 0b10010000, + 0b10010000, + 0b10010000, + 0b11110000, + 0b10010000, + 0b10010000, + + /* Character (0x42): 'B' + width=5 + +--------+ + |*** | + |* * | + |* * | + |*** | + |* * | + |* * | + |*** | + +--------+ */ + 0b11100000|CHAR5x7_WIDTH_5px, + 0b10010000, + 0b10010000, + 0b11100000, + 0b10010000, + 0b10010000, + 0b11100000, + + /* Character (0x43): 'C' + width=5 + +--------+ + | ** | + |* * | + |* | + |* | + |* | + |* * | + | ** | + +--------+ */ + 0b01100000|CHAR5x7_WIDTH_5px, + 0b10010000, + 0b10000000, + 0b10000000, + 0b10000000, + 0b10010000, + 0b01100000, + + /* Character (0x44): 'D' + width=5 + +--------+ + |*** | + |* * | + |* * | + |* * | + |* * | + |* * | + |*** | + +--------+ */ + 0b11100000|CHAR5x7_WIDTH_5px, + 0b10010000, + 0b10010000, + 0b10010000, + 0b10010000, + 0b10010000, + 0b11100000, + + /* Character (0x45): 'E' + width=5 + +--------+ + |**** | + |* | + |* | + |*** | + |* | + |* | + |**** | + +--------+ */ + 0b11110000|CHAR5x7_WIDTH_5px, + 0b10000000, + 0b10000000, + 0b11100000, + 0b10000000, + 0b10000000, + 0b11110000, + + /* Character (0x46): 'F' + width=5 + +--------+ + |**** | + |* | + |* | + |*** | + |* | + |* | + |* | + +--------+ */ + 0b11110000|CHAR5x7_WIDTH_5px, + 0b10000000, + 0b10000000, + 0b11100000, + 0b10000000, + 0b10000000, + 0b10000000, + + /* Character (0x47): 'G' + width=5 + +--------+ + | ** | + |* * | + |* | + |* ** | + |* * | + |* * | + | *** | + +--------+ */ + 0b01100000|CHAR5x7_WIDTH_5px, + 0b10010000, + 0b10000000, + 0b10110000, + 0b10010000, + 0b10010000, + 0b01110000, + + /* Character (0x48): 'H' + width=5 + +--------+ + |* * | + |* * | + |* * | + |**** | + |* * | + |* * | + |* * | + +--------+ */ + 0b10010000|CHAR5x7_WIDTH_5px, + 0b10010000, + 0b10010000, + 0b11110000, + 0b10010000, + 0b10010000, + 0b10010000, + + /* Character (0x49): 'I' + width=4 + +--------+ + |*** | + | * | + | * | + | * | + | * | + | * | + |*** | + +--------+ */ + 0b11100000|CHAR5x7_WIDTH_4px, + 0b01000000, + 0b01000000, + 0b01000000, + 0b01000000, + 0b01000000, + 0b11100000, + + /* Character (0x4a): 'J' + width=5 + +--------+ + | *** | + | * | + | * | + | * | + | * | + |* * | + | ** | + +--------+ */ + 0b01110000|CHAR5x7_WIDTH_5px, + 0b00010000, + 0b00010000, + 0b00010000, + 0b00010000, + 0b10010000, + 0b01100000, + + /* Character (0x4b): 'K' + width=5 + +--------+ + |* * | + |* * | + |* * | + |** | + |* * | + |* * | + |* * | + +--------+ */ + 0b10010000|CHAR5x7_WIDTH_5px, + 0b10010000, + 0b10010000, + 0b11100000, + 0b10010000, + 0b10010000, + 0b10010000, + + /* Character (0x4c): 'L' + width=5 + +--------+ + |* | + |* | + |* | + |* | + |* | + |* | + |**** | + +--------+ */ + 0b10000000|CHAR5x7_WIDTH_5px, + 0b10000000, + 0b10000000, + 0b10000000, + 0b10000000, + 0b10000000, + 0b11110000, + + /* Character (0x4d): 'M' + width=6 + +--------+ + |* * | + |** ** | + |* * * | + |* * * | + |* * | + |* * | + |* * | + +--------+ */ + 0b10001000|CHAR5x7_WIDTH_6px, + 0b11011000, + 0b10101000, + 0b10101000, + 0b10001000, + 0b10001000, + 0b10001000, + + /* Character (0x4e): 'N' + width=5 + +--------+ + |* * | + |* * | + |** * | + |* ** | + |* * | + |* * | + |* * | + +--------+ */ + 0b10010000|CHAR5x7_WIDTH_5px, + 0b10010000, + 0b11010000, + 0b10110000, + 0b10010000, + 0b10010000, + 0b10010000, + + /* Character (0x4f): 'O' + width=5 + +--------+ + | ** | + |* * | + |* * | + |* * | + |* * | + |* * | + | ** | + +--------+ */ + 0b01100000|CHAR5x7_WIDTH_5px, + 0b10010000, + 0b10010000, + 0b10010000, + 0b10010000, + 0b10010000, + 0b01100000, + + /* Character (0x50): 'P' + width=5 + +--------+ + |*** | + |* * | + |* * | + |*** | + |* | + |* | + |* | + +--------+ */ + 0b11100000|CHAR5x7_WIDTH_5px, + 0b10010000, + 0b10010000, + 0b11100000, + 0b10000000, + 0b10000000, + 0b10000000, + + /* Character (0x51): 'Q' + width=5 + +--------+ + | ** | + |* * | + |* * | + |* * | + |* * | + |* * | + | * * | + +--------+ */ + 0b01100000|CHAR5x7_WIDTH_5px, + 0b10010000, + 0b10010000, + 0b10010000, + 0b10010000, + 0b10100000, + 0b01010000, + + /* Character (0x52): 'R' + width=5 + +--------+ + |*** | + |* * | + |* * | + |*** | + |* * | + |* * | + |* * | + +--------+ */ + 0b11100000|CHAR5x7_WIDTH_5px, + 0b10010000, + 0b10010000, + 0b11100000, + 0b10010000, + 0b10010000, + 0b10010000, + + /* Character (0x53): 'S' + width=5 + +--------+ + | ** | + |* * | + |* | + | ** | + | * | + |* * | + | ** | + +--------+ */ + 0b01100000|CHAR5x7_WIDTH_5px, + 0b10010000, + 0b10000000, + 0b01100000, + 0b00010000, + 0b10010000, + 0b01100000, + + /* Character (0x54): 'T' + width=6 + +--------+ + |***** | + | * | + | * | + | * | + | * | + | * | + | * | + +--------+ */ + 0b11111000|CHAR5x7_WIDTH_6px, + 0b00100000, + 0b00100000, + 0b00100000, + 0b00100000, + 0b00100000, + 0b00100000, + + /* Character (0x55): 'U' + width=5 + +--------+ + |* * | + |* * | + |* * | + |* * | + |* * | + |* * | + | *** | + +--------+ */ + 0b10010000|CHAR5x7_WIDTH_5px, + 0b10010000, + 0b10010000, + 0b10010000, + 0b10010000, + 0b10010000, + 0b01110000, + + /* Character (0x56): 'V' + width=5 + +--------+ + |* * | + |* * | + |* * | + |* * | + |* * | + | ** | + | ** | + +--------+ */ + 0b10010000|CHAR5x7_WIDTH_5px, + 0b10010000, + 0b10010000, + 0b10010000, + 0b10010000, + 0b01100000, + 0b01100000, + + /* Character (0x57): 'W' + width=6 + +--------+ + |* * | + |* * | + |* * | + |* * * | + |* * * | + |* * * | + | * * | + +--------+ */ + 0b10001000|CHAR5x7_WIDTH_6px, + 0b10001000, + 0b10001000, + 0b10101000, + 0b10101000, + 0b10101000, + 0b01010000, + + /* Character (0x58): 'X' + width=6 + +--------+ + |* * | + |* * | + | * * | + | * | + | * * | + |* * | + |* * | + +--------+ */ + 0b10001000|CHAR5x7_WIDTH_6px, + 0b10001000, + 0b01010000, + 0b00100000, + 0b01010000, + 0b10001000, + 0b10001000, + + /* Character (0x59): 'Y' + width=6 + +--------+ + |* * | + |* * | + |* * | + | * * | + | * | + | * | + | * | + +--------+ */ + 0b10001000|CHAR5x7_WIDTH_6px, + 0b10001000, + 0b10001000, + 0b01010000, + 0b00100000, + 0b00100000, + 0b00100000, + + /* Character (0x5a): 'Z' + width=5 + +--------+ + |**** | + | * | + | * | + | * | + |* | + |* | + |**** | + +--------+ */ + 0b11110000|CHAR5x7_WIDTH_5px, + 0b00010000, + 0b00100000, + 0b01000000, + 0b10000000, + 0b10000000, + 0b11110000, + + /* Character (0x5b): '[' + width=4 + +--------+ + |*** | + |* | + |* | + |* | + |* | + |* | + |*** | + +--------+ */ + 0b11100000|CHAR5x7_WIDTH_4px, + 0b10000000, + 0b10000000, + 0b10000000, + 0b10000000, + 0b10000000, + 0b11100000, + + /* Character (0x5c): '\' + width=4 + +--------+ + |* | + |* | + | * | + | * | + | * | + | * | + | * | + +--------+ */ + 0b10000000|CHAR5x7_WIDTH_4px, + 0b10000000, + 0b01000000, + 0b01000000, + 0b01000000, + 0b00100000, + 0b00100000, + + /* Character (0x5d): ']' + width=4 + +--------+ + |*** | + | * | + | * | + | * | + | * | + | * | + |*** | + +--------+ */ + 0b11100000|CHAR5x7_WIDTH_4px, + 0b00100000, + 0b00100000, + 0b00100000, + 0b00100000, + 0b00100000, + 0b11100000, + + /* Character (0x5e): '^' + width=4 + +--------+ + | * | + |* * | + | | + | | + | | + | | + | | + +--------+ */ + 0b01000000|CHAR5x7_WIDTH_4px, + 0b10100000, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + + /* Character (0x5f): '_' + width=5 + +--------+ + | | + | | + | | + | | + | | + | | + |***** | + +--------+ */ + 0b00000000|CHAR5x7_WIDTH_5px, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + 0b11111000, + + /* Character (0x60): '`' + width=4 + +--------+ + |** | + | * | + | * | + | | + | | + | | + | | + +--------+ */ + 0b11000000|CHAR5x7_WIDTH_4px, + 0b01000000, + 0b00100000, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + + /* Character (0x61): 'a' + width=5 + +--------+ + | | + | | + | *** | + |* * | + |* * | + |* ** | + | * * | + +--------+ */ + 0b00000000|CHAR5x7_WIDTH_5px, + 0b00000000, + 0b01110000, + 0b10010000, + 0b10010000, + 0b10110000, + 0b01010000, + + /* Character (0x62): 'b' + width=5 + +--------+ + |* | + |* | + |* * | + |** * | + |* * | + |* * | + |*** | + +--------+ */ + 0b10000000|CHAR5x7_WIDTH_5px, + 0b10000000, + 0b10100000, + 0b11010000, + 0b10010000, + 0b10010000, + 0b11100000, + + /* Character (0x63): 'c' + width=5 + +--------+ + | | + | | + | *** | + |* | + |* | + |* | + | *** | + +--------+ */ + 0b00000000|CHAR5x7_WIDTH_5px, + 0b00000000, + 0b01110000, + 0b10000000, + 0b10000000, + 0b10000000, + 0b01110000, + + /* Character (0x64): 'd' + width=5 + +--------+ + | * | + | * | + | * * | + |* ** | + |* * | + |* * | + | *** | + +--------+ */ + 0b00010000|CHAR5x7_WIDTH_5px, + 0b00010000, + 0b01010000, + 0b10110000, + 0b10010000, + 0b10010000, + 0b01110000, + + /* Character (0x65): 'e' + width=5 + +--------+ + | | + | | + | ** | + |* * | + |**** | + |* | + | *** | + +--------+ */ + 0b00000000|CHAR5x7_WIDTH_5px, + 0b00000000, + 0b01100000, + 0b10010000, + 0b11110000, + 0b10000000, + 0b01110000, + + /* Character (0x66): 'f' + width=5 + +--------+ + | * | + | * * | + | * | + |*** | + | * | + | * | + | * | + +--------+ */ + 0b00100000|CHAR5x7_WIDTH_5px, + 0b01010000, + 0b01000000, + 0b11100000, + 0b01000000, + 0b01000000, + 0b01000000, + + /* Character (0x67): 'g' + width=5 + +--------+ + | | + | | + | *** | + |* * | + | *** | + | * | + | ** | + +--------+ */ + 0b00000000|CHAR5x7_WIDTH_5px, + 0b00000000, + 0b01110000, + 0b10010000, + 0b01110000, + 0b00010000, + 0b01100000, + + /* Character (0x68): 'h' + width=5 + +--------+ + |* | + |* | + |* * | + |** * | + |* * | + |* * | + |* * | + +--------+ */ + 0b10000000|CHAR5x7_WIDTH_5px, + 0b10000000, + 0b10100000, + 0b11010000, + 0b10010000, + 0b10010000, + 0b10010000, + + /* Character (0x69): 'i' + width=4 + +--------+ + | * | + | | + |** | + | * | + | * | + | * | + |*** | + +--------+ */ + 0b01000000|CHAR5x7_WIDTH_4px, + 0b00000000, + 0b11000000, + 0b01000000, + 0b01000000, + 0b01000000, + 0b11100000, + + /* Character (0x6a): + width=4 + +--------+ + | * | + | | + | * | + | * | + | * | + |* * | + | * | + +--------+ */ + 0b00100000|CHAR5x7_WIDTH_4px, + 0b00000000, + 0b00100000, + 0b00100000, + 0b00100000, + 0b10100000, + 0b01000000, + + /* Character (0x6b): 'k' + width=5 + +--------+ + |* | + |* | + |* * | + |* * | + |** | + |* * | + |* * | + +--------+ */ + 0b10000000|CHAR5x7_WIDTH_5px, + 0b10000000, + 0b10010000, + 0b10100000, + 0b11000000, + 0b10100000, + 0b10010000, + + /* Character (0x6c): 'l' + width=4 + +--------+ + |** | + | * | + | * | + | * | + | * | + | * | + |*** | + +--------+ */ + 0b11000000|CHAR5x7_WIDTH_4px, + 0b01000000, + 0b01000000, + 0b01000000, + 0b01000000, + 0b01000000, + 0b11100000, + + /* Character (0x6d): 'm' + width=6 + +--------+ + | | + | | + |**** | + |* * * | + |* * * | + |* * * | + |* * * | + +--------+ */ + 0b00000000|CHAR5x7_WIDTH_6px, + 0b00000000, + 0b11110000, + 0b10101000, + 0b10101000, + 0b10101000, + 0b10101000, + + /* Character (0x6e): 'n' + width=5 + +--------+ + | | + | | + |* * | + |** * | + |* * | + |* * | + |* * | + +--------+ */ + 0b00000000|CHAR5x7_WIDTH_5px, + 0b00000000, + 0b10100000, + 0b11010000, + 0b10010000, + 0b10010000, + 0b10010000, + + /* Character (0x6f): 'o' + width=5 + +--------+ + | | + | | + | ** | + |* * | + |* * | + |* * | + | ** | + +--------+ */ + 0b00000000|CHAR5x7_WIDTH_5px, + 0b00000000, + 0b01100000, + 0b10010000, + 0b10010000, + 0b10010000, + 0b01100000, + + /* Character (0x70): 'p' + width=5 + +--------+ + | | + | | + |*** | + |* * | + |* * | + |*** | + |* | + +--------+ */ + 0b00000000|CHAR5x7_WIDTH_5px, + 0b00000000, + 0b11100000, + 0b10010000, + 0b10010000, + 0b11100000, + 0b10000000, + + /* Character (0x71): 'q' + width=5 + +--------+ + | | + | | + | *** | + |* * | + |* * | + | *** | + | * | + +--------+ */ + 0b00000000|CHAR5x7_WIDTH_5px, + 0b00000000, + 0b01110000, + 0b10010000, + 0b10010000, + 0b01110000, + 0b00010000, + + /* Character (0x72): 'r' + width=5 + +--------+ + | | + | | + |* * | + |** * | + |* | + |* | + |* | + +--------+ */ + 0b00000000|CHAR5x7_WIDTH_5px, + 0b00000000, + 0b10100000, + 0b11010000, + 0b10000000, + 0b10000000, + 0b10000000, + + /* Character (0x73): 's' + width=5 + +--------+ + | | + | | + | *** | + |* | + | ** | + | * | + |*** | + +--------+ */ + 0b00000000|CHAR5x7_WIDTH_5px, + 0b00000000, + 0b01110000, + 0b10000000, + 0b01100000, + 0b00010000, + 0b11100000, + + /* Character (0x74): 't' + width=5 + +--------+ + | * | + | * | + |*** | + | * | + | * | + | * | + | ** | + +--------+ */ + 0b01000000|CHAR5x7_WIDTH_5px, + 0b01000000, + 0b11100000, + 0b01000000, + 0b01000000, + 0b01000000, + 0b00110000, + + /* Character (0x75): 'u' + width=5 + +--------+ + | | + | | + |* * | + |* * | + |* * | + |* ** | + | * * | + +--------+ */ + 0b00000000|CHAR5x7_WIDTH_5px, + 0b00000000, + 0b10010000, + 0b10010000, + 0b10010000, + 0b10110000, + 0b01010000, + + /* Character (0x76): 'v' + width=5 + +--------+ + | | + | | + |* * | + |* * | + |* * | + | ** | + | ** | + +--------+ */ + 0b00000000|CHAR5x7_WIDTH_5px, + 0b00000000, + 0b10010000, + 0b10010000, + 0b10010000, + 0b01100000, + 0b01100000, + + /* Character (0x77): 'w' + width=6 + +--------+ + | | + | | + |* * | + |* * | + |* * * | + |* * * | + | * * | + +--------+ */ + 0b00000000|CHAR5x7_WIDTH_6px, + 0b00000000, + 0b10001000, + 0b10001000, + 0b10101000, + 0b10101000, + 0b01010000, + + /* Character (0x78): 'x' + width=5 + +--------+ + | | + | | + |* * | + |* * | + | ** | + |* * | + |* * | + +--------+ */ + 0b00000000|CHAR5x7_WIDTH_5px, + 0b00000000, + 0b10010000, + 0b10010000, + 0b01100000, + 0b10010000, + 0b10010000, + + /* Character (0x79): 'y' + width=5 + +--------+ + | | + | | + |* * | + |* * | + | *** | + | * | + |*** | + +--------+ */ + 0b00000000|CHAR5x7_WIDTH_5px, + 0b00000000, + 0b10010000, + 0b10010000, + 0b01110000, + 0b00010000, + 0b11100000, + + /* Character (0x7a): 'z' + width=5 + +--------+ + | | + | | + |**** | + | * | + | * | + |* | + |**** | + +--------+ */ + 0b00000000|CHAR5x7_WIDTH_5px, + 0b00000000, + 0b11110000, + 0b00100000, + 0b01000000, + 0b10000000, + 0b11110000, + + /* Character (0x7b): '{' + width=5 + +--------+ + | * | + | * | + | * | + |* | + | * | + | * | + | * | + +--------+ */ + 0b00100000|CHAR5x7_WIDTH_4px, + 0b01000000, + 0b01000000, + 0b10000000, + 0b01000000, + 0b01000000, + 0b00100000, + + /* Character (0x7c): '|' + width=5 + +--------+ + | * | + | * | + | * | + | * | + | * | + | * | + | * | + +--------+ */ + 0b00100000|CHAR5x7_WIDTH_4px, + 0b00100000, + 0b00100000, + 0b00100000, + 0b00100000, + 0b00100000, + 0b00100000, + + /* Character (0x7d): '}' + width=5 + +--------+ + |* | + | * | + | * | + | * | + | * | + | * | + |* | + +--------+ */ + 0b10000000|CHAR5x7_WIDTH_4px, + 0b01000000, + 0b01000000, + 0b00100000, + 0b01000000, + 0b01000000, + 0b10000000, + + /* Character (0x7e): '~' + width=5 + +--------+ + | | + | | + | * * | + |* * | + | | + | | + | | + +--------+ */ + 0b00000000|CHAR5x7_WIDTH_5px, + 0b00000000, + 0b01010000, + 0b10100000, + 0b00000000, + 0b00000000, + 0b00000000, +}; diff --git a/chprintf.c b/chprintf.c index 7906dc90..fbfd1cd9 100644 --- a/chprintf.c +++ b/chprintf.c @@ -49,17 +49,17 @@ static const uint32_t pow10[FLOAT_PRECISION+1] = { }; // Prefixes for values bigger then 1000.0 // 1 1e3, 1e6, 1e9, 1e12, 1e15, 1e18, 1e21, 1e24 -static char bigPrefix[] = {' ', 'k', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y', 0}; +static char bigPrefix[] = {' ', 'k', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y', 0}; // Prefixes for values less then 1.0 // 1e-3, 1e-6, 1e-9, 1e-12, 1e-15, 1e-18, 1e-21, 1e-24 -static char smallPrefix[]= { 'm', 0x1d, 'n', 'p', 'f', 'a', 'z', 'y', 0}; +static char smallPrefix[] = {'m', 0x1d, 'n', 'p', 'f', 'a', 'z', 'y', 0}; #pragma pack(pop) static char *long_to_string_with_divisor(char *p, uint32_t num, - uint32_t radix, - uint32_t precision) { + uint32_t radix, + uint32_t precision) { char *q = p + MAX_FILLER; char *b = q; // convert to string from end buffer to begin @@ -78,12 +78,14 @@ static char *long_to_string_with_divisor(char *p, // default prescision = 13 // g.mmm kkk hhh -#define MAX_FREQ_PRESCISION 13 -#define FREQ_PSET 1 -#define FREQ_NO_SPACE 2 -#define FREQ_PREFIX_SPACE 4 - -static char *ulong_freq(char *p, uint32_t freq, uint32_t precision){ +#define MAX_FREQ_PRESCISION 13 +#define FREQ_PSET 1 +#define FREQ_NO_SPACE 2 +#define FREQ_PREFIX_SPACE 4 + +static char * +ulong_freq(char *p, uint32_t freq, uint32_t precision) +{ uint8_t flag = FREQ_PSET; if (precision == 0) flag|=FREQ_PREFIX_SPACE; @@ -94,7 +96,7 @@ static char *ulong_freq(char *p, uint32_t freq, uint32_t precision){ // Prefix counter uint32_t s = 0; // Set format (every 3 digits add ' ' up to GHz) - uint32_t format=0b00100100100; + uint32_t format = 0b00100100100; do { #if 0 uint8_t c = freq % 10; @@ -104,21 +106,27 @@ static char *ulong_freq(char *p, uint32_t freq, uint32_t precision){ // c = freq % 10 // freq = freq / 10; uint32_t c = freq; - freq>>=1; - freq+=freq>>1; - freq+=freq>>4; - freq+=freq>>8; - 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;} + freq >>= 1; + freq += freq >> 1; + freq += freq >> 4; + freq += freq >> 8; + 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; + } #endif *--q = c + '0'; - if (freq==0) - break; + if (freq == 0) break; // Add spaces, calculate prefix - if (format&1) {*--q = ' '; s++;} - format>>=1; + if (format & 1) { + *--q = ' '; + s++; + } + format >>= 1; } while (1); s = bigPrefix[s]; @@ -126,26 +134,25 @@ static char *ulong_freq(char *p, uint32_t freq, uint32_t precision){ uint32_t i = (b - q); // Limit string size, max size is - precision if (precision && i > precision) { - i = precision; - flag|=FREQ_NO_SPACE; + i = precision; + flag |= FREQ_NO_SPACE; } // copy string // Replace first ' ' by '.', remove ' ' if size too big - do{ + do { char c = *q++; // replace first ' ' on '.' if (c == ' ') { - if (flag&FREQ_PSET){ + if (flag & FREQ_PSET) { c = '.'; - flag&=~FREQ_PSET; - } - else if (flag&FREQ_NO_SPACE) + flag &= ~FREQ_PSET; + } else if (flag & FREQ_NO_SPACE) c = *q++; } *p++ = c; - }while (--i); + } while (--i); // Put pref (amd space before it if need) - if (flag&FREQ_PREFIX_SPACE && s!=' ') + if (flag & FREQ_PREFIX_SPACE && s != ' ') *p++ = ' '; *p++ = s; return p; @@ -153,7 +160,7 @@ static char *ulong_freq(char *p, uint32_t freq, uint32_t precision){ #if CHPRINTF_USE_FLOAT static char *ftoa(char *p, float num, uint32_t precision) { - // Check precision limit + // Check precision limit if (precision > FLOAT_PRECISION) precision = FLOAT_PRECISION; uint32_t multi = pow10[precision]; @@ -163,7 +170,7 @@ static char *ftoa(char *p, float num, uint32_t precision) { // Fix rounding error if get if (k>=multi){k-=multi;l++;} p = long_to_string_with_divisor(p, l, 10, 0); - if (precision){ + if (precision) { *p++ = '.'; p=long_to_string_with_divisor(p, k, 10, precision); #ifndef CHPRINTF_FORCE_TRAILING_ZEROS @@ -227,23 +234,23 @@ static char *ftoaS(char *p, float num, uint32_t precision) { * * @api */ -#define IS_LONG 1 -#define LEFT_ALIGN 2 -#define POSITIVE 4 -#define NEGATIVE 8 -#define PAD_ZERO 16 -#define PLUS_SPACE 32 -#define DEFAULT_PRESCISION 64 +#define IS_LONG 1 +#define LEFT_ALIGN 2 +#define POSITIVE 4 +#define NEGATIVE 8 +#define PAD_ZERO 16 +#define PLUS_SPACE 32 +#define DEFAULT_PRESCISION 64 int chvprintf(BaseSequentialStream *chp, const char *fmt, va_list ap) { char *p, *s, c, filler=' '; int precision, width; int n = 0; - uint32_t state; + uint32_t state; union { - uint32_t u; - int32_t l; - float f; + uint32_t u; + int32_t l; + float f; }value; #if CHPRINTF_USE_FLOAT char tmpbuf[2*MAX_FILLER + 1]; @@ -321,8 +328,8 @@ int chvprintf(BaseSequentialStream *chp, const char *fmt, va_list ap) { if (*fmt) c = *fmt++; } - else if((c >= 'A') && (c <= 'Z')) - state|=IS_LONG; + else if ((c >= 'A') && (c <= 'Z')) + state|=IS_LONG; */ // Parse type switch (c) { @@ -377,7 +384,7 @@ int chvprintf(BaseSequentialStream *chp, const char *fmt, va_list ap) { *p++ = '+'; #ifdef CHPRINTF_USE_SPACE_FLAG else if (state & PLUS_SPACE) - *p++ = ' '; + *p++ = ' '; #endif if (value.f == INFINITY){ *p++ = 0x19; diff --git a/flash.c b/flash.c index 9888cb51..a66315d7 100644 --- a/flash.c +++ b/flash.c @@ -96,7 +96,7 @@ config_save(void) flash_erase_page((uint32_t)dst); /* write to flahs */ - while(count-- > 0) { + while (count-- > 0) { flash_program_half_word((uint32_t)dst, *src++); dst++; } @@ -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(); @@ -154,7 +155,7 @@ caldata_save(int id) } /* write to flahs */ - while(count-- > 0) { + while (count-- > 0) { flash_program_half_word((uint32_t)dst, *src++); dst++; } @@ -191,7 +192,7 @@ caldata_recall(int id) memcpy(dst, src, sizeof(properties_t)); return 0; load_default: - loadDefaultProps(); + load_default_properties(); return -1; } diff --git a/ili9341.c b/ili9341.c index a66fc9ab..f1e46745 100644 --- a/ili9341.c +++ b/ili9341.c @@ -23,8 +23,8 @@ uint16_t spi_buffer[SPI_BUFFER_SIZE]; // Default foreground & background colors -uint16_t foreground_color=0; -uint16_t background_color=0; +uint16_t foreground_color = 0; +uint16_t background_color = 0; // Display width and height definition #define ILI9341_WIDTH 320 @@ -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 - | 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 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) +{ (void)spip; (void)flags; } @@ -199,13 +203,15 @@ 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){ - while (len){ +static void dmaStreamFlush(uint32_t len) +{ + while (len) { // DMA data transfer limited by 65535 uint16_t tx_size = len > 65535 ? 65535 : len; dmaStreamSetTransactionSize(dmatx, tx_size); @@ -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; @@ -345,31 +353,33 @@ void ili9341_fill(int x, int y, int w, int h, int color) { //uint8_t xx[4] = { x >> 8, x, (x+w-1) >> 8, (x+w-1) }; //uint8_t yy[4] = { y >> 8, y, (y+h-1) >> 8, (y+h-1) }; - uint32_t xx = __REV16(x|((x+w-1)<<16)); - uint32_t yy = __REV16(y|((y+h-1)<<16)); + 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); send_command(ILI9341_PAGE_ADDRESS_SET, 4, (uint8_t*)&yy); send_command(ILI9341_MEMORY_WRITE, 0, NULL); int32_t len = w * h; - while (len-- > 0){ - while (SPI_TX_IS_NOT_EMPTY); + while (len-- > 0) { + while (SPI_TX_IS_NOT_EMPTY) + ; SPI_WRITE_16BIT(color); } } void ili9341_bulk(int x, int y, int w, int h) { -//uint8_t xx[4] = { x >> 8, x, (x+w-1) >> 8, (x+w-1) }; -//uint8_t yy[4] = { y >> 8, y, (y+h-1) >> 8, (y+h-1) }; + // uint8_t xx[4] = { x >> 8, x, (x+w-1) >> 8, (x+w-1) }; + // uint8_t yy[4] = { y >> 8, y, (y+h-1) >> 8, (y+h-1) }; uint16_t *buf = spi_buffer; - 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); + 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); send_command(ILI9341_PAGE_ADDRESS_SET, 4, (uint8_t*)&yy); send_command(ILI9341_MEMORY_WRITE, 0, NULL); int32_t len = w * h; - while (len-- > 0){ - while (SPI_TX_IS_NOT_EMPTY); + while (len-- > 0) { + while (SPI_TX_IS_NOT_EMPTY) + ; SPI_WRITE_16BIT(*buf++); } } @@ -378,18 +388,18 @@ static uint8_t ssp_sendrecvdata(void) { // Start RX clock (by sending data) SPI_WRITE_8BIT(0); - while(SPI_RX_IS_EMPTY && SPI_IS_BUSY) + while (SPI_RX_IS_EMPTY && SPI_IS_BUSY) ; return SPI_READ_DATA; } void ili9341_read_memory(int x, int y, int w, int h, int len, uint16_t *out) { -//uint8_t xx[4] = { x >> 8, x, (x+w-1) >> 8, (x+w-1) }; -//uint8_t yy[4] = { y >> 8, y, (y+h-1) >> 8, (y+h-1) }; - 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); + // uint8_t xx[4] = { x >> 8, x, (x+w-1) >> 8, (x+w-1) }; + // uint8_t yy[4] = { y >> 8, y, (y+h-1) >> 8, (y+h-1) }; + 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); send_command(ILI9341_PAGE_ADDRESS_SET, 4, (uint8_t*)&yy); send_command(ILI9341_MEMORY_READ, 0, NULL); @@ -399,11 +409,11 @@ void ili9341_read_memory(int x, int y, int w, int h, int len, uint16_t *out) // require 8bit dummy clock ssp_sendrecvdata(); while (len-- > 0) { - // read data is always 18bit - uint8_t r = ssp_sendrecvdata(); - uint8_t g = ssp_sendrecvdata(); - uint8_t b = ssp_sendrecvdata(); - *out++ = RGB565(r,g,b); + // read data is always 18bit + uint8_t r = ssp_sendrecvdata(); + uint8_t g = ssp_sendrecvdata(); + uint8_t b = ssp_sendrecvdata(); + *out++ = RGB565(r, g, b); } CS_HIGH; } @@ -415,10 +425,10 @@ void ili9341_read_memory(int x, int y, int w, int h, int len, uint16_t *out) // Fill region by some color void ili9341_fill(int x, int y, int w, int h, int color) { - 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); - send_command(ILI9341_PAGE_ADDRESS_SET, 4, (uint8_t*)&yy); + 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); + send_command(ILI9341_PAGE_ADDRESS_SET, 4, (uint8_t *)&yy); send_command(ILI9341_MEMORY_WRITE, 0, NULL); dmaStreamSetMemory0(dmatx, &color); @@ -426,18 +436,20 @@ 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){ - 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); - send_command(ILI9341_PAGE_ADDRESS_SET, 4, (uint8_t*)&yy); +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); + send_command(ILI9341_PAGE_ADDRESS_SET, 4, (uint8_t *)&yy); send_command(ILI9341_MEMORY_WRITE, 0, NULL); uint8_t *buf = (uint8_t *)spi_buffer; int32_t len = w * h; - while (len-- > 0){ + while (len-- > 0) { uint16_t color = palette[*buf++]; - while (SPI_TX_IS_NOT_EMPTY); + while (SPI_TX_IS_NOT_EMPTY) + ; SPI_WRITE_16BIT(color); } } @@ -445,15 +457,16 @@ void ili9341_bulk_8bit(int x, int y, int w, int h, uint16_t *palette){ // Copy spi_buffer to region void ili9341_bulk(int x, int y, int w, int h) { - 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); - send_command(ILI9341_PAGE_ADDRESS_SET, 4, (uint8_t*)&yy); + 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); + send_command(ILI9341_PAGE_ADDRESS_SET, 4, (uint8_t *)&yy); send_command(ILI9341_MEMORY_WRITE, 0, NULL); // 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); } @@ -462,25 +475,25 @@ void ili9341_bulk(int x, int y, int w, int h) void ili9341_read_memory(int x, int y, int w, int h, int len, uint16_t *out) { uint8_t dummy_tx = 0; - uint8_t *rgbbuf=(uint8_t *)out; + uint8_t *rgbbuf = (uint8_t *)out; uint16_t data_size = len * 3 + 1; - 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); - send_command(ILI9341_PAGE_ADDRESS_SET, 4, (uint8_t*)&yy); + 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); + 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); dmaStreamSetMode(dmatx, txdmamode | STM32_DMA_CR_PSIZE_BYTE | STM32_DMA_CR_MSIZE_BYTE); - + // Start DMA exchange dmaStreamEnable(dmatx); dmaStreamEnable(dmarx); @@ -498,39 +511,53 @@ void ili9341_read_memory(int x, int y, int w, int h, int len, uint16_t *out) r = rgbbuf[0]; g = rgbbuf[1]; b = rgbbuf[2]; - *out++ = RGB565(r,g,b); - rgbbuf+=3; + *out++ = RGB565(r, g, b); + rgbbuf += 3; } } #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++) { + for (uint16_t c = 0; c < height; c++) { uint8_t bits = *bitmap++; - for (uint16_t r = 0; r < width; r++) { - *buf++ = (0x80 & bits) ? foreground_color : background_color; - bits <<= 1; - } + for (uint16_t r = 0; r < width; r++) { + *buf++ = (0x80 & bits) ? foreground_color : background_color; + bits <<= 1; + } } 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++) { + for (uint16_t c = 0; c < height; c++) { uint16_t bits = *bitmap++; for (uint16_t r = 0; r < width; r++) { *buf++ = (0x8000 & bits) ? foreground_color : background_color; @@ -552,36 +579,38 @@ void ili9341_drawstring(const char *str, int x, int y) const uint8_t *char_buf = FONT_GET_DATA(ch); uint16_t w = FONT_GET_WIDTH(ch); blit8BitWidthBitmap(x, y, w, FONT_GET_HEIGHT, char_buf); - x+=w; + x += w; } } -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) { uint16_t *buf = spi_buffer; const uint8_t *char_buf = FONT_GET_DATA(ch); - uint16_t w=FONT_GET_WIDTH(ch); - for(int c = 0; c < FONT_GET_HEIGHT; c++, char_buf++){ - for (int i=0;i dy ? dx : -dy) / 2; - while (1){ + while (1) { ili9341_pixel(x0, y0, DEFAULT_FG_COLOR); if (x0 == x1 && y0 == y1) break; diff --git a/main.c b/main.c index 69245fd1..fff210df 100644 --- a/main.c +++ b/main.c @@ -26,16 +26,15 @@ #include "fft.h" #include -//#include #include -//#include #include /* * 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 -//#define VNA_SHELL_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,13 +46,15 @@ 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[]) +typedef void (*vna_shellcmd_t)(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]; -static char *shell_args[VNA_SHELL_MAX_ARGUMENTS + 1]; +static char *shell_args[VNA_SHELL_MAX_ARGUMENTS + 1]; static uint16_t shell_nargs; static volatile vna_shellcmd_t shell_function = 0; @@ -117,21 +118,21 @@ static THD_FUNCTION(Thread1, arg) __WFI(); } // Run Shell command in sweep thread - if (shell_function){ - shell_function(shell_nargs-1, &shell_args[1]); + if (shell_function) { + shell_function(shell_nargs - 1, &shell_args[1]); shell_function = 0; osalThreadSleepMilliseconds(10); continue; } // Process UI inputs ui_process(); - // 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(); + // 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(); // Prepare draw graphics, cache all lines, mark screen cells for redraw plot_into_index(measured); - redraw_request |= REDRAW_CELLS|REDRAW_BATTERY; + redraw_request |= REDRAW_CELLS | REDRAW_BATTERY; if (uistat.marker_tracking) { int i = marker_search(); @@ -142,30 +143,32 @@ 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 } } static inline void pause_sweep(void) { - sweep_mode&=~SWEEP_ENABLE; + sweep_mode &= ~SWEEP_ENABLE; } static inline void resume_sweep(void) { - sweep_mode|=SWEEP_ENABLE; + sweep_mode |= SWEEP_ENABLE; } void toggle_sweep(void) { - sweep_mode^=SWEEP_ENABLE; + sweep_mode ^= SWEEP_ENABLE; } 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); @@ -197,70 +201,70 @@ transform_domain(void) uint8_t window_size = POINTS_COUNT, offset = 0; uint8_t is_lowpass = FALSE; switch (domain_mode & TD_FUNC) { - case TD_FUNC_BANDPASS: - offset = 0; - window_size = POINTS_COUNT; - break; - case TD_FUNC_LOWPASS_IMPULSE: - case TD_FUNC_LOWPASS_STEP: - is_lowpass = TRUE; - offset = POINTS_COUNT; - window_size = POINTS_COUNT*2; - break; + case TD_FUNC_BANDPASS: + offset = 0; + window_size = POINTS_COUNT; + break; + case TD_FUNC_LOWPASS_IMPULSE: + case TD_FUNC_LOWPASS_STEP: + is_lowpass = TRUE; + offset = POINTS_COUNT; + window_size = POINTS_COUNT * 2; + break; } float beta = 0.0; switch (domain_mode & TD_WINDOW) { - case TD_WINDOW_MINIMUM: - beta = 0.0; // this is rectangular - break; - case TD_WINDOW_NORMAL: - beta = 6.0; - break; - case TD_WINDOW_MAXIMUM: - beta = 13; - break; + case TD_WINDOW_MINIMUM: + beta = 0.0; // this is rectangular + break; + case TD_WINDOW_NORMAL: + beta = 6.0; + break; + case TD_WINDOW_MAXIMUM: + beta = 13; + break; } - for (int ch = 0; ch < 2; ch++) { - memcpy(tmp, measured[ch], sizeof(measured[0])); - for (int i = 0; i < POINTS_COUNT; i++) { - float w = kaiser_window(i+offset, window_size, beta); - tmp[i*2+0] *= w; - tmp[i*2+1] *= w; - } - for (int i = POINTS_COUNT; i < FFT_SIZE; i++) { - tmp[i*2+0] = 0.0; - tmp[i*2+1] = 0.0; - } - if (is_lowpass) { - for (int i = 1; i < POINTS_COUNT; i++) { - tmp[(FFT_SIZE-i)*2+0] = tmp[i*2+0]; - tmp[(FFT_SIZE-i)*2+1] = -tmp[i*2+1]; - } + memcpy(tmp, measured[ch], sizeof(measured[0])); + for (int i = 0; i < POINTS_COUNT; i++) { + float w = kaiser_window(i + offset, window_size, beta); + tmp[i * 2 + 0] *= w; + tmp[i * 2 + 1] *= w; + } + for (int i = POINTS_COUNT; i < FFT_SIZE; i++) { + tmp[i * 2 + 0] = 0.0; + tmp[i * 2 + 1] = 0.0; + } + if (is_lowpass) { + for (int i = 1; i < POINTS_COUNT; i++) { + tmp[(FFT_SIZE - i) * 2 + 0] = tmp[i * 2 + 0]; + tmp[(FFT_SIZE - i) * 2 + 1] = -tmp[i * 2 + 1]; } + } - fft256_inverse((float(*)[2])tmp); - memcpy(measured[ch], tmp, sizeof(measured[0])); - for (int i = 0; i < POINTS_COUNT; i++) { - measured[ch][i][0] /= (float)FFT_SIZE; - if (is_lowpass) { - measured[ch][i][1] = 0.0; - } else { - measured[ch][i][1] /= (float)FFT_SIZE; - } + fft256_inverse((float(*)[2])tmp); + memcpy(measured[ch], tmp, sizeof(measured[0])); + for (int i = 0; i < POINTS_COUNT; i++) { + measured[ch][i][0] /= (float)FFT_SIZE; + if (is_lowpass) { + measured[ch][i][1] = 0.0; + } else { + measured[ch][i][1] /= (float)FFT_SIZE; } - if ( (domain_mode & TD_FUNC) == TD_FUNC_LOWPASS_STEP ) { - for (int i = 1; i < POINTS_COUNT; i++) { - measured[ch][i][0] += measured[ch][i-1][0]; - } + } + if ((domain_mode & TD_FUNC) == TD_FUNC_LOWPASS_STEP) { + for (int i = 1; i < POINTS_COUNT; i++) { + measured[ch][i][0] += measured[ch][i - 1][0]; } + } } } // 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,13 +441,15 @@ 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){ + while (1) { char *p = v; - while (1){ - char c = *list; if (c == '|') c = 0; - if (c == *p++){ + while (1) { + char c = *list; + if (c == '|') c = 0; + if (c == *p++) { // Found, return index if (c == 0) return i; list++; // Compare next symbol @@ -450,9 +458,9 @@ static int getStringIndex(char *v, const char *list){ break; // Not equal, break } // Set new substring ptr - while (1){ + while (1) { // End of string, not found - if (*list == 0 ) return -1; + if (*list == 0) return -1; if (*list++ == '|') break; } i++; @@ -684,11 +692,11 @@ VNA_SHELL_FUNCTION(cmd_capture) #error "Low size of spi_buffer for cmd_capture" #endif // read 2 row pixel time (read buffer limit by 2/3 + 1 from spi_buffer size) - for (y=0; y < 240; y+=2){ + for (y = 0; y < 240; y += 2) { // use uint16_t spi_buffer[2048] (defined in ili9341) for read buffer uint8_t *buf = (uint8_t *)spi_buffer; - ili9341_read_memory(0, y, 320, 2, 2*320, spi_buffer); - for (i = 0; i < 4*320; i++) { + ili9341_read_memory(0, y, 320, 2, 2 * 320, spi_buffer); + for (i = 0; i < 4 * 320; i++) { streamPut(shell_stream, *buf++); } } @@ -715,14 +723,21 @@ static void (*sample_func)(float *gamma) = calculate_gamma; VNA_SHELL_FUNCTION(cmd_sample) { - if (argc!=1) goto usage; + 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 @@ -808,7 +824,7 @@ bool sweep(bool break_on_operation) if (frequencies[i] == 0) break; delay = set_frequency(frequencies[i]); // 700 tlv320aic3204_select(0); // 60 CH0:REFLECT, reset and begin measure - DSP_START(delay+((i==0)?1:0)); // 1900 + DSP_START(delay + ((i == 0) ? 1 : 0)); // 1900 //================================================ // Place some code thats need execute while delay //================================================ @@ -870,17 +886,15 @@ VNA_SHELL_FUNCTION(cmd_scan) pause_sweep(); sweep(false); // Output data after if set (faster data recive) - if (argc == 4){ + if (argc == 4) { uint16_t mask = my_atoui(argv[3]); - 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]); - shell_printf("\r\n"); + 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]); + shell_printf("\r\n"); + } } } } @@ -905,7 +919,7 @@ update_marker_index(void) } else { for (i = 0; i < sweep_points-1; i++) { if (frequencies[i] <= f && f < frequencies[i+1]) { - markers[m].index = f < (frequencies[i]/2 + frequencies[i+1]/2) ? i : i+1; + markers[m].index = f < (frequencies[i] / 2 + frequencies[i + 1] / 2) ? i : i + 1; break; } } @@ -927,7 +941,7 @@ set_frequencies(uint32_t start, uint32_t stop, uint16_t points) df+=error; if (df >=step) { f++; - df-=step; + df -= step; } } // disable at out of sweep range @@ -943,10 +957,10 @@ update_frequencies(void) stop = get_sweep_frequency(ST_STOP); set_frequencies(start, stop, sweep_points); -// operation_requested|= OP_FREQCHANGE; - + // operation_requested|= OP_FREQCHANGE; + update_marker_index(); - + // set grid layout update_grid(); } @@ -957,67 +971,65 @@ set_sweep_frequency(int type, uint32_t freq) int cal_applied = cal_status & CALSTAT_APPLY; // Check frequency for out of bounds (minimum SPAN can be any value) - if (type!=ST_SPAN && freq < START_MIN) + if (type != ST_SPAN && freq < START_MIN) freq = START_MIN; if (freq > STOP_MAX) freq = STOP_MAX; ensure_edit_config(); switch (type) { - case ST_START: - config.freq_mode&=~FREQ_MODE_CENTER_SPAN; - if (frequency0 != freq) { - frequency0 = freq; - // if start > stop then make start = stop - if (frequency1 < freq) - frequency1 = freq; - } - break; - case ST_STOP: - config.freq_mode&=~FREQ_MODE_CENTER_SPAN; - if (frequency1 != freq) { - frequency1 = freq; - // if start > stop then make start = stop - if (frequency0 > freq) + case ST_START: + config.freq_mode &= ~FREQ_MODE_CENTER_SPAN; + if (frequency0 != freq) { frequency0 = freq; - } - break; - case ST_CENTER: - config.freq_mode|=FREQ_MODE_CENTER_SPAN; - uint32_t center = frequency0/2 + frequency1/2; - if (center != freq) { - uint32_t span = frequency1 - frequency0; - if (freq < START_MIN + span/2) { - span = (freq - START_MIN) * 2; + // if start > stop then make start = stop + if (frequency1 < freq) frequency1 = freq; } - if (freq > STOP_MAX - span/2) { - span = (STOP_MAX - freq) * 2; + break; + case ST_STOP: + config.freq_mode &= ~FREQ_MODE_CENTER_SPAN; + if (frequency1 != freq) { + frequency1 = freq; + // if start > stop then make start = stop + if (frequency0 > freq) frequency0 = freq; } - frequency0 = freq - span/2; - frequency1 = freq + span/2; - } - break; - case ST_SPAN: - config.freq_mode|=FREQ_MODE_CENTER_SPAN; - if (frequency1 - frequency0 != freq) { - uint32_t center = frequency0/2 + frequency1/2; - if (center < START_MIN + freq/2) { - center = START_MIN + freq/2; + break; + case ST_CENTER: + config.freq_mode |= FREQ_MODE_CENTER_SPAN; + uint32_t center = frequency0 / 2 + frequency1 / 2; + if (center != freq) { + uint32_t span = frequency1 - frequency0; + if (freq < START_MIN + span / 2) { + span = (freq - START_MIN) * 2; + } + if (freq > STOP_MAX - span / 2) { + span = (STOP_MAX - freq) * 2; + } + frequency0 = freq - span / 2; + frequency1 = freq + span / 2; + } + break; + case ST_SPAN: + config.freq_mode |= FREQ_MODE_CENTER_SPAN; + if (frequency1 - frequency0 != freq) { + uint32_t center = frequency0 / 2 + frequency1 / 2; + if (center < START_MIN + freq / 2) { + center = START_MIN + freq / 2; + } + if (center > STOP_MAX - freq / 2) { + center = STOP_MAX - freq / 2; + } + frequency0 = center - freq / 2; + frequency1 = center + freq / 2; } - if (center > STOP_MAX - freq/2) { - center = STOP_MAX - freq/2; + break; + case ST_CW: + config.freq_mode |= FREQ_MODE_CENTER_SPAN; + if (frequency0 != freq || frequency1 != freq) { + frequency0 = freq; + frequency1 = freq; } - frequency0 = center - freq/2; - frequency1 = center + freq/2; - } - break; - case ST_CW: - config.freq_mode|=FREQ_MODE_CENTER_SPAN; - if (frequency0 != freq || frequency1 != freq) { - frequency0 = freq; - frequency1 = freq; - } - break; + break; } update_frequencies(); if (cal_auto_interpolate && cal_applied) @@ -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; @@ -1049,16 +1065,16 @@ VNA_SHELL_FUNCTION(cmd_sweep) } uint32_t value0 = 0; uint32_t value1 = 0; - if (argc >=1) value0 = my_atoui(argv[0]); - if (argc >=2) value1 = my_atoui(argv[1]); -#if MAX_FREQ_TYPE!=5 + if (argc >= 1) value0 = my_atoui(argv[0]); + if (argc >= 2) value1 = my_atoui(argv[1]); +#if MAX_FREQ_TYPE != 5 #error "Sweep mode possibly changed, check cmd_sweep function" #endif // Parse sweep {start|stop|center|span|cw} {freq(Hz)} // 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); @@ -1367,7 +1383,7 @@ cal_interpolate(int s) // found f between freqs at j and j+1 float k1 = (float)(f - src->_frequencies[j]) / (src->_frequencies[j+1] - src->_frequencies[j]); - + // avoid glitch between freqs in different harmonics mode if (IS_HARMONIC_MODE(src->_frequencies[j]) != IS_HARMONIC_MODE(src->_frequencies[j+1])) { // assume f[j] < f[j+1] @@ -1385,7 +1401,7 @@ cal_interpolate(int s) if (j == src->_sweep_points-1) break; } - + // upper than end freq of src range for (; i < sweep_points; i++) { // fill cal_data at tail of src @@ -1415,27 +1431,46 @@ 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; - 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]); + 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]); shell_printf("%f %f\r\n", cal_data[CAL_SHORT][0][0], cal_data[CAL_SHORT][0][1]); - shell_printf("%f %f\r\n", cal_data[CAL_THRU ][0][0], cal_data[CAL_THRU ][0][1]); + shell_printf("%f %f\r\n", cal_data[CAL_THRU][0][0], cal_data[CAL_THRU][0][1]); shell_printf("%f %f\r\n", cal_data[CAL_ISOLN][0][0], cal_data[CAL_ISOLN][0][1]); return; 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); } @@ -1517,7 +1552,7 @@ void set_trace_type(int t, int type) // Set default trace scale trace[t].scale = trace_info[type].scale_unit; force = TRUE; - } + } if (force) { plot_into_index(measured); force_set_markmap(); @@ -1572,7 +1607,7 @@ VNA_SHELL_FUNCTION(cmd_trace) } } return; - } + } if (strcmp(argv[0], "all") == 0 && argc > 1 && strcmp(argv[1], "off") == 0) { @@ -1590,20 +1625,20 @@ VNA_SHELL_FUNCTION(cmd_trace) shell_printf("%d %s %s\r\n", t, type, channel); return; } -#if MAX_TRACE_TYPE!=12 +#if MAX_TRACE_TYPE != 12 #error "Trace type enum possibly changed, check cmd_trace function" #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); - if (type >= 0){ + int type = get_str_index(argv[1], cmd_type_list); + if (type >= 0) { set_trace_type(t, type); goto check_ch_num; } // 0 1 static const char cmd_scale_ref_list[] = "scale|refpos"; - if (argc >= 3){ - switch (getStringIndex(argv[1], cmd_scale_ref_list)){ + if (argc >= 3) { + 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: @@ -1726,7 +1761,7 @@ VNA_SHELL_FUNCTION(cmd_touchtest) (void)argv; do { touch_draw_test(); - } while(argc); + } while (argc); } VNA_SHELL_FUNCTION(cmd_frequencies) @@ -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; @@ -1941,7 +1993,7 @@ VNA_SHELL_FUNCTION(cmd_info) { (void)argc; (void)argv; - int i=0; + int i = 0; while (info_about[i]) shell_printf("%s\r\n", info_about[i++]); } @@ -1956,7 +2008,7 @@ VNA_SHELL_FUNCTION(cmd_color) shell_printf("usage: color {id} {rgb24}\r\n"); for (i=-3; i < TRACES_MAX; i++) { #if 0 - switch(i){ + switch(i) { case -3: color = config.grid_color; break; case -2: color = config.menu_normal_color; break; case -1: color = config.menu_active_color; break; @@ -1981,7 +2033,7 @@ VNA_SHELL_FUNCTION(cmd_color) return; color = RGBHEX(my_atoui(argv[1])); #if 0 - switch(i){ + switch(i) { case -3: config.grid_color = color; break; case -2: config.menu_normal_color = color; break; case -1: config.menu_active_color = color; break; @@ -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,18 +2169,19 @@ 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; - while (1){ + while (1) { // Return 0 only if stream not active if (streamRead(shell_stream, &c, 1) == 0) return 0; // Backspace or Delete if (c == 8 || c == 0x7f) { if (ptr != line) { - static const char backspace[] = {0x08,0x20,0x08,0x00}; + static const char backspace[] = {0x08, 0x20, 0x08, 0x00}; shell_printf(backspace); ptr--; } @@ -2154,52 +2208,54 @@ 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){ + 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. - ep = (*lp == '"') ? strpbrk(++lp, "\"") : strpbrk( lp, " \t"); + while (*lp == ' ' || *lp == '\t') lp++; + // 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; + 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++) { + for (scp = commands; scp->sc_name != NULL; scp++) { if (strcmp(scp->sc_name, shell_args[0]) == 0) { - if (scp->flags&CMD_WAIT_MUTEX){ - shell_function= scp->sc_function; + if (scp->flags & CMD_WAIT_MUTEX) { + shell_function = scp->sc_function; // Wait execute command in sweep thread - do{ + do { osalThreadSleepMilliseconds(100); - } while(shell_function); + } while (shell_function); + } else { + scp->sc_function(shell_nargs - 1, &shell_args[1]); } - else - scp->sc_function(shell_nargs-1, &shell_args[1]); return; } } - shell_printf("%s?"VNA_SHELL_NEWLINE_STR, shell_args[0]); + shell_printf("%s?" VNA_SHELL_NEWLINE_STR, shell_args[0]); } #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); @@ -2341,20 +2397,21 @@ int main(void) /* The prototype shows it is a naked function - in effect this is just an assembly function. */ -void HardFault_Handler( void ); +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) { - uint32_t* sp; + uint32_t *sp; //__asm volatile ("mrs %0, msp \n\t": "=r" (sp) ); - __asm volatile ("mrs %0, psp \n\t": "=r" (sp) ); + __asm volatile("mrs %0, psp \n\t" : "=r"(sp)); hard_fault_handler_c(sp); } -void hard_fault_handler_c(uint32_t* sp) +void hard_fault_handler_c(uint32_t *sp) { (void)sp; - while (true) {} + while (true) { + } } diff --git a/mcuconf.h b/mcuconf.h index 9021c85d..a1da2872 100644 --- a/mcuconf.h +++ b/mcuconf.h @@ -96,7 +96,7 @@ #define STM32_EXT_EXTI17_IRQ_PRIORITY 3 #define STM32_EXT_EXTI21_22_IRQ_PRIORITY 3 -#define STM32_DISABLE_EXTI2122_HANDLER TRUE +#define STM32_DISABLE_EXTI2122_HANDLER TRUE /* * GPT driver system settings. diff --git a/nanovna.h b/nanovna.h index 281fa264..d553f386 100644 --- a/nanovna.h +++ b/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 @@ -169,15 +169,15 @@ extern int16_t area_height; // font extern const uint8_t x5x7_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 -#define FONT_GET_HEIGHT 7 +#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 +#define FONT_GET_HEIGHT 7 extern const uint16_t numfont16x22[]; -#define NUM_FONT_GET_DATA(ch) (&numfont16x22[ch*22]) -#define NUM_FONT_GET_WIDTH 16 -#define NUM_FONT_GET_HEIGHT 22 +#define NUM_FONT_GET_DATA(ch) (&numfont16x22[ch*22]) +#define NUM_FONT_GET_WIDTH 16 +#define NUM_FONT_GET_HEIGHT 22 #define S_DELTA "\004" #define S_DEGREE "\037" @@ -306,21 +306,21 @@ extern volatile uint8_t redraw_request; #define RGBHEX(hex) ( (((hex)&0x001c00)<<3) | (((hex)&0x0000f8)<<5) | (((hex)&0xf80000)>>16) | (((hex)&0x00e000)>>13) ) // Define size of screen buffer in pixels (one pixel 16bit size) -#define SPI_BUFFER_SIZE 2048 - -#define DEFAULT_FG_COLOR RGB565(255,255,255) -#define DEFAULT_BG_COLOR RGB565( 0, 0, 0) -#define DEFAULT_GRID_COLOR RGB565(128,128,128) -#define DEFAULT_MENU_COLOR RGB565(255,255,255) -#define DEFAULT_MENU_TEXT_COLOR RGB565( 0, 0, 0) -#define DEFAULT_MENU_ACTIVE_COLOR RGB565(180,255,180) -#define DEFAULT_TRACE_1_COLOR RGB565(255,255, 0) -#define DEFAULT_TRACE_2_COLOR RGB565( 0,255,255) -#define DEFAULT_TRACE_3_COLOR RGB565( 0,255, 0) -#define DEFAULT_TRACE_4_COLOR RGB565(255, 0,255) -#define DEFAULT_NORMAL_BAT_COLOR RGB565( 31,227, 0) -#define DEFAULT_LOW_BAT_COLOR RGB565(255, 0, 0) -#define DEFAULT_SPEC_INPUT_COLOR RGB565(128,255,128); +#define SPI_BUFFER_SIZE 2048 + +#define DEFAULT_FG_COLOR RGB565(255,255,255) +#define DEFAULT_BG_COLOR RGB565( 0, 0, 0) +#define DEFAULT_GRID_COLOR RGB565(128,128,128) +#define DEFAULT_MENU_COLOR RGB565(255,255,255) +#define DEFAULT_MENU_TEXT_COLOR RGB565( 0, 0, 0) +#define DEFAULT_MENU_ACTIVE_COLOR RGB565(180,255,180) +#define DEFAULT_TRACE_1_COLOR RGB565(255,255, 0) +#define DEFAULT_TRACE_2_COLOR RGB565( 0,255,255) +#define DEFAULT_TRACE_3_COLOR RGB565( 0,255, 0) +#define DEFAULT_TRACE_4_COLOR RGB565(255, 0,255) +#define DEFAULT_NORMAL_BAT_COLOR RGB565( 31,227, 0) +#define DEFAULT_LOW_BAT_COLOR RGB565(255, 0, 0) +#define DEFAULT_SPEC_INPUT_COLOR RGB565(128,255,128); extern uint16_t foreground_color; extern uint16_t background_color; @@ -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); diff --git a/numfont20x22.c b/numfont20x22.c index 34ce9474..85498ec1 100644 --- a/numfont20x22.c +++ b/numfont20x22.c @@ -24,533 +24,532 @@ const uint16_t numfont16x22[] = { - 0b0000111111110000, - 0b0011111111111100, - 0b0111111111111110, - 0b0111110000111110, - 0b1111100000011111, - 0b1111000000001111, - 0b1111000000001111, - 0b1111000000001111, - 0b1111000000001111, - 0b1111000000001111, - 0b1111000000001111, - 0b1111000000001111, - 0b1111000000001111, - 0b1111000000001111, - 0b1111000000001111, - 0b1111000000001111, - 0b1111000000001111, - 0b1111100000011111, - 0b0111110000111110, - 0b0111111111111110, - 0b0011111111111100, - 0b0000111111110000, + 0b0000111111110000, + 0b0011111111111100, + 0b0111111111111110, + 0b0111110000111110, + 0b1111100000011111, + 0b1111000000001111, + 0b1111000000001111, + 0b1111000000001111, + 0b1111000000001111, + 0b1111000000001111, + 0b1111000000001111, + 0b1111000000001111, + 0b1111000000001111, + 0b1111000000001111, + 0b1111000000001111, + 0b1111000000001111, + 0b1111000000001111, + 0b1111100000011111, + 0b0111110000111110, + 0b0111111111111110, + 0b0011111111111100, + 0b0000111111110000, - 0b0000000011110000, - 0b0000000111110000, - 0b0000001111110000, - 0b0000011111110000, - 0b0000111111110000, - 0b0000111111110000, - 0b0000111011110000, - 0b0000110011110000, - 0b0000000011110000, - 0b0000000011110000, - 0b0000000011110000, - 0b0000000011110000, - 0b0000000011110000, - 0b0000000011110000, - 0b0000000011110000, - 0b0000000011110000, - 0b0000000011110000, - 0b0000000011110000, - 0b0000000011110000, - 0b0000001111111100, - 0b0000001111111100, - 0b0000001111111100, + 0b0000000011110000, + 0b0000000111110000, + 0b0000001111110000, + 0b0000011111110000, + 0b0000111111110000, + 0b0000111111110000, + 0b0000111011110000, + 0b0000110011110000, + 0b0000000011110000, + 0b0000000011110000, + 0b0000000011110000, + 0b0000000011110000, + 0b0000000011110000, + 0b0000000011110000, + 0b0000000011110000, + 0b0000000011110000, + 0b0000000011110000, + 0b0000000011110000, + 0b0000000011110000, + 0b0000001111111100, + 0b0000001111111100, + 0b0000001111111100, - 0b0000111111110000, - 0b0011111111111100, - 0b0111111111111110, - 0b0111110000111110, - 0b1111100000011111, - 0b1111000000001111, - 0b1111000000001111, - 0b0000000000011111, - 0b0000000000111111, - 0b0000000001111110, - 0b0000000011111100, - 0b0000000111111000, - 0b0000001111110000, - 0b0000011111100000, - 0b0000111111000000, - 0b0001111110000000, - 0b0011111100000000, - 0b0111111000000000, - 0b1111110000000000, - 0b1111111111111111, - 0b1111111111111111, - 0b1111111111111111, + 0b0000111111110000, + 0b0011111111111100, + 0b0111111111111110, + 0b0111110000111110, + 0b1111100000011111, + 0b1111000000001111, + 0b1111000000001111, + 0b0000000000011111, + 0b0000000000111111, + 0b0000000001111110, + 0b0000000011111100, + 0b0000000111111000, + 0b0000001111110000, + 0b0000011111100000, + 0b0000111111000000, + 0b0001111110000000, + 0b0011111100000000, + 0b0111111000000000, + 0b1111110000000000, + 0b1111111111111111, + 0b1111111111111111, + 0b1111111111111111, - 0b0000111111110000, - 0b0011111111111100, - 0b0111111111111110, - 0b0111110000111110, - 0b1111100000011111, - 0b1111000000001111, - 0b1111000000001111, - 0b0000000000011110, - 0b0000000000111110, - 0b0000000111111100, - 0b0000000111111000, - 0b0000000111111100, - 0b0000000001111110, - 0b0000000000011111, - 0b0000000000001111, - 0b1111000000001111, - 0b1111000000001111, - 0b1111100000011111, - 0b0111110000111110, - 0b0111111111111110, - 0b0011111111111100, - 0b0000111111110000, + 0b0000111111110000, + 0b0011111111111100, + 0b0111111111111110, + 0b0111110000111110, + 0b1111100000011111, + 0b1111000000001111, + 0b1111000000001111, + 0b0000000000011110, + 0b0000000000111110, + 0b0000000111111100, + 0b0000000111111000, + 0b0000000111111100, + 0b0000000001111110, + 0b0000000000011111, + 0b0000000000001111, + 0b1111000000001111, + 0b1111000000001111, + 0b1111100000011111, + 0b0111110000111110, + 0b0111111111111110, + 0b0011111111111100, + 0b0000111111110000, - 0b0000000111111000, - 0b0000000111111000, - 0b0000001111111000, - 0b0000001111111000, - 0b0000011111111000, - 0b0000011111111000, - 0b0000111111111000, - 0b0000111101111000, - 0b0001111101111000, - 0b0001111001111000, - 0b0011111001111000, - 0b0011110001111000, - 0b0111110001111000, - 0b0111100001111000, - 0b1111100001111000, - 0b1111111111111111, - 0b1111111111111111, - 0b1111111111111111, - 0b0000000001111000, - 0b0000000001111000, - 0b0000000001111000, - 0b0000000001111000, + 0b0000000111111000, + 0b0000000111111000, + 0b0000001111111000, + 0b0000001111111000, + 0b0000011111111000, + 0b0000011111111000, + 0b0000111111111000, + 0b0000111101111000, + 0b0001111101111000, + 0b0001111001111000, + 0b0011111001111000, + 0b0011110001111000, + 0b0111110001111000, + 0b0111100001111000, + 0b1111100001111000, + 0b1111111111111111, + 0b1111111111111111, + 0b1111111111111111, + 0b0000000001111000, + 0b0000000001111000, + 0b0000000001111000, + 0b0000000001111000, - 0b1111111111111111, - 0b1111111111111111, - 0b1111111111111111, - 0b1111000000000000, - 0b1111000000000000, - 0b1111000000000000, - 0b1111000000000000, - 0b1111011111110000, - 0b1111111111111100, - 0b1111111111111110, - 0b1111110000111110, - 0b1111100000011111, - 0b0000000000001111, - 0b0000000000001111, - 0b0000000000001111, - 0b0000000000001111, - 0b1111000000001111, - 0b1111100000011111, - 0b0111110000111110, - 0b0111111111111110, - 0b0011111111111100, - 0b0000111111110000, + 0b1111111111111111, + 0b1111111111111111, + 0b1111111111111111, + 0b1111000000000000, + 0b1111000000000000, + 0b1111000000000000, + 0b1111000000000000, + 0b1111011111110000, + 0b1111111111111100, + 0b1111111111111110, + 0b1111110000111110, + 0b1111100000011111, + 0b0000000000001111, + 0b0000000000001111, + 0b0000000000001111, + 0b0000000000001111, + 0b1111000000001111, + 0b1111100000011111, + 0b0111110000111110, + 0b0111111111111110, + 0b0011111111111100, + 0b0000111111110000, - 0b0000111111110000, - 0b0011111111111100, - 0b0111111111111110, - 0b0111110000111110, - 0b1111100000011111, - 0b1111000000001111, - 0b1111000000000000, - 0b1111000000000000, - 0b1111011111110000, - 0b1111111111111100, - 0b1111111111111110, - 0b1111110000111110, - 0b1111100000011111, - 0b1111000000001111, - 0b1111000000001111, - 0b1111000000001111, - 0b1111000000001111, - 0b1111100000011111, - 0b0111110000111110, - 0b0111111111111110, - 0b0011111111111100, - 0b0000111111110000, + 0b0000111111110000, + 0b0011111111111100, + 0b0111111111111110, + 0b0111110000111110, + 0b1111100000011111, + 0b1111000000001111, + 0b1111000000000000, + 0b1111000000000000, + 0b1111011111110000, + 0b1111111111111100, + 0b1111111111111110, + 0b1111110000111110, + 0b1111100000011111, + 0b1111000000001111, + 0b1111000000001111, + 0b1111000000001111, + 0b1111000000001111, + 0b1111100000011111, + 0b0111110000111110, + 0b0111111111111110, + 0b0011111111111100, + 0b0000111111110000, - 0b1111111111111111, - 0b1111111111111111, - 0b1111111111111111, - 0b0000000000011111, - 0b0000000000111110, - 0b0000000001111100, - 0b0000000011111000, - 0b0000000111110000, - 0b0000000111100000, - 0b0000001111100000, - 0b0000001111000000, - 0b0000011111000000, - 0b0000011110000000, - 0b0000011110000000, - 0b0000111110000000, - 0b0000111100000000, - 0b0000111100000000, - 0b0000111100000000, - 0b0000111100000000, - 0b0000111100000000, - 0b0000111100000000, - 0b0000111100000000, + 0b1111111111111111, + 0b1111111111111111, + 0b1111111111111111, + 0b0000000000011111, + 0b0000000000111110, + 0b0000000001111100, + 0b0000000011111000, + 0b0000000111110000, + 0b0000000111100000, + 0b0000001111100000, + 0b0000001111000000, + 0b0000011111000000, + 0b0000011110000000, + 0b0000011110000000, + 0b0000111110000000, + 0b0000111100000000, + 0b0000111100000000, + 0b0000111100000000, + 0b0000111100000000, + 0b0000111100000000, + 0b0000111100000000, + 0b0000111100000000, - 0b0000011111100000, - 0b0001111111111000, - 0b0011111111111100, - 0b0111110000111110, - 0b0111100000011110, - 0b0111100000011110, - 0b0111100000011110, - 0b0011110000111100, - 0b0001111111111000, - 0b0000111111110000, - 0b0011111111111100, - 0b0111110000111110, - 0b0111100000011110, - 0b1111000000001111, - 0b1111000000001111, - 0b1111000000001111, - 0b1111000000001111, - 0b1111100000011111, - 0b0111110000111110, - 0b0111111111111110, - 0b0011111111111100, - 0b0000111111110000, + 0b0000011111100000, + 0b0001111111111000, + 0b0011111111111100, + 0b0111110000111110, + 0b0111100000011110, + 0b0111100000011110, + 0b0111100000011110, + 0b0011110000111100, + 0b0001111111111000, + 0b0000111111110000, + 0b0011111111111100, + 0b0111110000111110, + 0b0111100000011110, + 0b1111000000001111, + 0b1111000000001111, + 0b1111000000001111, + 0b1111000000001111, + 0b1111100000011111, + 0b0111110000111110, + 0b0111111111111110, + 0b0011111111111100, + 0b0000111111110000, - 0b0000111111110000, - 0b0011111111111100, - 0b0111111111111110, - 0b0111110000111110, - 0b1111100000011111, - 0b1111000000001111, - 0b1111000000001111, - 0b1111000000001111, - 0b1111000000001111, - 0b1111100000011111, - 0b0111110000111111, - 0b0111111111111111, - 0b0011111111111111, - 0b0000111111111111, - 0b0000000000001111, - 0b0000000000001111, - 0b1111000000001111, - 0b1111100000011111, - 0b0111110000111110, - 0b0111111111111110, - 0b0011111111111100, - 0b0000111111110000, + 0b0000111111110000, + 0b0011111111111100, + 0b0111111111111110, + 0b0111110000111110, + 0b1111100000011111, + 0b1111000000001111, + 0b1111000000001111, + 0b1111000000001111, + 0b1111000000001111, + 0b1111100000011111, + 0b0111110000111111, + 0b0111111111111111, + 0b0011111111111111, + 0b0000111111111111, + 0b0000000000001111, + 0b0000000000001111, + 0b1111000000001111, + 0b1111100000011111, + 0b0111110000111110, + 0b0111111111111110, + 0b0011111111111100, + 0b0000111111110000, - 0b0000000000000000, - 0b0000000000000000, - 0b0000000000000000, - 0b0000000000000000, - 0b0000000000000000, - 0b0000000000000000, - 0b0000000000000000, - 0b0000000000000000, - 0b0000000000000000, - 0b0000000000000000, - 0b0000000000000000, - 0b0000000000000000, - 0b0000000000000000, - 0b0000000000000000, - 0b0000000000000000, - 0b0000000000000000, - 0b0000000000000000, - 0b0000001110000000, - 0b0000011111000000, - 0b0000011111000000, - 0b0000001110000000, - 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000001110000000, + 0b0000011111000000, + 0b0000011111000000, + 0b0000001110000000, + 0b0000000000000000, - 0b0000000000000000, - 0b0000000000000000, - 0b0000000000000000, - 0b0000000000000000, - 0b0000000000000000, - 0b0000000000000000, - 0b0000000000000000, - 0b0000000000000000, - 0b0000000000000000, - 0b0000000000000000, - 0b0011111111111100, - 0b0011111111111100, - 0b0011111111111100, - 0b0011111111111100, - 0b0000000000000000, - 0b0000000000000000, - 0b0000000000000000, - 0b0000000000000000, - 0b0000000000000000, - 0b0000000000000000, - 0b0000000000000000, - 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0011111111111100, + 0b0011111111111100, + 0b0011111111111100, + 0b0011111111111100, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, - 0b0000000000000011, - 0b0000000000000111, - 0b0000000000001111, - 0b0000000000011111, - 0b0000000000111111, - 0b0000000001111111, - 0b0000000000001111, - 0b0000000000001111, - 0b0000000000001111, - 0b0110000011001111, - 0b1111000111101111, - 0b0111101111001111, - 0b0011111110001111, - 0b0001111100001111, - 0b0001111100001111, - 0b0011111110001111, - 0b0111101111001111, - 0b1111000111101111, - 0b0110000011001111, - 0b0000000000001111, - 0b0000000000001111, - 0b0000000000001111, + 0b0000000000000011, + 0b0000000000000111, + 0b0000000000001111, + 0b0000000000011111, + 0b0000000000111111, + 0b0000000001111111, + 0b0000000000001111, + 0b0000000000001111, + 0b0000000000001111, + 0b0110000011001111, + 0b1111000111101111, + 0b0111101111001111, + 0b0011111110001111, + 0b0001111100001111, + 0b0001111100001111, + 0b0011111110001111, + 0b0111101111001111, + 0b1111000111101111, + 0b0110000011001111, + 0b0000000000001111, + 0b0000000000001111, + 0b0000000000001111, - 0b1111000000000000, - 0b1111000000000000, - 0b1111000000000000, - 0b1111000000000000, - 0b1111000000000000, - 0b1111000000000000, - 0b1111000000111110, - 0b1111000001111100, - 0b1111000011111000, - 0b1111000111110000, - 0b1111001111100000, - 0b1111011111000000, - 0b1111111110000000, - 0b1111111100000000, - 0b1111111100000000, - 0b1111111110000000, - 0b1111011111000000, - 0b1111001111100000, - 0b1111000111110000, - 0b1111000011111000, - 0b1111000001111100, - 0b1111000000111110, + 0b1111000000000000, + 0b1111000000000000, + 0b1111000000000000, + 0b1111000000000000, + 0b1111000000000000, + 0b1111000000000000, + 0b1111000000111110, + 0b1111000001111100, + 0b1111000011111000, + 0b1111000111110000, + 0b1111001111100000, + 0b1111011111000000, + 0b1111111110000000, + 0b1111111100000000, + 0b1111111100000000, + 0b1111111110000000, + 0b1111011111000000, + 0b1111001111100000, + 0b1111000111110000, + 0b1111000011111000, + 0b1111000001111100, + 0b1111000000111110, - 0b1111000000001111, - 0b1111000000001111, - 0b1111100000011111, - 0b1111100000011111, - 0b1111110000111111, - 0b1111110000111111, - 0b1111111001111111, - 0b1111111001111111, - 0b1111111111111111, - 0b1111111111111111, - 0b1111111111111111, - 0b1111111111111111, - 0b1111011111101111, - 0b1111011111101111, - 0b1111001111001111, - 0b1111001111001111, - 0b1111000110001111, - 0b1111000110001111, - 0b1111000000001111, - 0b1111000000001111, - 0b1111000000001111, - 0b1111000000001111, + 0b1111000000001111, + 0b1111000000001111, + 0b1111100000011111, + 0b1111100000011111, + 0b1111110000111111, + 0b1111110000111111, + 0b1111111001111111, + 0b1111111001111111, + 0b1111111111111111, + 0b1111111111111111, + 0b1111111111111111, + 0b1111111111111111, + 0b1111011111101111, + 0b1111011111101111, + 0b1111001111001111, + 0b1111001111001111, + 0b1111000110001111, + 0b1111000110001111, + 0b1111000000001111, + 0b1111000000001111, + 0b1111000000001111, + 0b1111000000001111, - 0b0000111111110000, - 0b0011111111111100, - 0b0111111111111110, - 0b0111110000111110, - 0b1111100000011111, - 0b1111000000001111, - 0b1111000000001111, - 0b1111000000001111, - 0b1111000000000000, - 0b1111000000000000, - 0b1111000000000000, - 0b1111000000000000, - 0b1111000000111111, - 0b1111000000111111, - 0b1111000000111111, - 0b1111000000000111, - 0b1111000000001111, - 0b1111100000011111, - 0b0111110000111111, - 0b0111111111111111, - 0b0011111111110111, - 0b0000111111100111, + 0b0000111111110000, + 0b0011111111111100, + 0b0111111111111110, + 0b0111110000111110, + 0b1111100000011111, + 0b1111000000001111, + 0b1111000000001111, + 0b1111000000001111, + 0b1111000000000000, + 0b1111000000000000, + 0b1111000000000000, + 0b1111000000000000, + 0b1111000000111111, + 0b1111000000111111, + 0b1111000000111111, + 0b1111000000000111, + 0b1111000000001111, + 0b1111100000011111, + 0b0111110000111111, + 0b0111111111111111, + 0b0011111111110111, + 0b0000111111100111, - 0b0000000000000000, - 0b0000000000000000, - 0b0000000001000000, - 0b0000000011000000, - 0b0000000111000000, - 0b0000001111000000, - 0b0000011111000000, - 0b0000111111111111, - 0b0001111111111111, - 0b0011111111111111, - 0b0111111111111111, - 0b1111111111111111, - 0b0111111111111111, - 0b0011111111111111, - 0b0001111111111111, - 0b0000111111111111, - 0b0000011111000000, - 0b0000001111000000, - 0b0000000111000000, - 0b0000000011000000, - 0b0000000001000000, - 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000001000000, + 0b0000000011000000, + 0b0000000111000000, + 0b0000001111000000, + 0b0000011111000000, + 0b0000111111111111, + 0b0001111111111111, + 0b0011111111111111, + 0b0111111111111111, + 0b1111111111111111, + 0b0111111111111111, + 0b0011111111111111, + 0b0001111111111111, + 0b0000111111111111, + 0b0000011111000000, + 0b0000001111000000, + 0b0000000111000000, + 0b0000000011000000, + 0b0000000001000000, + 0b0000000000000000, - 0b0000000000000000, - 0b0000000000000000, - 0b0000000000000000, - 0b0000000000000000, - 0b0000000000000000, - 0b0001111000111100, - 0b0011111101111110, - 0b0111001111100110, - 0b0110000111000011, - 0b1110000111000011, - 0b1100000110000011, - 0b1100000110000011, - 0b1100000110000011, - 0b1100000110000011, - 0b1100001110000111, - 0b1100001110000110, - 0b0110011111001110, - 0b0111111011111100, - 0b0011110001111000, - 0b0000000000000000, - 0b0000000000000000, - 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0001111000111100, + 0b0011111101111110, + 0b0111001111100110, + 0b0110000111000011, + 0b1110000111000011, + 0b1100000110000011, + 0b1100000110000011, + 0b1100000110000011, + 0b1100000110000011, + 0b1100001110000111, + 0b1100001110000110, + 0b0110011111001110, + 0b0111111011111100, + 0b0011110001111000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, - 0b0000000000000000, - 0b0000000000000000, - 0b0000000000000000, - 0b0000011101111100, - 0b0000011101111110, - 0b0000001101100110, - 0b0000001101100110, - 0b0000001101100110, - 0b0000001101100110, - 0b0000001101100110, - 0b0011101101111100, - 0b0111111101111110, - 0b1110011101100111, - 0b1100001101100011, - 0b1100001101100011, - 0b1100001101100011, - 0b1100001101100011, - 0b1100001101100011, - 0b1100001101100011, - 0b1110011101100111, - 0b0111111101111110, - 0b0011101101111100, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000011101111100, + 0b0000011101111110, + 0b0000001101100110, + 0b0000001101100110, + 0b0000001101100110, + 0b0000001101100110, + 0b0000001101100110, + 0b0011101101111100, + 0b0111111101111110, + 0b1110011101100111, + 0b1100001101100011, + 0b1100001101100011, + 0b1100001101100011, + 0b1100001101100011, + 0b1100001101100011, + 0b1100001101100011, + 0b1110011101100111, + 0b0111111101111110, + 0b0011101101111100, - 0b0000000000000000, - 0b0000000000000000, - 0b0000001110000000, - 0b0000001110000000, - 0b0000001110000000, - 0b0000001110000000, - 0b0011111111111000, - 0b0011111111111000, - 0b0011111111111000, - 0b0000001110000000, - 0b0000001110000000, - 0b0000001110000000, - 0b0000001110000000, - 0b0000000000000000, - 0b0000000000000000, - 0b0011111111111000, - 0b0011111111111000, - 0b0011111111111000, - 0b0000000000000000, - 0b0000000000000000, - 0b0000000000000000, - 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000001110000000, + 0b0000001110000000, + 0b0000001110000000, + 0b0000001110000000, + 0b0011111111111000, + 0b0011111111111000, + 0b0011111111111000, + 0b0000001110000000, + 0b0000001110000000, + 0b0000001110000000, + 0b0000001110000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0011111111111000, + 0b0011111111111000, + 0b0011111111111000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, - 0b0000000000000000, - 0b0111101111011110, - 0b0111101111011110, - 0b0111101111011110, - 0b0111101111011110, - 0b0000000000000000, - 0b0111101111011110, - 0b0111101111011110, - 0b0111101111011110, - 0b0111101111011110, - 0b0000000000000000, - 0b0111101111011110, - 0b0111101111011110, - 0b0111101111011110, - 0b0111101111011110, - 0b0000000000000000, - 0b0111101111011110, - 0b0111101111011110, - 0b0111101111011110, - 0b0111101111011110, - 0b0000000000000000, - 0b0000000000000000, + 0b0000000000000000, + 0b0111101111011110, + 0b0111101111011110, + 0b0111101111011110, + 0b0111101111011110, + 0b0000000000000000, + 0b0111101111011110, + 0b0111101111011110, + 0b0111101111011110, + 0b0111101111011110, + 0b0000000000000000, + 0b0111101111011110, + 0b0111101111011110, + 0b0111101111011110, + 0b0111101111011110, + 0b0000000000000000, + 0b0111101111011110, + 0b0111101111011110, + 0b0111101111011110, + 0b0111101111011110, + 0b0000000000000000, + 0b0000000000000000, - 0b0000000000000000, - 0b0000000000000000, - 0b0000000000000000, - 0b0000000000000000, - 0b0000000000000000, - 0b0000000000000000, - 0b0000000000000000, - 0b0000000000000000, - 0b1111000111110000, - 0b1111011111111100, - 0b1111111111111110, - 0b1111111000111110, - 0b1111110000011111, - 0b1111100000001111, - 0b1111000000001111, - 0b1111000000001111, - 0b1111000000001111, - 0b1111000000001111, - 0b1111000000001111, - 0b1111000000001111, - 0b1111000000001111, - 0b1111000000001111, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b1111000111110000, + 0b1111011111111100, + 0b1111111111111110, + 0b1111111000111110, + 0b1111110000011111, + 0b1111100000001111, + 0b1111000000001111, + 0b1111000000001111, + 0b1111000000001111, + 0b1111000000001111, + 0b1111000000001111, + 0b1111000000001111, + 0b1111000000001111, + 0b1111000000001111, - 0b0000000000000000, - 0b0000000000000000, - 0b0000000000000000, - 0b0000000000000000, - 0b0000000000000000, - 0b0000000000000000, - 0b1111001111110000, - 0b1111011111111100, - 0b1111111111111110, - 0b1111111000011111, - 0b1111110000001111, - 0b1111100000000111, - 0b1111100000000111, - 0b1111100000000111, - 0b1111110000001111, - 0b1111111000011111, - 0b1111111111111110, - 0b1111011111111100, - 0b1111001111110000, - 0b1111000000000000, - 0b1111000000000000, - 0b1111000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b0000000000000000, + 0b1111001111110000, + 0b1111011111111100, + 0b1111111111111110, + 0b1111111000011111, + 0b1111110000001111, + 0b1111100000000111, + 0b1111100000000111, + 0b1111100000000111, + 0b1111110000001111, + 0b1111111000011111, + 0b1111111111111110, + 0b1111011111111100, + 0b1111001111110000, + 0b1111000000000000, + 0b1111000000000000, + 0b1111000000000000, }; - diff --git a/plot.c b/plot.c index a510b5b7..01b1e858 100644 --- a/plot.c +++ b/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 #include #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,12 +71,13 @@ 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)) -static int -floatToInt(float v){ - if (v < 0) return v-0.5; - if (v > 0) return v+0.5; - return 0; +//#define float2int(v) ((int)(v)) +static int +float2int(float v) +{ + if (v < 0) return v - 0.5; + if (v > 0) return v + 0.5; + return 0; } void update_grid(void) @@ -65,7 +86,7 @@ void update_grid(void) uint32_t fstart = get_sweep_frequency(ST_START); uint32_t fspan = get_sweep_frequency(ST_SPAN); uint32_t grid; - + while (gdigit > 100) { grid = 5 * gdigit; if (fspan / grid >= 4) @@ -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; @@ -148,52 +167,42 @@ smith_grid(int x, int y) // offset to center x -= P_CENTER_X; y -= P_CENTER_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); + d = circle_inout(x + P_RADIUS / 4, y, P_RADIUS / 4); if (d > 0) return 0; 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); + d = circle_inout(x + P_RADIUS / 2, y, P_RADIUS / 2); if (d > 0) return 0; 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; } @@ -206,7 +215,7 @@ smith_grid2(int x, int y, float scale) // offset to center x -= P_CENTER_X; y -= P_CENTER_Y; - + // outer circle d = circle_inout(x, y, P_RADIUS); if (d < 0) @@ -293,7 +302,7 @@ const int cirs[][4] = { { 115/2, 0, 115/2, 1 }, // Constant Resistance Circle: 0 : R { 173/2, 0, 173/2, 1 }, // Constant Resistance Circle: -1/3 : R*3/2 = 173 { 0, 0, 0, 0 } // sentinel -}; +}; static int smith_grid3(int x, int y) @@ -303,7 +312,7 @@ smith_grid3(int x, int y) // offset to center x -= P_CENTER_X; y -= P_CENTER_Y; - + // outer circle d = circle_inout(x, y, P_RADIUS); if (d < 0) @@ -354,9 +363,8 @@ rectangular_grid(int x, int y) static int rectangular_grid_x(int x) { - x-=CELLOFFSETX; - if (x < 0) - return 0; + x -= CELLOFFSETX; + 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,20 +604,20 @@ 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; + break; case MS_RX: plot_printf(buf, len, "%F"S_OHM"%+Fj", zr, zi); break; case MS_RLC: - if (zi < 0){// Capacity + 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,20 +762,23 @@ trace_get_info(int t, char *buf, int len) return 0; } -static float time_of_index(int idx) { - return 1.0 / (float)(frequencies[1] - frequencies[0]) / (float)FFT_SIZE * 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); - return distance * velocity_factor; +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; } static inline void mark_map(int x, int y) { if (y >= 0 && y < MAX_MARKMAP_Y && x >= 0 && x < MAX_MARKMAP_X) - markmap[current_mappage][y] |= 1<x1) SWAP(x0, x1); m0=m1; - int y0 = n0; int y1 = n1; if (y0>y1) SWAP(y0, y1); n0=n1; - for (; y0<=y1; y0++) - for(j=x0; j<=x1; j++) - map[y0]|= 1<x1) SWAP(x0, x1); m0 = m1; + int y0 = n0; int y1 = n1; if (y0>y1) SWAP(y0, y1); n0 = n1; + for (; y0 <= y1; y0++) + for (j = x0; j <= x1; j++) + map[y0] |= 1 << j; } } } @@ -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); } // @@ -841,20 +854,20 @@ markmap_upperarea(void) static inline void cell_drawline(int x0, int y0, int x1, int y1, int c) { - if (x0<0 && x1<0) return; - if (y0<0 && y1<0) return; - if (x0>=CELLWIDTH && x1>=CELLWIDTH )return; - if (y0>=CELLHEIGHT && y1>=CELLHEIGHT)return; + if (x0 < 0 && x1 < 0) return; + if (y0 < 0 && y1 < 0) return; + if (x0 >= CELLWIDTH && x1 >= CELLWIDTH) return; + if (y0 >= CELLHEIGHT && y1 >= CELLHEIGHT) return; // modifed Bresenham's line algorithm, see https://en.wikipedia.org/wiki/Bresenham%27s_line_algorithm - if (x1 < x0) {SWAP(x0,x1);SWAP(y0,y1);} + if (x1 < x0) { SWAP(x0, x1); SWAP(y0, y1); } int dx = x1 - x0; - int dy = y1 - y0, sy = 1; if (dy < 0) {dy = -dy; sy = -1;} + int dy = y1 - y0, sy = 1; if (dy < 0) { dy = -dy; sy = -1; } int err = (dx > dy ? dx : -dy) / 2; - while (1){ - if (y0>=0 && y0=0 && x0= 0 && y0 < CELLHEIGHT && x0 >= 0 && x0 < CELLWIDTH) + cell_buffer[y0 * CELLWIDTH + x0] |= c; if (x0 == x1 && y0 == y1) return; int e2 = err; @@ -877,12 +890,12 @@ search_index_range_x(int x1, int x2, index_t index[POINTS_COUNT], int *i0, int * while (1) { i = (head + tail) / 2; idx_x = CELL_X(index[i]); - if (idx_x >= x2){ // index after cell + if (idx_x >= x2) { // index after cell if (tail == i) return false; tail = i; } - else if (idx_x < x1){ // index before cell + else if (idx_x < x1) { // index before cell if (head == i) return false; head = i; @@ -892,14 +905,14 @@ search_index_range_x(int x1, int x2, index_t index[POINTS_COUNT], int *i0, int * } j = i; // Search index left from point - do{ + do { j--; - }while (j > 0 && x1 <= CELL_X(index[j])); + } while (j > 0 && x1 <= CELL_X(index[j])); *i0 = j; // Search index right from point - do{ + do { i++; - }while (i < sweep_points-1 && CELL_X(index[i]) < x2); + } while (i < sweep_points-1 && CELL_X(index[i]) < x2); *i1 = i; return TRUE; @@ -922,17 +935,16 @@ static const uint8_t reference_bitmap[]={ static void draw_refpos(int x, int y, int c) { - int y0=y, j; - for (j=0; j= CELLHEIGHT) - continue; - int x0=x; + int y0 = y, j; + for (j = 0; j < REFERENCE_HEIGHT; j++, y0++) { + if (y0 < 0 || y0 >= CELLHEIGHT) continue; + int x0 = x; uint8_t bits = reference_bitmap[j]; - while (bits){ + while (bits) { if (x0 >= 0 && x0 < CELLWIDTH) - cell_buffer[y0*CELLWIDTH+x0] = (bits&0x80) ? c : DEFAULT_BG_COLOR; + cell_buffer[y0 * CELLWIDTH + x0] = (bits & 0x80) ? c : DEFAULT_BG_COLOR; x0++; - bits<<=1; + bits <<= 1; } } } @@ -991,22 +1003,21 @@ static const uint8_t marker_bitmap[]={ static void draw_marker(int x, int y, int c, int ch) { - int y0=y, j; - for (j=0;j= 0 && x0 < CELLWIDTH && y0 >= 0 && y0 < CELLHEIGHT){ - if (bits&0x80) - cell_buffer[y0*CELLWIDTH+x0] = c; + while (bits) { + if (bits & 0x80) force_color = true; + if (x0 >= 0 && x0 < CELLWIDTH && y0 >= 0 && y0 < CELLHEIGHT) { + if (bits & 0x80) + cell_buffer[y0 * CELLWIDTH + x0] = c; else if (force_color) - cell_buffer[y0*CELLWIDTH+x0] = DEFAULT_BG_COLOR; + cell_buffer[y0 * CELLWIDTH + x0] = DEFAULT_BG_COLOR; } x0++; - bits<<=1; + bits <<= 1; } } } @@ -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,14 +1222,14 @@ 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); - p[1] = DEFAULT_BG_COLOR|(DEFAULT_BG_COLOR<<16); - p[2] = DEFAULT_BG_COLOR|(DEFAULT_BG_COLOR<<16); - p[3] = DEFAULT_BG_COLOR|(DEFAULT_BG_COLOR<<16); - p+=4; + p[0] = DEFAULT_BG_COLOR | (DEFAULT_BG_COLOR << 16); + p[1] = DEFAULT_BG_COLOR | (DEFAULT_BG_COLOR << 16); + p[2] = DEFAULT_BG_COLOR | (DEFAULT_BG_COLOR << 16); + p[3] = DEFAULT_BG_COLOR | (DEFAULT_BG_COLOR << 16); + p += 4; } #endif @@ -1227,41 +1238,40 @@ 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) - trace_type|=(1<= CELLOFFSETX && x+x0 <= WIDTH+CELLOFFSETX) + if (x + x0 >= CELLOFFSETX && x + x0 <= WIDTH + CELLOFFSETX) cell_buffer[y * CELLWIDTH + x] = c; } } } // Smith greed line (1000 system ticks for all screen calls) - if(trace_type&(1<=0 && x-MARKER_WIDTH=0 && y-MARKER_HEIGHT= 0 && x - MARKER_WIDTH < CELLWIDTH && + y + MARKER_HEIGHT >= 0 && y - MARKER_HEIGHT < CELLHEIGHT) draw_marker(x, y, config.trace_color[t], i); } } @@ -1325,24 +1340,24 @@ draw_cell(int m, int n) for (t = 0; t < TRACES_MAX; t++) { if (!trace[t].enabled) continue; - uint32_t trace_type = (1<=0 && x-REFERENCE_WIDTH=0 && y-REFERENCE_HEIGHT= 0 && x - REFERENCE_WIDTH < CELLWIDTH) { + 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]); } } // 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; - for (y=h; --y; src+=CELLWIDTH-w) - for(x=w;x--;) - *dst++=*src++; + if (w < CELLWIDTH) { + 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++; } #endif // Draw cell (500 system ticks for all screen calls) @@ -1350,12 +1365,13 @@ 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++) for (n = 0; n < (area_height+CELLHEIGHT-1) / CELLHEIGHT; n++) { - if ((markmap[0][n] | markmap[1][n]) & (1<= CELLHEIGHT || x <= -ch_size || x >= CELLWIDTH) -// return ch_size; + 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) return ch_size; - for(c = 0; c < FONT_GET_HEIGHT; c++) { + for (c = 0; c < FONT_GET_HEIGHT; c++) { bits = *char_buf++; if ((y + c) < 0 || (y + c) >= CELLHEIGHT) continue; @@ -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; @@ -1590,9 +1606,9 @@ void draw_frequencies(void) { char buf1[32]; - char buf2[32];buf2[0]=0; + char buf2[32]; buf2[0] = 0; if ((domain_mode & DOMAIN_MODE) == DOMAIN_FREQ) { - if (FREQ_IS_CW()){ + if (FREQ_IS_CW()) { plot_printf(buf1, sizeof(buf1), " CW %qHz", get_sweep_frequency(ST_CW)); } else if (FREQ_IS_STARTSTOP()) { plot_printf(buf1, sizeof(buf1), " START %qHz", get_sweep_frequency(ST_START)); @@ -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,13 +1673,13 @@ 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 // Battery top - int x=0; + int x = 0; string_buf[x++] = 0b00111100; string_buf[x++] = 0b00100100; string_buf[x++] = 0b11111111; @@ -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(); } diff --git a/si5351.c b/si5351.c index aee7ba8c..8f7c9c56 100644 --- a/si5351.c +++ b/si5351.c @@ -34,7 +34,7 @@ #define PLL_N 32 // I2C address on bus (only 0x60 for Si5351A in 10-Pin MSOP) -#define SI5351_I2C_ADDR 0x60 +#define SI5351_I2C_ADDR 0x60 static uint8_t current_band = 0; static uint32_t current_freq = 0; @@ -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 } @@ -178,34 +182,34 @@ static void si5351_setupPLL(uint8_t pllSource, /* SI5351_REG_PLL_A or SI5351_ /* Feedback Multisynth Divider Equation * where: a = mult, b = num and c = denom * P1 register is an 18-bit value using following formula: - * P1[17:0] = 128 * mult + int((128*num)/denom) - 512 + * P1[17:0] = 128 * mult + int((128*num)/denom) - 512 * P2 register is a 20-bit value using the following formula: - * P2[19:0] = (128 * num) % denom + * P2[19:0] = (128 * num) % denom * P3 register is a 20-bit value using the following formula: - * P3[19:0] = denom + * P3[19:0] = denom */ /* Set the main PLL config registers */ - mult<<=7; - num<<=7; - uint32_t P1 = mult - 512; // Integer mode + mult <<= 7; + num <<= 7; + uint32_t P1 = mult - 512; // Integer mode uint32_t P2 = 0; uint32_t P3 = 1; - if (num){ // Fractional mode + if (num) { // Fractional mode P1+= num / denom; P2 = num % denom; P3 = denom; } // Pll MSN(A|B) registers Datasheet uint8_t reg[9]; - reg[0]= pllSource; // SI5351_REG_PLL_A or SI5351_REG_PLL_B - reg[1]=( P3 & 0x0FF00)>> 8; // MSN_P3[15: 8] - reg[2]=( P3 & 0x000FF); // MSN_P3[ 7: 0] - reg[3]=( P1 & 0x30000)>>16; // MSN_P1[17:16] - reg[4]=( P1 & 0x0FF00)>> 8; // MSN_P1[15: 8] - reg[5]=( P1 & 0x000FF); // MSN_P1[ 7: 0] - reg[6]=((P3 & 0xF0000)>>12)|((P2 & 0xF0000)>>16); // MSN_P3[19:16] | MSN_P2[19:16] - reg[7]=( P2 & 0x0FF00)>> 8; // MSN_P2[15: 8] - reg[8]=( P2 & 0x000FF); // MSN_P2[ 7: 0] + reg[0] = pllSource; // SI5351_REG_PLL_A or SI5351_REG_PLL_B + reg[1] = (P3 & 0x0FF00) >> 8; // MSN_P3[15: 8] + reg[2] = (P3 & 0x000FF); // MSN_P3[ 7: 0] + reg[3] = (P1 & 0x30000) >> 16; // MSN_P1[17:16] + reg[4] = (P1 & 0x0FF00) >> 8; // MSN_P1[15: 8] + reg[5] = (P1 & 0x000FF); // MSN_P1[ 7: 0] + reg[6] = ((P3 & 0xF0000) >> 12) | ((P2 & 0xF0000) >> 16); // MSN_P3[19:16] | MSN_P2[19:16] + reg[7] = (P2 & 0x0FF00) >> 8; // MSN_P2[15: 8] + reg[8] = (P2 & 0x000FF); // MSN_P2[ 7: 0] si5351_bulk_write(reg, 9); } @@ -237,7 +241,7 @@ si5351_setupMultisynth(uint8_t channel, num<<=7; div<<=7; P1 = div - 512; // Integer mode - if (num){ // Fractional mode + if (num) { // Fractional mode P1+= num / denom; P2 = num % denom; P3 = denom; @@ -245,15 +249,15 @@ si5351_setupMultisynth(uint8_t channel, } /* Set the MSx config registers */ uint8_t reg[9]; - reg[0]= msreg_base[channel]; // SI5351_REG_42_MULTISYNTH0, SI5351_REG_50_MULTISYNTH1, SI5351_REG_58_MULTISYNTH2 - reg[1]=( P3 & 0x0FF00)>>8; // MSx_P3[15: 8] - reg[2]=( P3 & 0x000FF); // MSx_P3[ 7: 0] - reg[3]=((P1 & 0x30000)>>16)| rdiv; // Rx_DIV[2:0] | MSx_DIVBY4[1:0] | MSx_P1[17:16] - reg[4]=( P1 & 0x0FF00)>> 8; // MSx_P1[15: 8] - reg[5]=( P1 & 0x000FF); // MSx_P1[ 7: 0] - reg[6]=((P3 & 0xF0000)>>12)|((P2 & 0xF0000)>>16); // MSx_P3[19:16] | MSx_P2[19:16] - reg[7]=( P2 & 0x0FF00)>>8; // MSx_P2[15: 8] - reg[8]=( P2 & 0x000FF); // MSx_P2[ 7: 0] + reg[0] = msreg_base[channel]; // SI5351_REG_42_MULTISYNTH0, SI5351_REG_50_MULTISYNTH1, SI5351_REG_58_MULTISYNTH2 + reg[1] = (P3 & 0x0FF00)>>8; // MSx_P3[15: 8] + reg[2] = (P3 & 0x000FF); // MSx_P3[ 7: 0] + reg[3] = ((P1 & 0x30000)>>16)| rdiv; // Rx_DIV[2:0] | MSx_DIVBY4[1:0] | MSx_P1[17:16] + reg[4] = (P1 & 0x0FF00)>> 8; // MSx_P1[15: 8] + reg[5] = (P1 & 0x000FF); // MSx_P1[ 7: 0] + reg[6] = ((P3 & 0xF0000)>>12)|((P2 & 0xF0000)>>16); // MSx_P3[19:16] | MSx_P2[19:16] + reg[7] = (P2 & 0x0FF00)>>8; // MSx_P2[15: 8] + reg[8] = (P2 & 0x000FF); // MSx_P2[ 7: 0] si5351_bulk_write(reg, 9); /* Configure the clk control and enable the output */ @@ -264,7 +268,7 @@ si5351_setupMultisynth(uint8_t channel, #if USE_CLK_CONTROL_CACHE == TRUE // Use cache for this reg, not update if not change static uint8_t clk_cache[3]; - if (clk_cache[channel]!=dat){ + if (clk_cache[channel]!=dat) { si5351_write(clkctrl[channel], dat); clk_cache[channel]=dat; } @@ -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,38 +421,49 @@ 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 - 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); - delay=DELAY_BANDCHANGE_1; - } - 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); - 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); - delay=DELAY_BANDCHANGE_2; - } - 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 - // 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); - break; + case 1: + // 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); + delay = DELAY_BANDCHANGE_1; + } 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); + 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); + delay = DELAY_BANDCHANGE_2; + } 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 + // 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); + break; } if (current_band != band) { si5351_reset_pll(SI5351_PLL_RESET_A|SI5351_PLL_RESET_B); diff --git a/si5351.h b/si5351.h index 42a7d99e..315ce3cf 100644 --- a/si5351.h +++ b/si5351.h @@ -24,56 +24,54 @@ #define SI5351_CLK2_EN (1<<2) // Reg 16-18 CLKX_CONTROL -#define SI5351_REG_16_CLK0_CONTROL 16 -#define SI5351_REG_17_CLK1_CONTROL 17 -#define SI5351_REG_18_CLK2_CONTROL 18 -#define SI5351_CLK_POWERDOWN (1<<7) -#define SI5351_CLK_INTEGER_MODE (1<<6) -#define SI5351_CLK_PLL_SELECT_A (0<<5) -#define SI5351_CLK_PLL_SELECT_B (1<<5) -#define SI5351_CLK_INVERT (1<<4) -#define SI5351_CLK_INPUT_MASK (3<<2) -#define SI5351_CLK_INPUT_XTAL (0<<2) -#define SI5351_CLK_INPUT_CLKIN (1<<2) -#define SI5351_CLK_INPUT_MULTISYNTH_0_4 (2<<2) -#define SI5351_CLK_INPUT_MULTISYNTH_N (3<<2) -#define SI5351_CLK_DRIVE_STRENGTH_MASK (3<<0) -#define SI5351_CLK_DRIVE_STRENGTH_2MA (0<<0) -#define SI5351_CLK_DRIVE_STRENGTH_4MA (1<<0) -#define SI5351_CLK_DRIVE_STRENGTH_6MA (2<<0) -#define SI5351_CLK_DRIVE_STRENGTH_8MA (3<<0) +#define SI5351_REG_16_CLK0_CONTROL 16 +#define SI5351_REG_17_CLK1_CONTROL 17 +#define SI5351_REG_18_CLK2_CONTROL 18 +#define SI5351_CLK_POWERDOWN (1<<7) +#define SI5351_CLK_INTEGER_MODE (1<<6) +#define SI5351_CLK_PLL_SELECT_A (0<<5) +#define SI5351_CLK_PLL_SELECT_B (1<<5) +#define SI5351_CLK_INVERT (1<<4) +#define SI5351_CLK_INPUT_MASK (3<<2) +#define SI5351_CLK_INPUT_XTAL (0<<2) +#define SI5351_CLK_INPUT_CLKIN (1<<2) +#define SI5351_CLK_INPUT_MULTISYNTH_0_4 (2<<2) +#define SI5351_CLK_INPUT_MULTISYNTH_N (3<<2) +#define SI5351_CLK_DRIVE_STRENGTH_MASK (3<<0) +#define SI5351_CLK_DRIVE_STRENGTH_2MA (0<<0) +#define SI5351_CLK_DRIVE_STRENGTH_4MA (1<<0) +#define SI5351_CLK_DRIVE_STRENGTH_6MA (2<<0) +#define SI5351_CLK_DRIVE_STRENGTH_8MA (3<<0) -#define SI5351_REG_PLL_A 26 -#define SI5351_REG_PLL_B 34 +#define SI5351_REG_PLL_A 26 +#define SI5351_REG_PLL_B 34 -#define SI5351_REG_42_MULTISYNTH0 42 -#define SI5351_REG_50_MULTISYNTH1 50 -#define SI5351_REG_58_MULTISYNTH2 58 -#define SI5351_DIVBY4 (3<<2) -#define SI5351_R_DIV_1 (0<<4) -#define SI5351_R_DIV_2 (1<<4) -#define SI5351_R_DIV_4 (2<<4) -#define SI5351_R_DIV_8 (3<<4) -#define SI5351_R_DIV_16 (4<<4) -#define SI5351_R_DIV_32 (5<<4) -#define SI5351_R_DIV_64 (6<<4) -#define SI5351_R_DIV_128 (7<<4) +#define SI5351_REG_42_MULTISYNTH0 42 +#define SI5351_REG_50_MULTISYNTH1 50 +#define SI5351_REG_58_MULTISYNTH2 58 +#define SI5351_DIVBY4 (3<<2) +#define SI5351_R_DIV_1 (0<<4) +#define SI5351_R_DIV_2 (1<<4) +#define SI5351_R_DIV_4 (2<<4) +#define SI5351_R_DIV_8 (3<<4) +#define SI5351_R_DIV_16 (4<<4) +#define SI5351_R_DIV_32 (5<<4) +#define SI5351_R_DIV_64 (6<<4) +#define SI5351_R_DIV_128 (7<<4) -#define SI5351_REG_177_PLL_RESET 177 -#define SI5351_PLL_RESET_B (1<<7) -#define SI5351_PLL_RESET_A (1<<5) +#define SI5351_REG_177_PLL_RESET 177 +#define SI5351_PLL_RESET_B (1<<7) +#define SI5351_PLL_RESET_A (1<<5) #define SI5351_REG_183_CRYSTAL_LOAD 183 -#define SI5351_CRYSTAL_LOAD_6PF (1<<6) -#define SI5351_CRYSTAL_LOAD_8PF (2<<6) -#define SI5351_CRYSTAL_LOAD_10PF (3<<6) +#define SI5351_CRYSTAL_LOAD_6PF (1<<6) +#define SI5351_CRYSTAL_LOAD_8PF (2<<6) +#define SI5351_CRYSTAL_LOAD_10PF (3<<6) 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); diff --git a/tlv320aic3204.c b/tlv320aic3204.c index c1b57b57..21fbe841 100644 --- a/tlv320aic3204.c +++ b/tlv320aic3204.c @@ -116,7 +116,7 @@ static void tlv320aic3204_config(const uint8_t *data, int len) { i2cAcquireBus(&I2CD1); - for (;len--;data+=2) + for (; len--; data += 2) tlv320aic3204_bulk_write(data, 2); i2cReleaseBus(&I2CD1); } diff --git a/ui.c b/ui.c index ae251265..391af986 100644 --- a/ui.c +++ b/ui.c @@ -33,23 +33,23 @@ uistat_t uistat = { marker_tracking : FALSE, }; -#define NO_EVENT 0 -#define EVT_BUTTON_SINGLE_CLICK 0x01 -#define EVT_BUTTON_DOUBLE_CLICK 0x02 -#define EVT_BUTTON_DOWN_LONG 0x04 -#define EVT_UP 0x10 -#define EVT_DOWN 0x20 -#define EVT_REPEAT 0x40 - -#define BUTTON_DOWN_LONG_TICKS 5000 /* 1sec */ -#define BUTTON_DOUBLE_TICKS 2500 /* 500ms */ -#define BUTTON_REPEAT_TICKS 625 /* 125ms */ -#define BUTTON_DEBOUNCE_TICKS 200 +#define NO_EVENT 0 +#define EVT_BUTTON_SINGLE_CLICK 0x01 +#define EVT_BUTTON_DOUBLE_CLICK 0x02 +#define EVT_BUTTON_DOWN_LONG 0x04 +#define EVT_UP 0x10 +#define EVT_DOWN 0x20 +#define EVT_REPEAT 0x40 + +#define BUTTON_DOWN_LONG_TICKS 5000 /* 1sec */ +#define BUTTON_DOUBLE_TICKS 2500 /* 500ms */ +#define BUTTON_REPEAT_TICKS 625 /* 125ms */ +#define BUTTON_DEBOUNCE_TICKS 200 /* lever switch assignment */ -#define BIT_UP1 3 -#define BIT_PUSH 2 -#define BIT_DOWN1 1 +#define BIT_UP1 3 +#define BIT_PUSH 2 +#define BIT_DOWN1 1 #define READ_PORT() palReadPort(GPIOA) #define BUTTON_MASK 0b1111 @@ -288,24 +288,28 @@ 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 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(); @@ -354,7 +358,7 @@ touch_draw_test(void) x0 = x1; y0 = y1; chThdSleepMilliseconds(50); - } while(touch_check()!=EVT_TOUCH_RELEASED); + } while (touch_check() != EVT_TOUCH_RELEASED); touch_start_watchdog(); } @@ -372,13 +376,13 @@ 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]){ + while (info_about[i]) { do {shift>>=1; y+=5;} while (shift&1); ili9341_drawstring(info_about[i++], x, y+=5); } @@ -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) { @@ -1233,16 +1238,18 @@ static void draw_keypad(void) { int i = 0; - while (keypads[i].c>=0) { + while (keypads[i].c >= 0) { 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,15 +1289,15 @@ 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 ili9341_drawfont(0, x, 240-NUM_INPUT_HEIGHT+4); else // erase ili9341_fill(x, 240-NUM_INPUT_HEIGHT+4, NUM_FONT_GET_HEIGHT, NUM_FONT_GET_WIDTH+2+8, bg); - + x += xsim&0x8000 ? NUM_FONT_GET_WIDTH+2+8 : NUM_FONT_GET_WIDTH+2; } // erase last @@ -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); @@ -1431,7 +1438,7 @@ menu_apply_touch(void) for (i = 0; i < 7; i++) { if (menu[i].type == MT_NONE) break; - if (menu[i].type == MT_BLANK) + if (menu[i].type == MT_BLANK) continue; int y = MENU_BUTTON_HEIGHT*i; if (y < touch_y && touch_y < y+MENU_BUTTON_HEIGHT && 320-MENU_BUTTON_WIDTH < touch_x) { @@ -1510,7 +1517,7 @@ fetch_numeric_target(void) uistat.value = get_trace_scale(uistat.current_trace) * 1e12; break; } - + { uint32_t x = uistat.value; int n = 0; @@ -1566,7 +1573,7 @@ draw_numeric_area(void) static void ui_mode_menu(void) { - if (ui_mode == UI_MENU) + if (ui_mode == UI_MENU) return; ui_mode = UI_MENU; @@ -1580,11 +1587,11 @@ ui_mode_menu(void) static void ui_mode_numeric(int _keypad_mode) { - if (ui_mode == UI_NUMERIC) + if (ui_mode == UI_NUMERIC) return; leave_ui_mode(); - + // keypads array keypad_mode = _keypad_mode; ui_mode = UI_NUMERIC; @@ -1599,7 +1606,7 @@ ui_mode_numeric(int _keypad_mode) static void ui_mode_keypad(int _keypad_mode) { - if (ui_mode == UI_KEYPAD) + if (ui_mode == UI_KEYPAD) return; // keypads array @@ -1622,7 +1629,7 @@ ui_mode_keypad(int _keypad_mode) static void ui_mode_normal(void) { - if (ui_mode == UI_NORMAL) + if (ui_mode == UI_NORMAL) return; area_width = AREA_WIDTH_NORMAL; @@ -1678,13 +1685,13 @@ step_round(uint32_t v) uint32_t x = 1; for (x = 1; x*10 < v; x*= 10) ; - + // 1-2-5 step if (x * 2 > v) return x; else if (x * 5 > v) return x * 2; - else + else return x * 5; } @@ -1791,7 +1798,7 @@ ui_process_menu(void) } static int -keypad_click(int key) +keypad_click(int key) { int c = keypads[key].c; if ((c >= KP_X1 && c <= KP_G) || c == KP_N || c == KP_P) { @@ -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++) @@ -1871,7 +1878,7 @@ keypad_apply_touch(void) touch_position(&touch_x, &touch_y); - while (keypads[i].c>=0) { + while (keypads[i].c >= 0) { int x = KP_GET_X(keypads[i].x); int y = KP_GET_Y(keypads[i].y); if (x < touch_x && touch_x < x+KP_WIDTH && y < touch_y && touch_y < y+KP_HEIGHT) { @@ -1922,11 +1929,11 @@ numeric_apply_touch(void) uistat.value += step; } draw_numeric_area(); - + touch_wait_release(); uistat.digit_mode = FALSE; draw_numeric_area(); - + return; } @@ -2016,7 +2023,7 @@ ui_process_keypad(void) if (status == EVT_BUTTON_SINGLE_CLICK) { if (keypad_click(selection)) /* exit loop on done or cancel */ - break; + break; } if (touch_check() == EVT_TOUCH_PRESSED) { @@ -2040,16 +2047,16 @@ ui_process_lever(void) switch (ui_mode) { case UI_NORMAL: ui_process_normal(); - break; + break; case UI_MENU: ui_process_menu(); - break; + break; case UI_NUMERIC: ui_process_numeric(); - break; + break; case UI_KEYPAD: ui_process_keypad(); - break; + break; } } @@ -2069,7 +2076,7 @@ drag_marker(int t, int m) markers[m].frequency = frequencies[index]; redraw_marker(m); } - } while(touch_check()!=EVT_TOUCH_RELEASED); + } while (touch_check()!= EVT_TOUCH_RELEASED); } static int @@ -2091,9 +2098,9 @@ touch_pickup_marker(void) continue; marker_position(m, t, &x, &y); - x-=touch_x; - y-=touch_y; - if ((x*x+y*y) < 20*20) { + x -= touch_x; + y -= touch_y; + if ((x * x + y * y) < 20 * 20) { if (active_marker != m) { previous_marker = active_marker; active_marker = m; @@ -2102,7 +2109,7 @@ touch_pickup_marker(void) // select trace uistat.current_trace = t; select_lever_mode(LM_MARKER); - + // drag marker until release drag_marker(t, m); return TRUE; @@ -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; @@ -2243,7 +2252,7 @@ void ui_init() { adc_init(); - + /* * Activates the EXT driver 1. */