- expires = now() + config.credit_value;
- } else { //expiry already set, simply extend by time
- expires += config.credit_value;
+ printf("Nice! I just added %d to your time.\n", config.credit_value);
+
+ //Increment timer
+ if(expires == -1) //Initial credit, set the expiry to now plus time
+ {
+ expires = now() + config.credit_value;
+ } else { //expiry already set, simply extend by time
+ expires += config.credit_value;
+ }
+
+ //wait for button to be released
+ while(digitalRead(COIN_BUTTON) == LOW)
+ {
+ //I don't see this happening, but in principle if the button is held down
+ //It would be possible to stop the switch happening after time runs out
+ //So we must check for that here.
+ if(time_over())
+ break;
+
+ delay(10);
+ }