Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of kl46z_slider_v1 by
Revision 1:c3cfa0fd8ad7, committed 2016-09-14
- Comitter:
- eseifert
- Date:
- Wed Sep 14 14:29:22 2016 +0000
- Parent:
- 0:04499bc54bee
- Commit message:
- Modified slider program for SSD541. Wait removed, replaced with WaitTimer.
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Fri Sep 09 17:51:13 2016 +0000
+++ b/main.cpp Wed Sep 14 14:29:22 2016 +0000
@@ -3,7 +3,7 @@
#include "SLCD.h"
#define TSILIMIT 0.99
#define LCDCHARLEN 10
-#define DATAINTERVAL 0.1
+#define DATAINTERVAL 0.01
#define PROGNAME "kl46z_slider_test_v1\n\r"
SLCD slcd; //define LCD display
@@ -11,31 +11,40 @@
float tsidata;
-void LCDMess(char *lMess){
- slcd.Home();
- slcd.clear();
- slcd.printf(lMess);
+void LCDMess(char *lMess)
+{
+ slcd.Home();
+ slcd.clear();
+ slcd.printf(lMess);
}
-int main(void) {
+Timer WaitTimer;
+
+int main(void)
+{
char lcdData[LCDCHARLEN];
PwmOut gled(LED_GREEN);
PwmOut rled(LED_RED);
pc.printf(PROGNAME);
TSISensor tsi;
+ WaitTimer.start();
+ WaitTimer.reset();
- while (true) {
+ while (true) {
+ WaitTimer.start();
tsidata = tsi.readPercentage();
- if (tsidata > TSILIMIT){
+ if (tsidata > TSILIMIT) {
gled = 0.0;
rled = 0.0;
- }else {
- pc.printf("\n Position %f\n\r", tsidata);
- sprintf (lcdData,"%0.4f",tsidata);
- LCDMess(lcdData);
- gled = tsidata;
- rled = 1.0 - tsidata;
+ } else {
+ if(WaitTimer > DATAINTERVAL){
+ pc.printf("\n Position %f\n\r", tsidata);
+ sprintf (lcdData,"%0.4f",tsidata);
+ LCDMess(lcdData);
+ gled = tsidata;
+ rled = 1.0 - tsidata;
+ WaitTimer.reset();
+ }
}
- wait(DATAINTERVAL);
}
}
\ No newline at end of file
