Просмотр исходного кода

Updated back button behavior based on Sil's work
Found a way to detect the ofw/cfw, so..

HTotoo 2 лет назад
Родитель
Сommit
266e15f46a
3 измененных файлов с 37 добавлено и 20 удалено
  1. 24 6
      lib/nrf24/nrf24.c
  2. 10 13
      lib/nrf24/nrf24.h
  3. 3 1
      nrf24channelscanner.c

+ 24 - 6
lib/nrf24/nrf24.c

@@ -7,9 +7,19 @@
 
 void nrf24_init() {
     // this is needed if multiple SPI devices are connected to the same bus but with different CS pins
-    furi_hal_gpio_init_simple(&gpio_ext_pc3, GpioModeOutputPushPull);
-    furi_hal_gpio_write(&gpio_ext_pc3, true);
-
+	#ifdef XTREME_SETTINGS_PATH
+	
+    if(xtreme_settings.spi_nrf24_handle == SpiDefault) {
+        furi_hal_gpio_init_simple(&gpio_ext_pc3, GpioModeOutputPushPull);
+        furi_hal_gpio_write(&gpio_ext_pc3, true);
+    } else if(xtreme_settings.spi_nrf24_handle == SpiExtra) {
+        furi_hal_gpio_init_simple(&gpio_ext_pa4, GpioModeOutputPushPull);
+        furi_hal_gpio_write(&gpio_ext_pa4, true);
+    }
+	#else
+		furi_hal_gpio_init_simple(&gpio_ext_pc3, GpioModeOutputPushPull);
+		furi_hal_gpio_write(&gpio_ext_pc3, true);
+	#endif
     furi_hal_spi_bus_handle_init(nrf24_HANDLE);
     furi_hal_spi_acquire(nrf24_HANDLE);
     furi_hal_gpio_init(nrf24_CE_PIN, GpioModeOutputPushPull, GpioPullUp, GpioSpeedVeryHigh);
@@ -22,8 +32,16 @@ void nrf24_deinit() {
     furi_hal_gpio_write(nrf24_CE_PIN, false);
     furi_hal_gpio_init(nrf24_CE_PIN, GpioModeAnalog, GpioPullNo, GpioSpeedLow);
 
-    // resetting the CS pins to floating
-    furi_hal_gpio_init_simple(&gpio_ext_pc3, GpioModeAnalog);
+	#ifdef XTREME_SETTINGS_PATH
+		// resetting the CS pins to floating
+		if(xtreme_settings.spi_nrf24_handle == SpiDefault) {
+			furi_hal_gpio_init_simple(&gpio_ext_pc3, GpioModeAnalog);
+		} else if(xtreme_settings.spi_nrf24_handle == SpiExtra) {
+			furi_hal_gpio_init_simple(&gpio_ext_pa4, GpioModeAnalog);
+		}
+	#else
+		furi_hal_gpio_init_simple(&gpio_ext_pc3, GpioModeAnalog);
+	#endif
 }
 
 void nrf24_spi_trx(
@@ -105,4 +123,4 @@ bool nrf24_check_connected(FuriHalSpiBusHandle* handle) {
     } else {
         return false;
     }
-}
+}

+ 10 - 13
lib/nrf24/nrf24.h

@@ -2,11 +2,9 @@
 #include <stdbool.h>
 #include <stdint.h>
 #include <furi_hal_spi.h>
-
-//uncomment for Xtreme FW
-//#include <xtreme.h>
-//uncomment for RogueMaster
-//#include <cfw.h>
+#if __has_include("myinclude.h") 
+#include <xtreme.h>
+#endif
 
 #ifdef __cplusplus
 extern "C" {
@@ -46,14 +44,13 @@ extern "C" {
 
 #define nrf24_TIMEOUT 500
 #define nrf24_CE_PIN &gpio_ext_pb2
-
-//for ofw
+#ifdef XTREME_SETTINGS_PATH
+#define nrf24_HANDLE                                                                         \
+    (xtreme_settings.spi_nrf24_handle == SpiDefault ? &furi_hal_spi_bus_handle_external : \
+                                                         &furi_hal_spi_bus_handle_external_extra)
+#else
 #define nrf24_HANDLE &furi_hal_spi_bus_handle_external
-//for Xtreme
-//#define nrf24_HANDLE  (XTREME_SETTINGS()->spi_nrf24_handle == SpiDefault ? &furi_hal_spi_bus_handle_external : &furi_hal_spi_bus_handle_external_extra)
-//for RogueMaster
-//#define nrf24_HANDLE (CFW_SETTINGS()->spi_nrf24_handle == SpiDefault ? &furi_hal_spi_bus_handle_external :  &furi_hal_spi_bus_handle_external_extra)
-
+#endif
 /* Low level API */
 
 /** Write device register
@@ -134,4 +131,4 @@ bool nrf24_check_connected(FuriHalSpiBusHandle* handle);
 
 #ifdef __cplusplus
 }
-#endif
+#endif

+ 3 - 1
nrf24channelscanner.c

@@ -7,6 +7,7 @@
 #include <notification/notification_messages.h>
 #include <nrf24.h>
 #include "nrf24channelscanner_icons.h"
+#include <assets_icons.h>
 
 const uint8_t num_channels = 128;
 static uint8_t nrf24values[128] = {0}; //to store channel data
@@ -193,7 +194,8 @@ int32_t nrf24channelscanner_main(void* p) {
 
         if(event.type == EventTypeKey) {
             szuz = false; //hit any button, so hide welcome screen
-            if(event.input.type == InputTypeLong && event.input.key == InputKeyBack) {
+            if((event.input.type == InputTypeShort || event.input.type == InputTypeLong) &&
+               event.input.key == InputKeyBack) {
                 if(isScanning) {
                     stopNrfScan = true; //if running, stop it.
                     notification_message(notification, &sequence_blink_yellow_100);