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

Types and constants used everywhere for firmware implementation. More...

#include <cstdint>
#include <vector>
#include <optional>
#include "SimWheelTypes.hpp"

Go to the source code of this file.

Classes

struct  FakeInput
 Fake input specification used for testing. More...
 
struct  DeviceCapabilities
 Set of device capabilities. More...
 
class  BitQueue
 Queue for 61 bits. More...
 
struct  DecouplingEvent
 Decoupling event. More...
 
struct  BatteryStatus
 Battery status. More...
 
struct  BatteryStatusChrData
 Data format for the Battery Level Status characteristic (packed) More...
 
class  static_event< Args >
 Publish-subscribe event (forever subscribed) More...
 

Macros

#define PRIVATE   private
 For testing.
 
#define PROTECTED   protected
 For testing.
 
#define CLUTCH_NONE_VALUE   0
 Value for a fully released clutch.
 
#define CLUTCH_FULL_VALUE   254
 Value for a fully engaged clutch.
 
#define CLUTCH_DEFAULT_VALUE   127
 Default bite point value.
 
#define CLUTCH_1_4_VALUE   64
 Value for 1/4 engaged clutch.
 
#define CLUTCH_3_4_VALUE   192
 Value for 3/4 engaged clutch.
 
#define CLUTCH_INVALID_VALUE   255
 Invalid clutch value used for masking.
 
#define INPUT_TASK_PRIORITY   (tskIDLE_PRIORITY + 2)
 Priority of background tasks.
 
#define MAX_DECOUPLING_EVENT_COUNT   64
 Queue size for decoupling events.
 
#define AUTO_POWER_OFF_DELAY_SECS   60
 Time to wait for connection before power off (in seconds)
 

Enumerations

enum class  DeviceCapability : uint8_t {
  CLUTCH_BUTTON = 0 , CLUTCH_ANALOG = 1 , ALT = 2 , DPAD = 3 ,
  BATTERY = 4 , BATTERY_CALIBRATION_AVAILABLE = 5 , TELEMETRY_POWERTRAIN = 6 , TELEMETRY_ECU = 7 ,
  TELEMETRY_RACE_CONTROL = 8 , TELEMETRY_GAUGES = 9 , ROTARY_ENCODERS = 10 , TELEMETRY_WHEELS = 11 ,
  _MAX_VALUE = TELEMETRY_WHEELS
}
 Enumeration of device capabilities. More...
 
enum class  ClutchWorkingMode : uint8_t {
  CLUTCH = 0 , AXIS , ALT , BUTTON ,
  LAUNCH_CONTROL_MASTER_LEFT , LAUNCH_CONTROL_MASTER_RIGHT , _MAX_VALUE = LAUNCH_CONTROL_MASTER_RIGHT , _DEFAULT_VALUE = CLUTCH
}
 User-selected working mode of the clutch paddles. More...
 
enum class  AltButtonsWorkingMode : uint8_t { Regular = 0 , ALT , _MAX_VALUE = ALT , _DEFAULT_VALUE = ALT }
 User-selected working mode of "ALT" buttons. More...
 
enum class  PulseWidthMultiplier : uint8_t {
  X1 = 1 , X2 , X3 , X4 ,
  X5 , X6 , _MAX_VALUE = X6 , _DEFAULT_VALUE = X2
}
 User-selected pulse width multiplier. More...
 
enum class  DPadWorkingMode : uint8_t { Regular = 0 , Navigation , _MAX_VALUE = Navigation , _DEFAULT_VALUE = Navigation }
 User-selected working mode of directional pads. More...
 
enum class  UserSetting : uint8_t {
  ALL = 0 , AXIS_CALIBRATION , AXIS_POLARITY , PULSE_WIDTH ,
  SECURITY_LOCK , BITE_POINT , CLUTCH_WORKING_MODE , ALT_WORKING_MODE ,
  DPAD_WORKING_MODE , INPUT_MAP , CUSTOM_HARDWARE_ID , BATTERY_AUTO_CALIBRATION ,
  BATTERY_CALIBRATION_DATA , _MAX_VALUE = BATTERY_CALIBRATION_DATA
}
 User setting to be stored in flash memory. More...
 
enum  SimpleCommand {
  CMD_RESERVED = 0 , CMD_AXIS_RECALIBRATE = 1 , CMD_BATT_RECALIBRATE = 2 , CMD_RESET_BUTTONS_MAP = 3 ,
  CMD_SAVE_NOW = 4 , CMD_REVERSE_LEFT_AXIS = 5 , CMD_REVERSE_RIGHT_AXIS = 6 , CMD_SHOW_PIXELS = 7 ,
  CMD_RESET_PIXELS = 8 , _MAX_VALUE = 8
}
 Simple commands accepted from a feature HID report. More...
 

Variables

static_event OnStart
 System startup.
 
static_event OnShutdown
 The system is about to shutdown.
 
static_event OnDisconnected
 No host connection.
 
static_event OnConnected
 Host connection.
 
static_event< uint8_t > OnBitePoint
 New bite point.
 
static_event< ClutchWorkingModeOnClutchWorkingMode
 New clutch working mode.
 
static_event< AltButtonsWorkingModeOnAltButtonsWorkingMode
 New ALT buttons working mode.
 
static_event OnDPadWorkingMode
 New DPAD working mode.
 
static_event OnSettingsSaved
 Save event.
 
static_event< PulseWidthMultiplierOnPulseWidthMultiplier
 New pulse width multiplier.
 
static_event OnLowBattery
 Notified when a low battery condition is detected.
 
static_event< const BatteryStatus & > OnBatteryStatus
 New battery level (state of charge) or battery status.
 
static_event< UserSettingLoadSetting
 Request to load a user setting.
 
static_event< UserSettingSaveSetting
 Request to save a user setting.
 

Detailed Description

Types and constants used everywhere for firmware implementation.

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

Definition in file InternalTypes.hpp.

Macro Definition Documentation

◆ AUTO_POWER_OFF_DELAY_SECS

#define AUTO_POWER_OFF_DELAY_SECS   60

Time to wait for connection before power off (in seconds)

Definition at line 747 of file InternalTypes.hpp.

◆ CLUTCH_1_4_VALUE

#define CLUTCH_1_4_VALUE   64

Value for 1/4 engaged clutch.

Definition at line 202 of file InternalTypes.hpp.

◆ CLUTCH_3_4_VALUE

#define CLUTCH_3_4_VALUE   192

Value for 3/4 engaged clutch.

Definition at line 204 of file InternalTypes.hpp.

◆ CLUTCH_DEFAULT_VALUE

#define CLUTCH_DEFAULT_VALUE   127

Default bite point value.

Definition at line 200 of file InternalTypes.hpp.

◆ CLUTCH_FULL_VALUE

#define CLUTCH_FULL_VALUE   254

Value for a fully engaged clutch.

Definition at line 198 of file InternalTypes.hpp.

◆ CLUTCH_INVALID_VALUE

#define CLUTCH_INVALID_VALUE   255

Invalid clutch value used for masking.

Definition at line 206 of file InternalTypes.hpp.

◆ CLUTCH_NONE_VALUE

#define CLUTCH_NONE_VALUE   0

Value for a fully released clutch.

Definition at line 196 of file InternalTypes.hpp.

◆ INPUT_TASK_PRIORITY

#define INPUT_TASK_PRIORITY   (tskIDLE_PRIORITY + 2)

Priority of background tasks.

Definition at line 272 of file InternalTypes.hpp.

◆ MAX_DECOUPLING_EVENT_COUNT

#define MAX_DECOUPLING_EVENT_COUNT   64

Queue size for decoupling events.

Definition at line 361 of file InternalTypes.hpp.

◆ PRIVATE

#define PRIVATE   private

For testing.

Definition at line 25 of file InternalTypes.hpp.

◆ PROTECTED

#define PROTECTED   protected

For testing.

Definition at line 27 of file InternalTypes.hpp.

Enumeration Type Documentation

◆ AltButtonsWorkingMode

enum class AltButtonsWorkingMode : uint8_t
strong

User-selected working mode of "ALT" buttons.

Enumerator
Regular 

Regular button.

ALT 

Engage or disengage alternate mode.

Definition at line 216 of file InternalTypes.hpp.

◆ ClutchWorkingMode

enum class ClutchWorkingMode : uint8_t
strong

User-selected working mode of the clutch paddles.

Enumerator
CLUTCH 

F1-Style clutch. Must be the first in the enum: do not change.

AXIS 

Independent axes.

ALT 

Alternate mode.

BUTTON 

Regular buttons.

LAUNCH_CONTROL_MASTER_LEFT 

Launch control (left paddle is master)

LAUNCH_CONTROL_MASTER_RIGHT 

Launch control (right paddle is master)

Definition at line 177 of file InternalTypes.hpp.

◆ DeviceCapability

enum class DeviceCapability : uint8_t
strong

Enumeration of device capabilities.

Enumerator
CLUTCH_BUTTON 

Has digital clutch paddles (switches)

CLUTCH_ANALOG 

Has analog clutch paddles (potentiometers)

ALT 

Has "ALT" buttons.

DPAD 

Has a directional pad.

BATTERY 

Battery-operated.

BATTERY_CALIBRATION_AVAILABLE 

Has battery calibration data.

TELEMETRY_POWERTRAIN 

Able to display powertrain telemetry data.

TELEMETRY_ECU 

Able to display ECU telemetry data.

TELEMETRY_RACE_CONTROL 

Able to display race control telemetry data.

TELEMETRY_GAUGES 

Able to display telemetry data for gauges.

ROTARY_ENCODERS 

Has one or more rotary encoders.

TELEMETRY_WHEELS 

Able to display wheel telemetry data.

Definition at line 96 of file InternalTypes.hpp.

◆ DPadWorkingMode

enum class DPadWorkingMode : uint8_t
strong

User-selected working mode of directional pads.

Enumerator
Regular 

Regular button.

Navigation 

Navigation control.

Definition at line 254 of file InternalTypes.hpp.

◆ PulseWidthMultiplier

enum class PulseWidthMultiplier : uint8_t
strong

User-selected pulse width multiplier.

Definition at line 234 of file InternalTypes.hpp.

◆ SimpleCommand

Simple commands accepted from a feature HID report.

Enumerator
CMD_RESERVED 

Not a command, reserved to avoid mistakes.

CMD_AXIS_RECALIBRATE 

Recalibrate analog axes (if any)

CMD_BATT_RECALIBRATE 

Restart battery auto-calibration.

CMD_RESET_BUTTONS_MAP 

Reset buttons map to factory defaults.

CMD_SAVE_NOW 

Save all user settings to flash memory immediately.

CMD_REVERSE_LEFT_AXIS 

Reverse left axis (if any)

CMD_REVERSE_RIGHT_AXIS 

Reverse right axis (if any)

CMD_SHOW_PIXELS 

Display all pixels in all pixel groups.

CMD_RESET_PIXELS 

Turn off all pixels in all groups.

Definition at line 757 of file InternalTypes.hpp.

◆ UserSetting

enum class UserSetting : uint8_t
strong

User setting to be stored in flash memory.

Warning
Must be in the range [0,63]

Definition at line 483 of file InternalTypes.hpp.

Variable Documentation

◆ LoadSetting

static_event<UserSetting> LoadSetting
inline

Request to load a user setting.

Note
Notified when a user setting must be loaded

Definition at line 731 of file InternalTypes.hpp.

◆ OnAltButtonsWorkingMode

static_event<AltButtonsWorkingMode> OnAltButtonsWorkingMode
inline

New ALT buttons working mode.

Note
Notified when that working mode changes

Definition at line 694 of file InternalTypes.hpp.

◆ OnBatteryStatus

static_event<const BatteryStatus &> OnBatteryStatus
inline

New battery level (state of charge) or battery status.

Note
Notified when the state of charge changes by 1% or more.

Definition at line 725 of file InternalTypes.hpp.

◆ OnBitePoint

static_event<uint8_t> OnBitePoint
inline

New bite point.

Note
Notified when the clutch's bite point changes

Definition at line 682 of file InternalTypes.hpp.

◆ OnClutchWorkingMode

static_event<ClutchWorkingMode> OnClutchWorkingMode
inline

New clutch working mode.

Note
Notified when that working mode changes

Definition at line 688 of file InternalTypes.hpp.

◆ OnConnected

static_event OnConnected
inline

Host connection.

Note
Notified when this condition is detected.

Definition at line 676 of file InternalTypes.hpp.

◆ OnDisconnected

static_event OnDisconnected
inline

No host connection.

Note
Notified when this condition is detected, but not while it persists.

Definition at line 670 of file InternalTypes.hpp.

◆ OnDPadWorkingMode

static_event OnDPadWorkingMode
inline

New DPAD working mode.

Note
Notified when that working mode changes

Definition at line 700 of file InternalTypes.hpp.

◆ OnLowBattery

static_event OnLowBattery
inline

Notified when a low battery condition is detected.

Note
This event is notified at timed intervals while the condition persists.

Definition at line 719 of file InternalTypes.hpp.

◆ OnPulseWidthMultiplier

static_event<PulseWidthMultiplier> OnPulseWidthMultiplier
inline

New pulse width multiplier.

Note
Notified when changed

Definition at line 712 of file InternalTypes.hpp.

◆ OnSettingsSaved

static_event OnSettingsSaved
inline

Save event.

Note
Notified when a user setting is saved to persistent storage

Definition at line 706 of file InternalTypes.hpp.

◆ OnShutdown

static_event OnShutdown
inline

The system is about to shutdown.

Note
Notified only once.

Definition at line 663 of file InternalTypes.hpp.

◆ OnStart

static_event OnStart
inline

System startup.

Note
Notified only once.

Definition at line 657 of file InternalTypes.hpp.

◆ SaveSetting

static_event<UserSetting> SaveSetting
inline

Request to save a user setting.

Note
Notified when a user setting must be saved to persistent storage

Definition at line 737 of file InternalTypes.hpp.