Hi Nick, please don’t take this as a criticism, in fact I use the module a lot and would really love it to remember the last selected colour as this would make it even better than it already is, which is totally excellent.
But… if there is any chance that not knowing how to do this is holding you back, this is the type of code that I use to save selections in my modules:
// assuming you have a module variable something like:
int selectedColour{0};
json_t *dataToJson() override
{
json_t *rootJ = json_object();
json_object_set_new(rootJ, "selectedColour", json_integer(selectedColour));
return rootJ;
}
void dataFromJson(json_t *rootJ) override
{
json_t *selectedColourJ = json_object_get(rootJ, "selectedColour");
if (selectedColourJ)
{
selectedColour = json_integer_value(selectedColourJ);
}
}