I was not able to print without a colon. I tried to use the class info on Colon() class and set up a boolean to turn off the colon. I couldn't get it print.
Fork of kl46z_btn_slider_toSerial by
main.cpp@8:018b01e6b807, 2017-01-22 (annotated)
- Committer:
- menchacaeli
- Date:
- Sun Jan 22 23:37:06 2017 +0000
- Revision:
- 8:018b01e6b807
- Parent:
- 7:8f64ad5334ca
Attempted to make the program print with no colon. I used the classes information Colon() to print without a colon.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
scohennm | 0:e23fffd4b9a7 | 1 | #include "mbed.h" |
scohennm | 6:a109f45fae66 | 2 | #include "SLCD.h" |
scohennm | 6:a109f45fae66 | 3 | #include "TSISensor.h" |
scohennm | 6:a109f45fae66 | 4 | |
scohennm | 2:b49e5adf84df | 5 | |
scohennm | 0:e23fffd4b9a7 | 6 | #define LEDON false |
scohennm | 0:e23fffd4b9a7 | 7 | #define LEDOFF true |
scohennm | 1:2688f68df85d | 8 | #define NUMBUTS 2 |
scohennm | 6:a109f45fae66 | 9 | #define RBUTINDEX 0 |
scohennm | 6:a109f45fae66 | 10 | #define LBUTINDEX 1 |
scohennm | 3:7e9670be412e | 11 | #define LBUT PTC12 // port addresses for buttons |
scohennm | 1:2688f68df85d | 12 | #define RBUT PTC3 |
sim1sgl | 7:8f64ad5334ca | 13 | #define DATATIME 200 //milliseconds |
scohennm | 6:a109f45fae66 | 14 | #define LCDLEN 10 |
sim1sgl | 7:8f64ad5334ca | 15 | #define PROGNAME "kl46z_btn_slider_toSerial\r\n" |
menchacaeli | 8:018b01e6b807 | 16 | #define COLOFF 0 // setting boolean to turn off colon |
menchacaeli | 8:018b01e6b807 | 17 | #define COLON 1 // setting boolean to turn on colon |
scohennm | 3:7e9670be412e | 18 | |
scohennm | 6:a109f45fae66 | 19 | // Cap slider interface |
scohennm | 6:a109f45fae66 | 20 | SLCD slcd; //define LCD display |
scohennm | 6:a109f45fae66 | 21 | |
scohennm | 6:a109f45fae66 | 22 | TSISensor tsiScaling; // Capacitive sensor/slider |
scohennm | 6:a109f45fae66 | 23 | Timer dataTimer; |
scohennm | 0:e23fffd4b9a7 | 24 | |
scohennm | 6:a109f45fae66 | 25 | // Button interrrupts |
sim1sgl | 7:8f64ad5334ca | 26 | InterruptIn rtButton(RBUT); |
scohennm | 6:a109f45fae66 | 27 | InterruptIn lfButton(LBUT); |
scohennm | 3:7e9670be412e | 28 | |
menchacaeli | 8:018b01e6b807 | 29 | //char lcdData[LCDLEN]; |
menchacaeli | 8:018b01e6b807 | 30 | |
menchacaeli | 8:018b01e6b807 | 31 | char noColData[LCDLEN]; |
scohennm | 6:a109f45fae66 | 32 | |
sim1sgl | 7:8f64ad5334ca | 33 | Serial pc(USBTX, USBRX);// set up USB as communications to Host PC via USB connectons |
scohennm | 3:7e9670be412e | 34 | |
scohennm | 6:a109f45fae66 | 35 | // Interrupt service routines |
scohennm | 6:a109f45fae66 | 36 | void rtButtonPressed(){ |
sim1sgl | 7:8f64ad5334ca | 37 | pc.printf("button: right\r\n"); |
scohennm | 6:a109f45fae66 | 38 | } |
scohennm | 6:a109f45fae66 | 39 | |
scohennm | 6:a109f45fae66 | 40 | void lfButtonPressed(){ |
sim1sgl | 7:8f64ad5334ca | 41 | pc.printf("button: left \r\n"); |
scohennm | 6:a109f45fae66 | 42 | } |
scohennm | 6:a109f45fae66 | 43 | |
scohennm | 6:a109f45fae66 | 44 | // End interrupt routines |
scohennm | 6:a109f45fae66 | 45 | |
scohennm | 6:a109f45fae66 | 46 | // Regular routines |
scohennm | 6:a109f45fae66 | 47 | void LCDMessNoDwell(char *lMess){ |
scohennm | 6:a109f45fae66 | 48 | slcd.Home(); |
scohennm | 6:a109f45fae66 | 49 | slcd.clear(); |
menchacaeli | 8:018b01e6b807 | 50 | //using line below to turn off or on colon |
menchacaeli | 8:018b01e6b807 | 51 | slcd.Colon(COLOFF); |
scohennm | 6:a109f45fae66 | 52 | slcd.printf(lMess); |
scohennm | 6:a109f45fae66 | 53 | } |
scohennm | 6:a109f45fae66 | 54 | |
scohennm | 1:2688f68df85d | 55 | // -------------------------------- |
scohennm | 3:7e9670be412e | 56 | int main() { |
sim1sgl | 7:8f64ad5334ca | 57 | float sliderValue = 0.0; |
menchacaeli | 8:018b01e6b807 | 58 | //int sliderValue = 0; |
menchacaeli | 8:018b01e6b807 | 59 | |
sim1sgl | 7:8f64ad5334ca | 60 | pc.printf(PROGNAME); |
scohennm | 6:a109f45fae66 | 61 | dataTimer.start(); |
menchacaeli | 8:018b01e6b807 | 62 | dataTimer.reset(); |
menchacaeli | 8:018b01e6b807 | 63 | |
menchacaeli | 8:018b01e6b807 | 64 | //sprintf (lcdData,"%4.3f",0.0); |
menchacaeli | 8:018b01e6b807 | 65 | //LCDMessNoDwell(lcdData); |
menchacaeli | 8:018b01e6b807 | 66 | |
menchacaeli | 8:018b01e6b807 | 67 | sprintf (noColData,"%4.3f", 0.0); |
menchacaeli | 8:018b01e6b807 | 68 | LCDMessNoDwell(noColData); |
scohennm | 6:a109f45fae66 | 69 | |
scohennm | 6:a109f45fae66 | 70 | // Interrupt routine setups |
scohennm | 6:a109f45fae66 | 71 | rtButton.fall(&rtButtonPressed); |
scohennm | 6:a109f45fae66 | 72 | lfButton.fall(&lfButtonPressed); |
scohennm | 6:a109f45fae66 | 73 | |
scohennm | 3:7e9670be412e | 74 | // End of setup |
scohennm | 3:7e9670be412e | 75 | |
scohennm | 0:e23fffd4b9a7 | 76 | while(true) { |
sim1sgl | 7:8f64ad5334ca | 77 | // All the interrupts |
scohennm | 6:a109f45fae66 | 78 | |
scohennm | 6:a109f45fae66 | 79 | if (dataTimer.read_ms() > DATATIME){ |
sim1sgl | 7:8f64ad5334ca | 80 | // Read the slider value |
sim1sgl | 7:8f64ad5334ca | 81 | float newSliderValue = tsiScaling.readPercentage(); |
sim1sgl | 7:8f64ad5334ca | 82 | // Only do stuff with it if it's a new value or if it's not zero |
sim1sgl | 7:8f64ad5334ca | 83 | if(newSliderValue > 0.0 && newSliderValue != sliderValue) { |
sim1sgl | 7:8f64ad5334ca | 84 | sliderValue = newSliderValue; |
menchacaeli | 8:018b01e6b807 | 85 | //sprintf (lcdData,"%4.3f", sliderValue); // Just to make things user readable |
menchacaeli | 8:018b01e6b807 | 86 | sprintf (noColData, "%4.3f", sliderValue); |
sim1sgl | 7:8f64ad5334ca | 87 | |
menchacaeli | 8:018b01e6b807 | 88 | //LCDMessNoDwell(noColData); |
menchacaeli | 8:018b01e6b807 | 89 | LCDMessNoDwell(noColData); |
sim1sgl | 7:8f64ad5334ca | 90 | pc.printf("slider: %4.3f\r\n", sliderValue); |
scohennm | 6:a109f45fae66 | 91 | } |
scohennm | 6:a109f45fae66 | 92 | dataTimer.reset(); |
scohennm | 6:a109f45fae66 | 93 | } |
scohennm | 6:a109f45fae66 | 94 | |
scohennm | 0:e23fffd4b9a7 | 95 | } |
scohennm | 0:e23fffd4b9a7 | 96 | } |