Skip to content

Commit 644227f

Browse files
author
David Lee
committed
Callback after subghz. Waiting still not correct
1 parent 97c98a8 commit 644227f

File tree

7 files changed

+58
-36
lines changed

7 files changed

+58
-36
lines changed

docs/changelog.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
## v2.0
2-
2+
- SubGhz Functionality added
3+
- Slight change in Storage format to enalbe individual IR timings later (feature request)
34
- Fixed more memory leaks
45

56
## v1.1

helpers/subghz/subghz.c

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -28,33 +28,23 @@ void subghz_free(SubGhz* subghz) {
2828

2929
void subghz_scene_transmit_callback_end_tx(void* context) {
3030
furi_assert(context);
31-
//UNUSED(context);
3231
FURI_LOG_D(TAG, "callback end");
3332
XRemote* app = context;
3433
view_dispatcher_send_custom_event(
3534
app->view_dispatcher, XRemoteCustomEventViewTransmitterSendStop);
35+
36+
37+
//app->state_notifications = SubGhzNotificationStateIDLE;
38+
//subghz_txrx_stop(app->subghz->txrx);
39+
//app->transmitting = false;
40+
//xremote_scene_ir_notification_message(app, SubGhzNotificationMessageBlinkStop);
41+
xremote_cross_remote_set_transmitting(app->cross_remote, XRemoteTransmittingStop);
3642
}
3743

3844
void subghz_send(void* context, const char* path) {
39-
//UNUSED(context);
4045
XRemote* app = context;
41-
//SubGhz* subghz = subghz_alloc();
42-
43-
FURI_LOG_D(TAG, "loading protocol from file");
46+
4447
subghz_load_protocol_from_file(app->subghz, path);
45-
46-
/*Storage* storage = furi_record_open(RECORD_STORAGE);
47-
FlipperFormat* ff = flipper_format_file_alloc(storage);
48-
49-
if(!flipper_format_file_open_existing(ff, MEAL_PAGER_TMP_FILE)) {
50-
//totp_close_config_file(fff_file);
51-
FURI_LOG_E(TAG, "Error reading Temp File %s", MEAL_PAGER_TMP_FILE);
52-
furi_record_close(RECORD_STORAGE);
53-
return;
54-
}*/
55-
56-
//subghz_txrx_tx_start(subghz->txrx, ff);
57-
5848
FURI_LOG_D(TAG, "Starting Transmission");
5949
subghz_txrx_tx_start(
6050
app->subghz->txrx,
@@ -65,13 +55,7 @@ void subghz_send(void* context, const char* path) {
6555
app->subghz->txrx, subghz_scene_transmit_callback_end_tx, app);
6656
app->state_notifications = SubGhzNotificationStateTx;
6757

68-
/*flipper_format_rewind(ff);
69-
flipper_format_file_close(ff);
70-
flipper_format_free(ff);
7158

72-
furi_record_close(RECORD_STORAGE);*/
7359

74-
//subghz_free(subghz);
7560
FURI_LOG_D(TAG, "Finished Transmitting");
76-
//meal_pager_blink_stop(app);
7761
}

scenes/xremote_scene_menu.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#include "../helpers/subghz/subghz.h"
12
#include "../xremote.h"
23

34
enum SubmenuIndex {

scenes/xremote_scene_transmit.c

Lines changed: 44 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,13 @@ void xremote_scene_transmit_send_pause(XRemote* app, CrossRemoteItem* item) {
8080
}
8181

8282
void xremote_scene_transmit_send_subghz(XRemote* app, CrossRemoteItem* item) {
83-
UNUSED(item);
8483
app->transmitting = true;
8584
xremote_scene_ir_notification_message(app, SubGhzNotificationMessageBlinkStartSend);
8685
// ADD SEND METHOD HERE
87-
//FURI_LOG_D("SUBGZK", "path: %s", furi_string_get_cstr(item->filename));
8886
subghz_send(app, furi_string_get_cstr(item->filename)); //currently crashes, null pointer
89-
furi_thread_flags_wait(0, FuriFlagWaitAny, 2000); //Remove later
90-
app->transmitting = false;
91-
xremote_scene_ir_notification_message(app, SubGhzNotificationMessageBlinkStop);
87+
//furi_thread_flags_wait(0, FuriFlagWaitAny, 2000); //Remove later
88+
//app->transmitting = false;
89+
//xremote_scene_ir_notification_message(app, SubGhzNotificationMessageBlinkStop);
9290
}
9391

9492
void xremote_scene_transmit_send_signal(void* context, CrossRemoteItem* item) {
@@ -104,13 +102,15 @@ void xremote_scene_transmit_send_signal(void* context, CrossRemoteItem* item) {
104102
xremote_transmit_model_set_type(app->xremote_transmit, item->type);
105103
if(item->type == XRemoteRemoteItemTypeInfrared) {
106104
xremote_scene_transmit_send_ir_signal(app, item);
105+
xremote_cross_remote_set_transmitting(remote, XRemoteTransmittingStop);
107106
} else if(item->type == XRemoteRemoteItemTypePause) {
108107
xremote_scene_transmit_send_pause(app, item);
108+
xremote_cross_remote_set_transmitting(remote, XRemoteTransmittingStop);
109109
} else if(item->type == XRemoteRemoteItemTypeSubGhz) {
110110
xremote_scene_transmit_send_subghz(app, item);
111111
}
112112

113-
xremote_cross_remote_set_transmitting(remote, XRemoteTransmittingStop);
113+
//xremote_cross_remote_set_transmitting(remote, XRemoteTransmittingStop);
114114
}
115115

116116
void xremote_scene_transmit_run_remote(void* context) {
@@ -125,7 +125,16 @@ void xremote_scene_transmit_run_remote(void* context) {
125125
CrossRemoteItem* item = xremote_cross_remote_get_item(remote, i);
126126
xremote_scene_transmit_send_signal(app, item);
127127
//furi_thread_flags_wait(0, FuriFlagWaitAny, 2000);
128-
xremote_scene_ir_notification_message(app, InfraredNotificationMessageBlinkStartSend);
128+
//furi_thread_flags_wait(0, FuriFlagWaitAny, 1000);
129+
//xremote_scene_ir_notification_message(app, InfraredNotificationMessageBlinkStartSend);
130+
} else if(xremote_cross_remote_get_transmitting(remote) == XRemoteTransmittingStopSubghz) {
131+
i++;
132+
app->state_notifications = SubGhzNotificationStateIDLE;
133+
subghz_txrx_stop(app->subghz->txrx);
134+
app->transmitting = false;
135+
xremote_scene_ir_notification_message(app, SubGhzNotificationMessageBlinkStop);
136+
xremote_cross_remote_set_transmitting(remote, XRemoteTransmittingIdle);
137+
//furi_thread_flags_wait(0, FuriFlagWaitAny, 1000);
129138
} else if(xremote_cross_remote_get_transmitting(remote) == XRemoteTransmittingStop) {
130139
i++;
131140
xremote_cross_remote_set_transmitting(remote, XRemoteTransmittingIdle);
@@ -149,14 +158,38 @@ void xremote_scene_transmit_on_enter(void* context) {
149158

150159
bool xremote_scene_transmit_on_event(void* context, SceneManagerEvent event) {
151160
XRemote* app = context;
152-
153-
UNUSED(app);
154-
UNUSED(event);
155161
bool consumed = false;
162+
163+
if(event.type == SceneManagerEventTypeCustom) {
164+
FURI_LOG_D(TAG, "Custom Event");
165+
switch(event.event) {
166+
case XRemoteCustomEventViewTransmitterSendStop:
167+
FURI_LOG_D("SUBGHZ", "stop event");
168+
//app->stop_transmit = true;
169+
app->state_notifications = SubGhzNotificationStateIDLE;
170+
subghz_txrx_stop(app->subghz->txrx);
171+
app->transmitting = false;
172+
xremote_scene_ir_notification_message(app, SubGhzNotificationMessageBlinkStop);
173+
xremote_cross_remote_set_transmitting(app->cross_remote, XRemoteTransmittingStop);
174+
break;
175+
default:
176+
break;
177+
}
178+
} else if(event.type == SceneManagerEventTypeTick) {
179+
FURI_LOG_D(TAG, "Tick Event");
180+
if (app->state_notifications == SubGhzNotificationStateTx && app->led == 1) {
181+
//blink for subghz
182+
}
183+
}
184+
185+
156186
return consumed;
157187
}
158188

159189
void xremote_scene_transmit_on_exit(void* context) {
160190
XRemote* app = context;
161-
UNUSED(app);
191+
app->transmitting = false;
192+
subghz_txrx_stop(app->subghz->txrx);
193+
app->state_notifications = SubGhzNotificationStateIDLE;
194+
//xremote_cross_remote_set_transmitting(remote, XRemoteTransmittingIdle);
162195
}

xremote.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ XRemote* xremote_app_alloc() {
4949
app->transmitting = 0;
5050
app->ir_timing = 1000;
5151
app->ir_timing_char = "1000";
52+
app->stop_transmit = false;
5253

5354
// Load configs
5455
xremote_read_settings(app);

xremote.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ typedef struct {
4646
uint32_t ir_timing;
4747
char* ir_timing_char;
4848
bool transmitting;
49+
bool stop_transmit;
4950
char text_store[XREMOTE_TEXT_STORE_NUM][XREMOTE_TEXT_STORE_SIZE + 1];
5051
SubGhz* subghz;
5152
} XRemote;

xremote_i.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ typedef enum {
8787
XRemoteTransmittingIdle,
8888
XRemoteTransmittingStart,
8989
XRemoteTransmittingStop,
90+
XRemoteTransmittingStopSubghz,
9091
} XRemoteRemoteTransmissionStatus;
9192

9293
struct InfraredSignal {

0 commit comments

Comments
 (0)