Feature request: constants in PROGMEM

It would be neat if compile-time constants from using the “constant” node were in fact constant data, i.e. stored in the program memory space of the Harvard architecture uPs like the 8 bit Arduino Uno. A quick hack that should work is since a double/Number and a pointer are the same size on the AVR/Microchip 8 bit, one should be able to cast a pointer to program memory space to a Number and pass a reference to the constant data around that way as normal. It would require custom nodes for the storage and any nodes that wished to dereference and use the data, however.

I’m trying to think if there’s a way to do this generally with perhaps just a custom “PROGMEM” node and an intermediary conversion node, via the stack, without having to rewrite every node which accepts a Number or String to be PROGMEM-aware and know how to dereference PROGMEM pointers.

Hello! Yep, that makes sense. However, it is no longer actual after the loop unroll optimization. It has moved constants out of SRAM as a side-effect. The new code generator is already available in dev version and we’ll release it in 0.18.0, I think, until the end of month.

1 Like

Awesome, that should help with my ATTiny-targeted projects a lot! The XOD transactional model seems very efficient wrt stack usage, the trick when you only have 512 bytes of SRAM is to keep data off the heap if at all possible, particularly program-lifetime persistent data.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.