Style Arguments


Project maintained by profezzorn Hosted on GitHub Pages — Theme by mattgraham

Styles in ProffieOS can use arguments to make them more useful. Arguments can be integers or colors that can be changed by using the edit mode, or the ProffieOS workbench. There are two style templates that make this possible:

RgbArg<ARGUMENT_NUMBER, DEFAULT_COLOR>
or
IntArg<ARGUMENT_NUMBER, DEFALUT_VALUE>

While you don't have to use these arguments, they can be very useful for saving memory and making your saber or prop more dynamic and configurable.

Let's consider a simple preset, and I want a red, a green, and a blue preset, I would do:

{"font1", "tracks/track1.wav",
 StylePtr<EasyBlade<Red, White, 800, 300>>(),
 "label"},
{"font2", "tracks/track2.wav",
 StylePtr<EasyBlade<Green, White, 800, 300>>(),
 "label"},
{"font3", "tracks/track3.wav",
 StylePtr<EasyBlade<Blue, White, 800, 300>>(),
 "label"},

Not a problem, right? Since these are simple styles, they won't take up much space, and because they were made without arguments, they cannot be modified at run time.

Using arguments, I could instead write this as a single preset:

{"font1", "tracks/track1.wav",
 StylePtr<EasyBlade<RgbArg<BASE_COLOR_ARG, Red>, White, 800, 300>>(),
 "label"},

Then I could use edit mode or the ProffieOS workbench to copy this preset two more times, and change the fonts and the color for each preset. These copies would not take up any extra FLASH memory, which means I can use that memory for something else. (Like more styles...)

From ProffieOS 7.x, this gets even better, because you can specify the default arguments in the config file, like this:

{"font1", "tracks/track1.wav",
 StylePtr<EasyBlade<RgbArg<BASE_COLOR_ARG, Red>, White, 800, 300>>("65535,0,0"),
 "label"},
{"font2", "tracks/track2.wav",
 StylePtr<EasyBlade<RgbArg<BASE_COLOR_ARG, Red>, White, 800, 300>>("0,65535,0"),
 "label"},
{"font3", "tracks/track3.wav",
 StylePtr<EasyBlade<RgbArg<BASE_COLOR_ARG, Red>, White, 800, 300>>("0,0,65535"),
 "label"},

*Note the use of Rgb16 values

Because were using the very same style each time, it doesn't actually use up any more memory, and we don't have to use the style editor or the proffieos workbench to do the edits. It can all be done in the config file. Also, if we mess something up using edit mode, we can delete presets.ini and presets.tmp from the SD card, without losing the defaults.

If you don't know what string to put between the parenthesis, you can use edit mode/workbench to configure it the way you want it, then open up presets.ini/tmp and check the strings saved in there, then copy them to the config file.

By convention, these are the arguments we normally use in proffieos:

Note that this is just convetion. You can use IntArg<1, 1> in your style if you want to, but it will probably not work correctly with edit mode and the workbench.