Esteban Fuentealba 1 anno fa
parent
commit
a251744f55
3 ha cambiato i file con 258 aggiunte e 56 eliminazioni
  1. 191 0
      .clang-format
  2. 38 44
      malveke_pin_test.c
  3. 29 12
      malveke_pin_test.h

+ 191 - 0
.clang-format

@@ -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
+...
+

+ 38 - 44
malveke_pin_test.c

@@ -1,24 +1,20 @@
 #include "malveke_pin_test.h"
-#include <stdio.h>  // Para sprintf
+#include <stdio.h> // Para sprintf
 #include <string.h> // Para strlen
 
-
 static void gb_live_camera_view_draw_callback(Canvas* canvas, void* _model) {
     UartDumpModel* model = _model;
     UNUSED(model);
     // Prepare canvas
 
     char show_pin[20];
-    snprintf(show_pin, sizeof(show_pin), "%d", model->pin );
-
+    snprintf(show_pin, sizeof(show_pin), "%d", model->pin);
 
     canvas_set_color(canvas, ColorBlack);
     canvas_set_font(canvas, FontSecondary);
     canvas_draw_str(canvas, 37, 35, "PIN:");
     canvas_set_font(canvas, FontBigNumbers);
     canvas_draw_str(canvas, 57, 38, show_pin);
-
-    
 }
 static uint32_t gb_live_camera_exit(void* context) {
     UNUSED(context);
@@ -38,7 +34,6 @@ static void gb_live_camera_app_free(UartEchoApp* app) {
     furi_hal_serial_deinit(app->serial_handle);
     furi_hal_serial_control_release(app->serial_handle);
 
-
     // Free views
     view_dispatcher_remove_view(app->view_dispatcher, 0);
 
@@ -57,9 +52,8 @@ static void gb_live_camera_app_free(UartEchoApp* app) {
 }
 static bool gb_live_camera_view_input_callback(InputEvent* event, void* context) {
     UartEchoApp* app = context;
-    if (event->type == InputTypePress){
-        
-        if (event->key == InputKeyRight){
+    if(event->type == InputTypePress) {
+        if(event->key == InputKeyRight) {
             with_view_model(
                 app->view,
                 UartDumpModel * model,
@@ -67,46 +61,58 @@ static bool gb_live_camera_view_input_callback(InputEvent* event, void* context)
                     if(model->pin + 1 <= 31) {
                         model->pin += 1;
                         char gbpin_start_command[80]; // A reasonably sized buffer.
-                        snprintf(gbpin_start_command, sizeof(gbpin_start_command), "gbpin -p %d\n", model->pin);
-                        furi_hal_serial_tx(app->serial_handle, 
+                        snprintf(
+                            gbpin_start_command,
+                            sizeof(gbpin_start_command),
+                            "gbpin -p %d\n",
+                            model->pin);
+                        furi_hal_serial_tx(
+                            app->serial_handle,
                             (uint8_t*)gbpin_start_command,
                             strlen(gbpin_start_command));
-
                     }
-                    
                 },
                 true);
-           
-        }
-        else if (event->key == InputKeyLeft){
+
+        } else if(event->key == InputKeyLeft) {
             with_view_model(
                 app->view,
                 UartDumpModel * model,
                 {
-                    if(model->pin -1 >= 2) {
+                    if(model->pin - 1 >= 2) {
                         model->pin -= 1;
                         char gbpin_start_command[80]; // A reasonably sized buffer.
-                        snprintf(gbpin_start_command, sizeof(gbpin_start_command), "gbpin -p %d\n", model->pin);
-                        furi_hal_serial_tx(app->serial_handle, 
-                            (uint8_t*)gbpin_start_command, 
+                        snprintf(
+                            gbpin_start_command,
+                            sizeof(gbpin_start_command),
+                            "gbpin -p %d\n",
+                            model->pin);
+                        furi_hal_serial_tx(
+                            app->serial_handle,
+                            (uint8_t*)gbpin_start_command,
                             strlen(gbpin_start_command));
                     }
                 },
                 true);
-        } else if (event->key == InputKeyOk){
+        } else if(event->key == InputKeyOk) {
             for(int i = 2; i <= 31; i++) {
-                    with_view_model(
+                with_view_model(
                     app->view,
                     UartDumpModel * model,
                     {
                         model->pin = i;
                         char gbpin_start_command[80]; // A reasonably sized buffer.
-                        snprintf(gbpin_start_command, sizeof(gbpin_start_command), "gbpin -p %d\n", model->pin);
-                        furi_hal_serial_tx(app->serial_handle, 
-                            (uint8_t*)gbpin_start_command, 
+                        snprintf(
+                            gbpin_start_command,
+                            sizeof(gbpin_start_command),
+                            "gbpin -p %d\n",
+                            model->pin);
+                        furi_hal_serial_tx(
+                            app->serial_handle,
+                            (uint8_t*)gbpin_start_command,
                             strlen(gbpin_start_command));
-
-                    }, true);
+                    },
+                    true);
                 furi_delay_ms(600);
             }
         }
@@ -133,15 +139,8 @@ static UartEchoApp* gb_live_camera_app_alloc() {
     view_set_input_callback(app->view, gb_live_camera_view_input_callback);
     view_allocate_model(app->view, ViewModelTypeLocking, sizeof(UartDumpModel));
 
-
     with_view_model(
-        app->view,
-        UartDumpModel * model,
-        {
-            model->pin = 2;
-        },
-        true);
-
+        app->view, UartDumpModel * model, { model->pin = 2; }, true);
 
     view_set_previous_callback(app->view, gb_live_camera_exit);
     view_dispatcher_add_view(app->view_dispatcher, 0, app->view);
@@ -153,27 +152,22 @@ static UartEchoApp* gb_live_camera_app_alloc() {
         furi_delay_ms(5000);
     }
     furi_check(app->serial_handle);
-    furi_hal_serial_init(app->serial_handle,  115200);
-
+    furi_hal_serial_init(app->serial_handle, 115200);
 
     furi_hal_power_disable_otg();
 
-    
-
-
     // furi_hal_power_suppress_charge_enter();
-    furi_delay_ms(1); 
+    furi_delay_ms(1);
     return app;
 }
 
-
 int32_t malveke_pin_test_app(void* p) {
     UNUSED(p);
 
     UartEchoApp* app = gb_live_camera_app_alloc();
     view_dispatcher_run(app->view_dispatcher);
     gb_live_camera_app_free(app);
-    
+
     furi_hal_power_disable_otg();
 
     return 0;

+ 29 - 12
malveke_pin_test.h

@@ -24,7 +24,8 @@
 #define FRAME_WIDTH 128
 #define FRAME_HEIGTH 64
 #define FRAME_BIT_DEPTH 1
-#define FRAME_BUFFER_LENGTH (FRAME_WIDTH * FRAME_HEIGTH * FRAME_BIT_DEPTH / 8) // 128*64*1 / 8 = 1024
+#define FRAME_BUFFER_LENGTH \
+    (FRAME_WIDTH * FRAME_HEIGTH * FRAME_BIT_DEPTH / 8) // 128*64*1 / 8 = 1024
 #define ROW_BUFFER_LENGTH (FRAME_WIDTH / 8) // 128/8 = 16
 #define LAST_ROW_INDEX (FRAME_BUFFER_LENGTH - ROW_BUFFER_LENGTH) // 1024 - 16 = 1008
 #define RING_BUFFER_LENGTH (ROW_BUFFER_LENGTH + 3) // ROW_BUFFER_LENGTH + Header => 16 + 3 = 19
@@ -34,21 +35,38 @@
 #define MALVEKE_APP_FOLDER EXT_PATH(MALVEKE_APP_FOLDER_USER)
 #define MALVEKE_APP_FOLDER_PHOTOS MALVEKE_APP_FOLDER "/photos"
 
-
 // #define IMAGE_FILE_DIRECTORY_PATH EXT_PATH("DCIM")
 
 static const unsigned char bitmap_header[BITMAP_HEADER_LENGTH] = {
-	0x42, 0x4D, 0x3E, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3E, 0x00,
-	0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x40, 0x00,
-	0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF,
-	0xFF, 0x00
-};
+    0x42, 0x4D, 0x3E, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3E, 0x00, 0x00, 0x00, 0x28, 0x00,
+    0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00};
 
-const uint8_t _I_DolphinCommon_56x48_0[] = {0x01,0x00,0xdf,0x00,0x00,0x1f,0xfe,0x0e,0x05,0x3f,0x04,0x06,0x78,0x06,0x30,0x20,0xf8,0x00,0xc6,0x12,0x1c,0x04,0x0c,0x0a,0x38,0x08,0x08,0x0c,0x60,0xc0,0x21,0xe0,0x04,0x0a,0x18,0x02,0x1b,0x00,0x18,0xa3,0x00,0x21,0x90,0x01,0x8a,0x20,0x02,0x19,0x80,0x18,0x80,0x64,0x09,0x20,0x89,0x81,0x8c,0x3e,0x41,0xe2,0x80,0x50,0x00,0x43,0x08,0x01,0x0c,0xfc,0x68,0x40,0x61,0xc0,0x50,0x30,0x00,0x63,0xa0,0x7f,0x80,0xc4,0x41,0x19,0x07,0xff,0x02,0x06,0x18,0x24,0x03,0x41,0xf3,0x2b,0x10,0x19,0x38,0x10,0x30,0x31,0x7f,0xe0,0x34,0x08,0x30,0x19,0x60,0x80,0x65,0x86,0x0a,0x4c,0x0c,0x30,0x81,0xb9,0x41,0xa0,0x54,0x08,0xc7,0xe2,0x06,0x8a,0x18,0x25,0x02,0x21,0x0f,0x19,0x88,0xd8,0x6e,0x1b,0x01,0xd1,0x1b,0x86,0x39,0x66,0x3a,0xa4,0x1a,0x50,0x06,0x48,0x18,0x18,0xd0,0x03,0x01,0x41,0x98,0xcc,0x60,0x39,0x01,0x49,0x2d,0x06,0x03,0x50,0xf8,0x40,0x3e,0x02,0xc1,0x82,0x86,0xc7,0xfe,0x0f,0x28,0x2c,0x91,0xd2,0x90,0x9a,0x18,0x19,0x3e,0x6d,0x73,0x12,0x16,0x00,0x32,0x49,0x72,0xc0,0x7e,0x5d,0x44,0xba,0x2c,0x08,0xa4,0xc8,0x82,0x06,0x17,0xe0,0x81,0x90,0x2a,0x40,0x61,0xe1,0xa2,0x44,0x0c,0x76,0x2b,0xe8,0x89,0x26,0x43,0x83,0x31,0x8c,0x78,0x0c,0xb0,0x48,0x10,0x1a,0xe0,0x00,0x63,};
+const uint8_t _I_DolphinCommon_56x48_0[] = {
+    0x01, 0x00, 0xdf, 0x00, 0x00, 0x1f, 0xfe, 0x0e, 0x05, 0x3f, 0x04, 0x06, 0x78, 0x06, 0x30, 0x20,
+    0xf8, 0x00, 0xc6, 0x12, 0x1c, 0x04, 0x0c, 0x0a, 0x38, 0x08, 0x08, 0x0c, 0x60, 0xc0, 0x21, 0xe0,
+    0x04, 0x0a, 0x18, 0x02, 0x1b, 0x00, 0x18, 0xa3, 0x00, 0x21, 0x90, 0x01, 0x8a, 0x20, 0x02, 0x19,
+    0x80, 0x18, 0x80, 0x64, 0x09, 0x20, 0x89, 0x81, 0x8c, 0x3e, 0x41, 0xe2, 0x80, 0x50, 0x00, 0x43,
+    0x08, 0x01, 0x0c, 0xfc, 0x68, 0x40, 0x61, 0xc0, 0x50, 0x30, 0x00, 0x63, 0xa0, 0x7f, 0x80, 0xc4,
+    0x41, 0x19, 0x07, 0xff, 0x02, 0x06, 0x18, 0x24, 0x03, 0x41, 0xf3, 0x2b, 0x10, 0x19, 0x38, 0x10,
+    0x30, 0x31, 0x7f, 0xe0, 0x34, 0x08, 0x30, 0x19, 0x60, 0x80, 0x65, 0x86, 0x0a, 0x4c, 0x0c, 0x30,
+    0x81, 0xb9, 0x41, 0xa0, 0x54, 0x08, 0xc7, 0xe2, 0x06, 0x8a, 0x18, 0x25, 0x02, 0x21, 0x0f, 0x19,
+    0x88, 0xd8, 0x6e, 0x1b, 0x01, 0xd1, 0x1b, 0x86, 0x39, 0x66, 0x3a, 0xa4, 0x1a, 0x50, 0x06, 0x48,
+    0x18, 0x18, 0xd0, 0x03, 0x01, 0x41, 0x98, 0xcc, 0x60, 0x39, 0x01, 0x49, 0x2d, 0x06, 0x03, 0x50,
+    0xf8, 0x40, 0x3e, 0x02, 0xc1, 0x82, 0x86, 0xc7, 0xfe, 0x0f, 0x28, 0x2c, 0x91, 0xd2, 0x90, 0x9a,
+    0x18, 0x19, 0x3e, 0x6d, 0x73, 0x12, 0x16, 0x00, 0x32, 0x49, 0x72, 0xc0, 0x7e, 0x5d, 0x44, 0xba,
+    0x2c, 0x08, 0xa4, 0xc8, 0x82, 0x06, 0x17, 0xe0, 0x81, 0x90, 0x2a, 0x40, 0x61, 0xe1, 0xa2, 0x44,
+    0x0c, 0x76, 0x2b, 0xe8, 0x89, 0x26, 0x43, 0x83, 0x31, 0x8c, 0x78, 0x0c, 0xb0, 0x48, 0x10, 0x1a,
+    0xe0, 0x00, 0x63,
+};
 const uint8_t* const _I_DolphinCommon_56x48[] = {_I_DolphinCommon_56x48_0};
-const Icon I_DolphinCommon_56x48 = {.width=56,.height=48,.frame_count=1,.frame_rate=0,.frames=_I_DolphinCommon_56x48};
+const Icon I_DolphinCommon_56x48 = {
+    .width = 56,
+    .height = 48,
+    .frame_count = 1,
+    .frame_rate = 0,
+    .frames = _I_DolphinCommon_56x48};
 
 typedef struct UartDumpModel UartDumpModel;
 
@@ -62,7 +80,6 @@ typedef struct {
 } UartEchoApp;
 
 struct UartDumpModel {
-
     int pin;
 };