diff --git a/.github/workflows/check-clang.yml b/.github/workflows/check-clang.yml new file mode 100644 index 0000000..678fd31 --- /dev/null +++ b/.github/workflows/check-clang.yml @@ -0,0 +1,30 @@ +# Source: https://github.com/aliphys/.github/blob/main/workflow-templates/check-clang.yml +name: Check Clang + +# See: https://github.com/aliphys/.github/blob/main/workflow-templates/check-clang.md +on: + push: + pull_request: + schedule: + # Run every Tuesday at 8 AM UTC to catch breakage caused by new rules added to Arduino Lint. + - cron: "0 8 * * TUE" + workflow_dispatch: + repository_dispatch: + +jobs: + formatting-check: + name: Formatting Check + runs-on: ubuntu-latest + strategy: # Strategy individual folders + matrix: + path: + - 'src' # library source files (.h/.cpp) + - 'examples' # library example sketches (.ino) + + steps: + - uses: actions/checkout@v3 + - name: Run clang-format on ${{ matrix.path }} + uses: jidicula/clang-format-action@v4.11.0 + with: + clang-format-version: '17' #v17 must be used + check-path: ${{ matrix.path }} diff --git a/clang-format b/clang-format new file mode 100644 index 0000000..927b42e --- /dev/null +++ b/clang-format @@ -0,0 +1,190 @@ +# Source: https://github.com/arduino/tooling-project-assets/tree/main/other/clang-format-configuration +--- +AccessModifierOffset: -2 +AlignAfterOpenBracket: Align +AlignArrayOfStructures: None +AlignConsecutiveAssignments: None +AlignConsecutiveBitFields: None +AlignConsecutiveDeclarations: None +AlignConsecutiveMacros: None +AlignEscapedNewlines: DontAlign +AlignOperands: Align +AlignTrailingComments: true +AllowAllArgumentsOnNextLine: true +AllowAllConstructorInitializersOnNextLine: true +AllowAllParametersOfDeclarationOnNextLine: true +AllowShortBlocksOnASingleLine: Always +AllowShortCaseLabelsOnASingleLine: true +AllowShortEnumsOnASingleLine: true +AllowShortFunctionsOnASingleLine: Empty +AllowShortIfStatementsOnASingleLine: AllIfsAndElse +AllowShortLambdasOnASingleLine: Empty +AllowShortLoopsOnASingleLine: true +AlwaysBreakAfterDefinitionReturnType: None +AlwaysBreakAfterReturnType: None +AlwaysBreakBeforeMultilineStrings: false +AlwaysBreakTemplateDeclarations: No +AttributeMacros: + - __capability +BasedOnStyle: LLVM +BinPackArguments: true +BinPackParameters: true +BitFieldColonSpacing: Both +BraceWrapping: + AfterCaseLabel: false + AfterClass: false + AfterControlStatement: Never + AfterEnum: false + AfterFunction: false + AfterNamespace: false + AfterObjCDeclaration: false + AfterStruct: false + AfterUnion: false + AfterExternBlock: false + BeforeCatch: false + BeforeElse: false + BeforeLambdaBody: false + BeforeWhile: false + IndentBraces: false + SplitEmptyFunction: true + SplitEmptyRecord: true + SplitEmptyNamespace: true +BreakAfterJavaFieldAnnotations: false +BreakBeforeBinaryOperators: NonAssignment +BreakBeforeBraces: Attach +BreakBeforeConceptDeclarations: false +BreakBeforeInheritanceComma: false +BreakBeforeTernaryOperators: true +BreakConstructorInitializers: BeforeColon +BreakConstructorInitializersBeforeComma: false +BreakInheritanceList: BeforeColon +BreakStringLiterals: false +ColumnLimit: 0 +CommentPragmas: '' +CompactNamespaces: false +ConstructorInitializerAllOnOneLineOrOnePerLine: false +ConstructorInitializerIndentWidth: 2 +ContinuationIndentWidth: 2 +Cpp11BracedListStyle: false +DeriveLineEnding: true +DerivePointerAlignment: true +DisableFormat: false +EmptyLineAfterAccessModifier: Leave +EmptyLineBeforeAccessModifier: Leave +ExperimentalAutoDetectBinPacking: false +FixNamespaceComments: false +ForEachMacros: + - foreach + - Q_FOREACH + - BOOST_FOREACH +IfMacros: + - KJ_IF_MAYBE +IncludeBlocks: Preserve +IncludeCategories: + - Regex: '^"(llvm|llvm-c|clang|clang-c)/' + Priority: 2 + SortPriority: 0 + CaseSensitive: false + - Regex: '^(<|"(gtest|gmock|isl|json)/)' + Priority: 3 + SortPriority: 0 + CaseSensitive: false + - Regex: '.*' + Priority: 1 + SortPriority: 0 + CaseSensitive: false +IncludeIsMainRegex: '' +IncludeIsMainSourceRegex: '' +IndentAccessModifiers: false +IndentCaseBlocks: true +IndentCaseLabels: true +IndentExternBlock: Indent +IndentGotoLabels: false +IndentPPDirectives: None +IndentRequires: true +IndentWidth: 2 +IndentWrappedFunctionNames: false +InsertTrailingCommas: None +JavaScriptQuotes: Leave +JavaScriptWrapImports: true +KeepEmptyLinesAtTheStartOfBlocks: true +LambdaBodyIndentation: Signature +Language: Cpp +MacroBlockBegin: '' +MacroBlockEnd: '' +MaxEmptyLinesToKeep: 100000 +NamespaceIndentation: None +ObjCBinPackProtocolList: Auto +ObjCBlockIndentWidth: 2 +ObjCBreakBeforeNestedBlockParam: true +ObjCSpaceAfterProperty: false +ObjCSpaceBeforeProtocolList: true +PPIndentWidth: -1 +PackConstructorInitializers: BinPack +PenaltyBreakAssignment: 1 +PenaltyBreakBeforeFirstCallParameter: 1 +PenaltyBreakComment: 1 +PenaltyBreakFirstLessLess: 1 +PenaltyBreakOpenParenthesis: 1 +PenaltyBreakString: 1 +PenaltyBreakTemplateDeclaration: 1 +PenaltyExcessCharacter: 1 +PenaltyIndentedWhitespace: 1 +PenaltyReturnTypeOnItsOwnLine: 1 +PointerAlignment: Right +QualifierAlignment: Leave +ReferenceAlignment: Pointer +ReflowComments: false +RemoveBracesLLVM: false +SeparateDefinitionBlocks: Leave +ShortNamespaceLines: 0 +SortIncludes: Never +SortJavaStaticImport: Before +SortUsingDeclarations: false +SpaceAfterCStyleCast: false +SpaceAfterLogicalNot: false +SpaceAfterTemplateKeyword: false +SpaceAroundPointerQualifiers: Default +SpaceBeforeAssignmentOperators: true +SpaceBeforeCaseColon: false +SpaceBeforeCpp11BracedList: false +SpaceBeforeCtorInitializerColon: true +SpaceBeforeInheritanceColon: true +SpaceBeforeParens: ControlStatements +SpaceBeforeParensOptions: + AfterControlStatements: true + AfterForeachMacros: true + AfterFunctionDefinitionName: false + AfterFunctionDeclarationName: false + AfterIfMacros: true + AfterOverloadedOperator: false + BeforeNonEmptyParentheses: false +SpaceBeforeRangeBasedForLoopColon: true +SpaceBeforeSquareBrackets: false +SpaceInEmptyBlock: false +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 2 +SpacesInAngles: Leave +SpacesInCStyleCastParentheses: false +SpacesInConditionalStatement: false +SpacesInContainerLiterals: false +SpacesInLineCommentPrefix: + Minimum: 0 + Maximum: -1 +SpacesInParentheses: false +SpacesInSquareBrackets: false +Standard: Auto +StatementAttributeLikeMacros: + - Q_EMIT +StatementMacros: + - Q_UNUSED + - QT_REQUIRE_VERSION +TabWidth: 2 +UseCRLF: false +UseTab: Never +WhitespaceSensitiveMacros: + - STRINGIZE + - PP_STRINGIZE + - BOOST_PP_STRINGIZE + - NS_SWIFT_NAME + - CF_SWIFT_NAME \ No newline at end of file diff --git a/docs/README.md b/docs/README.md index f55cb43..35627c3 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,6 +1,6 @@ # Arduino Giga Display Touch Library -[![License](https://img.shields.io/badge/License-LGPLv3-blue.svg)]() +[![License](https://img.shields.io/badge/License-LGPLv3-blue.svg)]() [![Check Clang status](https://github.com/arduino-libraries/Arduino_GigaDisplayTouch/actions/workflows/check-clang.yml/badge.svg)](https://github.com/arduino-libraries/Arduino_GigaDisplayTouch/actions/workflows/check-clang.yml) The Arduino Giga Display Touch library is a C++ library designed to manage the touch controller of the Giga Display Shield. It is currently compatible with Goodix GT911 5-point Capacitive touch controller. diff --git a/library.properties b/library.properties index f040108..ab78b34 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=Arduino_GigaDisplayTouch -version=1.0.0 +version=1.0.1 author=Arduino maintainer=Arduino sentence=Touch library for Arduino Giga Display Shield diff --git a/src/Arduino_GigaDisplayTouch.cpp b/src/Arduino_GigaDisplayTouch.cpp index b5b04b0..bd6edc3 100644 --- a/src/Arduino_GigaDisplayTouch.cpp +++ b/src/Arduino_GigaDisplayTouch.cpp @@ -40,8 +40,12 @@ Arduino_GigaDisplayTouch * gThis; /* Private function prototypes -----------------------------------------------*/ #if __has_include ("lvgl.h") +#if (LVGL_VERSION_MAJOR == 9) +void _lvglTouchCb(lv_indev_t * indev, lv_indev_data_t * data); +#else void _lvglTouchCb(lv_indev_drv_t * indev, lv_indev_data_t * data); #endif +#endif /* Functions -----------------------------------------------------------------*/ Arduino_GigaDisplayTouch::Arduino_GigaDisplayTouch(TwoWire& wire, uint8_t intPin, uint8_t rstPin, uint8_t addr) @@ -84,19 +88,42 @@ bool Arduino_GigaDisplayTouch::begin() { uint8_t error = _gt911ReadOp(GT911_REG_CONFIG_VERSION, &testByte, 1); #if __has_include ("lvgl.h") +#if (LVGL_VERSION_MAJOR == 9) + static lv_indev_t * indev = lv_indev_create(); + lv_indev_set_type(indev, LV_INDEV_TYPE_POINTER); + lv_indev_set_read_cb(indev, _lvglTouchCb); +#else static lv_indev_drv_t indev_drv; /* Descriptor of a input device driver */ lv_indev_drv_init(&indev_drv); /* Basic initialization */ - indev_drv.type = LV_INDEV_TYPE_POINTER; /* Touch pad is a pointer-like device */ + indev_drv.type = LV_INDEV_TYPE_POINTER; /* Touch pad is a pointer-like device */ indev_drv.read_cb = _lvglTouchCb; /* Set your driver function */ lv_indev_t * my_indev = lv_indev_drv_register(&indev_drv); /* Register the driver in LVGL and save the created input device object */ - - gThis = this; +#endif #endif + gThis = this; return (error == 0); } #if __has_include ("lvgl.h") +#if (LVGL_VERSION_MAJOR == 9) +void _lvglTouchCb(lv_indev_t * indev, lv_indev_data_t * data) { + uint8_t contacts; + GDTpoint_t points[5]; + + contacts = gThis->getTouchPoints(points); + + if(contacts > 0) { + data->state = LV_INDEV_STATE_PRESSED; + data->point.x = points[0].x; + data->point.y = points[0].y; + } else { + data->state = LV_INDEV_STATE_RELEASED; + } + + return; +} +#else void _lvglTouchCb(lv_indev_drv_t * indev, lv_indev_data_t * data) { uint8_t contacts; GDTpoint_t points[5]; @@ -114,6 +141,7 @@ void _lvglTouchCb(lv_indev_drv_t * indev, lv_indev_data_t * data) { return; } #endif +#endif void Arduino_GigaDisplayTouch::end() { }