Skip to content

Commit

Permalink
Added LED Effects for compile & subghz
Browse files Browse the repository at this point in the history
  • Loading branch information
David Lee committed Nov 30, 2023
1 parent 6fac013 commit 1010eda
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 40 deletions.
17 changes: 17 additions & 0 deletions helpers/meal_pager_led.c
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down
6 changes: 6 additions & 0 deletions helpers/meal_pager_led.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
12 changes: 11 additions & 1 deletion helpers/subghz/subghz.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
11 changes: 0 additions & 11 deletions helpers/subghz/subghz_i.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
37 changes: 19 additions & 18 deletions helpers/subghz/subghz_txrx.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);

Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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
Expand All @@ -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);
Expand All @@ -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) {
Expand All @@ -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);
Expand Down Expand Up @@ -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()) {
Expand All @@ -459,7 +460,7 @@ void subghz_txrx_free(SubGhzTxRx* instance) {
instance->speaker_state = SubGhzSpeakerStateDisable;
}
}
}*/
}

/*void subghz_txrx_speaker_mute(SubGhzTxRx* instance) {
furi_assert(instance);
Expand All @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions helpers/subghz/subghz_txrx.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions helpers/subghz/subghz_txrx_i.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;*/
Expand Down
3 changes: 1 addition & 2 deletions meal_pager.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
#pragma once
#include "meal_pager_i.h"

#include "meal_pager_i.h"
5 changes: 5 additions & 0 deletions scenes/meal_pager_scene_transmit.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down

0 comments on commit 1010eda

Please sign in to comment.