Done

Dependencies:   HTU21D Hexi_KW40Z Hexi_OLED_SSD1351 MAX30101

Fork of Hexiwear by Jacob Shebesh

Files at this revision

API Documentation at this revision

Comitter:
Jashebes
Date:
Mon Apr 30 18:06:25 2018 +0000
Commit message:
For final

Changed in this revision

.gitignore Show annotated file Show diff for this revision Revisions of this file
HTU21D.lib Show annotated file Show diff for this revision Revisions of this file
Hexi_KW40Z.lib Show annotated file Show diff for this revision Revisions of this file
Hexi_OLED_SSD1351.lib Show annotated file Show diff for this revision Revisions of this file
MAX30101.lib Show annotated file Show diff for this revision Revisions of this file
README.md Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-os.lib Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r b9ba2cb49fbe .gitignore
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.gitignore	Mon Apr 30 18:06:25 2018 +0000
@@ -0,0 +1,4 @@
+.build
+.mbed
+projectfiles
+*.py*
diff -r 000000000000 -r b9ba2cb49fbe HTU21D.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/HTU21D.lib	Mon Apr 30 18:06:25 2018 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/hwing91/code/HTU21D/#db86ad1b4459
diff -r 000000000000 -r b9ba2cb49fbe Hexi_KW40Z.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Hexi_KW40Z.lib	Mon Apr 30 18:06:25 2018 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/Jashebes/code/Hexi_KW40Z/#c36aa84374e8
diff -r 000000000000 -r b9ba2cb49fbe Hexi_OLED_SSD1351.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Hexi_OLED_SSD1351.lib	Mon Apr 30 18:06:25 2018 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/teams/Hexiwear/code/Hexi_OLED_SSD1351/#9961c525e249
diff -r 000000000000 -r b9ba2cb49fbe MAX30101.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MAX30101.lib	Mon Apr 30 18:06:25 2018 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/users/DimiterK/code/MAX30101/#3be008e67345
diff -r 000000000000 -r b9ba2cb49fbe README.md
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/README.md	Mon Apr 30 18:06:25 2018 +0000
@@ -0,0 +1,57 @@
+# Getting started with Blinky on mbed OS
+
+This guide reviews the steps required to get Blinky working on an mbed OS platform.
+
+Please install [mbed CLI](https://github.com/ARMmbed/mbed-cli#installing-mbed-cli).
+
+## Import the example application
+
+From the command-line, import the example:
+
+```
+mbed import mbed-os-example-blinky
+cd mbed-os-example-blinky
+```
+
+### Now compile
+
+Invoke `mbed compile`, and specify the name of your platform and your favorite toolchain (`GCC_ARM`, `ARM`, `IAR`). For example, for the ARM Compiler 5:
+
+```
+mbed compile -m K64F -t ARM
+```
+
+Your PC may take a few minutes to compile your code. At the end, you see the following result:
+
+```
+[snip]
++----------------------------+-------+-------+------+
+| Module                     | .text | .data | .bss |
++----------------------------+-------+-------+------+
+| Misc                       | 13939 |    24 | 1372 |
+| core/hal                   | 16993 |    96 |  296 |
+| core/rtos                  |  7384 |    92 | 4204 |
+| features/FEATURE_IPV4      |    80 |     0 |  176 |
+| frameworks/greentea-client |  1830 |    60 |   44 |
+| frameworks/utest           |  2392 |   512 |  292 |
+| Subtotals                  | 42618 |   784 | 6384 |
++----------------------------+-------+-------+------+
+Allocated Heap: unknown
+Allocated Stack: unknown
+Total Static RAM memory (data + bss): 7168 bytes
+Total RAM memory (data + bss + heap + stack): 7168 bytes
+Total Flash memory (text + data + misc): 43402 bytes
+Image: .\.build\K64F\ARM\mbed-os-example-blinky.bin
+```
+
+### Program your board
+
+1. Connect your mbed device to the computer over USB.
+1. Copy the binary file to the mbed device.
+1. Press the reset button to start the program.
+
+The LED on your platform turns on and off.
+
+## Troubleshooting
+
+If you have problems, you can review the [documentation](https://os.mbed.com/docs/latest/tutorials/debugging.html) for suggestions on what could be wrong and how to fix it.
diff -r 000000000000 -r b9ba2cb49fbe main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Apr 30 18:06:25 2018 +0000
@@ -0,0 +1,247 @@
+#include "mbed.h"
+#include "Hexi_OLED_SSD1351.h"
+#include "Ticker.h"
+#include "Hexi_KW40Z.h"
+#include "HTU21D.h"
+#include "string.h"
+#include "MAX30101.h"
+
+#define LED_ON      0
+#define LED_OFF     1
+
+void StartHaptic(void);
+void StopHaptic(void const *n);
+void ButtonUp(void);
+void ButtonDown(void);
+void ButtonRight(void);
+void ButtonLeft(void);
+void ButtonSlide(void);
+void attime(void);
+
+DigitalOut redLed(LED1);
+DigitalOut greenLed(LED2);
+DigitalOut blueLed(LED3);
+DigitalOut haptic(PTB9);
+
+MAX30101 heart(PTB1, PTB0);
+
+/* Instantiate the SSD1351 OLED Driver */ 
+SSD1351 oled(PTB22,PTB21,PTC13,PTB20,PTE6, PTD15); /* (MOSI,SCLK,POWER,CS,RST,DC) */
+
+/* Instantiate the Hexi KW40Z Driver (UART TX, UART RX) */ 
+KW40Z kw40z_device(PTE24, PTE25);
+
+/* Define timer for haptic feedback */
+RtosTimer hapticTimer(StopHaptic, osTimerOnce);
+
+/* Instantiate the HTU21D Sensor */
+HTU21D temphumid(PTB1,PTB0);
+DigitalOut powerEN (PTB12); // Power Enable HTU21D Sensor
+
+int sample_ftemp;   //values for the humidity/temp sensors   
+int sample_ctemp;
+int sample_ktemp;
+int sample_humid;
+int sample_HR;
+
+char text[20];
+int flag=0;
+int counter=0;
+Ticker timer;  
+  
+int main() 
+{
+    powerEN =0;
+    
+    /* Register callbacks to application functions */
+    kw40z_device.attach_buttonUp(&ButtonUp);
+    kw40z_device.attach_buttonDown(&ButtonDown);
+    kw40z_device.attach_buttonLeft(&ButtonLeft);
+    kw40z_device.attach_buttonRight(&ButtonRight);
+    kw40z_device.attach_buttonSlide(&ButtonSlide);
+
+    heart.enable();
+        
+    /* Get OLED Class Default Text Properties */
+    oled_text_properties_t textProperties = {0};
+    oled.GetTextProperties(&textProperties);    
+
+    /* Turn on the backlight of the OLED Display */
+    oled.DimScreenON();
+    
+    /* Fills the screen with solid black */         
+    oled.FillScreen(COLOR_BLACK);
+
+    /* Display Text at (x=7,y=0) */
+    strcpy((char *) text,"Welcome");
+    oled.Label((uint8_t *)text,7,0);
+
+    /* Display text at (x=5,y=40) */ 
+    strcpy(text,"Initializing..");
+    oled.Label((uint8_t *)text,5,40);
+    /*
+    Thread::wait(3000);
+    
+    oled.FillScreen(COLOR_BLACK);
+    
+    strcpy((char *) text,"Functions List:");
+    oled.Label((uint8_t *)text,7,0);
+    
+    textProperties.fontColor   = COLOR_BLUE;
+    oled.SetTextProperties(&textProperties);
+    
+    
+    strcpy((char *) text,"Left:Bike Menu");
+    oled.Label((uint8_t *)text,0,15);
+    
+    
+    strcpy((char *) text,"Right:Biometrics");
+    oled.Label((uint8_t *)text,0,35);
+    */
+    Thread::wait(3000);
+    
+    
+    oled.FillScreen(COLOR_BLACK);
+    
+    textProperties.fontColor = COLOR_RED;
+    oled.SetTextProperties(&textProperties);   
+    
+    
+    strcpy((char *) text,"Temp:");
+    oled.Label((uint8_t *)text,5,15);
+    
+    //display Humidity-linked to while loop
+    strcpy((char *) text,"Humidity:");
+    oled.Label((uint8_t *)text,5,30);
+    
+    //display timer-linked to while loop for continuous readings
+    strcpy((char *) text,"Timer:");
+    oled.Label((uint8_t *)text,5,45);
+    
+    //display Humidity-linked to while loop
+   // strcpy((char *) text,"HR:");
+   // oled.Label((uint8_t *)text,5,60);
+    
+    
+      
+        
+    while(true)
+    {
+        sample_ftemp = temphumid.sample_ftemp();
+        sample_humid = temphumid.sample_humid();
+        sample_ftemp-=10;
+       // sample_HR = heart.getRevisionID();
+        
+        textProperties.fontColor = COLOR_WHITE;
+        textProperties.alignParam = OLED_TEXT_ALIGN_RIGHT;
+        oled.SetTextProperties(&textProperties);
+        
+        /* Format the value */
+        sprintf(text,"%d F",sample_ftemp);
+        /* Display time reading in 35px by 15px textbox at(x=55, y=40) */
+        oled.TextBox((uint8_t *)text,55,15,35,15); //Increase textbox for more digits
+        
+        /* Format the value */
+        sprintf(text,"%d %%",sample_humid);
+        /* Display time reading in 35px by 15px textbox at(x=55, y=40) */
+        oled.TextBox((uint8_t *)text,55,30,35,15); //Increase textbox for more digits
+        
+        sprintf(text,"%d s",counter); 
+        // Display time reading in 35px by 15px textbox at(x=55, y=40)
+        oled.TextBox((uint8_t *)text,55,45,35,15); //Increase textbox for more digits  
+        
+       // sprintf(text,"%d bpm",sample_HR); 
+        // Display time reading in 35px by 15px textbox at(x=55, y=40)
+        //oled.TextBox((uint8_t *)text,55,60,35,15); //Increase textbox for more digits  
+        //Thread::wait(300);     
+    }
+}
+void attime(void)
+{
+    counter++;    
+}
+void ButtonUp(void)
+{
+    StartHaptic();
+    Thread::wait(50); 
+    StartHaptic();
+    
+    redLed      = LED_ON;
+    greenLed    = LED_OFF;
+    blueLed     = LED_OFF;
+    
+    
+    if(flag==0)
+    {
+        timer.attach(&attime,1);
+        flag=1;
+    }
+    else
+    {
+        timer.detach();
+        counter=0;
+        flag=0;
+    }
+}
+
+void ButtonDown(void)
+{
+    StartHaptic();
+    Thread::wait(50); 
+    StartHaptic();
+    
+    redLed      = LED_OFF;
+    greenLed    = LED_ON;
+    blueLed     = LED_OFF;
+    
+    if(flag==0)
+    {
+        timer.attach(&attime,1);
+        flag=1;
+    }
+    else
+    {
+        timer.detach();
+        counter=0;
+        flag=0;
+    }
+}
+
+void ButtonRight(void)
+{
+    StartHaptic();
+    
+    redLed      = LED_OFF;
+    greenLed    = LED_OFF;
+    
+    blueLed     = LED_ON;
+}
+
+void ButtonLeft(void)
+{
+    StartHaptic();
+    
+    redLed      = LED_ON;
+    greenLed    = LED_ON;
+    blueLed     = LED_OFF;
+}
+
+void ButtonSlide(void)
+{
+    StartHaptic();
+    
+    redLed      = LED_ON;
+    greenLed    = LED_ON;
+    blueLed     = LED_ON;
+}
+
+void StartHaptic(void)
+{
+    hapticTimer.start(50);
+    haptic = 1;
+}
+
+void StopHaptic(void const *n) {
+    haptic = 0;
+    hapticTimer.stop();
+}
\ No newline at end of file
diff -r 000000000000 -r b9ba2cb49fbe mbed-os.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-os.lib	Mon Apr 30 18:06:25 2018 +0000
@@ -0,0 +1,1 @@
+https://github.com/ARMmbed/mbed-os/#f9ee4e849f8cbd64f1ec5fdd4ad256585a208360