Reduces flash memory usage by ~300B
The CMake build outputs an ASM file for the firmware image and is human readable.
To see the impacted functions, look for these routines:
__prologue_saves__
__epilogue_restores__
They should come in pairs.
For more info about this option, see:
https://gcc.gnu.org/onlinedocs/gcc-7.3.0/gcc/AVR-Options.html#AVR-Options
Before, the axis limits had an error of 25° so 225° would actually be measured as 250°.
Now after fixing axisUnitToTruncatedUnit to return a more accurate value, the new values are lower. Adjust the distances by 20° to offset previous error.
When converting 800mm/s2, it would be truncated to 795mm/s2 for the pulley. This is due to cutting out significant decimal digits.
Instead let's multiply in floating point, this needs quite a bit of resources. So to optimise against this, multiply with the recoprical. Then the cost is not more than 20 bytes.
Testing:
M707 A0x0e; Read Pulley Acceleration (default at boot up is 800mm/s2)
M708 A0x0e X790 ; Set Pulley Acceleration to 790mm/s2
M707 A0x0e; Read Pulley Acceleration (should be 790mm/s2)
The results before this commit:
M707 A0x0e -> returns 805
M708 A0x0e X790 ; Set Pulley Acceleration to 790mm/s2
M707 A0x0e; returns 795
After this commit:
M707 A0x0e -> returns 799
M708 A0x0e X790 ; Set Pulley Acceleration to 790mm/s2
M707 A0x0e; returns 789
NOTE:
axisUnitToTruncatedUnit is used in Idler homing, selector homing, and pulley positioning. I am not sure yet how this improvement will affect those areas.
When reading or setting the value, the driver is expecting steps_t which is a axis scaled value.
This increases the memory footprint quite a bit. But now if you set 800mm/s2, you should get a similar value back.
Flash: +132 bytes
SRAM: 0 bytes
The read operation now returns the actual used value instead of the maximum allowed acceleration value.
Change in memory:
Flash: + 78 bytes
SRAM: 0 bytes
AxisDistance returns uint16_t type and is currently compared with long double axis length. The axis lengths fit easily into uint16_t:
selectorLimits.lenght = 75
idlerLimits.lenght = 225
Change in memory:
Flash: -122 bytes
SRAM: 0 bytes
This commit produces the same savings as the compiler options -fshort-enums. Except by setting the types manually we save also 2 bytes of SRAM.
By default, the enum type is 2 bytes, with we can explictly set it to one byte when applicable to reduce code size.
Almost all the savings from from 'enum Mode' in leds.h.
Change in memory:
Flash: -116 bytes
SRAM: -2 bytes