Dependencies:   mbed m3pi FreeRTOS

Files at this revision

API Documentation at this revision

Comitter:
JoaoJardim
Date:
Wed Dec 05 17:56:16 2018 +0000
Parent:
3:d577dbef65a2
Commit message:
m3pi with RN41XVC-I/RM

Changed in this revision

m3pi.lib 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.bld Show annotated file Show diff for this revision Revisions of this file
diff -r d577dbef65a2 -r 33929b1afb80 m3pi.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/m3pi.lib	Wed Dec 05 17:56:16 2018 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/chris/code/m3pi/#4b7d6ea9b35b
diff -r d577dbef65a2 -r 33929b1afb80 main.cpp
--- a/main.cpp	Sun Sep 13 11:33:05 2015 +0000
+++ b/main.cpp	Wed Dec 05 17:56:16 2018 +0000
@@ -5,34 +5,64 @@
 #include "mbed.h"
 #include "FreeRTOS.h"
 #include "task.h"
+#include "m3pi.h"
+
+m3pi m3pi;
 
 DigitalOut led1(LED1);
 DigitalOut led2(LED2);
 
-void Task1 (void* pvParameters)
+Serial rn41(p28,p27); // Serial rn41(p9,p10);
+
+
+const portTickType xDelay = 100 / portTICK_RATE_MS;
+
+const float fVref = 4.0;
+
+
+void TaskBluetooth (void* pvParameters)
 {       
     (void) pvParameters;                    // Just to stop compiler warnings.   
+    
+    char *cBufferBT;    
+    
+    rn41.baud(115200);
+    led1 = 1;
+    led2 = 1;   
+    
     for (;;) {
+        
+        if(m3pi.battery() < fVref) {
+            m3pi.cls();
+            m3pi.locate(0,0);
+            m3pi.print("Low Pwr!", 8);            
+        }        
+        else{
+            m3pi.cls();
+            m3pi.locate(0,0);
+            m3pi.print("BT Task", 8);
+        }
+         
+        if (rn41.readable()) {          // When BT is readable
+        
+            sprintf(cBufferBT, "%d", rn41.getc());    // Reads Bluetooth
+            m3pi.locate(0,1);           // Prints the received message on the LCD
+            m3pi.print(cBufferBT, 8);
+            
+            rn41.putc(6);   // Send message to the BT terminal
+            led2 = !led2;
+        } 
+            
         led1 = !led1;
-        printf("Task1\n");
-        vTaskDelay(500);
+        vTaskDelay(xDelay);
     }
 }
 
-void Task2 (void* pvParameters)
-{
-    (void) pvParameters;                    // Just to stop compiler warnings.
-    for (;;) {
-        led2= !led2;
-        printf("Task2\n");
-        vTaskDelay(5000);
-    }
-}
+
 
 int main (void)
 {
-    xTaskCreate( Task1, ( signed char * ) "Task1", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, ( xTaskHandle * ) NULL );
-    xTaskCreate( Task2, ( signed char * ) "Task2", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, ( xTaskHandle * ) NULL );
+    xTaskCreate( TaskBluetooth, ( signed char * ) "TaskBluetooth", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, ( xTaskHandle * ) NULL );
     vTaskStartScheduler();
    //should never get here
    printf("ERORR: vTaskStartScheduler returned!");
diff -r d577dbef65a2 -r 33929b1afb80 mbed.bld
--- a/mbed.bld	Sun Sep 13 11:33:05 2015 +0000
+++ b/mbed.bld	Wed Dec 05 17:56:16 2018 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/ba1f97679dad
\ No newline at end of file
+https://os.mbed.com/users/mbed_official/code/mbed/builds/3a7713b1edbc
\ No newline at end of file