Introduced types.h and millis_t
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "globals.h"
|
||||
#include "types.h"
|
||||
|
||||
namespace {
|
||||
#ifdef FEATURE_BMS
|
||||
@ -8,8 +9,8 @@ namespace bms {
|
||||
constexpr auto autoReconnect = false; // causes hangs when not available
|
||||
|
||||
bool lastConnected;
|
||||
unsigned long lastSend;
|
||||
unsigned long lastReceive;
|
||||
millis_t lastSend;
|
||||
millis_t lastReceive;
|
||||
|
||||
float voltage;
|
||||
float current;
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "checkboxicon.h"
|
||||
#include "icons/back.h"
|
||||
#include "texts.h"
|
||||
#include "types.h"
|
||||
|
||||
namespace {
|
||||
class DebugMenu;
|
||||
@ -36,7 +37,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
mutable unsigned long m_nextUpdate{};
|
||||
mutable millis_t m_nextUpdate{};
|
||||
mutable String m_title;
|
||||
};
|
||||
|
||||
@ -57,7 +58,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
mutable unsigned long m_nextUpdate{};
|
||||
mutable millis_t m_nextUpdate{};
|
||||
mutable int m_color;
|
||||
};
|
||||
|
||||
@ -77,7 +78,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
mutable unsigned long m_nextUpdate{};
|
||||
mutable millis_t m_nextUpdate{};
|
||||
mutable int m_font;
|
||||
};
|
||||
|
||||
@ -100,7 +101,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
mutable unsigned long m_nextUpdate{};
|
||||
mutable millis_t m_nextUpdate{};
|
||||
mutable const Icon<24, 24> *m_icon;
|
||||
};
|
||||
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "checkboxicon.h"
|
||||
#include "icons/back.h"
|
||||
#include "texts.h"
|
||||
#include "types.h"
|
||||
|
||||
namespace {
|
||||
class MainMenu;
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "actions/dummyaction.h"
|
||||
#include "icons/back.h"
|
||||
#include "texts.h"
|
||||
#include "types.h"
|
||||
|
||||
namespace {
|
||||
class WifiSettingsMenu;
|
||||
@ -48,7 +49,7 @@ private:
|
||||
|
||||
std::vector<makeComponent<MenuItem, ChangeableText, DummyAction>> vec;
|
||||
|
||||
unsigned long m_lastScanComplete;
|
||||
millis_t m_lastScanComplete;
|
||||
};
|
||||
|
||||
String WifiScanMenu::text() const
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include <Arduino.h>
|
||||
|
||||
#include "globals.h"
|
||||
#include "types.h"
|
||||
|
||||
namespace {
|
||||
namespace dpad
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "globals.h"
|
||||
|
||||
#include "dpad.h"
|
||||
#include "types.h"
|
||||
|
||||
namespace {
|
||||
namespace dpad3wire
|
||||
|
@ -7,6 +7,8 @@
|
||||
|
||||
#include "bobbycar-protocol/protocol.h"
|
||||
|
||||
#include "types.h"
|
||||
|
||||
namespace {
|
||||
class FeedbackParser
|
||||
{
|
||||
@ -78,7 +80,7 @@ private:
|
||||
uint8_t m_incomingByte{};
|
||||
uint8_t m_incomingBytePrev{};
|
||||
|
||||
unsigned long m_lastFeedback{millis()};
|
||||
millis_t m_lastFeedback{millis()};
|
||||
const std::reference_wrapper<HardwareSerial> &m_serial;
|
||||
bool &m_feedbackValid;
|
||||
Feedback &m_feedback, m_newFeedback;
|
||||
|
@ -12,10 +12,9 @@
|
||||
#include "modeinterface.h"
|
||||
#include "settings.h"
|
||||
#include "settingssaver.h"
|
||||
#include "types.h"
|
||||
|
||||
namespace {
|
||||
using pin_t = int;
|
||||
|
||||
int16_t raw_gas, raw_brems;
|
||||
float gas, brems;
|
||||
#ifdef FEATURE_GAMETRAK
|
||||
@ -33,7 +32,7 @@ Controller front{Serial1, settings.controllerHardware.enableFrontLeft, settings.
|
||||
Controller back{Serial2, settings.controllerHardware.enableBackLeft, settings.controllerHardware.enableBackRight, settings.controllerHardware.invertBackLeft, settings.controllerHardware.invertBackRight};
|
||||
|
||||
struct {
|
||||
unsigned long lastTime = millis();
|
||||
millis_t lastTime = millis();
|
||||
int current{0};
|
||||
int last{0};
|
||||
} performance;
|
||||
@ -63,7 +62,7 @@ public:
|
||||
|
||||
static void confirmButton(bool pressed)
|
||||
{
|
||||
static unsigned long pressBegin = 0;
|
||||
static millis_t pressBegin = 0;
|
||||
|
||||
const auto now = millis();
|
||||
|
||||
@ -86,7 +85,7 @@ public:
|
||||
|
||||
static void backButton(bool pressed)
|
||||
{
|
||||
static unsigned long pressBegin = 0;
|
||||
static millis_t pressBegin = 0;
|
||||
|
||||
const auto now = millis();
|
||||
|
||||
|
@ -22,12 +22,13 @@
|
||||
#include "actions/bluetoothbeginmasteraction.h"
|
||||
#include "actions/bluetoothconnectbmsaction.h"
|
||||
#include "bobby_webserver.h"
|
||||
#include "types.h"
|
||||
|
||||
namespace {
|
||||
ModeInterface *lastMode{};
|
||||
unsigned long lastModeUpdate{};
|
||||
unsigned long lastStatsUpdate{};
|
||||
unsigned long lastDisplayRedraw{};
|
||||
millis_t lastModeUpdate{};
|
||||
millis_t lastStatsUpdate{};
|
||||
millis_t lastDisplayRedraw{};
|
||||
|
||||
constexpr auto modeUpdateRate = 50;
|
||||
constexpr auto statsUpdateRate = 50;
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "modeinterface.h"
|
||||
#include "globals.h"
|
||||
#include "utils.h"
|
||||
#include "types.h"
|
||||
|
||||
namespace {
|
||||
class DefaultMode : public ModeInterface
|
||||
@ -20,7 +21,7 @@ public:
|
||||
bool waitForBremsLoslass{false};
|
||||
|
||||
private:
|
||||
unsigned long lastTime{millis()};
|
||||
millis_t lastTime{millis()};
|
||||
float lastPwm{0};
|
||||
};
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include <Arduino.h>
|
||||
|
||||
#include "globals.h"
|
||||
#include "types.h"
|
||||
|
||||
namespace {
|
||||
template<typename HANDLER, pin_t CLK, pin_t DT, pin_t SW>
|
||||
|
6
src/types.h
Normal file
6
src/types.h
Normal file
@ -0,0 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
namespace {
|
||||
using pin_t = int;
|
||||
using millis_t = unsigned long;
|
||||
}
|
Reference in New Issue
Block a user