Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jetpack_Oli_buttons.h #755

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

olivierflying747-8
Copy link
Contributor

I have not yet been able to test it because my Proffie board is still not yet connected but I am hoping for my setup to be ready by end March 2025. I know I said end February but it is taking me a lot longer then I thought to design a chassis that I will be happy with.

I am hoping for a head-start on the code review as I am hoping not to miss the OS8.x launch.

Thank you for your time.

I also have the "jetpackdisplaycontroler" but I will wait until it can be integrated in the prop directly rather than in ssd1306.h

Copy link
Owner

@profezzorn profezzorn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

first pass

EFFECT(targetting); // viewfinder search/finds target sound
EFFECT(missilelaunch); // missile launch sound
EFFECT(missilegoesboom); // double explosion in the distance sound
EFFECT(mandotalk); // "Nice shot! I was aiming for the other one!
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's wrong with "quote" ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing wrong with quote, but I am planning to have a quote player added later down the line and this one has a specific use (recreating the missile scene of The Mandalorian S02E06 that I don't want to mix with regular quotes.

If you want me to use quote, I will but I would rather not.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And I also would like to have a specific animation for this "quote"

case EVENTID(BUTTON_POWER, EVENT_FIRST_SAVED_CLICK_SHORT, MODE_OFF):
case EVENTID(BUTTON_POWER, EVENT_FIRST_SAVED_CLICK_SHORT, MODE_ON):
if (!mode_volume_) {
if (idle_) StartFlightMode(); // Transition from idle to flight (rev more up)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not how you make an if statement easy to read, please remove extra spaces and put the function call on the next line.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, but I personally find it harder to read.

else if (flight_) StopFlightMode(); // Transition from flight to idle (rev down)
else StartIdleMode(); // Jetpack initial start from 0 to idle (rev up)
// if idle, it revs up / if up, it revs down to idle / if not idle or not up, it needs to rev "up" to idle.
} else VolumeUp();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you have a } before the else, you should have one after the else too.

} else {
  VolumeUp();
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

// Next Preset (1 button):
#if NUM_BUTTONS == 1
if (!mode_volume_) next_preset();
return true;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you have return true at the end of both the #if and the #else, you should just move it out to after the #endif.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

#else
// Start or Stop Track (2 and 3 buttons):
#ifdef JETPACK_TRACK_PLAYER
if (!istrack_playing_) StartTrackPlayer();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't do this:

if (A) B();
else C();

Do this instead:

if (A)
  B();
else
  C();

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, I think I got them all ? Maybe a second "first pass" to make sure ?

return true;
#endif // NUM_BUTTONS == 1
case EVENTID(BUTTON_POWER, EVENT_FIRST_CLICK_LONG, MODE_ON):
// Volume Down (1 button):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indent two more spaces

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

#ifndef DISABLE_COLOR_CHANGE
ToggleColorChangeMode();
#endif
return true;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You probably shouldn't return true here if DISABLE_COLOR_CHANGE is defined, since it doesn't actually do anything in that case.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, I think ?

#endif
#else
// Color Change mode (3 buttons):
#ifndef DISABLE_COLOR_CHANGE
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like it would be better to do:

#ifndef DISABLE_COLOR_CHANGE
#if NUM_BUTTONS == 1
#elif NUM_BUTTONS == 2
#elif ...
#endif
#endif

instead of:

#if NUM_BUTTONS==1
#ifndef DISABLE_COLOR_CHANGE
#endif
#elif NUM_BUTTONS==2
#ifndef DISABLE_COLOR_CHANGE
#endif
#ifndef NUM_BUTTONS==3
#ifndef DISABLE_COLOR_CHANGE
#endif
#endif

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, yes that looks much better.

void EffectHelper (Effect* effect1,const char* msg1) {
hybrid_font.PlayPolyphonic(effect1);
PVLOG_STATUS << msg1 << "\n";
return;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return; at the end of a function is redundant

Copy link
Contributor Author

@olivierflying747-8 olivierflying747-8 Mar 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed.
But then do I need to add return; at the end of each line in the switch (where it was initially before I had the EffectHelper function)?

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.

2 participants