JBWOPR
|
W.O.P.R. WiFi device class. More...
#include <jbwoprwifi.h>
Public Member Functions | |
JBWoprWiFiDevice () | |
JBWoprWiFiDevice constructor. | |
bool | begin (JBWoprBoardVariant variant) override |
Initialize JBWoprWiFiDevice. | |
bool | begin (JBWoprBoardVariant variant, JBWoprBoardPins pins) override |
Initialize JBWoprWiFiDevice. | |
void | loop () override |
JBWoprWiFiDevice loop. | |
void | setLogLevel (LogLevel level) override |
Set log level. | |
LogLevel | getLogLevel () override |
Get log level. | |
bool | startWiFi () |
Start WiFi. | |
void | webPortalStart () |
Start web portal. | |
void | webPortalStop () |
Stop web portal. | |
![]() | |
JBWoprDevice () | |
JBWoprDevice constructor. | |
JBWoprBoardVariant | getBoardVariant () |
Get W.O.P.R board variant. | |
JBWoprConfiguration * | getConfiguration () |
Get current JBWoprDevice configuration. | |
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. | |
JBWoprEffectBase * | effectsGetCurrentEffect () |
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. | |
Protected Member Functions | |
void | _loadConfiguration () |
Load configuration from file. | |
void | _saveConfiguration () |
Save configuration to file. | |
virtual void | _setConfigFromJsonDocument (const JsonDocument &jsonDoc) |
Get configuration. | |
virtual void | _setJsonDocumentFromConfig (JsonDocument &jsonDoc) |
Set configuration. | |
virtual void | _dumpConfig () |
Dump configuration to logger. | |
std::string | _getDeviceName () |
Get device name. | |
virtual WiFiManager * | _getWiFiManager () |
Get WiFi manager. | |
virtual void | _setupWiFiManager () |
Setup WiFiManager. | |
virtual void | _saveParamsCallback () |
Save parameters callback. | |
void | _apCallback (WiFiManager *wifiManager) |
AP callback. | |
void | _webServerCallback () |
Web server callback. | |
![]() | |
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. | |
Protected Attributes | |
JBWoprWiFiConfiguration | _wifiConfig |
WiFi configuration. | |
bool | _shouldSaveConfig = false |
Flag to save configuration. | |
const char * | CONFIG_FILE_NAME = "/config.json" |
Configuration file name. | |
WiFiManager * | _wifiManager |
WiFi manager. | |
std::string | _apName = "" |
AP name. | |
const char * | WEB_PORTAL_PASSWORD = "wopr1234" |
AP portal password. | |
const char * | JSON_KEY_EFFECTS_TIMEOUT = "effectsTimeout" |
Effects timeout key name. | |
const char * | JSON_KEY_TIME_FORMAT = "timeFormat" |
Time format key name. | |
const char * | JSON_KEY_DATE_FORMAT = "dateFormat" |
Date Format key name. | |
const char * | JSON_KEY_DEFCON_BRIGHTNESS = "defconBrightness" |
DEFCON LEDs brightness key name. | |
const char * | JSON_KEY_DISPLAY_BRIGHTNESS = "displayBrightness" |
Display brightness key name. | |
const char * | JSON_KEY_WIFI_HOST_NAME = "hostName" |
Host name key name. | |
const char * | JSON_KEY_WIFI_NTP_SERVER = "ntpServer" |
NTP Server key name. | |
const char * | JSON_KEY_WIFI_TIME_OFFSET = "timeOffsetString" |
NTP Server key name. | |
const char * | JSON_KEY_WIFI_USE_WEB_PORTAL = "useWebPortal" |
Use portal key name. | |
const char * | HTML_WOPR_TITLE = "<h2>W.O.P.R. settings</h2>" |
Settings title. | |
const char * | HTML_NETWORK_TITLE = "<h2>Network settings</h2>" |
Network title. | |
const char * | HTML_CHECKBOX_TRUE = "type=\"checkbox\" checked" |
HTML checkbox true. | |
const char * | HTML_CHECKBOX_FALSE = "type=\"checkbox\"" |
HTML checkbox false. | |
WiFiManagerParameter * | _woprTitleParam |
W.O.P.R. title parameter. | |
WiFiManagerParameter * | _networkTitleParam |
Network title parameter. | |
WiFiManagerParameter * | _breakParam |
Break parameter. | |
WiFiManagerParameter * | _effectsTimeoutParam |
Effects timeout parameter. | |
WiFiManagerParameter * | _timeFormatParam |
Time format parameter. | |
WiFiManagerParameter * | _dateFormatParam |
Date format parameter. | |
WiFiManagerParameter * | _displayBrightnessParam |
Display brightness parameter. | |
WiFiManagerParameter * | _defconLedsBrightnessParam |
DEFCON LEDs brightness parameter. | |
WiFiManagerParameter * | _hostNameParam |
Host name parameter. | |
WiFiManagerParameter * | _ntpServerNameParam |
NTP Server address. | |
WiFiManagerParameter * | _timeOffsetParam |
Time offset. | |
WiFiManagerParameter * | _useWebPortalParam |
Use web portal parameter. | |
char | _effectsTimeoutValue [3] |
Effects timeout value, set in WiFiManager callback. | |
char | _defconLedsBrightnessValue [3] |
DEFCON LEDs brightness value, set in WiFiManager callback. | |
char | _displayBrightnessValue [3] |
Display brightness value, set in WiFiManager callback. | |
![]() | |
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. | |
Additional Inherited Members | |
![]() | |
const char * | DEFCON_STRINGS [6] { "DEFCON 1", "DEFCON 2", "DEFCON 3", "DEFCON 4", "DEFCON 5", "None" } |
![]() | |
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. | |
W.O.P.R. WiFi device class.
This class extends the JBWoprDevice class with WiFi support and uses WiFiManager for easy configuration. It also supports a web portal for configuration after the initial setup.
The configuration is saved to a file on the device, and is loaded on startup.
|
protectedvirtual |
Dump configuration to logger.
Called when configuration is to be written to the logger.
Reimplemented in JBWoprHADevice, and JBWoprMqttDevice.
|
protected |
Load configuration from file.
Called on startup.
|
protected |
Save configuration to file.
Called when Save button is pressed in the configuration web page.
|
protectedvirtual |
Get configuration.
Called when JSON document have been loaded from file.
jsonDoc | JSON document |
Reimplemented in JBWoprMqttDevice, and JBWoprHADevice.
|
protectedvirtual |
Set configuration.
Called when JSON document is about to be saved to file.
jsonDoc | JSON document |
Reimplemented in JBWoprMqttDevice, and JBWoprHADevice.
|
overridevirtual |
Initialize JBWoprWiFiDevice.
Use this method if you are using a tinyXxx board, it will assign the ESP32 pins automatically.
variant | Board version |
Reimplemented from JBWoprDevice.
|
overridevirtual |
Initialize JBWoprWiFiDevice.
variant | Board version |
pins | Board pins |
Reimplemented from JBWoprDevice.
|
overridevirtual |
|
overridevirtual |
JBWoprWiFiDevice loop.
This method should be called from the main loop() method.
Reimplemented from JBWoprDevice.
|
overridevirtual |
Set log level.
This method will set the log level for the logger.
level | Log level |
Reimplemented from JBWoprDevice.