104 lines
2.9 KiB
C++

//======================================================
// MAIN PROGRAM LOOP
//======================================================
/* game selector is the main function that tell the game groutine
* which game to be JSONed and at what parameters
*/
void bluetooth_game_selector(String game, String settings)
{
// Kick Counter Game
if(game == "ct") {
terminal(GM_COUNTER);
game_counter_bluetooth(settings);
return;
}
// Time Attack Game
else if(game == "ta") {
terminal(GM_TATTACK);
time_attack_bluetooth(settings);
return;
}
// Time Attack Game
else if(game == "ra") {
terminal(GM_REACTION);
game_reaction_bluetooth(settings);
return;
}
// Unknown Game
else {
dualcomm(UNKNOWN_GAME);
return;
}
}
//======================================================
// GAME SELECTOR CODE
//======================================================
// SELECTOR ROUTINE
//------------------------------------------------------
void standalone_game_selector()
{
// Check Bluetooth
if(isBluetooth)
{
// Reading The Message From Bluetooth
String message = Bluetooth.readStringUntil('\n');
// Cleaning Bluetooth Receive Buffer
flushBluetooth;
// Cleaning The Message
message.trim();
// Cleaning JSON Document
JSON.clear();
}
}
//------------------------------------------------------
// DISPLAY MENU TITLE FUNCTION
//------------------------------------------------------
void GAME_TITLE_DISPLAY(uint8_t Number, String Title)
{
// Starting The First Code
OLED_CLEAR();
drawTextCenter(128/2, 5, 1, "MODE " + String(Number + 1));
drawTextCenter(128/2, 22, 2, " - " + Title + " - ");
drawTextCenter(128/2, 43, 1, "<< SELECT >>");
OLED_SHOW();
DISPLAY_CHANGED = true;
}
//------------------------------------------------------
// OLED DISPLAY - GAME COUNTER
//------------------------------------------------------
void GAME_COUNTER_DISPLAY(uint16_t count)
{
OLED_CLEAR();
drawTextCenter(128/2, 0, 2, "KICKS");
drawTextCenter(128/2, 20, 3, String(count));
drawTextCenter(128/2, 50, 1, "<< EXIT >>");
OLED_SHOW();
}
//------------------------------------------------------
// OLED DISPLAY - GAME TIMEATTACK
//------------------------------------------------------
void GAME_TIMEATTACK_DISPLAY(uint16_t count)
{
OLED_CLEAR();
drawTextCenter(128/2, 0, 2, "KICKS");
drawTextCenter(128/2, 20, 3, String(count));
drawTextCenter(128/2, 50, 1, "<< EXIT >>");
OLED_SHOW();
}
//------------------------------------------------------
// OLED DISPLAY - GAME REACTION
//------------------------------------------------------
void GAME_REACTION_DISPLAY(uint16_t count)
{
OLED_CLEAR();
drawTextCenter(128/2, 0, 2, "KICKS");
drawTextCenter(128/2, 20, 3, String(count));
drawTextCenter(128/2, 50, 1, "<< EXIT >>");
OLED_SHOW();
}