Code for long/short press buttons, and thanks

13 views
Skip to first unread message

Ben Kelley

unread,
Apr 30, 2017, 12:17:19 AM4/30/17
to Robots & Dinosaurs
Thanks so much for the friendly welcome last week.

I had hoped to have my prototype far enough advanced this week to be worth coming in and cutting pieces for my case yesterday, but you know how these things go. (I'm working on a wifi switch panel for lighting control, with touch sensitive switches behind perspex.)

My current incarnation uses mechanical switches and wired ethernet, and sends updates via MQTT when you press buttons. It distinguishes between short presses and long presses. If you are interested I have some details about this here: http://mrebenezer.blogspot.com.au/2017/03/button-box-for-home-assistant.html The source for this is here https://github.com/eb3nezer/buttonControlMQTT

If you are interested in the short press/long press code, have a look at processButtonPress() in https://github.com/eb3nezer/buttonControlMQTT/blob/master/Buttons/Buttons.ino

This code suits a situation where you can read the current state of the button (e.g. button connected directly to a digital input). My wifi version will use i2c to talk to the touch sensor, and so it will get updates when the state changes.

The difference is how you handle a long press. The current code signals a long press after you have held down the button for the right amount of time (without waiting for you to release it).


Paul Hutchison

unread,
Apr 30, 2017, 12:36:50 AM4/30/17
to Robots & Dinosaurs

Awesome, I might need to use similar code for my sunlight alarm (that I've been talking about since last winter). I've got an idea for a brightness slider as well but I still want to utilise tap handling for instant on and off and maybe long press for instant mood lighting.

Thanks for sharing.


--
You received this message because you are subscribed to the Google Groups "Robots & Dinosaurs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sydney-hackspa...@googlegroups.com.
To post to this group, send email to sydney-h...@googlegroups.com.
Visit this group at https://groups.google.com/group/sydney-hackspace.
For more options, visit https://groups.google.com/d/optout.

Ben Kelley

unread,
Apr 30, 2017, 7:04:10 PM4/30/17
to Robots & Dinosaurs
Pulled my finger out yesterday and did some work on my ESP8266 + CAP1188 (8 input capacitative touch sensor) version. Code + electronics working nicely.

I'm thinking a perspex slotted box for the case. About 70x150x20mm.

A basic box is simple enough (I see there are Inkscape plugins, or even online tools that will create the file for you). I want to make the top and bottom slightly oversized though, with rounded corners, and with screws on the top going into t-slots. Need to skill up a bit :)

The top panel will have the button outlines etched slightly, and then with copper tape on the underside of the top panel connected to the touch sensor board. Place your finger in the middle of the button outline to activate the touch sensor underneath.
Reply all
Reply to author
Forward
0 new messages