StarBoard Orange - Example application No.1 GoogleChartLogger with StarBoard Orange
Dependencies: EthernetNetIf mbed
Sensor/SensorDummy.cpp
- Committer:
- shintamainjp
- Date:
- 2010-08-11
- Revision:
- 1:123eff9ba7b2
File content as of revision 1:123eff9ba7b2:
/** * 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); }