Skip to content

Commit 46fe33b

Browse files
authored
Merge pull request #19 from leedave/feature/ufbt_update
Update for ufbt compatibility
2 parents 5d14c0a + 5d41c93 commit 46fe33b

25 files changed

+623
-426
lines changed

.clang-format

Lines changed: 191 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,191 @@
1+
---
2+
Language: Cpp
3+
AccessModifierOffset: -4
4+
AlignAfterOpenBracket: AlwaysBreak
5+
AlignArrayOfStructures: None
6+
AlignConsecutiveMacros: None
7+
AlignConsecutiveAssignments: None
8+
AlignConsecutiveBitFields: None
9+
AlignConsecutiveDeclarations: None
10+
AlignEscapedNewlines: Left
11+
AlignOperands: Align
12+
AlignTrailingComments: false
13+
AllowAllArgumentsOnNextLine: true
14+
AllowAllParametersOfDeclarationOnNextLine: false
15+
AllowShortEnumsOnASingleLine: true
16+
AllowShortBlocksOnASingleLine: Never
17+
AllowShortCaseLabelsOnASingleLine: false
18+
AllowShortFunctionsOnASingleLine: None
19+
AllowShortLambdasOnASingleLine: All
20+
AllowShortIfStatementsOnASingleLine: WithoutElse
21+
AllowShortLoopsOnASingleLine: true
22+
AlwaysBreakAfterDefinitionReturnType: None
23+
AlwaysBreakAfterReturnType: None
24+
AlwaysBreakBeforeMultilineStrings: false
25+
AlwaysBreakTemplateDeclarations: Yes
26+
AttributeMacros:
27+
- __capability
28+
BinPackArguments: false
29+
BinPackParameters: false
30+
BraceWrapping:
31+
AfterCaseLabel: false
32+
AfterClass: false
33+
AfterControlStatement: Never
34+
AfterEnum: false
35+
AfterFunction: false
36+
AfterNamespace: false
37+
AfterObjCDeclaration: false
38+
AfterStruct: false
39+
AfterUnion: false
40+
AfterExternBlock: false
41+
BeforeCatch: false
42+
BeforeElse: false
43+
BeforeLambdaBody: false
44+
BeforeWhile: false
45+
IndentBraces: false
46+
SplitEmptyFunction: true
47+
SplitEmptyRecord: true
48+
SplitEmptyNamespace: true
49+
BreakBeforeBinaryOperators: None
50+
BreakBeforeConceptDeclarations: true
51+
BreakBeforeBraces: Attach
52+
BreakBeforeInheritanceComma: false
53+
BreakInheritanceList: BeforeColon
54+
BreakBeforeTernaryOperators: false
55+
BreakConstructorInitializersBeforeComma: false
56+
BreakConstructorInitializers: BeforeComma
57+
BreakAfterJavaFieldAnnotations: false
58+
BreakStringLiterals: false
59+
ColumnLimit: 99
60+
CommentPragmas: '^ IWYU pragma:'
61+
QualifierAlignment: Leave
62+
CompactNamespaces: false
63+
ConstructorInitializerIndentWidth: 4
64+
ContinuationIndentWidth: 4
65+
Cpp11BracedListStyle: true
66+
DeriveLineEnding: true
67+
DerivePointerAlignment: false
68+
DisableFormat: false
69+
EmptyLineAfterAccessModifier: Never
70+
EmptyLineBeforeAccessModifier: LogicalBlock
71+
ExperimentalAutoDetectBinPacking: false
72+
PackConstructorInitializers: BinPack
73+
BasedOnStyle: ''
74+
ConstructorInitializerAllOnOneLineOrOnePerLine: false
75+
AllowAllConstructorInitializersOnNextLine: true
76+
FixNamespaceComments: false
77+
ForEachMacros:
78+
- foreach
79+
- Q_FOREACH
80+
- BOOST_FOREACH
81+
IfMacros:
82+
- KJ_IF_MAYBE
83+
IncludeBlocks: Preserve
84+
IncludeCategories:
85+
- Regex: '.*'
86+
Priority: 1
87+
SortPriority: 0
88+
CaseSensitive: false
89+
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
90+
Priority: 3
91+
SortPriority: 0
92+
CaseSensitive: false
93+
- Regex: '.*'
94+
Priority: 1
95+
SortPriority: 0
96+
CaseSensitive: false
97+
IncludeIsMainRegex: '(Test)?$'
98+
IncludeIsMainSourceRegex: ''
99+
IndentAccessModifiers: false
100+
IndentCaseLabels: false
101+
IndentCaseBlocks: false
102+
IndentGotoLabels: true
103+
IndentPPDirectives: None
104+
IndentExternBlock: AfterExternBlock
105+
IndentRequires: false
106+
IndentWidth: 4
107+
IndentWrappedFunctionNames: true
108+
InsertTrailingCommas: None
109+
JavaScriptQuotes: Leave
110+
JavaScriptWrapImports: true
111+
KeepEmptyLinesAtTheStartOfBlocks: false
112+
LambdaBodyIndentation: Signature
113+
MacroBlockBegin: ''
114+
MacroBlockEnd: ''
115+
MaxEmptyLinesToKeep: 1
116+
NamespaceIndentation: None
117+
ObjCBinPackProtocolList: Auto
118+
ObjCBlockIndentWidth: 4
119+
ObjCBreakBeforeNestedBlockParam: true
120+
ObjCSpaceAfterProperty: true
121+
ObjCSpaceBeforeProtocolList: true
122+
PenaltyBreakAssignment: 10
123+
PenaltyBreakBeforeFirstCallParameter: 30
124+
PenaltyBreakComment: 10
125+
PenaltyBreakFirstLessLess: 0
126+
PenaltyBreakOpenParenthesis: 0
127+
PenaltyBreakString: 10
128+
PenaltyBreakTemplateDeclaration: 10
129+
PenaltyExcessCharacter: 100
130+
PenaltyReturnTypeOnItsOwnLine: 60
131+
PenaltyIndentedWhitespace: 0
132+
PointerAlignment: Left
133+
PPIndentWidth: -1
134+
ReferenceAlignment: Pointer
135+
ReflowComments: false
136+
RemoveBracesLLVM: false
137+
SeparateDefinitionBlocks: Leave
138+
ShortNamespaceLines: 1
139+
SortIncludes: Never
140+
SortJavaStaticImport: Before
141+
SortUsingDeclarations: false
142+
SpaceAfterCStyleCast: false
143+
SpaceAfterLogicalNot: false
144+
SpaceAfterTemplateKeyword: true
145+
SpaceBeforeAssignmentOperators: true
146+
SpaceBeforeCaseColon: false
147+
SpaceBeforeCpp11BracedList: false
148+
SpaceBeforeCtorInitializerColon: true
149+
SpaceBeforeInheritanceColon: true
150+
SpaceBeforeParens: Never
151+
SpaceBeforeParensOptions:
152+
AfterControlStatements: false
153+
AfterForeachMacros: false
154+
AfterFunctionDefinitionName: false
155+
AfterFunctionDeclarationName: false
156+
AfterIfMacros: false
157+
AfterOverloadedOperator: false
158+
BeforeNonEmptyParentheses: false
159+
SpaceAroundPointerQualifiers: Default
160+
SpaceBeforeRangeBasedForLoopColon: true
161+
SpaceInEmptyBlock: false
162+
SpaceInEmptyParentheses: false
163+
SpacesBeforeTrailingComments: 1
164+
SpacesInAngles: Never
165+
SpacesInConditionalStatement: false
166+
SpacesInContainerLiterals: false
167+
SpacesInCStyleCastParentheses: false
168+
SpacesInLineCommentPrefix:
169+
Minimum: 1
170+
Maximum: -1
171+
SpacesInParentheses: false
172+
SpacesInSquareBrackets: false
173+
SpaceBeforeSquareBrackets: false
174+
BitFieldColonSpacing: Both
175+
Standard: c++03
176+
StatementAttributeLikeMacros:
177+
- Q_EMIT
178+
StatementMacros:
179+
- Q_UNUSED
180+
- QT_REQUIRE_VERSION
181+
TabWidth: 4
182+
UseCRLF: false
183+
UseTab: Never
184+
WhitespaceSensitiveMacros:
185+
- STRINGIZE
186+
- PP_STRINGIZE
187+
- BOOST_PP_STRINGIZE
188+
- NS_SWIFT_NAME
189+
- CF_SWIFT_NAME
190+
...
191+

application.fam

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ App(
1010
],
1111
stack_size=2 * 1024,
1212
order=10,
13-
fap_libs=["assets"],
1413
fap_icon="icons/boilerplate_10px.png",
1514
fap_icon_assets="icons",
1615
fap_category="Misc",
16+
fap_version="1.0",
1717
)

boilerplate.c

Lines changed: 35 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Boilerplate* boilerplate_app_alloc() {
2323
Boilerplate* app = malloc(sizeof(Boilerplate));
2424
app->gui = furi_record_open(RECORD_GUI);
2525
app->notification = furi_record_open(RECORD_NOTIFICATION);
26-
26+
2727
//Turn backlight on, believe me this makes testing your app easier
2828
notification_message(app->notification, &sequence_display_backlight_on);
2929

@@ -33,9 +33,12 @@ Boilerplate* boilerplate_app_alloc() {
3333

3434
app->scene_manager = scene_manager_alloc(&boilerplate_scene_handlers, app);
3535
view_dispatcher_set_event_callback_context(app->view_dispatcher, app);
36-
view_dispatcher_set_navigation_event_callback(app->view_dispatcher, boilerplate_navigation_event_callback);
37-
view_dispatcher_set_tick_event_callback(app->view_dispatcher, boilerplate_tick_event_callback, 100);
38-
view_dispatcher_set_custom_event_callback(app->view_dispatcher, boilerplate_custom_event_callback);
36+
view_dispatcher_set_navigation_event_callback(
37+
app->view_dispatcher, boilerplate_navigation_event_callback);
38+
view_dispatcher_set_tick_event_callback(
39+
app->view_dispatcher, boilerplate_tick_event_callback, 100);
40+
view_dispatcher_set_custom_event_callback(
41+
app->view_dispatcher, boilerplate_custom_event_callback);
3942
app->submenu = submenu_alloc();
4043

4144
// Set defaults, in case no config loaded
@@ -51,18 +54,32 @@ Boilerplate* boilerplate_app_alloc() {
5154
// Load configs
5255
boilerplate_read_settings(app);
5356

54-
view_dispatcher_add_view(app->view_dispatcher, BoilerplateViewIdMenu, submenu_get_view(app->submenu));
57+
view_dispatcher_add_view(
58+
app->view_dispatcher, BoilerplateViewIdMenu, submenu_get_view(app->submenu));
5559
app->boilerplate_startscreen = boilerplate_startscreen_alloc();
56-
view_dispatcher_add_view(app->view_dispatcher, BoilerplateViewIdStartscreen, boilerplate_startscreen_get_view(app->boilerplate_startscreen));
60+
view_dispatcher_add_view(
61+
app->view_dispatcher,
62+
BoilerplateViewIdStartscreen,
63+
boilerplate_startscreen_get_view(app->boilerplate_startscreen));
5764
app->boilerplate_scene_1 = boilerplate_scene_1_alloc();
58-
view_dispatcher_add_view(app->view_dispatcher, BoilerplateViewIdScene1, boilerplate_scene_1_get_view(app->boilerplate_scene_1));
65+
view_dispatcher_add_view(
66+
app->view_dispatcher,
67+
BoilerplateViewIdScene1,
68+
boilerplate_scene_1_get_view(app->boilerplate_scene_1));
5969
app->boilerplate_scene_2 = boilerplate_scene_2_alloc();
60-
view_dispatcher_add_view(app->view_dispatcher, BoilerplateViewIdScene2, boilerplate_scene_2_get_view(app->boilerplate_scene_2));
70+
view_dispatcher_add_view(
71+
app->view_dispatcher,
72+
BoilerplateViewIdScene2,
73+
boilerplate_scene_2_get_view(app->boilerplate_scene_2));
6174
app->button_menu = button_menu_alloc();
62-
view_dispatcher_add_view(app->view_dispatcher, BoilerplateViewIdScene3, button_menu_get_view(app->button_menu));
63-
75+
view_dispatcher_add_view(
76+
app->view_dispatcher, BoilerplateViewIdScene3, button_menu_get_view(app->button_menu));
77+
6478
app->variable_item_list = variable_item_list_alloc();
65-
view_dispatcher_add_view(app->view_dispatcher, BoilerplateViewIdSettings, variable_item_list_get_view(app->variable_item_list));
79+
view_dispatcher_add_view(
80+
app->view_dispatcher,
81+
BoilerplateViewIdSettings,
82+
variable_item_list_get_view(app->variable_item_list));
6683

6784
//End Scene Additions
6885

@@ -71,7 +88,7 @@ Boilerplate* boilerplate_app_alloc() {
7188

7289
void boilerplate_app_free(Boilerplate* app) {
7390
furi_assert(app);
74-
91+
7592
// Scene manager
7693
scene_manager_free(app->scene_manager);
7794

@@ -84,7 +101,7 @@ void boilerplate_app_free(Boilerplate* app) {
84101

85102
view_dispatcher_free(app->view_dispatcher);
86103
furi_record_close(RECORD_GUI);
87-
104+
88105
app->gui = NULL;
89106
app->notification = NULL;
90107

@@ -99,23 +116,21 @@ void boilerplate_app_free(Boilerplate* app) {
99116
int32_t boilerplate_app(void* p) {
100117
UNUSED(p);
101118
Boilerplate* app = boilerplate_app_alloc();
102-
119+
103120
view_dispatcher_attach_to_gui(app->view_dispatcher, app->gui, ViewDispatcherTypeFullscreen);
104-
105-
scene_manager_next_scene(app->scene_manager, BoilerplateSceneStartscreen); //Start with start screen
121+
122+
scene_manager_next_scene(
123+
app->scene_manager, BoilerplateSceneStartscreen); //Start with start screen
106124
//scene_manager_next_scene(app->scene_manager, BoilerplateSceneMenu); //if you want to directly start with Menu
107125

108126
furi_hal_power_suppress_charge_enter();
109127

110128
view_dispatcher_run(app->view_dispatcher);
111129

112130
boilerplate_save_settings(app);
113-
131+
114132
furi_hal_power_suppress_charge_exit();
115133
boilerplate_app_free(app);
116134

117135
return 0;
118136
}
119-
120-
121-

boilerplate.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#include <gui/gui.h>
66
#include <input/input.h>
77
#include <stdlib.h>
8-
#include <assets_icons.h>
98
#include <dialogs/dialogs.h>
109
#include <notification/notification_messages.h>
1110
#include <gui/view_dispatcher.h>
@@ -19,6 +18,7 @@
1918
#include "views/boilerplate_scene_1.h"
2019
#include "views/boilerplate_scene_2.h"
2120
#include "helpers/boilerplate_storage.h"
21+
#include "boilerplate_icons.h"
2222

2323
#define TAG "Boilerplate"
2424

@@ -37,7 +37,7 @@ typedef struct {
3737
BoilerplateScene2* boilerplate_scene_2;
3838
DialogsApp* dialogs; // File Browser
3939
FuriString* file_path; // File Browser
40-
uint32_t haptic;
40+
uint32_t haptic;
4141
uint32_t speaker;
4242
uint32_t led;
4343
uint32_t save_settings;

docs/README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
## Boilerplate
2+
3+
Boilerplate for a Flipper Zero application, you can use this code as a starting point for developing your own app.
4+
### Features
5+
- Start Screen
6+
- Menu
7+
- Button Menu
8+
- File Browser
9+
- Different Scenes / Views
10+
- Settings Page (On/Off for haptics, sound, led)
11+
- Handling of Button Inputs
12+
- Handling of Tick events
13+
- Handling of Enter/Exit events
14+
- Rendering to GUI
15+
- Haptic Feedback
16+
- Sound Effects
17+
- LED Effects
18+
- Dolphin Deeds (make dolphin happy)
19+
- Storage (Saves settings)

docs/changelog.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
## 1.0
2+
- Added versioning
3+
- Fixed icon dependency for full support of ufbt and custom firmware compilations
4+
- Added Changelog and docs
5+
- Code formatting updated

helpers/boilerplate_custom_event.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ static inline uint32_t boilerplate_custom_menu_event_pack(uint16_t type, int16_t
4141
BoilerplateCustomEventMenu event = {.content = {.type = type, .value = value}};
4242
return event.packed_value;
4343
}
44-
static inline void boilerplate_custom_menu_event_unpack(uint32_t packed_value, uint16_t* type, int16_t* value) {
44+
static inline void
45+
boilerplate_custom_menu_event_unpack(uint32_t packed_value, uint16_t* type, int16_t* value) {
4546
BoilerplateCustomEventMenu event = {.packed_value = packed_value};
4647
if(type) *type = event.content.type;
4748
if(value) *value = event.content.value;

0 commit comments

Comments
 (0)