mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-29 13:46:37 +00:00
Add some GPIO checks
This commit is contained in:
parent
e574f7dd84
commit
5c282db649
@ -995,6 +995,13 @@ int ResponseJsonEndEnd(void)
|
|||||||
* GPIO Module and Template management
|
* GPIO Module and Template management
|
||||||
\*********************************************************************************************/
|
\*********************************************************************************************/
|
||||||
|
|
||||||
|
void DigitalWrite(uint32_t gpio_pin, uint32_t state)
|
||||||
|
{
|
||||||
|
if (pin[gpio_pin] < 99) {
|
||||||
|
digitalWrite(pin[gpio_pin], state &1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
uint8_t ModuleNr(void)
|
uint8_t ModuleNr(void)
|
||||||
{
|
{
|
||||||
// 0 = User module (255)
|
// 0 = User module (255)
|
||||||
|
@ -166,9 +166,7 @@ void SetLatchingRelay(power_t lpower, uint32_t state)
|
|||||||
|
|
||||||
for (uint32_t i = 0; i < devices_present; i++) {
|
for (uint32_t i = 0; i < devices_present; i++) {
|
||||||
uint32_t port = (i << 1) + ((latching_power >> i) &1);
|
uint32_t port = (i << 1) + ((latching_power >> i) &1);
|
||||||
if (pin[GPIO_REL1 +port] < 99) {
|
DigitalWrite(GPIO_REL1 +port, bitRead(rel_inverted, port) ? !state : state);
|
||||||
digitalWrite(pin[GPIO_REL1 +port], bitRead(rel_inverted, port) ? !state : state);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -226,8 +224,8 @@ void SetDevicePower(power_t rpower, uint32_t source)
|
|||||||
else {
|
else {
|
||||||
for (uint32_t i = 0; i < devices_present; i++) {
|
for (uint32_t i = 0; i < devices_present; i++) {
|
||||||
power_t state = rpower &1;
|
power_t state = rpower &1;
|
||||||
if ((i < MAX_RELAYS) && (pin[GPIO_REL1 +i] < 99)) {
|
if (i < MAX_RELAYS) {
|
||||||
digitalWrite(pin[GPIO_REL1 +i], bitRead(rel_inverted, i) ? !state : state);
|
DigitalWrite(GPIO_REL1 +i, bitRead(rel_inverted, i) ? !state : state);
|
||||||
}
|
}
|
||||||
rpower >>= 1;
|
rpower >>= 1;
|
||||||
}
|
}
|
||||||
@ -293,7 +291,7 @@ void SetLedPowerIdx(uint32_t led, uint32_t state)
|
|||||||
} else {
|
} else {
|
||||||
led_power &= (0xFF ^ mask);
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ struct BUZZER {
|
|||||||
|
|
||||||
void BuzzerOff(void)
|
void BuzzerOff(void)
|
||||||
{
|
{
|
||||||
digitalWrite(pin[GPIO_BUZZER], Buzzer.inverted); // Buzzer Off
|
DigitalWrite(GPIO_BUZZER, Buzzer.inverted); // Buzzer Off
|
||||||
}
|
}
|
||||||
|
|
||||||
//void BuzzerBeep(uint32_t count = 1, uint32_t on = 1, uint32_t off = 1, uint32_t tune = 0);
|
//void BuzzerBeep(uint32_t count = 1, uint32_t on = 1, uint32_t off = 1, uint32_t tune = 0);
|
||||||
@ -124,7 +124,7 @@ void BuzzerEvery100mSec(void)
|
|||||||
Buzzer.duration = Buzzer.set[Buzzer.state];
|
Buzzer.duration = Buzzer.set[Buzzer.state];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
digitalWrite(pin[GPIO_BUZZER], (Buzzer.inverted) ? !Buzzer.state : Buzzer.state);
|
DigitalWrite(GPIO_BUZZER, (Buzzer.inverted) ? !Buzzer.state : Buzzer.state);
|
||||||
} else {
|
} else {
|
||||||
Buzzer.enable = false;
|
Buzzer.enable = false;
|
||||||
}
|
}
|
||||||
|
@ -143,9 +143,7 @@ void HlwEvery200ms(void)
|
|||||||
if (Hlw.cf1_timer >= 8) {
|
if (Hlw.cf1_timer >= 8) {
|
||||||
Hlw.cf1_timer = 0;
|
Hlw.cf1_timer = 0;
|
||||||
Hlw.select_ui_flag = (Hlw.select_ui_flag) ? false : true;
|
Hlw.select_ui_flag = (Hlw.select_ui_flag) ? false : true;
|
||||||
if (pin[GPIO_NRG_SEL] < 99) {
|
DigitalWrite(GPIO_NRG_SEL, Hlw.select_ui_flag);
|
||||||
digitalWrite(pin[GPIO_NRG_SEL], Hlw.select_ui_flag);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Hlw.cf1_pulse_counter) {
|
if (Hlw.cf1_pulse_counter) {
|
||||||
cf1_pulse_length = Hlw.cf1_summed_pulse_length / Hlw.cf1_pulse_counter;
|
cf1_pulse_length = Hlw.cf1_summed_pulse_length / Hlw.cf1_pulse_counter;
|
||||||
|
@ -570,9 +570,7 @@ void McpSnsInit(void)
|
|||||||
} else {
|
} else {
|
||||||
mcp_buffer = (char*)(malloc(MCP_BUFFER_SIZE));
|
mcp_buffer = (char*)(malloc(MCP_BUFFER_SIZE));
|
||||||
}
|
}
|
||||||
if (pin[GPIO_MCP39F5_RST] < 99) {
|
DigitalWrite(GPIO_MCP39F5_RST, 1); // MCP enable
|
||||||
digitalWrite(pin[GPIO_MCP39F5_RST], 1); // MCP enable
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
energy_flg = ENERGY_NONE;
|
energy_flg = ENERGY_NONE;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user