This repository has been archived by the owner on Aug 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 199
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Expand thermistortable to include precomputed slope
Save a division at runtime by pre-calculating the slope between each pair of adjacent thermistortable values. Since we use the larger value each time, save the slope between two values A and B in the table with the B data. Therefore the slope is that between each value and its predecessor in the list. Store this new value in the third element of the now 3-integers-wide array which makes up the table. Use fixed-point 6.10 format to store the slope. This is almost too narrow for some slopes and maybe it should be changed to 8.8 fixed-point. In practice this presents a loss in accuracy, but it is still significantly better than the previous fixed-sample-size table production method. In particular no provision is made to handle values which scale over 65535, and it seems we should at least warn about this if not simply fail before letting the user go off compiling his code. Add a new flag TEMPTABLE_FORMAT and define it as 1 to tell the code that we are using this new and incompatible format. This lets us tolerate old hand-crafted thermistor tables by keeping the slower algorithm in case one is still used. New thermistor tables should be defined with this new format and with the FORMAT define set accordingly. With the default 25 samples this adds 100 bytes to the flash image for the thermistortable storage for two different thermistors. But the code is simplified and saves me 134 bytes in the bargain for a net decrease in flash size of 34 bytes.
- Loading branch information
Showing
2 changed files
with
47 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters