-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor to use the new driver on IDF 5.0 (#45)
- Loading branch information
Showing
22 changed files
with
1,141 additions
and
493 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
--- | ||
Language: Cpp | ||
# BasedOnStyle: WebKit | ||
AccessModifierOffset: -4 | ||
AlignAfterOpenBracket: DontAlign | ||
AlignConsecutiveMacros: false | ||
AlignConsecutiveAssignments: false | ||
AlignConsecutiveDeclarations: false | ||
AlignEscapedNewlines: Right | ||
AlignOperands: false | ||
AlignTrailingComments: false | ||
AllowAllArgumentsOnNextLine: true | ||
AllowAllConstructorInitializersOnNextLine: true | ||
AllowAllParametersOfDeclarationOnNextLine: true | ||
AllowShortBlocksOnASingleLine: false | ||
AllowShortCaseLabelsOnASingleLine: false | ||
AllowShortFunctionsOnASingleLine: All | ||
AllowShortLambdasOnASingleLine: All | ||
AllowShortIfStatementsOnASingleLine: Never | ||
AllowShortLoopsOnASingleLine: false | ||
AlwaysBreakAfterDefinitionReturnType: None | ||
AlwaysBreakAfterReturnType: None | ||
AlwaysBreakBeforeMultilineStrings: false | ||
AlwaysBreakTemplateDeclarations: MultiLine | ||
BinPackArguments: true | ||
BinPackParameters: true | ||
BraceWrapping: | ||
AfterCaseLabel: false | ||
AfterClass: true | ||
AfterControlStatement: false | ||
AfterEnum: false | ||
AfterFunction: false | ||
AfterNamespace: false | ||
AfterObjCDeclaration: false | ||
AfterStruct: false | ||
AfterUnion: false | ||
AfterExternBlock: false | ||
BeforeCatch: false | ||
BeforeElse: false | ||
IndentBraces: false | ||
SplitEmptyFunction: true | ||
SplitEmptyRecord: true | ||
SplitEmptyNamespace: true | ||
BreakBeforeBinaryOperators: All | ||
BreakBeforeBraces: Attach | ||
BreakBeforeInheritanceComma: false | ||
BreakInheritanceList: BeforeColon | ||
BreakBeforeTernaryOperators: true | ||
BreakConstructorInitializersBeforeComma: false | ||
BreakConstructorInitializers: BeforeComma | ||
BreakAfterJavaFieldAnnotations: false | ||
BreakStringLiterals: true | ||
ColumnLimit: 0 | ||
CommentPragmas: '^ IWYU pragma:' | ||
CompactNamespaces: false | ||
ConstructorInitializerAllOnOneLineOrOnePerLine: false | ||
ConstructorInitializerIndentWidth: 4 | ||
ContinuationIndentWidth: 4 | ||
Cpp11BracedListStyle: false | ||
DerivePointerAlignment: false | ||
DisableFormat: false | ||
ExperimentalAutoDetectBinPacking: false | ||
FixNamespaceComments: false | ||
ForEachMacros: | ||
- foreach | ||
- Q_FOREACH | ||
- BOOST_FOREACH | ||
IncludeBlocks: Preserve | ||
IncludeCategories: | ||
- Regex: '^"(llvm|llvm-c|clang|clang-c)/' | ||
Priority: 2 | ||
- Regex: '^(<|"(gtest|gmock|isl|json)/)' | ||
Priority: 3 | ||
- Regex: '.*' | ||
Priority: 1 | ||
IncludeIsMainRegex: '(Test)?$' | ||
IndentCaseLabels: false | ||
IndentPPDirectives: None | ||
IndentWidth: 4 | ||
IndentWrappedFunctionNames: false | ||
JavaScriptQuotes: Leave | ||
JavaScriptWrapImports: true | ||
KeepEmptyLinesAtTheStartOfBlocks: true | ||
MacroBlockBegin: '' | ||
MacroBlockEnd: '' | ||
MaxEmptyLinesToKeep: 1 | ||
NamespaceIndentation: None | ||
ObjCBinPackProtocolList: Auto | ||
ObjCBlockIndentWidth: 4 | ||
ObjCSpaceAfterProperty: true | ||
ObjCSpaceBeforeProtocolList: true | ||
PenaltyBreakAssignment: 2 | ||
PenaltyBreakBeforeFirstCallParameter: 19 | ||
PenaltyBreakComment: 300 | ||
PenaltyBreakFirstLessLess: 120 | ||
PenaltyBreakString: 1000 | ||
PenaltyBreakTemplateDeclaration: 10 | ||
PenaltyExcessCharacter: 1000000 | ||
PenaltyReturnTypeOnItsOwnLine: 60 | ||
PointerAlignment: Left | ||
ReflowComments: false | ||
SortIncludes: true | ||
SortUsingDeclarations: true | ||
SpaceAfterCStyleCast: false | ||
SpaceAfterLogicalNot: false | ||
SpaceAfterTemplateKeyword: true | ||
SpaceBeforeAssignmentOperators: true | ||
SpaceBeforeCpp11BracedList: true | ||
SpaceBeforeCtorInitializerColon: true | ||
SpaceBeforeInheritanceColon: true | ||
SpaceBeforeParens: ControlStatements | ||
SpaceBeforeRangeBasedForLoopColon: true | ||
SpaceInEmptyParentheses: false | ||
SpacesBeforeTrailingComments: 1 | ||
SpacesInAngles: false | ||
SpacesInContainerLiterals: true | ||
SpacesInCStyleCastParentheses: false | ||
SpacesInParentheses: false | ||
SpacesInSquareBrackets: false | ||
Standard: Cpp11 | ||
StatementMacros: | ||
- Q_UNUSED | ||
- QT_REQUIRE_VERSION | ||
TabWidth: 8 | ||
UseTab: Never | ||
ColumnLimit: 120 | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: PlatformIO CI | ||
|
||
on: [push] | ||
|
||
jobs: | ||
build-test: | ||
runs-on: ubuntu-22.04 | ||
strategy: | ||
matrix: | ||
example: | ||
- examples/basic | ||
conf: | ||
- esp32-idf4-arduino.ini | ||
- esp32-idf5-idf.ini | ||
- esp32s3-idf4-arduino.ini | ||
- esp32s3-idf5-idf.ini | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
- name: Install dependencies | ||
run: | | ||
python3 -m pip install --upgrade pip | ||
python3 -m pip install platformio | ||
- name: Build examples | ||
run: platformio ci --lib="." --project-conf="./test-inis/${{ matrix.conf }}" | ||
env: | ||
PLATFORMIO_CI_SRC: ${{ matrix.example }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
cmake_minimum_required(VERSION 3.0) | ||
|
||
set(SRCS | ||
"src/Color.cpp" | ||
"src/RmtDriver4.cpp" | ||
"src/RmtDriver5.cpp" | ||
"src/SmartLeds.cpp" | ||
) | ||
|
||
idf_component_register( | ||
SRCS ${SRCS} | ||
INCLUDE_DIRS "./src" | ||
REQUIRES driver | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#ifdef LX16A_ARDUINO | ||
#include <Arduino.h> | ||
#else | ||
#include <freertos/FreeRTOS.h> | ||
#include <freertos/task.h> | ||
static void delay(int ms) { vTaskDelay(pdMS_TO_TICKS(ms)); } | ||
static uint32_t millis() { return xTaskGetTickCount(); } | ||
#endif | ||
|
||
#include <SmartLeds.h> | ||
|
||
const int LED_COUNT = 15; | ||
const int DATA_PIN = 22; | ||
const int CHANNEL = 0; | ||
|
||
// SmartLed -> RMT driver (WS2812/WS2812B/SK6812/WS2813) | ||
SmartLed leds(LED_WS2812B, LED_COUNT, DATA_PIN, CHANNEL, DoubleBuffer); | ||
|
||
const int CLK_PIN = 23; | ||
// APA102 -> SPI driver | ||
//Apa102 leds(LED_COUNT, CLK_PIN, DATA_PIN, DoubleBuffer); | ||
|
||
void setup() {} | ||
|
||
uint8_t hue; | ||
void showGradient() { | ||
hue++; | ||
// Use HSV to create nice gradient | ||
for (int i = 0; i != LED_COUNT; i++) | ||
leds[i] = Hsv { static_cast<uint8_t>(hue + 30 * i), 255, 255 }; | ||
leds.show(); | ||
// Show is asynchronous; if we need to wait for the end of transmission, | ||
// we can use leds.wait(); however we use double buffered mode, so we | ||
// can start drawing right after showing. | ||
} | ||
|
||
void showRgb() { | ||
leds[0] = Rgb { 255, 0, 0 }; | ||
leds[1] = Rgb { 0, 255, 0 }; | ||
leds[2] = Rgb { 0, 0, 255 }; | ||
leds[3] = Rgb { 0, 0, 0 }; | ||
leds[4] = Rgb { 255, 255, 255 }; | ||
leds.show(); | ||
} | ||
|
||
void loop() { | ||
if (millis() % 10000 < 5000) | ||
showGradient(); | ||
else | ||
showRgb(); | ||
delay(50); | ||
} | ||
|
||
#ifndef ARDUINO | ||
extern "C" void app_main() { | ||
setup(); | ||
while (true) { | ||
loop(); | ||
vTaskDelay(0); | ||
} | ||
} | ||
#endif |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.