bigtreetech / BIGTREETECH-TouchScreenFirmware

support TFT35 V1.0/V1.1/V1.2/V2.0/V3.0, TFT28, TFT24 V1.1, TFT43, TFT50, TFT70
GNU General Public License v3.0
1.32k stars 1.65k forks source link

Numpad bugfixes #2856

Open kisslorand opened 1 year ago

kisslorand commented 1 year ago

This PR deals with some bugs in the numpad.

The bugs:

  1. In float input mode if the decimal button (".") is pressed first than the numpad would not respond to it and by exiting with "OK" the "0" value would be saved as new value.
  2. In float input mode if original value is 0 (zero) than pressing the "Reset" button the reset value will have no decimal value even if it has decimal values specified in the function call.
  3. In float input mode if the parameter value is big enough (ex. 12345.67) than the maximum character number is not respected and a number of 12345.67xxx format is used, where "xxx" are random numbers found in the memory. If this number is edited than it results in memory corruption.
  4. If no title is specified (ex. minimum an maximum values) when calling the numpad function the title will refer to a pointer that is deallocated at the time of using the data at that memory location. It can lead to an unpredictable behaviour. It is something a programmer should just simply not do.

The fixes:

  1. If the decimal button (".") is pressed first it is handled properly, the display will show "0." as the current number.
  2. In float input mode if original value is 0 (zero) than pressing the "Reset" button the reset value will will have all it's decimals specified.
  3. Character numbers limitation in float input mode is handled properly, no memory corruption occurs.
  4. Title pointer location is always allocated at the time of usage and properly deallocated (if needed) at the exit from the function.

Note

Some other changes were made too with the purpose of FW size reduction to balance the FW size increase resulted from the bugfixes.

github-actions[bot] commented 7 months ago

This PR has been automatically marked as stale because it has had no activity for the last 60 days. It will be closed in 7 days if no further activity occurs. Thank you for your contribution.