OpenSourceSimWheelESP32
Open-source wireless steering wheel/button box for ESP32 boards
Loading...
Searching...
No Matches
SimWheelInternals.hpp File Reference

System functionality not exposed to the end user. More...

#include "InternalTypes.hpp"
#include "SimWheelTypes.hpp"

Go to the source code of this file.

Namespaces

namespace  internals::hid::common
 Common functionality to all HID implementations.
 

Functions

void internals::batteryMonitor::getReady ()
 Prepare to run.
 
void internals::batteryMonitor::configureForTesting ()
 Configure period, warning and power-off limits for testing.
 
void internals::batteryMonitor::configureFakeMonitor (BatteryStatus *fakeStatus)
 Configure a fake monitor for testing.
 
void * internals::batteryMonitor::getHardwareInstance ()
 Get the Hardware Instance object.
 
void internals::batteryCalibration::getReady ()
 Prepare to run.
 
void internals::batteryCalibration::clear ()
 Clear calibration data (but may persist in flash memory).
 
void internals::batteryCalibration::addSample (int reading)
 Add an ADC reading to calibration data. The battery should get fully charged before first call.
 
void internals::pixels::getReady ()
 Prepare to run.
 
void internals::pixels::show (const ::std::vector< Pixel > &telemetry, const ::std::vector< Pixel > &buttons, const ::std::vector< Pixel > &individual)
 Show pixel data in all groups.
 
uint8_t internals::pixels::getCount (PixelGroup group)
 Get the total number of pixels in a group.
 
void internals::ui::getReady ()
 Prepare to run.
 
void internals::ui::routeInput (uint8_t inputNumber)
 Route an input event to all UI instances.
 
void internals::inputs::getReady ()
 Prepare to run.
 
void internals::inputs::addFakeInput (FakeInput *instance)
 Add a fake input instance for testing.
 
void internals::inputs::notifyInputEvent (const DecouplingEvent &input)
 Push an input event into the decoupling queue (for testing)
 
void internals::inputHub::getReady ()
 Check that user configuration is correct.
 
void internals::inputHub::onRawInput (DecouplingEvent &input)
 Process a single input event.
 
void internals::storage::getReady ()
 Prepare to run.
 
void internals::inputMap::getReady ()
 Prepare to run.
 
void internals::inputMap::clear ()
 Clear the whole map (for testing) and the custom defaults.
 
void internals::inputMap::map (bool isAltModeEngaged, uint128_t &bitmap)
 Map a firmware-defined input bitmap.
 
void internals::power::getReady ()
 Prepare to run.
 
void internals::hid::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.
 
bool internals::hid::supportsCustomHardwareID ()
 Support for a custom PID/VID.
 
bool internals::hid::isConnected ()
 Tell if there is a host connection.
 
void internals::hid::reportChangeInConfig ()
 Report a change in user settings (clutch function, etc.)
 
void internals::hid::reportBatteryLevel (const BatteryStatus &status)
 Report current battery level and status to the host computer.
 
void internals::hid::reportInput (const uint128_t &inputs, uint8_t POVstate, uint8_t leftAxis, uint8_t rightAxis, uint8_t clutchAxis)
 Report HID inputs.
 
void internals::hid::reset ()
 Report all inputs as not active.
 
void internals::hid::common::getReady ()
 Prepare to run.
 
uint16_t internals::hid::common::onGetFeature (uint8_t report_id, uint8_t *buffer, uint16_t len)
 Send feature report.
 
void internals::hid::common::onSetFeature (uint8_t report_id, const uint8_t *buffer, uint16_t len)
 Receive a feature report.
 
void internals::hid::common::onOutput (uint8_t report_id, const uint8_t *buffer, uint16_t len)
 Receive an output report.
 
void internals::hid::common::onReset (uint8_t *report)
 Resets data for the input report.
 
void internals::hid::common::onReportInput (uint8_t *report, bool notifyConfigChanges, const uint128_t &inputs, uint8_t POVstate, uint8_t leftAxis, uint8_t rightAxis, uint8_t clutchAxis)
 Sets data for the input report.
 
BatteryStatusChrData internals::hid::common::toBleBatteryStatus (const BatteryStatus &status)
 Convert a battery status to the data format required by the BAS specification (BLE only)
 

Detailed Description

System functionality not exposed to the end user.

Author
Ángel Fernández Pineda. Madrid. Spain.
Date
2025-02-11

Definition in file SimWheelInternals.hpp.

Function Documentation

◆ addFakeInput()

void internals::inputs::addFakeInput ( FakeInput * instance)

Add a fake input instance for testing.

Parameters
instanceFake iput instance

◆ addSample()

void internals::batteryCalibration::addSample ( int reading)

Add an ADC reading to calibration data. The battery should get fully charged before first call.

Parameters
readingAn ADC reading of current battery(+) voltage.

◆ begin()

void internals::hid::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.

Warning
Setting both usb_enable and ble_enable to false will cause a runtime error
Note
When USB is enabled, VID will be ignored as another USB-IF license would be required. However, Espressif (the license holder) allows to use a custom PID . See https://docs.espressif.com/projects/esp-iot-solution/en/latest/usb/usb_overview/usb_vid_pid.html
Parameters
deviceNameConfigured device name
deviceManufacturerConfigured device manufacturer
enableAutoPowerOffRequest for automatic shutdown (may be ignored)
VIDConfigured custom vendor ID (may be ignored)
PIDConfigured custom product ID
usb_enableif true and available, USB connectivity is enabled
ble_enableif true and available, BLE connectivity is enabled
exclusiveif true, any previous connection is dropped when another comes

◆ configureFakeMonitor()

void internals::batteryMonitor::configureFakeMonitor ( BatteryStatus * fakeStatus)

Configure a fake monitor for testing.

Parameters
fakeStatusPointer to variable holding the fake battery status

◆ getCount()

uint8_t internals::pixels::getCount ( PixelGroup group)

Get the total number of pixels in a group.

Note
Only available after the OnStart event
Parameters
groupGroup of pixels
Returns
byte Number of pixels in the given group

◆ getHardwareInstance()

void * internals::batteryMonitor::getHardwareInstance ( )

Get the Hardware Instance object.

Note
For testing
Returns
void* Untyped hardware instance (must be type-casted)

◆ isConnected()

bool internals::hid::isConnected ( )

Tell if there is a host connection.

Returns
true when connected to a computer
false when not connected

◆ map()

void internals::inputMap::map ( bool isAltModeEngaged,
uint128_t & bitmap )

Map a firmware-defined input bitmap.

Parameters
isAltModeEngagedTrue if ALT mode is engaged, false otherwise.
[in,out]bitmapAt call, firmware-defined input bitmap. At return, user-defined input bitmap.

◆ notifyInputEvent()

void internals::inputs::notifyInputEvent ( const DecouplingEvent & input)
inline

Push an input event into the decoupling queue (for testing)

Parameters
inputEvent to push

◆ onRawInput()

void internals::inputHub::onRawInput ( DecouplingEvent & input)

Process a single input event.

Parameters
inputEvent to process

◆ reportBatteryLevel()

void internals::hid::reportBatteryLevel ( const BatteryStatus & status)

Report current battery level and status to the host computer.

Warning
May be called before internals::hid::begin()
Parameters
statusBattery status

◆ reportInput()

void internals::hid::reportInput ( const uint128_t & inputs,
uint8_t POVstate,
uint8_t leftAxis,
uint8_t rightAxis,
uint8_t clutchAxis )

Report HID inputs.

Parameters
[in]inputsState of input numbers
[in]POVstateState of the hat switch (POV or DPAD), this is, a value in the range 0 (no input) to 8 (up-left).
[in]leftAxisPosition of the left clutch, in the range 0-254.
[in]rightAxisPosition of the right clutch, in the range 0-254.
[in]clutchAxisPosition of the combined clutch, in the range 0-254.

◆ routeInput()

void internals::ui::routeInput ( uint8_t inputNumber)

Route an input event to all UI instances.

Parameters
inputNumberInput number

◆ show()

void internals::pixels::show ( const ::std::vector< Pixel > & telemetry,
const ::std::vector< Pixel > & buttons,
const ::std::vector< Pixel > & individual )

Show pixel data in all groups.

Note
if any parameter is nullptr, there is no display in that group
Pixel data is in RGB format
Parameters
telemetryPixel data for the telemetry group
buttonsPixel data for the backlit buttons group
individualPixel data for the individual pixels group

◆ supportsCustomHardwareID()

bool internals::hid::supportsCustomHardwareID ( )

Support for a custom PID/VID.

Returns
true If VID and PID can be provided externally via begin()
false If the externally provided VID/PID are ignored