auaesmrtsrfcs
Tuesday, December 13, 2011
Tuesday, December 6, 2011
042_use.less.thermostat
Almost done...
Need to implement a kickdown for the weekly timer event (requires a way to interpolate 7 day cycle out of monthly calendar data. Probably implement a counter to log everytime "day" changes and when it hits 7 execute kickdown and reset timer.
Other stuff ("learning") would just be calling appropriate values from our huge array and averaging them. Also implementing the finalized serial communication (Xbee?) between processing and arduino.
also: pachube
also: graph of pachube
import processing.serial.*;// import the serial library Serial port; PFont f = createFont("Knockout-HTF91-UltmtMiddlewt", 96, true); PFont g = createFont("Knockout-HTF91-UltmtMiddlewt", 48, true); int cels = 19; int temp = 5; int cal_x = 1000; int cal_y = 600; int multi = 25; //COUNTER int counter = 0; int minutetracker = 0; int hourtracker = 0; //BIG ARRAY!!! int years = 2; int weeks = 52; int days = 7; int hours = 24; float[][][][] userTempArray = new float[years][weeks][days][hours]; //HOURLY ARRAY int[] hourlog = new int[59]; //KEYBOARD //up/down arrows set user temp void keyPressed() { if (key == CODED) { switch(keyCode) { case (LEFT): cels -= 1; break; case (RIGHT): cels += 1; break; } } } void setup() { size(1920, 1080); println(Serial.list()); // prints out the serial ports available port = new Serial(this, Serial.list()[0], 9600);// change to correct com port(1) which is displayed by the previous line background(0); // color of the backround frameRate(10); for (int i = 0; i < years; i++) { for (int j = 0; j < weeks; j++) { for (int k = 0; k < days; k++) { for (int l = 0; l < hours; l++) { // for (int m = 0; j < halfhours; m++) { userTempArray[i][j][k][l] = 0; // } } } } } } void draw() { background(#000000); //Make the background black textFont(g); //Set the font fill(#ffffff); // Set the forground color white text("user input:", 820, 540); text("(c)", 1265, 540); text("temperature:", 747, 740); text("(c)", 1265, 740); textFont(f); //Set the font fill((255+((cels-temp)*multi)), (255-((cels-temp)*multi)), (255-((cels-temp)*multi))); text(cels, 1120, 540); fill((255-((cels-temp)*multi)), (255+((cels-temp)*multi)), (255+((cels-temp)*multi))); text(temp, 1120, 740); //time fill(255); String g = str(year())+"/"+str(month())+"/"+str(day())+"_"+str(hour())+":"+str(minute())+":"+str(second()); text (g, 150, 250); //TIMING //take time all at once to avoid timing errors int secondtracker = second(); int minutetracker = minute(); int hourtracker = hour(); //TEMPERATURE //UI simulating temperature change //********COMMENT OUT for final************ if (frameCount%30==0) //take frame count, divide by 30 (3 seconds), when remainder == 0, execute { if (cels > temp){ temp++; } if (cels < temp){ temp--; } if (frameCount%60==0){ if (cels == temp) { if (temp < 20) { temp--; } if (temp > 20) { temp++; } } } } //LOG //every 58 seconds, take current usertemp if (frameCount%580==0) { hourlog[minutetracker] = cels; int minutestemp = hourlog[minutetracker]; println(hour()+":"+minute()+"'s user temp is *"+minutestemp+"* degrees celsius"); } //HOURLY //at XX:59:56, average data in hourly log, dump to userTempArray, clear hourly log if (minute() == 59 && second() == 56) //at XX:59:56 { float average = 0; //set average to 0 (clear) for ( int i = 0; i < hourlog.length; ++i ) //add all values in hourlog[] { average += hourlog[i]; } average /= (float)(hourlog.length); //set average to above sum divided by length of hourlog[] userTempArray[0][0][0][hourtracker] = average; //assign average to userTempArray for it's respective hour println( hour()+"'s average user temp "+average ); delay(1001); //delay 1s so XX:59:56 cannot reoccur until next hour for ( int i = 0; i < hourlog.length; ++i ) //clear hourlog[ { hourlog[i] = 0; } } //DAILY //at 23:59:58 take if (hour() == 23 && minute() == 59 && second() == 58) { for (int i = 6; i > 0; i--) { for (int j = 23; j >= 0; j--) { userTempArray[0][0][i][j] = userTempArray[0][0][i-1][j-1]; } } for (int i = 0; i < 24; i++) { userTempArray[0][0][0][i] = 0; } delay(1001); } //END }
Tuesday, November 22, 2011
Sunday, November 20, 2011
Friday, November 18, 2011
Wednesday, November 9, 2011
Tuesday, November 8, 2011
Subscribe to:
Posts (Atom)