Click Relay example for Hexiwear featuring Display, Touch buttons and Haptic feedback

Dependencies:   Hexi_KW40Z Hexi_OLED_SSD1351

Fork of Hexi_Click_Relay-v3_Example by Hexiwear

This project demonstrates the use of the Mikroelektronika Click Relay module with hexiwear featuring the OLED display, 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-v3_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

The OLED screen will display two switch graphics with both relays in position OFF
Touch the left or right electrodes/buttons located below the screen to control the relay 1 or 2
Screen will update the graphics to reflect the status of the each relay either ON or OFF
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:
1:420b0ad324f8
Parent:
0:ac93d26bbdb5
--- a/main.cpp	Tue Sep 20 21:51:57 2016 +0000
+++ b/main.cpp	Wed Sep 21 23:05:11 2016 +0000
@@ -90,13 +90,11 @@
     const uint8_t *image1;
     const uint8_t *image2;
     const uint8_t *image3;
-    const uint8_t *image4;
 
     /* Setting pointer location of the 96 by 96 pixel bitmap */
-    image1  = Relay_FF;
-    image2  = Relay_NN;
-    image3  = Relay_FN;
-    image4  = Relay_NF;
+    image1  = Relay_OFF;
+    image2  = Button_OFF;
+    image3  = Button_ON;
     
     /* Turn on the backlight of the OLED Display */
     oled.DimScreenON();
@@ -111,43 +109,33 @@
     /* Fill 96px by 96px Screen with 96px by 96px NXP Image starting at x=0,y=0 */
     oled.DrawImage(image1,0,0);
 
-    while (true) {
-        
-        if (flag == 1) {
-        if (relay2==0)  {
-        if (relay1==0) {
-            /* Fill the screen with white to overwrite previous image */
-            oled.FillScreen(COLOR_BLACK);
-        
-            /* Fill 96px by 96px Screen with 96px by 96px NXP Image starting at x=0,y=0 */
-            oled.DrawImage(image1,0,0);
-            }
-        else {
-            /* Fill the screen with white to overwrite previous image */
-            oled.FillScreen(COLOR_BLACK);
+    while (true) 
+    {
         
-            /* Draw 96px by 96px NXP Banner at the bottom by setting x =0,y=64(96-32)*/
-            oled.DrawImage(image3,0,0);
-            }
-            }
-    else {
-        if (relay1==0) { 
-            /* Fill the screen with white to overwrite previous image */
-            oled.FillScreen(COLOR_BLACK);
-        
-            /* Fill 96px by 96px Screen with 96px by 96px NXP Image starting at x=0,y=0 */
-            oled.DrawImage(image4,0,0);
-       }
-        else {  
-            /* Fill the screen with white to overwrite previous image */
-            oled.FillScreen(COLOR_BLACK);
-        
-            /* Draw 96px by 96px NXP Banner at the bottom by setting x =0,y=64(96-32)*/
-            oled.DrawImage(image2,0,0);
-            }
-            }
-         flag = 0;
-            }
-            Thread::wait(50);
+        if (flag == 1) 
+        {
+            if (relay2==0)  
+                {
+                /* Fill 96px by 96px Screen with 96px by 96px NXP Image starting at x=0,y=0 */
+                oled.DrawImage(image2,9,25);
+                }
+            else 
+                {
+                /* Fill 96px by 96px Screen with 96px by 96px NXP Image starting at x=0,y=0 */
+                oled.DrawImage(image3,9,25);
+                }
+            if (relay1==0) 
+                {
+                /* Draw 96px by 96px NXP Banner at the bottom by setting x =0,y=64(96-32)*/
+                oled.DrawImage(image2,54,25);
+                }
+            else 
+                {
+                /* Draw 96px by 96px NXP Banner at the bottom by setting x =0,y=64(96-32)*/
+                oled.DrawImage(image3,54,25);
+                }
+        flag = 0;
+        }
+        Thread::wait(50);
     }
 }
\ No newline at end of file