Cable Colour Key announcement

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);
  }
}
1 Like

Hi Dan. It’s not a case of not knowing how save/load variables (Cable Colour Key already does this for a number of settings), but more a case of how it will fit with the rest of the options and behaviour of the module. I’ve still not had time to look into this in any depth, and probably won’t have a chance until after the new year, though I do some idea of how it might be implemented. :slight_smile:

1 Like