Skip to content

Commit

Permalink
PowerSwitch: Rename e2p setting to reflect that it is the switch stat…
Browse files Browse the repository at this point in the history
…e requested by a command, not the resulting one, which also depends on the optional manual switch.
  • Loading branch information
breaker27 committed Aug 8, 2019
1 parent 0142e69 commit 64a2647
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 23 deletions.
10 changes: 5 additions & 5 deletions firmware/shc_powerswitch/shc_powerswitch.c
Expand Up @@ -175,19 +175,19 @@ void switchRelais(int8_t num, bool on, uint16_t timeout, bool dbgmsg)
}
}

if (e2p_powerswitch_get_switchstate(num) != on)
if (e2p_powerswitch_get_cmdstate(num) != on)
{
e2p_powerswitch_set_switchstate(num, on);
e2p_powerswitch_set_cmdstate(num, on);
}

if (switch_timeout[num] != timeout)
{
switch_timeout[num] = timeout;
}

if (e2p_powerswitch_get_switchtimeout(num) != timeout)
if (e2p_powerswitch_get_cmdtimeout(num) != timeout)
{
e2p_powerswitch_set_switchtimeout(num, timeout);
e2p_powerswitch_set_cmdtimeout(num, timeout);
}
}

Expand Down Expand Up @@ -471,7 +471,7 @@ int main(void)
// read (saved) switch state from before the eventual powerloss
for (i = 0; i < RELAIS_COUNT; i++)
{
switchRelais(i, e2p_powerswitch_get_switchstate(i), e2p_powerswitch_get_switchtimeout(i), true);
switchRelais(i, e2p_powerswitch_get_cmdstate(i), e2p_powerswitch_get_cmdtimeout(i), true);
}

print_switch_state();
Expand Down
26 changes: 13 additions & 13 deletions firmware/src_common/e2p_powerswitch.h
Expand Up @@ -65,36 +65,36 @@ static inline uint32_t e2p_powerswitch_get_basestationpacketcounter(void)
return eeprom_read_UIntValue32(520, 24, 0, 16777215);
}

// SwitchState (BoolValue[8])
// Description: This field stores the last known switch state(s) for eight switches to allow restoring the same state after power loss. It contains also the remaining timeout value. Fill this with zeros when creating a e2p file!
// CMDState (BoolValue[8])
// Description: This field stores the switch state(s) which were requested by one of the supported 'set'/'setget' commands for eight switches to allow restoring the same state after power loss. Fill this with zeros when creating a e2p file!

// Set SwitchState (BoolValue)
// Set CMDState (BoolValue)
// Offset: 544, length bits 8
static inline void e2p_powerswitch_set_switchstate(uint8_t index, bool val)
static inline void e2p_powerswitch_set_cmdstate(uint8_t index, bool val)
{
eeprom_write_UIntValue(544 + (uint16_t)index * 8, 8, val ? 1 : 0);
}

// Get SwitchState (BoolValue)
// Get CMDState (BoolValue)
// Offset: 544, length bits 8
static inline bool e2p_powerswitch_get_switchstate(uint8_t index)
static inline bool e2p_powerswitch_get_cmdstate(uint8_t index)
{
return eeprom_read_UIntValue8(544 + (uint16_t)index * 8, 8, 0, 1) == 1;
}

// SwitchTimeout (UIntValue[8])
// Description: This field stores the last known switch state(s) for eight switches to allow restoring the same state after power loss. It contains also the remaining timeout value. Fill this with zeros when creating a e2p file!
// CMDTimeout (UIntValue[8])
// Description: This field stores the timeout value(s) which were requested by one of the supported 'set'/'setget' commands for eight switches to allow restoring the same state after power loss. Fill this with zeros when creating a e2p file!

// Set SwitchTimeout (UIntValue)
// Set CMDTimeout (UIntValue)
// Offset: 608, length bits 16, min val 0, max val 65767
static inline void e2p_powerswitch_set_switchtimeout(uint8_t index, uint16_t val)
static inline void e2p_powerswitch_set_cmdtimeout(uint8_t index, uint16_t val)
{
eeprom_write_UIntValue(608 + (uint16_t)index * 16, 16, val);
}

// Get SwitchTimeout (UIntValue)
// Get CMDTimeout (UIntValue)
// Offset: 608, length bits 16, min val 0, max val 65767
static inline uint16_t e2p_powerswitch_get_switchtimeout(uint8_t index)
static inline uint16_t e2p_powerswitch_get_cmdtimeout(uint8_t index)
{
return eeprom_read_UIntValue16(608 + (uint16_t)index * 16, 16, 0, 65767);
}
Expand All @@ -117,7 +117,7 @@ static inline uint8_t e2p_powerswitch_get_transceiverwatchdogtimeout(void)
}

// SwitchMode (EnumValue[8])
// Description: The mode decides how the optional manual switches are used in combination to the SwitchState command to set the relais status. In general, the status according SwitchState command (CMD) and the switch (SW) can be combined by 'and', 'or' or 'xor'. Additionally the switch can be active open or active close and therefore can be inversed ('not'). 'CMD' and '(not) SW' mean that only the command or switch are considered. The default value is to ignore the optional manual switch.
// Description: The mode decides how the optional manual switches are used in combination to the digital pin/port commands to set the relais status. In general, the status according digital pin/port command (CMD) and the switch (SW) can be combined by 'and', 'or' or 'xor'. Additionally the switch can be active open or active close and therefore can be inversed ('not'). 'CMD' and '(not) SW' mean that only the command or switch are considered. The default value is to ignore the optional manual switch.

#ifndef _ENUM_SwitchMode
#define _ENUM_SwitchMode
Expand Down
10 changes: 5 additions & 5 deletions tools/shc_e2p_editor/e2p_layout.xml
Expand Up @@ -635,15 +635,15 @@
<Array>
<Length>8</Length>
<BoolValue>
<ID>SwitchState</ID>
<Description>This field stores the switch state(s) which were requested by one of the supported 'set' commands for eight switches to allow restoring the same state after power loss. Fill this with zeros when creating a e2p file!</Description>
<ID>CMDState</ID>
<Description>This field stores the switch state(s) which were requested by one of the supported 'set'/'setget' commands for eight switches to allow restoring the same state after power loss. Fill this with zeros when creating a e2p file!</Description>
</BoolValue>
</Array>
<Array>
<Length>8</Length>
<UIntValue>
<ID>SwitchTimeout</ID>
<Description>This field stores the timeout value(s) which were requested by one of the supported 'set' commands for eight switches to allow restoring the same state after power loss. Fill this with zeros when creating a e2p file!</Description>
<ID>CMDTimeout</ID>
<Description>This field stores the timeout value(s) which were requested by one of the supported 'set'/'setget' commands for eight switches to allow restoring the same state after power loss. Fill this with zeros when creating a e2p file!</Description>
<Bits>16</Bits>
<MinVal>0</MinVal>
<MaxVal>65767</MaxVal>
Expand All @@ -661,7 +661,7 @@
<Length>8</Length>
<EnumValue>
<ID>SwitchMode</ID>
<Description>The mode decides how the optional manual switches are used in combination to the SwitchState command to set the relais status. In general, the status according SwitchState command (CMD) and the switch (SW) can be combined by 'and', 'or' or 'xor'. Additionally the switch can be active open or active close and therefore can be inversed ('not'). 'CMD' and '(not) SW' mean that only the command or switch are considered. The default value is to ignore the optional manual switch.</Description>
<Description>The mode decides how the optional manual switches are used in combination to the digital pin/port commands to set the relais status. In general, the status according digital pin/port command (CMD) and the switch (SW) can be combined by 'and', 'or' or 'xor'. Additionally the switch can be active open or active close and therefore can be inversed ('not'). 'CMD' and '(not) SW' mean that only the command or switch are considered. The default value is to ignore the optional manual switch.</Description>
<Bits>8</Bits>
<Element>
<Value>0</Value>
Expand Down

0 comments on commit 64a2647

Please sign in to comment.