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

Added LED Effects for compile & subghz

David Lee 2 лет назад
Родитель
Сommit
1010eda040

+ 17 - 0
helpers/meal_pager_led.c

@@ -1,5 +1,22 @@
 #include "meal_pager_led.h"
 
+void meal_pager_blink_start_subghz(Meal_Pager* app) {
+    furi_assert(app);
+    notification_message(app->notification, &sequence_blink_stop);
+    notification_message(app->notification, &sequence_blink_start_magenta);
+}
+
+void meal_pager_blink_start_compile(Meal_Pager* app) {
+    furi_assert(app);
+    notification_message(app->notification, &sequence_blink_stop);
+    notification_message(app->notification, &sequence_blink_start_yellow);
+}
+
+void meal_pager_blink_stop(Meal_Pager* app) {
+    furi_assert(app);
+    notification_message(app->notification, &sequence_blink_stop);
+}
+
 void meal_pager_led_set_rgb(void* context, int red, int green, int blue) {
     Meal_Pager* app = context;
     if (app->led != 1) {

+ 6 - 0
helpers/meal_pager_led.h

@@ -2,6 +2,12 @@
 
 #include "../meal_pager_i.h"
 
+void meal_pager_blink_start_subghz(Meal_Pager* app);
+
+void meal_pager_blink_start_compile(Meal_Pager* app);
+
+void meal_pager_blink_stop(Meal_Pager* app);
+
 void meal_pager_led_set_rgb(void* context, int red, int green, int blue);
 
 void meal_pager_led_reset(void* context);

+ 11 - 1
helpers/subghz/subghz.c

@@ -27,7 +27,17 @@ void subghz_send(void* context) {
     UNUSED(context);
     SubGhz* subghz = subghz_alloc();
 
-    
+    Storage* storage = furi_record_open(RECORD_STORAGE);
+    FlipperFormat* ff = flipper_format_file_alloc(storage);
+
+    subghz_txrx_tx_start(subghz->txrx, ff);
+
+    flipper_format_rewind(ff);
+    flipper_format_file_close(ff);
+    flipper_format_free(ff);
+
+    furi_record_close(RECORD_STORAGE);
+
 
     subghz_free(subghz);
 }

+ 0 - 11
helpers/subghz/subghz_i.c

@@ -28,17 +28,6 @@ void subghz_set_default_preset(SubGhz* subghz) {
         0);
 }*/
 
-/*void subghz_blink_start(SubGhz* subghz) {
-    furi_assert(subghz);
-    notification_message(subghz->notifications, &sequence_blink_stop);
-    notification_message(subghz->notifications, &sequence_blink_start_magenta);
-}*/
-
-/*void subghz_blink_stop(SubGhz* subghz) {
-    furi_assert(subghz);
-    notification_message(subghz->notifications, &sequence_blink_stop);
-}*/
-
 /*bool subghz_tx_start(SubGhz* subghz, FlipperFormat* flipper_format) {
     switch(subghz_txrx_tx_start(subghz->txrx, flipper_format)) {
     case SubGhzTxRxStartTxStateErrorParserOthers:

+ 19 - 18
helpers/subghz/subghz_txrx.c

@@ -183,14 +183,14 @@ void subghz_txrx_free(SubGhzTxRx* instance) {
     return value;
 }*/
 
-/*static void subghz_txrx_idle(SubGhzTxRx* instance) {
+static void subghz_txrx_idle(SubGhzTxRx* instance) {
     furi_assert(instance);
     if(instance->txrx_state != SubGhzTxRxStateSleep) {
         subghz_devices_idle(instance->radio_device);
         subghz_txrx_speaker_off(instance);
         instance->txrx_state = SubGhzTxRxStateIDLE;
     }
-}*/
+}
 
 /*static void subghz_txrx_rx_end(SubGhzTxRx* instance) {
     furi_assert(instance);
@@ -226,7 +226,7 @@ void subghz_txrx_free(SubGhzTxRx* instance) {
     return ret;
 }*/
 
-/*SubGhzTxRxStartTxState subghz_txrx_tx_start(SubGhzTxRx* instance, FlipperFormat* flipper_format) {
+SubGhzTxRxStartTxState subghz_txrx_tx_start(SubGhzTxRx* instance, FlipperFormat* flipper_format) {
     furi_assert(instance);
     furi_assert(flipper_format);
 
@@ -235,7 +235,8 @@ void subghz_txrx_free(SubGhzTxRx* instance) {
     SubGhzTxRxStartTxState ret = SubGhzTxRxStartTxStateErrorParserOthers;
     FuriString* temp_str = furi_string_alloc();
     uint32_t repeat = 200;
-    do {
+    UNUSED(repeat);
+    /*do {
         if(!flipper_format_rewind(flipper_format)) {
             FURI_LOG_E(TAG, "Rewind error");
             break;
@@ -295,10 +296,10 @@ void subghz_txrx_free(SubGhzTxRx* instance) {
             }
         }
 
-    } while(false);
+    } while(false);*/
     furi_string_free(temp_str);
     return ret;
-}*/
+}
 
 /*void subghz_txrx_rx_start(SubGhzTxRx* instance) {
     furi_assert(instance);
@@ -319,7 +320,7 @@ void subghz_txrx_free(SubGhzTxRx* instance) {
     instance->need_save_context = context;
 }*/
 
-/*static void subghz_txrx_tx_stop(SubGhzTxRx* instance) {
+static void subghz_txrx_tx_stop(SubGhzTxRx* instance) {
     furi_assert(instance);
     furi_assert(instance->txrx_state == SubGhzTxRxStateTx);
     //Stop TX
@@ -328,14 +329,14 @@ void subghz_txrx_free(SubGhzTxRx* instance) {
     subghz_transmitter_free(instance->transmitter);
 
     //if protocol dynamic then we save the last upload
-    if(instance->decoder_result->protocol->type == SubGhzProtocolTypeDynamic) {
+    /*if(instance->decoder_result->protocol->type == SubGhzProtocolTypeDynamic) {
         if(instance->need_save_callback) {
             instance->need_save_callback(instance->need_save_context);
         }
-    }
+    }*/
     subghz_txrx_idle(instance);
     subghz_txrx_speaker_off(instance);
-}*/
+}
 
 /*FlipperFormat* subghz_txrx_get_fff_data(SubGhzTxRx* instance) {
     furi_assert(instance);
@@ -347,7 +348,7 @@ void subghz_txrx_free(SubGhzTxRx* instance) {
     return instance->setting;
 }*/
 
-/*void subghz_txrx_stop(SubGhzTxRx* instance) {
+void subghz_txrx_stop(SubGhzTxRx* instance) {
     furi_assert(instance);
 
     switch(instance->txrx_state) {
@@ -356,14 +357,14 @@ void subghz_txrx_free(SubGhzTxRx* instance) {
         subghz_txrx_speaker_unmute(instance);
         break;
     case SubGhzTxRxStateRx:
-        subghz_txrx_rx_end(instance);
-        subghz_txrx_speaker_mute(instance);
+        //subghz_txrx_rx_end(instance);
+        //subghz_txrx_speaker_mute(instance);
         break;
 
     default:
         break;
     }
-}*/
+}
 
 /*void subghz_txrx_hopper_update(SubGhzTxRx* instance) {
     furi_assert(instance);
@@ -449,7 +450,7 @@ void subghz_txrx_free(SubGhzTxRx* instance) {
     }
 }*/
 
-/*void subghz_txrx_speaker_off(SubGhzTxRx* instance) {
+void subghz_txrx_speaker_off(SubGhzTxRx* instance) {
     furi_assert(instance);
     if(instance->speaker_state != SubGhzSpeakerStateDisable) {
         if(furi_hal_speaker_is_mine()) {
@@ -459,7 +460,7 @@ void subghz_txrx_free(SubGhzTxRx* instance) {
                 instance->speaker_state = SubGhzSpeakerStateDisable;
         }
     }
-}*/
+}
 
 /*void subghz_txrx_speaker_mute(SubGhzTxRx* instance) {
     furi_assert(instance);
@@ -470,14 +471,14 @@ void subghz_txrx_free(SubGhzTxRx* instance) {
     }
 }*/
 
-/*void subghz_txrx_speaker_unmute(SubGhzTxRx* instance) {
+void subghz_txrx_speaker_unmute(SubGhzTxRx* instance) {
     furi_assert(instance);
     if(instance->speaker_state == SubGhzSpeakerStateEnable) {
         if(furi_hal_speaker_is_mine()) {
             subghz_devices_set_async_mirror_pin(instance->radio_device, &gpio_speaker);
         }
     }
-}*/
+}
 
 /*void subghz_txrx_speaker_set_state(SubGhzTxRx* instance, SubGhzSpeakerState state) {
     furi_assert(instance);

+ 4 - 4
helpers/subghz/subghz_txrx.h

@@ -93,7 +93,7 @@ void subghz_txrx_free(SubGhzTxRx* instance);
  * @param flipper_format Pointer to a FlipperFormat
  * @return SubGhzTxRxStartTxState 
  */
-//SubGhzTxRxStartTxState subghz_txrx_tx_start(SubGhzTxRx* instance, FlipperFormat* flipper_format);
+SubGhzTxRxStartTxState subghz_txrx_tx_start(SubGhzTxRx* instance, FlipperFormat* flipper_format);
 
 /**
  * Start RX CC1101
@@ -107,7 +107,7 @@ void subghz_txrx_free(SubGhzTxRx* instance);
  * 
  * @param instance Pointer to a SubGhzTxRx
  */
-//void subghz_txrx_stop(SubGhzTxRx* instance);
+void subghz_txrx_stop(SubGhzTxRx* instance);
 
 /**
  * Set sleep mode CC1101
@@ -165,7 +165,7 @@ void subghz_txrx_free(SubGhzTxRx* instance);
  * 
  * @param instance Pointer to a SubGhzTxRx 
  */
-//void subghz_txrx_speaker_off(SubGhzTxRx* instance);
+void subghz_txrx_speaker_off(SubGhzTxRx* instance);
 
 /**
  * Speaker mute
@@ -179,7 +179,7 @@ void subghz_txrx_free(SubGhzTxRx* instance);
  * 
  * @param instance Pointer to a SubGhzTxRx 
  */
-//void subghz_txrx_speaker_unmute(SubGhzTxRx* instance);
+void subghz_txrx_speaker_unmute(SubGhzTxRx* instance);
 
 /**
  * Set state speaker

+ 4 - 4
helpers/subghz/subghz_txrx_i.h

@@ -6,9 +6,9 @@ struct SubGhzTxRx {
     SubGhzWorker* worker;
 
     /*SubGhzEnvironment* environment;
-    SubGhzReceiver* receiver;
+    SubGhzReceiver* receiver;*/
     SubGhzTransmitter* transmitter;
-    SubGhzProtocolDecoderBase* decoder_result;
+    /*SubGhzProtocolDecoderBase* decoder_result;
     FlipperFormat* fff_data;
 
     SubGhzRadioPreset* preset;
@@ -18,11 +18,11 @@ struct SubGhzTxRx {
     uint8_t hopper_idx_frequency;
     bool is_database_loaded;
     SubGhzHopperState hopper_state;
-
+*/
     SubGhzTxRxState txrx_state;
     SubGhzSpeakerState speaker_state;
     const SubGhzDevice* radio_device;
-    SubGhzRadioDeviceType radio_device_type;
+    /*SubGhzRadioDeviceType radio_device_type;
 
     SubGhzTxRxNeedSaveCallback need_save_callback;
     void* need_save_context;*/

+ 1 - 2
meal_pager.h

@@ -1,3 +1,2 @@
 #pragma once
-#include "meal_pager_i.h"
-
+#include "meal_pager_i.h"

+ 5 - 0
scenes/meal_pager_scene_transmit.c

@@ -2,6 +2,7 @@
 #include "../helpers/meal_pager_custom_event.h"
 #include "../helpers/retekess/meal_pager_retekess_t119.h"
 #include "../views/meal_pager_transmit.h"
+#include "../helpers/meal_pager_led.h"
 #include "../helpers/subghz/subghz.h"
 
 void meal_pager_transmit_callback(Meal_PagerCustomEvent event, void* context) {
@@ -15,15 +16,19 @@ void meal_pager_scene_transmit_on_enter(void* context) {
     Meal_Pager* app = context;
     FURI_LOG_D(TAG, "Type is %lu", app->pager_type);
 
+    meal_pager_blink_start_compile(app);
     meal_pager_transmit_model_set_type(app->meal_pager_transmit, app->pager_type);
     meal_pager_transmit_model_set_station(app->meal_pager_transmit, app->current_station);
     meal_pager_transmit_model_set_pager(app->meal_pager_transmit, app->current_pager);
     meal_pager_transmit_set_callback(app->meal_pager_transmit, meal_pager_transmit_callback, app);
     view_dispatcher_switch_to_view(app->view_dispatcher, Meal_PagerViewIdTransmit);
     meal_pager_retekess_t119_generate_all(app);
+
+    meal_pager_blink_start_subghz(app);
     app->stop_transmit = false;
     FURI_LOG_D(TAG, "Generated tmp.sub");
     subghz_send(app);
+    meal_pager_blink_stop(app);
 }
 
 bool meal_pager_scene_transmit_on_event(void* context, SceneManagerEvent event) {