Przeglądaj źródła

fix an issue that will hang the program when the reading of ch1 equals 0

Jack Shao 9 lat temu
rodzic
commit
3a239bfe97
1 zmienionych plików z 4 dodań i 0 usunięć
  1. 4 0
      Digital_Light_TSL2561.cpp

+ 4 - 0
Digital_Light_TSL2561.cpp

@@ -78,6 +78,10 @@ signed long TSL2561_CalculateLux::readVisibleLux()
    getLux();
    getLux();
 
 
    writeRegister(TSL2561_Address,TSL2561_Control,0x00);  // POWER Down
    writeRegister(TSL2561_Address,TSL2561_Control,0x00);  // POWER Down
+   if(ch1 == 0)
+   { 
+     return 0;
+   }
    if(ch0/ch1 < 2 && ch0 > 4900)
    if(ch0/ch1 < 2 && ch0 > 4900)
    {
    {
      return -1;  //ch0 out of range, but ch1 not. the lux is not valid in this situation.
      return -1;  //ch0 out of range, but ch1 not. the lux is not valid in this situation.