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

[Friend V2] Action button firmware characteristic ($500) #566

Closed
josancamon19 opened this issue Aug 10, 2024 · 3 comments
Closed

[Friend V2] Action button firmware characteristic ($500) #566

josancamon19 opened this issue Aug 10, 2024 · 3 comments
Assignees
Labels
firmware firmware work flutter flutter work Paid Bounty 💰

Comments

@josancamon19
Copy link
Contributor

Is your feature request related to a problem? Please describe.
Friend App should have a firmware characteristic that notifies when the button is pressed.

Describe the solution you'd like
There should be a firmware characteristic in the firmware that listens for the button click.

The app should read the characteristic and trigger whatever you want for now (based on that)

@josancamon19 josancamon19 changed the title [Friend V2] Action button firmware characteristic [Friend V2] Action button firmware characteristic ($500) Aug 10, 2024
@kodjima33 kodjima33 moved this to Backlog in omi TODO Aug 10, 2024
@josancamon19 josancamon19 changed the title [Friend V2] Action button firmware characteristic ($500) [Friend V2] Action button firmware characteristic ($300) Aug 10, 2024
@midepeter
Copy link

Hello @josancamon19,

I assume this is a paid task. I will love to take on this and make a PR soon😊

@josancamon19 josancamon19 changed the title [Friend V2] Action button firmware characteristic ($300) [Friend V2] Action button firmware characteristic ($500) Aug 10, 2024
@josancamon19
Copy link
Contributor Author

@kevvz please comment here so I can assign this to you.

@kevvz
Copy link
Collaborator

kevvz commented Aug 15, 2024

hello

josancamon19 added a commit that referenced this issue Aug 28, 2024
#566 Added button and button characteristic


How to test:

Download the uf2 file for this repository and flash it onto your device.
It should be in Friend/firmware/firmware_v1.0/button_build. If you can’t
find it then you can generate it using the nrf SDK. I used version 2.5.0
for both
Download the updated app on your phone. Make sure to enable debug mode.
Go to the debug console.
Wait until your device connects to the app (blue light.) There are two
modes: press for a little bit, then press for about 2 seconds. You
should get the notifications Button Pressed and Button long Press,
indicating a button tap and Long press respectively.
If for some reason you can’t use the friend debugger, then you can
simply open the BLE app and press the button described in 3. You should
be getting the count.

Quick rundown on how it works

An interrupt service routine is attached to pin D5 according to the Xiao
sense diagram. The interrupt triggers when it detects a button press,
both pressed up and down. Pin D4 is configured as supply power.
When the interrupt triggers, a function is called that checks if the
button press is actually a button press (for this implementation, it
rejects inputs that appear jittery, or swing in voltage too often. That
way only “stable” inputs are considered pressed). Then the input is
recorded.
A work order occasionally checks the input value. Then we grab the
current state of the button, whether it be idle, single pressed, double
press, or in a grace period. Depending on the state and if the current
GPIO pin reads 1 or 0, it will perform different actions such as notify
taps, double taps, presses, etc. I may write a guide later but TLDR it
is a finite state machine, that computes an action given its state and
event.


Some notes on the button:

I noticed that “fat fingering” the button, which means clicking the
button with your skin tends to make the button act unpredictably. The
most likely reason may be the contacts on the right side of the button,
in which your fingers could accidentally connect the metal and trigger
the button. Try to use your fingernails or cover the button with
insulation. I imagine that in future versions that you would press the
button with some insulation to protect against this (much like Avi’s
Friend pendant.)
I’ve probably pressed the button about 1000 times, and the solder
connecting the button is starting to break. The boards appear to be
separating.

What can you build?

Some ideas that were thrown around was attaching APIs according to
button events. Also mentioned earlier was a “record” button that could
simulate other necklaces on the market. Ideas for implementation are
plenty!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
firmware firmware work flutter flutter work Paid Bounty 💰
Projects
Status: Done
Development

No branches or pull requests

3 participants