#include "WS_GPIO.h" /************************************************************* I/O *************************************************************/ void RGB_Light(uint8_t red_val, uint8_t green_val, uint8_t blue_val) { neopixelWrite(GPIO_PIN_RGB,green_val,red_val,blue_val); // RGB color adjustment } void Buzzer_PWM(uint16_t Time) //ledChannel:PWM Channe dutyfactor:dutyfactor { ledcWrite(PWM_Channel, Dutyfactor); delay(Time); ledcWrite(PWM_Channel, 0); } int relays[6] = { GPIO_PIN_CH1, GPIO_PIN_CH2, GPIO_PIN_CH3, GPIO_PIN_CH4, GPIO_PIN_CH5, GPIO_PIN_CH6 }; void TriggerRelay(int relay, bool closed) { digitalWrite(relays[relay], closed ? HIGH : LOW); } bool RelayStatus(int relay) { return digitalRead(relays[relay] > 0); } bool IsOverride() { return digitalRead(GPIO_OVERRIDE > 0); } void GPIO_Init() { /************************************************************************* Relay GPIO *************************************************************************/ for (int i=0; i<6; i++) pinMode(relays[i], OUTPUT); pinMode(GPIO_OVERRIDE, INPUT); pinMode(GPIO_PIN_RGB, OUTPUT); // Initialize the control GPIO of RGB pinMode(GPIO_PIN_Buzzer, OUTPUT); // Initialize the control GPIO of Buzzer ledcSetup(PWM_Channel, Frequency, Resolution); // Set a LEDC channel ledcAttachPin(GPIO_PIN_Buzzer, PWM_Channel); // Connect the channel to the corresponding pin }