DCC-EX Simple Throttle
Simple throttle for a DCC-EX CommandStation
Loading...
Searching...
No Matches
/home/runner/work/DCCEXSimpleThrottle/DCCEXSimpleThrottle/ThrottleScreen.h
Go to the documentation of this file.
1/*
2 * © 2024 Peter Cole
3 * © 2023 Peter Cole
4 *
5 * This is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * It is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this code. If not, see <https://www.gnu.org/licenses/>.
17 */
18
19#ifndef THROTTLESCREEN_H
20#define THROTTLESCREEN_H
21
22#include "EventStructure.h"
23#include "ScreenInterface.h"
24#include <DCCEXProtocol.h>
25
27public:
33 ThrottleScreen(DCCEXProtocol *dccexProtocolClient, uint8_t throttleStep, uint8_t throttleStepFaster,
34 uint8_t throttleStepFastest);
35
39
42 void handleUserSelectionAction(UserSelectionAction action, bool throttleInverted) override;
43
46 void drawScreen(DisplayInterface *display) override;
47
50 void setLoco(Loco *loco);
51
54 void locoBroadcastReceived(LocoBroadcast locoBroadcast);
55
58 uint8_t getSpeed();
59
62 void trackPowerUpdateReceived(TrackPower trackPower);
63
65 void requestLocoUpdate();
66
69
70private:
71 uint8_t _speed;
73 Direction _direction;
75 Loco *_loco;
76 TrackPower _trackPower;
78 DCCEXProtocol *_dccexProtocolClient;
82 unsigned long _speedUpdateDelay;
83 unsigned long _lastSpeedUpdate;
84
86 void _toggleTrackPower();
87
89 void _toggleLights();
90};
91
92#endif // THROTTLESCREEN_H
UserConfirmationAction
User confirmation action data types available.
Definition UserConfirmationInterface.h:23
UserSelectionAction
User selection action data types available.
Definition UserSelectionInterface.h:23
Interface class to abstract construction of what is displayed on screen from the physical implementat...
Definition DisplayInterface.h:29
Definition ScreenInterface.h:27
Definition ThrottleScreen.h:26
void _toggleLights()
Toggle lights (assumed to be F0) on/off.
Definition ThrottleScreen.cpp:197
void _toggleTrackPower()
Toggle track power state - if unknown, turn on.
Definition ThrottleScreen.cpp:189
bool _directionChanged
Definition ThrottleScreen.h:74
void trackPowerUpdateReceived(TrackPower trackPower)
Method to call when a track power update has been received.
Definition ThrottleScreen.cpp:178
bool _speedChanged
Definition ThrottleScreen.h:72
DCCEXProtocol * _dccexProtocolClient
Definition ThrottleScreen.h:78
void requestLocoUpdate()
Explicitly request an update for the currently selected loco address.
Definition ThrottleScreen.cpp:185
uint8_t _speed
Definition ThrottleScreen.h:71
void setLoco(Loco *loco)
Set the loco currently being operated.
Definition ThrottleScreen.cpp:160
void locoBroadcastReceived(LocoBroadcast locoBroadcast)
Method to call when a loco broadcast has been received.
Definition ThrottleScreen.cpp:162
TrackPower _trackPower
Definition ThrottleScreen.h:76
void handleUserConfirmationAction(UserConfirmationAction action) override
Implement this method to define what to do when user confirmation actions are performed.
Definition ThrottleScreen.cpp:37
uint8_t _throttleStepFastest
Definition ThrottleScreen.h:81
Direction _direction
Definition ThrottleScreen.h:73
void drawScreen(DisplayInterface *display) override
Implement this method to draw the associated screen object on the specified display.
Definition ThrottleScreen.cpp:144
bool _trackPowerChanged
Definition ThrottleScreen.h:77
Loco * _loco
Definition ThrottleScreen.h:75
uint8_t _throttleStepFaster
Definition ThrottleScreen.h:80
uint8_t getSpeed()
Get the current speed.
Definition ThrottleScreen.cpp:176
void handleUserSelectionAction(UserSelectionAction action, bool throttleInverted) override
Implement this method to define what to do when user selection actions are performed.
Definition ThrottleScreen.cpp:68
void requestTrackPowerUpdate()
Explicitly request a track power update (actually sends for server version which does this)
Definition ThrottleScreen.cpp:187
unsigned long _lastSpeedUpdate
Definition ThrottleScreen.h:83
uint8_t _throttleStep
Definition ThrottleScreen.h:79
unsigned long _speedUpdateDelay
Definition ThrottleScreen.h:82
Structure for data from a Loco broadcast.
Definition EventStructure.h:42