Text config file support
[hdmi-switcher.git] / main.c
diff --git a/main.c b/main.c
index 06d1713..9227a5a 100644 (file)
--- a/main.c
+++ b/main.c
@@ -1,9 +1,10 @@
 #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;
 
@@ -41,14 +42,14 @@ int read_button()
 {
   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
@@ -71,7 +72,9 @@ int read_button()
 
 int main (void)
 {
+  init_config(&config);
   init_gpio();
+
   printf ("Short pin 7 and 9 to increment timer.\n") ;
 
   while(1)