Compare commits

...

3 Commits

Author SHA1 Message Date
Pavel Brychta 1c870374cd Upravy na zaklade clang-tidy 2023-05-20 11:53:18 +02:00
Pavel Brychta 581749b7f7 Poradi inicializace 2019-11-23 12:08:38 +01:00
Pavel Brychta 73f8bd919a Odstraneni varovani z cppchecku 2019-11-23 11:56:50 +01:00
2 changed files with 19 additions and 20 deletions

View File

@ -1,19 +1,19 @@
#include "interval.h"
// Public Methods //////////////////////////////////////////////////////////////
uint32_t Interval::remains(void)
uint32_t Interval::remains() const
{
return _timeout - (millis() - _timefrom);
}
uint32_t Interval::elapsed(void)
uint32_t Interval::elapsed() const
{
return millis() - _timefrom;
}
bool Interval::expired(void)
bool Interval::expired()
{
bool result = false;
@ -66,7 +66,7 @@ void Interval::setPeriodic(uint32_t tmout)
_done = 0xff;
}
void Interval::reload(void)
void Interval::reload()
{
_timefrom = millis();

View File

@ -1,8 +1,7 @@
#ifndef _INTERVAL_H_
#define _INTERVAL_H_
#pragma once
/* Interval
* Copyright (C) 2014, 2016, 2018, 2019 Pavel Brychta http://www.xpablo.cz
* Copyright (C) 2014, 2016, 2018, 2019, 2023 Pavel Brychta http://www.xpablo.cz
*
* This program is free software: you can redistribute it and/or modify it under the terms of the MIT License
*/
@ -12,21 +11,21 @@
class Interval
{
protected:
uint32_t _timefrom;
uint32_t _timeout;
uint8_t _mode; // mode of actual operation (compatibility, oneshot, periodic)
uint8_t _done;
uint32_t _timefrom = 0;
uint32_t _timeout = 0;
uint8_t _mode = 0; // mode of actual operation (compatibility, oneshot, periodic)
uint8_t _done = 0xff; // compatibility mode autostart
public:
Interval(): _mode(0), _done(0xff) {} // compatibility mode autostart
Interval(uint32_t tmout): _timeout(tmout), _mode(2), _done(0xff) {} // periodic mode autostart
bool expired(void);
Interval() = default;
explicit Interval(uint32_t tmout)
: _timeout(tmout)
, _mode(2) // periodic mode autostart
{}
bool expired();
void set(uint32_t tmout);
void setOneshot(uint32_t tmout);
void setPeriodic(uint32_t tmout);
void reload(void);
uint32_t elapsed(void);
uint32_t remains(void);
void reload();
[[nodiscard]] uint32_t elapsed() const;
[[nodiscard]] uint32_t remains() const;
};
#endif
// EOF