ZI5 lib
Dependencies: C12832
Revision 0:af5927fceeb9, committed 2016-06-23
- Comitter:
- tbjazic
- Date:
- Thu Jun 23 13:50:05 2016 +0000
- Commit message:
- initial
Changed in this revision
diff -r 000000000000 -r af5927fceeb9 C12832.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/C12832.lib Thu Jun 23 13:50:05 2016 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/askksa12543/code/C12832/#990d5eec2ef6
diff -r 000000000000 -r af5927fceeb9 TempSenzor.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TempSenzor.cpp Thu Jun 23 13:50:05 2016 +0000 @@ -0,0 +1,51 @@ +#include "mbed.h" +#include "C12832.h" +#include "TempSenzor.h" + +TempSenzor::TempSenzor (PinName prviPin, PinName drugiPin, PinName tipkaPin): senzor1(prviPin), senzor2(drugiPin), tipka(tipkaPin), lcd(p5, p7, p6, p8, p11){ + odabraniC=true; + ispis.attach(this, &TempSenzor::ispisi, 0.5); + tipka.rise(this, &TempSenzor::ocitajVrijednost); + debounceTipka.start(); + + + } + + +void TempSenzor::ocitajVrijednost(){ + if (debounceTipka.read_ms()>20){ + if(odabraniC==true){ + odabraniC=false; + } + else{ + odabraniC=true; + } + +debounceTipka.reset(); + } + + } + + + + +void TempSenzor::ispisi(){ + if(odabraniC==true){ + lcd.cls(); + lcd.locate(0,3); + lcd.printf("Senzor 1: %f C\n",senzor1*330); + lcd.printf("Senzor 2: %f C\n", senzor2*330); + prosjek1= ((senzor1*330)+(senzor2*330))/2; + lcd.printf("Prosjek: %f C\n", prosjek1); + } + else { + lcd.cls(); + lcd.locate(0,3); + lcd.printf("Senzor 1: %f K\n",(senzor1*330)+273.15); + lcd.printf("Senzor 2: %f K\n", (senzor2*330)+273.15); + prosjek2= ((senzor1*330)+273.15)+((senzor2*330)+273.15)/2; + lcd.printf("Prosjek: %f K\n", prosjek2); + + } + + } \ No newline at end of file
diff -r 000000000000 -r af5927fceeb9 TempSenzor.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TempSenzor.h Thu Jun 23 13:50:05 2016 +0000 @@ -0,0 +1,26 @@ +#ifndef TEMPSENZOR_H +#define TEMPSENZOR_H + +#include "mbed.h" +#include "C12832.h" +class TempSenzor { + public: + TempSenzor (PinName prviPin, PinName drugiPin, PinName tipkaPin); + private: + AnalogIn senzor1; + AnalogIn senzor2; + InterruptIn tipka; + C12832 lcd; + Timer debounceTipka; + Ticker ispis; + bool odabraniC; + float prosjek1, prosjek2; + void ocitajVrijednost(); + void ispisi(); + + + }; + + + +#endif \ No newline at end of file