Legacy named styles question

Good afternoon,

I was under the impression that removing the legacy named styles and replacing them with equivalent StylePtr one’s would help reduce the flash memory usage. I replaced all my StyleFirePtr<RED, YELLOW, 0>(), with StylePtr<StyleFire<RED, YELLOW, 0>>(), but my memory usage went up instead of down:

from:
Sketch uses 458240 bytes (90%) of program storage space. Maximum is 507904 bytes.
to:
Sketch uses 461312 bytes (90%) of program storage space. Maximum is 507904 bytes. 

I still have all my StyleNormalPtr to convert but is it worth it ?

As always, thanks for any insight. Have a pleasant weekend.

Disregard, I was using the lazy way and asked ChatGPT to convert them for me and of course I got garbage.

I think, I finally understand what “Expand” from the style editor does: It converts the legacy named styles to the StylePtr, is this correct ?

Bladestyles are put together as templates using the C++ type system, and what C++ provides is a way to “alias” types.

For example:

using MyFunType = int32_t;

void function() {
    // Holds an int because the underlying type is still an int. More practically this can be used to alias longer types into shorter ones. 
    MyFunType var{32};
}

Many bladestyles are implemented using other bladestyles, and so they use aliases. If you look around the bladestyle code there’s tons of examples of this.

“Expand” just replaces (some?) of these aliases with the underlying types… or rather styles.

Today was the first time that “Expand” button was not greyed-out.

The Style Editor doesn’t like this one:
StylePtr<InOutSparkTip<EASYBLADE(BLUE,WHITE),300,800>>() and gives an Unknown identifier: EASYBLADE error after I click submit.

Easy blade is an old macro (not a style) and so might not be added in the editor.

Thanks Ryan (@ryryog25),
I searched for EASYBLADE and found it’s home in “…\styles\legacy_styles.h”:

#define EASYBLADE(COLOR, CLASH_COLOR) \
  SimpleClash<Lockup<Blast<COLOR, WHITE>, AudioFlicker<COLOR, WHITE> >, CLASH_COLOR>

So I replaced EASYBLADE with “it’s code”, changed COLOR & CLASH_COLOR with the respective colors and got this:

StylePtr<InOutSparkTip<SimpleClash<Lockup<Blast<BLUE,WHITE>,AudioFlicker<BLUE, WHITE>>,WHITE>,300,800>>()

Which is accepted by the Style Generator to be Argified.

Now, for the assumption that Legacy Styles use more flash memory or not, here are my numbers for myconfig.h:

  • Before with Legacy Named Styles:
    Sketch uses 458240 bytes (90%) of program storage space. Maximum is 507904 bytes.
  • After with StylePtr Styles (however, I also Argified all of them):
    Sketch uses 459696 bytes (90%) of program storage space. Maximum is 507904 bytes.
    No decrease, but the increase is only 0.29% and they are Argified, so they can be modified without a “re-upload” so I will call this one a “draw”.

To save memory not using legacy styles you would use
#define DISABLE_BASIC_PARSER_STYLES in your config file.

This is close, but not correct.

I think you are conflating a few things:

  1. #define DISABLE_BASIC_PARSER_STYLES This define removes some choices from the ProffieOS Workbench tool. These choices are some built-in legacy styles that very very few people use. Removing them usually saves some memory.
  2. Fett263 has a style generator which generates very versatile styles that are design to save memory. Note that generally, each style tends to take more memory than a simpler legacy style, but they can be re-used with edit mode to create several presets with different colors and options, and doing so does not use any more flash memory. When used this way, Fett263 styles saves a lot of memory.
  3. Using the same style multiple time in your config file saves memory. To some degree, using styles where some section of the style is the same also saves memory. Mixing legacy and Fett263 styles in the same config tends to use more memory than sticking to one or the other.

For more information, read this page:

1 Like

Hi @NoSloppy ,

I do have that define, both before removing my Legacy Named styles & after I changed them all (I think) to StylePtr...something...something(), !

I doubt you would want to look over at my “before” & “after” more than 3800 lines each (I know, I am crazy :upside_down_face:, but I promisse, I am not dangerous :grin:) configs, but if you do, I can post them for you ?

Sort of.
A lot of styles in templates in ProffieOS are just aliases for something else. Using he alias, or the expanded version is exactly the same. Expanding does not save memory, but it does let you see and/or change what’s inside those aliases.

1 Like

Oh, believe me, I have read that page many times.

I replaced all my legacy named styles (many times identical one’s) with the same amount of “repetition” for the “modernized styles” Edit: I also Argified them (so a bit more information to store) “end of edit”, memory usage still went up (which I expected due to having “more” code after the conversion).