Fix pin handling part 1

This commit is contained in:
Theo Arends 2020-04-27 10:35:38 +02:00
parent c54dc6cdb5
commit 5d9be9a4d0
6 changed files with 12 additions and 12 deletions

View File

@ -1100,10 +1100,10 @@ void SetPin(uint32_t lpin, uint32_t gpio) {
*/
}
void DigitalWrite(uint32_t gpio_pin, uint32_t state)
void DigitalWrite(uint32_t gpio_pin, uint32_t index, uint32_t state)
{
if (Pin(gpio_pin) < 99) {
digitalWrite(Pin(gpio_pin), state &1);
if (Pin(gpio_pin, index) < 99) {
digitalWrite(Pin(gpio_pin, index), state &1);
}
}

View File

@ -166,7 +166,7 @@ void SetLatchingRelay(power_t lpower, uint32_t state)
for (uint32_t i = 0; i < devices_present; i++) {
uint32_t port = (i << 1) + ((latching_power >> i) &1);
DigitalWrite(GPIO_REL1 +port, bitRead(rel_inverted, port) ? !state : state);
DigitalWrite(GPIO_REL1, port, bitRead(rel_inverted, port) ? !state : state);
}
}
@ -228,7 +228,7 @@ void SetDevicePower(power_t rpower, uint32_t source)
for (uint32_t i = 0; i < devices_present; i++) {
power_t state = rpower &1;
if (i < MAX_RELAYS) {
DigitalWrite(GPIO_REL1 +i, bitRead(rel_inverted, i) ? !state : state);
DigitalWrite(GPIO_REL1, i, bitRead(rel_inverted, i) ? !state : state);
}
rpower >>= 1;
}
@ -351,7 +351,7 @@ void SetLedPowerIdx(uint32_t led, uint32_t state)
} else {
led_power &= (0xFF ^ mask);
}
DigitalWrite(Pin(GPIO_LED1, led), bitRead(led_inverted, led) ? !state : state);
DigitalWrite(GPIO_LED1, led, bitRead(led_inverted, led) ? !state : state);
}
#ifdef USE_BUZZER
if (led == 0) {

View File

@ -41,7 +41,7 @@ struct BUZZER {
void BuzzerOff(void)
{
DigitalWrite(GPIO_BUZZER, Buzzer.inverted); // Buzzer Off
DigitalWrite(GPIO_BUZZER, 0, Buzzer.inverted); // Buzzer Off
}
//void BuzzerBeep(uint32_t count = 1, uint32_t on = 1, uint32_t off = 1, uint32_t tune = 0, uint32_t mode = 0);
@ -81,7 +81,7 @@ void BuzzerSetStateToLed(uint32_t state)
{
if (Buzzer.enable && (2 == Buzzer.mode)) {
Buzzer.state = (state != 0);
DigitalWrite(GPIO_BUZZER, (Buzzer.inverted) ? !Buzzer.state : Buzzer.state);
DigitalWrite(GPIO_BUZZER, 0, (Buzzer.inverted) ? !Buzzer.state : Buzzer.state);
}
}
@ -140,7 +140,7 @@ void BuzzerEvery100mSec(void)
Buzzer.duration = Buzzer.set[Buzzer.state];
}
}
DigitalWrite(GPIO_BUZZER, (Buzzer.inverted) ? !Buzzer.state : Buzzer.state);
DigitalWrite(GPIO_BUZZER, 0, (Buzzer.inverted) ? !Buzzer.state : Buzzer.state);
} else {
Buzzer.enable = false;
}

View File

@ -165,7 +165,7 @@ void PWMDimmerSetPoweredOffLed(void)
void PWMDimmerSetPower(void)
{
DigitalWrite(GPIO_REL1, bitRead(rel_inverted, 0) ? !power : power);
DigitalWrite(GPIO_REL1, 0, bitRead(rel_inverted, 0) ? !power : power);
PWMDimmerSetBrightnessLeds(0);
PWMDimmerSetPoweredOffLed();
}

View File

@ -143,7 +143,7 @@ void HlwEvery200ms(void)
if (Hlw.cf1_timer >= 8) {
Hlw.cf1_timer = 0;
Hlw.select_ui_flag = (Hlw.select_ui_flag) ? false : true;
DigitalWrite(GPIO_NRG_SEL, Hlw.select_ui_flag);
DigitalWrite(GPIO_NRG_SEL, 0, Hlw.select_ui_flag);
if (Hlw.cf1_pulse_counter) {
cf1_pulse_length = Hlw.cf1_summed_pulse_length / Hlw.cf1_pulse_counter;

View File

@ -570,7 +570,7 @@ void McpSnsInit(void)
} else {
mcp_buffer = (char*)(malloc(MCP_BUFFER_SIZE));
}
DigitalWrite(GPIO_MCP39F5_RST, 1); // MCP enable
DigitalWrite(GPIO_MCP39F5_RST, 0, 1); // MCP enable
} else {
energy_flg = ENERGY_NONE;
}