Skip to content

Commit

Permalink
Adding missing documents and Format code
Browse files Browse the repository at this point in the history
  • Loading branch information
Tinyu-Zhao committed Aug 23, 2022
1 parent 78d2a99 commit 845e162
Show file tree
Hide file tree
Showing 101 changed files with 33,216 additions and 27,379 deletions.
168 changes: 168 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
---
Language: Cpp
BasedOnStyle: Google
AccessModifierOffset: -1
AlignAfterOpenBracket: Align
AlignConsecutiveMacros: true
AlignConsecutiveAssignments: true
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Left
AlignOperands: true
AlignTrailingComments: true
AllowAllArgumentsOnNextLine: true
AllowAllConstructorInitializersOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: Never
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: false
AllowShortLambdasOnASingleLine: All
AllowShortIfStatementsOnASingleLine: WithoutElse
AllowShortLoopsOnASingleLine: true
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
AfterCaseLabel: false
AfterClass: false
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: None
BreakBeforeBraces: Attach
BreakBeforeInheritanceComma: false
BreakInheritanceList: BeforeColon
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeColon
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
ColumnLimit: 80
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DeriveLineEnding: true
DerivePointerAlignment: true
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
IncludeBlocks: Regroup
IncludeCategories:
- Regex: '^<ext/.*\.h>'
Priority: 2
SortPriority: 0
- Regex: '^<.*\.h>'
Priority: 1
SortPriority: 0
- Regex: '^<.*'
Priority: 2
SortPriority: 0
- Regex: '.*'
Priority: 3
SortPriority: 0
IncludeIsMainRegex: '([-_](test|unittest))?$'
IncludeIsMainSourceRegex: ''
IndentCaseLabels: true
IndentGotoLabels: true
IndentPPDirectives: None
IndentWidth: 4
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: false
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyBlock: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 2
SpacesInAngles: false
SpacesInConditionalStatement: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
SpaceBeforeSquareBrackets: false
Standard: Auto
StatementMacros:
- Q_UNUSED
- QT_REQUIRE_VERSION
TabWidth: 4
UseCRLF: false
UseTab: Never
...

8 changes: 4 additions & 4 deletions .github/workflows/clang-format-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ jobs:
matrix:
path:
- check: './' # path to include
exclude: '' # path to exclude
exclude: '(utility|RFID|HEART)' # path to exclude
# - check: 'src'
# exclude: ''
# exclude: '(Fonts)' # Exclude file paths containing "Fonts"
# - check: 'examples'
# exclude: ''
steps:
- uses: actions/checkout@v2
- name: Run clang-format style check for C/C++/Protobuf programs.
uses: jidicula/clang-format-action@v4.5.0
uses: jidicula/clang-format-action@v4.8.0
with:
clang-format-version: '13'
check-path: ${{ matrix.path['check'] }}
exclude-regex: ${{ matrix.path['exclude'] }}
exclude-regex: ${{ matrix.path['exclude'] }}
4 changes: 3 additions & 1 deletion examples/Advanced/AXP192/BtnIrq/BtnIrq.ino
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ static void clear_mpu6880IRQ() {
M5.Mpu6886.ClearAllIRQ();
}

static void clear_200qIRQ() { M5.I2C.writeByte(0x6C, 0x13, 0xe0); }
static void clear_200qIRQ() {
M5.I2C.writeByte(0x6C, 0x13, 0xe0);
}

void setup() {
M5.begin();
Expand Down
17 changes: 6 additions & 11 deletions examples/Advanced/AXP192/PowerWake/PowerWake.ino
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,24 @@ void setup() {

void loop() {
loopTime = millis();
if(startTime < (loopTime - 5000))
{
if(M5.Axp.GetWarningLevel())
{
if (startTime < (loopTime - 5000)) {
if (M5.Axp.GetWarningLevel()) {
sleep_count++;
M5.Lcd.fillScreen(WHITE);
M5.Lcd.setCursor(0, 20, 2);
M5.Lcd.setTextColor(RED, WHITE);
M5.Lcd.printf("Warning: low battery");
//delay(3000);
if(sleep_count >= 2)
{
// delay(3000);
if (sleep_count >= 2) {
sleep_count = 0;
M5.Axp.SetSleep();
}
}
else
{
} else {
M5.Lcd.fillScreen(WHITE);
}
startTime = loopTime;
}

M5.Lcd.setCursor(0, 0, 1);
M5.Lcd.setTextColor(BLACK, WHITE);
M5.Lcd.printf("vbat:%.3fV\r\n", M5.Axp.GetBatVoltage());
Expand Down
12 changes: 5 additions & 7 deletions examples/Advanced/AXP192/sleep/sleep.ino
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <M5StickC.h>

void setup() {
// put your setup code here, to run once:
// put your setup code here, to run once:
M5.begin();
M5.Lcd.setRotation(3);
M5.Lcd.fillScreen(BLACK);
Expand All @@ -12,17 +12,16 @@ void setup() {
void loop() {
M5.update();

if(M5.BtnA.wasPressed())
{
if (M5.BtnA.wasPressed()) {
M5.Lcd.drawCentreString("Go light sleep (5s wakeup)", 80, 30, 1);
delay(2000);

// close tft lcd
// close tft lcd
M5.Axp.SetLDO2(false);
// 6MA
M5.Axp.LightSleep(SLEEP_SEC(5));
// open tft lcd
M5.Axp.SetLDO2(true);
M5.Axp.SetLDO2(true);

M5.Lcd.fillScreen(BLACK);
M5.Lcd.drawCentreString("Week up from light sleep", 80, 30, 1);
Expand All @@ -38,8 +37,7 @@ void loop() {
M5.Axp.DeepSleep(SLEEP_SEC(20));
}

if(M5.BtnB.wasPressed())
{
if (M5.BtnB.wasPressed()) {
// will close esp32, can`t wakeup by timer
M5.Axp.PowerOff();
}
Expand Down
Loading

0 comments on commit 845e162

Please sign in to comment.