yocto_display.h
Go to the documentation of this file.
1 /*********************************************************************
2  *
3  * $Id: yocto_display.h 28753 2017-10-03 11:23:38Z seb $
4  *
5  * Declares yFindDisplay(), the high-level API for Display functions
6  *
7  * - - - - - - - - - License information: - - - - - - - - -
8  *
9  * Copyright (C) 2011 and beyond by Yoctopuce Sarl, Switzerland.
10  *
11  * Yoctopuce Sarl (hereafter Licensor) grants to you a perpetual
12  * non-exclusive license to use, modify, copy and integrate this
13  * file into your software for the sole purpose of interfacing
14  * with Yoctopuce products.
15  *
16  * You may reproduce and distribute copies of this file in
17  * source or object form, as long as the sole purpose of this
18  * code is to interface with Yoctopuce products. You must retain
19  * this notice in the distributed source file.
20  *
21  * You should refer to Yoctopuce General Terms and Conditions
22  * for additional information regarding your rights and
23  * obligations.
24  *
25  * THE SOFTWARE AND DOCUMENTATION ARE PROVIDED "AS IS" WITHOUT
26  * WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING
27  * WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, FITNESS
28  * FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO
29  * EVENT SHALL LICENSOR BE LIABLE FOR ANY INCIDENTAL, SPECIAL,
30  * INDIRECT OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA,
31  * COST OF PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY OR
32  * SERVICES, ANY CLAIMS BY THIRD PARTIES (INCLUDING BUT NOT
33  * LIMITED TO ANY DEFENSE THEREOF), ANY CLAIMS FOR INDEMNITY OR
34  * CONTRIBUTION, OR OTHER SIMILAR COSTS, WHETHER ASSERTED ON THE
35  * BASIS OF CONTRACT, TORT (INCLUDING NEGLIGENCE), BREACH OF
36  * WARRANTY, OR OTHERWISE.
37  *
38  *********************************************************************/
39 
40 
41 #ifndef YOCTO_DISPLAY_H
42 #define YOCTO_DISPLAY_H
43 
44 #include "yocto_api.h"
45 #include <cfloat>
46 #include <cmath>
47 #include <map>
48 
49 
50 //--- (generated code: YDisplay definitions)
51 class YDisplay; // forward declaration
52 
53 typedef void (*YDisplayValueCallback)(YDisplay *func, const string& functionValue);
54 #ifndef _Y_ENABLED_ENUM
55 #define _Y_ENABLED_ENUM
56 typedef enum {
61 #endif
62 #ifndef _Y_ORIENTATION_ENUM
63 #define _Y_ORIENTATION_ENUM
64 typedef enum {
71 #endif
72 #ifndef _Y_DISPLAYTYPE_ENUM
73 #define _Y_DISPLAYTYPE_ENUM
74 typedef enum {
80 #endif
81 #define Y_STARTUPSEQ_INVALID (YAPI_INVALID_STRING)
82 #define Y_BRIGHTNESS_INVALID (YAPI_INVALID_UINT)
83 #define Y_DISPLAYWIDTH_INVALID (YAPI_INVALID_UINT)
84 #define Y_DISPLAYHEIGHT_INVALID (YAPI_INVALID_UINT)
85 #define Y_LAYERWIDTH_INVALID (YAPI_INVALID_UINT)
86 #define Y_LAYERHEIGHT_INVALID (YAPI_INVALID_UINT)
87 #define Y_LAYERCOUNT_INVALID (YAPI_INVALID_UINT)
88 #define Y_COMMAND_INVALID (YAPI_INVALID_STRING)
89 //--- (end of generated code: YDisplay definitions)
90 
91 //--- (generated code: YDisplayLayer definitions)
92  #ifndef _Y_ALIGN
93  #define _Y_ALIGN
94  typedef enum {
111  } Y_ALIGN;
112  #endif
113 
114 //--- (end of generated code: YDisplayLayer definitions)
115 
116 class YDisplay;
117 
118 //--- (generated code: YDisplayLayer declaration)
128 #ifdef __BORLANDC__
129 #pragma option push -w-8022
130 #endif
131 //--- (end of generated code: YDisplayLayer declaration)
132  //--- (generated code: YDisplayLayer attributes)
133  // Attributes (function value cache)
134  //--- (end of generated code: YDisplayLayer attributes)
135  //--- (generated code: YDisplayLayer constructor)
136 
137  //--- (end of generated code: YDisplayLayer constructor)
138  //--- (generated code: YDisplayLayer initialization)
139  //--- (end of generated code: YDisplayLayer initialization)
140 
142  int _id;
143  string _cmdbuff;
144  bool _hidden;
145 
146  // internal function to send a command for this layer
147  int command_push(string cmd);
148  int command_flush(string cmd);
149 
150 public:
151  int flush_now();
152  virtual ~YDisplayLayer(){};
153  YDisplayLayer(YDisplay *parent, int id);
154  //--- (generated code: YDisplayLayer accessors declaration)
155 
156  static const Y_ALIGN ALIGN_TOP_LEFT = Y_ALIGN_TOP_LEFT;
157  static const Y_ALIGN ALIGN_CENTER_LEFT = Y_ALIGN_CENTER_LEFT;
158  static const Y_ALIGN ALIGN_BASELINE_LEFT = Y_ALIGN_BASELINE_LEFT;
159  static const Y_ALIGN ALIGN_BOTTOM_LEFT = Y_ALIGN_BOTTOM_LEFT;
160  static const Y_ALIGN ALIGN_TOP_CENTER = Y_ALIGN_TOP_CENTER;
161  static const Y_ALIGN ALIGN_CENTER = Y_ALIGN_CENTER;
162  static const Y_ALIGN ALIGN_BASELINE_CENTER = Y_ALIGN_BASELINE_CENTER;
163  static const Y_ALIGN ALIGN_BOTTOM_CENTER = Y_ALIGN_BOTTOM_CENTER;
164  static const Y_ALIGN ALIGN_TOP_DECIMAL = Y_ALIGN_TOP_DECIMAL;
165  static const Y_ALIGN ALIGN_CENTER_DECIMAL = Y_ALIGN_CENTER_DECIMAL;
166  static const Y_ALIGN ALIGN_BASELINE_DECIMAL = Y_ALIGN_BASELINE_DECIMAL;
167  static const Y_ALIGN ALIGN_BOTTOM_DECIMAL = Y_ALIGN_BOTTOM_DECIMAL;
168  static const Y_ALIGN ALIGN_TOP_RIGHT = Y_ALIGN_TOP_RIGHT;
169  static const Y_ALIGN ALIGN_CENTER_RIGHT = Y_ALIGN_CENTER_RIGHT;
170  static const Y_ALIGN ALIGN_BASELINE_RIGHT = Y_ALIGN_BASELINE_RIGHT;
171  static const Y_ALIGN ALIGN_BOTTOM_RIGHT = Y_ALIGN_BOTTOM_RIGHT;
172 
183  virtual int reset(void);
184 
195  virtual int clear(void);
196 
209  virtual int selectColorPen(int color);
210 
225  virtual int selectGrayPen(int graylevel);
226 
237  virtual int selectEraser(void);
238 
255  virtual int setAntialiasingMode(bool mode);
256 
267  virtual int drawPixel(int x,int y);
268 
281  virtual int drawRect(int x1,int y1,int x2,int y2);
282 
295  virtual int drawBar(int x1,int y1,int x2,int y2);
296 
308  virtual int drawCircle(int x,int y,int r);
309 
321  virtual int drawDisc(int x,int y,int r);
322 
336  virtual int selectFont(string fontname);
337 
356  virtual int drawText(int x,int y,Y_ALIGN anchor,string text);
357 
372  virtual int drawImage(int x,int y,string imagename);
373 
394  virtual int drawBitmap(int x,int y,int w,string bitmap,int bgcol);
395 
406  virtual int moveTo(int x,int y);
407 
420  virtual int lineTo(int x,int y);
421 
435  virtual int consoleOut(string text);
436 
449  virtual int setConsoleMargins(int x1,int y1,int x2,int y2);
450 
462  virtual int setConsoleBackground(int bgcol);
463 
474  virtual int setConsoleWordWrap(bool wordwrap);
475 
484  virtual int clearConsole(void);
485 
500  virtual int setLayerPosition(int x,int y,int scrollTime);
501 
512  virtual int hide(void);
513 
521  virtual int unhide(void);
522 
528  virtual YDisplay* get_display(void);
529 
537  virtual int get_displayWidth(void);
538 
546  virtual int get_displayHeight(void);
547 
555  virtual int get_layerWidth(void);
556 
564  virtual int get_layerHeight(void);
565 
566  virtual int resetHiddenFlag(void);
567 
568 #ifdef __BORLANDC__
569 #pragma option pop
570 #endif
571  //--- (end of generated code: YDisplayLayer accessors declaration)
572  int drawBitmap(int x,int y,int w,const std::vector<unsigned char>& data,int bgcol);
573 };
574 
575 
576 //--- (generated code: YDisplay declaration)
587 #ifdef __BORLANDC__
588 #pragma option push -w-8022
589 #endif
590 //--- (end of generated code: YDisplay declaration)
591  //--- (generated code: YDisplay attributes)
592  // Attributes (function value cache)
594  string _startupSeq;
603  string _command;
605 
606  friend YDisplay *yFindDisplay(const string& func);
607  friend YDisplay *yFirstDisplay(void);
608 
609  // Function-specific method for parsing of JSON output and caching result
610  virtual int _parseAttr(YJSONObject* json_val);
611 
612  // Constructor is protected, use yFindDisplay factory function to instantiate
613  YDisplay(const string& func);
614  //--- (end of generated code: YDisplay attributes)
615  vector<YDisplayLayer*> _allDisplayLayers;
617  string _sequence;
618 
619  //--- (generated code: YDisplay initialization)
620  //--- (end of generated code: YDisplay initialization)
621 
622 public:
623  ~YDisplay();
624  //--- (generated code: YDisplay accessors declaration)
625 
626  static const Y_ENABLED_enum ENABLED_FALSE = Y_ENABLED_FALSE;
627  static const Y_ENABLED_enum ENABLED_TRUE = Y_ENABLED_TRUE;
628  static const Y_ENABLED_enum ENABLED_INVALID = Y_ENABLED_INVALID;
629  static const string STARTUPSEQ_INVALID;
630  static const int BRIGHTNESS_INVALID = YAPI_INVALID_UINT;
631  static const Y_ORIENTATION_enum ORIENTATION_LEFT = Y_ORIENTATION_LEFT;
632  static const Y_ORIENTATION_enum ORIENTATION_UP = Y_ORIENTATION_UP;
633  static const Y_ORIENTATION_enum ORIENTATION_RIGHT = Y_ORIENTATION_RIGHT;
634  static const Y_ORIENTATION_enum ORIENTATION_DOWN = Y_ORIENTATION_DOWN;
635  static const Y_ORIENTATION_enum ORIENTATION_INVALID = Y_ORIENTATION_INVALID;
636  static const int DISPLAYWIDTH_INVALID = YAPI_INVALID_UINT;
637  static const int DISPLAYHEIGHT_INVALID = YAPI_INVALID_UINT;
638  static const Y_DISPLAYTYPE_enum DISPLAYTYPE_MONO = Y_DISPLAYTYPE_MONO;
639  static const Y_DISPLAYTYPE_enum DISPLAYTYPE_GRAY = Y_DISPLAYTYPE_GRAY;
640  static const Y_DISPLAYTYPE_enum DISPLAYTYPE_RGB = Y_DISPLAYTYPE_RGB;
641  static const Y_DISPLAYTYPE_enum DISPLAYTYPE_INVALID = Y_DISPLAYTYPE_INVALID;
642  static const int LAYERWIDTH_INVALID = YAPI_INVALID_UINT;
643  static const int LAYERHEIGHT_INVALID = YAPI_INVALID_UINT;
644  static const int LAYERCOUNT_INVALID = YAPI_INVALID_UINT;
645  static const string COMMAND_INVALID;
646 
654  Y_ENABLED_enum get_enabled(void);
655 
656  inline Y_ENABLED_enum enabled(void)
657  { return this->get_enabled(); }
658 
668  int set_enabled(Y_ENABLED_enum newval);
669  inline int setEnabled(Y_ENABLED_enum newval)
670  { return this->set_enabled(newval); }
671 
679  string get_startupSeq(void);
680 
681  inline string startupSeq(void)
682  { return this->get_startupSeq(); }
683 
695  int set_startupSeq(const string& newval);
696  inline int setStartupSeq(const string& newval)
697  { return this->set_startupSeq(newval); }
698 
706  int get_brightness(void);
707 
708  inline int brightness(void)
709  { return this->get_brightness(); }
710 
722  int set_brightness(int newval);
723  inline int setBrightness(int newval)
724  { return this->set_brightness(newval); }
725 
734  Y_ORIENTATION_enum get_orientation(void);
735 
737  { return this->get_orientation(); }
738 
750  int set_orientation(Y_ORIENTATION_enum newval);
752  { return this->set_orientation(newval); }
753 
761  int get_displayWidth(void);
762 
763  inline int displayWidth(void)
764  { return this->get_displayWidth(); }
765 
773  int get_displayHeight(void);
774 
775  inline int displayHeight(void)
776  { return this->get_displayHeight(); }
777 
786  Y_DISPLAYTYPE_enum get_displayType(void);
787 
789  { return this->get_displayType(); }
790 
798  int get_layerWidth(void);
799 
800  inline int layerWidth(void)
801  { return this->get_layerWidth(); }
802 
810  int get_layerHeight(void);
811 
812  inline int layerHeight(void)
813  { return this->get_layerHeight(); }
814 
822  int get_layerCount(void);
823 
824  inline int layerCount(void)
825  { return this->get_layerCount(); }
826 
827  string get_command(void);
828 
829  inline string command(void)
830  { return this->get_command(); }
831 
832  int set_command(const string& newval);
833  inline int setCommand(const string& newval)
834  { return this->set_command(newval); }
835 
863  static YDisplay* FindDisplay(string func);
864 
876  virtual int registerValueCallback(YDisplayValueCallback callback);
878 
879  virtual int _invokeValueCallback(string value);
880 
890  virtual int resetAll(void);
891 
903  virtual int fade(int brightness,int duration);
904 
914  virtual int newSequence(void);
915 
927  virtual int saveSequence(string sequenceName);
928 
939  virtual int playSequence(string sequenceName);
940 
955  virtual int pauseSequence(int delay_ms);
956 
965  virtual int stopSequence(void);
966 
979  virtual int upload(string pathname,string content);
980 
995  virtual int copyLayerContent(int srcLayerId,int dstLayerId);
996 
1012  virtual int swapLayerContent(int layerIdA,int layerIdB);
1013 
1014 
1015  inline static YDisplay* Find(string func)
1016  { return YDisplay::FindDisplay(func); }
1017 
1025  YDisplay *nextDisplay(void);
1026  inline YDisplay *next(void)
1027  { return this->nextDisplay();}
1028 
1038  static YDisplay* FirstDisplay(void);
1039  inline static YDisplay* First(void)
1040  { return YDisplay::FirstDisplay();}
1041 #ifdef __BORLANDC__
1042 #pragma option pop
1043 #endif
1044  //--- (end of generated code: YDisplay accessors declaration)
1045 
1046 
1047 
1048 
1049 
1061  YDisplayLayer* get_displayLayer(unsigned layerId);
1062 
1063 
1064  int flushLayers(void);
1065 
1066  int sendCommand(string cmd);
1067 
1068  // internal function to clear hidden flag during resetAll
1069  void resetHiddenLayerFlags(void);
1070 };
1071 
1072 //--- (generated code: YDisplay functions declaration)
1073 
1101 inline YDisplay* yFindDisplay(const string& func)
1102 { return YDisplay::FindDisplay(func);}
1113 { return YDisplay::FirstDisplay();}
1114 
1115 //--- (end of generated code: YDisplay functions declaration)
1116 
1117 #endif
Y_ENABLED_enum enabled(void)
Y_ORIENTATION_enum orientation(void)
void(* YDisplayValueCallback)(YDisplay *func, const string &functionValue)
Definition: yocto_display.h:53
Y_ENABLED_enum
Definition: yocto_current.h:59
int _layerHeight
YDisplay * yFindDisplay(const string &func)
string _startupSeq
Y_DISPLAYTYPE_enum _displayType
static YDisplay * FindDisplay(string func)
virtual ~YDisplayLayer()
Y_ORIENTATION_enum _orientation
int setCommand(const string &newval)
int _displayHeight
static const string STARTUPSEQ_INVALID
YDisplay * next(void)
int layerWidth(void)
static YDisplay * Find(string func)
Y_ENABLED_enum
Definition: yocto_display.h:56
Y_ENABLED_enum _enabled
#define YAPI_INVALID_UINT
Definition: yocto_api.h:71
int setEnabled(Y_ENABLED_enum newval)
string _command
int displayWidth(void)
virtual int _parseAttr(YJSONObject *json_val)
Definition: yocto_api.cpp:2367
int displayHeight(void)
int layerHeight(void)
int brightness(void)
int _layerWidth
static YDisplay * First(void)
int setOrientation(Y_ORIENTATION_enum newval)
int _brightness
string command(void)
int setStartupSeq(const string &newval)
static const string COMMAND_INVALID
Y_ALIGN
Definition: yocto_display.h:94
string startupSeq(void)
int _layerCount
int setBrightness(int newval)
int layerCount(void)
static int upload(const char *hubserial, const char *subpath, const char *filename, u8 *data, u32 data_len, char *errmsg)
Definition: yprog.c:1631
virtual int registerValueCallback(YFunctionValueCallback callback)
Definition: yocto_api.cpp:2544
bool _recording
YDisplay * _display
int _displayWidth
YDisplayValueCallback _valueCallbackDisplay
#define YOCTO_CLASS_EXPORT
Definition: yocto_api.h:61
string _sequence
Y_ORIENTATION_enum
Definition: yocto_display.h:64
Y_DISPLAYTYPE_enum
Definition: yocto_display.h:74
static YDisplay * FirstDisplay(void)
Y_DISPLAYTYPE_enum displayType(void)
vector< YDisplayLayer * > _allDisplayLayers
virtual int _invokeValueCallback(string value)
Definition: yocto_api.cpp:2563
YDisplay * yFirstDisplay(void)


yoctopuce_altimeter
Author(s): Anja Sheppard
autogenerated on Mon Jun 10 2019 15:49:11