Willy-JL il y a 1 an
Parent
commit
e0cf1c734b

+ 10 - 18
gpio_controller/app_defines.h

@@ -3,35 +3,28 @@
 
 #define GPIO_PIN_COUNT 8
 #define ANIMATE_FRAME_TIME_MS 133
-#define FRAME_TIME 66.666666 
+#define FRAME_TIME 66.666666
 
 typedef void (*DrawView)(Canvas* canvas, void* ctx);
 typedef void (*HandleInput)(InputEvent* event, void* ctx);
 
-typedef enum {
-    MAIN_VIEW,
-    CONFIG_MENU_VIEW
-}enum_view;
+typedef enum { MAIN_VIEW, CONFIG_MENU_VIEW } enum_view;
 
 typedef enum {
     GPIO_MODE_INPUT,
     GPIO_MODE_INPUT_PULLUP,
     GPIO_MODE_OUTPUT,
     GPIO_MODE_UNSET
-}GpioUserMode;
+} GpioUserMode;
 
 typedef enum {
     GPIO_VALUE_TRUE,
     GPIO_VALUE_FALSE,
     GPIO_VALUE_INPUT,
     GPIO_VALUE_NONE
-}GpioUserValue;
+} GpioUserValue;
 
-typedef enum {
-    CONFIG_MENU_MODE,
-    CONFIG_MENU_VALUE,
-    CONFIG_MENU_INPUT
-}ConfigMenuOptions;
+typedef enum { CONFIG_MENU_MODE, CONFIG_MENU_VALUE, CONFIG_MENU_INPUT } ConfigMenuOptions;
 
 typedef struct {
     GpioUserMode mode;
@@ -39,7 +32,7 @@ typedef struct {
     int gp_idx_input;
     bool changed;
     GpioUserMode prev_mode;
-}GPIOPinUserSelection;
+} GPIOPinUserSelection;
 
 typedef struct {
     int selected;
@@ -79,7 +72,7 @@ typedef enum {
     PIN_GND_11,
     PIN_GND_18,
     NONE
-}enum_view_element;
+} enum_view_element;
 
 typedef struct {
     enum_view_element element;
@@ -94,7 +87,7 @@ typedef struct {
     const char* name;
     Icon* icon;
     Icon* selected_icon;
-}ViewElement;
+} ViewElement;
 
 typedef struct {
     uint8_t element_idx;
@@ -108,7 +101,7 @@ typedef struct {
     bool found;
     bool input;
     GPIOPinUserSelection user;
-}GPIOPin;
+} GPIOPin;
 
 // GPIO enums from firmware/targets/f7/furi_hal/furi_hal_gpio.h
 
@@ -139,5 +132,4 @@ typedef struct {
 //     GpioPullDown,
 // } GpioPull;
 
-
-#endif 
+#endif

+ 1 - 1
gpio_controller/application.fam

@@ -7,5 +7,5 @@ App(
     stack_size=1 * 1024,
     fap_category="GPIO",
     fap_icon="icon10px.png",
-    fap_icon_assets="images"
+    fap_icon_assets="images",
 )

+ 191 - 179
gpio_controller/gpio_controller.c

@@ -17,93 +17,140 @@
 static void draw_main_view(Canvas* canvas, void* ctx);
 static void draw_config_menu_view(Canvas* canvas, void* ctx);
 
-static DrawView draw_view_funcs[] = {
-    draw_main_view,
-    draw_config_menu_view
-};
+static DrawView draw_view_funcs[] = {draw_main_view, draw_config_menu_view};
 
 static void handle_main_input(InputEvent* event, void* ctx);
 static void handle_config_menu_input(InputEvent* event, void* ctx);
 
-static HandleInput input_handlers[] = {
-    handle_main_input,
-    handle_config_menu_input
-};
+static HandleInput input_handlers[] = {handle_main_input, handle_config_menu_input};
 
 static ViewerState vstate;
 
-static int wiggle[] = {-1,1,-1,1};
+static int wiggle[] = {-1, 1, -1, 1};
 static uint32_t wiggle_frame_count = 4;
 
 static ViewElement elements[] = {
-    {PIN_5V,     PIN_3V,  true, false,  true,  true, -1,   0,   0, "5V" ,               (Icon*)&I_5v_pin, NULL},
-    {PIN_A7,     PIN_SWC, true, false,  true,  true, -1,  14,   0, "PA7",               (Icon*)&I_a7_pin, NULL},
-    {PIN_A6,     NONE,    true, false,  true,  true, -1,  28,   0, "PA6",               (Icon*)&I_a6_pin, NULL},
-    {PIN_A4,     PIN_SIO, true, false,  true,  true, -1,  42,   0, "PA4",               (Icon*)&I_a4_pin, NULL},
-    {PIN_B3,     PIN_TX,  true, false,  true,  true, -1,  56,   0, "PB3",               (Icon*)&I_b3_pin, NULL},
-    {PIN_B2,     PIN_RX,  true, false,  true,  true, -1,  70,   0, "PB2",               (Icon*)&I_b2_pin, NULL},
-    {PIN_C3,     PIN_C1,  true, false,  true,  true, -1,  84,   0, "PC3",               (Icon*)&I_c3_pin, NULL}, 
-    {GEARIC,     PIN_1W,  true,  true,  true, false, -1, 112,   0, "Settings",          (Icon*)&I_gear_unhighlighted, (Icon*)&I_gear_highlighted},
-    {PIN_3V,     PIN_5V,  true, false, false,  true, -1,   0,  48, "3.3V",              (Icon*)&I_3v_pin, NULL},
-    {PIN_SWC,    PIN_A7,  true, false, false,  true, -1,  14,  48, "Serial Wire Clock", (Icon*)&I_swc_pin, NULL},
-    {PIN_SIO,    PIN_A4,  true, false, false,  true, -1,  42,  48, "Serial IO",         (Icon*)&I_sio_pin, NULL},
-    {PIN_TX,     PIN_B3,  true, false, false,  true, -1,  56,  48, "UART - Transmit",   (Icon*)&I_tx_pin, NULL},
-    {PIN_RX,     PIN_B2,  true, false, false,  true, -1,  70,  48, "UART - Receive",    (Icon*)&I_rx_pin, NULL},
-    {PIN_C1,     PIN_C3,  true, false, false,  true, -1,  84,  48, "PC1",               (Icon*)&I_c1_pin, NULL},
-    {PIN_C0,     NONE,    true, false, false,  true, -1,  98,  48, "PC0",               (Icon*)&I_c0_pin, NULL},
-    {PIN_1W,     GEARIC,  true,  true, false,  true, -1, 112,  48, "1-Wire",            (Icon*)&I_1w_pin, NULL},
-    {PIN_GND_08, NONE,   false, false,  true, false, -1,  98,  -1, "GND (Ground)",      (Icon*)&I_gnd_pin, NULL},
-    {PIN_GND_11, NONE,   false, false, false, false, -1,  28,  48, "GND (Ground)",      (Icon*)&I_gnd_pin, NULL},
-    {PIN_GND_18, NONE,   false, false, false, false, -1, 126,  48, "GND (Ground)",      (Icon*)&I_gnd_pin, NULL},
+    {PIN_5V, PIN_3V, true, false, true, true, -1, 0, 0, "5V", (Icon*)&I_5v_pin, NULL},
+    {PIN_A7, PIN_SWC, true, false, true, true, -1, 14, 0, "PA7", (Icon*)&I_a7_pin, NULL},
+    {PIN_A6, NONE, true, false, true, true, -1, 28, 0, "PA6", (Icon*)&I_a6_pin, NULL},
+    {PIN_A4, PIN_SIO, true, false, true, true, -1, 42, 0, "PA4", (Icon*)&I_a4_pin, NULL},
+    {PIN_B3, PIN_TX, true, false, true, true, -1, 56, 0, "PB3", (Icon*)&I_b3_pin, NULL},
+    {PIN_B2, PIN_RX, true, false, true, true, -1, 70, 0, "PB2", (Icon*)&I_b2_pin, NULL},
+    {PIN_C3, PIN_C1, true, false, true, true, -1, 84, 0, "PC3", (Icon*)&I_c3_pin, NULL},
+    {GEARIC,
+     PIN_1W,
+     true,
+     true,
+     true,
+     false,
+     -1,
+     112,
+     0,
+     "Settings",
+     (Icon*)&I_gear_unhighlighted,
+     (Icon*)&I_gear_highlighted},
+    {PIN_3V, PIN_5V, true, false, false, true, -1, 0, 48, "3.3V", (Icon*)&I_3v_pin, NULL},
+    {PIN_SWC,
+     PIN_A7,
+     true,
+     false,
+     false,
+     true,
+     -1,
+     14,
+     48,
+     "Serial Wire Clock",
+     (Icon*)&I_swc_pin,
+     NULL},
+    {PIN_SIO, PIN_A4, true, false, false, true, -1, 42, 48, "Serial IO", (Icon*)&I_sio_pin, NULL},
+    {PIN_TX, PIN_B3, true, false, false, true, -1, 56, 48, "UART - Transmit", (Icon*)&I_tx_pin, NULL},
+    {PIN_RX, PIN_B2, true, false, false, true, -1, 70, 48, "UART - Receive", (Icon*)&I_rx_pin, NULL},
+    {PIN_C1, PIN_C3, true, false, false, true, -1, 84, 48, "PC1", (Icon*)&I_c1_pin, NULL},
+    {PIN_C0, NONE, true, false, false, true, -1, 98, 48, "PC0", (Icon*)&I_c0_pin, NULL},
+    {PIN_1W, GEARIC, true, true, false, true, -1, 112, 48, "1-Wire", (Icon*)&I_1w_pin, NULL},
+    {PIN_GND_08,
+     NONE,
+     false,
+     false,
+     true,
+     false,
+     -1,
+     98,
+     -1,
+     "GND (Ground)",
+     (Icon*)&I_gnd_pin,
+     NULL},
+    {PIN_GND_11,
+     NONE,
+     false,
+     false,
+     false,
+     false,
+     -1,
+     28,
+     48,
+     "GND (Ground)",
+     (Icon*)&I_gnd_pin,
+     NULL},
+    {PIN_GND_18,
+     NONE,
+     false,
+     false,
+     false,
+     false,
+     -1,
+     126,
+     48,
+     "GND (Ground)",
+     (Icon*)&I_gnd_pin,
+     NULL},
 };
 
 static GPIOPin gpio_pin_config[GPIO_PIN_COUNT];
 
-static int element_count = NONE; // The NONE enum will a value equal to the number of elements defined in enum_view_element
+static int element_count =
+    NONE; // The NONE enum will a value equal to the number of elements defined in enum_view_element
 
-size_t strnlen(const char *str, size_t maxlen) {
+size_t strnlen(const char* str, size_t maxlen) {
     size_t len = 0;
-    while (len < maxlen && str[len] != '\0') {
+    while(len < maxlen && str[len] != '\0') {
         len++;
     }
     return len;
 }
 
-static void init_state()
-{
+static void init_state() {
     vstate.selected = PIN_A7;
-    vstate.wiggle_frame=-1;
+    vstate.wiggle_frame = -1;
     vstate.view = MAIN_VIEW;
 }
 
-static void init_gpio()
-{
+static void init_gpio() {
     int count = 0;
     for(size_t i = 0; i < gpio_pins_count; i++) {
         if(!gpio_pins[i].debug) {
             for(int j = 0; j < element_count; j++) {
-                if( strcmp(elements[j].name,gpio_pins[i].name) == 0 )
-                {
-                        gpio_pin_config[count].element_idx     = j;
-                        gpio_pin_config[count].pin             = gpio_pins[i].pin;
-                        gpio_pin_config[count].mode            = GpioModeOutputPushPull;
-                        gpio_pin_config[count].pull            = GpioPullNo;
-                        gpio_pin_config[count].speed           = GpioSpeedVeryHigh;
-                        gpio_pin_config[count].value           = 0;
-                        gpio_pin_config[count].name            = gpio_pins[i].name;
-                        gpio_pin_config[count].unset           = true;
-                        gpio_pin_config[count].found           = true;
-                        gpio_pin_config[count].input           = false;
-
-                        gpio_pin_config[count].user.mode = GPIO_MODE_UNSET;
-                        gpio_pin_config[count].user.value = GPIO_VALUE_FALSE;
-                        gpio_pin_config[count].user.gp_idx_input = -1;
-                        gpio_pin_config[count].user.changed = false;
-
-                        elements[j].gp_idx   = i;
-                        elements[j].editable = true;
-
-                        count++;
+                if(strcmp(elements[j].name, gpio_pins[i].name) == 0) {
+                    gpio_pin_config[count].element_idx = j;
+                    gpio_pin_config[count].pin = gpio_pins[i].pin;
+                    gpio_pin_config[count].mode = GpioModeOutputPushPull;
+                    gpio_pin_config[count].pull = GpioPullNo;
+                    gpio_pin_config[count].speed = GpioSpeedVeryHigh;
+                    gpio_pin_config[count].value = 0;
+                    gpio_pin_config[count].name = gpio_pins[i].name;
+                    gpio_pin_config[count].unset = true;
+                    gpio_pin_config[count].found = true;
+                    gpio_pin_config[count].input = false;
+
+                    gpio_pin_config[count].user.mode = GPIO_MODE_UNSET;
+                    gpio_pin_config[count].user.value = GPIO_VALUE_FALSE;
+                    gpio_pin_config[count].user.gp_idx_input = -1;
+                    gpio_pin_config[count].user.changed = false;
+
+                    elements[j].gp_idx = i;
+                    elements[j].editable = true;
+
+                    count++;
                 }
             }
         }
@@ -112,14 +159,12 @@ static void init_gpio()
     vstate.result = 0;
 }
 
-static void update_gpio()
-{
+static void update_gpio() {
     // read from gpio pins
     for(int i = 0; i < GPIO_PIN_COUNT; i++) {
         GPIOPin* gpc = &gpio_pin_config[i];
-        if( !gpc->unset )
-        {
-            if( gpc->mode == GpioModeInput ) {
+        if(!gpc->unset) {
+            if(gpc->mode == GpioModeInput) {
                 gpc->value = furi_hal_gpio_read(gpc->pin) ? 1 : 0;
             }
         }
@@ -129,12 +174,10 @@ static void update_gpio()
 #define TOGGLECOLOR(state, canvas, setting, selected_col, deselected_col) \
     canvas_set_color(canvas, (state == setting) ? selected_col : deselected_col)
 
+const char* gpio_user_mode_strs[] = {"INPUT", "INPUT_PULLUP", "OUTPUT", "UNSET"};
+const char* gpio_user_value_strs[] = {"TRUE", "FALSE", "INPUT"};
 
-const char* gpio_user_mode_strs[] = {"INPUT","INPUT_PULLUP","OUTPUT","UNSET"};
-const char* gpio_user_value_strs[] = {"TRUE","FALSE","INPUT"};
-
-static void draw_config_menu_view(Canvas* canvas, void* ctx)
-{
+static void draw_config_menu_view(Canvas* canvas, void* ctx) {
     UNUSED(ctx);
 
     int gp_idx = elements[vstate.selected].gp_idx;
@@ -146,60 +189,64 @@ static void draw_config_menu_view(Canvas* canvas, void* ctx)
 
     canvas_set_color(canvas, ColorBlack);
     canvas_draw_rframe(canvas, 1, 1, 126, 62, 0);
-    
+
     TOGGLECOLOR(vstate.config_menu_selected, canvas, CONFIG_MENU_MODE, ColorBlack, ColorWhite);
     canvas_draw_box(canvas, 2, 2, 124, 15);
 
     TOGGLECOLOR(vstate.config_menu_selected, canvas, CONFIG_MENU_MODE, ColorWhite, ColorBlack);
     canvas_draw_str(canvas, 6, 12, "Mode");
 
-    if( gpc->user.mode > 0 ) canvas_draw_str(canvas, 34, 12, "<");
+    if(gpc->user.mode > 0) canvas_draw_str(canvas, 34, 12, "<");
 
     canvas_draw_str(canvas, 45, 12, gpio_user_mode_strs[gpc->user.mode]);
 
-    if( gpc->user.mode < GPIO_MODE_UNSET ) canvas_draw_str(canvas, 120, 12, ">");
+    if(gpc->user.mode < GPIO_MODE_UNSET) canvas_draw_str(canvas, 120, 12, ">");
 
-    if( gpc->user.mode == GPIO_MODE_OUTPUT )
-    {
-        TOGGLECOLOR(vstate.config_menu_selected, canvas, CONFIG_MENU_VALUE, ColorBlack, ColorWhite);
+    if(gpc->user.mode == GPIO_MODE_OUTPUT) {
+        TOGGLECOLOR(
+            vstate.config_menu_selected, canvas, CONFIG_MENU_VALUE, ColorBlack, ColorWhite);
         canvas_draw_box(canvas, 2, 16, 124, 15);
 
-        TOGGLECOLOR(vstate.config_menu_selected, canvas, CONFIG_MENU_VALUE, ColorWhite, ColorBlack);
+        TOGGLECOLOR(
+            vstate.config_menu_selected, canvas, CONFIG_MENU_VALUE, ColorWhite, ColorBlack);
         canvas_draw_str(canvas, 6, 12 + 16, "Value");
 
-        if( gpc->user.value > 0 ) canvas_draw_str(canvas, 34, 12 + 16, "<");
+        if(gpc->user.value > 0) canvas_draw_str(canvas, 34, 12 + 16, "<");
 
         canvas_draw_str(canvas, 45, 12 + 16, gpio_user_value_strs[gpc->user.value]);
 
-        if( gpc->user.value < GPIO_VALUE_INPUT ) canvas_draw_str(canvas, 120, 12 + 16, ">");    
+        if(gpc->user.value < GPIO_VALUE_INPUT) canvas_draw_str(canvas, 120, 12 + 16, ">");
     }
-
 }
 
-// TODO: Determine the lowest frame delta we can get away with. 
+// TODO: Determine the lowest frame delta we can get away with.
 // TODO: Redraw only what changes.
 //       - clear previous (drawn) selected pin
 //       - clear newly selected pin
 
-static void draw_main_view(Canvas* canvas, void* ctx)
-{
+static void draw_main_view(Canvas* canvas, void* ctx) {
     UNUSED(ctx);
 
     canvas_clear(canvas);
 
     size_t current_frame_time = furi_get_tick();
-    size_t delta_cycles = (current_frame_time > vstate.prev_frame_time ? current_frame_time - vstate.prev_frame_time : 0);
+    size_t delta_cycles =
+        (current_frame_time > vstate.prev_frame_time ?
+             current_frame_time - vstate.prev_frame_time :
+             0);
     size_t delta_time_ms = delta_cycles * 1000 / furi_kernel_get_tick_frequency();
 
     // delay until desired delta time and recalculate
-    if( delta_time_ms < FRAME_TIME )
-    {
-        furi_delay_ms(FRAME_TIME-delta_time_ms);
+    if(delta_time_ms < FRAME_TIME) {
+        furi_delay_ms(FRAME_TIME - delta_time_ms);
         current_frame_time = furi_get_tick();
-        delta_cycles = (current_frame_time > vstate.prev_frame_time ? current_frame_time - vstate.prev_frame_time : 0);
+        delta_cycles =
+            (current_frame_time > vstate.prev_frame_time ?
+                 current_frame_time - vstate.prev_frame_time :
+                 0);
         delta_time_ms = delta_cycles * 1000 / furi_kernel_get_tick_frequency();
     }
-    
+
     vstate.elapsed_time += delta_time_ms;
     vstate.prev_frame_time = current_frame_time;
 
@@ -209,78 +256,57 @@ static void draw_main_view(Canvas* canvas, void* ctx)
 
     // draw values
     for(int i = 0; i < GPIO_PIN_COUNT; i++) {
-        if( !gpio_pin_config[i].unset )
-        {
+        if(!gpio_pin_config[i].unset) {
             ViewElement e = elements[gpio_pin_config[i].element_idx];
 
             // draw wire
-            if(e.top_row)
-            {
+            if(e.top_row) {
                 canvas_draw_line(canvas, e.x_pos + 6, e.y_pos + 16, e.x_pos + 6, e.y_pos + 16 + 8);
-            }
-            else
-            {
+            } else {
                 canvas_draw_line(canvas, e.x_pos + 6, e.y_pos, e.x_pos + 6, e.y_pos - 8);
             }
-            
-            if(gpio_pin_config[i].mode == GpioModeAnalog)
-            {
+
+            if(gpio_pin_config[i].mode == GpioModeAnalog) {
                 snprintf(hex_string, sizeof(hex_string), "%02X", (int)gpio_pin_config[i].value);
-                if(e.top_row)
-                {
+                if(e.top_row) {
                     canvas_draw_icon(canvas, e.x_pos - 1, e.y_pos + 20, &I_analog_box);
                     canvas_draw_str(canvas, e.x_pos + 1, e.y_pos + 22 + 7, hex_string);
 
-                }   
-                else
-                {
+                } else {
                     canvas_draw_icon(canvas, e.x_pos - 1, e.y_pos - 15, &I_analog_box);
                     canvas_draw_str(canvas, e.x_pos + 1, e.y_pos - 6, hex_string);
                 }
-            }
-            else
-            {
+            } else {
                 const Icon* icon = (int)gpio_pin_config[i].value ? &I_digi_one : &I_digi_zero;
-                if(e.top_row)
-                {
+                if(e.top_row) {
                     canvas_draw_icon(canvas, e.x_pos + 2, e.y_pos + 20, icon);
-                }   
-                else
-                {
+                } else {
                     canvas_draw_icon(canvas, e.x_pos + 2, e.y_pos - 13, icon);
                 }
-                
             }
         }
     }
 
-    for(int i = 0; i < element_count; i++)
-    {
+    for(int i = 0; i < element_count; i++) {
         ViewElement e = elements[i];
         int x = e.x_pos;
         int y = e.y_pos + (e.top_row && e.pull_out ? -3 : 0);
         Icon* icon = e.icon;
 
-        if( vstate.selected == i )
-        {
-            if( e.pull_out )
-            {
+        if(vstate.selected == i) {
+            if(e.pull_out) {
                 y += e.top_row ? 3 : -3;
             }
-            if( e.selected_icon != NULL )
-            {
+            if(e.selected_icon != NULL) {
                 icon = e.selected_icon;
             }
 
-            if(vstate.wiggle_frame >= 0)
-            {
+            if(vstate.wiggle_frame >= 0) {
                 x += wiggle[vstate.wiggle_frame];
 
-                if(vstate.elapsed_time >= ANIMATE_FRAME_TIME_MS)
-                {
+                if(vstate.elapsed_time >= ANIMATE_FRAME_TIME_MS) {
                     vstate.wiggle_frame++;
-                    if ((unsigned int)(vstate.wiggle_frame) >= wiggle_frame_count)
-                    {
+                    if((unsigned int)(vstate.wiggle_frame) >= wiggle_frame_count) {
                         vstate.wiggle_frame = -1;
                     }
                     vstate.elapsed_time = 0;
@@ -293,21 +319,17 @@ static void draw_main_view(Canvas* canvas, void* ctx)
 
     // draw arrows
     for(int i = 0; i < GPIO_PIN_COUNT; i++) {
-        if( !gpio_pin_config[i].unset )
-        {
+        if(!gpio_pin_config[i].unset) {
             ViewElement e = elements[gpio_pin_config[i].element_idx];
 
             bool selected = vstate.selected == gpio_pin_config[i].element_idx;
 
             // draw arrow
-            if(e.top_row)
-            {   
+            if(e.top_row) {
                 int offset = selected ? 3 : 0;
                 const Icon* arrow_icon = gpio_pin_config[i].input ? &I_arrow_up : &I_arrow_down;
                 canvas_draw_icon(canvas, e.x_pos + 3, e.y_pos + 8 + offset, arrow_icon);
-            }   
-            else
-            {
+            } else {
                 int offset = selected ? 0 : 3;
                 const Icon* arrow_icon = gpio_pin_config[i].input ? &I_arrow_down : &I_arrow_up;
                 canvas_draw_icon(canvas, e.x_pos + 3, e.y_pos + -1 + offset, arrow_icon);
@@ -315,59 +337,54 @@ static void draw_main_view(Canvas* canvas, void* ctx)
         }
     }
 
-    
-
     canvas_set_font(canvas, FontSecondary);
     canvas_draw_str(canvas, 0, 42, elements[vstate.selected].name);
 }
 
 static void handle_main_input(InputEvent* event, void* ctx) {
-    if( vstate.wiggle_frame < 0 )
-    {
+    if(vstate.wiggle_frame < 0) {
         furi_assert(ctx);
         FuriMessageQueue* event_queue = ctx;
 
         // place in queue to handle backing out of app
         furi_message_queue_put(event_queue, event, FuriWaitForever);
 
-        if( (event->type == InputTypePress || event->type == InputTypeRelease) && event->key == InputKeyOk )
-        {
-            if( event->type == InputTypePress && elements[vstate.selected].gp_idx < 0 )
-            {
+        if((event->type == InputTypePress || event->type == InputTypeRelease) &&
+           event->key == InputKeyOk) {
+            if(event->type == InputTypePress && elements[vstate.selected].gp_idx < 0) {
                 vstate.wiggle_frame = 0;
                 vstate.elapsed_time = 0;
-            }
-            else if( elements[vstate.selected].gp_idx >= 0 && (event->type == InputTypePress || event->type == InputTypeRelease) )
-            {
+            } else if(
+                elements[vstate.selected].gp_idx >= 0 &&
+                (event->type == InputTypePress || event->type == InputTypeRelease)) {
                 int gp_idx = elements[vstate.selected].gp_idx;
                 gpio_pin_config[gp_idx].user.prev_mode = gpio_pin_config[gp_idx].user.mode;
 
                 vstate.view = CONFIG_MENU_VIEW;
                 vstate.config_menu_selected = CONFIG_MENU_MODE;
             }
-        }
-        else if(event->type == InputTypePress || event->type == InputTypeRepeat) {
+        } else if(event->type == InputTypePress || event->type == InputTypeRepeat) {
             switch(event->key) {
             case InputKeyLeft:
                 vstate.selected--;
-                if(vstate.selected == GEARIC) vstate.selected = PIN_1W;
-                else if(vstate.selected < 0) vstate.selected = GEARIC;
+                if(vstate.selected == GEARIC)
+                    vstate.selected = PIN_1W;
+                else if(vstate.selected < 0)
+                    vstate.selected = GEARIC;
                 break;
             case InputKeyRight:
-                if(vstate.selected <= GEARIC)
-                {
+                if(vstate.selected <= GEARIC) {
                     vstate.selected++;
                     vstate.selected = vstate.selected > GEARIC ? PIN_5V : vstate.selected;
-                }
-                else
-                {
+                } else {
                     vstate.selected++;
                     vstate.selected = vstate.selected > PIN_1W ? PIN_3V : vstate.selected;
                 }
                 break;
             case InputKeyUp:
             case InputKeyDown:
-                if (elements[vstate.selected].opposite != NONE) vstate.selected = elements[vstate.selected].opposite;
+                if(elements[vstate.selected].opposite != NONE)
+                    vstate.selected = elements[vstate.selected].opposite;
                 break;
             default:
                 break;
@@ -376,15 +393,12 @@ static void handle_main_input(InputEvent* event, void* ctx) {
     }
 }
 
-static void set_GPIO_pin_via_user(int gp_idx)
-{
+static void set_GPIO_pin_via_user(int gp_idx) {
     GPIOPin* gpc = &gpio_pin_config[gp_idx];
 
-    if(gpc->user.changed)
-    {
+    if(gpc->user.changed) {
         // update attributes
-        switch(gpc->user.mode)
-        {
+        switch(gpc->user.mode) {
         case GPIO_MODE_INPUT:
             gpc->mode = GpioModeInput;
             gpc->pull = GpioPullNo;
@@ -404,8 +418,7 @@ static void set_GPIO_pin_via_user(int gp_idx)
             break;
         }
 
-        switch(gpc->user.value)
-        {
+        switch(gpc->user.value) {
         case GPIO_VALUE_TRUE:
             gpc->value = (double)1.0;
             break;
@@ -419,11 +432,11 @@ static void set_GPIO_pin_via_user(int gp_idx)
         }
 
         furi_hal_gpio_write(gpc->pin, gpc->value != (double)0.0 ? true : false);
-        if( gpc->user.mode != gpc->user.prev_mode) {
+        if(gpc->user.mode != gpc->user.prev_mode) {
             furi_hal_gpio_init(gpc->pin, gpc->mode, gpc->pull, gpc->speed);
             gpc->unset = false;
         }
-        
+
         gpc->user.changed = false;
     }
 }
@@ -437,8 +450,7 @@ static void handle_config_menu_input(InputEvent* event, void* ctx) {
     if(event->type == InputTypePress || event->type == InputTypeRepeat) {
         switch(event->key) {
         case InputKeyLeft:
-            switch(vstate.config_menu_selected)
-            {
+            switch(vstate.config_menu_selected) {
             case CONFIG_MENU_MODE:
                 if(gpc->user.mode > 0) {
                     gpc->user.mode--;
@@ -458,8 +470,7 @@ static void handle_config_menu_input(InputEvent* event, void* ctx) {
             }
             break;
         case InputKeyRight:
-            switch(vstate.config_menu_selected)
-            {
+            switch(vstate.config_menu_selected) {
             case CONFIG_MENU_MODE:
                 if(gpc->user.mode < GPIO_MODE_UNSET) {
                     gpc->user.mode++;
@@ -479,21 +490,23 @@ static void handle_config_menu_input(InputEvent* event, void* ctx) {
             }
             break;
         case InputKeyUp:
-            if(gpc->user.mode == GPIO_MODE_OUTPUT )
-            { 
-                if( vstate.config_menu_selected == 0 ) vstate.config_menu_selected = CONFIG_MENU_VALUE;
-                else vstate.config_menu_selected--;
+            if(gpc->user.mode == GPIO_MODE_OUTPUT) {
+                if(vstate.config_menu_selected == 0)
+                    vstate.config_menu_selected = CONFIG_MENU_VALUE;
+                else
+                    vstate.config_menu_selected--;
             }
             break;
         case InputKeyDown:
-            if(gpc->user.mode == GPIO_MODE_OUTPUT )
-            {
-                if( vstate.config_menu_selected == CONFIG_MENU_VALUE ) vstate.config_menu_selected = 0;
-                else vstate.config_menu_selected++;
+            if(gpc->user.mode == GPIO_MODE_OUTPUT) {
+                if(vstate.config_menu_selected == CONFIG_MENU_VALUE)
+                    vstate.config_menu_selected = 0;
+                else
+                    vstate.config_menu_selected++;
             }
             break;
         case InputKeyBack:
-            
+
             // Set new pin configuration
             set_GPIO_pin_via_user(gp_idx);
 
@@ -507,11 +520,11 @@ static void handle_config_menu_input(InputEvent* event, void* ctx) {
 }
 
 static void app_draw_callback(Canvas* canvas, void* ctx) {
-    draw_view_funcs[vstate.view](canvas,ctx);
+    draw_view_funcs[vstate.view](canvas, ctx);
 }
 
 static void app_input_callback(InputEvent* input_event, void* ctx) {
-    input_handlers[vstate.view](input_event,ctx);
+    input_handlers[vstate.view](input_event, ctx);
 }
 
 int32_t gpio_controller_main(void* p) {
@@ -538,7 +551,6 @@ int32_t gpio_controller_main(void* p) {
     bool running = true;
     while(running) {
         if(furi_message_queue_get(event_queue, &event, 100) == FuriStatusOk) {
-
             if(event.type == InputTypePress || event.type == InputTypeRepeat) {
                 switch(event.key) {
                 case InputKeyBack:

+ 1 - 1
oscilloscope/application.fam

@@ -10,5 +10,5 @@ App(
     fap_icon="scope_10px.png",
     fap_icon_assets="icons",
     fap_version="0.2",
-    fap_description="Oscilloscope application - apply signal to pin 16/PC0, with a voltage ranging from 0V to 2.5V and ground to pin 18/GND"
+    fap_description="Oscilloscope application - apply signal to pin 16/PC0, with a voltage ranging from 0V to 2.5V and ground to pin 18/GND",
 )

+ 55 - 82
rolling_flaws/rolling_flaws_settings.c

@@ -1,74 +1,62 @@
 #include "rolling_flaws_settings.h"
 
-void rolling_flaws_setting_change(VariableItem *item, char **names, uint8_t *new_index)
-{
+void rolling_flaws_setting_change(VariableItem* item, char** names, uint8_t* new_index) {
     uint8_t index = variable_item_get_current_value_index(item);
     variable_item_set_current_value_text(item, names[index]);
     *new_index = index;
 }
 
-uint32_t setting_frequency_values[] = {310000000, 315000000, 390000000, 433420000, 433920000, 868350000, 868800000};
-char *setting_frequency_names[] = {"310.00", "315.00", "390.00", "433.42", "433.92", "868.35", "868.80"};
-void rolling_flaws_setting_frequency_change(VariableItem *item)
-{
-    RollingFlaws *app = variable_item_get_context(item);
+uint32_t setting_frequency_values[] =
+    {310000000, 315000000, 390000000, 433420000, 433920000, 868350000, 868800000};
+char* setting_frequency_names[] =
+    {"310.00", "315.00", "390.00", "433.42", "433.92", "868.35", "868.80"};
+void rolling_flaws_setting_frequency_change(VariableItem* item) {
+    RollingFlaws* app = variable_item_get_context(item);
     rolling_flaws_setting_change(item, setting_frequency_names, &app->model->frequency_index);
 }
-char *rolling_flaws_setting_frequency_name_get(RollingFlawsModel *model)
-{
+char* rolling_flaws_setting_frequency_name_get(RollingFlawsModel* model) {
     return setting_frequency_names[model->frequency_index];
 }
-uint32_t rolling_flaws_setting_frequency_get(RollingFlawsModel *model)
-{
+uint32_t rolling_flaws_setting_frequency_get(RollingFlawsModel* model) {
     return setting_frequency_values[model->frequency_index];
 }
 
 uint32_t setting_fix_values[] = {0x20000000, 0x201EA8D8, 0x284EE9D5, 0xCAFECAFE};
-char *setting_fix_names[] = {"0x20000000", "0x201EA8D8", "0x284EE9D5", "Custom"};
-void rolling_flaws_setting_fix_change(VariableItem *item)
-{
-    RollingFlaws *app = variable_item_get_context(item);
+char* setting_fix_names[] = {"0x20000000", "0x201EA8D8", "0x284EE9D5", "Custom"};
+void rolling_flaws_setting_fix_change(VariableItem* item) {
+    RollingFlaws* app = variable_item_get_context(item);
     rolling_flaws_setting_change(item, setting_fix_names, &app->model->fix_index);
 }
-uint32_t rolling_flaws_setting_fix_get(RollingFlawsModel *model)
-{
-    if (model->fix_index == COUNT_OF(setting_fix_values) - 1)
-    {
+uint32_t rolling_flaws_setting_fix_get(RollingFlawsModel* model) {
+    if(model->fix_index == COUNT_OF(setting_fix_values) - 1) {
         return model->custom_fix;
     }
     return setting_fix_values[model->fix_index];
 }
-char *rolling_flaws_setting_fix_display_name_get(RollingFlawsModel *model)
-{
+char* rolling_flaws_setting_fix_display_name_get(RollingFlawsModel* model) {
     return setting_fix_names[model->fix_index];
 }
 
-char *setting_protocol_values_mf_name[] = {"DoorHan", "*", "Custom"};
-char *setting_protocol_values_base_name[] = {"KeeLoq 64bit", "KeeLoq 64bit", "KeeLoq 64bit"};
-char *setting_protocol_names[] = {"KL (DH)", "KL (All)", "KL (Custom)"};
-void rolling_flaws_setting_protocol_change(VariableItem *item)
-{
-    RollingFlaws *app = variable_item_get_context(item);
+char* setting_protocol_values_mf_name[] = {"DoorHan", "*", "Custom"};
+char* setting_protocol_values_base_name[] = {"KeeLoq 64bit", "KeeLoq 64bit", "KeeLoq 64bit"};
+char* setting_protocol_names[] = {"KL (DH)", "KL (All)", "KL (Custom)"};
+void rolling_flaws_setting_protocol_change(VariableItem* item) {
+    RollingFlaws* app = variable_item_get_context(item);
     rolling_flaws_setting_change(item, setting_protocol_names, &app->model->protocol_index);
 }
-char *rolling_flaws_setting_protocol_base_name_get(RollingFlawsModel *model)
-{
+char* rolling_flaws_setting_protocol_base_name_get(RollingFlawsModel* model) {
     return setting_protocol_values_base_name[model->protocol_index];
 }
-char *rolling_flaws_setting_protocol_display_name_get(RollingFlawsModel *model)
-{
+char* rolling_flaws_setting_protocol_display_name_get(RollingFlawsModel* model) {
     return setting_protocol_names[model->protocol_index];
 }
-const char *rolling_flaws_setting_protocol_mf_name_get(RollingFlawsModel *model)
-{
-    if (model->protocol_index == COUNT_OF(setting_protocol_values_mf_name) - 1)
-    {
+const char* rolling_flaws_setting_protocol_mf_name_get(RollingFlawsModel* model) {
+    if(model->protocol_index == COUNT_OF(setting_protocol_values_mf_name) - 1) {
         return furi_string_get_cstr(model->custom_mf);
     }
     return setting_protocol_values_mf_name[model->protocol_index];
 }
-void rolling_flaws_setting_protocol_custom_mf_set(RollingFlawsModel *model, FuriString *mf)
-{
+void rolling_flaws_setting_protocol_custom_mf_set(RollingFlawsModel* model, FuriString* mf) {
     model->protocol_index = COUNT_OF(setting_protocol_values_mf_name) - 1;
     variable_item_set_current_value_index(model->variable_item_protocol, model->protocol_index);
     variable_item_set_current_value_text(
@@ -83,99 +71,84 @@ void rolling_flaws_setting_protocol_custom_mf_set(RollingFlawsModel *model, Furi
 }
 
 bool setting_replay_values[] = {false, true};
-char *setting_replay_names[] = {"No", "Yes"};
-void rolling_flaws_setting_replay_change(VariableItem *item)
-{
-    RollingFlaws *app = variable_item_get_context(item);
+char* setting_replay_names[] = {"No", "Yes"};
+void rolling_flaws_setting_replay_change(VariableItem* item) {
+    RollingFlaws* app = variable_item_get_context(item);
     rolling_flaws_setting_change(item, setting_replay_names, &app->model->replay_index);
 }
-bool rolling_flaws_setting_replay_get(RollingFlawsModel *model)
-{
+bool rolling_flaws_setting_replay_get(RollingFlawsModel* model) {
     return setting_replay_values[model->replay_index];
 }
 
 /// @brief The window_next_values have precedence over past/future values.
 uint32_t setting_window_next_values[] = {4, 8, 16, 256, 16384, 32768, 65536};
-char *setting_window_next_names[] = {"4", "8", "16", "256", "16384", "32768", "All"};
-void rolling_flaws_setting_window_next_change(VariableItem *item)
-{
-    RollingFlaws *app = variable_item_get_context(item);
+char* setting_window_next_names[] = {"4", "8", "16", "256", "16384", "32768", "All"};
+void rolling_flaws_setting_window_next_change(VariableItem* item) {
+    RollingFlaws* app = variable_item_get_context(item);
     rolling_flaws_setting_change(item, setting_window_next_names, &app->model->window_next_index);
 }
-uint32_t rolling_flaws_setting_window_next_get(RollingFlawsModel *model)
-{
+uint32_t rolling_flaws_setting_window_next_get(RollingFlawsModel* model) {
     return setting_window_next_values[model->window_next_index];
 }
 
 uint32_t setting_window_future_values[] = {1, 8, 16, 256, 16384, 32768, 65536};
-char *setting_window_future_names[] = {"1", "8", "16", "256", "16384", "32768", "All"};
-void rolling_flaws_setting_window_future_change(VariableItem *item)
-{
-    RollingFlaws *app = variable_item_get_context(item);
+char* setting_window_future_names[] = {"1", "8", "16", "256", "16384", "32768", "All"};
+void rolling_flaws_setting_window_future_change(VariableItem* item) {
+    RollingFlaws* app = variable_item_get_context(item);
     rolling_flaws_setting_change(
         item, setting_window_future_names, &app->model->window_future_index);
 }
-uint32_t rolling_flaws_setting_window_future_get(RollingFlawsModel *model)
-{
+uint32_t rolling_flaws_setting_window_future_get(RollingFlawsModel* model) {
     return setting_window_future_values[model->window_future_index];
 }
 
 uint32_t setting_window_future_gap_values[] = {1, 2, 3, 4};
-char *setting_window_future_gap_names[] = {"1", "2", "3", "4"};
-void rolling_flaws_setting_window_future_gap_change(VariableItem *item)
-{
-    RollingFlaws *app = variable_item_get_context(item);
+char* setting_window_future_gap_names[] = {"1", "2", "3", "4"};
+void rolling_flaws_setting_window_future_gap_change(VariableItem* item) {
+    RollingFlaws* app = variable_item_get_context(item);
     rolling_flaws_setting_change(
         item, setting_window_future_gap_names, &app->model->window_future_gap_index);
 }
-uint32_t rolling_flaws_setting_window_future_gap_get(RollingFlawsModel *model)
-{
+uint32_t rolling_flaws_setting_window_future_gap_get(RollingFlawsModel* model) {
     return setting_window_future_gap_values[model->window_future_gap_index];
 }
 
 bool setting_sn_zero_values[] = {false, true};
-char *setting_sn_zero_names[] = {"No", "Yes"};
-void rolling_flaws_setting_sn_zero_change(VariableItem *item)
-{
-    RollingFlaws *app = variable_item_get_context(item);
+char* setting_sn_zero_names[] = {"No", "Yes"};
+void rolling_flaws_setting_sn_zero_change(VariableItem* item) {
+    RollingFlaws* app = variable_item_get_context(item);
     rolling_flaws_setting_change(item, setting_sn_zero_names, &app->model->sn_zero_index);
 }
-bool rolling_flaws_setting_sn_zero_get(RollingFlawsModel *model)
-{
+bool rolling_flaws_setting_sn_zero_get(RollingFlawsModel* model) {
     return setting_sn_zero_values[model->sn_zero_index];
 }
 
 // HCS300 uses 10 bits in discriminator, HCS200 uses 8 bits
 uint8_t setting_sn_bits_values[] = {8, 10};
-char *setting_sn_bits_names[] = {"8", "10 (dec)"};
-void rolling_flaws_setting_sn_bits_change(VariableItem *item)
-{
-    RollingFlaws *app = variable_item_get_context(item);
+char* setting_sn_bits_names[] = {"8", "10 (dec)"};
+void rolling_flaws_setting_sn_bits_change(VariableItem* item) {
+    RollingFlaws* app = variable_item_get_context(item);
     rolling_flaws_setting_change(item, setting_sn_bits_names, &app->model->sn_bits_index);
 }
-uint8_t rolling_flaws_setting_sn_bits_get(RollingFlawsModel *model)
-{
+uint8_t rolling_flaws_setting_sn_bits_get(RollingFlawsModel* model) {
     return setting_sn_bits_values[model->sn_bits_index];
 }
 
 bool setting_count_zero_values[] = {false, true};
-char *setting_count_zero_names[] = {"No", "Yes"};
-void rolling_flaws_setting_count_zero_change(VariableItem *item)
-{
-    RollingFlaws *app = variable_item_get_context(item);
+char* setting_count_zero_names[] = {"No", "Yes"};
+void rolling_flaws_setting_count_zero_change(VariableItem* item) {
+    RollingFlaws* app = variable_item_get_context(item);
     rolling_flaws_setting_change(item, setting_sn_zero_names, &app->model->count_zero_index);
 }
-bool rolling_flaws_setting_count_zero_get(RollingFlawsModel *model)
-{
+bool rolling_flaws_setting_count_zero_get(RollingFlawsModel* model) {
     return setting_count_zero_values[model->count_zero_index];
 }
 
-void rolling_flaw_populate_variable_item_list(RollingFlaws *app)
-{
+void rolling_flaw_populate_variable_item_list(RollingFlaws* app) {
     app->variable_item_list_config = variable_item_list_alloc();
     variable_item_list_reset(app->variable_item_list_config);
 
-    VariableItem *item;
+    VariableItem* item;
     item = variable_item_list_add(
         app->variable_item_list_config,
         "Frequency",

+ 11 - 9
seader/application.fam

@@ -7,24 +7,26 @@ App(
     entry_point="seader_app",
     cdefines=["APP_SEADER"],
     requires=[
-        "gui", "storage", "nfc",
+        "gui",
+        "storage",
+        "nfc",
     ],
     stack_size=7 * 1024,
     order=20,
     sources=[
-      "*.c",
-      "aeabi_uldivmod.sx",
+        "*.c",
+        "aeabi_uldivmod.sx",
     ],
     fap_icon="icons/logo.png",
     fap_category="NFC",
     fap_version="2.4",
     fap_author="bettse",
-#    fap_extbuild=(
-#        ExtFile(
-#            path="${FAP_SRC_DIR}/lib/asn1/asn_system.h",
-#            command="asn1c -D ${FAP_SRC_DIR}/lib/asn1 -no-gen-example -pdu=all ${FAP_SRC_DIR}/seader.asn1"
-#        ),
-#    ),
+    #    fap_extbuild=(
+    #        ExtFile(
+    #            path="${FAP_SRC_DIR}/lib/asn1/asn_system.h",
+    #            command="asn1c -D ${FAP_SRC_DIR}/lib/asn1 -no-gen-example -pdu=all ${FAP_SRC_DIR}/seader.asn1"
+    #        ),
+    #    ),
     fap_libs=["mbedtls"],
     fap_private_libs=[
         Lib(

+ 1 - 1
usb_consumer_control/application.fam

@@ -8,5 +8,5 @@ App(
     fap_category="USB",
     fap_description="USB Consumer Control",
     fap_icon="usb_ccb_10px.png",
-    fap_version="1.0", 
+    fap_version="1.0",
 )

+ 20 - 10
usb_consumer_control/usb_ccb.c

@@ -65,11 +65,14 @@ UsbCcb* usb_ccb_app_alloc() {
     // Submenu view
     app->submenu = submenu_alloc();
     submenu_set_header(app->submenu, "USB Consumer Control");
-    submenu_add_item(app->submenu, "About", UsbCcbSubmenuIndexAbout, usb_ccb_submenu_callback, app);
+    submenu_add_item(
+        app->submenu, "About", UsbCcbSubmenuIndexAbout, usb_ccb_submenu_callback, app);
     submenu_add_item(app->submenu, "Help", UsbCcbSubmenuIndexHelp, usb_ccb_submenu_callback, app);
-    submenu_add_item(app->submenu, "Start", UsbCcbSubmenuIndexStart, usb_ccb_submenu_callback, app);
+    submenu_add_item(
+        app->submenu, "Start", UsbCcbSubmenuIndexStart, usb_ccb_submenu_callback, app);
     view_set_previous_callback(submenu_get_view(app->submenu), usb_ccb_exit);
-    view_dispatcher_add_view(app->view_dispatcher, UsbCcbViewSubmenu, submenu_get_view(app->submenu));
+    view_dispatcher_add_view(
+        app->view_dispatcher, UsbCcbViewSubmenu, submenu_get_view(app->submenu));
 
     // Dialog view
     app->dialog = dialog_ex_alloc();
@@ -79,22 +82,29 @@ UsbCcb* usb_ccb_app_alloc() {
     dialog_ex_set_right_button_text(app->dialog, "Stay");
     dialog_ex_set_center_button_text(app->dialog, "Menu");
     dialog_ex_set_header(app->dialog, "Exit or return to menu?", 64, 11, AlignCenter, AlignTop);
-    view_dispatcher_add_view(app->view_dispatcher, UsbCcbViewExitConfirm, dialog_ex_get_view(app->dialog));
+    view_dispatcher_add_view(
+        app->view_dispatcher, UsbCcbViewExitConfirm, dialog_ex_get_view(app->dialog));
 
     // About view
     app->usb_ccb_about = usb_ccb_about_alloc();
-    view_set_previous_callback(usb_ccb_about_get_view(app->usb_ccb_about), usb_ccb_exit_confirm_view);
-    view_dispatcher_add_view(app->view_dispatcher, UsbCcbViewAbout, usb_ccb_about_get_view(app->usb_ccb_about));
+    view_set_previous_callback(
+        usb_ccb_about_get_view(app->usb_ccb_about), usb_ccb_exit_confirm_view);
+    view_dispatcher_add_view(
+        app->view_dispatcher, UsbCcbViewAbout, usb_ccb_about_get_view(app->usb_ccb_about));
 
     // Help view
     app->usb_ccb_help = usb_ccb_help_alloc();
-    view_set_previous_callback(usb_ccb_help_get_view(app->usb_ccb_help), usb_ccb_exit_confirm_view);
-    view_dispatcher_add_view(app->view_dispatcher, UsbCcbViewHelp, usb_ccb_help_get_view(app->usb_ccb_help));
+    view_set_previous_callback(
+        usb_ccb_help_get_view(app->usb_ccb_help), usb_ccb_exit_confirm_view);
+    view_dispatcher_add_view(
+        app->view_dispatcher, UsbCcbViewHelp, usb_ccb_help_get_view(app->usb_ccb_help));
 
     // Start view
     app->usb_ccb_start = usb_ccb_start_alloc();
-    view_set_previous_callback(usb_ccb_start_get_view(app->usb_ccb_start), usb_ccb_exit_confirm_view);
-    view_dispatcher_add_view(app->view_dispatcher, UsbCcbViewStart, usb_ccb_start_get_view(app->usb_ccb_start));
+    view_set_previous_callback(
+        usb_ccb_start_get_view(app->usb_ccb_start), usb_ccb_exit_confirm_view);
+    view_dispatcher_add_view(
+        app->view_dispatcher, UsbCcbViewStart, usb_ccb_start_get_view(app->usb_ccb_start));
 
     app->view_id = UsbCcbViewSubmenu;
     view_dispatcher_switch_to_view(app->view_dispatcher, app->view_id);

+ 3 - 2
usb_consumer_control/views/usb_ccb_about.c

@@ -35,7 +35,7 @@ static bool usb_ccb_about_input_callback(InputEvent* event, void* context) {
 
     if(event->type == InputTypeLong && event->key == InputKeyBack) {
         furi_hal_hid_kb_release_all();
-    } 
+    }
 
     return consumed;
 }
@@ -64,5 +64,6 @@ View* usb_ccb_about_get_view(UsbCcbAbout* usb_ccb_about) {
 
 void usb_ccb_about_set_connected_status(UsbCcbAbout* usb_ccb_about, bool connected) {
     furi_assert(usb_ccb_about);
-    with_view_model(usb_ccb_about->view, UsbCcbAboutModel * model, { model->connected = connected; }, true);
+    with_view_model(
+        usb_ccb_about->view, UsbCcbAboutModel * model, { model->connected = connected; }, true);
 }

+ 3 - 2
usb_consumer_control/views/usb_ccb_help.c

@@ -36,7 +36,7 @@ static bool usb_ccb_help_input_callback(InputEvent* event, void* context) {
 
     if(event->type == InputTypeLong && event->key == InputKeyBack) {
         furi_hal_hid_kb_release_all();
-    } 
+    }
 
     return consumed;
 }
@@ -65,5 +65,6 @@ View* usb_ccb_help_get_view(UsbCcbHelp* usb_ccb_help) {
 
 void usb_ccb_help_set_connected_status(UsbCcbHelp* usb_ccb_help, bool connected) {
     furi_assert(usb_ccb_help);
-    with_view_model(usb_ccb_help->view, UsbCcbHelpModel * model, { model->connected = connected; }, true);
+    with_view_model(
+        usb_ccb_help->view, UsbCcbHelpModel * model, { model->connected = connected; }, true);
 }

+ 43 - 44
usb_consumer_control/views/usb_ccb_start.c

@@ -388,16 +388,14 @@ HID_CONSUMER hidConsumerArray[] = {
     {0x299, "AC_MERGE"},
     {0x29A, "AC_SPLIT"},
     {0x29B, "AC_DISRIBUTE_HORIZONTALLY"},
-    {0x29C, "AC_DISTRIBUTE_VERTICALLY"}
-};
+    {0x29C, "AC_DISTRIBUTE_VERTICALLY"}};
 
 const int hidConsumerArraySize = sizeof(hidConsumerArray) / sizeof(hidConsumerArray[0]);
 
 void strrev(char* arr, int start, int end) {
     char temp;
 
-    if (start >= end)
-        return;
+    if(start >= end) return;
 
     temp = *(arr + start);
     *(arr + start) = *(arr + end);
@@ -408,32 +406,28 @@ void strrev(char* arr, int start, int end) {
     strrev(arr, start, end);
 }
 
-char *itoa(int number, char *arr, int base){
+char* itoa(int number, char* arr, int base) {
     int i = 0, r, negative = 0;
 
-    if (number == 0)
-    {
+    if(number == 0) {
         arr[i] = '0';
         arr[i + 1] = '\0';
         return arr;
     }
 
-    if (number < 0 && base == 10)
-    {
+    if(number < 0 && base == 10) {
         number *= -1;
         negative = 1;
     }
 
-    while (number != 0)
-    {
+    while(number != 0) {
         r = number % base;
         arr[i] = (r > 9) ? (r - 10) + 'a' : r + '0';
         i++;
         number /= base;
     }
 
-    if (negative)
-    {
+    if(negative) {
         arr[i] = '-';
         i++;
     }
@@ -447,7 +441,7 @@ char *itoa(int number, char *arr, int base){
 
 // Function to convert a single hex digit to its character representation
 char hexDigitToChar(uint8_t digit) {
-    if (digit < 10) {
+    if(digit < 10) {
         return '0' + digit;
     } else {
         return 'A' + (digit - 10);
@@ -459,13 +453,13 @@ void uint16ToHexString(uint16_t value, char* hexString) {
     hexString[0] = '0';
     hexString[1] = 'x';
     int startIndex = 2;
-    for (int i = 3; i >= 0; --i) {
+    for(int i = 3; i >= 0; --i) {
         uint8_t digit = (value >> (i * 4)) & 0xF;
-        if (digit != 0 || startIndex != 2) {
+        if(digit != 0 || startIndex != 2) {
             hexString[startIndex++] = hexDigitToChar(digit);
         }
     }
-    if (startIndex == 2) { // If there are no non-zero digits, display at least "0x0"
+    if(startIndex == 2) { // If there are no non-zero digits, display at least "0x0"
         hexString[startIndex++] = '0';
     }
     hexString[startIndex] = '\0';
@@ -482,7 +476,7 @@ int currentSubsetIndex = 13;
 
 // Array to store indexes of different CCB subsets
 // The idea would be to try using these different subsets against different types of devices
-int hidConsumerSubsets[] = { 
+int hidConsumerSubsets[] = {
     0, // Generic Consumer Control Device
     7, // Numeric Key Pad
     10, // General Controls
@@ -503,35 +497,35 @@ int hidConsumerSubsets[] = {
 const int hidConsumerSubsetsSize = sizeof(hidConsumerSubsets) / sizeof(hidConsumerSubsets[0]);
 
 const char* getConsumerSubsetName(int i) {
-    if (i >= 0 && i < 7) {
+    if(i >= 0 && i < 7) {
         return "Generic Consumer Control";
-    } else if (i >= 7 && i < 10) {
+    } else if(i >= 7 && i < 10) {
         return "Numeric Key Pad";
-    } else if (i >= 10 && i < 17) {
+    } else if(i >= 10 && i < 17) {
         return "General Controls";
-    } else if (i >= 17 && i < 26) {
+    } else if(i >= 17 && i < 26) {
         return "Menu Controls";
-    } else if (i >= 26 && i < 33) {
+    } else if(i >= 26 && i < 33) {
         return "Display Controls";
-    } else if (i >= 33 && i < 69) {
+    } else if(i >= 33 && i < 69) {
         return "Selection Controls";
-    } else if (i >= 69 && i < 87) {
+    } else if(i >= 69 && i < 87) {
         return "Transport Controls";
-    } else if (i >= 87 && i < 100) {
+    } else if(i >= 87 && i < 100) {
         return "Search Controls";
-    } else if (i >= 100 && i < 111) {
+    } else if(i >= 100 && i < 111) {
         return "Audio Controls";
-    } else if (i >= 111 && i < 117) {
+    } else if(i >= 111 && i < 117) {
         return "Speed Controls";
-    } else if (i >= 117 && i < 131) {
+    } else if(i >= 117 && i < 131) {
         return "Home and Security Controls";
-    } else if (i >= 131 && i < 148) {
+    } else if(i >= 131 && i < 148) {
         return "Speaker Channels";
-    } else if (i >= 148 && i < 153) {
+    } else if(i >= 148 && i < 153) {
         return "PC Theatre";
-    } else if (i >= 153 && i < 224) {
+    } else if(i >= 153 && i < 224) {
         return "Application Launch Buttons";
-    } else if (i >= 224) {
+    } else if(i >= 224) {
         return "GUI Application Controls";
     }
     // Won't ever happen though
@@ -556,7 +550,11 @@ static void usb_ccb_start_draw_callback(Canvas* canvas, void* context) {
     canvas_draw_str(canvas, 0, 38, "Current key subset:");
     canvas_draw_str(canvas, 0, 46, getConsumerSubsetName(i));
 
-    canvas_draw_str(canvas, 0, 56, is_running ? "Sent:                HID_CONSUMER_" : "Next:                HID_CONSUMER_");
+    canvas_draw_str(
+        canvas,
+        0,
+        56,
+        is_running ? "Sent:                HID_CONSUMER_" : "Next:                HID_CONSUMER_");
     canvas_draw_str(canvas, 24, 56, hexString);
     canvas_draw_str(canvas, 0, 64, hidConsumerArray[i].name);
 
@@ -566,7 +564,7 @@ static void usb_ccb_start_draw_callback(Canvas* canvas, void* context) {
         furi_delay_us(autofire_delay * 500);
         furi_hal_hid_consumer_key_press(consumer_key);
         furi_delay_us(2000); // Hold the key pressed for a short amount of time
-        
+
         // Stop sending the consumer control button
         furi_hal_hid_consumer_key_release(consumer_key);
         furi_delay_us(autofire_delay * 500);
@@ -575,8 +573,8 @@ static void usb_ccb_start_draw_callback(Canvas* canvas, void* context) {
         i += 1;
 
         // Stop once we've cycled all consumer control buttons
-        if(i == hidConsumerArraySize){
-            i = 0; 
+        if(i == hidConsumerArraySize) {
+            i = 0;
             is_running = false;
         }
     }
@@ -588,14 +586,15 @@ static void usb_ccb_start_process(UsbCcbStart* usb_ccb_start, InputEvent* event)
         usb_ccb_start->view,
         UsbCcbStartModel * model,
         {
-            if (event->type == InputTypeLong) {
-                if (event->key == InputKeyRight) {
+            if(event->type == InputTypeLong) {
+                if(event->key == InputKeyRight) {
                     model->right_pressed = true;
                     currentSubsetIndex = (currentSubsetIndex + 1) % hidConsumerSubsetsSize;
                     i = hidConsumerSubsets[currentSubsetIndex];
-                } else if (event->key == InputKeyLeft) {
+                } else if(event->key == InputKeyLeft) {
                     model->left_pressed = true;
-                    currentSubsetIndex = (currentSubsetIndex - 1 + hidConsumerSubsetsSize) % hidConsumerSubsetsSize;
+                    currentSubsetIndex =
+                        (currentSubsetIndex - 1 + hidConsumerSubsetsSize) % hidConsumerSubsetsSize;
                     i = hidConsumerSubsets[currentSubsetIndex];
                 }
             } else if(event->type == InputTypePress) {
@@ -608,7 +607,7 @@ static void usb_ccb_start_process(UsbCcbStart* usb_ccb_start, InputEvent* event)
                 } else if(event->key == InputKeyDown) {
                     model->down_pressed = true;
                     if(autofire_delay > 0) {
-                            autofire_delay -= 100;
+                        autofire_delay -= 100;
                     }
                 } else if(event->key == InputKeyUp) {
                     model->up_pressed = true;
@@ -637,7 +636,6 @@ static void usb_ccb_start_process(UsbCcbStart* usb_ccb_start, InputEvent* event)
                 if(event->key == InputKeyBack) {
                 }
             }
-            
         },
         true);
 }
@@ -682,5 +680,6 @@ View* usb_ccb_start_get_view(UsbCcbStart* usb_ccb_start) {
 
 void usb_ccb_start_set_connected_status(UsbCcbStart* usb_ccb_start, bool connected) {
     furi_assert(usb_ccb_start);
-    with_view_model(usb_ccb_start->view, UsbCcbStartModel * model, { model->connected = connected; }, true);
+    with_view_model(
+        usb_ccb_start->view, UsbCcbStartModel * model, { model->connected = connected; }, true);
 }

+ 3 - 3
xremote/xremote.h

@@ -8,9 +8,9 @@
 
 #include "xremote_app.h"
 
-#define XREMOTE_VERSION_MAJ   1
-#define XREMOTE_VERSION_MIN   2
-#define XREMOTE_BUILD_NUMBER  0
+#define XREMOTE_VERSION_MAJ 1
+#define XREMOTE_VERSION_MIN 2
+#define XREMOTE_BUILD_NUMBER 0
 
 /* Returns FAP_VERSION + XREMOTE_BUILD_NUMBER */
 void xremote_get_version(char* version, size_t length);