Strength of Irradiance and the UV Index chart page added

Dependencies:   TFT_fonts UniGraphic VEML6075 mbed vt100

Fork of quattro_vishay_6075 by quattro_dev

This is a forked version of quattro_vishay_6075.
An additional Strength of Irradiance and the UV Index page added.

NOTE: Please update the VEML6075.lib before compile.

/media/uploads/Rhyme/img_2118.jpg

Files at this revision

API Documentation at this revision

Comitter:
Rhyme
Date:
Wed Oct 18 05:19:39 2017 +0000
Parent:
0:11b872c2badc
Commit message:
Strength of Irradiance and the UV Index page added

Changed in this revision

UniGraphic.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
diff -r 11b872c2badc -r 6b82f17ff8e0 UniGraphic.lib
--- a/UniGraphic.lib	Fri Feb 05 02:30:50 2016 +0000
+++ b/UniGraphic.lib	Wed Oct 18 05:19:39 2017 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/teams/GraphicsDisplay/code/UniGraphic/#87855d03d91a
+http://mbed.org/teams/GraphicsDisplay/code/UniGraphic/#f87f06292637
diff -r 11b872c2badc -r 6b82f17ff8e0 main.cpp
--- a/main.cpp	Fri Feb 05 02:30:50 2016 +0000
+++ b/main.cpp	Wed Oct 18 05:19:39 2017 +0000
@@ -186,19 +186,19 @@
     float fUVB_CIE = 0.0 ;
     float uvi = 0 ;
  
-    veml->setUVConf(uvconf) ;
-    veml->getUVConf(&uvconf) ;
-    veml->getID(&id) ;
+    veml6075->setUVConf(uvconf) ;
+    veml6075->getUVConf(&uvconf) ;
+    veml6075->getID(&id) ;
     
-    veml->getUVAData(&uvadata) ;
-    veml->getUVBData(&uvbdata) ;
-    veml->getUVCOMP1Data(&uvcomp1data) ;
-    veml->getUVCOMP2Data(&uvcomp2data) ;
-    fUVA = veml->getUVA() ;
-    fUVA_CIE = veml->getUVA_CIE() ;
-    fUVB = veml->getUVB() ;
-    fUVB_CIE = veml->getUVB_CIE() ;
-    uvi = veml->UVI() ;
+    veml6075->getUVAData(&uvadata) ;
+    veml6075->getUVBData(&uvbdata) ;
+    veml6075->getUVCOMP1Data(&uvcomp1data) ;
+    veml6075->getUVCOMP2Data(&uvcomp2data) ;
+    fUVA = veml6075->getUVA() ;
+    fUVA_CIE = veml6075->getUVA_CIE() ;
+    fUVB = veml6075->getUVB() ;
+    fUVB_CIE = veml6075->getUVB_CIE() ;
+    uvi = veml6075->UVI() ;
     
     TFT.foreground(White);
     TFT.locate(x+30, y) ;
@@ -243,6 +243,109 @@
 //    reportVEML6040(veml6040, 5, 10) ;
 }
 
+void drawUVIArrow(float value, uint16_t color)
+{
+    int x, y ;
+    x = 116 ;
+    y = 110 - (value * 8.0) ;
+    if (y > 108) y = 108 ;
+    if (y < 17) y = 17 ;
+    TFT.line(x, y, x+7, y, color) ;
+    TFT.line(x, y, x+2, y-2, color) ;
+    TFT.line(x, y, x+2, y+2, color) ;
+}
+/*
+ * UV index
+ * 11~ Extreme
+ * 8~10 Very High
+ * 6~7 High
+ * 3~5 Moderate
+ * 0~2 Low
+ */
+void drawUVIFrame(void)
+{
+    int x, y, i ;
+    uint16_t color ;
+     
+    TFT.set_font((unsigned char*) Terminal6x8);
+    
+    TFT.rect(0, 0, 127, 111, White) ;
+    TFT.line(32, 0, 32, 111, White) ;
+    TFT.line(96, 0, 96, 111, White) ;
+    TFT.line(0, 16, 127, 16, White) ;
+    color = Purple ;
+    TFT.fillrect(33, 17, 95,  33, color) ; /* extreme */
+    TFT.locate(44, 21) ; TFT.background(color) ;
+    TFT.printf("Extreme") ;
+    color = Red ;
+    TFT.fillrect(33, 34, 95,  54, color) ;
+    TFT.locate(38, 40) ; TFT.background(color) ;
+    TFT.printf("Very High") ;
+    color = Orange ;
+    TFT.fillrect(33, 55, 95,  70, color) ;
+    TFT.locate(50, 59) ; TFT.background(color) ;
+        TFT.foreground(Black) ;
+    TFT.printf("High") ;
+    color = Yellow ;
+    TFT.fillrect(33, 71, 95,  95, color) ;
+    TFT.locate(40, 79) ; TFT.background(color) ;
+    TFT.printf("Moderate") ;
+
+    color = Green ;
+    TFT.fillrect(33, 96, 95, 110, color) ;
+    TFT.locate(56, 100) ; TFT.background(color) ;
+    TFT.printf("Low") ;
+    
+    TFT.foreground(White) ;    
+    TFT.background(Black) ;
+    TFT.locate(10, 6) ;
+    TFT.printf("Ee") ;
+    TFT.locate(40, 6) ;
+    TFT.printf("Strength") ;
+    TFT.locate(102, 6) ;
+    TFT.printf("UVI") ;
+
+    i = 1 ;
+    for (y = 111 - 8 ; y > 16 ; y -= 8) {
+        TFT.line(28, y, 34, y, White) ;
+        TFT.line(94, y, 100, y, White) ;
+        TFT.locate(102, y-4) ; TFT.printf("%2d",i) ;
+        i++ ;
+    }
+    TFT.locate(8, 100) ; TFT.printf("0.0") ;
+    TFT.locate(8, 76)  ; TFT.printf("0.1") ;
+    TFT.locate(8, 46)  ; TFT.printf("0.2") ;
+    TFT.locate(8, 18)  ; TFT.printf("0.3") ;
+}
+
+void drawVemlUVI(void)
+{
+    uint8_t uvconf = 0x00 ;
+    float uvi = 0 ;
+    static float prev_uvi = 0 ;
+ 
+    veml6075->setUVConf(uvconf) ;
+    veml6075->getUVConf(&uvconf) ;
+    uvi = veml6075->UVI() ;
+    
+    TFT.set_font((unsigned char*) Terminal6x8);
+    TFT.locate(16, 117) ; 
+    TFT.printf("UV Index = %2.3f", uvi) ;
+    drawUVIArrow(prev_uvi, Black) ;
+    drawUVIArrow(uvi, White) ;
+    prev_uvi = uvi ;
+}
+
+void doDrawUVI(void)
+{
+    if (prevPage != page) {
+       TFT.cls() ;
+       wait(0.5) ;
+       drawUVIFrame() ;
+    }
+    drawVemlUVI() ;
+}
+
 double clip(double src)
 {
     double value ;
@@ -270,9 +373,9 @@
         break ;
     case 2:
           doReportVeml() ;
-//         if (page != prevPage) {
-//            doPict(ojizo) ;
-//        }
+        break ;
+    case 3:
+        doDrawUVI() ;
         break ;
     default:
         page = 0 ;