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

Types and constants required for custom firmware setup. More...

#include <cstdint>
#include <string>
#include <stdexcept>
#include <set>
#include <vector>
#include <initializer_list>
#include <map>
#include <algorithm>
#include "driver/rtc_io.h"
#include "hal/gpio_types.h"
#include "driver/gpio.h"
#include "esp32-hal-psram.h"

Go to the source code of this file.

Classes

class  invalid_input_number
 Exception for invalid input numbers. More...
 
class  gpio_error
 Exception for invalid GPIO pin numbers. More...
 
class  empty_input_number_set
 Exception for empty input number specifications. More...
 
class  unknown_input_number
 Exception for unknown input numbers. More...
 
struct  uint128_t
 128-bit integer More...
 
struct  InputNumber
 Firmware-defined input numbers in the range [0,127] or unspecified. More...
 
struct  InputNumberCombination
 Combination of input numbers. More...
 
struct  GPIO
 GPIO pin number. More...
 
struct  OutputGPIO
 Output-capable GPIO pin number. More...
 
struct  InputGPIO
 Input-capable GPIO pin number. More...
 
struct  ADC_GPIO
 ADC-capable GPIO pin number. More...
 
struct  RTC_GPIO
 RTC-capable GPIO pin number. More...
 
struct  TelemetryData
 Telemetry data. More...
 
struct  Pixel
 Pixel in 3-byte packed RGB format. More...
 
class  AbstractUserInterface
 Abstract interface for notifications and telemetry display. More...
 
class  PixelControlNotification
 Notifications using pixel control. More...
 

Macros

#define GPIO_IS_VALID_RTC_GPIO(pin)
 Validation of RTC GPIO pins.
 
#define JOY_A   0
 Game pad button "A".
 
#define JOY_B   1
 Game pad button "B".
 
#define JOY_X   2
 Game pad button "X".
 
#define JOY_Y   3
 Game pad button "Y".
 
#define JOY_LB   4
 Game pad left shoulder button.
 
#define JOY_RB   5
 Game pad right shoulder button.
 
#define JOY_LSHIFT_PADDLE   4
 Left shift paddle.
 
#define JOY_RSHIFT_PADDLE   5
 Right shift paddle.
 
#define JOY_BACK   6
 Game pad back button.
 
#define JOY_START   7
 Game pad start button.
 
#define JOY_LTHUMBSTICK_CLICK   8
 Game pad left thumb stick click button.
 
#define JOY_RTHUMBSTICK_CLICK   9
 Game pad right thumb stick click button.
 

Typedefs

typedef std::set< GPIOGPIOCollection
 Collection of GPIOs.
 
typedef std::set< InputGPIOInputGPIOCollection
 Collection of input GPIOs.
 
typedef std::set< OutputGPIOOutputGPIOCollection
 Collection of output GPIOs.
 

Enumerations

enum class  UNSPECIFIED { VALUE = 0xFF }
 Unspecified value type. More...
 
enum class  I2CBus { PRIMARY = 0 , SECONDARY }
 I2C bus controller. More...
 
enum class  PowerLatchMode : uint8_t { POWER_OPEN_DRAIN , POWER_OFF_HIGH , POWER_OFF_LOW }
 Supported power latch modes. More...
 
enum class  Connectivity : uint8_t {
  USB_BLE = 0 , USB_BLE_EXCLUSIVE = 1 , USB = 2 , BLE = 3 ,
  DUMMY = 4 , _DEFAULT = USB_BLE
}
 Connectivity choice. More...
 
enum class  PixelGroup { GRP_TELEMETRY = 0 , GRP_BUTTONS , GRP_INDIVIDUAL }
 Available RGB LED groups for pixel control. More...
 
enum class  PixelDriver {
  WS2811 = 0 , WS2812 , WS2815 , SK6812 ,
  UCS1903 , APA106
}
 Pixel driver. More...
 
enum class  PixelFormat : unsigned char {
  RGB = 0 , RBG , GRB , GBR ,
  BRG , BGR
}
 Byte order of pixel data starting with the least significant byte. More...
 

Functions

int map_value (int x, int in_min, int in_max, int out_min, int out_max)
 Equivalent to Arduino's map()
 
constexpr uint128_t operator<< (const uint128_t &source, ::std::size_t n) noexcept
 Shift left.
 
constexpr uint128_t operator>> (const uint128_t &source, ::std::size_t n) noexcept
 Shift right.
 
constexpr uint128_t operator| (uint128_t a, uint128_t b) noexcept
 Bitwise OR.
 
constexpr uint128_t operator& (uint128_t a, uint128_t b) noexcept
 Bitwise AND.
 
constexpr uint128_t operator^ (uint128_t a, uint128_t b) noexcept
 Bitwise XOR.
 
constexpr uint128_t operator~ (uint128_t a) noexcept
 Bitwise negation.
 
constexpr bool operator== (uint128_t a, uint128_t b) noexcept
 Check equality.
 
constexpr bool operator!= (uint128_t a, uint128_t b)
 Check inequality.
 

Detailed Description

Types and constants required for custom firmware setup.

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

Definition in file SimWheelTypes.hpp.

Macro Definition Documentation

◆ GPIO_IS_VALID_RTC_GPIO

#define GPIO_IS_VALID_RTC_GPIO ( pin)
Value:
rtc_gpio_is_valid_gpio(static_cast<gpio_num_t>(pin))

Validation of RTC GPIO pins.

Definition at line 35 of file SimWheelTypes.hpp.

◆ JOY_A

#define JOY_A   0

Game pad button "A".

Definition at line 807 of file SimWheelTypes.hpp.

◆ JOY_B

#define JOY_B   1

Game pad button "B".

Definition at line 808 of file SimWheelTypes.hpp.

◆ JOY_BACK

#define JOY_BACK   6

Game pad back button.

Definition at line 815 of file SimWheelTypes.hpp.

◆ JOY_LB

#define JOY_LB   4

Game pad left shoulder button.

Definition at line 811 of file SimWheelTypes.hpp.

◆ JOY_LSHIFT_PADDLE

#define JOY_LSHIFT_PADDLE   4

Left shift paddle.

Definition at line 813 of file SimWheelTypes.hpp.

◆ JOY_LTHUMBSTICK_CLICK

#define JOY_LTHUMBSTICK_CLICK   8

Game pad left thumb stick click button.

Definition at line 817 of file SimWheelTypes.hpp.

◆ JOY_RB

#define JOY_RB   5

Game pad right shoulder button.

Definition at line 812 of file SimWheelTypes.hpp.

◆ JOY_RSHIFT_PADDLE

#define JOY_RSHIFT_PADDLE   5

Right shift paddle.

Definition at line 814 of file SimWheelTypes.hpp.

◆ JOY_RTHUMBSTICK_CLICK

#define JOY_RTHUMBSTICK_CLICK   9

Game pad right thumb stick click button.

Definition at line 818 of file SimWheelTypes.hpp.

◆ JOY_START

#define JOY_START   7

Game pad start button.

Definition at line 816 of file SimWheelTypes.hpp.

◆ JOY_X

#define JOY_X   2

Game pad button "X".

Definition at line 809 of file SimWheelTypes.hpp.

◆ JOY_Y

#define JOY_Y   3

Game pad button "Y".

Definition at line 810 of file SimWheelTypes.hpp.

Typedef Documentation

◆ GPIOCollection

typedef std::set<GPIO> GPIOCollection

Collection of GPIOs.

Definition at line 1073 of file SimWheelTypes.hpp.

◆ InputGPIOCollection

typedef std::set<InputGPIO> InputGPIOCollection

Collection of input GPIOs.

Definition at line 1075 of file SimWheelTypes.hpp.

◆ OutputGPIOCollection

typedef std::set<OutputGPIO> OutputGPIOCollection

Collection of output GPIOs.

Definition at line 1077 of file SimWheelTypes.hpp.

Enumeration Type Documentation

◆ Connectivity

enum class Connectivity : uint8_t
strong

Connectivity choice.

Enumerator
USB_BLE 

Combined USB and BLE connectivity if available.

USB_BLE_EXCLUSIVE 

Combined USB and BLE connectivity with forced connection drop.

USB 

USB connectivity only, if available.

BLE 

BLE connectivity only, if available.

DUMMY 

No connectivity at all (for troubleshooting)

_DEFAULT 

Default connectivity.

Definition at line 1125 of file SimWheelTypes.hpp.

◆ I2CBus

enum class I2CBus
strong

I2C bus controller.

Definition at line 1095 of file SimWheelTypes.hpp.

◆ PixelDriver

enum class PixelDriver
strong

Pixel driver.

Enumerator
WS2811 

WS2811 driver.

WS2812 

WS2812 family.

WS2815 

WS2815 family.

SK6812 

SK6812 driver.

UCS1903 

UCS1903 driver.

APA106 

APA106 driver.

Definition at line 1163 of file SimWheelTypes.hpp.

◆ PixelFormat

enum class PixelFormat : unsigned char
strong

Byte order of pixel data starting with the least significant byte.

Enumerator
RGB 

Red-green-blue.

RBG 

Red-blue-green.

GRB 

Green-red-blue.

GBR 

Green-blue-red.

BRG 

Blue-red-green.

BGR 

Blue-green-red.

Definition at line 1307 of file SimWheelTypes.hpp.

◆ PixelGroup

enum class PixelGroup
strong

Available RGB LED groups for pixel control.

Enumerator
GRP_TELEMETRY 

Telemetry leds group.

GRP_BUTTONS 

Buttons lighting group.

GRP_INDIVIDUAL 

Individual leds group.

Definition at line 1149 of file SimWheelTypes.hpp.

◆ PowerLatchMode

enum class PowerLatchMode : uint8_t
strong

Supported power latch modes.

Enumerator
POWER_OPEN_DRAIN 

Power on when low voltage, power off when open drain.

POWER_OFF_HIGH 

Power on when low voltage, power off when high voltage.

POWER_OFF_LOW 

Power on when high voltage, power off when low voltage.

Definition at line 1110 of file SimWheelTypes.hpp.

◆ UNSPECIFIED

enum class UNSPECIFIED
strong

Unspecified value type.

Enumerator
VALUE 

Unspecified value.

Definition at line 188 of file SimWheelTypes.hpp.

Function Documentation

◆ map_value()

int map_value ( int x,
int in_min,
int in_max,
int out_min,
int out_max )
inline

Equivalent to Arduino's map()

Parameters
xInput value
in_minInput min value
in_maxInput max value
out_minOutput min value
out_maxOutput max value
Returns
int Output value

Definition at line 170 of file SimWheelTypes.hpp.

◆ operator!=()

bool operator!= ( uint128_t a,
uint128_t b )
inlineconstexpr

Check inequality.

Parameters
aLeft operand
bRight operand
Returns
true If not equal
false If equal

Definition at line 483 of file SimWheelTypes.hpp.

◆ operator&()

uint128_t operator& ( uint128_t a,
uint128_t b )
inlineconstexprnoexcept

Bitwise AND.

Parameters
aLeft operand
bRight operand
Returns
constexpr uint128_t Resulting bitmap

Definition at line 425 of file SimWheelTypes.hpp.

◆ operator<<()

uint128_t operator<< ( const uint128_t & source,
::std::size_t n )
inlineconstexprnoexcept

Shift left.

Parameters
sourceBitmap
nCount of bits to shift
Returns
constexpr uint128_t Shifted bitmap

Definition at line 346 of file SimWheelTypes.hpp.

◆ operator==()

bool operator== ( uint128_t a,
uint128_t b )
inlineconstexprnoexcept

Check equality.

Parameters
aLeft operand
bRight operand
Returns
true If equal
false If not equal

Definition at line 470 of file SimWheelTypes.hpp.

◆ operator>>()

uint128_t operator>> ( const uint128_t & source,
::std::size_t n )
inlineconstexprnoexcept

Shift right.

Parameters
sourceBitmap
nCount of bits to shift
Returns
constexpr uint128_t Shifted bitmap

Definition at line 378 of file SimWheelTypes.hpp.

◆ operator^()

uint128_t operator^ ( uint128_t a,
uint128_t b )
inlineconstexprnoexcept

Bitwise XOR.

Parameters
aLeft operand
bRight operand
Returns
constexpr uint128_t Resulting bitmap

Definition at line 440 of file SimWheelTypes.hpp.

◆ operator|()

uint128_t operator| ( uint128_t a,
uint128_t b )
inlineconstexprnoexcept

Bitwise OR.

Parameters
aLeft operand
bRight operand
Returns
constexpr uint128_t Resulting bitmap

Definition at line 410 of file SimWheelTypes.hpp.

◆ operator~()

uint128_t operator~ ( uint128_t a)
inlineconstexprnoexcept

Bitwise negation.

Parameters
aOperand
Returns
constexpr uint128_t Resulting bitmap

Definition at line 454 of file SimWheelTypes.hpp.