11. Using Yocto-Display with C++
C++ is not the simplest language to master. However, if you take care to limit yourself to its essential
functionalities, this language can very well be used for short programs quickly coded, and it has the
advantage of being easily ported from one operating system to another. Under Windows, all the
examples and the project models are tested with Microsoft Visual Studio 2010 Express, freely
available on the Microsoft web site
1
. Under Mac OS X, all the examples and project models are
tested with XCode 4, available on the App Store. Moreover, under Max OS X and under Linux, you
can compile the examples using a command line with GCC using the provided
GNUmakefile
. In
the same manner under Windows, a
Makefile
allows you to compile examples using a command
line, fully knowing the compilation and linking arguments.
Yoctopuce C++ libraries
2
are integrally provided as source files. A section of the low-level library is
written in pure C, but you should not need to interact directly with it: everything was done to ensure
the simplest possible interaction from C++. The library is naturally also available as binary files, so
that you can link it directly if you prefer.
You will soon notice that the C++ API defines many functions which return objects. You do not need
to deallocate these objects yourself, the API does it automatically at the end of the application.
In order to keep them simple, all the examples provided in this documentation are console
applications. Naturally, the libraries function in a strictly identical manner if you integrate them in an
application with a graphical interface. You will find in the last section of this chapter all the information
needed to create a wholly new project linked with the Yoctopuce libraries.
11.1. Control of the Display function
A few lines of code are enough to use a Yocto-Display. Here is the skeleton of a C++ code snipplet
to use the Display function.
#include "yocto_api.h"
#include "yocto_display.h"
[
...
]
String errmsg
;
YDisplay
*
display
;
// Get access to your device, connected locally on USB for instance
yRegisterHub
(
"usb"
, errmsg
);
display
=
yFindDisplay
(
"YD128X32-123456.display"
);
1
http://www.microsoft.com/visualstudio/en-us/products/2010-editions/visual-cpp-express
2
www.yoctopuce.com/EN/libraries.php
www.yoctopuce.com
57
Summary of Contents for Yocto-Display
Page 1: ...Yocto Display User Manual...
Page 2: ......
Page 40: ...34 www yoctopuce com...
Page 52: ...46 www yoctopuce com...
Page 84: ...78 www yoctopuce com...
Page 92: ...86 www yoctopuce com...
Page 130: ...124 www yoctopuce com...
Page 422: ...416 www yoctopuce com...