mandulaj / PZEM-004T-v30

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

Reduce RAM usage by storing crcTable in PROGMEM #11

Closed growboxguy closed 4 years ago

growboxguy commented 4 years ago

Hi, thanks for the module!

You could reduce the RAM usage of the module by declaring crcTable as: static PROGMEM const uint16_t crcTable[]

In this case reading from the crcTable should be updated to: crc ^= (uint16_t)pgm_read_word(&crcTable[nTemp]);

mandulaj commented 4 years ago

Excellent point! Is this also compatible with ESPs and STM32 (Bluepil)? If yes, I will add it immediately.

mandulaj commented 4 years ago

Thanks for the suggestion @growboxguy