ThermistorPack.
Dependents: Pachube_TestProgram ThermistorPack_TestProgram _DearMrJeffMourich StarBoardOrangeExpansion2 ... more
Diff: ThermistorDummy.cpp
- Revision:
- 0:ac6a05fefa2f
- Child:
- 1:4f84f03b1703
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ThermistorDummy.cpp Fri Sep 17 23:42:46 2010 +0000 @@ -0,0 +1,31 @@ +/** + * Sensor interface driver. (Version 0.0.1) + * + * Copyright (C) 2010 Shinichiro Nakamura (CuBeatSystems) + * http://shinta.main.jp/ + */ + +#include "ThermistorDummy.h" + +ThermistorDummy::ThermistorDummy() + : memory(getNextValue(MIN + ((MAX - MIN)/2))) { +} + +ThermistorDummy::~ThermistorDummy() { +} + +double ThermistorDummy::read() { + memory = getNextValue(memory); + return memory; +} + +double ThermistorDummy::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); +}