okyeron / OMX-27

161 stars 38 forks source link

Fix pattern settings save #35

Closed catkins closed 2 years ago

catkins commented 2 years ago

Fixes bug where pattern settings were just being saved to the EEPROM/FRAM as the literal value of the pointer itself (eg 0x3100000f) rather than contents of the Pattern struct as I'd forgotten to dereference the Pattern before passing it to read/writeObject methods.

Reimplemented storage functions to appropriately write out the correct number of bytes depending if EEPROM or FRAM is used.

okyeron commented 2 years ago

Looking at some bits and I'm noticing the Pattern struct is likely wrong now that patterns can be 64 steps

    uint8_t startstep : 4;      // step to begin pattern. must be < patternlength-1
    uint8_t autoresetstep : 4;  // step to reset on / 0 = off
    uint8_t autoresetfreq : 4;  // tracking reset iteration if enabled / ie Freq of autoreset. should be renamed
    uint8_t current_cycle : 4;  // tracking current cycle of autoreset counter / start it at 1
    uint8_t rndstep : 4;        // for random autostep functionality

These should be 6 instead I think?

@szydek did that code to start so I'm slightly fuzzy on all those parts

catkins commented 2 years ago

Good spotting: fixed in fd6fb4e