xoseperez / hlw8012

HLW8012 library for Arduino and ESP8266 using the Arduino Core for ESP8266.
GNU General Public License v3.0
126 stars 48 forks source link

No way to handle a SEL pin that's just tied to a pullup or pulldown #5

Open xoseperez opened 6 years ago

xoseperez commented 6 years ago

Originally reported by: pjz (Bitbucket: pjz, GitHub: pjz)


There's not a good way to use this library with a SEL pin that's not tied to a GPIO.

xoseperez commented 6 years ago

Original comment by pjz (Bitbucket: pjz, GitHub: pjz):


I presented you with my first PR ( https://bitbucket.org/xoseperez/hlw8012/pull-requests/2 ), but you wanted a different API than I proposed. I tried to fix it in another PR ( https://bitbucket.org/xoseperez/hlw8012/pull-requests/3 ) but you again expressed dissatisfaction with that API. Could you please present an API you'd be happy with, and I'd be happy to write the code for it? I'd like to get this fixed.

NdK73 commented 5 years ago

Just found a nice device that uses hardwired SEL and ignores CF1: shelly1pf (from shelly.cloud ). What about just passing an invalid pin (42? :) ) as CF1 pin and SEL pin? Should require minimal changes. Obviously some methods will be useless: is it better to return 'invalid' values or an exception?