mandulaj / PZEM-004T-v30

Arduino library for the Updated PZEM-004T v3.0 Power and Energy meter
MIT License
256 stars 108 forks source link

fix building with 'PZEM004_NO_SWSERIAL' under esp8266 #79

Closed vortigont closed 2 years ago

vortigont commented 2 years ago

wrong logic in define's resulted in build error under esp8266 if PZEM004_NO_SWSERIAL was set. Also updated HWSerial example to be a real HWSerial, no gotchas. So from now on CI job should detect such build issues

mandulaj commented 2 years ago

Hey, thanks for the PR. That's a good point! However as I pointed out in the comments above, it used to be possible to set the Serial by compiler flags but now it's not. I am not sure why I have done it that way, perhaps it was used during some kind of testing earlier. Can't see a reason to keep it. Otherwise, everything looks good.

If you don't see a reason to keep the old functionality, I will merge this.

vortigont commented 2 years ago

Hi @mandulaj, That's a pretty simple example, not sure that it needs all flags to be strictly re-definable :) Actually I changed it just to be capable to detect build issues with NO_SWSERIAL via CI task. Had to convert it to .cpp instead of .ino though. Platformio does not work well with .ino's defines even if guarded with #ifndef's

P.S. You might be interested, I've made another lib for PZEM's, a completely different approach, check it if you like - pzem-edl