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

View File

@ -1,8 +1,7 @@
#ifndef _INTERVAL_H_ #pragma once
#define _INTERVAL_H_
/* Interval /* 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 * 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 class Interval
{ {
protected: protected:
uint32_t _timefrom; uint32_t _timefrom = 0;
uint32_t _timeout; uint32_t _timeout = 0;
uint8_t _mode; // mode of actual operation (compatibility, oneshot, periodic) uint8_t _mode = 0; // mode of actual operation (compatibility, oneshot, periodic)
uint8_t _done; uint8_t _done = 0xff; // compatibility mode autostart
public: public:
Interval():_timefrom(0), _timeout(0), _mode(0), _done(0xff) {} // compatibility mode autostart Interval() = default;
Interval(uint32_t tmout): _timefrom(0), _timeout(tmout), _mode(2), _done(0xff) {} // periodic mode autostart explicit Interval(uint32_t tmout)
bool expired(void); : _timeout(tmout)
, _mode(2) // periodic mode autostart
{}
bool expired();
void set(uint32_t tmout); void set(uint32_t tmout);
void setOneshot(uint32_t tmout); void setOneshot(uint32_t tmout);
void setPeriodic(uint32_t tmout); void setPeriodic(uint32_t tmout);
void reload(void); void reload();
uint32_t elapsed(void); [[nodiscard]] uint32_t elapsed() const;
uint32_t remains(void); [[nodiscard]] uint32_t remains() const;
}; };
#endif
// EOF