very preliminary code, pins clearly havent been chosen yet!

Dependencies:   TextLCD mbed

readknobs.cpp

Committer:
gcme93
Date:
2013-07-02
Revision:
0:438bb4b2ba51
Child:
1:0404e9aa397f

File content as of revision 0:438bb4b2ba51:

#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);
}