Skip to content

Commit

Permalink
Merge pull request #17 from leedave/feature/linting
Browse files Browse the repository at this point in the history
Feature/linting
  • Loading branch information
leedave authored Jan 5, 2024
2 parents 908eb0b + f179b0d commit cc0c618
Show file tree
Hide file tree
Showing 25 changed files with 501 additions and 354 deletions.
191 changes: 191 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
---
Language: Cpp
AccessModifierOffset: -4
AlignAfterOpenBracket: AlwaysBreak
AlignArrayOfStructures: None
AlignConsecutiveMacros: None
AlignConsecutiveAssignments: None
AlignConsecutiveBitFields: None
AlignConsecutiveDeclarations: None
AlignEscapedNewlines: Left
AlignOperands: Align
AlignTrailingComments: false
AllowAllArgumentsOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortEnumsOnASingleLine: true
AllowShortBlocksOnASingleLine: Never
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: None
AllowShortLambdasOnASingleLine: All
AllowShortIfStatementsOnASingleLine: WithoutElse
AllowShortLoopsOnASingleLine: true
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: Yes
AttributeMacros:
- __capability
BinPackArguments: false
BinPackParameters: false
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
BreakBeforeBinaryOperators: None
BreakBeforeConceptDeclarations: true
BreakBeforeBraces: Attach
BreakBeforeInheritanceComma: false
BreakInheritanceList: BeforeColon
BreakBeforeTernaryOperators: false
BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeComma
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: false
ColumnLimit: 99
CommentPragmas: '^ IWYU pragma:'
QualifierAlignment: Leave
CompactNamespaces: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DeriveLineEnding: true
DerivePointerAlignment: false
DisableFormat: false
EmptyLineAfterAccessModifier: Never
EmptyLineBeforeAccessModifier: LogicalBlock
ExperimentalAutoDetectBinPacking: false
PackConstructorInitializers: BinPack
BasedOnStyle: ''
ConstructorInitializerAllOnOneLineOrOnePerLine: false
AllowAllConstructorInitializersOnNextLine: true
FixNamespaceComments: false
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
IfMacros:
- KJ_IF_MAYBE
IncludeBlocks: Preserve
IncludeCategories:
- Regex: '.*'
Priority: 1
SortPriority: 0
CaseSensitive: false
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
Priority: 3
SortPriority: 0
CaseSensitive: false
- Regex: '.*'
Priority: 1
SortPriority: 0
CaseSensitive: false
IncludeIsMainRegex: '(Test)?$'
IncludeIsMainSourceRegex: ''
IndentAccessModifiers: false
IndentCaseLabels: false
IndentCaseBlocks: false
IndentGotoLabels: true
IndentPPDirectives: None
IndentExternBlock: AfterExternBlock
IndentRequires: false
IndentWidth: 4
IndentWrappedFunctionNames: true
InsertTrailingCommas: None
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: false
LambdaBodyIndentation: Signature
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBinPackProtocolList: Auto
ObjCBlockIndentWidth: 4
ObjCBreakBeforeNestedBlockParam: true
ObjCSpaceAfterProperty: true
ObjCSpaceBeforeProtocolList: true
PenaltyBreakAssignment: 10
PenaltyBreakBeforeFirstCallParameter: 30
PenaltyBreakComment: 10
PenaltyBreakFirstLessLess: 0
PenaltyBreakOpenParenthesis: 0
PenaltyBreakString: 10
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 100
PenaltyReturnTypeOnItsOwnLine: 60
PenaltyIndentedWhitespace: 0
PointerAlignment: Left
PPIndentWidth: -1
ReferenceAlignment: Pointer
ReflowComments: false
RemoveBracesLLVM: false
SeparateDefinitionBlocks: Leave
ShortNamespaceLines: 1
SortIncludes: Never
SortJavaStaticImport: Before
SortUsingDeclarations: false
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeCaseColon: false
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: Never
SpaceBeforeParensOptions:
AfterControlStatements: false
AfterForeachMacros: false
AfterFunctionDefinitionName: false
AfterFunctionDeclarationName: false
AfterIfMacros: false
AfterOverloadedOperator: false
BeforeNonEmptyParentheses: false
SpaceAroundPointerQualifiers: Default
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyBlock: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: Never
SpacesInConditionalStatement: false
SpacesInContainerLiterals: false
SpacesInCStyleCastParentheses: false
SpacesInLineCommentPrefix:
Minimum: 1
Maximum: -1
SpacesInParentheses: false
SpacesInSquareBrackets: false
SpaceBeforeSquareBrackets: false
BitFieldColonSpacing: Both
Standard: c++03
StatementAttributeLikeMacros:
- Q_EMIT
StatementMacros:
- Q_UNUSED
- QT_REQUIRE_VERSION
TabWidth: 4
UseCRLF: false
UseTab: Never
WhitespaceSensitiveMacros:
- STRINGIZE
- PP_STRINGIZE
- BOOST_PP_STRINGIZE
- NS_SWIFT_NAME
- CF_SWIFT_NAME
...

12 changes: 4 additions & 8 deletions application.fam
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,12 @@ App(
name="Restaurant Pager Trigger",
apptype=FlipperAppType.EXTERNAL,
entry_point="meal_pager_app",
cdefines=["APP_MEAL_PAGER"],
requires=[
"gui",
"storage",
],
stack_size=2 * 1024,
order=10,
fap_libs=["assets"],
fap_icon="icons/meal_pager_10px.png",
fap_icon_assets="icons",
fap_category="Sub-Ghz",
fap_version="0.1",
fap_version="0.7",
fap_author="leedave",
fap_weburl="https://github.com/leedave/flipper-zero-meal-pager",
fap_description="This app triggers restaurant pagers in a brute force manner, useful to test if devices are still functional.",
)
20 changes: 10 additions & 10 deletions helpers/meal_pager_calc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

void customConcat(char* dest, const char* src) {
// Find the end of the destination string
while (*dest != '\0') {
while(*dest != '\0') {
dest++;
}

// Copy characters from src to dest
while (*src != '\0') {
while(*src != '\0') {
*dest = *src;
dest++;
src++;
Expand All @@ -22,18 +22,18 @@ char* encManchester(const char* bits, int mode) {
char* res = (char*)malloc((strlen(bits) * 2 + 1) * sizeof(char));

int index = 0;
for (int i = 0; bits[i] != '\0'; i++) {
for(int i = 0; bits[i] != '\0'; i++) {
char c = bits[i];
if (c == '0') {
if (mode) {
if(c == '0') {
if(mode) {
res[index++] = '1';
res[index++] = '0';
} else {
res[index++] = '0';
res[index++] = '1';
}
} else if (c == '1') {
if (mode) {
} else if(c == '1') {
if(mode) {
res[index++] = '0';
res[index++] = '1';
} else {
Expand All @@ -56,21 +56,21 @@ char* encManchester(const char* bits, int mode) {
void uint32ToBinaray(uint32_t number, char* str, int8_t length) {
int i = 0;
length--; // count length without 0
for (i = length; i >= 0; i--) {
for(i = length; i >= 0; i--) {
// Bitwise AND extration of the i-th bit
int bit = (number >> i) & 1;
// convert the bit to a character of 1 or 0
str[length - i] = bit + '0';
}
// Terminate the string
str[length+1] = '\0';
str[length + 1] = '\0';
}

void reverse(char* str) {
int length = strlen(str);
int start = 0;
int end = length - 1;
while (start < end) {
while(start < end) {
char temp = str[start];
str[start] = str[end];
str[end] = temp;
Expand Down
3 changes: 2 additions & 1 deletion helpers/meal_pager_custom_event.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ static inline uint32_t meal_pager_custom_menu_event_pack(uint16_t type, int16_t
Meal_PagerCustomEventMenu event = {.content = {.type = type, .value = value}};
return event.packed_value;
}
static inline void meal_pager_custom_menu_event_unpack(uint32_t packed_value, uint16_t* type, int16_t* value) {
static inline void
meal_pager_custom_menu_event_unpack(uint32_t packed_value, uint16_t* type, int16_t* value) {
Meal_PagerCustomEventMenu event = {.packed_value = packed_value};
if(type) *type = event.content.type;
if(value) *value = event.content.value;
Expand Down
8 changes: 4 additions & 4 deletions helpers/meal_pager_haptic.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

void meal_pager_play_happy_bump(void* context) {
Meal_Pager* app = context;
if (app->haptic != 1) {
if(app->haptic != 1) {
return;
}
notification_message(app->notification, &sequence_set_vibro_on);
Expand All @@ -12,7 +12,7 @@ void meal_pager_play_happy_bump(void* context) {

void meal_pager_play_bad_bump(void* context) {
Meal_Pager* app = context;
if (app->haptic != 1) {
if(app->haptic != 1) {
return;
}
notification_message(app->notification, &sequence_set_vibro_on);
Expand All @@ -22,10 +22,10 @@ void meal_pager_play_bad_bump(void* context) {

void meal_pager_play_long_bump(void* context) {
Meal_Pager* app = context;
if (app->haptic != 1) {
if(app->haptic != 1) {
return;
}
for (int i = 0; i < 4; i++) {
for(int i = 0; i < 4; i++) {
notification_message(app->notification, &sequence_set_vibro_on);
furi_thread_flags_wait(0, FuriFlagWaitAny, 50);
notification_message(app->notification, &sequence_reset_vibro);
Expand Down
1 change: 0 additions & 1 deletion helpers/meal_pager_haptic.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,3 @@ void meal_pager_play_happy_bump(void* context);
void meal_pager_play_bad_bump(void* context);

void meal_pager_play_long_bump(void* context);

10 changes: 6 additions & 4 deletions helpers/meal_pager_led.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ void meal_pager_blink_stop(Meal_Pager* app) {

void meal_pager_led_set_rgb(void* context, int red, int green, int blue) {
Meal_Pager* app = context;
if (app->led != 1) {
if(app->led != 1) {
return;
}
NotificationMessage notification_led_message_1;
Expand All @@ -40,14 +40,16 @@ void meal_pager_led_set_rgb(void* context, int red, int green, int blue) {
NULL,
};
notification_message(app->notification, &notification_sequence);
furi_thread_flags_wait(0, FuriFlagWaitAny, 10); //Delay, prevent removal from RAM before LED value set
furi_thread_flags_wait(
0, FuriFlagWaitAny, 10); //Delay, prevent removal from RAM before LED value set
}

void meal_pager_led_reset(void* context) {
Meal_Pager* app = context;
notification_message(app->notification, &sequence_reset_red);
notification_message(app->notification, &sequence_reset_green);
notification_message(app->notification, &sequence_reset_blue);

furi_thread_flags_wait(0, FuriFlagWaitAny, 300); //Delay, prevent removal from RAM before LED value set

furi_thread_flags_wait(
0, FuriFlagWaitAny, 300); //Delay, prevent removal from RAM before LED value set
}
1 change: 0 additions & 1 deletion helpers/meal_pager_led.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,3 @@ void meal_pager_blink_stop(Meal_Pager* app);
void meal_pager_led_set_rgb(void* context, int red, int green, int blue);

void meal_pager_led_reset(void* context);

5 changes: 2 additions & 3 deletions helpers/meal_pager_speaker.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,18 @@

void meal_pager_play_input_sound(void* context) {
Meal_Pager* app = context;
if (app->speaker != 1) {
if(app->speaker != 1) {
return;
}
float volume = 1.0f;
if(furi_hal_speaker_is_mine() || furi_hal_speaker_acquire(30)) {
furi_hal_speaker_start(NOTE_INPUT, volume);
}

}

void meal_pager_stop_all_sound(void* context) {
Meal_Pager* app = context;
if (app->speaker != 1) {
if(app->speaker != 1) {
return;
}
if(furi_hal_speaker_is_mine()) {
Expand Down
Loading

0 comments on commit cc0c618

Please sign in to comment.