Сбор информации о погодных условиях

Dependencies:   RF24 USBDevice mbed

Revision:
6:db4538895ae7
Parent:
4:7cd67d988145
--- a/Sensors/Photoresistor.cpp	Wed Oct 28 20:52:12 2015 +0000
+++ b/Sensors/Photoresistor.cpp	Sat Dec 05 16:57:30 2015 +0000
@@ -3,9 +3,13 @@
 Photoresistor::Photoresistor(AnalogIn inputChanel):input(inputChanel){}
 
 Illumination Photoresistor::getIllumination(){
+    return getIlluminationByAdcValue(input.read());
+}
+
+Illumination Photoresistor::getIlluminationByAdcValue(float adcVal){
     double realV;
         //3.3 - ADC maximum
-    realV = input.read()*3.3;
+    realV = adcVal*3.3;
     
     if(realV > 0){
         double resistance = (10.0 * 3.3) / realV - 10.0; //resistance in kOhms.
@@ -17,4 +21,28 @@
     }else{
             return DARK; //resistance == +inf. No light 
         }
-}
\ No newline at end of file
+}
+
+bool PhotoresistorTest::adcValue_0_isDark(){
+    return Photoresistor::getIlluminationByAdcValue(0.0)==DARK;
+}
+
+bool PhotoresistorTest::adcValue_0_009_isDark(){
+    return Photoresistor::getIlluminationByAdcValue(0.009)==DARK;
+}
+
+bool PhotoresistorTest::adcValue_0_34_isVeryCloudly(){
+    return Photoresistor::getIlluminationByAdcValue(0.34)==VERY_CLOUDLY;
+}
+
+bool PhotoresistorTest::adcValue_0_93_isCloudly(){    
+    return Photoresistor::getIlluminationByAdcValue(0.93)==CLOUDLY;
+}
+
+bool PhotoresistorTest::adcValue_0_97_isClear(){
+    return Photoresistor::getIlluminationByAdcValue(0.97)==CLEAR;
+}
+
+bool PhotoresistorTest::adcValue_0_98_isVerySunny(){
+    return Photoresistor::getIlluminationByAdcValue(0.98)==VERY_SUNNY;
+}    
\ No newline at end of file