monome / teletype

monome eurorack module
GNU General Public License v2.0
202 stars 84 forks source link

Accept all line ending styles for USB load #306

Closed scanner-darkly closed 1 year ago

scanner-darkly commented 1 year ago

What does this PR do?

previously, only *nix style line endings (LF) were accepted. i've updated deserialization code to accept DOS (CRLF) and Mac (CR) line ending styles as well. i also used it as an opportunity to make the deserialization code more robust.

as a consequence of this update, now it will also ignore any lines that start with # and are not followed by M, I, P, G or 1-8, which means script files can be annotated with comments. it also effectively fixes #104.

while working on this, i realized that we use magic numbers for script numbers in multiple places, which makes it more difficult to create firmware mods for increased script count, so i've addressed that as well (i'm also considering revisiting the idea of shadow scripts..)

finally, as there was no need for a dedicated enum for script number, i've changed it to uint8_t and this surfaced an issue in our tests where the script number wasn't set properly, and a couple of places in the main code where we weren't doing boundary checks, so i fixed that as well.

How should this be manually tested?

save/load scenes to USB using different line endings.

If the related Github issues aren't referenced in your commits, please link to them here.

104

I have,