
Click Relay example for Hexiwear featuring Touch buttons and Haptic feedback
Dependencies: Hexi_KW40Z
This project demonstrates the use of the Mikroelektronika Click Relay
module with hexiwear featuring the Touch buttons
and Haptic feedback
Plug Hexiwear into the Docking Station and the RELAY Click to the Click Socket 1
Connect the USB cable to your computer and to the micro-USB port of the Docking Station
Compile the project and copy the binary "Hexi_Click_Relay-v2_Example_HEXIWEAR.bin" in the DAP-LINK drive
from your computer file explorer
Press the K64F-RESET button
on the docking station to start the program on your board
Touch the left or right electrodes/buttons
located below the screen to control the relay 1 or 2
Haptic motor will vibrate
to acknowledge that a touch command has been received
RGB LED
will briefly turn orange for Relay 1
and red for Relay 2
position change.
Revision 0:a9a4819ff9dc, committed 2016-09-20
- Comitter:
- GregC
- Date:
- Tue Sep 20 21:16:44 2016 +0000
- Commit message:
- Click Relay example for Hexiwear featuring Touch buttons and Haptic feedback
Changed in this revision
diff -r 000000000000 -r a9a4819ff9dc .gitignore --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.gitignore Tue Sep 20 21:16:44 2016 +0000 @@ -0,0 +1,4 @@ +.build +.mbed +projectfiles +*.py*
diff -r 000000000000 -r a9a4819ff9dc Hexi_KW40Z.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Hexi_KW40Z.lib Tue Sep 20 21:16:44 2016 +0000 @@ -0,0 +1,1 @@ +https://developer.mbed.org/teams/Hexiwear/code/Hexi_KW40Z/#f6f9b24aea57
diff -r 000000000000 -r a9a4819ff9dc main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Sep 20 21:16:44 2016 +0000 @@ -0,0 +1,74 @@ +#include "mbed.h" +#include "Hexi_KW40Z.h" + +#define LED_ON 0 +#define LED_OFF 1 + +void StartHaptic(void); +void StopHaptic(void const *n); + +DigitalOut relay1(PTA10); +DigitalOut relay2(PTC4); + +DigitalOut redLed(LED1); +DigitalOut greenLed(LED2); +DigitalOut blueLed(LED3); +DigitalOut haptic(PTB9); + +/* Define timer for haptic feedback */ +RtosTimer hapticTimer(StopHaptic, osTimerOnce); + +/* Instantiate the Hexi KW40Z Driver (UART TX, UART RX) */ +KW40Z kw40z_device(PTE24, PTE25); + +void ButtonLeft(void) +{ + StartHaptic(); + + redLed = LED_ON; + greenLed = LED_ON; + blueLed = LED_OFF; + + relay2 = !relay2; +} + +void ButtonRight(void) +{ + StartHaptic(); + + redLed = LED_ON; + greenLed = LED_OFF; + blueLed = LED_OFF; + + relay1 = !relay1; +} + +void StartHaptic(void) +{ + hapticTimer.start(75); + haptic = 1; +} + +void StopHaptic(void const *n) { + haptic = 0; + hapticTimer.stop(); + redLed = LED_OFF; + greenLed = LED_OFF; + blueLed = LED_OFF; +} + +int main() +{ + redLed = LED_OFF; + greenLed = LED_OFF; + blueLed = LED_OFF; + /* Register callbacks to application functions */ + kw40z_device.attach_buttonLeft(&ButtonLeft); + kw40z_device.attach_buttonRight(&ButtonRight); + + while (true) { + Thread::wait(500); + } +} + +
diff -r 000000000000 -r a9a4819ff9dc mbed-os.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed-os.lib Tue Sep 20 21:16:44 2016 +0000 @@ -0,0 +1,1 @@ +https://github.com/ARMmbed/mbed-os/#21dd7008a1540c02150f1b87c12294301db979bb