1
1
#include "../xremote.h"
2
2
#include <lib/toolbox/value_index.h>
3
- /*
4
- enum SettingsIndex {
5
- SettingsIndexHaptic = 10,
6
- SettingsIndexValue1,
7
- SettingsIndexValue2,
8
- };*/
9
-
10
- /*const char* const haptic_text[2] = {
11
- "OFF",
12
- "ON",
3
+
4
+ static const char * infrared_pin_text [] = {
5
+ "Flipper" ,
6
+ "2 (A7)" ,
7
+ "Detect" ,
13
8
};
14
- const uint32_t haptic_value[2] = {
15
- XRemoteHapticOff,
16
- XRemoteHapticOn,
17
- };*/
18
9
19
- /* const char* const speaker_text[2 ] = {
10
+ static const char * infrared_otg_text [ ] = {
20
11
"OFF" ,
21
12
"ON" ,
22
13
};
23
- const uint32_t speaker_value[2] = {
24
- XRemoteSpeakerOff,
25
- XRemoteSpeakerOn,
26
- };*/
27
14
28
15
const char * const led_text [2 ] = {
29
16
"OFF" ,
@@ -33,6 +20,7 @@ const uint32_t led_value[2] = {
33
20
XRemoteLedOff ,
34
21
XRemoteLedOn ,
35
22
};
23
+
36
24
const char * const loop_text [2 ] = {
37
25
"OFF" ,
38
26
"ON" ,
@@ -41,6 +29,7 @@ const uint32_t loop_value[2] = {
41
29
XRemoteLoopOff ,
42
30
XRemoteLoopOn ,
43
31
};
32
+
44
33
const char * const settings_text [2 ] = {
45
34
"OFF" ,
46
35
"ON" ,
@@ -50,20 +39,27 @@ const uint32_t settings_value[2] = {
50
39
XRemoteSettingsOn ,
51
40
};
52
41
53
- /* static void xremote_scene_settings_set_haptic (VariableItem* item) {
42
+ static void xremote_scene_settings_set_ir_pin (VariableItem * item ) {
54
43
XRemote * app = variable_item_get_context (item );
55
44
uint8_t index = variable_item_get_current_value_index (item );
56
45
57
- variable_item_set_current_value_text(item, haptic_text[index]);
58
- app->haptic = haptic_value[index];
59
- }*/
46
+ variable_item_set_current_value_text (item , infrared_pin_text [index ]);
47
+ app -> ir_tx_pin = index ;
48
+ view_dispatcher_send_custom_event (
49
+ app -> view_dispatcher ,
50
+ xremote_custom_menu_event_pack (XRemoteCustomEventTypeIrGpioPinChanged , index ));
51
+ }
60
52
61
- /* static void xremote_scene_settings_set_speaker (VariableItem* item) {
53
+ static void xremote_scene_settings_set_ir_is_otg_enabled (VariableItem * item ) {
62
54
XRemote * app = variable_item_get_context (item );
63
55
uint8_t index = variable_item_get_current_value_index (item );
64
- variable_item_set_current_value_text(item, speaker_text[index]);
65
- app->speaker = speaker_value[index];
66
- }*/
56
+
57
+ variable_item_set_current_value_text (item , infrared_otg_text [index ]);
58
+ app -> ir_is_otg_enabled = index ;
59
+ view_dispatcher_send_custom_event (
60
+ app -> view_dispatcher ,
61
+ xremote_custom_menu_event_pack (XRemoteCustomEventTypeIrGpioOtgChanged , index ));
62
+ }
67
63
68
64
static void xremote_scene_settings_set_led (VariableItem * item ) {
69
65
XRemote * app = variable_item_get_context (item );
@@ -109,25 +105,11 @@ void xremote_scene_settings_submenu_callback(void* context, uint32_t index) {
109
105
view_dispatcher_send_custom_event (app -> view_dispatcher , index );
110
106
}
111
107
112
- void xremote_scene_settings_on_enter (void * context ) {
113
- XRemote * app = context ;
108
+ void xremote_scene_settings_init (void * context ) {
109
+ XRemote * app = context ;
114
110
VariableItem * item ;
115
111
uint8_t value_index ;
116
112
117
- // Vibro on/off
118
- /* item = variable_item_list_add(
119
- app->variable_item_list, "Vibro/Haptic:", 2, xremote_scene_settings_set_haptic, app);
120
- value_index = value_index_uint32(app->haptic, haptic_value, 2);
121
- variable_item_set_current_value_index(item, value_index);
122
- variable_item_set_current_value_text(item, haptic_text[value_index]);*/
123
-
124
- // Sound on/off
125
- /* item = variable_item_list_add(
126
- app->variable_item_list, "Sound:", 2, xremote_scene_settings_set_speaker, app);
127
- value_index = value_index_uint32(app->speaker, speaker_value, 2);
128
- variable_item_set_current_value_index(item, value_index);
129
- variable_item_set_current_value_text(item, speaker_text[value_index]);*/
130
-
131
113
// LED Effects on/off
132
114
item = variable_item_list_add (
133
115
app -> variable_item_list , "LED FX" , 2 , xremote_scene_settings_set_led , app );
@@ -149,6 +131,35 @@ void xremote_scene_settings_on_enter(void* context) {
149
131
variable_item_set_current_value_index (item , value_index );
150
132
variable_item_set_current_value_text (item , settings_text [value_index ]);
151
133
134
+ // Infrared GPIO Board
135
+ item = variable_item_list_add (
136
+ app -> variable_item_list ,
137
+ "External IR" ,
138
+ COUNT_OF (infrared_pin_text ),
139
+ xremote_scene_settings_set_ir_pin ,
140
+ app );
141
+ value_index = app -> ir_tx_pin ;
142
+ variable_item_set_current_value_index (item , value_index );
143
+ variable_item_set_current_value_text (item , infrared_pin_text [value_index ]);
144
+
145
+ // Infrared GPIO 5V
146
+ item = variable_item_list_add (
147
+ app -> variable_item_list ,
148
+ "5V on IR GPIO" ,
149
+ COUNT_OF (infrared_otg_text ),
150
+ xremote_scene_settings_set_ir_is_otg_enabled ,
151
+ app );
152
+
153
+ if (app -> ir_tx_pin < FuriHalInfraredTxPinMax ) {
154
+ value_index = app -> ir_is_otg_enabled ;
155
+ variable_item_set_current_value_index (item , value_index );
156
+ variable_item_set_current_value_text (item , infrared_otg_text [value_index ]);
157
+ } else {
158
+ variable_item_set_values_count (item , 1 );
159
+ variable_item_set_current_value_index (item , 0 );
160
+ variable_item_set_current_value_text (item , "Auto" );
161
+ }
162
+
152
163
// Set Infrared Timer
153
164
item = variable_item_list_add (
154
165
app -> variable_item_list , "IR Time ms" , 30 , xremote_scene_settings_set_ir_timing , app );
@@ -163,16 +174,28 @@ void xremote_scene_settings_on_enter(void* context) {
163
174
164
175
variable_item_set_current_value_index (item , (uint8_t )(app -> sg_timing / 100 ));
165
176
snprintf (app -> sg_timing_char , 20 , "%lu" , app -> sg_timing );
166
- variable_item_set_current_value_text (item , app -> sg_timing_char );
177
+ variable_item_set_current_value_text (item , app -> sg_timing_char );
178
+ }
167
179
180
+ void xremote_scene_settings_on_enter (void * context ) {
181
+ XRemote * app = context ;
182
+ xremote_scene_settings_init (app );
168
183
view_dispatcher_switch_to_view (app -> view_dispatcher , XRemoteViewIdSettings );
169
184
}
170
185
171
186
bool xremote_scene_settings_on_event (void * context , SceneManagerEvent event ) {
172
187
XRemote * app = context ;
173
- UNUSED (app );
174
188
bool consumed = false;
175
189
if (event .type == SceneManagerEventTypeCustom ) {
190
+ const uint16_t custom_event_type = xremote_custom_menu_event_get_type (event .event );
191
+
192
+ if (custom_event_type == XRemoteCustomEventTypeIrGpioPinChanged ) {
193
+ variable_item_list_reset (app -> variable_item_list );
194
+ xremote_scene_settings_init (app );
195
+ xremote_ir_set_tx_pin (app );
196
+ } else if (custom_event_type == XRemoteCustomEventTypeIrGpioOtgChanged ) {
197
+ xremote_ir_enable_otg (app , app -> ir_is_otg_enabled );
198
+ }
176
199
}
177
200
return consumed ;
178
201
}
0 commit comments