Hi Danal,
I would not say I really like it. ;( You did big job separating strings/rearranging structs/etc.. But was it really necessary?
1) For inline strings there are really convenient macro PSTR(...)
2) It does not work for struct initializers, and there are 2 ways to overcome it:
- declare string separately(as you did)
- move strings inside struct as fixed-size array
The variable length strings packed better in the flash, but you need additional code to handle them.
The fixed size strings, easier to handle but have flash overhead. But, I think, more importantly it is much easier to read and manage:
Code: Select all
static lcd_param_t lcd_param[] PROGMEM = {
{("PITCH&ROLL P"), &P8[ROLL], &__P}
, {("ROLL P"), &P8[ROLL], &__P}, {("ROLL I"), &I8[ROLL], &__I}, {("ROLL D"), &D8[ROLL], &__D}
, {("PITCH P"), &P8[PITCH], &__P}, {("PITCH I"), &I8[PITCH], &__I}, {("PITCH D"), &D8[PITCH], &__D}
So I did the test with 1.8. This is comparison of the r423 and attached LCD.pde
Code: Select all
Simple Config (gyro+acc):
Var Strings Fixed Strings
Program: 14780 bytes Program: 14664 bytes
Data: 888 bytes Data: 870 bytes
Big Config (gyro+acc+baro+power meter):
Var Strings Fixed Strings
Program: 19664 bytes Program: 19818 bytes
Data: 1078 bytes Data: 1054 bytes
As you can see it uses less SRAM and even less Flash for small number of lcd params.
So, the question is: do we really need to economize this flash?
regards,
ziss_dm