//* left/right/on/off Menu Functionality for the Homework Problem *

#define MAX_LED (4) // This variable needs to be declared in a .C file // as they are altered here and at the same time are used by the LED flushing function static uint8_t LED_mode[MAX_LED] = {0, 1, 0, 0}; /* modes (all at the same time period): 3 - continuously on 2 - long blinks 1 - short blinks 0 - continuously off */ // This variable can be declared within the button scanning function static uint8_t LED_current = 1; ... if ( _key_off_pressed_detected_ ) { LED_modes[LED_current] = 1; } ... if ( _key_on_pressed_detected_ ) { LED_modes[LED_current] = 2; } ... if ( _key_left_pressed_detected_ ) { if ( LED_current<MAX_LED) { if (2==LED_modes[LED_current]) LED_modes[LED_current] = 3; else /* 1==LED... */ LED_modes[LED_current] = 0; ++LED_current; if (3==LED_modes[LED_current]) LED_modes[LED_current] = 2; else /* 0==LED... */ LED_modes[LED_current] = 1; } } ... if ( _key_right_pressed_detected_ ) {\ if ( LED_current>0) { if (2==LED_modes[LED_current]) LED_modes[LED_current] = 3; else /* 1==LED... */ LED_modes[LED_current] = 0; --LED_current; if (3==LED_modes[LED_current]) LED_modes[LED_current] = 2; else /* 0==LED... */ LED_modes[LED_current] = 1; } } ...