Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 18 additions & 15 deletions arduino/cover/cover.ino
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class Cover {
}

void reset() {
InterruptGuard _{};
m_position.position = 0;
m_position.close = 0;
m_position.open = 0;
Expand Down Expand Up @@ -184,21 +185,23 @@ class Cover {
m_set_limits = SetLimit::CLOSE;
break;
case Direction::STOP:
switch (m_set_limits) {
case SetLimit::OPEN:
m_position.open = position;
break;
case SetLimit::CLOSE:
m_position.close = position;
break;
case SetLimit::NONE:
break;
{
InterruptGuard _{};
switch (m_set_limits) {
case SetLimit::OPEN:
m_position.open = position;
break;
case SetLimit::CLOSE:
m_position.close = position;
break;
case SetLimit::NONE:
break;
}
m_set_limits = SetLimit::NONE;
// Save settings to EEPROM. Update will not touch the EEPROM if the data is the same so
// it's safe to put it here.
EEPROM.updateBlock(0, m_position);
}
m_set_limits = SetLimit::NONE;
// Save settings to EEPROM. Update will not touch the EEPROM if the data is the same so
// it's safe to put it here.
InterruptGuard _{};
EEPROM.updateBlock(0, m_position);
break;
}
}
Expand Down Expand Up @@ -231,7 +234,7 @@ class Cover {

void debug() const {
Serial.print(F("position="));
Serial.println(m_position.position);
Serial.println(get_position());
Serial.print(F("open="));
Serial.println(m_position.open);
Serial.print(F("close="));
Expand Down
Loading