WS_GPIO.cpp 1022 B

1234567891011121314151617181920212223242526272829303132
  1. #include "WS_GPIO.h"
  2. /************************************************************* I/O *************************************************************/
  3. void RGB_Light(uint8_t red_val, uint8_t green_val, uint8_t blue_val)
  4. {
  5. neopixelWrite(GPIO_PIN_RGB,green_val,red_val,blue_val); // RGB color adjustment
  6. }
  7. int relays[6] = { GPIO_PIN_CH1, GPIO_PIN_CH2, GPIO_PIN_CH3, GPIO_PIN_CH4, GPIO_PIN_CH5, GPIO_PIN_CH6 };
  8. void TriggerRelay(int relay, bool closed)
  9. {
  10. digitalWrite(relays[relay], closed ? HIGH : LOW);
  11. }
  12. bool RelayStatus(int relay)
  13. {
  14. return digitalRead(relays[relay] > 0);
  15. }
  16. void GPIO_Init()
  17. {
  18. /*************************************************************************
  19. Relay GPIO
  20. *************************************************************************/
  21. for (int i=0; i<6; i++)
  22. pinMode(relays[i], OUTPUT);
  23. pinMode(GPIO_PIN_RGB, OUTPUT); // Initialize the control GPIO of RGB
  24. RGB_Light(0, 0, 0);
  25. }