JBWOPR
Loading...
Searching...
No Matches
JBWoprDevice Class Reference

W.O.P.R. device base class. More...

#include <jbwopr.h>

Inheritance diagram for JBWoprDevice:
JBWoprWiFiDevice JBWoprMqttDevice JBWoprHADevice

Public Member Functions

 JBWoprDevice ()
 JBWoprDevice constructor.
 
virtual bool begin (JBWoprBoardVariant variant=JBWoprBoardVariant::ORIGINAL)
 Initialize JBWoprDevice.
 
virtual bool begin (JBWoprBoardVariant variant, JBWoprBoardPins pins)
 Initialize JBWoprDevice.
 
virtual void loop ()
 JBWoprDevice loop.
 
JBWoprBoardVariant getBoardVariant ()
 Get W.O.P.R board variant.
 
JBWoprConfigurationgetConfiguration ()
 Get current JBWoprDevice configuration.
 
virtual void setLogLevel (LogLevel level)
 Set log level.
 
virtual LogLevel getLogLevel ()
 Get log level.
 
void effectsRegisterDefaultEffect (JBWoprEffectBase *effect)
 Register default effect.
 
bool effectsDefaultEffectIsRunning ()
 Check if default effect is running.
 
void effectsRegisterEffect (JBWoprEffectBase *effect)
 Register effect.
 
std::vector< JBWoprEffectBase * > effectsGetRegisteredEffects ()
 Get a list of registered effects.
 
JBWoprEffectBaseeffectsGetCurrentEffect ()
 Get current effect.
 
virtual void effectsStartCurrentEffect ()
 Start current effect.
 
virtual void effectsStopCurrentEffect ()
 Stop current effect.
 
bool effectsCurrentEffectIsRunning ()
 Check if current effect is running.
 
virtual void effectsStartEffect (JBWoprEffectBase *effect)
 Start effect.
 
virtual void effectsStartEffect (const std::string &name)
 Start named effect.
 
virtual void effectsStartEffect (const char *name)
 Start named effect.
 
std::array< Adafruit_AlphaNum4, 3 > getDisplay ()
 Get display.
 
virtual void displaySetState (bool state)
 Set display state.
 
virtual void displayClear ()
 Clear display.
 
virtual void displayShow ()
 Force display to show current data.
 
virtual void displaySetBrightness (uint8_t val)
 Set display brightness percentage.
 
virtual void displaySetChar (uint8_t index, char chr)
 Set individual display character.
 
virtual void displayShowText (const char *text, JBTextAlignment alignment)
 Set display text.
 
virtual void displayShowText (const std::string &text, JBTextAlignment alignment)
 Set display text.
 
virtual void displayShowText (const String &text, JBTextAlignment alignment)
 Set display text.
 
virtual void displayShowText (const char *text)
 Set display text, left aligned.
 
virtual void displayShowText (const std::string &text)
 Set display text, left aligned.
 
virtual void displayShowText (const String &text)
 Set display text, left aligned.
 
virtual void displayScrollText (const char *text, uint16_t delay_ms)
 Set display scroll text.
 
virtual void displayScrollText (const String &text, uint16_t delay_ms)
 Set display scroll text.
 
virtual void displayScrollText (const std::string &text, uint16_t delay_ms)
 Set display scroll text.
 
virtual void displayScrollText (const char *text)
 Set display scroll text with a delay of 100 ms.
 
virtual void displayScrollText (const std::string &text)
 Set display scroll text with a delay of 100 ms.
 
virtual void displayScrollText (const String &text)
 Set display scroll text with a delay of 100 ms.
 
Adafruit_NeoPixel * getDefconLeds ()
 Get DEFCON LEDs.
 
virtual void defconLedsSetState (bool state)
 Set DEFCON state.
 
virtual void defconLedsSetBrightness (uint8_t brightness)
 Set DEFCON LED's brightness level.
 
virtual void defconLedsSetDefconLevel (JBDefconLevel level)
 Set DEFCON level.
 
virtual void defconLedsSetColor (uint32_t color)
 Set all DEFCON LED's color.
 
virtual void defconLedsClear ()
 Clear all DEFCON LEDs.
 
virtual void defconLedSetColor (JBDefconLevel level, uint32_t color)
 Set individual DEFCON LED's color.
 
virtual void defconLedSetDefconStateColor (JBDefconLevel level, uint32_t color)
 Set color for a DEFCON level.
 
void audioPlayTone (const uint16_t freq)
 Play audio tone.
 
void audioPlayNote (note_t note, uint8_t octave)
 Play audio tone.
 
void audioClear ()
 Stop audio playback.
 
OneButton * getButtonFrontLeft ()
 Get front left button OneButton instance.
 
OneButton * getButtonFrontRight ()
 Get front right button OneButton instance.
 
OneButton * getButtonBackTop ()
 Get back top button OneButton instance.
 
OneButton * getButtonBackBottom ()
 Get back bottom button OneButton instance.
 
virtual void buttonFrontLeftSetClickCallback (std::function< void()> func)
 Set front left button click callback.
 
virtual void buttonFrontLeftSetDoubleClickCallback (std::function< void()> func)
 Set front left button double click callback.
 
virtual void buttonFrontRightSetClickCallback (std::function< void()> func)
 Set front right button click callback.
 
virtual void buttonFrontRightSetDoubleClickCallback (std::function< void()> func)
 Set front right button double click callback.
 
virtual void buttonBackTopSetClickCallback (std::function< void()> func)
 Set back top button click callback.
 
virtual void buttonBackTopSetDoubleClickCallback (std::function< void()> func)
 Set back top button double click callback.
 
virtual void buttonBackBottomSetClickCallback (std::function< void()> func)
 Set back top button long press callback.
 
virtual void buttonBackBottomSetDoubleClickCallback (std::function< void()> func)
 Set back bottom button double click callback.
 

Public Attributes

const char * DEFCON_STRINGS [6] { "DEFCON 1", "DEFCON 2", "DEFCON 3", "DEFCON 4", "DEFCON 5", "None" }
 

Protected Member Functions

JBDefconLevel _getDefconLevel (std::string value)
 Get DEFCON level from string value.
 
std::string _getDefconLevelString (JBDefconLevel level)
 Get DEFCON level string from DEFCON level.
 
uint32_t _getDefconLedsPixel (JBDefconLevel level)
 Get DEFCON LED strip pixel from DEFCON level.
 
virtual void _buttonFrontLeftClick ()
 Front left button click callback.
 
virtual void _buttonFrontLeftDoubleClick ()
 Front left button double click callback.
 
virtual void _buttonFrontRightClick ()
 Front right button click callback.
 
virtual void _buttonFrontRightDoubleClick ()
 Front right button double click callback.
 
virtual void _buttonBackTopClick ()
 Back top button click callback.
 
virtual void _buttonBackTopDoubleClick ()
 Back top button double click callback.
 
virtual void _buttonBackBottomClick ()
 Back bottom button click callback.
 
virtual void _buttonBackBottomDoubleClick ()
 Back bottom button double click callback.
 

Static Protected Member Functions

static void _staticButtonFrontLeftClickCallback (void *data)
 Front left button internal click callback.
 
static void _staticButtonFrontLeftDoubleClickCallback (void *data)
 Front left button internal double click callback.
 
static void _staticButtonFrontRightClickCallback (void *data)
 Front right button internal click callback.
 
static void _staticButtonFrontRightDoubleClickCallback (void *data)
 Front right button internal double click callback.
 
static void _staticButtonBackTopClickCallback (void *data)
 Back top button internal click callback.
 
static void _staticButtonBackTopDoubleClickCallback (void *data)
 Back top button internal double click callback.
 
static void _staticButtonBackBottomClickCallback (void *data)
 Back bottom button internal click callback.
 
static void _staticButtonBackBottomDoubleClickCallback (void *data)
 Back bottom button internal double click callback.
 

Protected Attributes

JBWoprBoardVariant _woprVariant
 W.O.P.R. board version.
 
JBWoprConfiguration _config
 JBWoprDevice configuration.
 
JBWoprBoardPins _pins
 W.O.P.R. board pin assignements.
 
JBWoprEffectBase_defaultEffect = nullptr
 Default effect.
 
std::vector< JBWoprEffectBase * > _effects
 Effects.
 
JBWoprEffectBase_currentEffect = nullptr
 Current effect.
 
uint32_t _effectsCounter = 0
 Effects counter.
 
std::array< Adafruit_AlphaNum4, 3 > _display
 Display.
 
bool _displayState = true
 Display state.
 
uint32_t _displayBrightness = 100
 Display brightness.
 
Adafruit_NeoPixel _defconLeds = Adafruit_NeoPixel(5, 1, NEO_GRB + NEO_KHZ800)
 DEFCON LEDs.
 
bool _defconState = true
 DEFCON state.
 
JBDefconLevel _defconLevel = JBDefconLevel::DEFCON_NONE
 DEFCON level.
 
uint32_t _defconColors [5]
 DEFCON colors.
 
uint32_t _defconBrightness = 100
 DEFCON brightness.
 
uint32_t _defconLedsColor = 0
 DEFCON LED's color.
 
uint32_t _defconPixels [5] { 0,0,0,0,0}
 DEFCON buffered pixel colors.
 
uint32_t _defconBrigthtness = 100
 DEFCON brightness.
 
OneButton * _buttonFrontLeft
 Front left button.
 
OneButton * _buttonFrontRight
 Front right button.
 
OneButton * _buttonBackTop
 Back to.
 
OneButton * _buttonBackBottom
 Back bottom button.
 
std::function< void()> _buttonFrontLeftClickCallback
 Front left button click callback.
 
std::function< void()> _buttonFrontLeftDoubleClickCallback
 Front left button double click callback.
 
std::function< void()> _buttonFrontRightClickCallback
 Front right button click callback.
 
std::function< void()> _buttonFrontRightDoubleClickCallback
 Front right button double click callback.
 
std::function< void()> _buttonBackTopClickCallback
 Back top button click callback.
 
std::function< void()> _buttonBackTopDoubleClickCallback
 Back top button double click callback.
 
std::function< void()> _buttonBackBottomClickCallback
 Back bottom button click callback.
 
std::function< void()> _buttonBackBottomDoubleClickCallback
 Back bottom button double click callback.
 
bool _useDAC = false
 Use DAC.
 
int _audioFreq = 2000
 Audio frequency.
 
int _audioChannel = 0
 Audio channel.
 
int _audioResolution = 8
 Audio resolution.
 

Detailed Description

W.O.P.R. device base class.

This class contains all the base functionality for the W.O.P.R.

This class can be used as is, or as a base class for your own W.O.P.R. device. It exposes convenient methods for controlling the display, DEFCON LEDs, audio and buttons. It also contains a simple effects system that can be used to create your own effects.

Member Function Documentation

◆ _buttonBackBottomClick()

void JBWoprDevice::_buttonBackBottomClick ( )
protectedvirtual

Back bottom button click callback.

Reimplemented in JBWoprMqttDevice.

◆ _buttonBackBottomDoubleClick()

void JBWoprDevice::_buttonBackBottomDoubleClick ( )
protectedvirtual

Back bottom button double click callback.

Reimplemented in JBWoprMqttDevice.

◆ _buttonBackTopClick()

void JBWoprDevice::_buttonBackTopClick ( )
protectedvirtual

Back top button click callback.

Reimplemented in JBWoprMqttDevice.

◆ _buttonBackTopDoubleClick()

void JBWoprDevice::_buttonBackTopDoubleClick ( )
protectedvirtual

Back top button double click callback.

Reimplemented in JBWoprMqttDevice.

◆ _buttonFrontLeftClick()

void JBWoprDevice::_buttonFrontLeftClick ( )
protectedvirtual

Front left button click callback.

Reimplemented in JBWoprMqttDevice.

◆ _buttonFrontLeftDoubleClick()

void JBWoprDevice::_buttonFrontLeftDoubleClick ( )
protectedvirtual

Front left button double click callback.

Reimplemented in JBWoprMqttDevice.

◆ _buttonFrontRightClick()

void JBWoprDevice::_buttonFrontRightClick ( )
protectedvirtual

Front right button click callback.

Reimplemented in JBWoprMqttDevice.

◆ _buttonFrontRightDoubleClick()

void JBWoprDevice::_buttonFrontRightDoubleClick ( )
protectedvirtual

Front right button double click callback.

Reimplemented in JBWoprMqttDevice.

◆ _getDefconLedsPixel()

uint32_t JBWoprDevice::_getDefconLedsPixel ( JBDefconLevel  level)
protected

Get DEFCON LED strip pixel from DEFCON level.

Parameters
levelDEFCON level
Returns
DEFCON LED strip pixel

◆ _getDefconLevel()

JBDefconLevel JBWoprDevice::_getDefconLevel ( std::string  value)
protected

Get DEFCON level from string value.

Parameters
valueString value
Returns
DEFCON level

◆ _getDefconLevelString()

std::string JBWoprDevice::_getDefconLevelString ( JBDefconLevel  level)
protected

Get DEFCON level string from DEFCON level.

Parameters
levelDEFCON level
Returns
DEFCON level string

◆ begin() [1/2]

bool JBWoprDevice::begin ( JBWoprBoardVariant  variant,
JBWoprBoardPins  pins 
)
virtual

Initialize JBWoprDevice.

Use this method if you are using a custom ESP32 board.

Parameters
variantW.O.P.R. board version
pinsW.O.P.R. ESP32 pin assignments
Returns
True if successful

Reimplemented in JBWoprHADevice, JBWoprMqttDevice, and JBWoprWiFiDevice.

◆ begin() [2/2]

bool JBWoprDevice::begin ( JBWoprBoardVariant  variant = JBWoprBoardVariant::ORIGINAL)
virtual

Initialize JBWoprDevice.

Use this method if you are using a tinyXxx board, it will assign the ESP32 pins automatically.

Parameters
variantW.O.P.R. board version
Returns
True if successful

Reimplemented in JBWoprHADevice, JBWoprMqttDevice, and JBWoprWiFiDevice.

◆ loop()

void JBWoprDevice::loop ( )
virtual

JBWoprDevice loop.

This method should be called from the main loop() method.

Reimplemented in JBWoprHADevice, JBWoprMqttDevice, and JBWoprWiFiDevice.


The documentation for this class was generated from the following files: