Taiyo Mineo / GraphicHandler

Dependencies:   C12832_lcd LCD_fonts

Files at this revision

API Documentation at this revision

Comitter:
yukari_hinata
Date:
Sun Feb 15 09:27:58 2015 +0000
Parent:
1:4399eaceb999
Child:
3:3569342a4ab0
Commit message:
modified.

Changed in this revision

GraphicHandler.cpp Show annotated file Show diff for this revision Revisions of this file
GraphicHandler.hpp Show annotated file Show diff for this revision Revisions of this file
main.cpp Show diff for this revision Revisions of this file
mbed.bld Show diff for this revision Revisions of this file
--- a/GraphicHandler.cpp	Wed Jan 28 15:52:09 2015 +0000
+++ b/GraphicHandler.cpp	Sun Feb 15 09:27:58 2015 +0000
@@ -12,6 +12,7 @@
     now_data        = new float[data_dimension];
     predict_data    = new float[data_dimension * predict_length];
     predict_weather = new int[predict_length];
+    predict_probability = new float[predict_length];
 
     // ティッカー初期化
     time_ticker.attach(this, &GraphicHandler::update_time, 60.0);
@@ -37,16 +38,18 @@
 {
     delete [] now_data;
     delete [] predict_data;
+    delete [] predict_probability;
     delete [] predict_weather;
     delete joy_left;
     delete joy_right;
 }
 
 // 予測データと天気のセット
-void GraphicHandler::set_predict_data(float* predict_data, int* predict_weather)
+void GraphicHandler::set_predict_data(float* predict_data, int* predict_weather, float* predict_probability)
 {
     memcpy(this->predict_data, predict_data, sizeof(float) * data_dimension * predict_length);
     memcpy(this->predict_weather, predict_weather, sizeof(int) * predict_length);
+    memcpy(this->predict_probability, predict_probability, sizeof(float) * predict_length);
 }
 
 // 観測データのセット
@@ -124,7 +127,7 @@
         draw_data_at(predict_data[base_index + 1], "%%", (unsigned char *)Small_7, 37, 12);
         draw_data_at(predict_data[base_index + 2], "hPa", (unsigned char *)Small_7, 37, 20);
         draw_weather_bitmap_at(predict_weather[current_display_no-1], current_image_no, 87, 2);
-        // draw_percentage_at(0.5, (unsigned char *)Small_6, 112, 25);
+        draw_percentage_at(predict_probability[current_display_no-1], (unsigned char *)Small_6, 112, 25);
         // 予測時刻
         draw_time_at((unsigned char *)Arial_9, seq_time_interval * current_display_no, 5, 10);
     }
@@ -197,49 +200,50 @@
 }
 
 // 天候の描画ルーチン
-    void GraphicHandler::draw_weather_bitmap_at(int weather_id,
-            int image_no,
-            int x, int y) {
-        Bitmap buffer;
+void GraphicHandler::draw_weather_bitmap_at(int weather_id,
+        int image_no,
+        int x, int y)
+{
+    Bitmap buffer;
 
-        // lcd.setmode(XOR);
-        // ビットマップ選択
-        switch(weather_id) {
-            case SHINY:
-                // 番号についても場合分けだよ!
-                if (image_no == 0) {
-                    buffer = bitm_shiny1;
-                } else if (image_no == 1) {
-                    buffer = bitm_shiny2;
-                }
-                break;
-            case CLOUDY:
-                if (image_no == 0) {
-                    buffer = bitm_cloudy1;
-                } else if (image_no == 1) {
-                    buffer = bitm_cloudy2;
-                }
-                break;
-            case RAINY:
-                if (image_no == 0) {
-                    buffer = bitm_rainy1;
-                } else if (image_no == 1) {
-                    buffer = bitm_rainy2;
-                }
-                break;
-            case SNOWY:
-                if (image_no == 0) {
-                    buffer = bitm_snowy1;
-                } else if (image_no == 1) {
-                    buffer = bitm_snowy2;
-                }
-                break;
-            default:
-                fprintf(stderr, "ERROR : weather drawing \r\n");
-                break;
-        }
-        // 描画
-        lcd.print_bm(buffer, x, y);
-        lcd.copy_to_lcd();
-        return;
+    // lcd.setmode(XOR);
+    // ビットマップ選択
+    switch(weather_id) {
+        case SHINY:
+            // 番号についても場合分けだよ!
+            if (image_no == 0) {
+                buffer = bitm_shiny1;
+            } else if (image_no == 1) {
+                buffer = bitm_shiny2;
+            }
+            break;
+        case CLOUDY:
+            if (image_no == 0) {
+                buffer = bitm_cloudy1;
+            } else if (image_no == 1) {
+                buffer = bitm_cloudy2;
+            }
+            break;
+        case RAINY:
+            if (image_no == 0) {
+                buffer = bitm_rainy1;
+            } else if (image_no == 1) {
+                buffer = bitm_rainy2;
+            }
+            break;
+        case SNOWY:
+            if (image_no == 0) {
+                buffer = bitm_snowy1;
+            } else if (image_no == 1) {
+                buffer = bitm_snowy2;
+            }
+            break;
+        default:
+            fprintf(stderr, "ERROR : weather drawing \r\n");
+            break;
     }
+    // 描画
+    lcd.print_bm(buffer, x, y);
+    lcd.copy_to_lcd();
+    return;
+}
--- a/GraphicHandler.hpp	Wed Jan 28 15:52:09 2015 +0000
+++ b/GraphicHandler.hpp	Sun Feb 15 09:27:58 2015 +0000
@@ -6,14 +6,7 @@
 #include "Arial_9.h"
 #include "Small_7.h"
 #include "Small_6.h"
-
-// 天候を表す -> どこかのヘッダに記述予定
-typedef enum {
-    SHINY,
-    CLOUDY,
-    RAINY,
-    SNOWY,
-} WEATHER_STATUS;
+#include "share.hpp"
 
 // 表示モード
 typedef enum {
@@ -33,6 +26,7 @@
     int         current_display_no; // 現在の画面No
     int         current_image_no;   // 現在のビットマップNo
     float*      predict_data;       // 予測データ
+    float*      predict_probability;// 予測天候確率
     int*        predict_weather;    // 予測天候の列
     Ticker      time_ticker;        // 時間更新用のティッカー
     Ticker      image_ticker;       // ビットマップアニメーションのティッカー
@@ -50,7 +44,8 @@
                                    
     // 予測データと天候のセット.
     void set_predict_data(float*, // 予測データ 
-                          int*);  // 予測天候
+                          int*,   // 予測天候
+                          float*);// 予測確率  
                           
     // 現在の観測データのセット
     void set_now_data(float*);    // 観測データ
--- a/main.cpp	Wed Jan 28 15:52:09 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,16 +0,0 @@
-#include "mbed.h"
-#include "GraphicHandler.hpp"
-
-int main(void) {
-    GraphicHandler gh(3,30,3);
-    float now_test[] = {20.0, 50.0, 1000.0};
-    float predict_test[] = {21.0, 51.0, 1010.0, 22.0, 52.0, 1020.0, 23.0, 53.0, 1030.0};
-    int weather_test[] = { SHINY, CLOUDY, RAINY };
-    gh.set_now_data(now_test);
-    gh.set_predict_data(predict_test, weather_test);
-    gh.update_last_learned_time();
-    while (true) {
-        gh.update_draw();
-        wait(1.0);
-    }
-}
--- a/mbed.bld	Wed Jan 28 15:52:09 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/4fc01daae5a5
\ No newline at end of file