frederic blanc
/
SHTxx2013
SHT V4 5V UART
Fork of SHT_v1 by
Diff: main.cpp
- Revision:
- 1:0dbbb4802508
- Parent:
- 0:df1c8f2961a1
--- a/main.cpp Sun Jan 24 22:00:35 2010 +0000 +++ b/main.cpp Tue Feb 23 08:10:54 2016 +0000 @@ -3,18 +3,49 @@ #include "mbed.h" #include "SHT.h" +const char VERSION[]="2014_11_14"; +Serial pc(USBTX, USBRX); // tx, rx +//SHT sht(PTE2,PTE3,SHT_high); // sclock, data +SHT sht(p19,p20,SHT_high); // sclock, data +DigitalOut led1(LED1); +Ticker flipper; -SHT th1(p5,p6,SHT_high); // sclock, data - -DigitalOut led1(LED1); +void flip() +{ + led1=!led1; + sht.update(SHT_high); +} -int main() { - while(1) { - th1.update(SHT_high); - printf("t:%6.2fC h:%6.2f%%\n",th1.get_temperature(),th1.get_humidity()); - led1=!led1; - wait(1); +void pc_rx(void) +{ + char c; + c=pc.getc(); + switch (c) { + + case 'H': + case 'h': + pc.printf("Humdity [ %3.2f %% ]\r\n", sht.get_humidity()); + break; + case 'T': + case 't': + pc.printf("Temperature [ %3.2f C ]\r\n", sht.get_temperature()); + break; + case 'V': + case 'v': + pc.printf("version %s\r\n",VERSION); + break; + } + +} +int main() { +flipper.attach(&flip, 0.5); + while (1) { + if (pc.readable()) + pc_rx(); + + + } }