Arnold-n / P1P2MQTT

Monitor and control Daikin/Rotex (hybrid/Altherma) heat pumps via the 2-wire P1/P2 thermostat interface with an ATmega328P, ESP8266, and electronics. The P1P2Serial library and P1P2Monitor program perform low-level bus operation, the P1P2-bridge-esp8266 program interprets data from/to MQTT supporting Home Assistant MQTT discovery. P1P2Serial may also be used for other Japanese Home Bus System based standards: DIII-NET (F1/F2) bus, Mitsubishi M-Net bus, Toshiba TCC-Link, Hitachi H-link, Panasonic/Sanyo SIII-Net, Haier, York, and others.
Other
324 stars 62 forks source link

Parameter Conversion improvement #63

Open budulinek opened 1 year ago

budulinek commented 1 year ago
Arnold-n commented 1 year ago

Hi @budulinek,

Thanks for the EHV support extension, good to hear from you again, would love to add it!

As for the run-time bytestart calculation, I would rather not add it, as it results in a lot of avoidable CPU cycles. It avoids human mistakes in preparing the code, so I feel is it then better to calculate it once and store is in an array? Originally I considered that but didn't to reduce its (limited) RAM usage.

Arnold

budulinek commented 1 year ago

Hi Arnold, at first I was trying to figure out whether the bytestart calculation could be done during compile-time (in combination with macros). Here is a discussion suggesting that some calculations could be done during compile-time: https://forum.arduino.cc/t/calculating-variables-at-compile-time/262409/18 https://forum.arduino.cc/t/run-time-vs-compile-time-functions/379649/8

If you are woried about CPU cycles, you can fill the bytestart[][] array during setup(). RAM usage? The code is supposed to run on ESP8266, so I think we can afford to spend few more bytes of RAM in order to avoid human mistake in the code. And by the way, why uint32_t bytestart and uint32_t nr_bytes?? uint16_t should suffice.

Yeah, I am working on a major upgrade of my Daikin P1P2 ⇔ UDP Gateway. I have noticed you have made a huge progress with P1P2 in the meantime, congratulations!

Arnold-n commented 1 year ago

Hi @budulinek , Thanks! I agree data size seems enough (80kB), but we were still running out of space, that is why the schedule code has been disabled for now. This code will disappear with the planned rewrite anyway. Indeed uint16_t for bytestart should suffice if in RAM, but it is easier to use uint32_t if in flash (PROGMEM).