The core class for DumbDisplay; everything starts here. The most important argument to DumbDisplay is an DDInputOutput object. For an example, please refer to Blink Test With Virtual Display, DumbDisplay More...
#include <dumbdisplay.h>
Public Member Functions | |
| DumbDisplay (DDInputOutput *pIO, uint16_t sendBufferSize=DD_DEF_SEND_BUFFER_SIZE, long idleTimeout=DD_DEF_IDLE_TIMEOUT) | |
| void | connect () |
| bool | connected () const |
| int | getConnectVersion () const |
| int | getCompatibilityVersion () const |
| void | setFeedbackSingleClickOnly (bool singleClickOnly=true) |
| void | configAutoPin (const String &layoutSpec=DD_AP_VERT, bool autoControlLayerVisible=false) |
| void | addRemainingAutoPinConfig (const String &restLayoutSpec) |
| add the "auto pin" config (REST "auto pin" config) for layers not included in "auto pin" set by configAutoPin() | |
| void | deleteAllRemainingAutoPinConfigs () |
| delete all added REST "auto pin" configs | |
| void | configPinFrame (int xUnitCount=100, int yUnitCount=100, bool autoControlLayerVisible=false) |
| void | pinLayer (DDLayer *pLayer, int uLeft, int uTop, int uWidth, int uHeight, const String &align="") |
| void | pinAutoPinLayers (const String &layoutSpec, int uLeft, int uTop, int uWidth, int uHeight, const String &align="") |
| void | resetPinLayers () |
| rest pinning of layers, as if they are not pinned | |
| GraphicalDDLayer * | setRootLayer (int width, int height, const String &containedAlignment="") |
| MbDDLayer * | createMicrobitLayer (int width=5, int height=5) |
| create a Microbit-like layer | |
| TurtleDDLayer * | createTurtleLayer (int width, int height) |
| create a Turtle-like layer | |
| LedGridDDLayer * | createLedGridLayer (int colCount=1, int rowCount=1, int subColCount=1, int subRowCount=1) |
| create a LED-grid layer | |
| LcdDDLayer * | createLcdLayer (int colCount=16, int rowCount=2, int charHeight=0, const String &fontName="") |
| create a LCD layer | |
| SelectionDDLayer * | createSelectionLayer (int colCount=16, int rowCount=2, int horiSelectionCount=1, int vertSelectionCount=1, int charHeight=0, const String &fontName="", bool canDrawDots=true, float selectionBorderSizeCharHeightFactor=0.3) |
| create a "selection" layer | |
| SelectionListDDLayer * | createSelectionListLayer (int colCount=16, int rowCount=2, int horiSelectionCount=1, int vertSelectionCount=1, int charHeight=0, const String &fontName="", bool canDrawDots=true, float selectionBorderSizeCharHeightFactor=0.3) |
| create a list "selection" layer | |
| GraphicalDDLayer * | createGraphicalLayer (int width, int height) |
| SevenSegmentRowDDLayer * | create7SegmentRowLayer (int digitCount=1) |
| JoystickDDLayer * | createJoystickLayer (int maxStickValue=1023, const String &directions="", float stickSizeFactor=1.0) |
| PlotterDDLayer * | createPlotterLayer (int width, int height, int pixelsPerSecond=10) |
| create a plotter layer | |
| PlotterDDLayer * | createFixedRatePlotterLayer (int width, int height, int pixelsPerScale=5) |
| TomTomMapDDLayer * | createTomTomMapLayer (const String &mapKey, int width, int height) |
| TerminalDDLayer * | createTerminalLayer (int width, int height) |
| WebViewDDLayer * | createWebViewLayer (int width, int height, const String &jsObjectName="DD") |
| DumbDisplayWindowDDLayer * | createDumbDisplayWindowLayer (int width, int height) |
| RtspClientDDLayer * | createRtspClient (int width, int height) |
| BasicDDTunnel * | createBasicTunnel (const String &endPoint, bool connectNow=true, int8_t bufferSize=DD_TUNNEL_DEF_BUFFER_SIZE) |
| JsonDDTunnel * | createJsonTunnel (const String &endPoint, bool connectNow=true, int8_t bufferSize=DD_TUNNEL_DEF_BUFFER_SIZE) |
| JsonDDTunnel * | createFilteredJsonTunnel (const String &endPoint, const String &fieldNames, bool connectNow=true, int8_t bufferSize=DD_TUNNEL_DEF_BUFFER_SIZE) |
| ImageDownloadDDTunnel * | createImageDownloadTunnel (const String &endPoint, const String &imageName, bool redownload=true) |
| BasicDDTunnel * | createDateTimeServiceTunnel () |
| BasicDDTunnel * | createGeneralServiceTunnel () |
| GpsServiceDDTunnel * | createGpsServiceTunnel () |
| ObjectDetectDemoServiceDDTunnel * | createObjectDetectDemoServiceTunnel (int scaleToWidth=0, int scaleToHeight=0, int maxNumObjs=1) |
| ImageRetrieverDDTunnel * | createImageRetrieverTunnel () |
| GraphicalDDLayerHandle | createGraphicalLayerHandle (int width, int height) |
| LcdDDLayerHandle | createLcdLayerHandle (int colCount=16, int rowCount=2, int charHeight=0, const String &fontName="") |
| LedGridDDLayerHandle | createLedGridLayerHandle (int colCount=1, int rowCount=1, int subColCount=1, int subRowCount=1) |
| void | deleteTunnel (DDTunnel *pTunnel) |
| if finished using a "tunnel", delete it to release resource | |
| void | freezeDrawing () |
| void | unfreezeDrawing (bool refreezeAfterward=false) |
| void | backgroundColor (const String &color) |
| void | recordLayerSetupCommands () |
| basically, functions the same as recordLayerCommands() | |
| void | playbackLayerSetupCommands (const String &layerSetupPersistId) |
| void | recordLayerCommands () |
| void | playbackLayerCommands () |
| playback recorded commands (unfreeze the display) | |
| void | stopRecordLayerCommands (const String &saveId="", bool persistSave=false) |
| void | saveLayerCommands (const String &id, bool persist=false, bool stopAfterSave=false) |
| void | loadLayerCommands (const String &id) |
| void | capture (const String &imageFileName, int width, int height) |
| void | sendNoOp () |
| send "no-op" command | |
| void | writeComment (const String &comment) |
| write out a comment to DD app | |
| void | tone (uint32_t freq, uint32_t duration) |
| make DD app sound a tone | |
| void | notone () |
| void | playSound (const String &soundName) |
| make DD app play the sound of the given sound file | |
| void | stopSound () |
| void | saveSound8 (const String &soundName, const int8_t *bytes, int sampleCount, int sampleRate, int numChannels=1) |
| save 8-bit sound with the given sound samples | |
| void | saveSound16 (const String &soundName, const int16_t *data, int sampleCount, int sampleRate, int numChannels=1) |
| save 16-bit sound with the given sound samples | |
| void | cacheSound8 (const String &soundName, const int8_t *bytes, int sampleCount, int sampleRate, int numChannels=1) |
| cache 8-bit sound with the given sound samples | |
| void | cacheSound16 (const String &soundName, const int16_t *data, int sampleCount, int sampleRate, int numChannels=1) |
| cache 16-bit sound with the given sound samples | |
| void | saveCachedSound (const String &soundName) |
| save the cached sound | |
| void | saveCachedSoundAsH (const String &soundName) |
| save the cached sound as C header file (.h) | |
| int | streamSound8 (int sampleRate, int numChannels=1) |
| stream sound 8-bit sample (for playing sound) | |
| int | streamSound16 (int sampleRate, int numChannels=1) |
| stream sound 16-bit sample (for playing sound) | |
| int | saveSoundChunked8 (const String &soundName, int sampleRate, int numChannels=1) |
| int | saveSoundChunked16 (const String &soundName, int sampleRate, int numChannels=1) |
| int | cacheSoundChunked8 (const String &soundName, int sampleRate, int numChannels=1) |
| int | cacheSoundChunked16 (const String &soundName, int sampleRate, int numChannels=1) |
| void | sendSoundChunk8 (int chunkId, const int8_t *bytes, int sampleCount, bool isFinal=false) |
| send 8-bit sound data chunk for saving/caching after calling saveSoundChunked8() or cacheSoundChunked8() | |
| void | sendSoundChunk16 (int chunkId, const int16_t *data, int sampleCount, bool isFinal=false) |
| send 16-bit sound data chunk for saving/caching after calling saveSoundChunked16() or cacheSoundChunked16() | |
| void | saveImage (const String &imageName, const uint8_t *bytes, int byteCount) |
| svae image with the given image data | |
| void | savePixelImage (const String &imageName, const uint8_t *bytes, int width, int height, const String &color="", char compressMethod=0) |
| save single-bit "pixel" image (i.e. B&W image) with the given image data | |
| void | savePixelImage16 (const String &imageName, const uint16_t *data, int width, int height, const String &options="", char compressMethod=0) |
| save 16-bit "pixel" image (i.e. 565 RGB image) with the given image data | |
| void | savePixelImageGS (const String &imageName, const uint8_t *data, int width, int height, const String &options="", char compressMethod=0) |
| save grayscale "pixel" image with the given image data | |
| void | stitchImages (const String &imageNames, const String &asImageName) |
| void | alert (const String &message, const String &title="") |
| pop up a dialog to alert | |
| void | reorderLayer (DDLayer *pLayer, const String &how) |
| void | deleteLayer (DDLayer *pLayer) |
| if layer is no longer used; delete it to release resources | |
| void | deleteLayer (DDLayerHandle layerHandle) |
| if layer is no longer used; delete it to release resources | |
| void | walkLayers (void(*walker)(DDLayer *)) |
| loop through all the existing layers calling the function passed in | |
| void | setIdleCallback (DDIdleCallback idleCallback) |
| void | setConnectVersionChangedCallback (DDConnectVersionChangedCallback connectVersionChangedCallback) |
| bool | canPrintToSerial () |
| check if it is safe to print to Serial | |
| void | logToSerial (const String &logLine, bool force=false) |
| log line to Serial; if it is not safe to output to Serial, will write comment with DumbDisplay::writeComment() instead | |
| void | log (const String &logLine, bool isError=false) |
| like to Serial (if safe to do so); and if connected, will log as comment to DD as well | |
| bool | connectPassive (DDConnectPassiveStatus *pStatus=NULL) |
| void | masterReset () |
| void | debugSetup (DDDebugInterface *debugInterface) |
| void | debugOnly (int i) |
The core class for DumbDisplay; everything starts here. The most important argument to DumbDisplay is an DDInputOutput object. For an example, please refer to Blink Test With Virtual Display, DumbDisplay
| void DumbDisplay::backgroundColor | ( | const String & | color | ) |
set DD background color
| color | DD_COLOR_XXX; DD_RGB_COLOR(...); can also be common "color name" |
| int DumbDisplay::cacheSoundChunked16 | ( | const String & | soundName, |
| int | sampleRate, | ||
| int | numChannels = 1 |
||
| ) |
initiate caching of 16-bit sound sound chunked; use sendSoiundChunk16() to send sound data
| int DumbDisplay::cacheSoundChunked8 | ( | const String & | soundName, |
| int | sampleRate, | ||
| int | numChannels = 1 |
||
| ) |
initiate caching of 8-bit sound sound chunked; use sendSoiundChunk8() to send sound data
| void DumbDisplay::capture | ( | const String & | imageFileName, |
| int | width, | ||
| int | height | ||
| ) |
capture and save display as image
| imageFileName | name of image file; if it ends with ".png", saved image format will be PNG; other, saved image format will be JPEG */ |
| width | width of the display on which to render the layers |
| height | height of the display on which to render the layers |
| void DumbDisplay::configAutoPin | ( | const String & | layoutSpec = DD_AP_VERT, |
| bool | autoControlLayerVisible = false |
||
| ) |
configure "auto pinning of layers" with the layer spec provided
| layoutSpec | the layout specification |
| autoControlLayerVisible | auto set layer visible (visibility) according whether the layer is specified in the layoutSpec or not; false by default |
| void DumbDisplay::configPinFrame | ( | int | xUnitCount = 100, |
| int | yUnitCount = 100, |
||
| bool | autoControlLayerVisible = false |
||
| ) |
configure "pin frame" to be x-units by y-units (default 100x100)
| autoControlLayerVisible | auto set layer visible (visibility) according whether the layer is pinned or not; false by default |
| void DumbDisplay::connect | ( | ) |
explicitly make connection (blocking); implicitly called in situations like create a layer
| bool DumbDisplay::connected | ( | ) | const |
| bool DumbDisplay::connectPassive | ( | DDConnectPassiveStatus * | pStatus = NULL | ) |
make connection passively; i.e. will not block, but will require continuous calling for making connection
| SevenSegmentRowDDLayer * DumbDisplay::create7SegmentRowLayer | ( | int | digitCount = 1 | ) |
create a 7-segment layer
| digitCount | show how many digits; 1 by default |
| BasicDDTunnel * DumbDisplay::createBasicTunnel | ( | const String & | endPoint, |
| bool | connectNow = true, |
||
| int8_t | bufferSize = DD_TUNNEL_DEF_BUFFER_SIZE |
||
| ) |
create a "tunnel" for accessing the Web
| BasicDDTunnel * DumbDisplay::createDateTimeServiceTunnel | ( | ) |
| DumbDisplayWindowDDLayer * DumbDisplay::createDumbDisplayWindowLayer | ( | int | width, |
| int | height | ||
| ) |
create a DumbDisplay "window" layer
| JsonDDTunnel * DumbDisplay::createFilteredJsonTunnel | ( | const String & | endPoint, |
| const String & | fieldNames, | ||
| bool | connectNow = true, |
||
| int8_t | bufferSize = DD_TUNNEL_DEF_BUFFER_SIZE |
||
| ) |
create a JSON 'tunnel' for thing like making RESTful calls; with result filtered
| fieldNames | comma-delimited list of field names to accept; note that matching is "case-insensitive containment match" |
| PlotterDDLayer * DumbDisplay::createFixedRatePlotterLayer | ( | int | width, |
| int | height, | ||
| int | pixelsPerScale = 5 |
||
| ) |
create a fixed-rate plotter layer i.e. it will assume fixe-rate of PlotterDDLayer::set()
| BasicDDTunnel * DumbDisplay::createGeneralServiceTunnel | ( | ) |
create a general "service tunnel" for purposes like getting date-time info from phone; use reconnectTo() with commands like
now – e.g now:yyyy-MM-dd-hh-mm-ss where yyyy-MM-dd-hh-mm-ss is the formatnow-millisconfirm – pop up a dialog to confirm; e.g. confirm?title=Confirm&message=Are%20you%20sure%3F&ok=Yes&cancel=No | GpsServiceDDTunnel * DumbDisplay::createGpsServiceTunnel | ( | ) |
create a "service tunnel" for getting GPS info from phone
| GraphicalDDLayer * DumbDisplay::createGraphicalLayer | ( | int | width, |
| int | height | ||
| ) |
create a graphical LCD layer
| GraphicalDDLayerHandle DumbDisplay::createGraphicalLayerHandle | ( | int | width, |
| int | height | ||
| ) |
experimental: create a visual-only graphical LCD layer handle which you can be used where GraphicalDDLayerHandle is accepted, like construction of GraphicalDDLayer;
| ImageDownloadDDTunnel * DumbDisplay::createImageDownloadTunnel | ( | const String & | endPoint, |
| const String & | imageName, | ||
| bool | redownload = true |
||
| ) |
create a "tunnel" to download image from the web, and save the downloaded image to phone; you will get result in JSON format: {"result":"ok"} or {"result":"failed"} for simplicity, use SimpleToolDDTunnel.checkResult() to check the result
| JoystickDDLayer * DumbDisplay::createJoystickLayer | ( | int | maxStickValue = 1023, |
| const String & | directions = "", |
||
| float | stickSizeFactor = 1.0 |
||
| ) |
create a joystick layer:
| maxStickValue | the max value of the stick; e.g. 255 or 1023 (the default); min is 15 |
| directions | "lr" or "hori": left-to-right; "tb" or "vert": top-to-bottom; "rl": right-to-left; "bt": bottom-to-top; use "+" combines the above like "lr+tb" to mean both directions; "" the same as "lr+tb" |
| stickSizeFactor | the size factor of the stick (UI); 1 by default |
| JsonDDTunnel * DumbDisplay::createJsonTunnel | ( | const String & | endPoint, |
| bool | connectNow = true, |
||
| int8_t | bufferSize = DD_TUNNEL_DEF_BUFFER_SIZE |
||
| ) |
create a JSON 'tunnel' for thing like making RESTful calls
| LcdDDLayerHandle DumbDisplay::createLcdLayerHandle | ( | int | colCount = 16, |
| int | rowCount = 2, |
||
| int | charHeight = 0, |
||
| const String & | fontName = "" |
||
| ) |
experimental: create a visual-only LCD layer handle which you can be used where LcdDDLayerHandle is accepted, like construction of LcdDDLayer;
| LedGridDDLayerHandle DumbDisplay::createLedGridLayerHandle | ( | int | colCount = 1, |
| int | rowCount = 1, |
||
| int | subColCount = 1, |
||
| int | subRowCount = 1 |
||
| ) |
experimental: create a visual-only LED-grid layer handle which you can be used where LedGridDDLayerHandle is accepted, like construction of LedGridDDLayer;
| ObjectDetectDemoServiceDDTunnel * DumbDisplay::createObjectDetectDemoServiceTunnel | ( | int | scaleToWidth = 0, |
| int | scaleToHeight = 0, |
||
| int | maxNumObjs = 1 |
||
| ) |
create a "service tunnel" for getting object detection info from phone; model used is the demo model mobilenetv1.tflite
| RtspClientDDLayer * DumbDisplay::createRtspClient | ( | int | width, |
| int | height | ||
| ) |
create a RTSP-client layer
| TerminalDDLayer * DumbDisplay::createTerminalLayer | ( | int | width, |
| int | height | ||
| ) |
create a terminal layer
| TomTomMapDDLayer * DumbDisplay::createTomTomMapLayer | ( | const String & | mapKey, |
| int | width, | ||
| int | height | ||
| ) |
create a TomTom map layer
| mapKey | should be provided; plesae visit TomTom's website to get one of your own if pass in "" as mapKey, will use my testing one |
| WebViewDDLayer * DumbDisplay::createWebViewLayer | ( | int | width, |
| int | height, | ||
| const String & | jsObjectName = "DD" |
||
| ) |
create a WebView layer
| void DumbDisplay::debugSetup | ( | DDDebugInterface * | debugInterface | ) |
set debug use callback
| debugInterface | a concrete implementation of DDDebugInterface |
| void DumbDisplay::freezeDrawing | ( | ) |
freeze draw (update) of the layers @size v0.9.9-r53
| int DumbDisplay::getCompatibilityVersion | ( | ) | const |
| int DumbDisplay::getConnectVersion | ( | ) | const |
| void DumbDisplay::loadLayerCommands | ( | const String & | id | ) |
load saved commands (as if recording those commands)
| void DumbDisplay::masterReset | ( | ) |
"master reset" will: . disconnect from DD app (if connected) . delete all created layers and tunnels; hence, DO NOT use the pointers to them after "master reset" . DumbDisplay object will be just like at initial state; it will not be deleted
| void DumbDisplay::pinAutoPinLayers | ( | const String & | layoutSpec, |
| int | uLeft, | ||
| int | uTop, | ||
| int | uWidth, | ||
| int | uHeight, | ||
| const String & | align = "" |
||
| ) |
pin "auto pin" layers @ some position, like pinLayer()
| layoutSpec | the "auto pin" layout specification to pin; see configAutoPin() for how spec is constructed |
| align | (e.g. "LB") – left align "L"; right align "R"; top align "T"; bottom align "B"; default is center align */ |
| void DumbDisplay::pinLayer | ( | DDLayer * | pLayer, |
| int | uLeft, | ||
| int | uTop, | ||
| int | uWidth, | ||
| int | uHeight, | ||
| const String & | align = "" |
||
| ) |
pin a layer @ some position of an imaginary grid of "pin grame"
| void DumbDisplay::playbackLayerSetupCommands | ( | const String & | layerSetupPersistId | ) |
basically, functions the same as playbackLayerCommands(). additionally:
| void DumbDisplay::recordLayerCommands | ( | ) |
start recording layer commands (of any layers); and sort of freeze the display, until playback
| void DumbDisplay::reorderLayer | ( | DDLayer * | pLayer, |
| const String & | how | ||
| ) |
reorder the layer (by moving one layer in the z-order plane)
| how | can be "T" for top; or "B" for bottom; "U" for up; or "D" for down |
| void DumbDisplay::saveLayerCommands | ( | const String & | id, |
| bool | persist = false, |
||
| bool | stopAfterSave = false |
||
| ) |
save the recorded commands (continue recording or not depends on parameter passed in ); any pre-existed saved commands with the same id will be replaced with the recording commands (delete if not recording)
| id | identifier of the recorded commands, overwriting and previous one; if not recording, will delete previous recorded commands |
| persist | store it to your phone as well |
| stopAfterSave | stop recording after saving |
| int DumbDisplay::saveSoundChunked16 | ( | const String & | soundName, |
| int | sampleRate, | ||
| int | numChannels = 1 |
||
| ) |
initiate saving of 16-bit sound sound chunked; use sendSoiundChunk16() to send sound data
| int DumbDisplay::saveSoundChunked8 | ( | const String & | soundName, |
| int | sampleRate, | ||
| int | numChannels = 1 |
||
| ) |
initiate saving of 8-bit sound sound chunked; use sendSoiundChunk8() to send sound data
| void DumbDisplay::setConnectVersionChangedCallback | ( | DDConnectVersionChangedCallback | connectVersionChangedCallback | ) |
set callback when version changed (e.g. reconnected after disconnect)
| connectVersionChangedCallback | the callback function; see DDConnectVersionChangedCallback |
| void DumbDisplay::setFeedbackSingleClickOnly | ( | bool | singleClickOnly = true | ) |
by default, "long press feedback" and "double click feedback" is enabled; however, this makes "click feedback" detection less responsive; one remedy is to set for "single click feedback" only
| void DumbDisplay::setIdleCallback | ( | DDIdleCallback | idleCallback | ) |
set 'idle callback', which will be called repeatedly in 2 situations:
| idleCallback | the callback function; see DDIdleCallback |
| GraphicalDDLayer * DumbDisplay::setRootLayer | ( | int | width, |
| int | height, | ||
| const String & | containedAlignment = "" |
||
| ) |
set the "root" layer, which is the foundation layer on which all other layers are contained;
| containedAlignment | the alignment of the contained layers; "L" / "T" / "LT"; "" means centered currently, "container" layer does not support "feedback" |
| void DumbDisplay::stitchImages | ( | const String & | imageNames, |
| const String & | asImageName | ||
| ) |
stitch images together
| imageNames | '+' delimited |
| asImageName | name for the stitched image |
| void DumbDisplay::stopRecordLayerCommands | ( | const String & | saveId = "", |
| bool | persistSave = false |
||
| ) |
stop recording commands (if not saved, will forget what recorded)
| saveId | if provided, save like calling saveLayerCommands(); otherwise, forget what have been recording |
| persistSave | if save, store it to your phone as well |
| void DumbDisplay::unfreezeDrawing | ( | bool | refreezeAfterward = false | ) |
unfreeze draw (update) of the layers
| refreezeAfterward | if true, will freeze again after [draw] @size v0.9.9-r53 |