MCPcopy Create free account
hub / github.com/BruceDevices/firmware / handleSettingChange

Function handleSettingChange

src/modules/ir/ir_jammer.cpp:281–320  ·  view source on GitHub ↗

* Process changes to setting values based on Next/Prev button presses * * @param state Current jammer state to be updated * @param nextPressed Whether the Next button was pressed * @param prevPressed Whether the Previous button was pressed */

Source from the content-addressed store, hash-verified

279 * @param prevPressed Whether the Previous button was pressed
280 */
281void handleSettingChange(JammerState &state, bool nextPressed, bool prevPressed) {
282 // Exit if neither button is pressed
283 if (!nextPressed && !prevPressed) return;
284
285 // Determine adjustment direction based on which button was pressed
286 int adjustment = nextPressed ? 1 : -1;
287
288 // Handle changes based on which setting is currently selected
289 switch (state.settingIndex) {
290 case 0: // Status (active/paused)
291 state.jamming_active = !state.jamming_active;
292 if (state.jamming_active) {
293 // Reset statistics when starting a new jamming session
294 state.startTime = millis();
295 state.jamCount = 0;
296 }
297 break;
298
299 case 1: // Frequency selection
300 // Cycle through available frequencies with wrap-around
301 state.current_freq_idx = (state.current_freq_idx + adjustment + NUM_FREQS) % NUM_FREQS;
302 break;
303
304 case 2: // Jamming mode selection
305 // Cycle through available modes with wrap-around
306 state.currentMode = (JamMode)((state.currentMode + adjustment + 5) % 5);
307 // Update available settings based on new mode
308 updateMaxSettings(state);
309 updatePatterns(state);
310 break;
311
312 // Mode-specific settings (handled by the helper function)
313 default: adjustModeSpecificSetting(state, state.settingIndex, adjustment); break;
314 }
315
316 // Mark UI for redrawing and update pattern arrays
317 state.redraw = true;
318 updatePatterns(state);
319 delay(100); // Prevent too rapid changes when button is held
320}
321
322/**
323 * Update pattern arrays based on current timing settings

Callers 1

handleJammerInputFunction · 0.85

Calls 4

millisFunction · 0.85
updateMaxSettingsFunction · 0.85
updatePatternsFunction · 0.85

Tested by

no test coverage detected