OpenSourceSimWheelESP32
Open-source wireless steering wheel/button box for ESP32 boards
Loading...
Searching...
No Matches
SimWheelInternals.hpp
Go to the documentation of this file.
1
12#pragma once
13
14//-------------------------------------------------------------------
15// Imports
16//-------------------------------------------------------------------
17
18#include "InternalTypes.hpp"
19#include "SimWheelTypes.hpp"
20
21//-------------------------------------------------------------------
22// GLOBALS
23//-------------------------------------------------------------------
24
25//-------------------------------------------------------------------
26// API
27//-------------------------------------------------------------------
28
29namespace internals
30{
31 namespace batteryMonitor
32 {
37 void getReady();
38
44
51
60
61 } // namespace batteryMonitor
62
63 namespace batteryCalibration
64 {
69 void getReady();
70
75 void clear();
76
83 void addSample(int reading);
84
90 // void save();
91 }
92
93 namespace pixels
94 {
99 void getReady();
100
114 void set(PixelGroup group,
115 uint8_t pixelIndex,
116 uint8_t red,
117 uint8_t green,
118 uint8_t blue);
119
128 void setAll(PixelGroup group,
129 uint8_t red,
130 uint8_t green,
131 uint8_t blue);
132
139
146
151 void show();
152
157 void reset();
158
165 uint8_t getCount(PixelGroup group);
166 } // namespace pixels
167
168 namespace ui
169 {
173 void getReady();
174 } // namespace ui
175
176 namespace inputs
177 {
182 void getReady();
183
189 void addFakeInput(FakeInput *instance);
190
197 inline void notifyInputEvent(const DecouplingEvent &input);
198 } // namespace inputs
199
200 namespace inputHub
201 {
206 void getReady();
207
214 } // namespace inputHub
215
216 namespace storage
217 {
219 void getReady();
220 } // namespace storage
221
222 namespace inputMap
223 {
228 void getReady();
229
235 void clear();
236
246 void map(
247 bool isAltModeEngaged,
248 uint64_t firmware_bitmap,
249 uint64_t &low,
250 uint64_t &high);
251 } // namespace inputMap
252
253 namespace power
254 {
259 void getReady();
260 } // namespace power
261
262 namespace hid
263 {
264
287 void begin(
288 std::string deviceName,
289 std::string deviceManufacturer,
290 bool enableAutoPowerOff,
291 uint16_t VID,
292 uint16_t PID,
293 bool usb_enable = true,
294 bool ble_enable = true,
295 bool exclusive = false);
296
305
313
319
328
341 uint64_t inputsLow,
342 uint64_t inputsHigh,
343 uint8_t POVstate,
344 uint8_t leftAxis,
345 uint8_t rightAxis,
346 uint8_t clutchAxis);
347
352 void reset();
353
360 namespace common
361 {
363 void getReady();
364
373 uint16_t onGetFeature(uint8_t report_id, uint8_t *buffer, uint16_t len);
374
382 void onSetFeature(uint8_t report_id, const uint8_t *buffer, uint16_t len);
383
391 void onOutput(uint8_t report_id, const uint8_t *buffer, uint16_t len);
392
399 void onReset(uint8_t *report);
400
415 uint8_t *report,
416 bool &notifyConfigChanges,
417 uint64_t &inputsLow,
418 uint64_t &inputsHigh,
419 uint8_t &POVstate,
420 uint8_t &leftAxis,
421 uint8_t &rightAxis,
422 uint8_t &clutchAxis);
423
432 const BatteryStatus &status);
433
434 } // namespace common
435 } // namespace hid
436} // namespace internals
437
438//-------------------------------------------------------------------
439//
440//-------------------------------------------------------------------
Types and constants used everywhere for firmware implementation.
void configureForTesting()
Configure period, warning and power-off limits for testing.
void * getHardwareInstance()
Get the Hardware Instance object.
void shiftToNext(PixelGroup group)
Shift all pixel colors to the next pixel index.
void addFakeInput(FakeInput *instance)
Add a fake input instance for testing.
void clear()
Clear calibration data (but may persist in flash memory).
void getReady()
Prepare to run.
bool isConnected()
Tell if there is a host connection.
uint8_t getCount(PixelGroup group)
Get the total number of pixels in a group.
bool supportsCustomHardwareID()
Support for a custom PID/VID.
void notifyInputEvent(const DecouplingEvent &input)
Push an input event into the decoupling queue (for testing)
void addSample(int reading)
Add an ADC reading to calibration data. The battery should get fully charged before first call.
void reportChangeInConfig()
Report a change in user settings (clutch function, etc.)
void reset()
Turn off all pixels in all groups.
void shiftToPrevious(PixelGroup group)
Shift all pixel colors to the previous pixel index.
void reportInput(uint64_t inputsLow, uint64_t inputsHigh, uint8_t POVstate, uint8_t leftAxis, uint8_t rightAxis, uint8_t clutchAxis)
Report HID inputs.
void begin(std::string deviceName, std::string deviceManufacturer, bool enableAutoPowerOff, uint16_t VID, uint16_t PID, bool usb_enable=true, bool ble_enable=true, bool exclusive=false)
Start BLE/Bluetooth HID.
void onRawInput(DecouplingEvent &input)
Process a single input event.
void configureFakeMonitor(BatteryStatus *fakeStatus)
Configure a fake monitor for testing.
void map(bool isAltModeEngaged, uint64_t firmware_bitmap, uint64_t &low, uint64_t &high)
Map a firmware-defined input bitmap.
void setAll(PixelGroup group, uint8_t red, uint8_t green, uint8_t blue)
Set the color of all pixels in a group.
void show()
Display all pixels in all groups at once.
void reportBatteryLevel(const BatteryStatus &status)
Report current battery level and status to the host computer.
Types and constants required for custom firmware setup.
PixelGroup
Available RGB LED groups for pixel control.
Everything related to the measurement of available battery charge.
Definition SimWheel.hpp:636
Everything related to the HID protocol.
Definition SimWheel.hpp:562
Everything related to the combined state of all inputs and their treatment.
Definition SimWheel.hpp:289
Translates firmware-defined input numbers to user-defined input numbers.
Definition SimWheel.hpp:509
Everything related to hardware inputs and their events.
Definition SimWheel.hpp:31
uint16_t onGetFeature(uint8_t report_id, uint8_t *buffer, uint16_t len)
Send feature report.
void onOutput(uint8_t report_id, const uint8_t *buffer, uint16_t len)
Receive an output report.
void getReady()
Prepare to run.
void onReportInput(uint8_t *report, bool &notifyConfigChanges, uint64_t &inputsLow, uint64_t &inputsHigh, uint8_t &POVstate, uint8_t &leftAxis, uint8_t &rightAxis, uint8_t &clutchAxis)
Sets data for the input report.
void onReset(uint8_t *report)
Resets data for the input report.
BatteryStatusChrData toBleBatteryStatus(const BatteryStatus &status)
Convert a battery status to the data format required by the BAS specification (BLE only)
void onSetFeature(uint8_t report_id, const uint8_t *buffer, uint16_t len)
Receive a feature report.
Everything related to pixel control.
Definition SimWheel.hpp:724
Everything related to power management.
Definition SimWheel.hpp:605
Everything related to the user interface, if available.
Definition SimWheel.hpp:776
Data format for the Battery Level Status characteristic (packed)
Battery status.
Decoupling event.
Fake input specification used for testing.