very preliminary code, pins clearly havent been chosen yet!

Dependencies:   TextLCD mbed

Revision:
0:438bb4b2ba51
Child:
1:0404e9aa397f
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/readknobs.cpp	Tue Jul 02 09:16:17 2013 +0000
@@ -0,0 +1,54 @@
+#include "mbed.h"
+#include "TextLCD.h"
+#include "readknobs.h"
+
+extern int tempo;
+extern int swing;
+extern int mintempo;
+extern int maxtempo;
+int k;
+
+
+TextLCD lcd(PTA1, PTA2, PTA4, PTA5, PTC8, PTC9, TextLCD::LCD20x4); // rs, e, d4-d7
+
+
+void readknobs()
+{
+
+// SWING CALCULATION
+
+int a = sw.read() * 10;
+
+    switch (a)
+    {
+    case 0: swing = -150;
+    case 1: swing = -150;
+    case 2: swing = -100;
+    case 3: swing = -60;
+    case 4:
+    case 5:
+    case 6: swing = 0;
+    case 7: swing = 60;
+    case 8: swing = 100;
+    case 9: swing = 100;
+    case 10: swing = 150;
+    }
+    
+// TEMPO CALCULATION
+
+    tempo = mintempo + (maxtempo-mintempo)*tmp.read_u16() / 65535;
+    
+    tempo = (doubletime) ? 2*tempo : tempo;
+    
+// DISPLAY INFO
+char signature = (k==1) ? 3/4 : 4/4;
+char percentage = 37;
+
+lcd.cls();
+lcd.locate(0,0);
+lcd.printf("%d bpm", tempo);
+lcd.locate(1,0);
+lcd.printf("Swing: %d %c", swing, percentage);
+lcd.locate(2,0);
+lcd.printf("TimeSig: %s", signature);
+}
\ No newline at end of file