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

Allow watch faces to implement custom handleButtonPress functions #165

Closed

Conversation

synthead
Copy link

@synthead synthead commented May 12, 2022

This PR allows users to implement custom implementations for handleButtonPress!

For example, with the changes in this PR, I could do:

void WatchyKeen::handleButtonPress() {
  pinMode(VIB_MOTOR_PIN, OUTPUT);
  
  digitalWrite(VIB_MOTOR_PIN, HIGH);
  delay(50);
  digitalWrite(VIB_MOTOR_PIN, LOW);

  Watchy::handleButtonPress();
}

This example gives a "tactile" effect for every button press by doing two things:

These changes are backward-compatible: if a watch face does not implement handleButtonPress, then there will be no functional changes with any watch face.

In addition, calling Watchy::handleButtonPress() from the user's own handleButtonPress function will make the watch perform its regular functions with the original buttons. However, if the user would like to have their own menu, for example, they don't need to always call Watchy::handleButtonPress(). This could look like this:

bool inMyMenu = false;

void WatchyKeen::handleButtonPress() {
  if (!inMyMenu && buttonPressed == myMenuButton) {
    inMyMenu = true;
  }

  if (inMyMenu) {
    // perform your own tasks here
    // set inMyMenu to false when you're done
  } else {
    Watchy::handleButtonPress();
  }
}

Other examples of how this could be implemented:

  • Make the up and down buttons turn lights on and off in your home
  • Kick off a non-deep-sleep routine, like a watch face-specific menu or other feature
  • Change the watch backgrounds, if multiple are available on a watch face

@synthead synthead force-pushed the make-handleButtonPress-virtual branch from 86a95c0 to 6af6742 Compare May 12, 2022 09:28
@synthead
Copy link
Author

I actually kinda like #164 more, since it's more straight-forward and has the potential to cause less problems 🙂 I'm going to close this PR in favor of #164 👍

@synthead synthead closed this May 12, 2022
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