-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathyocto_display.h
More file actions
1362 lines (1236 loc) · 53.1 KB
/
yocto_display.h
File metadata and controls
1362 lines (1236 loc) · 53.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*********************************************************************
*
* $Id: yocto_display.h 72057 2026-02-17 09:44:53Z mvuilleu $
*
* Declares yFindDisplay(), the high-level API for Display functions
*
* - - - - - - - - - License information: - - - - - - - - -
*
* Copyright (C) 2011 and beyond by Yoctopuce Sarl, Switzerland.
*
* Yoctopuce Sarl (hereafter Licensor) grants to you a perpetual
* non-exclusive license to use, modify, copy and integrate this
* file into your software for the sole purpose of interfacing
* with Yoctopuce products.
*
* You may reproduce and distribute copies of this file in
* source or object form, as long as the sole purpose of this
* code is to interface with Yoctopuce products. You must retain
* this notice in the distributed source file.
*
* You should refer to Yoctopuce General Terms and Conditions
* for additional information regarding your rights and
* obligations.
*
* THE SOFTWARE AND DOCUMENTATION ARE PROVIDED "AS IS" WITHOUT
* WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING
* WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO
* EVENT SHALL LICENSOR BE LIABLE FOR ANY INCIDENTAL, SPECIAL,
* INDIRECT OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA,
* COST OF PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY OR
* SERVICES, ANY CLAIMS BY THIRD PARTIES (INCLUDING BUT NOT
* LIMITED TO ANY DEFENSE THEREOF), ANY CLAIMS FOR INDEMNITY OR
* CONTRIBUTION, OR OTHER SIMILAR COSTS, WHETHER ASSERTED ON THE
* BASIS OF CONTRACT, TORT (INCLUDING NEGLIGENCE), BREACH OF
* WARRANTY, OR OTHERWISE.
*
*********************************************************************/
#ifndef YOCTO_DISPLAY_H
#define YOCTO_DISPLAY_H
#include <cfloat>
#include <cmath>
#include "yocto_api.h"
#ifdef YOCTOLIB_NAMESPACE
namespace YOCTOLIB_NAMESPACE
{
#endif
//--- (generated code: YDisplay definitions)
class YDisplay; // forward declaration
typedef void (*YDisplayValueCallback)(YDisplay *func, const string& functionValue);
#ifndef _Y_ENABLED_ENUM
#define _Y_ENABLED_ENUM
typedef enum {
Y_ENABLED_FALSE = 0,
Y_ENABLED_TRUE = 1,
Y_ENABLED_INVALID = -1,
} Y_ENABLED_enum;
#endif
#ifndef _Y_ORIENTATION_ENUM
#define _Y_ORIENTATION_ENUM
typedef enum {
Y_ORIENTATION_LEFT = 0,
Y_ORIENTATION_UP = 1,
Y_ORIENTATION_RIGHT = 2,
Y_ORIENTATION_DOWN = 3,
Y_ORIENTATION_INVALID = -1,
} Y_ORIENTATION_enum;
#endif
#ifndef _Y_DISPLAYTYPE_ENUM
#define _Y_DISPLAYTYPE_ENUM
typedef enum {
Y_DISPLAYTYPE_MONO = 0,
Y_DISPLAYTYPE_EPAPER_BW = 1,
Y_DISPLAYTYPE_EPAPER_BWR = 2,
Y_DISPLAYTYPE_EPAPER_BWRY = 3,
Y_DISPLAYTYPE_INVALID = -1,
} Y_DISPLAYTYPE_enum;
#endif
#define Y_STARTUPSEQ_INVALID (YAPI_INVALID_STRING)
#define Y_BRIGHTNESS_INVALID (YAPI_INVALID_UINT)
#define Y_AUTOINVERTDELAY_INVALID (YAPI_INVALID_UINT)
#define Y_DISPLAYPANEL_INVALID (YAPI_INVALID_STRING)
#define Y_DISPLAYWIDTH_INVALID (YAPI_INVALID_UINT)
#define Y_DISPLAYHEIGHT_INVALID (YAPI_INVALID_UINT)
#define Y_LAYERWIDTH_INVALID (YAPI_INVALID_UINT)
#define Y_LAYERHEIGHT_INVALID (YAPI_INVALID_UINT)
#define Y_LAYERCOUNT_INVALID (YAPI_INVALID_UINT)
#define Y_COMMAND_INVALID (YAPI_INVALID_STRING)
//--- (end of generated code: YDisplay definitions)
//--- (generated code: YDisplayLayer definitions)
#ifndef _Y_ALIGN
#define _Y_ALIGN
typedef enum {
Y_ALIGN_TOP_LEFT = 0 ,
Y_ALIGN_CENTER_LEFT = 1 ,
Y_ALIGN_BASELINE_LEFT = 2 ,
Y_ALIGN_BOTTOM_LEFT = 3 ,
Y_ALIGN_TOP_CENTER = 4 ,
Y_ALIGN_CENTER = 5 ,
Y_ALIGN_BASELINE_CENTER = 6 ,
Y_ALIGN_BOTTOM_CENTER = 7 ,
Y_ALIGN_TOP_DECIMAL = 8 ,
Y_ALIGN_CENTER_DECIMAL = 9 ,
Y_ALIGN_BASELINE_DECIMAL = 10 ,
Y_ALIGN_BOTTOM_DECIMAL = 11 ,
Y_ALIGN_TOP_RIGHT = 12 ,
Y_ALIGN_CENTER_RIGHT = 13 ,
Y_ALIGN_BASELINE_RIGHT = 14 ,
Y_ALIGN_BOTTOM_RIGHT = 15
} Y_ALIGN;
#endif
//--- (end of generated code: YDisplayLayer definitions)
class YDisplay;
//--- (generated code: YDisplayLayer declaration)
/**
* YDisplayLayer Class: Interface for drawing into display layers, obtained by calling display.get_displayLayer.
*
* Each DisplayLayer represents an image layer containing objects
* to display (bitmaps, text, etc.). The content is displayed only when
* the layer is active on the screen (and not masked by other
* overlapping layers).
*/
class YOCTO_CLASS_EXPORT YDisplayLayer {
#ifdef __BORLANDC__
#pragma option push -w-8022
#endif
//--- (end of generated code: YDisplayLayer declaration)
//--- (generated code: YDisplayLayer attributes)
// Attributes (function value cache)
int _polyPrevX;
int _polyPrevY;
//--- (end of generated code: YDisplayLayer attributes)
//--- (generated code: YDisplayLayer constructor)
//--- (end of generated code: YDisplayLayer constructor)
//--- (generated code: YDisplayLayer initialization)
//--- (end of generated code: YDisplayLayer initialization)
YDisplay *_display;
int _id;
string _cmdbuff;
bool _hidden;
// internal function to send a command for this layer
int command_push(string cmd);
int command_flush(string cmd);
public:
int flush_now();
virtual ~YDisplayLayer(){};
YDisplayLayer(YDisplay *parent, int id);
//--- (generated code: YDisplayLayer accessors declaration)
static const int NO_INK = -1;
static const int BG_INK = -2;
static const int FG_INK = -3;
static const Y_ALIGN ALIGN_TOP_LEFT = Y_ALIGN_TOP_LEFT;
static const Y_ALIGN ALIGN_CENTER_LEFT = Y_ALIGN_CENTER_LEFT;
static const Y_ALIGN ALIGN_BASELINE_LEFT = Y_ALIGN_BASELINE_LEFT;
static const Y_ALIGN ALIGN_BOTTOM_LEFT = Y_ALIGN_BOTTOM_LEFT;
static const Y_ALIGN ALIGN_TOP_CENTER = Y_ALIGN_TOP_CENTER;
static const Y_ALIGN ALIGN_CENTER = Y_ALIGN_CENTER;
static const Y_ALIGN ALIGN_BASELINE_CENTER = Y_ALIGN_BASELINE_CENTER;
static const Y_ALIGN ALIGN_BOTTOM_CENTER = Y_ALIGN_BOTTOM_CENTER;
static const Y_ALIGN ALIGN_TOP_DECIMAL = Y_ALIGN_TOP_DECIMAL;
static const Y_ALIGN ALIGN_CENTER_DECIMAL = Y_ALIGN_CENTER_DECIMAL;
static const Y_ALIGN ALIGN_BASELINE_DECIMAL = Y_ALIGN_BASELINE_DECIMAL;
static const Y_ALIGN ALIGN_BOTTOM_DECIMAL = Y_ALIGN_BOTTOM_DECIMAL;
static const Y_ALIGN ALIGN_TOP_RIGHT = Y_ALIGN_TOP_RIGHT;
static const Y_ALIGN ALIGN_CENTER_RIGHT = Y_ALIGN_CENTER_RIGHT;
static const Y_ALIGN ALIGN_BASELINE_RIGHT = Y_ALIGN_BASELINE_RIGHT;
static const Y_ALIGN ALIGN_BOTTOM_RIGHT = Y_ALIGN_BOTTOM_RIGHT;
/**
* Reverts the layer to its initial state (fully transparent, default settings).
* Reinitializes the drawing pointer to the upper left position,
* and selects the most visible pen color. If you only want to erase the layer
* content, use the method clear() instead.
*
* @return YAPI::SUCCESS if the call succeeds.
*
* On failure, throws an exception or returns a negative error code.
*/
virtual int reset(void);
/**
* Erases the whole content of the layer (makes it fully transparent).
* This method does not change any other attribute of the layer.
* To reinitialize the layer attributes to defaults settings, use the method
* reset() instead.
*
* @return YAPI::SUCCESS if the call succeeds.
*
* On failure, throws an exception or returns a negative error code.
*/
virtual int clear(void);
/**
* Selects the color to be used for all subsequent drawing functions,
* for filling as well as for line and text drawing.
* To select a different fill and outline color, use
* selectFillColor and selectLineColor.
* The pen color is provided as an RGB value.
* For grayscale or monochrome displays, the value is
* automatically converted to the proper range.
*
* @param color : the desired pen color, as a 24-bit RGB value
*
* @return YAPI::SUCCESS if the call succeeds.
*
* On failure, throws an exception or returns a negative error code.
*/
virtual int selectColorPen(int color);
/**
* Selects the pen gray level for all subsequent drawing functions,
* for filling as well as for line and text drawing.
* To select a different fill and outline color, use
* selectFillColor and selectLineColor.
* The gray level is provided as a number between
* 0 (black) and 255 (white, or whichever the lightest color is).
* For monochrome displays (without gray levels), any value
* lower than 128 is rendered as black, and any value equal
* or above to 128 is non-black.
*
* @param graylevel : the desired gray level, from 0 to 255
*
* @return YAPI::SUCCESS if the call succeeds.
*
* On failure, throws an exception or returns a negative error code.
*/
virtual int selectGrayPen(int graylevel);
/**
* Selects an eraser instead of a pen for all subsequent drawing functions,
* except for bitmap copy functions. Any point drawn using the eraser
* becomes transparent (as when the layer is empty), showing the other
* layers beneath it.
*
* @return YAPI::SUCCESS if the call succeeds.
*
* On failure, throws an exception or returns a negative error code.
*/
virtual int selectEraser(void);
/**
* Selects the color to be used for filling rectangular bars,
* discs and polygons. The color is provided as an RGB value.
* For grayscale or monochrome displays, the value is
* automatically converted to the proper range.
* You can also use the constants FG_INK to use the
* default drawing colour, BG_INK to use the default
* background colour, and NO_INK to disable filling.
*
* @param color : the desired drawing color, as a 24-bit RGB value,
* or one of the constants NO_INK, FG_INK
* or BG_INK
*
* @return YAPI::SUCCESS if the call succeeds.
*
* On failure, throws an exception or returns a negative error code.
*/
virtual int selectFillColor(int color);
/**
* Selects the color to be used for drawing the outline of rectangular
* bars, discs and polygons, as well as for drawing lines and text.
* The color is provided as an RGB value.
* For grayscale or monochrome displays, the value is
* automatically converted to the proper range.
* You can also use the constants FG_INK to use the
* default drawing colour, BG_INK to use the default
* background colour, and NO_INK to disable outline drawing.
*
* @param color : the desired drawing color, as a 24-bit RGB value,
* or one of the constants NO_INK, FG_INK
* or BG_INK
*
* @return YAPI::SUCCESS if the call succeeds.
*
* On failure, throws an exception or returns a negative error code.
*/
virtual int selectLineColor(int color);
/**
* Selects the line width for drawing the outline of rectangular
* bars, discs and polygons, as well as for drawing lines.
*
* @param width : the desired line width, in pixels
*
* @return YAPI::SUCCESS if the call succeeds.
*
* On failure, throws an exception or returns a negative error code.
*/
virtual int selectLineWidth(int width);
virtual int setAntialiasingMode(bool mode);
/**
* Draws a single pixel at the specified position.
*
* @param x : the distance from left of layer, in pixels
* @param y : the distance from top of layer, in pixels
*
* @return YAPI::SUCCESS if the call succeeds.
*
* On failure, throws an exception or returns a negative error code.
*/
virtual int drawPixel(int x,int y);
/**
* Draws an empty rectangle at a specified position.
*
* @param x1 : the distance from left of layer to the left border of the rectangle, in pixels
* @param y1 : the distance from top of layer to the top border of the rectangle, in pixels
* @param x2 : the distance from left of layer to the right border of the rectangle, in pixels
* @param y2 : the distance from top of layer to the bottom border of the rectangle, in pixels
*
* @return YAPI::SUCCESS if the call succeeds.
*
* On failure, throws an exception or returns a negative error code.
*/
virtual int drawRect(int x1,int y1,int x2,int y2);
/**
* Draws a filled rectangular bar at a specified position.
*
* @param x1 : the distance from left of layer to the left border of the rectangle, in pixels
* @param y1 : the distance from top of layer to the top border of the rectangle, in pixels
* @param x2 : the distance from left of layer to the right border of the rectangle, in pixels
* @param y2 : the distance from top of layer to the bottom border of the rectangle, in pixels
*
* @return YAPI::SUCCESS if the call succeeds.
*
* On failure, throws an exception or returns a negative error code.
*/
virtual int drawBar(int x1,int y1,int x2,int y2);
/**
* Draws an empty circle at a specified position.
*
* @param x : the distance from left of layer to the center of the circle, in pixels
* @param y : the distance from top of layer to the center of the circle, in pixels
* @param r : the radius of the circle, in pixels
*
* @return YAPI::SUCCESS if the call succeeds.
*
* On failure, throws an exception or returns a negative error code.
*/
virtual int drawCircle(int x,int y,int r);
/**
* Draws a filled disc at a given position.
*
* @param x : the distance from left of layer to the center of the disc, in pixels
* @param y : the distance from top of layer to the center of the disc, in pixels
* @param r : the radius of the disc, in pixels
*
* @return YAPI::SUCCESS if the call succeeds.
*
* On failure, throws an exception or returns a negative error code.
*/
virtual int drawDisc(int x,int y,int r);
/**
* Selects a font to use for the next text drawing functions, by providing the name of the
* font file. You can use a built-in font as well as a font file that you have previously
* uploaded to the device built-in memory. If you experience problems selecting a font
* file, check the device logs for any error message such as missing font file or bad font
* file format.
*
* @param fontname : the font file name, embedded fonts are 8x8.yfm, Small.yfm, Medium.yfm, Large.yfm
* (not available on Yocto-MiniDisplay).
*
* @return YAPI::SUCCESS if the call succeeds.
*
* On failure, throws an exception or returns a negative error code.
*/
virtual int selectFont(string fontname);
/**
* Draws a text string at the specified position. The point of the text that is aligned
* to the specified pixel position is called the anchor point, and can be chosen among
* several options. Text is rendered from left to right, without implicit wrapping.
*
* @param x : the distance from left of layer to the text anchor point, in pixels
* @param y : the distance from top of layer to the text anchor point, in pixels
* @param anchor : the text anchor point, chosen among the YDisplayLayer::ALIGN enumeration:
* YDisplayLayer::ALIGN_TOP_LEFT, YDisplayLayer::ALIGN_CENTER_LEFT,
* YDisplayLayer::ALIGN_BASELINE_LEFT, YDisplayLayer::ALIGN_BOTTOM_LEFT,
* YDisplayLayer::ALIGN_TOP_CENTER, YDisplayLayer::ALIGN_CENTER,
* YDisplayLayer::ALIGN_BASELINE_CENTER, YDisplayLayer::ALIGN_BOTTOM_CENTER,
* YDisplayLayer::ALIGN_TOP_DECIMAL, YDisplayLayer::ALIGN_CENTER_DECIMAL,
* YDisplayLayer::ALIGN_BASELINE_DECIMAL, YDisplayLayer::ALIGN_BOTTOM_DECIMAL,
* YDisplayLayer::ALIGN_TOP_RIGHT, YDisplayLayer::ALIGN_CENTER_RIGHT,
* YDisplayLayer::ALIGN_BASELINE_RIGHT, YDisplayLayer::ALIGN_BOTTOM_RIGHT.
* @param text : the text string to draw
*
* @return YAPI::SUCCESS if the call succeeds.
*
* On failure, throws an exception or returns a negative error code.
*/
virtual int drawText(int x,int y,Y_ALIGN anchor,string text);
/**
* Draws an image previously uploaded to the device filesystem, at the specified position.
* At present time, GIF images are the only supported image format. If you experience
* problems using an image file, check the device logs for any error message such as
* missing image file or bad image file format.
*
* @param x : the distance from left of layer to the left of the image, in pixels
* @param y : the distance from top of layer to the top of the image, in pixels
* @param imagename : the GIF file name
*
* @return YAPI::SUCCESS if the call succeeds.
*
* On failure, throws an exception or returns a negative error code.
*/
virtual int drawImage(int x,int y,string imagename);
/**
* Draws a bitmap at the specified position. The bitmap is provided as a binary object,
* where each pixel maps to a bit, from left to right and from top to bottom.
* The most significant bit of each byte maps to the leftmost pixel, and the least
* significant bit maps to the rightmost pixel. Bits set to 1 are drawn using the
* layer selected pen color. Bits set to 0 are drawn using the specified background
* gray level, unless -1 is specified, in which case they are not drawn at all
* (as if transparent).
*
* @param x : the distance from left of layer to the left of the bitmap, in pixels
* @param y : the distance from top of layer to the top of the bitmap, in pixels
* @param w : the width of the bitmap, in pixels
* @param bitmap : a binary object
* @param bgcol : the background gray level to use for zero bits (0 = black,
* 255 = white), or -1 to leave the pixels unchanged
*
* @return YAPI::SUCCESS if the call succeeds.
*
* On failure, throws an exception or returns a negative error code.
*/
virtual int drawBitmap(int x,int y,int w,string bitmap,int bgcol);
/**
* Draws a GIF image provided as a binary buffer at the specified position.
* If the image drawing must be included in an animation sequence, save it
* in the device filesystem first and use drawImage instead.
*
* @param x : the distance from left of layer to the left of the image, in pixels
* @param y : the distance from top of layer to the top of the image, in pixels
* @param gifimage : a binary object with the content of a GIF file
*
* @return YAPI::SUCCESS if the call succeeds.
*
* On failure, throws an exception or returns a negative error code.
*/
virtual int drawGIF(int x,int y,string gifimage);
/**
* Moves the drawing pointer of this layer to the specified position.
*
* @param x : the distance from left of layer, in pixels
* @param y : the distance from top of layer, in pixels
*
* @return YAPI::SUCCESS if the call succeeds.
*
* On failure, throws an exception or returns a negative error code.
*/
virtual int moveTo(int x,int y);
/**
* Draws a line from current drawing pointer position to the specified position.
* The specified destination pixel is included in the line. The pointer position
* is then moved to the end point of the line.
*
* @param x : the distance from left of layer to the end point of the line, in pixels
* @param y : the distance from top of layer to the end point of the line, in pixels
*
* @return YAPI::SUCCESS if the call succeeds.
*
* On failure, throws an exception or returns a negative error code.
*/
virtual int lineTo(int x,int y);
/**
* Starts drawing a polygon with the first corner at the specified position.
*
* @param x : the distance from left of layer, in pixels
* @param y : the distance from top of layer, in pixels
*
* @return YAPI::SUCCESS if the call succeeds.
*
* On failure, throws an exception or returns a negative error code.
*/
virtual int polygonStart(int x,int y);
/**
* Adds a point to the currently open polygon, previously opened using
* polygonStart.
*
* @param x : the distance from left of layer to the new point, in pixels
* @param y : the distance from top of layer to the new point, in pixels
*
* @return YAPI::SUCCESS if the call succeeds.
*
* On failure, throws an exception or returns a negative error code.
*/
virtual int polygonAdd(int x,int y);
/**
* Close the currently open polygon, fill its content the fill color currently
* selected for the layer, and draw its outline using the selected line color.
*
* @return YAPI::SUCCESS if the call succeeds.
*
* On failure, throws an exception or returns a negative error code.
*/
virtual int polygonEnd(void);
/**
* Outputs a message in the console area, and advances the console pointer accordingly.
* The console pointer position is automatically moved to the beginning
* of the next line when a newline character is met, or when the right margin
* is hit. When the new text to display extends below the lower margin, the
* console area is automatically scrolled up.
*
* @param text : the message to display
*
* @return YAPI::SUCCESS if the call succeeds.
*
* On failure, throws an exception or returns a negative error code.
*/
virtual int consoleOut(string text);
/**
* Sets up display margins for the consoleOut function.
*
* @param x1 : the distance from left of layer to the left margin, in pixels
* @param y1 : the distance from top of layer to the top margin, in pixels
* @param x2 : the distance from left of layer to the right margin, in pixels
* @param y2 : the distance from top of layer to the bottom margin, in pixels
*
* @return YAPI::SUCCESS if the call succeeds.
*
* On failure, throws an exception or returns a negative error code.
*/
virtual int setConsoleMargins(int x1,int y1,int x2,int y2);
/**
* Sets up the background color used by the clearConsole function and by
* the console scrolling feature.
*
* @param bgcol : the background gray level to use when scrolling (0 = black,
* 255 = white), or -1 for transparent
*
* @return YAPI::SUCCESS if the call succeeds.
*
* On failure, throws an exception or returns a negative error code.
*/
virtual int setConsoleBackground(int bgcol);
/**
* Sets up the wrapping behavior used by the consoleOut function.
*
* @param wordwrap : true to wrap only between words,
* false to wrap on the last column anyway.
*
* @return YAPI::SUCCESS if the call succeeds.
*
* On failure, throws an exception or returns a negative error code.
*/
virtual int setConsoleWordWrap(bool wordwrap);
/**
* Blanks the console area within console margins, and resets the console pointer
* to the upper left corner of the console.
*
* @return YAPI::SUCCESS if the call succeeds.
*
* On failure, throws an exception or returns a negative error code.
*/
virtual int clearConsole(void);
/**
* Sets the position of the layer relative to the display upper left corner.
* When smooth scrolling is used, the display offset of the layer is
* automatically updated during the next milliseconds to animate the move of the layer.
*
* @param x : the distance from left of display to the upper left corner of the layer
* @param y : the distance from top of display to the upper left corner of the layer
* @param scrollTime : number of milliseconds to use for smooth scrolling, or
* 0 if the scrolling should be immediate.
*
* @return YAPI::SUCCESS if the call succeeds.
*
* On failure, throws an exception or returns a negative error code.
*/
virtual int setLayerPosition(int x,int y,int scrollTime);
/**
* Hides the layer. The state of the layer is preserved but the layer is not displayed
* on the screen until the next call to unhide(). Hiding the layer can positively
* affect the drawing speed, since it postpones the rendering until all operations are
* completed (double-buffering).
*
* @return YAPI::SUCCESS if the call succeeds.
*
* On failure, throws an exception or returns a negative error code.
*/
virtual int hide(void);
/**
* Shows the layer. Shows the layer again after a hide command.
*
* @return YAPI::SUCCESS if the call succeeds.
*
* On failure, throws an exception or returns a negative error code.
*/
virtual int unhide(void);
/**
* Gets parent YDisplay. Returns the parent YDisplay object of the current YDisplayLayer::
*
* @return an YDisplay object
*/
virtual YDisplay* get_display(void);
/**
* Returns the display width, in pixels.
*
* @return an integer corresponding to the display width, in pixels
*
* On failure, throws an exception or returns YDisplayLayer::DISPLAYWIDTH_INVALID.
*/
virtual int get_displayWidth(void);
/**
* Returns the display height, in pixels.
*
* @return an integer corresponding to the display height, in pixels
*
* On failure, throws an exception or returns YDisplayLayer::DISPLAYHEIGHT_INVALID.
*/
virtual int get_displayHeight(void);
/**
* Returns the width of the layers to draw on, in pixels.
*
* @return an integer corresponding to the width of the layers to draw on, in pixels
*
* On failure, throws an exception or returns YDisplayLayer::LAYERWIDTH_INVALID.
*/
virtual int get_layerWidth(void);
/**
* Returns the height of the layers to draw on, in pixels.
*
* @return an integer corresponding to the height of the layers to draw on, in pixels
*
* On failure, throws an exception or returns YDisplayLayer::LAYERHEIGHT_INVALID.
*/
virtual int get_layerHeight(void);
virtual int resetHiddenFlag(void);
#ifdef __BORLANDC__
#pragma option pop
#endif
//--- (end of generated code: YDisplayLayer accessors declaration)
int drawBitmap(int x,int y,int w,const std::vector<unsigned char>& data,int bgcol);
};
//--- (generated code: YDisplay declaration)
/**
* YDisplay Class: display control interface, available for instance in the Yocto-Display, the
* Yocto-MaxiDisplay, the Yocto-MaxiDisplay-G or the Yocto-MiniDisplay
*
* The YDisplay class allows to drive Yoctopuce displays.
* Yoctopuce display interface has been designed to easily
* show information and images. The device provides built-in
* multi-layer rendering. Layers can be drawn offline, individually,
* and freely moved on the display. It can also replay recorded
* sequences (animations).
*
* In order to draw on the screen, you should use the
* display.get_displayLayer method to retrieve the layer(s) on
* which you want to draw, and then use methods defined in
* YDisplayLayer to draw on the layers.
*/
class YOCTO_CLASS_EXPORT YDisplay: public YFunction {
#ifdef __BORLANDC__
#pragma option push -w-8022
#endif
//--- (end of generated code: YDisplay declaration)
//--- (generated code: YDisplay attributes)
// Attributes (function value cache)
Y_ENABLED_enum _enabled;
string _startupSeq;
int _brightness;
int _autoInvertDelay;
Y_ORIENTATION_enum _orientation;
string _displayPanel;
int _displayWidth;
int _displayHeight;
Y_DISPLAYTYPE_enum _displayType;
int _layerWidth;
int _layerHeight;
int _layerCount;
string _command;
YDisplayValueCallback _valueCallbackDisplay;
vector<YDisplayLayer*> _allDisplayLayers;
friend YDisplay *yFindDisplay(const string& func);
friend YDisplay *yFirstDisplay(void);
// Function-specific method for parsing of JSON output and caching result
virtual int _parseAttr(YJSONObject *json_val);
// Constructor is protected, use yFindDisplay factory function to instantiate
YDisplay(const string& func);
//--- (end of generated code: YDisplay attributes)
bool _recording;
string _sequence;
//--- (generated code: YDisplay initialization)
//--- (end of generated code: YDisplay initialization)
public:
~YDisplay();
//--- (generated code: YDisplay accessors declaration)
static const Y_ENABLED_enum ENABLED_FALSE = Y_ENABLED_FALSE;
static const Y_ENABLED_enum ENABLED_TRUE = Y_ENABLED_TRUE;
static const Y_ENABLED_enum ENABLED_INVALID = Y_ENABLED_INVALID;
static const string STARTUPSEQ_INVALID;
static const int BRIGHTNESS_INVALID = YAPI_INVALID_UINT;
static const int AUTOINVERTDELAY_INVALID = YAPI_INVALID_UINT;
static const Y_ORIENTATION_enum ORIENTATION_LEFT = Y_ORIENTATION_LEFT;
static const Y_ORIENTATION_enum ORIENTATION_UP = Y_ORIENTATION_UP;
static const Y_ORIENTATION_enum ORIENTATION_RIGHT = Y_ORIENTATION_RIGHT;
static const Y_ORIENTATION_enum ORIENTATION_DOWN = Y_ORIENTATION_DOWN;
static const Y_ORIENTATION_enum ORIENTATION_INVALID = Y_ORIENTATION_INVALID;
static const string DISPLAYPANEL_INVALID;
static const int DISPLAYWIDTH_INVALID = YAPI_INVALID_UINT;
static const int DISPLAYHEIGHT_INVALID = YAPI_INVALID_UINT;
static const Y_DISPLAYTYPE_enum DISPLAYTYPE_MONO = Y_DISPLAYTYPE_MONO;
static const Y_DISPLAYTYPE_enum DISPLAYTYPE_EPAPER_BW = Y_DISPLAYTYPE_EPAPER_BW;
static const Y_DISPLAYTYPE_enum DISPLAYTYPE_EPAPER_BWR = Y_DISPLAYTYPE_EPAPER_BWR;
static const Y_DISPLAYTYPE_enum DISPLAYTYPE_EPAPER_BWRY = Y_DISPLAYTYPE_EPAPER_BWRY;
static const Y_DISPLAYTYPE_enum DISPLAYTYPE_INVALID = Y_DISPLAYTYPE_INVALID;
static const int LAYERWIDTH_INVALID = YAPI_INVALID_UINT;
static const int LAYERHEIGHT_INVALID = YAPI_INVALID_UINT;
static const int LAYERCOUNT_INVALID = YAPI_INVALID_UINT;
static const string COMMAND_INVALID;
/**
* Returns true if the screen is powered, false otherwise.
*
* @return either YDisplay::ENABLED_FALSE or YDisplay::ENABLED_TRUE, according to true if the screen is
* powered, false otherwise
*
* On failure, throws an exception or returns YDisplay::ENABLED_INVALID.
*/
Y_ENABLED_enum get_enabled(void);
inline Y_ENABLED_enum enabled(void)
{ return this->get_enabled(); }
/**
* Changes the power state of the display.
*
* @param newval : either YDisplay::ENABLED_FALSE or YDisplay::ENABLED_TRUE, according to the power
* state of the display
*
* @return YAPI::SUCCESS if the call succeeds.
*
* On failure, throws an exception or returns a negative error code.
*/
int set_enabled(Y_ENABLED_enum newval);
inline int setEnabled(Y_ENABLED_enum newval)
{ return this->set_enabled(newval); }
/**
* Returns the name of the sequence to play when the displayed is powered on.
*
* @return a string corresponding to the name of the sequence to play when the displayed is powered on
*
* On failure, throws an exception or returns YDisplay::STARTUPSEQ_INVALID.
*/
string get_startupSeq(void);
inline string startupSeq(void)
{ return this->get_startupSeq(); }
/**
* Changes the name of the sequence to play when the displayed is powered on.
* Remember to call the saveToFlash() method of the module if the
* modification must be kept.
*
* @param newval : a string corresponding to the name of the sequence to play when the displayed is powered on
*
* @return YAPI::SUCCESS if the call succeeds.
*
* On failure, throws an exception or returns a negative error code.
*/
int set_startupSeq(const string& newval);
inline int setStartupSeq(const string& newval)
{ return this->set_startupSeq(newval); }
/**
* Returns the luminosity of the module informative LEDs (from 0 to 100).
*
* @return an integer corresponding to the luminosity of the module informative LEDs (from 0 to 100)
*
* On failure, throws an exception or returns YDisplay::BRIGHTNESS_INVALID.
*/
int get_brightness(void);
inline int brightness(void)
{ return this->get_brightness(); }
/**
* Changes the brightness of the display. The parameter is a value between 0 and
* 100. Remember to call the saveToFlash() method of the module if the
* modification must be kept.
*
* @param newval : an integer corresponding to the brightness of the display
*
* @return YAPI::SUCCESS if the call succeeds.
*
* On failure, throws an exception or returns a negative error code.
*/
int set_brightness(int newval);
inline int setBrightness(int newval)
{ return this->set_brightness(newval); }
/**
* Returns the interval between automatic display inversions, or 0 if automatic
* inversion is disabled. Using the automatic inversion mechanism reduces the
* burn-in that occurs on OLED screens over long periods when the same content
* remains displayed on the screen.
*
* @return an integer corresponding to the interval between automatic display inversions, or 0 if automatic
* inversion is disabled
*
* On failure, throws an exception or returns YDisplay::AUTOINVERTDELAY_INVALID.
*/
int get_autoInvertDelay(void);
inline int autoInvertDelay(void)
{ return this->get_autoInvertDelay(); }
/**
* Changes the interval between automatic display inversions.
* The parameter is the number of seconds, or 0 to disable automatic inversion.
* Using the automatic inversion mechanism reduces the burn-in that occurs on OLED
* screens over long periods when the same content remains displayed on the screen.
* Remember to call the saveToFlash() method of the module if the
* modification must be kept.
*
* @param newval : an integer corresponding to the interval between automatic display inversions
*
* @return YAPI::SUCCESS if the call succeeds.
*
* On failure, throws an exception or returns a negative error code.
*/
int set_autoInvertDelay(int newval);
inline int setAutoInvertDelay(int newval)
{ return this->set_autoInvertDelay(newval); }
/**
* Returns the currently selected display orientation.
*
* @return a value among YDisplay::ORIENTATION_LEFT, YDisplay::ORIENTATION_UP,
* YDisplay::ORIENTATION_RIGHT and YDisplay::ORIENTATION_DOWN corresponding to the currently selected
* display orientation
*
* On failure, throws an exception or returns YDisplay::ORIENTATION_INVALID.
*/
Y_ORIENTATION_enum get_orientation(void);
inline Y_ORIENTATION_enum orientation(void)
{ return this->get_orientation(); }
/**
* Changes the display orientation. Remember to call the saveToFlash()
* method of the module if the modification must be kept.
*
* @param newval : a value among YDisplay::ORIENTATION_LEFT, YDisplay::ORIENTATION_UP,
* YDisplay::ORIENTATION_RIGHT and YDisplay::ORIENTATION_DOWN corresponding to the display orientation
*
* @return YAPI::SUCCESS if the call succeeds.
*
* On failure, throws an exception or returns a negative error code.
*/
int set_orientation(Y_ORIENTATION_enum newval);
inline int setOrientation(Y_ORIENTATION_enum newval)
{ return this->set_orientation(newval); }
/**
* Returns the exact model of the display panel.
*
* @return a string corresponding to the exact model of the display panel
*
* On failure, throws an exception or returns YDisplay::DISPLAYPANEL_INVALID.
*/
string get_displayPanel(void);
inline string displayPanel(void)
{ return this->get_displayPanel(); }
/**
* Changes the model of display to match the connected display panel.
* This function has no effect if the module does not support the selected
* display panel.
* Remember to call the saveToFlash()
* method of the module if the modification must be kept.
*
* @param newval : a string corresponding to the model of display to match the connected display panel
*
* @return YAPI::SUCCESS if the call succeeds.
*
* On failure, throws an exception or returns a negative error code.
*/
int set_displayPanel(const string& newval);
inline int setDisplayPanel(const string& newval)
{ return this->set_displayPanel(newval); }
/**
* Returns the display width, in pixels.
*
* @return an integer corresponding to the display width, in pixels
*
* On failure, throws an exception or returns YDisplay::DISPLAYWIDTH_INVALID.
*/
int get_displayWidth(void);
inline int displayWidth(void)
{ return this->get_displayWidth(); }
/**
* Returns the display height, in pixels.
*
* @return an integer corresponding to the display height, in pixels
*
* On failure, throws an exception or returns YDisplay::DISPLAYHEIGHT_INVALID.
*/
int get_displayHeight(void);
inline int displayHeight(void)
{ return this->get_displayHeight(); }
/**
* Returns the display type: monochrome OLED, black and white ePaper, color ePaper, etc.
*
* @return a value among YDisplay::DISPLAYTYPE_MONO, YDisplay::DISPLAYTYPE_EPAPER_BW,
* YDisplay::DISPLAYTYPE_EPAPER_BWR and YDisplay::DISPLAYTYPE_EPAPER_BWRY corresponding to the display
* type: monochrome OLED, black and white ePaper, color ePaper, etc
*
* On failure, throws an exception or returns YDisplay::DISPLAYTYPE_INVALID.
*/
Y_DISPLAYTYPE_enum get_displayType(void);
inline Y_DISPLAYTYPE_enum displayType(void)
{ return this->get_displayType(); }
/**
* Returns the width of the layers to draw on, in pixels.
*
* @return an integer corresponding to the width of the layers to draw on, in pixels
*
* On failure, throws an exception or returns YDisplay::LAYERWIDTH_INVALID.
*/
int get_layerWidth(void);
inline int layerWidth(void)
{ return this->get_layerWidth(); }
/**
* Returns the height of the layers to draw on, in pixels.
*
* @return an integer corresponding to the height of the layers to draw on, in pixels
*
* On failure, throws an exception or returns YDisplay::LAYERHEIGHT_INVALID.
*/
int get_layerHeight(void);
inline int layerHeight(void)
{ return this->get_layerHeight(); }