StarBoard Orange - Example application No.1 GoogleChartLogger with StarBoard Orange

Dependencies:   EthernetNetIf mbed

Files at this revision

API Documentation at this revision

Comitter:
shintamainjp
Date:
Wed Aug 11 10:24:25 2010 +0000
Parent:
0:77d8b45a8f42
Commit message:

Changed in this revision

Sensor/SensorDummy.cpp Show annotated file Show diff for this revision Revisions of this file
Sensor/SensorDummy.h 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 77d8b45a8f42 -r 123eff9ba7b2 Sensor/SensorDummy.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Sensor/SensorDummy.cpp	Wed Aug 11 10:24:25 2010 +0000
@@ -0,0 +1,27 @@
+/**
+ * Sensor interface driver. (Version 0.0.1)
+ *
+ * Copyright (C) 2010 Shinichiro Nakamura (CuBeatSystems)
+ * http://shinta.main.jp/
+ */
+
+#include "SensorDummy.h"
+
+SensorDummy::SensorDummy() : memory(getNextValue(MIN + ((MAX - MIN)/2))) {}
+SensorDummy::~SensorDummy() {}
+
+double SensorDummy::read() {
+    memory = getNextValue(memory);
+    return memory;
+}
+
+double SensorDummy::getNextValue(double prev) {
+    static const int THR = 5;
+    int SCOPE = (MAX - MIN) + 1;
+    int tmp = 0;
+    do {
+        tmp = (rand() % SCOPE) + MIN;
+    } while (THR < abs(tmp - prev));
+    int udt = rand() % 10;
+    return (double)tmp + (double)(udt * 0.1);
+}
diff -r 77d8b45a8f42 -r 123eff9ba7b2 Sensor/SensorDummy.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Sensor/SensorDummy.h	Wed Aug 11 10:24:25 2010 +0000
@@ -0,0 +1,28 @@
+/**
+ * Sensor interface driver. (Version 0.0.1)
+ *
+ * Copyright (C) 2010 Shinichiro Nakamura (CuBeatSystems)
+ * http://shinta.main.jp/
+ */
+
+#ifndef _SENSOR_DUMMY_H_
+#define _SENSOR_DUMMY_H_
+
+#include <mbed.h>
+
+#include "Sensor.h"
+
+class SensorDummy : public Sensor {
+public:
+    SensorDummy();
+    virtual ~SensorDummy();
+    virtual double read();
+private:
+    static const int MIN = -10;
+    static const int MAX = 50;
+    double memory;
+    
+    static double getNextValue(double prev);
+};
+
+#endif
diff -r 77d8b45a8f42 -r 123eff9ba7b2 main.cpp
--- a/main.cpp	Wed Aug 11 01:53:35 2010 +0000
+++ b/main.cpp	Wed Aug 11 10:24:25 2010 +0000
@@ -1,12 +1,12 @@
 /**
  * StarBoard Orange - Example application No.1 (Version 0.0.1)
- *
  * GoogleChartLogger with StarBoard Orange
+ * See also ... http://mbed.org/users/shintamainjp/notebook/starboard_example1_ja/
+ * See also ... http://mbed.org/users/shintamainjp/notebook/starboard_example1_en/
  *
  * Copyright (C) 2010 Shinichiro Nakamura (CuBeatSystems)
  * http://shinta.main.jp/
  */
-
 #include "mbed.h"
 #include "SDFileSystem.h"
 #include "TextLCD.h"
@@ -15,6 +15,7 @@
 #include "SensorLM60.h"
 #include "SensorLM35.h"
 #include "SensorMCP9700.h"
+#include "SensorDummy.h"
 #include "GoogleChartLineChart.h"
 
 #define SUPERTWEET_ACCOUNT  "YourAccount"
@@ -181,7 +182,6 @@
     chart.setDataScale(dsn1, TEMP_LOW, TEMP_HIGH);
     chart.setDataScale(dsn2, TEMP_LOW, TEMP_HIGH);
 
-
     /*
      * Set date and time. (If you want.)
      *