#include <stdio.h>
#include <wiringPi.h>
#include <time.h>
+#include "config.h"
#define COIN_BUTTON 7
-#define CREDIT_EXTENSION 10
+configuration config;
int expires = -1;
int one_second_ago = 0;
{
if(digitalRead(COIN_BUTTON) == LOW)
{
- printf("Nice! I just added %d to your time.\n", CREDIT_EXTENSION);
+ 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() + CREDIT_EXTENSION;
+ expires = now() + config.credit_value;
} else { //expiry already set, simply extend by time
- expires += CREDIT_EXTENSION;
+ expires += config.credit_value;
}
//wait for button to be released
int main (void)
{
+ init_config(&config);
init_gpio();
+
printf ("Short pin 7 and 9 to increment timer.\n") ;
while(1)