Published BetterPhotonButton Library (updated to 0.1.4)



Replacement for Particle’s InternetButton library specific to the Photon

After reading through the code to InternetButton from Particle I wanted to fix a few things. Instead I ended up creating a replacement.

BetterPhotonButton only works with the Photon (not the Core). The LED driver class only works with WS2812 LEDs (the ones on the InternetButton).

There is no use of the delay() function in BetterPhotonButton.

Button presses and releases have debounce handling built in and can trigger a callback function.

The LED/Pixel classes support animations. Write your own or use one of the 17 built in animations. The animations support custom color palettes.

LEDs can be set with separate r, g, b values or with a combined value (like html colors).

The Accelerometer class supports a callback method which is called when the InternetButton starts or stops moving. The class also provides angle, azimuth, pitch, and roll calculations. It uses a state machine when starting up to also avoid using delay().

All of the above is accomplished by an update() method on BetterPhotonButton.
Just add update(millis()) to the loop() method and BetterPhotonButton classes take care of the rest.

See the firmware/examples/*.cpp for example usage of the various features.


This is great! It’s much easier to get something interesting going with your api for button presses and built-in animations. Are you planning to add support for the buzzer?


As soon as I can get it implemented without the use of delay().

@clairetang6 I’ve updated BetterPhotonButton to version 0.1.3 which includes playNotes().

PlayNotes builds on the same update() functionality used for animations, debounce, accelerometer, etc. and plays the notes “in the background”.

See ToneTest.cpp for an example:

1 Like

@krsmes Awesome! I’ll have to learn how to compose some jingles now.

I made a little Pomodoro app for my InternetButton using the BetterPhotonButton and just added some sounds to it (the tune in your example)! It has a LED countdown to a user-set amount of time and then a pixel animation and tune when the session is over. And it also keeps track of how many sessions you’ve done so you can see how productive you’ve been. Now I just need to make a web app for it to track sessions over days or something. :stuck_out_tongue: The demo has each session set at a few seconds, because having the session any longer makes for a pretty boring demo.


1 Like

nice. is your app on github?

i’ve fixed some issues with the string handling for playNotes(), made it more versatile, and added a PlaySongs.cpp example.

It is version 0.1.4 – I’m not exactly sure how handles versions, you may have to reimport it to your app.

1 Like

@krsmes I just uploaded it to Github if you want to check it out! I am using version 0.1.3, but I’ll check it v0.1.4 soon too.