OpenSourceSimWheelESP32
Open-source wireless steering wheel/button box for ESP32 boards
Loading...
Searching...
No Matches
SimWheelUI.hpp
Go to the documentation of this file.
1
12#pragma once
13
14//-------------------------------------------------------------------
15// Imports
16//-------------------------------------------------------------------
17
18#include "OutputHardware.hpp"
19
20//-------------------------------------------------------------------
21// Auxiliary types
22//-------------------------------------------------------------------
23
28enum class RevLightsMode : uint8_t
29{
35 IN_OUT,
37 OUT_IN
38};
39
40//-----------------------------------------------------------------------------
41// Single Color-Single LED user interface
42//-----------------------------------------------------------------------------
43
49{
50public:
58
59 virtual void onStart() override;
60 virtual void onConnected() override;
61 virtual void onTelemetryData(const TelemetryData *pTelemetryData) override;
62 virtual void serveSingleFrame(uint32_t elapsedMs) override;
63 virtual void shutdown() override;
64 virtual uint8_t getMaxFPS() override { return 60; }
65 virtual uint16_t getStackSize() override { return 1024; }
66
67private:
68 SingleLED *led;
69 uint8_t ledMode;
70 uint32_t blinkTimer;
71 void setMode(uint8_t newMode);
72};
73
74//-----------------------------------------------------------------------------
75// PCF8574-driven rev lights
76//-----------------------------------------------------------------------------
77
83{
84public:
96 uint8_t hardwareAddress,
97 I2CBus bus = I2CBus::SECONDARY,
98 uint8_t factoryAddress = 0b0100000,
101
102 virtual void onStart() override;
103 virtual void onConnected() override;
104 virtual void onTelemetryData(const TelemetryData *pTelemetryData) override;
105 virtual void serveSingleFrame(uint32_t elapsedMs) override;
106 virtual void onBitePoint(uint8_t bitePoint) override;
107 virtual void onLowBattery() override;
108 virtual void onSaveSettings() override;
109 virtual void shutdown() override;
110 virtual uint8_t getMaxFPS() override { return 40; }
111 virtual uint16_t getStackSize() override { return 2048; }
112
113private:
114 PCF8574LedDriver *driver;
115 uint8_t litCount, lastBitePoint;
116 uint32_t timer;
117 bool displayBitePoint;
118 bool blink;
119 bool blinkState;
120 RevLightsMode displayMode;
121};
Output hardware classes.
I2CBus
I2C bus controller.
RevLightsMode
Display modes for "rev lights".
@ RIGHT_TO_LEFT
Moving from right to left.
@ IN_OUT
Moving from center to edges.
@ LEFT_TO_RIGHT
Moving from left to right.
@ OUT_IN
Moving from edges to center.
Abstract interface for notifications and telemetry display.
8-LED driver based on the PCF8574 GPIO expander
Use eight single-color LEDS as "rev lights".
virtual uint16_t getStackSize() override
Get the stack size required by this user interface.
virtual void onBitePoint(uint8_t bitePoint) override
Notify a change in the current bite point.
virtual void shutdown() override
Cut power to the UI hardware.
virtual void onSaveSettings() override
Notify that user settings have been saved to flash memory.
virtual uint8_t getMaxFPS() override
Get the maximum FPS supported by the underlying hardware.
virtual void onStart() override
Called just once after initialization.
virtual void onTelemetryData(const TelemetryData *pTelemetryData) override
Notify new telemetry data.
virtual void onLowBattery() override
Notify low battery.
virtual void serveSingleFrame(uint32_t elapsedMs) override
Draw a single frame.
PCF8574RevLights(uint8_t hardwareAddress, I2CBus bus=I2CBus::SECONDARY, uint8_t factoryAddress=0b0100000, RevLightsMode displayMode=RevLightsMode::LEFT_TO_RIGHT)
Create "rev lights" using PCF8574 and single-color LEDs.
virtual void onConnected() override
Notify device is connected.
Use a single-color LED as a shift light indicator.
virtual uint8_t getMaxFPS() override
Get the maximum FPS supported by the underlying hardware.
virtual void shutdown() override
Cut power to the UI hardware.
SimpleShiftLight(OutputGPIO ledPin)
Create a simple "shift" light.
virtual uint16_t getStackSize() override
Get the stack size required by this user interface.
virtual void onConnected() override
Notify device is connected.
virtual void onTelemetryData(const TelemetryData *pTelemetryData) override
Notify new telemetry data.
virtual void onStart() override
Called just once after initialization.
virtual void serveSingleFrame(uint32_t elapsedMs) override
Draw a single frame.
A simple LED driver for a single LED.
Output-capable GPIO pin number.
Telemetry data.