Skip to content

Commit

Permalink
naming
Browse files Browse the repository at this point in the history
  • Loading branch information
mcspr committed Mar 5, 2020
1 parent 56f8bc4 commit 6d2f0cd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions code/espurna/led.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ struct led_pattern_t {
led_pattern_t() = default;
led_pattern_t(const std::vector<led_delay_t>& delays);

void load();
void unload();
void start();
void stop();

bool loaded();
bool started();
bool ready();

std::vector<led_delay_t> delays;
Expand Down
18 changes: 9 additions & 9 deletions code/espurna/led.ino
Original file line number Diff line number Diff line change
Expand Up @@ -69,23 +69,23 @@ led_pattern_t::led_pattern_t(const std::vector<led_delay_t>& delays) :
clock_delay(delays.size() ? delays.back().on : 0)
{}

bool led_pattern_t::loaded() {
bool led_pattern_t::started() {
return queue.size() > 0;
}

bool led_pattern_t::ready() {
return delays.size() > 0;
}

void led_pattern_t::load() {
void led_pattern_t::start() {
clock_last = ESP.getCycleCount();
clock_delay = 0;
queue = {
delays.rbegin(), delays.rend()
};
}

void led_pattern_t::unload() {
void led_pattern_t::stop() {
queue.clear();
}

Expand All @@ -112,7 +112,7 @@ unsigned char ledCount() {
}

bool _ledStatus(led_t& led) {
return led.pattern.loaded() || led.status();
return led.pattern.started() || led.status();
}

bool _ledStatus(led_t& led, bool status) {
Expand All @@ -121,12 +121,12 @@ bool _ledStatus(led_t& led, bool status) {
// when led has pattern, status depends on whether it's running
if (led.pattern.ready()) {
if (status) {
if (!led.pattern.loaded()) {
led.pattern.load();
if (!led.pattern.started()) {
led.pattern.start();
}
result = true;
} else {
led.pattern.unload();
led.pattern.stop();
led.status(false);
result = false;
}
Expand Down Expand Up @@ -288,7 +288,7 @@ void _ledConfigure() {
for (unsigned char id = 0; id < _leds.size(); ++id) {
_leds[id].mode = getSetting({"ledMode", id}, _ledMode(id));
_leds[id].relayID = getSetting({"ledRelay", id}, _ledRelay(id));
_leds[id].pattern.unload();
_leds[id].pattern.stop();
_ledLoadPattern(_leds[id], getSetting({"ledPattern", id}).c_str());
}
_led_update = true;
Expand Down Expand Up @@ -470,7 +470,7 @@ void ledLoop() {

}

if (led.pattern.loaded()) {
if (led.pattern.started()) {
_ledPattern(led);
continue;
}
Expand Down

0 comments on commit 6d2f0cd

Please sign in to comment.