LCD RGB

Dependents:   Prg_TP_CAN

Fork of Dashboard by Karim EL GHARBI

Files at this revision

API Documentation at this revision

Comitter:
KEG
Date:
Tue Jun 05 16:22:55 2018 +0000
Parent:
0:a0ef433339ff
Commit message:
Prog Final

Changed in this revision

Dashboard.cpp Show annotated file Show diff for this revision Revisions of this file
Dashboard.h Show annotated file Show diff for this revision Revisions of this file
diff -r a0ef433339ff -r 666c0aa82871 Dashboard.cpp
--- a/Dashboard.cpp	Tue Jun 05 07:41:18 2018 +0000
+++ b/Dashboard.cpp	Tue Jun 05 16:22:55 2018 +0000
@@ -1,17 +1,34 @@
 #include "mbed.h"
 #include "Dashboard.h"
+#include <string>
 
 Dashboard::Dashboard(PinName sda, PinName scl):Grove_LCD_RGB_Backlight(sda,scl)
 {
-    //Grove_LCD_RGB_Backlight(sda,scl);
     this->init();
 };
 
-void Dashboard::printData(char *str)
+void Dashboard::printData(signed char *str)
 {
-    char* result;
-    sprintf(result, "T: %d  P: %d H: %d",str[0],(str[1]<<8) + str[2],str[3]);
+    char result[32];
+    signed char temperature = str[0];
+    char hygrometrie = str[3];
+    int pression = (str[1]<<8) + str[2];
+    
+    sprintf(result, "T: %d  H: %d",temperature,hygrometrie);
+    this->locate(0,0);
     this->print(result);
+    
+    sprintf(result, "P : %d",pression);
+    this->locate(0,1);
+    this->print(result);
+}
+
+void Dashboard::changeColor(signed char temp)
+{
+    if(temp<0){
+        temp=temp+10;
+    }
+    this->setRGB(temp,0,40-temp);
 }
 
 
diff -r a0ef433339ff -r 666c0aa82871 Dashboard.h
--- a/Dashboard.h	Tue Jun 05 07:41:18 2018 +0000
+++ b/Dashboard.h	Tue Jun 05 16:22:55 2018 +0000
@@ -7,5 +7,6 @@
     //Contructor
     Dashboard(PinName sda, PinName scl);
     //print T°C + P[hPa] + H[%]
-    void printData(char *dataToPrint);
+    void printData(signed char *dataToPrint);
+    void changeColor(signed char temp);
 };
\ No newline at end of file