// FacePanelSwitches // // Wazzup switchez? // Tim Hirzel Dec. 2007 // This tab keeps track of the 4-switch panel on the front // of a Rancilio Silvia. It also says what to do with each switch //#define ANALOG_TO_BOOLEAN_THRESHOLD 512 boolean tcState, upperState, middleState, lowerState; boolean tcUpdate, upperUpdate, middleUpdate, lowerUpdate; //boolean aDigitalRead(int analogPin) { // return analogRead(analogPin) > ANALOG_TO_BOOLEAN_THRESHOLD; //} void setupSwitches() { pinMode( TOP_CENTER_SWITCH_PIN, INPUT); digitalWrite(TOP_CENTER_SWITCH_PIN, HIGH); pinMode( UPPER_SWITCH_PIN, INPUT); digitalWrite(UPPER_SWITCH_PIN, HIGH); pinMode( MIDDLE_SWITCH_PIN, INPUT); digitalWrite(MIDDLE_SWITCH_PIN, HIGH); pinMode( LOWER_SWITCH_PIN, INPUT); digitalWrite(LOWER_SWITCH_PIN, HIGH); } void updateSwitches(boolean force) { int lastOn; int secondToLastOn; tcUpdate = !digitalRead(TOP_CENTER_SWITCH_PIN); //"power" switch (now sleep-mode) upperUpdate = !digitalRead(UPPER_SWITCH_PIN); // brew switch middleUpdate = !digitalRead(MIDDLE_SWITCH_PIN); // water switch lowerUpdate = !digitalRead(LOWER_SWITCH_PIN); // steam switch if (force or tcState != tcUpdate) { tcState = tcUpdate; // I want to allow the power switch to be setup such that it can wake the machine and put it to sleep machineWakeOrSleep(tcState); } if (force or upperState != upperUpdate) { upperState = upperUpdate; espresso(upperState); } if (force or middleState != middleUpdate) { middleState = middleUpdate; water(middleState); } if (force or lowerState != lowerUpdate) { lowerState = lowerUpdate; setUseHighTemp(lowerState); } }