void readKeys() { lcd.setCursor(0, 0); int lcd_key = read_LCD_buttons(); // read the buttons switch (lcd_key) // depending on which button was pushed, we perform an action { case btnRIGHT: { lcd.setCursor(0, 0); lcd.print("RIGHT "); lcd.setCursor(0, 1); lcd.print(" "); break; } case btnLEFT: { lcd.setCursor(0, 0); lcd.print("LEFT "); lcd.setCursor(0, 1); lcd.print(" "); break; } case btnUP: { lcd.setCursor(0, 0); lcd.print("UP "); lcd.setCursor(0, 1); lcd.print(" "); break; } case btnDOWN: { lcd.setCursor(0, 0); lcd.print("DOWN "); lcd.setCursor(0, 1); lcd.print(" "); break; } case btnSELECT: { lcd.setCursor(0, 0); lcd.print("IP Address: "); lcd.setCursor(0, 1); lcd.print(WiFi.localIP()); break; } case btnNONE: { lcd.setCursor(0, 0); lcd.print("Uptime: "); lcd.setCursor(0, 1); lcd.print(millis() / 1000 / 60); lcd.print(":"); lcd.print(millis() / 1000 % 60); lcd.print(" "); break; } } }
//*************************************************** //*************************************************** void LCD_service::lcd_service_latch() { // update the button states read_LCD_buttons(); // process any local LCD message packets process_local_TUN_packet(); // process any external LCD message packets process_external_TUN_packet(); }
void loop(){ if(gameFinished == false){ float time_to = random(1,2); //.. Aantal milliseconde om mee te beginnen int i; float current_multiplier = 0.98; float cashedOutMultiplier; int randomNumber = random(0,1000); if(randomNumber < 201){ randomNumber = 0; } for(i = 0; i <= randomNumber; i++){ switch (lcd_key){ case btnSELECT:{ cashedOut = true; cashedOutMultiplier = current_multiplier; break; }} lcd.clear(); lcd.print("BustaDuino"); // print a simple message on the LCD lcd.setCursor(0, 1); if(randomNumber > 0){ current_multiplier = current_multiplier + 0.01; }else{ current_multiplier = 0; } lcd.print(String(current_multiplier) + "x"); Serial.print(String(current_multiplier) + "x"); lcd_key = read_LCD_buttons(); // read the buttons if(i <= randomNumber && cashedOut == true){ lcd.clear(); lcd.print("You Win!"); lcd.setCursor(0, 1); lcd.print(String(cashedOutMultiplier) + "x"); Serial.print(String(cashedOutMultiplier) + "x"); gameFinished = true; break; }else if(i >= randomNumber && cashedOut == false){ lcd.clear(); lcd.print("BUSTED!"); lcd.setCursor(0, 1); lcd.print(String(current_multiplier) + "x"); Serial.print(String(current_multiplier) + "x"); gameFinished = true; } delay((time_to/i) * 3000); } } }
void loop() { lcd.setCursor(9,1); // move cursor to second line "1" and 9 spaces over lcd.print(millis()/1000); // display seconds elapsed since power-up lcd.setCursor(0,1); // move to the begining of the second line lcd_key = read_LCD_buttons(); // read the buttons switch (lcd_key) // depending on which button was pushed, we perform an action { case btnRIGHT: { lcd.print("RIGHT "); break; } case btnLEFT: { lcd.print("LEFT "); break; } case btnUP: { lcd.print("UP "); break; } case btnDOWN: { lcd.print("DOWN "); break; } case btnSELECT: { lcd.print("SELECT"); break; } case btnNONE: { lcd.print("NONE "); break; } } }
void loop() { lcd.print("Minutes: "); lcd.setCursor(0,1); lcd.blink(); while (selectmin == true) { lcd_key = read_LCD_buttons(); switch (lcd_key) { case btnRIGHT: break; case btnLEFT: break; case btnUP: { minutes = minutes + 1; lcd.setCursor(0,1); lcd.print(minutes); break; } case btnDOWN: { if (minutes > 0) { minutes = minutes - 1; lcd.setCursor(0,1); lcd.print(minutes); } break; } case btnSELECT: { selectmin = false; break; } case btnNONE: break; } delay(200); } lcd.clear(); delay(500); lcd.print("Seconds: "); lcd.setCursor(0,1); lcd.blink(); while (selectsec == true) { lcd_key = read_LCD_buttons(); switch (lcd_key) { case btnRIGHT: break; case btnLEFT: break; case btnUP: { if (seconds == 59) { seconds = 0; } else { seconds = seconds + 1; } lcd.setCursor(0,1); lcd.print(seconds); break; } case btnDOWN: { if (seconds > 0) { seconds = seconds - 1; } else if (seconds == 0) { seconds = 59; } lcd.setCursor(0,1); lcd.print(seconds); } break; } case btnSELECT: { selectsec = false; break; } case btnNONE: break; } }