SB_SSD341_5.1

Dependencies:   SLCD TSI mbed

Fork of kl46z_slider_v1 by Stanley Cohen

Committer:
sbart
Date:
Wed Sep 14 00:36:37 2016 +0000
Revision:
1:4f5a6fff2389
Parent:
0:04499bc54bee
SBART_SSD341_5.1

Who changed what in which revision?

UserRevisionLine numberNew contents of line
scohennm 0:04499bc54bee 1 #include "mbed.h"
scohennm 0:04499bc54bee 2 #include "TSISensor.h"
scohennm 0:04499bc54bee 3 #include "SLCD.h"
scohennm 0:04499bc54bee 4 #define TSILIMIT 0.99
scohennm 0:04499bc54bee 5 #define LCDCHARLEN 10
scohennm 0:04499bc54bee 6 #define DATAINTERVAL 0.1
scohennm 0:04499bc54bee 7 #define PROGNAME "kl46z_slider_test_v1\n\r"
scohennm 0:04499bc54bee 8
scohennm 0:04499bc54bee 9 SLCD slcd; //define LCD display
scohennm 0:04499bc54bee 10 Serial pc(USBTX, USBRX);
sbart 1:4f5a6fff2389 11 Timer SliderTimer;
scohennm 0:04499bc54bee 12
scohennm 0:04499bc54bee 13 float tsidata;
scohennm 0:04499bc54bee 14
scohennm 0:04499bc54bee 15 void LCDMess(char *lMess){
scohennm 0:04499bc54bee 16 slcd.Home();
scohennm 0:04499bc54bee 17 slcd.clear();
scohennm 0:04499bc54bee 18 slcd.printf(lMess);
scohennm 0:04499bc54bee 19 }
scohennm 0:04499bc54bee 20
scohennm 0:04499bc54bee 21 int main(void) {
sbart 1:4f5a6fff2389 22 SliderTimer.start();
sbart 1:4f5a6fff2389 23 SliderTimer.reset();
scohennm 0:04499bc54bee 24 char lcdData[LCDCHARLEN];
scohennm 0:04499bc54bee 25 PwmOut gled(LED_GREEN);
scohennm 0:04499bc54bee 26 PwmOut rled(LED_RED);
scohennm 0:04499bc54bee 27 pc.printf(PROGNAME);
scohennm 0:04499bc54bee 28 TSISensor tsi;
scohennm 0:04499bc54bee 29
scohennm 0:04499bc54bee 30 while (true) {
scohennm 0:04499bc54bee 31 tsidata = tsi.readPercentage();
sbart 1:4f5a6fff2389 32 if (SliderTimer.read() > DATAINTERVAL){
sbart 1:4f5a6fff2389 33 SliderTimer.reset();
sbart 1:4f5a6fff2389 34 if (tsidata > TSILIMIT){
sbart 1:4f5a6fff2389 35 gled = 0.0;
sbart 1:4f5a6fff2389 36 rled = 0.0;
sbart 1:4f5a6fff2389 37 }else {
sbart 1:4f5a6fff2389 38 pc.printf("\n Position %f\n\r", tsidata);
sbart 1:4f5a6fff2389 39 sprintf (lcdData,"%0.4f",tsidata);
sbart 1:4f5a6fff2389 40 LCDMess(lcdData);
sbart 1:4f5a6fff2389 41 gled = tsidata;
sbart 1:4f5a6fff2389 42 rled = 1.0 - tsidata;
sbart 1:4f5a6fff2389 43 }
scohennm 0:04499bc54bee 44 }
scohennm 0:04499bc54bee 45 }
scohennm 0:04499bc54bee 46 }