@@ -73,143 +73,145 @@ int32_t i2ctools_app(void* p) {
73
73
// Share scanner with sender
74
74
i2ctools -> sender -> scanner = i2ctools -> scanner ;
75
75
76
- while (furi_message_queue_get (event_queue , & event , FuriWaitForever ) == FuriStatusOk ) {
77
- // Back
78
- if (event .key == InputKeyBack && event .type == InputTypeRelease ) {
79
- if (i2ctools -> main_view -> current_view == MAIN_VIEW ) {
80
- break ;
81
- } else {
82
- if (i2ctools -> main_view -> current_view == SNIFF_VIEW ) {
83
- stop_interrupts ();
84
- i2ctools -> sniffer -> started = false;
85
- i2ctools -> sniffer -> state = I2C_BUS_FREE ;
86
- }
87
- i2ctools -> main_view -> current_view = MAIN_VIEW ;
88
- }
89
- }
90
- // Up
91
- else if (event .key == InputKeyUp && event .type == InputTypeRelease ) {
92
- if (i2ctools -> main_view -> current_view == MAIN_VIEW ) {
93
- if ((i2ctools -> main_view -> menu_index > SCAN_VIEW )) {
94
- i2ctools -> main_view -> menu_index -- ;
95
- }
96
- } else if (i2ctools -> main_view -> current_view == SCAN_VIEW ) {
97
- if (i2ctools -> scanner -> menu_index > 0 ) {
98
- i2ctools -> scanner -> menu_index -- ;
99
- }
100
- } else if (i2ctools -> main_view -> current_view == SNIFF_VIEW ) {
101
- if (i2ctools -> sniffer -> row_index > 0 ) {
102
- i2ctools -> sniffer -> row_index -- ;
103
- }
104
- } else if (i2ctools -> main_view -> current_view == SEND_VIEW ) {
105
- if (i2ctools -> sender -> value < 0xFF ) {
106
- i2ctools -> sender -> value ++ ;
107
- i2ctools -> sender -> sended = false;
108
- }
109
- }
110
- }
111
- // Long Up
112
- else if (
113
- event .key == InputKeyUp &&
114
- (event .type == InputTypeLong || event .type == InputTypeRepeat )) {
115
- if (i2ctools -> main_view -> current_view == SCAN_VIEW ) {
116
- if (i2ctools -> scanner -> menu_index > 5 ) {
117
- i2ctools -> scanner -> menu_index -= 5 ;
118
- }
119
- } else if (i2ctools -> main_view -> current_view == SEND_VIEW ) {
120
- if (i2ctools -> sender -> value < 0xF9 ) {
121
- i2ctools -> sender -> value += 5 ;
122
- i2ctools -> sender -> sended = false;
123
- }
124
- } else if (i2ctools -> main_view -> current_view == SNIFF_VIEW ) {
125
- if (i2ctools -> sniffer -> row_index > 5 ) {
126
- i2ctools -> sniffer -> row_index -= 5 ;
76
+ while (1 ) {
77
+ if (furi_message_queue_get (event_queue , & event , 100 ) == FuriStatusOk ) {
78
+ // Back
79
+ if (event .key == InputKeyBack && event .type == InputTypeRelease ) {
80
+ if (i2ctools -> main_view -> current_view == MAIN_VIEW ) {
81
+ break ;
127
82
} else {
128
- i2ctools -> sniffer -> row_index = 0 ;
129
- }
130
- }
131
- }
132
- // Down
133
- else if (event .key == InputKeyDown && event .type == InputTypeRelease ) {
134
- if (i2ctools -> main_view -> current_view == MAIN_VIEW ) {
135
- if (i2ctools -> main_view -> menu_index < MENU_SIZE - 1 ) {
136
- i2ctools -> main_view -> menu_index ++ ;
137
- }
138
- } else if (i2ctools -> main_view -> current_view == SCAN_VIEW ) {
139
- if (i2ctools -> scanner -> menu_index < ((int )i2ctools -> scanner -> nb_found / 3 )) {
140
- i2ctools -> scanner -> menu_index ++ ;
141
- }
142
- } else if (i2ctools -> main_view -> current_view == SNIFF_VIEW ) {
143
- if ((i2ctools -> sniffer -> row_index + 3 ) <
144
- (int )i2ctools -> sniffer -> frames [i2ctools -> sniffer -> menu_index ].data_index ) {
145
- i2ctools -> sniffer -> row_index ++ ;
146
- }
147
- } else if (i2ctools -> main_view -> current_view == SEND_VIEW ) {
148
- if (i2ctools -> sender -> value > 0x00 ) {
149
- i2ctools -> sender -> value -- ;
150
- i2ctools -> sender -> sended = false;
83
+ if (i2ctools -> main_view -> current_view == SNIFF_VIEW ) {
84
+ stop_interrupts ();
85
+ i2ctools -> sniffer -> started = false;
86
+ i2ctools -> sniffer -> state = I2C_BUS_FREE ;
87
+ }
88
+ i2ctools -> main_view -> current_view = MAIN_VIEW ;
151
89
}
152
90
}
153
- }
154
- // Long Down
155
- else if (
156
- event .key == InputKeyDown &&
157
- (event .type == InputTypeLong || event .type == InputTypeRepeat )) {
158
- if (i2ctools -> main_view -> current_view == SEND_VIEW ) {
159
- if (i2ctools -> sender -> value > 0x05 ) {
160
- i2ctools -> sender -> value -= 5 ;
161
- i2ctools -> sender -> sended = false;
162
- } else {
163
- i2ctools -> sender -> value = 0 ;
164
- i2ctools -> sender -> sended = false;
165
- }
166
- } else if (i2ctools -> main_view -> current_view == SNIFF_VIEW ) {
167
- if ((i2ctools -> sniffer -> row_index + 8 ) <
168
- (int )i2ctools -> sniffer -> frames [i2ctools -> sniffer -> menu_index ].data_index ) {
169
- i2ctools -> sniffer -> row_index += 5 ;
91
+ // Up
92
+ else if (event .key == InputKeyUp && event .type == InputTypeRelease ) {
93
+ if (i2ctools -> main_view -> current_view == MAIN_VIEW ) {
94
+ if ((i2ctools -> main_view -> menu_index > SCAN_VIEW )) {
95
+ i2ctools -> main_view -> menu_index -- ;
96
+ }
97
+ } else if (i2ctools -> main_view -> current_view == SCAN_VIEW ) {
98
+ if (i2ctools -> scanner -> menu_index > 0 ) {
99
+ i2ctools -> scanner -> menu_index -- ;
100
+ }
101
+ } else if (i2ctools -> main_view -> current_view == SNIFF_VIEW ) {
102
+ if (i2ctools -> sniffer -> row_index > 0 ) {
103
+ i2ctools -> sniffer -> row_index -- ;
104
+ }
105
+ } else if (i2ctools -> main_view -> current_view == SEND_VIEW ) {
106
+ if (i2ctools -> sender -> value < 0xFF ) {
107
+ i2ctools -> sender -> value ++ ;
108
+ i2ctools -> sender -> sended = false;
109
+ }
170
110
}
171
111
}
172
-
173
- } else if (event .key == InputKeyOk && event .type == InputTypeRelease ) {
174
- if (i2ctools -> main_view -> current_view == MAIN_VIEW ) {
175
- i2ctools -> main_view -> current_view = i2ctools -> main_view -> menu_index ;
176
- } else if (i2ctools -> main_view -> current_view == SCAN_VIEW ) {
177
- scan_i2c_bus (i2ctools -> scanner );
178
- } else if (i2ctools -> main_view -> current_view == SEND_VIEW ) {
179
- i2ctools -> sender -> must_send = true;
180
- } else if (i2ctools -> main_view -> current_view == SNIFF_VIEW ) {
181
- if (i2ctools -> sniffer -> started ) {
182
- stop_interrupts ();
183
- i2ctools -> sniffer -> started = false;
184
- i2ctools -> sniffer -> state = I2C_BUS_FREE ;
185
- } else {
186
- start_interrupts (i2ctools -> sniffer );
187
- i2ctools -> sniffer -> started = true;
188
- i2ctools -> sniffer -> state = I2C_BUS_FREE ;
112
+ // Long Up
113
+ else if (
114
+ event .key == InputKeyUp &&
115
+ (event .type == InputTypeLong || event .type == InputTypeRepeat )) {
116
+ if (i2ctools -> main_view -> current_view == SCAN_VIEW ) {
117
+ if (i2ctools -> scanner -> menu_index > 5 ) {
118
+ i2ctools -> scanner -> menu_index -= 5 ;
119
+ }
120
+ } else if (i2ctools -> main_view -> current_view == SEND_VIEW ) {
121
+ if (i2ctools -> sender -> value < 0xF9 ) {
122
+ i2ctools -> sender -> value += 5 ;
123
+ i2ctools -> sender -> sended = false;
124
+ }
125
+ } else if (i2ctools -> main_view -> current_view == SNIFF_VIEW ) {
126
+ if (i2ctools -> sniffer -> row_index > 5 ) {
127
+ i2ctools -> sniffer -> row_index -= 5 ;
128
+ } else {
129
+ i2ctools -> sniffer -> row_index = 0 ;
130
+ }
189
131
}
190
132
}
191
- } else if (event .key == InputKeyRight && event .type == InputTypeRelease ) {
192
- if (i2ctools -> main_view -> current_view == SEND_VIEW ) {
193
- if (i2ctools -> sender -> address_idx < (i2ctools -> scanner -> nb_found - 1 )) {
194
- i2ctools -> sender -> address_idx ++ ;
195
- i2ctools -> sender -> sended = false;
196
- }
197
- } else if (i2ctools -> main_view -> current_view == SNIFF_VIEW ) {
198
- if (i2ctools -> sniffer -> menu_index < i2ctools -> sniffer -> frame_index ) {
199
- i2ctools -> sniffer -> menu_index ++ ;
200
- i2ctools -> sniffer -> row_index = 0 ;
133
+ // Down
134
+ else if (event .key == InputKeyDown && event .type == InputTypeRelease ) {
135
+ if (i2ctools -> main_view -> current_view == MAIN_VIEW ) {
136
+ if (i2ctools -> main_view -> menu_index < MENU_SIZE - 1 ) {
137
+ i2ctools -> main_view -> menu_index ++ ;
138
+ }
139
+ } else if (i2ctools -> main_view -> current_view == SCAN_VIEW ) {
140
+ if (i2ctools -> scanner -> menu_index < ((int )i2ctools -> scanner -> nb_found / 3 )) {
141
+ i2ctools -> scanner -> menu_index ++ ;
142
+ }
143
+ } else if (i2ctools -> main_view -> current_view == SNIFF_VIEW ) {
144
+ if ((i2ctools -> sniffer -> row_index + 3 ) <
145
+ (int )i2ctools -> sniffer -> frames [i2ctools -> sniffer -> menu_index ].data_index ) {
146
+ i2ctools -> sniffer -> row_index ++ ;
147
+ }
148
+ } else if (i2ctools -> main_view -> current_view == SEND_VIEW ) {
149
+ if (i2ctools -> sender -> value > 0x00 ) {
150
+ i2ctools -> sender -> value -- ;
151
+ i2ctools -> sender -> sended = false;
152
+ }
201
153
}
202
154
}
203
- } else if (event .key == InputKeyLeft && event .type == InputTypeRelease ) {
204
- if (i2ctools -> main_view -> current_view == SEND_VIEW ) {
205
- if (i2ctools -> sender -> address_idx > 0 ) {
206
- i2ctools -> sender -> address_idx -- ;
207
- i2ctools -> sender -> sended = false;
208
- }
209
- } else if (i2ctools -> main_view -> current_view == SNIFF_VIEW ) {
210
- if (i2ctools -> sniffer -> menu_index > 0 ) {
211
- i2ctools -> sniffer -> menu_index -- ;
212
- i2ctools -> sniffer -> row_index = 0 ;
155
+ // Long Down
156
+ else if (
157
+ event .key == InputKeyDown &&
158
+ (event .type == InputTypeLong || event .type == InputTypeRepeat )) {
159
+ if (i2ctools -> main_view -> current_view == SEND_VIEW ) {
160
+ if (i2ctools -> sender -> value > 0x05 ) {
161
+ i2ctools -> sender -> value -= 5 ;
162
+ i2ctools -> sender -> sended = false;
163
+ } else {
164
+ i2ctools -> sender -> value = 0 ;
165
+ i2ctools -> sender -> sended = false;
166
+ }
167
+ } else if (i2ctools -> main_view -> current_view == SNIFF_VIEW ) {
168
+ if ((i2ctools -> sniffer -> row_index + 8 ) <
169
+ (int )i2ctools -> sniffer -> frames [i2ctools -> sniffer -> menu_index ].data_index ) {
170
+ i2ctools -> sniffer -> row_index += 5 ;
171
+ }
172
+ }
173
+
174
+ } else if (event .key == InputKeyOk && event .type == InputTypeRelease ) {
175
+ if (i2ctools -> main_view -> current_view == MAIN_VIEW ) {
176
+ i2ctools -> main_view -> current_view = i2ctools -> main_view -> menu_index ;
177
+ } else if (i2ctools -> main_view -> current_view == SCAN_VIEW ) {
178
+ scan_i2c_bus (i2ctools -> scanner );
179
+ } else if (i2ctools -> main_view -> current_view == SEND_VIEW ) {
180
+ i2ctools -> sender -> must_send = true;
181
+ } else if (i2ctools -> main_view -> current_view == SNIFF_VIEW ) {
182
+ if (i2ctools -> sniffer -> started ) {
183
+ stop_interrupts ();
184
+ i2ctools -> sniffer -> started = false;
185
+ i2ctools -> sniffer -> state = I2C_BUS_FREE ;
186
+ } else {
187
+ start_interrupts (i2ctools -> sniffer );
188
+ i2ctools -> sniffer -> started = true;
189
+ i2ctools -> sniffer -> state = I2C_BUS_FREE ;
190
+ }
191
+ }
192
+ } else if (event .key == InputKeyRight && event .type == InputTypeRelease ) {
193
+ if (i2ctools -> main_view -> current_view == SEND_VIEW ) {
194
+ if (i2ctools -> sender -> address_idx < (i2ctools -> scanner -> nb_found - 1 )) {
195
+ i2ctools -> sender -> address_idx ++ ;
196
+ i2ctools -> sender -> sended = false;
197
+ }
198
+ } else if (i2ctools -> main_view -> current_view == SNIFF_VIEW ) {
199
+ if (i2ctools -> sniffer -> menu_index < i2ctools -> sniffer -> frame_index ) {
200
+ i2ctools -> sniffer -> menu_index ++ ;
201
+ i2ctools -> sniffer -> row_index = 0 ;
202
+ }
203
+ }
204
+ } else if (event .key == InputKeyLeft && event .type == InputTypeRelease ) {
205
+ if (i2ctools -> main_view -> current_view == SEND_VIEW ) {
206
+ if (i2ctools -> sender -> address_idx > 0 ) {
207
+ i2ctools -> sender -> address_idx -- ;
208
+ i2ctools -> sender -> sended = false;
209
+ }
210
+ } else if (i2ctools -> main_view -> current_view == SNIFF_VIEW ) {
211
+ if (i2ctools -> sniffer -> menu_index > 0 ) {
212
+ i2ctools -> sniffer -> menu_index -- ;
213
+ i2ctools -> sniffer -> row_index = 0 ;
214
+ }
213
215
}
214
216
}
215
217
}
0 commit comments