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 <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...
 
class  invalid_user_input_number
 Exception for invalid user-defined input numbers. More...
 
struct  InputNumber
 Firmware-defined input numbers in the range [0,63] or unspecified. More...
 
class  InputNumberCombination
 Combination of input numbers. More...
 
struct  UserInputNumber
 User-defined input numbers in the range [0,127]. 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...
 
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::vector< GPIOGPIOCollection
 Collection of GPIOs.
 
typedef std::vector< InputGPIOInputGPIOCollection
 Collection of input GPIOs.
 
typedef std::vector< 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
}
 Pixel driver. More...
 
enum class  PixelFormat {
  AUTO = 0 , RGB , RBG , GRB ,
  GBR , BRG , BGR
}
 Byte order of pixel data. More...
 

Functions

template<typename T >
bool addIfNotExists (T item, std::vector< T > &vector)
 Add an item to a collection without duplicates.
 
int map_value (int x, int in_min, int in_max, int out_min, int out_max)
 Equivalent to Arduino's map()
 

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 491 of file SimWheelTypes.hpp.

◆ JOY_B

#define JOY_B   1

Game pad button "B".

Definition at line 492 of file SimWheelTypes.hpp.

◆ JOY_BACK

#define JOY_BACK   6

Game pad back button.

Definition at line 499 of file SimWheelTypes.hpp.

◆ JOY_LB

#define JOY_LB   4

Game pad left shoulder button.

Definition at line 495 of file SimWheelTypes.hpp.

◆ JOY_LSHIFT_PADDLE

#define JOY_LSHIFT_PADDLE   4

Left shift paddle.

Definition at line 497 of file SimWheelTypes.hpp.

◆ JOY_LTHUMBSTICK_CLICK

#define JOY_LTHUMBSTICK_CLICK   8

Game pad left thumb stick click button.

Definition at line 501 of file SimWheelTypes.hpp.

◆ JOY_RB

#define JOY_RB   5

Game pad right shoulder button.

Definition at line 496 of file SimWheelTypes.hpp.

◆ JOY_RSHIFT_PADDLE

#define JOY_RSHIFT_PADDLE   5

Right shift paddle.

Definition at line 498 of file SimWheelTypes.hpp.

◆ JOY_RTHUMBSTICK_CLICK

#define JOY_RTHUMBSTICK_CLICK   9

Game pad right thumb stick click button.

Definition at line 502 of file SimWheelTypes.hpp.

◆ JOY_START

#define JOY_START   7

Game pad start button.

Definition at line 500 of file SimWheelTypes.hpp.

◆ JOY_X

#define JOY_X   2

Game pad button "X".

Definition at line 493 of file SimWheelTypes.hpp.

◆ JOY_Y

#define JOY_Y   3

Game pad button "Y".

Definition at line 494 of file SimWheelTypes.hpp.

Typedef Documentation

◆ GPIOCollection

typedef std::vector<GPIO> GPIOCollection

Collection of GPIOs.

Definition at line 850 of file SimWheelTypes.hpp.

◆ InputGPIOCollection

typedef std::vector<InputGPIO> InputGPIOCollection

Collection of input GPIOs.

Definition at line 852 of file SimWheelTypes.hpp.

◆ OutputGPIOCollection

typedef std::vector<OutputGPIO> OutputGPIOCollection

Collection of output GPIOs.

Definition at line 854 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 902 of file SimWheelTypes.hpp.

◆ I2CBus

enum class I2CBus
strong

I2C bus controller.

Definition at line 872 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.

Definition at line 940 of file SimWheelTypes.hpp.

◆ PixelFormat

enum class PixelFormat
strong

Byte order of pixel data.

Enumerator
AUTO 

Auto-detect based on pixel driver.

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 958 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 926 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 887 of file SimWheelTypes.hpp.

◆ UNSPECIFIED

enum class UNSPECIFIED
strong

Unspecified value type.

Enumerator
VALUE 

Unspecified value.

Definition at line 236 of file SimWheelTypes.hpp.

Function Documentation

◆ addIfNotExists()

template<typename T >
bool addIfNotExists ( T item,
std::vector< T > & vector )

Add an item to a collection without duplicates.

Template Parameters
TItem class
Parameters
itemItem to be added
vectorCollection
Returns
true If added
false If already exists

Definition at line 199 of file SimWheelTypes.hpp.

◆ 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 218 of file SimWheelTypes.hpp.