sequences.ino 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. sequences.ino
  3. This file contains the sequences for handling the power up / down
  4. reset logic as well as reading the status LEDs from front-panel headers
  5. */
  6. /*
  7. Programmable Buttons Functions
  8. Edit the customButtonOnPress and customButtonOnRelease function
  9. to fit your needs.
  10. Leave it as default for acting like a power button.
  11. */
  12. void customButtonOnPress(){
  13. digitalWrite(PWR_BTN, HIGH);
  14. digitalWrite(BTN_LED, LOW);
  15. }
  16. void customButtonOnRelease(){
  17. digitalWrite(PWR_BTN, LOW);
  18. digitalWrite(BTN_LED, HIGH);
  19. }
  20. //Handle call to press / release function events
  21. void handleCustomButtonEvents(){
  22. //Note: The button pin is pulled low when button is pressed
  23. int btnPinState = digitalRead(BTN_INPUT);
  24. if (btnPinState == HIGH && customBtnPressed == true){
  25. //The button has just been released. Call to the onRelease event
  26. customBtnPressed = false;
  27. customButtonOnRelease();
  28. }else if (btnPinState == LOW && customBtnPressed == false){
  29. //The button has just been pressed. Call to the onPress event
  30. customBtnPressed = true;
  31. customButtonOnPress();
  32. }
  33. }
  34. //Read the current front panel LED state and store to global variables
  35. void updateFrontPanelLEDStatus() {
  36. val = digitalRead(HDD_LED);
  37. hddLedState = (val == LOW); //Active low
  38. val = digitalRead(PWR_LED);
  39. pwrLedState = (val == LOW); //Active low
  40. }
  41. //Emulate power button press
  42. void pressPowerButton() {
  43. digitalWrite(PWR_BTN, HIGH);
  44. delay(1000);
  45. digitalWrite(PWR_BTN, LOW);
  46. }
  47. //Emulate reset button perss
  48. void pressResetButton() {
  49. digitalWrite(RST_BTN, HIGH);
  50. delay(1000);
  51. digitalWrite(RST_BTN, LOW);
  52. }