mister-grumbler / w1209-firmware

The functional eqivalent to the original firmware of "Digital Thermostat Module Model XH-W1209".
GNU General Public License v3.0
39 stars 23 forks source link

Bug found in parameter P6 - Temperature of 110°C is less than 27°C #26

Open rtek1000 opened 1 year ago

rtek1000 commented 1 year ago

Original code: https://github.com/mister-grumbler/w1209-firmware/blob/master/ts.c

        if (getMenuDisplay() == MENU_ROOT) {
            int temp = getTemperature();
            itofpa (temp, (char*) stringBuffer, 0);
            setDisplayStr ( (char*) stringBuffer);

            if (getParamById (PARAM_OVERHEAT_INDICATION) ) {
                if (temp < getParamById (PARAM_MIN_TEMPERATURE) ) {
                    setDisplayStr ("LLL");
                } else if (temp > getParamById (PARAM_MAX_TEMPERATURE) ) { // <------------- Temperature of 110°C is less than 27°C
                    setDisplayStr ("HHH");
                }
            }

I noticed that the value returned in getParamById(PARAM_MAX_TEMPERATURE) is "110", but the temperature is a value multiplied by 10, to shift the decimal digit. So I believe I would have to multiply the getParamById() value by 10 to compare.

        if (getMenuDisplay() == MENU_ROOT) {
            int temp = getTemperature();
            temp = getParamById (PARAM_MAX_TEMPERATURE); // <------ For test only

            itofpa (temp, (char*) stringBuffer, 0);
            setDisplayStr ( (char*) stringBuffer);

            if (getParamById (PARAM_OVERHEAT_INDICATION) ) {
                if (temp < getParamById (PARAM_MIN_TEMPERATURE) ) {
                    setDisplayStr ("LLL");
                } else if (temp > getParamById (PARAM_MAX_TEMPERATURE) ) {
                    setDisplayStr ("HHH");
                }
            }

With this test, the value of 110ºC of parameter P2 appeared on the display with the value 11.0 (which is smaller than the value of 27.0ºC).

rtek1000 commented 1 year ago

I made modifications, added functions and improvements such as button debounce, code available at:

https://github.com/rtek1000/W1209-firmware-modified