timestamp => endtime

master
Scott Lahteine 9 years ago
parent 71674059c3
commit d1dffc7ad1

@ -46,7 +46,7 @@ class Buzzer {
private:
struct state_t {
tone_t tone;
uint32_t timestamp;
uint32_t endtime;
} state;
protected:
@ -82,7 +82,7 @@ class Buzzer {
*/
void reset() {
this->off();
this->state.timestamp = 0;
this->state.endtime = 0;
}
public:
@ -117,14 +117,14 @@ class Buzzer {
* playing the tones in the queue.
*/
virtual void tick() {
if (!this->state.timestamp) {
if (!this->state.endtime) {
if (this->buffer.isEmpty()) return;
this->state.tone = this->buffer.dequeue();
this->state.timestamp = millis() + this->state.tone.duration;
this->state.endtime = millis() + this->state.tone.duration;
if (this->state.tone.frequency > 0) this->on();
}
else if (ELAPSED(millis(), this->state.timestamp)) this->reset();
else if (ELAPSED(millis(), this->state.endtime)) this->reset();
}
};

Loading…
Cancel
Save