Skip to content

WIP: Refactor everything#3

Open
anthonydavidson wants to merge 17 commits into
masterfrom
td_refactor
Open

WIP: Refactor everything#3
anthonydavidson wants to merge 17 commits into
masterfrom
td_refactor

Conversation

@anthonydavidson

@anthonydavidson anthonydavidson commented Dec 2, 2019

Copy link
Copy Markdown
Collaborator

This is a work in progress. Radio receive is not functional.

Changes:

  • Added a start up sequence that's a rainbow strobe.
  • There's no longer a state where you aren't running one of the expected animations (what was in runAdjustments())
  • Created a MasterController that loop() delegates to. It controls what mode the scarf is in - Off Mode or Animation Mode.
  • Off Mode and Animation Mode each have their own controller. The MasterController delegates to one of them depending on which mode is active.
  • Switching between modes is now done with a long click.
  • Created MilliTimer class to capture concept of checking on time passed.
  • All animations and Off Mode now only write to the LEDs when the lights need to be updated. I hope this increases battery life a small bit.
  • Replaced click button part of MyKnob with ButtonControl. It's a singleton like MyKnob was.
  • No longer have to release button for long click. An event is created once you've been holding it down long enough.
  • An event is created for double click but it currently isn't used.
  • Replaced rotary part of MyKnob with KnobSetting, though MyKnob was a singleton that had a bunch of references to it while KnobSetting captures (and contains) the information needed for a particular setting on an animation while still using a global Encoder.
  • The state of a setting for a particular animation (that's altered by rotating the knob) is now saved and will be what's used by that animation when you return to it.
  • Radio now sends only once a second and not when state of animation changes. Radio sending was so chatty because the rotary knob doesn't have the equivalent of a debouncer. In other terms, the potentiometer that the rotary know is connected to increments more than once for each click of the rotary. This means that turning the knob to the next setting causes multiple state changes which are captured by the loop and sent out by the radio.

@counterbeing

Copy link
Copy Markdown
Owner

Hey there! Thanks for the PR.

I've just started to go over it. I'm totally down to merge it once the radios work :) and we have equivalent functionality.

Just for my understanding, as I'd brand myself as a C++ novice/hobbyist, I'd love to hear about why you changed what you did.

Things definitely look a bit more succinct than before! I have to say that in writing a lot of the code I felt like there was a lot of duplication, but came to believe that was just a necessary evil of writing C++.

I may sprinkle a few questions in, but would love to hear about your overarching design ideas, or any obvious problems you saw in the code before.

Thanks!

Comment thread src/main.cpp
Comment thread src/animations/Rainbow.h Outdated
Comment thread src/main.cpp Outdated
@anthonydavidson

Copy link
Copy Markdown
Collaborator Author

Hey @counterbeing ! Thanks for your comments. My intent was to get this a little farther along (to where it is now, more or less) and then add in some explanations, which hopefully I'll get to tomorrow. I'm also happy to get on a call and walk you (& Mac) through any or all of it. Radio work still to come.

@counterbeing

Copy link
Copy Markdown
Owner

Thanks @anthonydavidson! This all sounds perfect. I'd love to hop on the phone with you and Mac at some point just to do a code review so that I can learn a bit more.

I think in the coming weeks I'll be attempting to run a version of the software on new hardware (esp32) to see if I can adapt it. It's probably just easier hardware to run on. I'll try and run your new code if it's up!

Are you running your changes on a nano currently?

Cheers!

@anthonydavidson

Copy link
Copy Markdown
Collaborator Author

Cory - Yes, I'm running on one of @100ideas 's scarves.

I've got radio send working now, still need to update state on radio receive, but that should be it.

counterbeing and others added 2 commits December 8, 2019 00:16
If this is trouble feel free to revert it, i just think it might save us
some pain later.
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.

3 participants