Upravy na zaklade clang-tidy

This commit is contained in:
Pavel Brychta 2023-05-20 11:53:18 +02:00
parent 581749b7f7
commit 1c870374cd
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():_timefrom(0), _timeout(0), _mode(0), _done(0xff) {} // compatibility mode autostart
Interval(uint32_t tmout): _timefrom(0), _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