Store in GIT
This commit is contained in:
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
Kamer.cpp
|
||||
Copyright (c) 2014 Kenneth van Ewijk. All right reserved.
|
||||
*/
|
||||
|
||||
// include this library's description file
|
||||
#include "Kamer.h"
|
||||
|
||||
Kamer::Kamer(void)
|
||||
{
|
||||
// initialize this instance's variables
|
||||
volume = 0;
|
||||
temp = 0;
|
||||
wallSurface = 0;
|
||||
windowSurface = 0;
|
||||
surfaceArea = 0;
|
||||
heatFlow = 0;
|
||||
deltaTemp = 0;
|
||||
}
|
||||
|
||||
|
||||
//Set Room Properties
|
||||
void Kamer::setVolume(int givenVolume)
|
||||
{
|
||||
volume = givenVolume;
|
||||
}
|
||||
|
||||
void Kamer::setTemp(double givenTemp)
|
||||
{
|
||||
temp = givenTemp;
|
||||
}
|
||||
|
||||
void Kamer::setSurfaceArea(int givenWall, int givenWindow)
|
||||
{
|
||||
wallSurface = givenWall;
|
||||
windowSurface = givenWindow;
|
||||
surfaceArea = wallSurface + windowSurface;
|
||||
}
|
||||
|
||||
|
||||
//Calc Room Properties
|
||||
void Kamer::calcTemp(int outsideTemp)
|
||||
{
|
||||
calcHeatFlow(outsideTemp);
|
||||
|
||||
deltaTemp = heatFlow / ( (volume * 1.43) * 920);
|
||||
double newTemp = temp - deltaTemp;
|
||||
|
||||
temp = newTemp;
|
||||
}
|
||||
|
||||
void Kamer::calcHeatFlow(int outsideTemp)
|
||||
{
|
||||
double deltaTemp2 = temp - outsideTemp;
|
||||
|
||||
//Make sure deltaTemp is positive
|
||||
double heatFlowWall = 0.6 * wallSurface * (deltaTemp2 / 20);
|
||||
double heatFlowIsolation = 0.08 * wallSurface * (deltaTemp2 / 0.5);
|
||||
|
||||
double heatFlowWallTotal = 1 / ( (1 / heatFlowWall) + (1 / heatFlowIsolation) );
|
||||
|
||||
double heatFlowWindow = 0.98 * windowSurface * (deltaTemp2 / 12);
|
||||
double heatFlowAir = 0.025 * windowSurface * (deltaTemp2 / 12);
|
||||
|
||||
double heatFlowWindowTotal = 1 / ( (1 / heatFlowWindow) + (1 / heatFlowAir) );
|
||||
|
||||
heatFlow = heatFlowWindowTotal + heatFlowWallTotal;
|
||||
heatFlow = heatFlow * 60;
|
||||
}
|
||||
|
||||
|
||||
//Get Room Properties
|
||||
int Kamer::getVolume(void)
|
||||
{
|
||||
return volume;
|
||||
}
|
||||
|
||||
double Kamer::getTemp(void)
|
||||
{
|
||||
return temp;
|
||||
}
|
||||
|
||||
int Kamer::getSurfaceArea(void)
|
||||
{
|
||||
return surfaceArea;
|
||||
}
|
||||
|
||||
double Kamer::getHeatFlow(void)
|
||||
{
|
||||
return heatFlow;
|
||||
}
|
||||
|
||||
double Kamer::getDeltaTemp(void)
|
||||
{
|
||||
return deltaTemp;
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
Kamer.h
|
||||
Copyright (c) 2014 Kenneth van Ewijk. All right reserved.
|
||||
*/
|
||||
|
||||
// ensure this library description is only included once
|
||||
#ifndef Kamer_h
|
||||
#define Kamer_h
|
||||
|
||||
// library interface description
|
||||
class Kamer
|
||||
{
|
||||
// user-accessible "public" interface
|
||||
public:
|
||||
Kamer(void);
|
||||
void setVolume(int);
|
||||
void setTemp(double);
|
||||
void setSurfaceArea(int, int);
|
||||
void calcTemp(int);
|
||||
int getVolume(void);
|
||||
double getTemp(void);
|
||||
int getSurfaceArea(void);
|
||||
double getHeatFlow(void);
|
||||
double getDeltaTemp(void);
|
||||
// code-accessible "private" interface
|
||||
private:
|
||||
void calcHeatFlow(int);
|
||||
int volume;
|
||||
double temp;
|
||||
int wallSurface;
|
||||
int windowSurface;
|
||||
int surfaceArea;
|
||||
double heatFlow;
|
||||
double deltaTemp;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,56 @@
|
||||
#include <Kamer.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
|
||||
#define _USE_MATH_DEFINES
|
||||
|
||||
// Library for "Kamer"
|
||||
// by Kenneth van Ewijk <http://www.kennyboy.nl>
|
||||
|
||||
// Demostrates how to do something with the Kamer library
|
||||
|
||||
// Created 16 February 2014
|
||||
|
||||
Kamer slaapkamer = Kamer();
|
||||
int volume;
|
||||
int temp;
|
||||
int surfaceArea;
|
||||
int outsideTemp;
|
||||
int timer;
|
||||
int dag = 0;
|
||||
int rd = rand();
|
||||
int eq;
|
||||
int amp;
|
||||
|
||||
void setup()
|
||||
{
|
||||
timer = 0;
|
||||
slaapkamer.setVolume(40);
|
||||
slaapkamer.setTemp(21);
|
||||
slaapkamer.setSurfaceArea(15, 3);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
int uur = timer / (3600);
|
||||
int newdag = uur / 24;
|
||||
|
||||
if(newdag > dag){
|
||||
rd = rand();
|
||||
dag = newdag;
|
||||
|
||||
eq = 9- ((1/6) * dag) + (5 * rd);
|
||||
amp = (rd * 9) + 3;
|
||||
}
|
||||
|
||||
int per = (2 * M_PI) / 24;
|
||||
|
||||
outsideTemp = eq + amp * sin( per * timer);
|
||||
|
||||
slaapkamer.calcTemp(outsideTemp);
|
||||
temp = slaapkamer.getTemp();
|
||||
|
||||
++timer;
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
Kamer KEYWORD1
|
||||
|
||||
setVolume KEYWORD2
|
||||
setTemp KEYWORD2
|
||||
setSurfaceArea KEYWORD2
|
||||
|
||||
calcTemp KEYWORD2
|
||||
calcHeatFlow KEYWORD2
|
||||
|
||||
getVolume KEYWORD2
|
||||
getTemp KEYWORD2
|
||||
getSurfaceArea KEYWORD2
|
||||
@@ -0,0 +1,39 @@
|
||||
This is an example C++ library for Arduino 0004+, based on one created by
|
||||
Nicholas Zambetti for Wiring 0006+
|
||||
|
||||
Installation
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
To install this library, just place this entire folder as a subfolder in your
|
||||
Arduino/lib/targets/libraries folder.
|
||||
|
||||
When installed, this library should look like:
|
||||
|
||||
Arduino/lib/targets/libraries/Test (this library's folder)
|
||||
Arduino/lib/targets/libraries/Test/Test.cpp (the library implementation file)
|
||||
Arduino/lib/targets/libraries/Test/Test.h (the library description file)
|
||||
Arduino/lib/targets/libraries/Test/keywords.txt (the syntax coloring file)
|
||||
Arduino/lib/targets/libraries/Test/examples (the examples in the "open" menu)
|
||||
Arduino/lib/targets/libraries/Test/readme.txt (this file)
|
||||
|
||||
Building
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
After this library is installed, you just have to start the Arduino application.
|
||||
You may see a few warning messages as it's built.
|
||||
|
||||
To use this library in a sketch, go to the Sketch | Import Library menu and
|
||||
select Test. This will add a corresponding line to the top of your sketch:
|
||||
#include <Test.h>
|
||||
|
||||
To stop using this library, delete that line from your sketch.
|
||||
|
||||
Geeky information:
|
||||
After a successful build of this library, a new file named "Test.o" will appear
|
||||
in "Arduino/lib/targets/libraries/Test". This file is the built/compiled library
|
||||
code.
|
||||
|
||||
If you choose to modify the code for this library (i.e. "Test.cpp" or "Test.h"),
|
||||
then you must first 'unbuild' this library by deleting the "Test.o" file. The
|
||||
new "Test.o" with your code will appear after the next press of "verify"
|
||||
|
||||
Reference in New Issue
Block a user