FRDM-KL46Z pinmap is different from KL25Z
Dependencies: MAG3110 MMA8451Q TSI SLCD mbed-src
Diff: main.cpp
- Revision:
- 1:96fe777bad5a
- Parent:
- 0:52fadadad843
- Child:
- 2:e3770fac7512
diff -r 52fadadad843 -r 96fe777bad5a main.cpp --- a/main.cpp Mon Oct 14 14:57:22 2013 +0000 +++ b/main.cpp Fri Feb 07 14:24:49 2014 +0000 @@ -1,59 +1,55 @@ -//KL46Z try out #include "mbed.h" #include "TSISensor.h" #include "MMA8451Q.h" #include "MAG3110.h" +#include "vfnLCD.h" #include <cstdlib> #include <iostream> Serial pc(USBTX, USBRX); TSISensor tsi; -MMA8451Q acc51(PTE25, PTE24, 0x1D<<1); +MMA8451Q acc(PTE25, PTE24, 0x1D<<1); MAG3110 mag(PTE25, PTE24, 0x0E<<1); +vfnLCD lcd; PwmOut rled(PTE29); PwmOut gled(PTD5); AnalogIn lightSensor(PTE22); -DigitalIn SW1(PTC3); -DigitalIn SW3(PTC12); -//AnalogOut lcd03(PTB23); -//PwmOut lcd07(PTB7); +DigitalIn s1(PTC3); +DigitalIn s3(PTC12); int main() { using namespace std; - - float onTime = 1.0; - float offTime = 0.0; + + // float onTime = 1.0; + // float offTime = 0.0; float holdTime = 1.0; - bool on = true; - bool off = false; int magX = 0, magY = 0, magZ = 0; - //lcd03.write(0.33); - //lcd07.write(0.25); - //lcd07.period_ms(10); - - while(true) { - - rled = onTime - abs(acc51.getAccX()); - gled = onTime - abs(acc51.getAccY()); + + + while(1) { + + rled = abs(acc.getAccX()); + //gled = abs(acc.getAccY()); mag.getValues(&magX, &magY, &magZ); - - cout << "MMA8451: " << acc51.getAccX() << "\t" << acc51.getAccY() << "\t" << acc51.getAccZ() << "\n\r" << endl; + lcd.vfnLCD_All_Segments_ON(); + + cout << "MMA8451: " << acc.getAccX() << "\t" << acc.getAccY() << "\t" << acc.getAccZ() << "\n\r" << endl; cout << "MAG3110: " << magX << "\t" << magY << "\t" << magZ << "\n\r" << endl; cout << "MAG3110: " << mag.getHeading() << "\n\r" << endl; wait(holdTime); - + rled = tsi.readPercentage(); gled = tsi.readPercentage(); - + lcd.vfnLCD_All_Segments_OFF(); + cout << "Touch: " << tsi.readPercentage() << "\n\r" << endl; - cout << "SW1: " << SW1 << "\n\r" << endl; - cout << "SW3: " << SW3 << "\n\r" << endl; + cout << "SW1: " << s1 << "\n\r" << endl; + cout << "SW3: " << s3 << "\n\r" << endl; cout << "Light Sensor: " << lightSensor << "\n\r" << endl; wait(holdTime); } - return 0; }