Hi, I have a general question about whether I'm doing something wrong or if this is simply not possible. I'm also not sure if this is the right place to ask this question, so if thereβs a more appropriate location, feel free to move the post there.
I want to save a variable or, more specifically, the value of a variable, and keep it stored even after a board reset. The variable accumulates values during printing, and I want this value to persist until a manual reset via G-code.
I declared the variable in the config as follows:
global totalDistance = 0
After resetting or restarting the board, I want the saved value to be restored. I tried two approaches:
Using save_variables.g:
M28 "0:/sys/saved_variables.g"
echo "set global.totalDistance = " ^ {global.totalDistance}
M29
However, the problem here is that it only saves the text and does not store the actual value behind {global.totalDistance}. When I send the command manually:
echo "set global.totalDistance = " ^ {global.totalDistance}
it outputs:
set global.totalDistance = 2357
But after restarting the board, the config resets the variable to 0, and I cannot figure out how to reload the state or value of the variable after the restart.
I also tried using M500 to save the variable's value, but this only saves axis-related information.
So my question is: Is there a way to save the value of a variable?
Some information about my hardware, although itβs irrelevant to the question:
Hardware in use:
Duet 3 Mini 5+ with RepRapFirmware 3.5.4
Duet 3 Expansion 1HCL 3.5.4
Duet Web Control 3.5.4