xxxxxxxxxx
240
/************************************************/
/* Change programm just by the following values */
/************************************************/
// Sensebox1 Data
senseBoxID1 = "5f324b06a4a11c001b303e28"; // put here the SenseboxID and use quotationmarks
sensorNumber1_Box1 = 0; // the number of the sensor you want to display. The first one is zero
labelSensorValue1_Box1 = " °C"; // Enter the label of the sensor
sensorNumber2_Box1 = 1; // the number of the sensor you want to display. The first one is zero
labelSensorValue2_Box1 = " %"; // Enter the label of the sensor
labelDescriptionBox1 = "Glasgow, Scottland"; // Enter the descriptionlabelin the bottom line
// Sensebox2 Data
senseBoxID2 = "5b38de4a1fef04001b738c2d"; // put here the SenseboxID and use quotationmarks
sensorNumber1_Box2 = 2; // the number of the sensor you want to display. The first one is zero
labelSensorValue1_Box2 = " °C"; // Enter the label of the sensor
sensorNumber2_Box2 = 3; // the number of the sensor you want to display. The first one is zero
labelSensorValue2_Box2 = " %"; // Enter the label of the sensor
labelDescriptionBox2 = "Naples, Italy"; // Enter the descriptionlabelin the bottom line
// Sensebox3 Data
senseBoxID3 = "5d6e465a953683001a2b62c5"; // put here the SenseboxID and use quotationmarks
sensorNumber1_Box3 = 0; // the number of the sensor you want to display. The first one is zero
labelSensorValue1_Box3 = " °C"; // Enter the label of the sensor
sensorNumber2_Box3 = 1; // the number of the sensor you want to display. The first one is zero
labelSensorValue2_Box3 = " %"; // Enter the label of the sensor
labelDescriptionBox3 = "Berlin, Germany"; // Enter the descriptionlabelin the bottom line
headlineText = "Flowers grow with rising temperature and loose petals with falling humidity"
/************************************************/
function draw() {
background(155); // set Backround color
fill(255); // color headline
textSize(20); // size headline
text(headlineText, 20, 40); // show headline
// Flower test flower
xPosition = 200; // set x-position
yPosition = 200; // set y-position
size = 40; // set size, can get connected with sensorvalue
petalColor = color(255, 0, 255); // set petal color RGB (Red, Green, Blue), 0-255
lookOfPetals = 0.75; // changes the look. should be between 0.5 to 2
showStrokes = true; // true: strokes activated, false: strokes deactivated
strokeColor = color(100, 100, 255); // set stroke color RGB (Red, Green, Blue), 0-255
centerColor = color(255, 165, 0); // set center color RGB (Red, Green, Blue), 0-255
stemLength = 150; // sets the Length of the stems
stemColor = color(0, 136, 0); // set color of stem RGB (Red, Green, Blue), 0-255
numberOfPetals = 13; // set number of petals
skipPetals = 0; // the flower can loose petals, can get connected with sensorvalue
sensor1 = "not found";
sensor1Label = "!";
sensor2 = "";
sensor2Label = "";
descriptionLabel = "Test Flower";
textColor = color(0, 0, 0); // set textcolor
sizeOfText = 30; // set textsize
drawAFlower(xPosition, yPosition, size, petalColor, lookOfPetals, centerColor, showStrokes, strokeColor, stemLength, stemColor, numberOfPetals, skipPetals, sensor1, sensor1Label, sensor2, sensor2Label, descriptionLabel, textColor, sizeOfText);
// Flower sensebox1
xPosition = 700;
yPosition = 200;
size = map(sensorValue1_Box1, -5, 35, 20, 80);
petalColor = color(255, 255, 255); // set petal color RGB
lookOfPetals = 1;
showStrokes = true;
strokeColor = color(0, 0, 150);
centerColor = color(0, 0, 150); // set center color RGB
stemLength = 150;
stemColor = color(0, 136, 0);
numberOfPetals = 11;
skipPetals = map(sensorValue2_Box1, 30, 100, numberOfPetals-1, 0);
sensor1 = sensorValue1_Box1;
sensor1Label = labelSensorValue1_Box1;
sensor2 = sensorValue2_Box1;
sensor2Label = labelSensorValue2_Box1;
descriptionLabel = labelDescriptionBox1;
textColor = color(0, 0, 0);
sizeOfText = 30;
drawAFlower(xPosition, yPosition, size, petalColor, lookOfPetals, centerColor, showStrokes, strokeColor, stemLength, stemColor, numberOfPetals, skipPetals, sensor1, sensor1Label, sensor2, sensor2Label, descriptionLabel, textColor, sizeOfText);
// Flower sensebox2
xPosition = 200;
yPosition = 600;
size = map(sensorValue1_Box2, -5, 35, 20, 80);
petalColor = color(200, 0, 0); // set petal color RGB
lookOfPetals = 1.5;
showStrokes = true;
strokeColor = color(0, 0, 0);
centerColor = color(255, 255, 255); // set center color RGB
stemLength = 150;
stemColor = color(0, 136, 0);
numberOfPetals = 9;
skipPetals = 0;
sensor1 = sensorValue1_Box2;
sensor1Label = labelSensorValue1_Box2;
sensor2 = "";
sensor2Label = "";
descriptionLabel = labelDescriptionBox2;
textColor = color(0, 0, 0);
sizeOfText = 30;
drawAFlower(xPosition, yPosition, size, petalColor, lookOfPetals, centerColor, showStrokes, strokeColor, stemLength, stemColor, numberOfPetals, skipPetals, sensor1, sensor1Label, sensor2, sensor2Label, descriptionLabel, textColor, sizeOfText);
// Flower sensebox3
xPosition = 700;
yPosition = 600;
size = map(sensorValue1_Box3, -5, 35, 20, 80);
petalColor = color(255, 255, 0); // set petal color RGB
lookOfPetals = 1;
showStrokes = true;
strokeColor = color(0, 0, 0);
centerColor = color(255, 0, 0); // set center color RGB
stemLength = 150;
stemColor = color(0, 136, 0);
numberOfPetals = 13;
skipPetals = map(sensorValue2_Box3, 30, 100, numberOfPetals-1, 0);
sensor1 = sensorValue1_Box3;
sensor1Label = labelSensorValue1_Box3;
sensor2 = sensorValue2_Box3;
sensor2Label = labelSensorValue2_Box3;
descriptionLabel = labelDescriptionBox3;
textColor = color(0, 0, 0);
sizeOfText = 30;
drawAFlower(xPosition, yPosition, size, petalColor, lookOfPetals, centerColor, showStrokes, strokeColor, stemLength, stemColor, numberOfPetals, skipPetals, sensor1, sensor1Label, sensor2, sensor2Label, descriptionLabel, textColor, sizeOfText);
}
/************************************************/
/* Do not change the code below */
/************************************************/
function setup() {
createCanvas(1000, 1000);
checkAPI();
setInterval(checkAPI, 300000);
}
let sensorValue1_Box1 = 0;
let sensorValue2_Box1 = 0;
let sensorValue1_Box2 = 0;
let sensorValue2_Box2 = 0;
let sensorValue1_Box3 = 0;
let sensorValue2_Box3 = 0;
function checkAPI() {
loadJSON("https://api.opensensemap.org/boxes/" + senseBoxID1, DataFromSenseBox_1); // Sensebox 1
loadJSON("https://api.opensensemap.org/boxes/" + senseBoxID2, DataFromSenseBox_2); // Sensebox 2
loadJSON("https://api.opensensemap.org/boxes/" + senseBoxID3, DataFromSenseBox_3); // Sensebox 3
}
function DataFromSenseBox_1(data) {
console.log("DataFromSenseBox_1:");
console.log(data);
sensorValue1_Box1 = data.sensors[sensorNumber1_Box1].lastMeasurement.value;
sensorValue2_Box1 = data.sensors[sensorNumber2_Box1].lastMeasurement.value;
}
function DataFromSenseBox_2(data) {
console.log("DataFromSenseBox_2:");
console.log(data);
sensorValue1_Box2 = data.sensors[sensorNumber1_Box2].lastMeasurement.value;
sensorValue2_Box2 = data.sensors[sensorNumber2_Box2].lastMeasurement.value;
}
function DataFromSenseBox_3(data) {
console.log("DataFromSenseBox_3:");
console.log(data);
sensorValue1_Box3 = data.sensors[sensorNumber1_Box3].lastMeasurement.value;
sensorValue2_Box3 = data.sensors[sensorNumber2_Box3].lastMeasurement.value;
}
function drawAFlower(xPosition, yPosition, size, colorOfPetals, lookOfPetals, colorOfCenter, showStrokes, strokeColor, stemLength, stemColor, numberOfPetals, skipPetals, sensor1, sensor1Label, sensor2, sensor2Label, descriptionLabel, textColor, sizeOfText) {
var rad = size * lookOfPetals;
var xPos = (size / 3) + size / 2;
var yPos = 0;
var numPetals = numberOfPetals;
// draw stem
noFill();
strokeWeight(stemLength / 20);
stroke(stemColor);
curve(xPosition - (stemLength / 2), yPosition - stemLength, xPosition, yPosition, xPosition, yPosition + stemLength, xPosition - (stemLength / 2), yPosition + 2 * stemLength);
fill(stemColor);
arc(xPosition + (stemLength / 5), yPosition + (stemLength * 2 / 3), stemLength / 4, stemLength / 6, radians(30), radians(180 - 30), CHORD);
arc(xPosition + (stemLength / 5), yPosition + (stemLength * 2 / 3) + stemLength / 12, stemLength / 4, stemLength / 6, radians(180 + 30), radians(-30), CHORD);
// draw petals
stroke(strokeColor);
strokeWeight(1);
if (showStrokes == false) {
noStroke();
}
fill(colorOfPetals);
for (var i = 0; i < (numPetals - skipPetals); i++) {
push();
translate(xPosition, yPosition);
rotate(radians(i * 360 / numPetals));
arc(xPos, yPos, rad, rad, radians(30), radians(180 - 30), CHORD);
arc(xPos, yPos + rad / 2, rad, rad, radians(180 + 30), radians(-30), CHORD);
pop();
}
// draw centerpart
fill(colorOfCenter);
ellipseMode(CENTER);
if (showStrokes == false) {
noStroke();
}
ellipse(xPosition, yPosition, size);
// write text
stroke(textColor);
fill(textColor);
textStyle(BOLD);
textSize(sizeOfText);
text(sensor1 + sensor1Label, xPosition-(size), yPosition + stemLength + sizeOfText);
if (sensor2 != "") {
text(sensor2 + sensor2Label, xPosition-(size), yPosition + stemLength + 2*sizeOfText);
}
textStyle(NORMAL);
textSize(sizeOfText*2/3);
if (sensor2 != "") {
text(descriptionLabel, xPosition-(size), yPosition + stemLength + 3*sizeOfText);
}
else {
text(descriptionLabel, xPosition-(size), yPosition + stemLength + 2*sizeOfText);
}
}