ArduinoDumbDisplay v0.9.9-r53
DumbDisplay Arduino Library -- https://github.com/trevorwslee/Arduino-DumbDisplay
 
Loading...
Searching...
No Matches
dumbdisplay.h
1/*
2
3============================
4
5if want to disable int parameter encoding, define DD_DISABLE_PARAM_ENCODING before including dumbdisplay.h, like
6
7#define DD_DISABLE_PARAM_ENCODING
8
9=============================
10
11*/
12
13#ifdef DD_DISABLE_PARAM_ENCODING
14 #pragma "message ***** DD_DISABLE_PARAM_ENCODING *****"
15#endif
16
17
18
19
20#ifndef dumbdisplay_h
21#define dumbdisplay_h
22
23
24// not used???
25// #ifdef DD_4_ESP32
26// #include <esp_spp_api.h>
27// #include "HardwareSerial.h"
28// #endif
29
30
31#define DUMBDISPLAY_BAUD 115200
32#define DD_SERIAL_BAUD DUMBDISPLAY_BAUD
33#define DD_WIFI_PORT 10201
34
35
36#define DD_DEF_SEND_BUFFER_SIZE 128
37#define DD_DEF_IDLE_TIMEOUT 5000
38#define DD_DEF_TUNNEL_TIMEOUT 150000
39
40
41#include "_dd_util.h"
42
43
44#define DD_CONDENSE_COMMAND
45
46
47#define DD_HEX_COLOR(color) ("#" + String(color, 16))
48
49
50#ifdef DD_CONDENSE_COMMAND
51 #define DD_INT_COLOR(color) ("+" + DDIntEncoder(color).encoded())
52 #if defined(ARDUINO_AVR_UNO) || defined(ARDUINO_AVR_NANO) || defined(DD_DISABLE_PARAM_ENCODING)
53 #define DD_RGB_COLOR(r, g, b) (String(r) + "-" + String(g) + "-" + String(b))
54 #else
55 #define DD_RGB_COLOR(r, g, b) ("+" + DDIntEncoder(0xffffff & ((((((int32_t) (r)) << 8) + ((int32_t) (g))) << 8) + ((int32_t) (b)))).encoded())
56 #endif
57 // #if defined(ARDUINO_AVR_UNO) || defined(ARDUINO_AVR_NANO)
58 // #define DD_RGB_COLOR(r, g, b) (String(r) + "-" + String(g) + "-" + String(b))
59 // //#define DD_RGB_COLOR(r, g, b) (String(r<0?0:(r>255?255:r)) + "-" + String(g<0?0:(g>255?255:g)) + "-" + String(b<0?0:(b>255?255:b)))
60 // #else
61 // #if defined(DD_DISABLE_PARAM_ENCODING)
62 // #define DD_RGB_COLOR(r, g, b) ("#" + String(0xffffff & ((((((int32_t) (r)) << 8) + ((int32_t) (g))) << 8) + ((int32_t) (b))), 16))
63 // #else
64 // #define DD_RGB_COLOR(r, g, b) ("+" + DDIntEncoder(0xffffff & ((((((int32_t) (r)) << 8) + ((int32_t) (g))) << 8) + ((int32_t) (b)))).encoded())
65 // #endif
66 // #endif
67#else
68 #define DD_RGB_COLOR(r, g, b) (String(r<0?0:(r>255?255:r)) + "-" + String(g<0?0:(g>255?255:g)) + "-" + String(b<0?0:(b>255?255:b)))
69 #define DD_INT_COLOR(color) ("+" + String(color))
70#endif
71
72
73
74#define DD_AP_HORI "H(*)"
75#define DD_AP_VERT "V(*)"
76#define DD_AP_STACK "S(*)"
77#define DD_AP_HORI_2(id1, id2) ("H(" + id1 + "+" + id2 + ")")
78#define DD_AP_VERT_2(id1, id2) ("V(" + id1 + "+" + id2 + ")")
79#define DD_AP_STACK_2(id1, id2) ("S(" + id1 + "+" + id2 + ")")
80#define DD_AP_HORI_3(id1, id2, id3) ("H(" + id1 + "+" + id2 + "+" + id3 + ")")
81#define DD_AP_VERT_3(id1, id2, id3) ("V(" + id1 + "+" + id2 + "+" + id3 + ")")
82#define DD_AP_STACK_3(id1, id2, id3) ("S(" + id1 + "+" + id2 + "+" + id3 + ")")
83#define DD_AP_HORI_4(id1, id2, id3, id4) ("H(" + id1 + "+" + id2 + "+" + id3 + "+" + id4 + ")")
84#define DD_AP_VERT_4(id1, id2, id3, id4) ("V(" + id1 + "+" + id2 + "+" + id3 + "+" + id4 + ")")
85#define DD_AP_STACK_4(id1, id2, id3, id4) ("S(" + id1 + "+" + id2 + "+" + id3 + "+" + id4 + ")")
86#define DD_AP_HORI_5(id1, id2, id3, id4, id5) ("H(" + id1 + "+" + id2 + "+" + id3 + "+" + id4 + "+" + id5 + ")")
87#define DD_AP_VERT_5(id1, id2, id3, id4, id5) ("V(" + id1 + "+" + id2 + "+" + id3 + "+" + id4 + "+" + id5 + ")")
88#define DD_AP_STACK_5(id1, id2, id3, id4, id5) ("S(" + id1 + "+" + id2 + "+" + id3 + "+" + id4 + "+" + id5 + ")")
89#define DD_AP_HORI_6(id1, id2, id3, id4, id5, id6) ("H(" + id1 + "+" + id2 + "+" + id3 + "+" + id4 + "+" + id5 + ")" + "+" + id6 + ")")
90#define DD_AP_VERT_6(id1, id2, id3, id4, id5, id6) ("V(" + id1 + "+" + id2 + "+" + id3 + "+" + id4 + "+" + id5 + ")" + "+" + id6 + ")")
91#define DD_AP_STACK_6(id1, id2, id3, id4, id5, id6) ("S(" + id1 + "+" + id2 + "+" + id3 + "+" + id4 + "+" + id5 + ")" + "+" + id6 + ")")
92
93#define DD_AP_PADDING(lp, tp, rp, bp, id) ("S/" + String(lp) + "-" + String(tp) + "-" + String(rp) + "-" + String(bp) + "(" + id + ")")
94
95#define DD_AP_SPACER(w, h) (String("<") + String(w) + "x" + String(h) + String(">"))
96
97#define DD_PROGRAM_SPACE_COMPRESS_BA_0 '!'
98#define DD_COMPRESS_BA_0 '0'
99
100#ifndef DD_TUNNEL_DEF_BUFFER_SIZE
101 #if defined(ARDUINO_AVR_UNO) || defined(ARDUINO_AVR_NANO)
102 #define DD_TUNNEL_DEF_BUFFER_SIZE 2
103 #else
104 #define DD_TUNNEL_DEF_BUFFER_SIZE 4
105 #endif
106#endif
107#if DD_TUNNEL_DEF_BUFFER_SIZE < 2
108 #error "DD_TUNNEL_DEF_BUFFER_SIZE must be at least 2"
109#endif
110
111
112#define DDIO_USE_DD_SERIAL
113
114#include "_dd_serial.h"
115#ifdef DDIO_USE_DD_SERIAL
116 extern DDSerial* _The_DD_Serial;
117#endif
118
119#include "_dd_io.h"
120#include "_dd_feedback.h"
121#include "_dd_colors.h"
122
123
124class DDLayer;
125
132typedef void (*DDFeedbackHandler)(DDLayer* pLayer, DDFeedbackType type, const DDFeedback& feedback);
133
134
135const int8_t DD_OBJECT_TYPE_LAYER = 0;
136const int8_t DD_OBJECT_TYPE_TUNNEL = 1;
137
138
140struct DDObject {
143#ifdef DD_NO_CUSTOM_DATA
144 #warning ??? DD_NO_CUSTOM_DATA set ???
145#else
148#endif
149public:
150 // since 20230601
151 virtual ~DDObject() {}
152};
153
154
157 int _h;
158};
159
160
162class DDLayer: public DDObject {
163 public:
173 void border(float size, const String& color, const String& shape = "flat", float extraSize = 0);
176 void noBorder();
180 void padding(float size);
184 void padding(float left, float top, float right, float bottom);
187 void noPadding();
191 void margin(float size);
195 void margin(float left, float top, float right, float bottom);
198 void noMargin();
203 void backgroundColor(const String& color, int opacity = 100);
213 void backgroundImage(const String& backgroundImageName, const String& drawBackgroundOptions, int refImageWidth = 0);
220 void exportAsBackgroundImage(bool replace = true, bool noDrawBackground = true, int exportAsWidth = 0);
226 void animateBackgroundImage(float fps, bool reset = true, const String& options = "");
229 void stopAnimateBackgroundImage(bool reset = true);
232 void visible(bool visible);
238 void disabled(bool disabled = true);
242 void opacity(int opacity);
246 void alpha(int alpha);
252 void blend(const String& color, int alpha = 255, const String& mode = "darken");
255 void noblend();
257 void clear();
259 void flash();
261 void flashArea(int x, int y);
270 void explicitFeedback(int16_t x = 0, int16_t y = 0, const String& text = "", DDFeedbackType type = DDFeedbackType::CLICK, const String& option = "");
271 inline const String& getLayerId() const { return layerId; }
277 void setFeedbackHandler(DDFeedbackHandler handler, const String& autoFeedbackMethod = "", const String& allowFeedbackTypes = "");
288 void enableFeedback(const String& autoFeedbackMethod = "", const String& allowFeedbackTypes = "");
295 void debugOnly(int i);
296 public:
297#ifndef DD_NO_FEEDBACK
299 inline DDFeedbackManager* getFeedbackManager() const { return pFeedbackManager; }
301 inline DDFeedbackHandler getFeedbackHandler() const { return feedbackHandler; }
302#endif
303 protected:
304 DDLayer(int8_t layerId);
305 public:
306 // made virtual since 20230601
307 virtual ~DDLayer();
308 protected:
309 void _enableFeedback();
310 protected:
311 String layerId;
312#ifndef DD_NO_FEEDBACK
313 // either feedbackManager or feedbackHandler is used
314 DDFeedbackManager *pFeedbackManager;
315 DDFeedbackHandler feedbackHandler;
316#endif
317};
318
319#define DD_DEF_LAYER_LEVEL_ID "_"
320
325 public:
330 void addLevel(const String& levelId, float width, float height, bool switchToIt = false);
332 inline void addLevel(const String& levelId, bool switchToIt = false) {
333 addLevel(levelId, 0, 0, switchToIt);
334 }
336 void addTopLevel(const String& levelId, float width = 0, float height = 0, bool switchToIt = false);
338 inline void addTopLevel(const String& levelId, bool switchToIt) {
339 addTopLevel(levelId, 0, 0, switchToIt);
340 }
344 void switchLevel(const String& levelId, bool addIfMissing = true);
346 void pushLevel();
349 void pushLevelAndSwitchTo(const String& switchTolevelId, bool addIfMissing = true);
351 void popLevel();
358 void setLevelAnchor(float x, float y, long reachInMillis = 0);
360 void moveLevelAnchorBy(float byX, float byY, long reachInMillis = 0);
367 void registerLevelBackground(const String& backgroundId, const String& backgroundImageName, const String& drawBackgroundOptions = "");
373 void exportLevelAsRegisteredBackground(const String& backgroundId, bool replace = true);
380 void setLevelBackground(const String& backgroundId, const String& backgroundImageName = "", const String& drawBackgroundOptions = "");
387 void animateLevelBackground(float fps, bool reset = true, const String& options = "");
390 void stopAnimateLevelBackground(bool reset = true);
393 void reorderLevel(const String& levelId, const String& how);
395 void exportLevelsAsImage(const String& imageFileName, bool cacheItNotSave = false);
397 void deleteLevel(const String& levelId);
398 protected:
399 MultiLevelDDLayer(int8_t layerId): DDLayer(layerId) {}
400};
401
402
403
404enum MbArrow { North, NorthEast, East, SouthEast, South, SouthWest, West, NorthWest };
405enum MbIcon { Heart, SmallHeart, Yes, No, Happy, Sad, Confused, Angry, Asleep, Surprised,
406 Silly, Fabulous, Meh, TShirt, Rollerskate, Duck, House, Tortoise, Butterfly, StickFigure,
407 Ghost, Sword, Giraffe, Skull, Umbrella, Snake, Rabbit, Cow, QuarterNote, EigthNote,
408 Pitchfork, Target, Triangle, LeftTriangle, Chessboard, Diamond, SmallDiamond, Square, SmallSquare, Scissors };
409
410class MbImage {
411 public:
412 MbImage(int8_t imageId) {
413 this->imageId = String(imageId);
414 }
415 inline const String& getImageId() const { return this->imageId; }
416 private:
417 String imageId;
418};
419
421class MbDDLayer: public DDLayer {
422 public:
424 MbDDLayer(int8_t layerId): DDLayer(layerId) {
425 }
427 void showIcon(MbIcon icon);
429 void showArrow(MbArrow arrow);
431 void showNumber(int num);
433 void showString(const String& str);
435 void plot(int x, int y);
437 void unplot(int x, int y);
439 void toggle(int x, int y);
445 void showLeds(const String& ledPattern);
448 void ledColor(const String& color);
449 MbImage* createImage(const String& ledPattern);
450 void releaseImage(MbImage *pImage);
451 void showImage(MbImage *pImage, int xOff);
452 void scrollImage(MbImage *pImage, int xOff, long interval);
453};
454
457 public:
459 TurtleDDLayer(int8_t layerId): MultiLevelDDLayer(layerId) {
460 }
462 void forward(int distance, bool withPen = true);
464 void backward(int distance, bool withPen = true);
466 void leftTurn(int angle);
468 void rightTurn(int angle);
470 void home(bool withPen = true);
472 void goTo(int x, int y, bool withPen = true);
474 void goBy(int byX, int byY, bool withPen = true);
476 void setHeading(int angle);
478 void penSize(int size);
481 void penColor(const String& color);
484 void fillColor(const String& color);
488 void penFilled(bool filled = true);
490 void setTextSize(int size);
494 void setTextFont(const String& fontName = "", int textSize = 0);
496 void penUp();
498 void penDown();
499 void beginFill();
500 void endFill();
502 void dot(int size, const String& color);
504 void circle(int radius, bool centered = false);
506 void oval(int width, int height, bool centered = false);
508 void arc(int width, int height, int startAngle, int sweepAngle, bool centered = false);
510 void triangle(int side1, int angle, int side2);
512 void isoscelesTriangle(int side, int angle);
514 void rectangle(int width, int height, bool centered = false);
516 void polygon(int side, int vertexCount);
520 void centeredPolygon(int radius, int vertexCount, bool inside = false);
522 void write(const String& text); // TODO: add align param
524 void drawText(const String& text);
526 inline void write(const String& text, bool draw) {
527 if (draw) {
528 drawText(text);
529 } else {
530 write(text);
531 }
532 }
533};
534
536
537
539class LedGridDDLayer: public DDLayer {
540 public:
543 LedGridDDLayer(LedGridDDLayerHandle layerHandle): DDLayer(layerHandle._h) {
544 }
545 public:
547 LedGridDDLayer(int8_t layerId): DDLayer(layerId) {
548 }
550 void turnOn(int x = 0, int y = 0);
552 void turnOff(int x = 0, int y = 0);
554 void toggle(int x = 0, int y = 0);
557 void turnOnEx(int x = 0, int y = 0, const String& onColor = "");
562 void bitwise(unsigned int bits, int y = 0, bool reverse = false);
565 void bitwise2(unsigned int bits_0, unsigned int bits_1, int y = 0, bool reverse = false);
568 void bitwise3(unsigned int bits_0, unsigned int bits_1, unsigned int bits_2, int y = 0, bool reverse = false);
571 void bitwise4(unsigned int bits_0, unsigned int bits_1, unsigned int bits_2, unsigned int bits_3, int y = 0, bool reverse = false);
574 void horizontalBar(int count, bool rightToLeft = false);
577 void verticalBar(int count, bool bottomToTop = true);
582 void horizontalBarEx(int count, int startX = 0, const String& color = "");
587 void verticalBarEx(int count, int startY = 0, const String& color = "");
590 void onColor(const String& color);
593 void offColor(const String& color);
596};
597
598
600
606class LcdDDLayer: public DDLayer {
607 public:
610 LcdDDLayer(LcdDDLayerHandle layerHandle): DDLayer(layerHandle._h) {
611 }
612 public:
614 LcdDDLayer(int8_t layerId): DDLayer(layerId) {
615 }
617 void print(const String& text);
619 void home();
623 void setCursor(int x, int y);
625 void cursor();
627 void noCursor();
632 void display();
633 void noDisplay();
634 void scrollDisplayLeft();
635 void scrollDisplayRight();
638 void writeLine(const String& text, int y = 0, const String& align = "L");
640 void writeRightAlignedLine(const String& text, int y = 0);
642 void writeCenteredLine(const String& text, int y = 0);
645 void pixelColor(const String &color);
648 void bgPixelColor(const String &color, bool sameForBackgroundColor = false, int backgroundOpacity = 100);
651};
652
653
655 public:
657 SelectionBaseDDLayer(int8_t layerId): DDLayer(layerId) {
658 _enableFeedback();
659 }
663 void pixelColor(const String &color);
667 void pixelColor(const String &color, bool selected);
668 // /// set background pixel color
669 // /// @param color DD_RGB_COLOR(...) or common color name
670 // void bgPixelColor(const String &color, bool sameForBackgroundColor = false, int backgroundOpacity = 100);
672 void selectAll();
678 void highlightBorder(bool forSelected, const String& borderColor = "", const String& borderShape = "");
679};
680
686 public:
688 SelectionDDLayer(int8_t layerId): SelectionBaseDDLayer(layerId) {}
691 void text(const String& text, int y = 0, int horiSelectionIdx = 0, int vertSelectionIdx = 0, const String& align = "L");
693 void textCentered(const String& text, int y = 0, int horiSelectionIdx = 0, int vertSelectionIdx = 0);
695 void textRightAligned(const String& text, int y = 0, int horiSelectionIdx = 0, int vertSelectionIdx = 0);
698 void unselectedText(const String& text, int y = 0, int horiSelectionIdx = 0, int vertSelectionIdx = 0, const String& align = "L");
700 void unselectedTextCentered(const String& text, int y = 0, int horiSelectionIdx = 0, int vertSelectionIdx = 0);
702 void unselectedTextRightAligned(const String& text, int y = 0, int horiSelectionIdx = 0, int vertSelectionIdx = 0);
704 void select(int horiSelectionIdx = 0, int vertSelectionIdx = 0, bool deselectTheOthers = true);
706 void deselect(int horiSelectionIdx = 0, int vertSelectionIdx = 0, bool selectTheOthers = false);
708 void setSelected(bool selected, int horiSelectionIdx = 0, int vertSelectionIdx = 0) {
709 if (selected) {
710 select(horiSelectionIdx, vertSelectionIdx, false);
711 } else {
712 deselect(horiSelectionIdx, vertSelectionIdx, false);
713 }
714 }
716 void selected(bool selected, int horiSelectionIdx = 0, int vertSelectionIdx = 0, bool reverseTheOthers = false);
717};
718
725 public:
727 SelectionListDDLayer(int8_t layerId): SelectionBaseDDLayer(layerId) {}
730 void add(int selectionIdx);
733 void remove(int selectionIdx);
735 void offset(int offset);
738 void text(int selectionIdx, const String& text, int y = 0, const String& align = "L");
740 void textCentered(int selectionIdx, const String& text, int y = 0);
742 void textRightAligned(int selectionIdx, const String& text, int y = 0);
745 void unselectedText(int selectionIdx, const String& text, int y = 0, const String& align = "L");
747 void unselectedTextCentered(int selectionIdx, const String& text, int y = 0);
749 void unselectedTextRightAligned(int selectionIdx, const String& text, int y = 0);
751 void select(int selectionIdx, bool deselectTheOthers = true);
753 void deselect(int selectionIdx, bool selectTheOthers = false);
755 void selected(int selectionIdx, bool selected, bool reverseTheOthers = false);
756};
757
758
760
761
764 public:
768 }
769 public:
771 GraphicalDDLayer(int8_t layerId): MultiLevelDDLayer(layerId) {
772 }
774 void setRotation(int8_t rotationType);
776 void setCursor(int x, int y);
778 void moveCursorBy(int byX, int byY);
782 void setTextColor(const String& color, const String& bgColor = "");
784 void setTextSize(int size);
788 void setTextFont(const String& fontName);
792 inline void setTextFont(const String& fontName, int textSize) {
793 setTextFont(fontName);
794 if (textSize > 0) {
795 setTextSize(textSize);
796 }
797 }
799 void setTextWrap(bool wrapOn);
802 void fillScreen(const String& color);
804 void print(const String& text);
806 void println(const String& text = "");
811 void drawChar(int x, int y, char c, const String& color = "", const String& bgColor = "", int size = 0);
816 void drawStr(int x, int y, const String& string, const String& color = "", const String& bgColor = "", int size = 0);
819 void drawTextLine(const String& text, int y, const String& align = "L", const String& color = "", const String& bgColor = "", int size = 0);
822 void drawPixel(int x, int y, const String& color = "");
825 void drawLine(int x1, int y1, int x2, int y2, const String& color = "");
828 void drawCircle(int x, int y, int r, const String& color = "", bool filled = false);
829 // draw filled circle
831 inline void fillCircle(int x, int y, int r, const String& color = "") {
832 drawCircle(x, y, r, color, true);
833 }
836 void drawTriangle(int x1, int y1, int x2, int y2, int x3, int y3, const String& color = "", bool filled = false);
839 inline void fillTriangle(int x1, int y1, int x2, int y2, int x3, int y3, const String& color = "") {
840 drawTriangle(x1, y1, x2, y2, x3, y3, color, true);
841 }
844 void drawRect(int x, int y, int w, int h, const String& color = "", bool filled = false);
847 inline void fillRect(int x, int y, int w, int h, const String& color = "") {
848 drawRect(x, y, w, h, color, true);
849 }
852 void drawRoundRect(int x, int y, int w, int h, int r, const String& color = "", bool filled = false);
855 inline void fillRoundRect(int x, int y, int w, int h, int r, const String& color = "") {
856 drawRoundRect(x, y, w, h, r, color, true);
857 }
860 void drawOval(int x, int y, int w, int h, const String& color = "", bool filled = false);
863 inline void fillOval(int x, int y, int w, int h, const String& color = "") {
864 drawOval(x, y, w, h, color, true);
865 }
868 void drawArc(int x, int y, int w, int h, int startAngle, int sweepAngle, bool useCenter, const String& color = "", bool filled = false);
871 inline void fillArc(int x, int y, int w, int h, int startAngle, int sweepAngle, bool useCenter, const String& color = "") {
872 drawArc(x, y, w, h, startAngle, sweepAngle, useCenter, color, true);
873 }
875 void forward(int distance, bool withPen = true);
877 void backward(int distance, bool withPen = true);
879 void leftTurn(int angle);
881 void rightTurn(int angle);
883 void setHeading(int angle);
885 void penSize(int size);
888 void penColor(const String& color);
891 void fillColor(const String& color);
895 void circle(int radius, bool centered = false);
897 void oval(int width, int height, bool centered = false);
899 void arc(int width, int height, int startAngle, int sweepAngle, bool centered = false);
901 void triangle(int side1, int angle, int side2);
903 void isoscelesTriangle(int side, int angle);
905 void rectangle(int width, int height, bool centered = false);
907 void polygon(int side, int vertexCount);
912 void centeredPolygon(int radius, int vertexCount, bool inside = false);
914 void write(const String& text);
916 void drawText(const String& text);
918 inline void write(const String& text, bool draw) {
919 if (draw) {
920 drawText(text);
921 } else {
922 write(text);
923 }
924 }
928 void loadImageFile(const String& imageFileName, int w = 0, int h = 0, const String& asImageFileName = "");
934 inline void loadImageFileScaled(const String& imageFileName, int w, int h, const String& asImageFileName) {
935 loadImageFile(imageFileName, w, h, asImageFileName);
936 }
937 void loadImageFileCropped(const String& imageFileName, int x, int y, int w, int h, const String& asImageFileName, int scaleW = 0, int scaleH = 0);
939 void unloadImageFile(const String& imageFileName);
945 void drawImageFile(const String& imageFileName, int x = 0, int y = 0, int w = 0, int h = 0, const String& options = "");
947 inline void drawImageFile(const String& imageFileName, const String& options) {
948 drawImageFile(imageFileName, 0, 0, 0, 0, options);
949 }
952 inline void drawImageFileScaled(const String& imageFileName, int w, int h, const String& options = "") {
953 drawImageFile(imageFileName, 0, 0, w, h, options);
954 }
958 void drawImageFileFit(const String& imageFileName, int x = 0, int y = 0, int w = 0, int h = 0, const String& options = "");
960 inline void drawImageFileFit(const String& imageFileName, const String& options) {
961 drawImageFileFit(imageFileName, 0, 0, 0, 0, options);
962 }
965 void cacheImage(const String& imageName, const uint8_t *bytes, int byteCount, char compressionMethod = 0);
968 void cacheImageWithTS(const String& imageName, const uint8_t *bytes, int byteCount, long imageTimestamp, char compressionMethod = 0);
971 void cachePixelImage(const String& imageName, const uint8_t *bytes, int width, int height, const String& color = "", char compressionMethod = 0);
974 void cachePixelImage16(const String& imageName, const uint16_t *data, int width, int height, const String& options = "", char compressMethod = 0);
977 void cachePixelImageGS(const String& imageName, const uint8_t *data, int width, int height, const String& options = "", char compressMethod = 0);
980 void saveCachedImageFile(const String& imageName, const String& asImageName = "");
981#ifdef ESP32
984 void saveCachedImageFileWithTS(const String& imageName, const String& asImageName, int64_t imageTimestamp);
985#endif
988 void saveCachedImageFileAsync(const String& imageName, const String& asImageName = "");
989#ifdef ESP32
992 void saveCachedImageFileWithTSAsync(const String& imageName, const String& asImageName, int64_t imageTimestamp);
993#endif
996 void saveCachedImageFiles(const String& stitchAsImageName = "");
997};
998
999
1002 public:
1004 SevenSegmentRowDDLayer(int8_t layerId): DDLayer(layerId) {
1005 }
1008 void segmentColor(const String& color);
1011 void resetSegmentOffColor(const String& color);
1017 void turnOn(const String& segments, int digitIdx = 0);
1021 void turnOff(const String& segments, int digitIdx = 0);
1024 void setOn(const String& segments = "", int digitIdx = 0);
1026 void showDigit(int digit, int digitIdx = 0);
1028 void showNumber(float number, const String& padding = " ");
1030 void showHexNumber(int16_t number);
1033 void showFormatted(const String& formatted, bool completeReplace = true, int startIdx = 0);
1034};
1035
1036
1041 public:
1043 JoystickDDLayer(int8_t layerId): DDLayer(layerId) {
1044 _enableFeedback();
1045 }
1048 void autoRecenter(bool autoRecenter = true);
1050 void colors(const String& stickColor, const String& stickOutlineColor, const String& socketColor = "", const String& socketOutlineColor = "");
1055 void moveToPos(int16_t x, int16_t y, bool sendFeedback = false);
1058 void moveToCenter(bool sendFeedback = false);
1063 void valueRange(int16_t minValue, int16_t maxValue, int valueStep = 1, bool sendFeedback = false);
1065 void snappy(bool snappy = true);
1067 void showValue(bool show = true, const String& color = "");
1068};
1069
1072 public:
1074 PlotterDDLayer(int8_t layerId): DDLayer(layerId) {
1075 }
1078 void label(const String& key, const String& lab);
1079 inline void label(const String& lab) { label("", lab); }
1082 void set(const String& key, float value);
1084 inline void set(float value) { set("", value); }
1085 void set(const String& key1, float value1, const String& key2, float value2);
1086 void set(const String& key1, float value1, const String& key2, float value2, const String& key3, float value3);
1087 void set(const String& key1, float value1, const String& key2, float value2, const String& key3, float value3, const String& key4, float value4);
1088};
1089
1090
1094 public:
1096 TomTomMapDDLayer(int8_t layerId): DDLayer(layerId) {
1097 }
1098 void goTo(float latitude, float longitude, const String& label = "");
1099 void zoomTo(float latitude, float longitude, float zoomLevel = 15.0, const String& label = "");
1100 void zoom(float zoomLevel);
1101};
1102
1103
1106 public:
1108 TerminalDDLayer(int8_t layerId): DDLayer(layerId) {
1109 }
1110 void print(const String& val);
1111 void println(const String& val);
1112 inline void print(int intVal) {
1113 String val(intVal);
1114 print(val);
1115 }
1116 inline void println(int intVal) {
1117 String val(intVal);
1118 print(val);
1119 }
1120 inline void print(float floatVal) {
1121 String val(floatVal);
1122 print(val);
1123 }
1124 inline void println(float floatVal) {
1125 String val(floatVal);
1126 print(val);
1127 }
1128 inline void println() {
1129 println("");
1130 }
1131};
1132
1136 public:
1138 WebViewDDLayer(int8_t layerId): DDLayer(layerId) {
1139 _enableFeedback();
1140 }
1141 void loadUrl(const String& url);
1142 void loadHtml(const String& html);
1143 void execJs(const String& js);
1144};
1145
1146
1150 public:
1152 DumbDisplayWindowDDLayer(int8_t layerId): DDLayer(layerId) {
1153 }
1154 void connect(const String& deviceType, const String& deviceName, const String& deviceAddress);
1155 void disconnect();
1156};
1157
1161 public:
1163 RtspClientDDLayer(int8_t layerId): DDLayer(layerId) {}
1165 void start(const String& url);
1166 void stop();
1167};
1168
1169
1170
1171
1172
1175 public:
1176 DDTunnelEndpoint(const String& endPoint) {
1177 this->endPoint = endPoint;
1178 this->headers = "";
1179 this->params = "";
1180 }
1182 void resetEndpoint(const String& endPoint) {
1183 this->endPoint = endPoint;
1184 }
1187 void resetSoundAttachment(const String& soundName) {
1188 if (soundName == "") {
1189 this->attachmentId = "";
1190 } else {
1191 this->attachmentId = "sound:" + soundName;
1192 }
1193 }
1196 this->headers = "";
1197 }
1200 this->params = "";
1201 }
1203 void addParam(const String& param) {
1204 if (true) {
1205 if (this->params.length() > 0) {
1206 this->params.concat(',');
1207 }
1208 this->params.concat(param);
1209 } else {
1210 if (this->params == "") {
1211 this->params = param;
1212 } else {
1213 this->params = this->params + "," + param;
1214 }
1215 }
1216 }
1218 void addNamedParam(const String& paramName, const String& paramValue) {
1219 addParam(paramName + "=" + paramValue);
1220 }
1222 void addHeader(const String& headerKey, const String& headerValue) {
1223 if (true) {
1224 if (this->headers.length() > 0) {
1225 this->headers.concat('|');
1226 }
1227 this->headers.concat(headerKey);
1228 this->headers.concat(":");
1229 this->headers.concat(headerValue);
1230 } else {
1231 if (this->headers == "") {
1232 this->headers = String(headerKey) + ":" + headerValue;
1233 } else {
1234 this->headers = this->headers + "|" + headerKey + ":" + headerValue;
1235 }
1236 }
1237 }
1238 public:
1239 String endPoint;
1240 String headers;
1241 String attachmentId;
1242 String params;
1243};
1244
1245
1247class DDTunnel: public DDObject {
1248 public:
1250 DDTunnel(const String& type, int8_t tunnelId, const String& params, const String& endPoint/*, bool connectNow*/);
1251 void afterConstruct(bool connectNow);
1252 virtual ~DDTunnel() override;
1253 public:
1254 const String& getEndpoint() { return endPoint; }
1255 public:
1256 virtual void release();
1257 protected:
1258 virtual void _reconnect(const String& extraParams = "");
1259 void _reconnectTo(const String& endPoint, const String& extraParams = "");
1260 public:
1261 const String& getTunnelId() const { return tunnelId; }
1264 public:
1265 inline void reconnectTo(const String& endPoint) { _reconnectTo(endPoint); }
1266 protected:
1267 // /// reconnect to specified endpoint with parameters
1268 // /// @param endPoint endpoint to connect to
1269 // /// @param params parameters to to end point; empty if none
1270 // void reconnectToSetParams(const String& endPoint, const String& params) {
1271 // this->endPoint = endPoint;
1272 // this->params = params;
1273 // _reconnect();
1274 // }
1275 public:
1278 this->endPoint = endpoint.endPoint;
1279 this->headers = endpoint.headers;
1280 this->attachmentId = endpoint.attachmentId;
1281 this->params = endpoint.params;
1282 _reconnect();
1283 }
1284 protected:
1285 inline bool _pending() { return doneState == 0; }
1286 //int _count();
1287 inline bool _timedOut() { return /*timedOut*/doneState == -1; }
1288 virtual bool _eof(long timeoutMillis);
1289 //void _readLine(String &buffer);
1290 void _writeLine(const String& data);
1291 void _writeSound(const String& soundName);
1292 public:
1293 virtual void handleInput(const String& data, uint8_t* fbBytes, bool final) { doneHandleInput(final); }
1294 protected:
1295 void doneHandleInput(bool final);
1296 protected:
1297 String type;
1298 String tunnelId;
1299 String endPoint;
1300 String headers;
1301 String attachmentId;
1302 String params;
1303 unsigned long connectMillis;
1304 // int arraySize;
1305 // String* dataArray;
1306 // int nextArrayIdx;
1307 // int validArrayIdx;
1308 private:
1309 //bool done;
1310 //bool timedOut;
1311 int8_t doneState; // 0 not done; 1 done; -1 timed out
1312};
1313
1314
1317 public:
1319 DDBufferedTunnel(const String& type, int8_t tunnelId, const String& params, const String& endPoint/*, bool connectNow*/, int8_t bufferSize);
1320 virtual ~DDBufferedTunnel() override;
1321 public:
1322 virtual void release() override;
1323 protected:
1324 virtual void _reconnect(const String& extraParams = "") override;
1325 //const String& getTunnelId() { return tunnelId; }
1326 public:
1327 inline void reconnect() { _reconnect(); }
1328 protected:
1329 int _count();
1330 virtual bool _eof(long timeoutMillis) override;
1331 bool _readLine(String &buffer, uint8_t** pFBBytes = NULL);
1332 //void _writeLine(const String& data);
1333 public:
1335 virtual void handleInput(const String& data, uint8_t* fbBytes, bool final) override;
1336 private:
1337 // String endPoint;
1338 // String tunnelId;
1339 int8_t arraySize;
1340 String* dataArray;
1341 uint8_t** fbByesArray;
1342 int8_t nextArrayIdx;
1343 int8_t validArrayIdx;
1344 //bool done;
1345 public:
1346 bool pending();
1348 inline int count() { return _count(); }
1352 inline bool eof(long timeoutMillis = DD_DEF_TUNNEL_TIMEOUT) { return _eof(timeoutMillis); }
1354 inline bool timedOut() { return _timedOut(); }
1356 String readLine();
1358 inline bool readLine(String &buffer) { return _readLine(buffer); }
1360 inline void writeLine(const String& data) { _writeLine(data); }
1362 bool read(String& fieldId, String& fieldValue);
1363};
1364
1365
1372
1399
1402 public:
1404 SimpleToolDDTunnel(const String& type, int8_t tunnelId, const String& params, const String& endPoint/*, bool connectNow*/, int bufferSize):
1405 BasicDDTunnel(type, tunnelId, params, endPoint/*, connectNow*/, bufferSize) {
1406 this->result = 0;
1407 }
1408 protected:
1409 virtual void _reconnect(const String& extraParams = "") override;
1410 public:
1411 //inline void reconnect() { _reconnect(); }
1414 private:
1415 int result;
1416};
1417
1420 public:
1422 ImageDownloadDDTunnel(int8_t tunnelId, const String& params, const String& endPoint/*, bool connectNow*/, int bufferSize):
1423 SimpleToolDDTunnel("dddownloadimage", tunnelId, params, endPoint/*, connectNow*/, bufferSize) {}
1424 public:
1426 void reconnectTo(const String& endPoint, const String& cropUIConfig = "");
1427};
1428
1429
1432 float latitude;
1433 float longitude;
1434};
1437 public:
1439 GpsServiceDDTunnel(const String& type, int8_t tunnelId, const String& params, const String& endPoint/*, bool connectNow*/, int8_t bufferSize):
1440 BasicDDTunnel(type, tunnelId, params, endPoint/*, connectNow*/, bufferSize) {
1441 }
1442 public:
1444 void reconnectForLocation(int repeat = -1);
1445 bool readLocation(DDLocation& location);
1446};
1447
1448
1451 int left;
1452 int top;
1453 int right;
1454 int bottom;
1455 String label;
1456};
1459 public:
1461 ObjectDetectDemoServiceDDTunnel(const String& type, int8_t tunnelId, const String& params, const String& endPoint/*, bool connectNow*/, int8_t bufferSize):
1462 BasicDDTunnel(type, tunnelId, params, endPoint/*, connectNow*/, bufferSize) {
1463 }
1464 public:
1465 void reconnectForObjectDetect(const String& imageName);
1466 void reconnectForObjectDetectFrom(GraphicalDDLayer* pGraphicalLayer, const String& imageName);
1467 bool readObjectDetectResult(DDObjectDetectDemoResult& objectDetectResult);
1468};
1469
1471 DDImageData(): bytes(NULL) {};
1472 ~DDImageData();
1473 bool isValid() { return width > 0 && height > 0; }
1474 void release();
1475 int width;
1476 int height;
1477 int byteCount;
1478 uint8_t* bytes;
1479protected:
1480 void transferTo(DDImageData& imageData);
1481};
1483 void transferDataTo(DDPixelImage& pixelImage) { DDImageData::transferTo(pixelImage); }
1484};
1486 DDPixelImage16(): data(NULL) {};
1488 bool isValid() { return width > 0 && height > 0; }
1489 void transferTo(DDPixelImage16& pixelImage16);
1490 void release();
1491 int width;
1492 int height;
1493 int byteCount;
1494 uint16_t* data;
1495};
1496struct DDJpegImage: public DDImageData {
1497 void transferTo(DDJpegImage& jpegImage) { DDImageData::transferTo(jpegImage); }
1498};
1506 public:
1508 ImageRetrieverDDTunnel(const String& type, int8_t tunnelId, const String& params, const String& endPoint/*, bool connectNow*/, int8_t bufferSize):
1509 BasicDDTunnel(type, tunnelId, params, endPoint/*, connectNow*/, bufferSize) {
1510 }
1511 public:
1514 void reconnectForPixelImage(const String& imageName, int width, int height, bool fit = false);
1517 void reconnectForPixelImage16(const String& imageName, int width, int height, bool fit = false, bool grayscale = false);
1518 void reconnectForPixelImageGS(const String& imageName, int width, int height, bool fit = false);
1521 void reconnectForJpegImage(const String& imageName, int width, int height, int quality=100, bool fit = false);
1523 bool readPixelImage(DDPixelImage& pixelImage);
1525 bool readPixelImage16(DDPixelImage16& pixelImage16);
1526 bool readPixelImageGS(DDPixelImage& pixelImage);
1531 private:
1532 bool _readImageData(DDImageData& imageData, short type);
1533};
1534
1535
1536
1540 public:
1542 JsonDDTunnelMultiplexer(JsonDDTunnel** tunnels, int8_t tunnelCount);
1544 int count();
1545 bool eof();
1547 int read(String& fieldId, String& fieldValue);
1548 void release();
1549 void reconnect();
1550 private:
1551 int8_t tunnelCount;
1552 JsonDDTunnel** tunnels;
1553};
1554
1555#ifndef DD_NO_IDLE_CALLBACK
1559enum DDIdleConnectionState { IDLE_NOT_CONNECTED, IDLE_CONNECTING, IDLE_RECONNECTING };
1565typedef void (*DDIdleCallback)(long idleForMillis, DDIdleConnectionState connectionState);
1566#endif
1567
1568#ifndef DD_NO_CONNECT_VERSION_CHANGED_CALLBACK
1572typedef void (*DDConnectVersionChangedCallback)(int connectVersion);
1573#endif
1574
1575#ifndef DD_NO_DEBUG_INTERFACE
1579enum DDDebugConnectionState { DEBUG_NOT_CONNECTED, DEBUG_CONNECTING, DEBUG_CONNECTED, DEBUG_RECONNECTING, DEBUG_RECONNECTED };
1582 public:
1584 virtual void logConnectionState(DDDebugConnectionState connectionState) {}
1586 virtual void logSendCommand(int state) {}
1587 virtual void logError(const String& errMsg) {}
1588};
1589#endif
1590
1591
1592#ifndef DD_NO_PASSIVE_CONNECT
1601};
1602#endif
1603
1604
1605extern bool _DDDisableParamEncoding;
1606inline void DDDebugDisableParamEncoding() { _DDDisableParamEncoding = true; }
1607
1608
1613 public:
1614 DumbDisplay(DDInputOutput* pIO, uint16_t sendBufferSize = DD_DEF_SEND_BUFFER_SIZE, long idleTimeout = DD_DEF_IDLE_TIMEOUT/*, bool enableDoubleClick = true*/) {
1615#ifdef DD_DISABLE_PARAM_ENCODING
1616 DDDebugDisableParamEncoding();
1617#endif
1618#ifdef DD_NO_SERIAL
1619 #warning ***** DD_NO_SERIAL defined *****
1620#else
1621 #ifdef DDIO_USE_DD_SERIAL
1622 if (pIO->isForSerial() || pIO->isBackupBySerial()) {
1623 _The_DD_Serial = new DDSerial();
1624 }
1625 #endif
1626#endif
1627 initialize(pIO, sendBufferSize, idleTimeout/*, enableDoubleClick*/);
1628 }
1631 void connect();
1633 bool connected() const;
1641 void setFeedbackSingleClickOnly(bool singleClickOnly = true);
1649 void configAutoPin(const String& layoutSpec = DD_AP_VERT, bool autoControlLayerVisible = false);
1651 void addRemainingAutoPinConfig(const String& restLayoutSpec);
1657 void configPinFrame(int xUnitCount = 100, int yUnitCount = 100, bool autoControlLayerVisible = false);
1661 void pinLayer(DDLayer *pLayer, int uLeft, int uTop, int uWidth, int uHeight, const String& align = "");
1665 void pinAutoPinLayers(const String& layoutSpec, int uLeft, int uTop, int uWidth, int uHeight, const String& align = "");
1672 GraphicalDDLayer* setRootLayer(int width, int height, const String& containedAlignment = "");
1674 MbDDLayer* createMicrobitLayer(int width = 5, int height = 5);
1676 TurtleDDLayer* createTurtleLayer(int width, int height);
1678 LedGridDDLayer* createLedGridLayer(int colCount = 1, int rowCount = 1, int subColCount = 1, int subRowCount = 1);
1680 LcdDDLayer* createLcdLayer(int colCount = 16, int rowCount = 2, int charHeight = 0, const String& fontName = "");
1682 SelectionDDLayer* createSelectionLayer(int colCount = 16, int rowCount = 2,
1683 int horiSelectionCount = 1, int vertSelectionCount = 1,
1684 int charHeight = 0, const String& fontName = "",
1685 bool canDrawDots = true, float selectionBorderSizeCharHeightFactor = 0.3);
1687 SelectionListDDLayer* createSelectionListLayer(int colCount = 16, int rowCount = 2,
1688 int horiSelectionCount = 1, int vertSelectionCount = 1,
1689 int charHeight = 0, const String& fontName = "",
1690 bool canDrawDots = true, float selectionBorderSizeCharHeightFactor = 0.3);
1706 JoystickDDLayer* createJoystickLayer(int maxStickValue = 1023, const String& directions = "", float stickSizeFactor = 1.0/*, int stickValueDivider = 1*/);
1708 PlotterDDLayer* createPlotterLayer(int width, int height, int pixelsPerSecond = 10);
1712 PlotterDDLayer* createFixedRatePlotterLayer(int width, int height, int pixelsPerScale = 5);
1717 TomTomMapDDLayer* createTomTomMapLayer(const String& mapKey, int width, int height);
1720 TerminalDDLayer* createTerminalLayer(int width, int height);
1723 WebViewDDLayer* createWebViewLayer(int width, int height, const String& jsObjectName = "DD");
1729 RtspClientDDLayer* createRtspClient(int width, int height);
1733 BasicDDTunnel* createBasicTunnel(const String& endPoint, bool connectNow = true, int8_t bufferSize = DD_TUNNEL_DEF_BUFFER_SIZE);
1737 JsonDDTunnel* createJsonTunnel(const String& endPoint, bool connectNow = true, int8_t bufferSize = DD_TUNNEL_DEF_BUFFER_SIZE);
1742 JsonDDTunnel* createFilteredJsonTunnel(const String& endPoint, const String& fieldNames, bool connectNow = true, int8_t bufferSize = DD_TUNNEL_DEF_BUFFER_SIZE);
1747 ImageDownloadDDTunnel* createImageDownloadTunnel(const String& endPoint, const String& imageName, bool redownload = true);
1762 ObjectDetectDemoServiceDDTunnel* createObjectDetectDemoServiceTunnel(int scaleToWidth = 0, int scaleToHeight = 0, int maxNumObjs = 1);
1763 ImageRetrieverDDTunnel* createImageRetrieverTunnel();
1769 LcdDDLayerHandle createLcdLayerHandle(int colCount = 16, int rowCount = 2, int charHeight = 0, const String& fontName = "");
1772 LedGridDDLayerHandle createLedGridLayerHandle(int colCount = 1, int rowCount = 1, int subColCount = 1, int subRowCount = 1);
1774 void deleteTunnel(DDTunnel *pTunnel);
1781 void unfreezeDrawing(bool refreezeAfterward = false);
1784 void backgroundColor(const String& color);
1791 void playbackLayerSetupCommands(const String& layerSetupPersistId);
1800 void stopRecordLayerCommands(const String& saveId = "", bool persistSave = false);
1807 void saveLayerCommands(const String& id, bool persist = false, bool stopAfterSave = false);
1812 void loadLayerCommands(const String& id);
1818 void capture(const String& imageFileName, int width, int height);
1820 void sendNoOp();
1822 void writeComment(const String& comment);
1824 void tone(uint32_t freq, uint32_t duration);
1825 void notone();
1827 void playSound(const String& soundName);
1828 void stopSound();
1830 void saveSound8(const String& soundName, const int8_t *bytes, int sampleCount, int sampleRate, int numChannels = 1);
1832 void saveSound16(const String& soundName, const int16_t *data, int sampleCount, int sampleRate, int numChannels = 1);
1834 void cacheSound8(const String& soundName, const int8_t *bytes, int sampleCount, int sampleRate, int numChannels = 1);
1836 void cacheSound16(const String& soundName, const int16_t *data, int sampleCount, int sampleRate, int numChannels = 1);
1838 void saveCachedSound(const String& soundName);
1840 void saveCachedSoundAsH(const String& soundName);
1842 int streamSound8(int sampleRate, int numChannels = 1);
1844 int streamSound16(int sampleRate, int numChannels = 1);
1847 int saveSoundChunked8(const String& soundName/*, const int8_t *bytes, int sampleCount*/, int sampleRate, int numChannels = 1);
1850 int saveSoundChunked16(const String& soundName/*, const int16_t *data, int sampleCount*/, int sampleRate, int numChannels = 1);
1853 int cacheSoundChunked8(const String& soundName/*, const int8_t *bytes, int sampleCount*/, int sampleRate, int numChannels = 1);
1856 int cacheSoundChunked16(const String& soundName/*, const int16_t *data, int sampleCount*/, int sampleRate, int numChannels = 1);
1858 void sendSoundChunk8(int chunkId, const int8_t *bytes, int sampleCount, bool isFinal = false);
1860 void sendSoundChunk16(int chunkId, const int16_t *data, int sampleCount, bool isFinal = false);
1862 void saveImage(const String& imageName, const uint8_t *bytes, int byteCount);
1864 void savePixelImage(const String& imageName, const uint8_t *bytes, int width, int height, const String& color = "", char compressMethod = 0);
1866 void savePixelImage16(const String& imageName, const uint16_t *data, int width, int height, const String& options = "", char compressMethod = 0);
1868 void savePixelImageGS(const String& imageName, const uint8_t *data, int width, int height, const String& options = "", char compressMethod = 0);
1872 void stitchImages(const String& imageNames, const String& asImageName);
1874 void alert(const String& message, const String& title = "");
1877 void reorderLayer(DDLayer *pLayer, const String& how);
1879 void deleteLayer(DDLayer *pLayer);
1881 void deleteLayer(DDLayerHandle layerHandle);
1883 void walkLayers(void (*walker)(DDLayer *));
1884 #ifndef DD_NO_IDLE_CALLBACK
1889 void setIdleCallback(DDIdleCallback idleCallback);
1890#endif
1891#ifndef DD_NO_CONNECT_VERSION_CHANGED_CALLBACK
1895#endif
1899 void logToSerial(const String& logLine, bool force = false);
1901 void log(const String& logLine, bool isError = false);
1902 public:
1903 #ifndef DD_NO_PASSIVE_CONNECT
1916#endif
1917 public:
1920#ifndef DD_NO_DEBUG_INTERFACE
1921 void debugSetup(DDDebugInterface *debugInterface);
1922#endif
1923 void debugOnly(int i);
1924 private:
1925 void initialize(DDInputOutput* pIO, uint16_t sendBufferSize, long idleTimeout/*, bool enableDoubleClick*/);
1926 //bool canLogToSerial();
1927};
1928
1929#include "_dd_misc.h"
1930
1931#endif
Class for DD "tunnel", with buffering support; created with DumbDisplay::createBasicTunnel()
Definition: dumbdisplay.h:1316
virtual void handleInput(const String &data, uint8_t *fbBytes, bool final) override
bool readLine(String &buffer)
read a line from buffer, in to the buffer passed in
Definition: dumbdisplay.h:1358
bool timedOut()
check whether EOF caused by timeout or not; note that timeout is only due to check of EOF with DDBuff...
Definition: dumbdisplay.h:1354
bool read(String &fieldId, String &fieldValue)
read a piece of JSON data
void writeLine(const String &data)
write a line
Definition: dumbdisplay.h:1360
bool eof(long timeoutMillis=DD_DEF_TUNNEL_TIMEOUT)
Definition: dumbdisplay.h:1352
String readLine()
read a line from buffer
DDBufferedTunnel(const String &type, int8_t tunnelId, const String &params, const String &endPoint, int8_t bufferSize)
for internal use only
int count()
count buffer ready read
Definition: dumbdisplay.h:1348
Base class for debug callback set by calling DumbDisplay::debugSetup()
Definition: dumbdisplay.h:1581
virtual void logConnectionState(DDDebugConnectionState connectionState)
See DDDebugConnectionState.
Definition: dumbdisplay.h:1584
virtual void logSendCommand(int state)
Definition: dumbdisplay.h:1586
Class for DD input/output; you explicitly constructed it, pass in when instantiate DumbDisplay,...
Definition: _dd_io.h:9
Base class for the different layers support by DumbDisplay; created with various layer creation metho...
Definition: dumbdisplay.h:162
void animateBackgroundImage(float fps, bool reset=true, const String &options="")
void visible(bool visible)
void noBackgroundImage()
set no layer background image
void backgroundImage(const String &backgroundImageName, const String &drawBackgroundOptions, int refImageWidth=0)
void noBorder()
void enableFeedback(const String &autoFeedbackMethod="", const String &allowFeedbackTypes="")
void explicitFeedback(int16_t x=0, int16_t y=0, const String &text="", DDFeedbackType type=DDFeedbackType::CLICK, const String &option="")
void exportAsBackgroundImage(bool replace=true, bool noDrawBackground=true, int exportAsWidth=0)
void padding(float left, float top, float right, float bottom)
void blend(const String &color, int alpha=255, const String &mode="darken")
void setFeedbackHandler(DDFeedbackHandler handler, const String &autoFeedbackMethod="", const String &allowFeedbackTypes="")
void noblend()
void clear()
clear the layer
void disabled(bool disabled=true)
void stopAnimateBackgroundImage(bool reset=true)
DDFeedbackHandler getFeedbackHandler() const
Definition: dumbdisplay.h:301
void transparent(bool transparent)
DDFeedbackManager * getFeedbackManager() const
Definition: dumbdisplay.h:299
void noMargin()
void opacity(int opacity)
void noPadding()
void backgroundColor(const String &color, int opacity=100)
const DDFeedback * getFeedback()
void alpha(int alpha)
void border(float size, const String &color, const String &shape="flat", float extraSize=0)
void flash()
normally used for "feedback" – flash the default way (layer + border)
void margin(float left, float top, float right, float bottom)
void debugOnly(int i)
for debug use
void margin(float size)
void noBackgroundColor()
void disableFeedback()
disable "feedback"
void flashArea(int x, int y)
normally used for "feedback" – flash the area (x, y) where the layer is clicked
void padding(float size)
Helper class for constructing "tunnel" endpoint, if the endpoint is not a simple URL....
Definition: dumbdisplay.h:1174
void resetParams()
reset params (to the endpoint query string)
Definition: dumbdisplay.h:1199
void resetSoundAttachment(const String &soundName)
Definition: dumbdisplay.h:1187
void addParam(const String &param)
add param (to the endpoint query string)
Definition: dumbdisplay.h:1203
void resetHeaders()
reset headers
Definition: dumbdisplay.h:1195
void addHeader(const String &headerKey, const String &headerValue)
add header to the request
Definition: dumbdisplay.h:1222
void resetEndpoint(const String &endPoint)
reset the endpoint
Definition: dumbdisplay.h:1182
void addNamedParam(const String &paramName, const String &paramValue)
add named param (to the endpoint query string)
Definition: dumbdisplay.h:1218
Base class for DD "tunnel".
Definition: dumbdisplay.h:1247
void reconnectToEndpoint(const DDTunnelEndpoint endpoint)
reconnect to specified endpoint. See DDTunnelEndpoint.
Definition: dumbdisplay.h:1277
DDTunnel(const String &type, int8_t tunnelId, const String &params, const String &endPoint)
for internal use only
void reconnectTo(const String &endPoint)
Definition: dumbdisplay.h:1265
The core class for DumbDisplay; everything starts here. The most important argument to DumbDisplay is...
Definition: dumbdisplay.h:1612
LcdDDLayerHandle createLcdLayerHandle(int colCount=16, int rowCount=2, int charHeight=0, const String &fontName="")
int cacheSoundChunked8(const String &soundName, int sampleRate, int numChannels=1)
int getConnectVersion() const
void deleteAllRemainingAutoPinConfigs()
delete all added REST "auto pin" configs
void debugSetup(DDDebugInterface *debugInterface)
BasicDDTunnel * createGeneralServiceTunnel()
ObjectDetectDemoServiceDDTunnel * createObjectDetectDemoServiceTunnel(int scaleToWidth=0, int scaleToHeight=0, int maxNumObjs=1)
void backgroundColor(const String &color)
PlotterDDLayer * createFixedRatePlotterLayer(int width, int height, int pixelsPerScale=5)
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 connect()
void saveCachedSoundAsH(const String &soundName)
save the cached sound as C header file (.h)
void unfreezeDrawing(bool refreezeAfterward=false)
void stitchImages(const String &imageNames, const String &asImageName)
bool canPrintToSerial()
check if it is safe to print to Serial
BasicDDTunnel * createDateTimeServiceTunnel()
GraphicalDDLayer * createGraphicalLayer(int width, int height)
LedGridDDLayerHandle createLedGridLayerHandle(int colCount=1, int rowCount=1, int subColCount=1, int subRowCount=1)
TurtleDDLayer * createTurtleLayer(int width, int height)
create a Turtle-like layer
bool connectPassive(DDConnectPassiveStatus *pStatus=NULL)
void recordLayerCommands()
void saveCachedSound(const String &soundName)
save the cached sound
void setConnectVersionChangedCallback(DDConnectVersionChangedCallback connectVersionChangedCallback)
void setIdleCallback(DDIdleCallback idleCallback)
GraphicalDDLayerHandle createGraphicalLayerHandle(int width, int height)
void configPinFrame(int xUnitCount=100, int yUnitCount=100, bool autoControlLayerVisible=false)
int cacheSoundChunked16(const String &soundName, int sampleRate, int numChannels=1)
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
LcdDDLayer * createLcdLayer(int colCount=16, int rowCount=2, int charHeight=0, const String &fontName="")
create a LCD layer
TerminalDDLayer * createTerminalLayer(int width, int height)
int saveSoundChunked16(const String &soundName, int sampleRate, int numChannels=1)
GraphicalDDLayer * setRootLayer(int width, int height, const String &containedAlignment="")
int streamSound8(int sampleRate, int numChannels=1)
stream sound 8-bit sample (for playing sound)
void sendNoOp()
send "no-op" command
int streamSound16(int sampleRate, int numChannels=1)
stream sound 16-bit sample (for playing sound)
void deleteTunnel(DDTunnel *pTunnel)
if finished using a "tunnel", delete it to release resource
void pinLayer(DDLayer *pLayer, int uLeft, int uTop, int uWidth, int uHeight, const String &align="")
WebViewDDLayer * createWebViewLayer(int width, int height, const String &jsObjectName="DD")
MbDDLayer * createMicrobitLayer(int width=5, int height=5)
create a Microbit-like layer
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
int saveSoundChunked8(const String &soundName, int sampleRate, int numChannels=1)
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 masterReset()
JsonDDTunnel * createJsonTunnel(const String &endPoint, bool connectNow=true, int8_t bufferSize=DD_TUNNEL_DEF_BUFFER_SIZE)
void configAutoPin(const String &layoutSpec=DD_AP_VERT, bool autoControlLayerVisible=false)
RtspClientDDLayer * createRtspClient(int width, int height)
void recordLayerSetupCommands()
basically, functions the same as recordLayerCommands()
void alert(const String &message, const String &title="")
pop up a dialog to alert
SevenSegmentRowDDLayer * create7SegmentRowLayer(int digitCount=1)
JoystickDDLayer * createJoystickLayer(int maxStickValue=1023, const String &directions="", float stickSizeFactor=1.0)
void loadLayerCommands(const String &id)
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 playSound(const String &soundName)
make DD app play the sound of the given sound file
void deleteLayer(DDLayer *pLayer)
if layer is no longer used; delete it to release resources
void reorderLayer(DDLayer *pLayer, const String &how)
DumbDisplayWindowDDLayer * createDumbDisplayWindowLayer(int width, int height)
void playbackLayerSetupCommands(const String &layerSetupPersistId)
void setFeedbackSingleClickOnly(bool singleClickOnly=true)
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 saveLayerCommands(const String &id, bool persist=false, bool stopAfterSave=false)
void resetPinLayers()
rest pinning of layers, as if they are not pinned
JsonDDTunnel * createFilteredJsonTunnel(const String &endPoint, const String &fieldNames, bool connectNow=true, int8_t bufferSize=DD_TUNNEL_DEF_BUFFER_SIZE)
int getCompatibilityVersion() const
void writeComment(const String &comment)
write out a comment to DD app
void playbackLayerCommands()
playback recorded commands (unfreeze the display)
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 saveImage(const String &imageName, const uint8_t *bytes, int byteCount)
svae image with the given image data
BasicDDTunnel * createBasicTunnel(const String &endPoint, bool connectNow=true, int8_t bufferSize=DD_TUNNEL_DEF_BUFFER_SIZE)
void capture(const String &imageFileName, int width, int height)
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::write...
void deleteLayer(DDLayerHandle layerHandle)
if layer is no longer used; delete it to release resources
void stopRecordLayerCommands(const String &saveId="", bool persistSave=false)
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
void walkLayers(void(*walker)(DDLayer *))
loop through all the existing layers calling the function passed in
TomTomMapDDLayer * createTomTomMapLayer(const String &mapKey, int width, int height)
LedGridDDLayer * createLedGridLayer(int colCount=1, int rowCount=1, int subColCount=1, int subRowCount=1)
create a LED-grid layer
void freezeDrawing()
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
bool connected() const
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 cacheSoundChunked...
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 cacheSoundChunk...
void pinAutoPinLayers(const String &layoutSpec, int uLeft, int uTop, int uWidth, int uHeight, const String &align="")
ImageDownloadDDTunnel * createImageDownloadTunnel(const String &endPoint, const String &imageName, bool redownload=true)
void addRemainingAutoPinConfig(const String &restLayoutSpec)
add the "auto pin" config (REST "auto pin" config) for layers not included in "auto pin" set by confi...
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
PlotterDDLayer * createPlotterLayer(int width, int height, int pixelsPerSecond=10)
create a plotter layer
void tone(uint32_t freq, uint32_t duration)
make DD app sound a tone
GpsServiceDDTunnel * createGpsServiceTunnel()
Definition: dumbdisplay.h:1149
DumbDisplayWindowDDLayer(int8_t layerId)
for internal use only
Definition: dumbdisplay.h:1152
Class for GPS service "tunnel".
Definition: dumbdisplay.h:1436
GpsServiceDDTunnel(const String &type, int8_t tunnelId, const String &params, const String &endPoint, int8_t bufferSize)
Definition: dumbdisplay.h:1439
void reconnectForLocation(int repeat=-1)
Class for graphical LCD layer; created with DumbDisplay::createGraphicalLayer()
Definition: dumbdisplay.h:763
void drawImageFileFit(const String &imageFileName, const String &options)
another version of drawImageFileFit() with options
Definition: dumbdisplay.h:960
void setTextSize(int size)
set text size
void drawCircle(int x, int y, int r, const String &color="", bool filled=false)
void println(const String &text="")
print text with line feed
void cachePixelImage16(const String &imageName, const uint16_t *data, int width, int height, const String &options="", char compressMethod=0)
void print(const String &text)
print text
void noFillColor()
set no fill color (for shape)
void loadImageFile(const String &imageFileName, int w=0, int h=0, const String &asImageFileName="")
void setTextWrap(bool wrapOn)
set whether "print" will auto wrap or not
void saveCachedImageFiles(const String &stitchAsImageName="")
void cacheImageWithTS(const String &imageName, const uint8_t *bytes, int byteCount, long imageTimestamp, char compressionMethod=0)
void penSize(int size)
set pen size
void write(const String &text, bool draw)
Definition: dumbdisplay.h:918
void setHeading(int angle)
set heading angle (degree)
void circle(int radius, bool centered=false)
draw a circle; centered or not
void setTextFont()
reset text font and size
void setTextFont(const String &fontName, int textSize)
Definition: dumbdisplay.h:792
void backward(int distance, bool withPen=true)
move backward (relative to cursor)
void isoscelesTriangle(int side, int angle)
draw isosceles triangle; given size and angle
void drawRect(int x, int y, int w, int h, const String &color="", bool filled=false)
void setTextColor(const String &color, const String &bgColor="")
void drawRoundRect(int x, int y, int w, int h, int r, const String &color="", bool filled=false)
void fillCircle(int x, int y, int r, const String &color="")
Definition: dumbdisplay.h:831
void drawOval(int x, int y, int w, int h, const String &color="", bool filled=false)
void arc(int width, int height, int startAngle, int sweepAngle, bool centered=false)
draw arc; centered or not
void fillRect(int x, int y, int w, int h, const String &color="")
Definition: dumbdisplay.h:847
void cachePixelImageGS(const String &imageName, const uint8_t *data, int width, int height, const String &options="", char compressMethod=0)
void rightTurn(int angle)
turn right
void setCursor(int x, int y)
set cursor to position
void saveCachedImageFile(const String &imageName, const String &asImageName="")
void fillScreen(const String &color)
void drawStr(int x, int y, const String &string, const String &color="", const String &bgColor="", int size=0)
void drawImageFile(const String &imageFileName, const String &options)
another version of drawImageFile() with options
Definition: dumbdisplay.h:947
void forward(int distance, bool withPen=true)
move forward (relative to cursor)
GraphicalDDLayer(int8_t layerId)
for internal use only
Definition: dumbdisplay.h:771
void unloadImageFile(const String &imageFileName)
unload image file from cache
void unloadAllImageFiles()
unload all image files from cache
void fillArc(int x, int y, int w, int h, int startAngle, int sweepAngle, bool useCenter, const String &color="")
Definition: dumbdisplay.h:871
void cachePixelImage(const String &imageName, const uint8_t *bytes, int width, int height, const String &color="", char compressionMethod=0)
void drawChar(int x, int y, char c, const String &color="", const String &bgColor="", int size=0)
void penColor(const String &color)
void saveCachedImageFileAsync(const String &imageName, const String &asImageName="")
void polygon(int side, int vertexCount)
draw polygon given side and vertex count
void centeredPolygon(int radius, int vertexCount, bool inside=false)
GraphicalDDLayer(GraphicalDDLayerHandle layerHandle)
Definition: dumbdisplay.h:767
void drawPixel(int x, int y, const String &color="")
void fillColor(const String &color)
void drawTextLine(const String &text, int y, const String &align="L", const String &color="", const String &bgColor="", int size=0)
void drawImageFileFit(const String &imageFileName, int x=0, int y=0, int w=0, int h=0, const String &options="")
void drawImageFileScaled(const String &imageFileName, int w, int h, const String &options="")
Definition: dumbdisplay.h:952
void drawTriangle(int x1, int y1, int x2, int y2, int x3, int y3, const String &color="", bool filled=false)
void setTextFont(const String &fontName)
void drawText(const String &text)
draw text (honor heading)
void drawLine(int x1, int y1, int x2, int y2, const String &color="")
void leftTurn(int angle)
turn left
void triangle(int side1, int angle, int side2)
draw triangle (SAS)
void fillTriangle(int x1, int y1, int x2, int y2, int x3, int y3, const String &color="")
Definition: dumbdisplay.h:839
void drawImageFile(const String &imageFileName, int x=0, int y=0, int w=0, int h=0, const String &options="")
void write(const String &text)
write text (will not auto wrap)
void cacheImage(const String &imageName, const uint8_t *bytes, int byteCount, char compressionMethod=0)
void moveCursorBy(int byX, int byY)
move cursor by some amount
void drawArc(int x, int y, int w, int h, int startAngle, int sweepAngle, bool useCenter, const String &color="", bool filled=false)
void fillRoundRect(int x, int y, int w, int h, int r, const String &color="")
Definition: dumbdisplay.h:855
void oval(int width, int height, bool centered=false)
draw an oval; centered or not
void setRotation(int8_t rotationType)
rotate the screen
void loadImageFileScaled(const String &imageFileName, int w, int h, const String &asImageFileName)
Definition: dumbdisplay.h:934
void rectangle(int width, int height, bool centered=false)
draw rectangle; centered or not
void fillOval(int x, int y, int w, int h, const String &color="")
Definition: dumbdisplay.h:863
Image download tool "tunnel" created with DumbDisplay::createImageDownloadTunnel()
Definition: dumbdisplay.h:1419
ImageDownloadDDTunnel(int8_t tunnelId, const String &params, const String &endPoint, int bufferSize)
Definition: dumbdisplay.h:1422
void reconnectTo(const String &endPoint, const String &cropUIConfig="")
Definition: dumbdisplay.h:1505
ImageRetrieverDDTunnel(const String &type, int8_t tunnelId, const String &params, const String &endPoint, int8_t bufferSize)
Definition: dumbdisplay.h:1508
bool readPixelImage16(DDPixelImage16 &pixelImage16)
get 16-bit image data retrieved with reconnectForPixelImage16
bool readJpegImage(DDJpegImage &jpeg)
get JPEG image data retrieved with reconnectForJpegImage
bool readPixelImage(DDPixelImage &pixelImage)
get single-bit image data retrieved with reconnectForPixelImage
bool readPixelImageGS16(DDPixelImage16 &pixelImage16)
get grayscale 16-bit image data retrieved with reconnectForPixelImageGS
void reconnectForJpegImage(const String &imageName, int width, int height, int quality=100, bool fit=false)
void reconnectForPixelImage16(const String &imageName, int width, int height, bool fit=false, bool grayscale=false)
void reconnectForPixelImage(const String &imageName, int width, int height, bool fit=false)
Class for virtual joystick layer; created with DumbDisplay::createJoystickLayer()
Definition: dumbdisplay.h:1040
void moveToPos(int16_t x, int16_t y, bool sendFeedback=false)
void colors(const String &stickColor, const String &stickOutlineColor, const String &socketColor="", const String &socketOutlineColor="")
set the colors of the stick UI
void valueRange(int16_t minValue, int16_t maxValue, int valueStep=1, bool sendFeedback=false)
void snappy(bool snappy=true)
set 'snappy' makes stick snaps to closest value when moved
JoystickDDLayer(int8_t layerId)
for internal use only
Definition: dumbdisplay.h:1043
void autoRecenter(bool autoRecenter=true)
void moveToCenter(bool sendFeedback=false)
void showValue(bool show=true, const String &color="")
show value on top of the stick
Definition: dumbdisplay.h:1539
JsonDDTunnelMultiplexer(JsonDDTunnel **tunnels, int8_t tunnelCount)
int read(String &fieldId, String &fieldValue)
Class for LCD layer; created with DumbDisplay::createLcdLayer()
Definition: dumbdisplay.h:606
void cursor()
show cursor
void noBgPixelColor()
set no "background" (off) pixel color
LcdDDLayer(LcdDDLayerHandle layerHandle)
Definition: dumbdisplay.h:610
void bgPixelColor(const String &color, bool sameForBackgroundColor=false, int backgroundOpacity=100)
void setCursor(int x, int y)
void print(const String &text)
print text, moving cursor
void pixelColor(const String &color)
void autoscroll()
enable auto-scroll
void writeCenteredLine(const String &text, int y=0)
write text as a line, with align "centered"
void writeRightAlignedLine(const String &text, int y=0)
write text as a right-aligned line
void noAutoscroll()
disable auto-scroll
LcdDDLayer(int8_t layerId)
for internal use only
Definition: dumbdisplay.h:614
void home()
move cursor to home
void noCursor()
hide cursor
void writeLine(const String &text, int y=0, const String &align="L")
Class for LED grid layer; created with DumbDisplay::createLedGridLayer()
Definition: dumbdisplay.h:539
LedGridDDLayer(int8_t layerId)
for internal use only
Definition: dumbdisplay.h:547
void onColor(const String &color)
void turnOff(int x=0, int y=0)
turn off LED @ (x, y)
void toggle(int x=0, int y=0)
toggle LED @ (x, y)
void bitwise3(unsigned int bits_0, unsigned int bits_1, unsigned int bits_2, int y=0, bool reverse=false)
void verticalBarEx(int count, int startY=0, const String &color="")
void verticalBar(int count, bool bottomToTop=true)
void bitwise(unsigned int bits, int y=0, bool reverse=false)
void bitwise4(unsigned int bits_0, unsigned int bits_1, unsigned int bits_2, unsigned int bits_3, int y=0, bool reverse=false)
void horizontalBar(int count, bool rightToLeft=false)
void offColor(const String &color)
LedGridDDLayer(LedGridDDLayerHandle layerHandle)
Definition: dumbdisplay.h:543
void turnOn(int x=0, int y=0)
turn on LED @ (x, y)
void noOffColor()
set no LED off color
void turnOnEx(int x=0, int y=0, const String &onColor="")
void horizontalBarEx(int count, int startX=0, const String &color="")
void bitwise2(unsigned int bits_0, unsigned int bits_1, int y=0, bool reverse=false)
Class for Microbit-like DD layer; created with DumbDisplay::createMicrobitLayer()
Definition: dumbdisplay.h:421
void plot(int x, int y)
turn on LED @ (x, y)
void showString(const String &str)
show string; scroll if more than a single character; but you get to control timing by using delay()
void unplot(int x, int y)
turn off LED @ (x, y)
void showLeds(const String &ledPattern)
MbDDLayer(int8_t layerId)
for internal use only
Definition: dumbdisplay.h:424
void showIcon(MbIcon icon)
show Microbit icon
void showNumber(int num)
show number; scroll if more than a single digit; but you get to control timing by using delay()
void ledColor(const String &color)
void toggle(int x, int y)
toggle LED @ (x, y) on / off
void showArrow(MbArrow arrow)
show Microbit arrow
Definition: dumbdisplay.h:410
Definition: dumbdisplay.h:324
void pushLevelAndSwitchTo(const String &switchTolevelId, bool addIfMissing=true)
void moveLevelAnchorBy(float byX, float byY, long reachInMillis=0)
move the level anchor
void switchLevel(const String &levelId, bool addIfMissing=true)
void setLevelNoBackground()
set that the current level uses no background image
void popLevel()
pop a level from the level stack and make it the current level
void reorderLevel(const String &levelId, const String &how)
void stopAnimateLevelBackground(bool reset=true)
void setLevelAnchor(float x, float y, long reachInMillis=0)
set the anchor of the level; note that level anchor is the top-left corner of the level "opening"
void addTopLevel(const String &levelId, float width=0, float height=0, bool switchToIt=false)
like addLevel() but add to the top (i.e. will be drawn last)
void exportLevelAsRegisteredBackground(const String &backgroundId, bool replace=true)
void levelOpacity(int opacity)
void registerLevelBackground(const String &backgroundId, const String &backgroundImageName, const String &drawBackgroundOptions="")
void addTopLevel(const String &levelId, bool switchToIt)
another version of addTopLevel()
Definition: dumbdisplay.h:338
void deleteLevel(const String &levelId)
delete the specified level
void addLevel(const String &levelId, bool switchToIt=false)
another version of addLevel()
Definition: dumbdisplay.h:332
void pushLevel()
push the current level onto the level stack, to be pop with popLevel()
void levelTransparent(bool transparent)
set whether level is transparent
void animateLevelBackground(float fps, bool reset=true, const String &options="")
void setLevelBackground(const String &backgroundId, const String &backgroundImageName="", const String &drawBackgroundOptions="")
void exportLevelsAsImage(const String &imageFileName, bool cacheItNotSave=false)
export (and save) the levels as an image (without the decorations of the layer like border)
void addLevel(const String &levelId, float width, float height, bool switchToIt=false)
Class for "object detection demo" service "tunnel".
Definition: dumbdisplay.h:1458
ObjectDetectDemoServiceDDTunnel(const String &type, int8_t tunnelId, const String &params, const String &endPoint, int8_t bufferSize)
Definition: dumbdisplay.h:1461
Class for plotter layer; created with DumbDisplay::createPlotterLayer() or DumbDisplay::createFixedRa...
Definition: dumbdisplay.h:1071
void label(const String &key, const String &lab)
void set(float value)
set value with empty key
Definition: dumbdisplay.h:1084
void set(const String &key, float value)
PlotterDDLayer(int8_t layerId)
for internal use only
Definition: dumbdisplay.h:1074
Definition: dumbdisplay.h:1160
RtspClientDDLayer(int8_t layerId)
for internal use only
Definition: dumbdisplay.h:1163
void start(const String &url)
Definition: dumbdisplay.h:654
void pixelColor(const String &color)
void highlightBorder(bool forSelected, const String &borderColor="", const String &borderShape="")
void pixelColor(const String &color, bool selected)
void deselectAll()
deselect all "selection" units
SelectionBaseDDLayer(int8_t layerId)
for internal use only
Definition: dumbdisplay.h:657
void selectAll()
select all "selection" units
Class for "selection" layer of multiple LCD-like "selection" units; created with DumbDisplay::createS...
Definition: dumbdisplay.h:685
void unselectedTextRightAligned(const String &text, int y=0, int horiSelectionIdx=0, int vertSelectionIdx=0)
set a "selection" unit right-aligned text (of y-th row) when unselected (it defaults to the same text...
void textCentered(const String &text, int y=0, int horiSelectionIdx=0, int vertSelectionIdx=0)
set a "selection" unit centered text (of y-th row)
void selected(bool selected, int horiSelectionIdx=0, int vertSelectionIdx=0, bool reverseTheOthers=false)
set a "selection" unit selected or not (combination of select() and deselect())
void setSelected(bool selected, int horiSelectionIdx=0, int vertSelectionIdx=0)
Definition: dumbdisplay.h:708
void unselectedTextCentered(const String &text, int y=0, int horiSelectionIdx=0, int vertSelectionIdx=0)
set a "selection" unit centered text (of y-th row) when unselected (it defaults to the same text as s...
void text(const String &text, int y=0, int horiSelectionIdx=0, int vertSelectionIdx=0, const String &align="L")
void select(int horiSelectionIdx=0, int vertSelectionIdx=0, bool deselectTheOthers=true)
select a "selection" unit
SelectionDDLayer(int8_t layerId)
for internal use only
Definition: dumbdisplay.h:688
void textRightAligned(const String &text, int y=0, int horiSelectionIdx=0, int vertSelectionIdx=0)
set a "selection" unit right-aligned text (of y-th row)
void unselectedText(const String &text, int y=0, int horiSelectionIdx=0, int vertSelectionIdx=0, const String &align="L")
void deselect(int horiSelectionIdx=0, int vertSelectionIdx=0, bool selectTheOthers=false)
deselect a "selection" unit
Class for "selection list" layer, like SelectionDDLayer but "selections" can be added and removed dyn...
Definition: dumbdisplay.h:724
void add(int selectionIdx)
void select(int selectionIdx, bool deselectTheOthers=true)
select a "selection" unit
void textCentered(int selectionIdx, const String &text, int y=0)
set a "selection" unit centered text (of y-th row)
void deselect(int selectionIdx, bool selectTheOthers=false)
deselect a "selection" unit
void unselectedTextCentered(int selectionIdx, const String &text, int y=0)
set a "selection" unit centered text (of y-th row) when unselected (it defaults to the same text as s...
void unselectedTextRightAligned(int selectionIdx, const String &text, int y=0)
set a "selection" unit right-aligned text (of y-th row) when unselected (it defaults to the same text...
void unselectedText(int selectionIdx, const String &text, int y=0, const String &align="L")
void text(int selectionIdx, const String &text, int y=0, const String &align="L")
SelectionListDDLayer(int8_t layerId)
for internal use only
Definition: dumbdisplay.h:727
void offset(int offset)
set the offset to the "selection" unit start showing
void selected(int selectionIdx, bool selected, bool reverseTheOthers=false)
set a "selection" unit selected or not (combination of select() and deselect())
void remove(int selectionIdx)
void textRightAligned(int selectionIdx, const String &text, int y=0)
set a "selection" unit right-aligned text (of y-th row)
Class for 7-segment row layer; created with DumbDisplay::create7SegmentRowLayer()
Definition: dumbdisplay.h:1001
void turnOn(const String &segments, int digitIdx=0)
void showFormatted(const String &formatted, bool completeReplace=true, int startIdx=0)
void resetSegmentOffColor(const String &color)
SevenSegmentRowDDLayer(int8_t layerId)
for internal use only
Definition: dumbdisplay.h:1004
void setOn(const String &segments="", int digitIdx=0)
void showHexNumber(int16_t number)
show HEX number
void showNumber(float number, const String &padding=" ")
show number (can be float)
void segmentColor(const String &color)
void showDigit(int digit, int digitIdx=0)
show a digit
void resetSegmentOffNoColor()
reset segment off color to no color; note that this will clear all digits
void turnOff(const String &segments, int digitIdx=0)
Class for basic tool "tunnel".
Definition: dumbdisplay.h:1401
SimpleToolDDTunnel(const String &type, int8_t tunnelId, const String &params, const String &endPoint, int bufferSize)
Definition: dumbdisplay.h:1404
Class for a terminal-like "device dependent view" layer, for logging etc; created with DumbDisplay::c...
Definition: dumbdisplay.h:1105
TerminalDDLayer(int8_t layerId)
for internal use only
Definition: dumbdisplay.h:1108
Definition: dumbdisplay.h:1093
TomTomMapDDLayer(int8_t layerId)
for internal use only
Definition: dumbdisplay.h:1096
Class for Turtle-like DD layer; created with DumbDisplay::createTurtleLayer()
Definition: dumbdisplay.h:456
void penColor(const String &color)
void arc(int width, int height, int startAngle, int sweepAngle, bool centered=false)
draw arc; centered or not
void isoscelesTriangle(int side, int angle)
draw isosceles triangle; given size and angle
void goBy(int byX, int byY, bool withPen=true)
go by (byX, byY); with pen or not
void polygon(int side, int vertexCount)
draw polygon given side and vertex count
void goTo(int x, int y, bool withPen=true)
go to (x, y); with pen or not
void forward(int distance, bool withPen=true)
forward; with pen or not
void centeredPolygon(int radius, int vertexCount, bool inside=false)
void triangle(int side1, int angle, int side2)
draw triangle (SAS)
void oval(int width, int height, bool centered=false)
draw oval; centered or not
void circle(int radius, bool centered=false)
draw circle; centered or not
void write(const String &text, bool draw)
Definition: dumbdisplay.h:526
void dot(int size, const String &color)
draw a dot
void setTextFont(const String &fontName="", int textSize=0)
void penFilled(bool filled=true)
set pen filled or not; if filled, shape drawn will be filled
void penUp()
pen up
void write(const String &text)
write text
TurtleDDLayer(int8_t layerId)
for internal use only
Definition: dumbdisplay.h:459
void home(bool withPen=true)
go home (0, 0); with pen or not
void leftTurn(int angle)
left turn
void setTextSize(int size)
set text size
void penDown()
pen down
void drawText(const String &text)
draw text (honor heading)
void noFillColor()
set no fill color
void rightTurn(int angle)
right turn
void penSize(int size)
set pen size
void backward(int distance, bool withPen=true)
backward; with pen or not
void setHeading(int angle)
set heading angle (degree)
void fillColor(const String &color)
void rectangle(int width, int height, bool centered=false)
draw rectangle; centered or not
Definition: dumbdisplay.h:1135
WebViewDDLayer(int8_t layerId)
for internal use only
Definition: dumbdisplay.h:1138
Struct for the status values of calling DumbDisplay::connectPassive()
Definition: dumbdisplay.h:1594
bool reconnecting
reconnecting: when connected; detected reconnecting (after lost of connection)
Definition: dumbdisplay.h:1600
bool connecting
connecting: when not connected; starting to establish connection by sending hand-shake messages
Definition: dumbdisplay.h:1598
bool connected
connection made or not – same as the return value of DumbDisplay::connectPassive()
Definition: dumbdisplay.h:1596
Type signature for callback function that will be called when connect version (counting up) changed....
See DDDebugInterface.
Type signature for "feedback" handler. See DDLayer::setFeedbackHandler()
The struct that captures info about "feedback". See DDLayer::enableFeedback()
Definition: _dd_feedback.h:29
The enum indicating the type of "feedback". See DDFeedback.
Type signature for callback function that will be called when idle. See DumbDisplay::setIdleCallback(...
See DDIdleCallback.
Definition: dumbdisplay.h:1470
Definition: dumbdisplay.h:1496
experimental: _h is for internal use only
Definition: dumbdisplay.h:156
Output struct of GpsServiceDDTunnel.
Definition: dumbdisplay.h:1431
Output struct of ObjectDetectDemoServiceDDTunnel.
Definition: dumbdisplay.h:1450
Base class for DD objects.
Definition: dumbdisplay.h:140
int8_t objectType
object type – DD_OBJECT_TYPE_LAYER or DD_OBJECT_TYPE_TUNNEL
Definition: dumbdisplay.h:142
String customData
custom data
Definition: dumbdisplay.h:147
Definition: dumbdisplay.h:1485
Definition: dumbdisplay.h:1482
Definition: dumbdisplay.h:759
Definition: dumbdisplay.h:599
Definition: dumbdisplay.h:535