Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: EFM32 RDA5807M RDS Radio EMF32-Segment-Touch-Demo EFM32_Bugs MFALHIMOHAMMED ... more
EFM32_CapSenseSlider Class Reference
A driver for the capacitive touch slider on some EFM32 STKs. More...
#include <EFM32_CapSenseSlider.h>
Public Member Functions | |
| EFM32_CapSenseSlider () | |
| Constructor. | |
| void | start () |
| Start measuring. | |
| void | stop () |
| Stop measuring. | |
| void | attach_touch (cbptr_t callback=NULL) |
| Attach a callback handler, which gets called once on touch. | |
| void | attach_untouch (cbptr_t callback=NULL) |
| Attach a callback handler, which gets called once on releasing touch. | |
| void | attach_slide (int32_t trip=-1, cbptr_t callback=NULL) |
| Attach a callback which will trigger once the slider value passes a certain point. | |
| bool | isTouched () |
| Check whether the slider is currently being touched. | |
| int32_t | get_position () |
| Get the current position. | |
Detailed Description
A driver for the capacitive touch slider on some EFM32 STKs.
Currently supports EFM32 Wonder, Giant and Leopard Gecko kits.
#include "mbed.h" #include "EFM32_CapSenseSlider.h" silabs::EFM32_CapSenseSlider capSlider; void touchCallback(void) { if(!capSlider.isTouched()) { printf("Lost touch"); } else { printf("Finger detected! Position %d", capSlider.getPosition()); } } int main() { capSlider.start(); capSlider.attach_touch(touchCallback); while(1) sleep(); }
Definition at line 75 of file EFM32_CapSenseSlider.h.
Constructor & Destructor Documentation
Constructor.
Definition at line 42 of file EFM32_CapSenseSlider.cpp.
Member Function Documentation
| void attach_slide | ( | int32_t | trip = -1, |
| cbptr_t | callback = NULL |
||
| ) |
Attach a callback which will trigger once the slider value passes a certain point.
- Parameters:
-
trip point after which the callback gets called. If -1, the callback gets called on any change in position. callback pointer to a void (void) function. If null, then the callback gets disabled.
Definition at line 101 of file EFM32_CapSenseSlider.cpp.
| void attach_touch | ( | cbptr_t | callback = NULL ) |
Attach a callback handler, which gets called once on touch.
- Parameters:
-
callback pointer to a void (void) function. If null, then the callback gets disabled.
Definition at line 83 of file EFM32_CapSenseSlider.cpp.
| void attach_untouch | ( | cbptr_t | callback = NULL ) |
Attach a callback handler, which gets called once on releasing touch.
- Parameters:
-
callback pointer to a void (void) function. If null, then the callback gets disabled.
Definition at line 91 of file EFM32_CapSenseSlider.cpp.
| int32_t get_position | ( | ) |
Get the current position.
- Returns:
- The finger position on the slider (0-48). -1 if not touched.
Definition at line 116 of file EFM32_CapSenseSlider.cpp.
| bool isTouched | ( | ) |
Check whether the slider is currently being touched.
- Returns:
- True if a finger is currently detected.
Definition at line 109 of file EFM32_CapSenseSlider.cpp.
| void start | ( | ) |
Start measuring.
Definition at line 59 of file EFM32_CapSenseSlider.cpp.
| void stop | ( | ) |
Stop measuring.
Definition at line 71 of file EFM32_CapSenseSlider.cpp.
Generated on Tue Jul 12 2022 18:58:41 by
1.7.2