Skip to content

Code reformat for less repetition and better reading#2

Open
Flavsditz wants to merge 10 commits into
gary909:masterfrom
Flavsditz:master
Open

Code reformat for less repetition and better reading#2
Flavsditz wants to merge 10 commits into
gary909:masterfrom
Flavsditz:master

Conversation

@Flavsditz

@Flavsditz Flavsditz commented Dec 27, 2020

Copy link
Copy Markdown

Hey, thanks so much for writing this! It was really useful when I tried implementing it myself.
I did use an ESP32 though and the code was a bit different for me. So to create this merge Request I changed a to make it so it works for Arduino (I haven't tested since I don't have a freed-up Arduino board here atm).

What I did:
The loops were the same with just different delay values so:

  • I extracted the loops into their own functions
  • The functions get a list of delays that are used in the correct cases

With that, all you have to do is call the doCycle function with the parameters and it works the same with less repeated code.

If you can also test it to see if it works on your board or if you have any other questions we can discuss them here :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant