![](/media/cache/profiles/004acbc8eefec9fe0629b15f52b94bcf.50x50_q85.jpg)
very preliminary code, pins clearly havent been chosen yet!
Diff: readknobs.cpp
- Revision:
- 1:0404e9aa397f
- Parent:
- 0:438bb4b2ba51
--- a/readknobs.cpp Tue Jul 02 09:16:17 2013 +0000 +++ b/readknobs.cpp Tue Jul 02 17:50:52 2013 +0000 @@ -2,32 +2,28 @@ #include "TextLCD.h" #include "readknobs.h" +//Declare necessary variables 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() +void readknobs() //Function Definition { // SWING CALCULATION -int a = sw.read() * 10; +int a = sw.read() * 10; //Make the analog read an integer from 0-10 - switch (a) + switch (a) //Segmented solution to each case { 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 4: // + case 5: // Note, plenty of 0 swing to prevent accidental swing + case 6: swing = 0; // case 7: swing = 60; case 8: swing = 100; case 9: swing = 100; @@ -36,12 +32,21 @@ // TEMPO CALCULATION - tempo = mintempo + (maxtempo-mintempo)*tmp.read_u16() / 65535; + tempo = mintempo + (maxtempo-mintempo)*tmp.read_u16() / 65535; //Tempo as the analog read percentage multiplied by tempo range - tempo = (doubletime) ? 2*tempo : tempo; + tempo = (doubletime) ? 2*tempo : tempo; //Double the tempo if doubletime==1 // DISPLAY INFO -char signature = (k==1) ? 3/4 : 4/4; +char signature[]="x/4"; +if (threetime==0) +{ +signature[0]= '4'; +} +else +{ +signature[0]= '3'; +} + char percentage = 37; lcd.cls();