Store in GIT
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
Weer.cpp
|
||||
Copyright (c) 2014 Kenneth van Ewijk. All right reserved.
|
||||
*/
|
||||
|
||||
// include this library's description file
|
||||
#include "Weer.h"
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#define _USE_MATH_DEFINES
|
||||
|
||||
Weer::Weer(void)
|
||||
{
|
||||
// initialize this instance's variables
|
||||
min = 0;
|
||||
newdag = 0;
|
||||
dag = 0;
|
||||
rd = 0;
|
||||
rd2 = 0;
|
||||
amp = 0;
|
||||
outsideTemp = 0;
|
||||
eq = 0;
|
||||
}
|
||||
|
||||
void Weer::setTemp(double givenTemp)
|
||||
{
|
||||
outsideTemp = givenTemp;
|
||||
}
|
||||
|
||||
void Weer::calcTemp(int timer){
|
||||
min = timer;
|
||||
newdag = floor(min / 3600) + 1;
|
||||
|
||||
if(newdag > dag){
|
||||
rd = ((double) rand() / (RAND_MAX));
|
||||
rd2 = round(rd * 5);
|
||||
dag = newdag;
|
||||
|
||||
eq = 9- ((1/6) * dag) + rd2;
|
||||
amp = (rd * 9) + 3;
|
||||
}
|
||||
|
||||
outsideTemp = eq + (amp * sin( ((2 * M_PI) / 3600) * (min - 900)) );
|
||||
}
|
||||
|
||||
double Weer::getTemp(void)
|
||||
{
|
||||
return outsideTemp;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
Weer.h
|
||||
Copyright (c) 2014 Kenneth van Ewijk. All right reserved.
|
||||
*/
|
||||
|
||||
// ensure this library description is only included once
|
||||
#ifndef Weer_h
|
||||
#define Weer_h
|
||||
|
||||
// library interface description
|
||||
class Weer
|
||||
{
|
||||
// user-accessible "public" interface
|
||||
public:
|
||||
Weer(void);
|
||||
void setTemp(double);
|
||||
void calcTemp(int);
|
||||
double getTemp(void);
|
||||
private:
|
||||
int min;
|
||||
int newdag;
|
||||
int dag;
|
||||
double rd;
|
||||
double rd2;
|
||||
double amp;
|
||||
double outsideTemp;
|
||||
double eq;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,24 @@
|
||||
#include <Weer.h>
|
||||
|
||||
// Library for "Weer"
|
||||
// by Kenneth van Ewijk <http://www.kennyboy.nl>
|
||||
|
||||
// Demostrates how to do something with the Weer library
|
||||
|
||||
// Created 16 February 2014
|
||||
|
||||
Weer weer = Weer();
|
||||
int timer = 0;
|
||||
int temp = 0;
|
||||
|
||||
void setup()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
temp = weer.getTemp(timer);
|
||||
++timer;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
Weer KEYWORD1
|
||||
|
||||
getTemp KEYWORD2
|
||||
setTemp 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