mirror of https://github.com/arendst/Tasmota.git
Merge pull request #3459 from andrethomas/development
Rename mcp230xx_config[].b4 to mcp230xx_config[].saved_state
This commit is contained in:
commit
afa2e57e3e
|
@ -154,9 +154,9 @@ typedef union {
|
||||||
typedef union {
|
typedef union {
|
||||||
uint8_t data;
|
uint8_t data;
|
||||||
struct {
|
struct {
|
||||||
uint8_t pinmode : 3; // Enable INPUT
|
uint8_t pinmode : 3; // Pin mode (1 through 5)
|
||||||
uint8_t pullup : 1; // Enable internal weak pull-up resistor
|
uint8_t pullup : 1; // Enable internal weak pull-up resistor
|
||||||
uint8_t b4 : 1;
|
uint8_t saved_state : 1; // Save output state, if used.
|
||||||
uint8_t b5 : 1;
|
uint8_t b5 : 1;
|
||||||
uint8_t b6 : 1;
|
uint8_t b6 : 1;
|
||||||
uint8_t b7 : 1;
|
uint8_t b7 : 1;
|
||||||
|
|
|
@ -95,7 +95,7 @@ void MCP230xx_ApplySettings(void) {
|
||||||
case 5:
|
case 5:
|
||||||
reg_iodir &= ~(1 << idx);
|
reg_iodir &= ~(1 << idx);
|
||||||
if (Settings.flag.save_state) { // Firmware configuration wants us to use the last pin state
|
if (Settings.flag.save_state) { // Firmware configuration wants us to use the last pin state
|
||||||
reg_portpins |= (Settings.mcp230xx_config[idx+(mcp230xx_port*8)].b4 << idx);
|
reg_portpins |= (Settings.mcp230xx_config[idx+(mcp230xx_port*8)].saved_state << idx);
|
||||||
} else {
|
} else {
|
||||||
if (Settings.mcp230xx_config[idx+(mcp230xx_port*8)].pullup) {
|
if (Settings.mcp230xx_config[idx+(mcp230xx_port*8)].pullup) {
|
||||||
reg_portpins |= (1 << idx);
|
reg_portpins |= (1 << idx);
|
||||||
|
@ -128,12 +128,12 @@ void MCP230xx_ApplySettings(void) {
|
||||||
|
|
||||||
void MCP230xx_Detect()
|
void MCP230xx_Detect()
|
||||||
{
|
{
|
||||||
uint8_t buffer;
|
|
||||||
|
|
||||||
if (mcp230xx_type) {
|
if (mcp230xx_type) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint8_t buffer;
|
||||||
|
|
||||||
for (byte i = 0; i < sizeof(mcp230xx_addresses); i++) {
|
for (byte i = 0; i < sizeof(mcp230xx_addresses); i++) {
|
||||||
mcp230xx_address = mcp230xx_addresses[i];
|
mcp230xx_address = mcp230xx_addresses[i];
|
||||||
I2cWrite8(mcp230xx_address, MCP230xx_IOCON, 0x80); // attempt to set bank mode - this will only work on MCP23017, so its the best way to detect the different chips 23008 vs 23017
|
I2cWrite8(mcp230xx_address, MCP230xx_IOCON, 0x80); // attempt to set bank mode - this will only work on MCP23017, so its the best way to detect the different chips 23008 vs 23017
|
||||||
|
@ -243,7 +243,7 @@ void MCP230xx_SetOutPin(uint8_t pin,uint8_t pinstate) {
|
||||||
}
|
}
|
||||||
I2cWrite8(mcp230xx_address, MCP230xx_GPIO + port, portpins);
|
I2cWrite8(mcp230xx_address, MCP230xx_GPIO + port, portpins);
|
||||||
if (Settings.flag.save_state) { // Firmware configured to save last known state in settings
|
if (Settings.flag.save_state) { // Firmware configured to save last known state in settings
|
||||||
Settings.mcp230xx_config[pin].b4=portpins>>(pin-(port*8))&1;
|
Settings.mcp230xx_config[pin].saved_state=portpins>>(pin-(port*8))&1;
|
||||||
}
|
}
|
||||||
switch (pinstate) {
|
switch (pinstate) {
|
||||||
case 0:
|
case 0:
|
||||||
|
@ -269,7 +269,7 @@ void MCP230xx_Reset(uint8_t pinmode) {
|
||||||
for (uint8_t pinx=0;pinx<16;pinx++) {
|
for (uint8_t pinx=0;pinx<16;pinx++) {
|
||||||
Settings.mcp230xx_config[pinx].pinmode=pinmode;
|
Settings.mcp230xx_config[pinx].pinmode=pinmode;
|
||||||
Settings.mcp230xx_config[pinx].pullup=pullup;
|
Settings.mcp230xx_config[pinx].pullup=pullup;
|
||||||
Settings.mcp230xx_config[pinx].b4=0;
|
Settings.mcp230xx_config[pinx].saved_state=0;
|
||||||
Settings.mcp230xx_config[pinx].b5=0;
|
Settings.mcp230xx_config[pinx].b5=0;
|
||||||
Settings.mcp230xx_config[pinx].b6=0;
|
Settings.mcp230xx_config[pinx].b6=0;
|
||||||
Settings.mcp230xx_config[pinx].b7=0;
|
Settings.mcp230xx_config[pinx].b7=0;
|
||||||
|
|
Loading…
Reference in New Issue