Test program using the LCD and touch pad to adjust the Analog output DAC on the KL46Z Port PTE30
Fork of keyer_test_v3 by
Diff: analgoutv1.cpp
- Revision:
- 2:86fa1f84db36
- Child:
- 3:dd70474b11bc
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/analgoutv1.cpp Tue Feb 10 21:15:22 2015 +0000 @@ -0,0 +1,74 @@ +#include "mbed.h" +#include "SLCD.h" +#include "TSISensor.h" + +//Code parameters + +#define LCDLEN 10 +//LCD messages +#define VOLTAST 0 +#define VOLTMESS "V:" +#define DATARATE 0.1 // sec +#define MAXVOLTS 3.3 +#define FUTURESTATE 1 + +SLCD slcd; //define LCD display + +//Global classes +TSISensor tsiScaling; // Capacitive sensor/slider +AnalogOut refOut(PTE30); +PwmOut led(LED_RED); + +// Global scalars +char lcdData[LCDLEN]; + + + + +void LCDMessNoDwell(char *lMess){ + slcd.Home(); + slcd.clear(); + slcd.printf(lMess); +} + + + +void parameterAdjust( int adjState, float scaling) { // small adjustment state machine + float tempFloat; + switch (adjState){ + case VOLTAST: { + tempFloat = scaling; + refOut.write(tempFloat); + sprintf (lcdData,"%4.3f",tempFloat*MAXVOLTS); + break; + } + case FUTURESTATE: { + /*toneFreq = TONEMIN + scaling * TONEINT; + tonePeriod = 1.0/toneFreq; + soundOut.period(tonePeriod); + tempInt = (int)toneFreq; + sprintf (lcdData,"%4d",tempInt); + */ + break; + } + } + LCDMessNoDwell(lcdData); + return; +} + +int main(){ + + float tempValue; + + parameterAdjust( VOLTAST, 0.0); + + + while (true) { + tempValue = tsiScaling.readPercentage(); + if(tempValue > 0) { + parameterAdjust( VOLTAST, tempValue); + } + + wait(DATARATE); + } // while forever +}// end main \ No newline at end of file