void fsm_right_button(){ switch (g_state) { case STATE_MENU: if(menu_next()){ play_melody(MENU_SOUND); } _delay_ms(50); if(menu_get_index() == 0){ if(menu_get_arrow_position == 2){ oled_print_pong(); } else if(menu_get_arrow_position() == 3){ oled_print_game_over(); } } else if(menu_get_index() == 4){ g_state = STATE_CALIBRATE; } else if(menu_get_index() == 6){ g_state = STATE_DEBUG; } else if(menu_get_index() == 7){ g_game_melody = menu_get_arrow_position(); play_melody(g_game_melody); } else if(menu_get_index() == 2){ new_game(JOYSTICK); } else if(menu_get_index() == 3){ new_game(PLAYSTATION); } break; case STATE_GAME: // Send pulse to solenoid set_bit(DDRD, PD4); _delay_ms(200); clear_bit(DDRD,PD4); break; case STATE_GAME_OVER: break; case STATE_CALIBRATE: joy_calibrate(); break; case STATE_DEBUG: if(menu_get_arrow_position() == 1){ send_state(STATE_DEBUG); printf("Debug Mode\n"); } break; case STATE_PID: break; default: break; } }
void menu_prev(void) { currentPointer = currentPointer->prev; if (menu_index) { menu_index--; if (lcd_row_pos > 0) lcd_row_pos--; } else { menu_index = menu_get_index(currentPointer); if (menu_index >= LCD_ROWS - 1) lcd_row_pos = LCD_ROWS - 1; else lcd_row_pos = menu_index; } menu_refresh(); }
void fsm_joy_right(){ switch (g_state) { case STATE_MENU: if(menu_next()){ play_melody(MENU_SOUND); } if(menu_get_index() == 0){ if(menu_get_arrow_position == 2){ oled_print_pong(); } else if(menu_get_arrow_position() == 3){ oled_print_game_over(); } } else if(menu_get_index() == 4){ g_state = STATE_CALIBRATE; } else if(menu_get_index() == 6){ g_state = STATE_DEBUG; } else if(menu_get_index() == 7){ g_game_melody = menu_get_arrow_position(); play_melody(g_game_melody); } else if(menu_get_index() == 2){ new_game(JOYSTICK); } else if(menu_get_index() == 3){ new_game(PLAYSTATION); } break; case STATE_GAME: break; case STATE_GAME_OVER: break; case STATE_CALIBRATE: break; case STATE_DEBUG: if(menu_get_arrow_position() == 1){ send_state(STATE_DEBUG); printf("Debug Mode\n"); } break; case STATE_PID: break; default: break; } }
void menu_back(void) { if (currentPointer->parent) { switch (menu_get_level(currentPointer)) { case 1: lcd_row_pos = lcd_row_pos_level_1; break; case 2: lcd_row_pos = lcd_row_pos_level_2; break; } currentPointer = currentPointer->parent; menu_index = menu_get_index(currentPointer); menu_refresh(); } }