diff --git a/libraries/Max44009/Max44009.h b/libraries/Max44009/Max44009.h index 76d8bb74..8526abe8 100644 --- a/libraries/Max44009/Max44009.h +++ b/libraries/Max44009/Max44009.h @@ -3,7 +3,7 @@ // // FILE: Max44009.h // AUTHOR: Rob dot Tillaart at gmail dot com -// VERSION: 0.1.10 +// VERSION: 0.2.0 // PURPOSE: library for MAX44009 lux sensor Arduino // HISTORY: See Max440099.cpp // @@ -18,7 +18,7 @@ #include "WProgram.h" #endif -#define MAX44009_LIB_VERSION "0.1.10" +#define MAX44009_LIB_VERSION "0.2.0" // REGISTERS #define MAX44009_INTERRUPT_STATUS 0x00 @@ -40,9 +40,13 @@ class Max44009 { public: + +#if defined(ESP8266) || defined(ESP32) // dataPin and clockPin can be used for ESP8266 - // for UNO ignore these (and its warning) - Max44009(const uint8_t address, const uint8_t dataPin = 255, const uint8_t clockPin = 255); + Max44009(const uint8_t address, const uint8_t dataPin, const uint8_t clockPin); +#endif + // ctor for UNO + Max44009(const uint8_t address); float getLux(); int getError(); diff --git a/libraries/Max44009/examples/max44009_test01/max44009_test01.ino b/libraries/Max44009/examples/max44009_test01/max44009_test01.ino index ecdc808a..75cbcbd7 100644 --- a/libraries/Max44009/examples/max44009_test01/max44009_test01.ino +++ b/libraries/Max44009/examples/max44009_test01/max44009_test01.ino @@ -1,10 +1,9 @@ // // FILE: max44009_test01.ino // AUTHOR: Rob Tillaart -// VERSION: 0.1.1 +// VERSION: 0.1.2 // PURPOSE: demo of max44009 library // DATE: 2015-08-06 -// URL: ? // // Released to the public domain // @@ -12,7 +11,7 @@ #include "Wire.h" #include "Max44009.h" -Max44009 myLux(0xCB); // default addr +Max44009 myLux(0xCB); // default addr uint32_t lastDisplay = 0; @@ -21,6 +20,9 @@ void setup() Serial.begin(115200); Serial.print("Start max44009_test01 : "); Serial.println(MAX44009_LIB_VERSION); + + Wire.begin(); + } void loop() @@ -44,4 +46,4 @@ void loop() } - +// END OF FILE diff --git a/libraries/Max44009/library.json b/libraries/Max44009/library.json index 2cb12c1e..06e58fc9 100644 --- a/libraries/Max44009/library.json +++ b/libraries/Max44009/library.json @@ -15,7 +15,7 @@ "type": "git", "url": "https://github.com/RobTillaart/Arduino.git" }, - "version":"0.1.10", + "version":"0.2.0", "frameworks": "arduino", "platforms": "*", "export": { diff --git a/libraries/Max44009/library.properties b/libraries/Max44009/library.properties index f9a70193..7ee0d687 100644 --- a/libraries/Max44009/library.properties +++ b/libraries/Max44009/library.properties @@ -1,5 +1,5 @@ name=Max44009 -version=0.1.10 +version=0.2.0 author=Rob Tillaart maintainer=Rob Tillaart sentence=Library for MAX44009 lux sensor Arduino. diff --git a/libraries/Max44009/max44009.cpp b/libraries/Max44009/max44009.cpp index c98f5c09..b546a83a 100644 --- a/libraries/Max44009/max44009.cpp +++ b/libraries/Max44009/max44009.cpp @@ -1,12 +1,13 @@ // // FILE: Max44009.cpp // AUTHOR: Rob Tillaart -// VERSION: 0.1.10 +// VERSION: 0.2.0 // PURPOSE: library for MAX44009 lux sensor Arduino // URL: https://github.com/RobTillaart/Arduino/tree/master/libraries // // Released to the public domain // +// 0.2.0 - 2019-08-23 solve #127 == redo #118 // 0.1.10 - 2018-12-08 issue #118 Fix constructor esp8266 // (thanks to Bolukan) // 0.1.9 - 2018-07-01 issue #108 Fix shift math @@ -24,10 +25,13 @@ #include "Max44009.h" - +#if defined(ESP8266) || defined(ESP32) Max44009::Max44009(const uint8_t address, const uint8_t dataPin, const uint8_t clockPin) { _address = address; + _data = 0; + _error = 0; + if ((dataPin < 255) && (clockPin < 255)) { Wire.begin(dataPin, clockPin); @@ -35,8 +39,17 @@ Max44009::Max44009(const uint8_t address, const uint8_t dataPin, const uint8_t c Wire.begin(); } // TWBR = 12; // Wire.setClock(400000); +} +#endif + +Max44009::Max44009(const uint8_t address) +{ + _address = address; _data = 0; _error = 0; + + Wire.begin(); + // TWBR = 12; // Wire.setClock(400000); } float Max44009::getLux(void) @@ -132,7 +145,7 @@ void Max44009::setManualMode(uint8_t CDR, uint8_t TIM) void Max44009::setThreshold(const uint8_t reg, const float value) { // TODO CHECK RANGE - uint32_t m = round(value / 0.045); // mulitply * 22.22222222 is faster. + uint32_t m = round(value * 22.2222222); // was round(value / 0.045); mulitply is faster. uint8_t e = 0; while (m > 255) {