}
There are only a few really important lines in this example. We will look at them in details.
yocto_api.h et yocto_display.h
These two import files provide access to the functions allowing you to manage Yoctopuce modules.
yocto_api.h
must always be used,
yocto_display.h
is necessary to manage modules
containing a display, such as Yocto-Display.
[YAPI RegisterHub]
The
[YAPI RegisterHub]
function initializes the Yoctopuce API and indicates where the
modules should be looked for. When used with the parameter
@"usb"
, it will use the modules
locally connected to the computer running the library. If the initialization does not succeed, this
function returns a value different from
YAPI_SUCCESS
and
errmsg
contains the error message.
[Display FindDisplay]
The
[Display FindDisplay]
function allows you to find a display from the serial number of the
module on which it resides and from its function name. You can use logical names as well, as long
as you have initialized them. Let us imagine a Yocto-Display module with serial number
YD128X32-123456
which you have named "
MyModule
", and for which you have given the
display
function the name "
MyFunction
". The following five calls are strictly equivalent, as long as
"
MyFunction
" is defined only once.
YDisplay
*
display
=
[
Display FindDisplay
:
@"YD128X32-123456.display"
]
;
YDisplay
*
display
=
[
Display FindDisplay
:
@"YD128X32-123456.MyFunction"
]
;
YDisplay
*
display
=
[
Display FindDisplay
:
@"MyModule.display"
]
;
YDisplay
*
display
=
[
Display FindDisplay
:
@"MyModule.MyFunction"
]
;
YDisplay
*
display
=
[
Display FindDisplay
:
@"MyFunction"
]
;
[Display FindDisplay]
returns an object which you can then use at will to control the display.
isOnline
The
isOnline
method of the object returned by
[Display FindDisplay]
allows you to know
if the corresponding module is present and in working order.
get_displayLayer
The
get_displayLayer()
method of the object returned by
YDisplay.FindDisplay
allows
you to retrieve the object corresponding to one of the screen layers. This object implements all the
graphical routines.
12.2. Control of the module part
Each module can be controlled in a similar manner, you can find below a simple sample program
displaying the main parameters of the module and enabling you to activate the localization beacon.
#import <Foundation/Foundation.h>
#import "yocto_api.h"
static
void
usage
(
const
char
*
exe
)
{
NSLog
(
@"usage: %s <serial or logical name> [ON/OFF]
\n
"
, exe
)
;
exit
(
1
)
;
}
int
main
(
int
argc,
const
char
*
argv
[])
{
NSError
*
error;
@autoreleasepool
{
// Setup the API to use local USB devices
12. Using Yocto-Display with Objective-C
www.yoctopuce.com
67
Содержание Yocto-Display
Страница 1: ...Yocto Display User Manual...
Страница 2: ......
Страница 40: ...34 www yoctopuce com...
Страница 52: ...46 www yoctopuce com...
Страница 84: ...78 www yoctopuce com...
Страница 92: ...86 www yoctopuce com...
Страница 130: ...124 www yoctopuce com...
Страница 158: ...22 High level API Reference 152 www yoctopuce com On failure throws an exception or returns a negative error code...
Страница 422: ...416 www yoctopuce com...
Страница 424: ...24 Characteristics 418 www yoctopuce com...