瀏覽代碼

Bug fixes

Fixed back button not stopping running application. moved to tools.
J 2 年之前
父節點
當前提交
4893b8fe90
共有 4 個文件被更改,包括 33 次插入6 次删除
  1. 4 0
      .gitignore
  2. 1 1
      application.fam
  3. 7 3
      views/bf_dev_env.c
  4. 21 2
      worker.c

+ 4 - 0
.gitignore

@@ -1,2 +1,6 @@
 
 README.md
+.vscode/c_cpp_properties.json
+.vscode/launch.json
+README.md
+README.md

+ 1 - 1
application.fam

@@ -9,6 +9,6 @@ App(
     ],
     stack_size=8 * 1024,
     fap_icon="bfico.png",
-    fap_category="Misc",
+    fap_category="Tools",
     fap_icon_assets="icons",
 )

+ 7 - 3
views/bf_dev_env.c

@@ -35,9 +35,9 @@ int selectedButton = 0;
 int saveNotifyCountdown = 0;
 int execCountdown = 0;
 
-char dspLine0[25] = {};
-char dspLine1[25] = {};
-char dspLine2[25] = {};
+char dspLine0[25] = { 0x00 };
+char dspLine1[25] = { 0x00 };
+char dspLine2[25] = { 0x00 };
 
 static bMapping buttonMappings[12] = {
     { 8,  8,  7,  1},  //0
@@ -355,6 +355,10 @@ static void bf_dev_enter_callback(void* context) {
 
     //read into the buffer
     appDev->dataSize = stream_size(stream);
+    if(appDev->dataSize > 2000){
+        return; //BF file is too large
+    }
+
     stream_read(stream, (uint8_t*)appDev->dataBuffer, appDev->dataSize);
     buffered_file_stream_close(stream);
 

+ 21 - 2
worker.c

@@ -1,4 +1,6 @@
 #include "worker.h"
+#include <furi_hal_resources.h>
+#include <furi.h>
 
 bool killswitch = false;
 
@@ -178,12 +180,21 @@ static const NotificationSequence led_on = {
 };
 
 static const NotificationSequence led_off = {
-    &message_green_0,
+    &message_blue_0,
     NULL,
 };
 
+void input_kill(void* _ctx) {
+    UNUSED(_ctx);
+    killswitch = true;
+}
+
 void beginWorker(){
     status = 1;
+
+    //redefined from furi_hal_resources.c
+    const GpioPin gpio_button_back = {.port = GPIOC, .pin = LL_GPIO_PIN_13};
+
     while (inst[instPtr] != 0x00) {
 
         if(runOpCount % 500 == 0){ 
@@ -191,8 +202,16 @@ void beginWorker(){
             notification_message(wrkrApp->notifications, &led_on);
         }
 
+        //status 2 indicates failure
         if(status == 2){ status = 0; break; }
-        if(killswitch) {status = 0; killswitch = false; break; }
+
+        //read back button directly to avoid weirdness in furi
+        if(killswitch || !furi_hal_gpio_read(&gpio_button_back)) {
+            status = 0; 
+            killswitch = false; 
+            break; 
+        }
+
         switch (inst[instPtr]) {
             case '>':
                 rShift();