12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- /*
- sequences.ino
- This file contains the sequences for handling the power up / down
- reset logic as well as reading the status LEDs from front-panel headers
- */
- /*
- Programmable Buttons Functions
-
- Edit the customButtonOnPress and customButtonOnRelease function
- to fit your needs.
- Leave it as default for acting like a power button.
-
- */
- void customButtonOnPress(){
- digitalWrite(PWR_BTN, HIGH);
- digitalWrite(BTN_LED, LOW);
- }
- void customButtonOnRelease(){
- digitalWrite(PWR_BTN, LOW);
- digitalWrite(BTN_LED, HIGH);
- }
- //Handle call to press / release function events
- void handleCustomButtonEvents(){
- //Note: The button pin is pulled low when button is pressed
- int btnPinState = digitalRead(BTN_INPUT);
- if (btnPinState == HIGH && customBtnPressed == true){
- //The button has just been released. Call to the onRelease event
- customBtnPressed = false;
- customButtonOnRelease();
- }else if (btnPinState == LOW && customBtnPressed == false){
- //The button has just been pressed. Call to the onPress event
- customBtnPressed = true;
- customButtonOnPress();
- }
- }
- //Read the current front panel LED state and store to global variables
- void updateFrontPanelLEDStatus() {
- val = digitalRead(HDD_LED);
- hddLedState = (val == LOW); //Active low
- val = digitalRead(PWR_LED);
- pwrLedState = (val == LOW); //Active low
- }
- //Emulate power button press
- void pressPowerButton() {
- digitalWrite(PWR_BTN, HIGH);
- delay(1000);
- digitalWrite(PWR_BTN, LOW);
- }
- //Emulate reset button perss
- void pressResetButton() {
- digitalWrite(RST_BTN, HIGH);
- delay(1000);
- digitalWrite(RST_BTN, LOW);
- }
|