Professional Documents
Culture Documents
* weather_patterns.ino
* NAME: James Mayclin
* DATE: 5/23/18
* When run in conjunction with weather_api.py,
* obtains the current weather condition and offers
* a graphical display of said condition. pressing the push
* button toggles the display on and off
*/
/*******************************************************
* Constant Declaration and Global variables *
*******************************************************/
/*******************************************************
* Arudino SETUP/LOOP *
*******************************************************/
pinMode(BUTTON, INPUT_PULLUP);
for (byte i = 0; i < 8; i++) {
pinMode(ANODE_PINS[i], OUTPUT); //Set Pins
pinMode(CATHODE_PINS[i], OUTPUT);
/*****************************************
* SETTING/INCREMENT Functions *
*****************************************/
/*******************************************************
* Weather Helper Functions *
*******************************************************/
//Draw clouds and drop pattern (used by multiple methods). Avoids having to loop
over all 64 elements.
void drawCloudsDrop(byte drops[4][4], byte pattern[4][4][4], byte drop_brightness,
byte cloud_brightness) {
for (byte i = 0; i < 4; i++) {
for (byte j = 0; j < 4; j++) {
pattern[i][j][3] = cloud_brightness;
pattern[i][j][drops[i][j]] = drop_brightness;
}
}
}
//Zero out the drops in the LED pattern
void zeroDropPattern(byte drops[4][4], byte pattern[4][4][4]) {
for (byte i = 0; i < 4; i++) {
for (byte j = 0; j < 4; j++) {
pattern[i][j][drops[i][j]] = 0;
}
}
}
/*******************************************************
* IO Function *
*******************************************************/
setPattern(weather_state);
}
}