4.2. Limitations .......................... 5. First steps ..........................5.1. Prerequisites ........................5.2. Testing USB connectivity ....................5.3. Localization ........................5.4. Test of the module ......................5.5. Configuration ........................6. Assembly and connections ................... 6.1. Fixing ..........................6.2. USB power distribution ..................... www.yoctopuce.com...
Page 4
12.3. Error handling ........................13. Using Yocto-Display with Visual Basic .NET ............. 13.1. Installation ........................13.2. Using the Yoctopuce API in a Visual Basic project ............13.3. Control of the Display function ..................13.4. Control of the module part ....................
Page 5
14.2. Using the Yoctopuce API in a Visual C# project ............14.3. Control of the Display function ..................14.4. Control of the module part ....................14.5. Error handling ........................15. Using the Yocto-Display with Universal Windows Platform ..... 15.1. Blocking and asynchronous functions ................
Page 6
....................... 23.4. ARM Platforms: HF and EL ................... 23.5. Powered module but invisible for the OS ..............23.6. Another process named xxx is already using yAPI ............ 23.7. Disconnections, erratic behavior ................. 23.8. Damaged device ......................24. Characteristics ......................... www.yoctopuce.com...
The Yocto-Display module The Yocto-Display is not in itself a complete product. It is a component intended to be integrated into a solution used in laboratory equipments, or in industrial process-control equipments, or for similar applications in domestic and commercial environments.
If you intend to use the Yocto-Display for another kind of application, you should check the safety regulations according to the standard applicable to your application. In particular, the Yocto-Display is not certified for use in medical environments or for life-support applications. Environment The Yocto-Display is not certified for use in hazardous locations, explosive environments, or life- threatening applications.
USB connector Yoctopuce modules all come with a USB 2.0 micro-B socket. Warning: the USB connector is simply soldered in surface and can be pulled out if the USB plug acts as a lever. In this case, if the tracks stayed in position, the connector can be soldered back with a good iron and using flux to avoid bridges.
The screen is an OLED screen manufactured by WiseChip under the UG-2832ALBCG01 reference. Being made of glass, it is rather fragile. Do not let your Yocto-Display drop. When you install your Yocto-Display, make sure that the screen is not subjected to any mechanical constraint. Moreover, the ribbon coming out of the screen is particularly fragile at its junction with the screen.
Screws and spacers In order to mount the Yocto-Display module, you can put small screws in the 3mm assembly holes, with a screw head no larger than 8mm. The best way is to use threaded spacers, which you can then mount wherever you want.
Page 12
VirtualHub. 1.27mm (or 1.25mm) connectors In case you wish to connect your Yocto-Display to a Micro-hub USB or a YoctoHub without using a bulky USB connector, you can use the four 1.27mm pads just behind the USB connector. There are two options.
Thus, to draw a line, the host computer only needs to send a draw a line command to the Yocto-Display. It does not have to do anything else, everything is managed by the Yocto-Display processor. For this reason, the Yocto-Display behaves a little like a graphic accelerator where the graphical tasks are performed by a dedicated processor, letting the main processor perform other tasks.
Yocto-Display to build a bitmap in memory, then render it with a single command on the layer of your choice. The Yoctopuce API is fast enough to make this possible even to make real-time animations.
8x8.yfm Console mode There is another method to display text on your Yocto-Display: the console mode. The console is a rectangular area of which you can parameterize the position. Texts displayed in this console are displayed like in a terminal, and line feeds are automatically generated. By default, the console size of each layer is initialized to the size of the screen.
Your Yocto-Display contains a few embedded fonts, but it is designed so that you could create your own fonts as easily as possible. A font file for your Yocto-Display is mostly a large bitmap where all the characters are drawn one after the other, in the order of the ASCII code of each character.
When you are done recording the sequence components, call saveSequence. The sequence is then saved in the Yocto-Display file system. You can play it back at will with playSequence. You can create loops by calling playSequence within a sequence.
Page 18
Here is the C code allowing you to draw a pixel at the (x,y) coordinates in the byte array representing a w x h bitmap. void putpixel(unsigned char *data, int x, int y) int bytesPerLine = (w + 7) >> 3; data[ (x >> 3) + (y * bytesPerLine) ] |= 128 >> (x & 7); Prog-Display-DoubleBuffering Prog-Display-DrawBitmap www.yoctopuce.com...
"123456789" is 0xCBF43926. HTTP usage You can access the files that your have downloaded on your Yocto-Display by HTTP, at the root of the module (at the same level as the REST API). This allows you to load personalized HTML and...
4.2. Limitations The file system embedded on your Yocto-Display has some technical limitations: • Its maximal storage space is 3.5MB, allocated in blocks enabling to store up to about 128 files.
5. First steps By design, all Yoctopuce modules are driven the same way. Therefore, user's guides for all the modules of the range are very similar. If you have already carefully read through the user's guide of another Yoctopuce module, you can jump directly to the description of the module functions.
The most common USB 2.0 connectors: A, B, Mini B, Micro A, Micro B To connect your Yocto-Display module to a computer, you need a USB 2.0 cable of type A-micro B. The price of this cable may vary a lot depending on the source, look for it under the name USB 2.0 A to micro B Data cable.
5.4. Test of the module The first item to check is that your module is working well: click on the serial number corresponding to your module. This displays a window summarizing the properties of your Yocto-Display. Properties of the Yocto-Display module This window allows you, among other things, to display an arbitrary text on the screen and to check the state of the anButtons inputs.
Page 24
Logical names of functions Each Yoctopuce module has a serial number and a logical name. In the same way, each function on each Yoctopuce module has a hardware name and a logical name, the latter can be freely chosen by the user.
Examples of assembly on supports The Yocto-Display module contains 3mm assembly holes. You can use these holes for screws. The screw head diameter must not be larger than 8mm or they will damage the module circuits. Make sure that the lower surface of the module is not in contact with the support.
Page 26
2000mA, it actually works in every day life, and seldom makes hardware damage. What you should remember: if you connect Yoctopuce modules through one, or more, USB hub without external power supply, you have no safe-guard and you depend entirely on your computer manufacturer attention to provide as much current as possible on the USB ports, and to detect overloads before they lead to problems or to hardware damages.
The Yoctopuce API was designed to be at the same time simple to use and sufficiently generic for the concepts used to be valid for all the modules in the Yoctopuce range, and this in all the available programming languages. Therefore, when you have understood how to drive your Yocto-Display with your favorite programming language, learning to use another module, even with a different language, will most likely take you only a minimum of time.
Page 28
YSensor, it will work with all Yoctopuce sensors, even those which do no yet exist. Programmation In the Yoctopuce API, priority was put on the ease of access to the module functions by offering the possibility to make abstractions of the modules implementing them. Therefore, it is quite possible to work with a set of functions without ever knowing exactly which module are hosting them at the hardware level.
7.2. The Yocto-Display module The Yocto-Display is a 128x32 OLED display. It includes a flash-based filesystem to store files (such as images, fonts and animated sequences) and six instances of the AnButton function, corresponding to the six analog inputs (potentiometer or button reading) present on the module.
7.3. Module control interface This interface is identical for all Yoctopuce USB modules. It can be used to control the module global parameters, and to enumerate the functions provided by each module. productName Character string containing the commercial name of the module, as set by the factory.
32bit integer variable available for user storage. 7.4. Display function interface 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).
7.5. AnButton function interface Yoctopuce application programming interface allows you to measure the state of a simple button as well as to read an analog potentiometer (variable resistance). This can be use for instance with a continuous rotating knob, a throttle grip or a joystick.
19 characters among , and advertisedValue Short character string summarizing the current state of the filesystem, that is automatically advertised up to the parent hub. For a filesystem, the advertised value is the number of files loaded in the filesystem. www.yoctopuce.com...
Free space for uploading new files to the filesystem, in bytes. 7.7. What interface: Native, DLL or Service ? There are several methods to control you Yoctopuce module by software. Native control In this case, the software driving your project is compiled directly with a library which provides control of the modules.
Page 35
Some languages do simply not allow you to easily gain access to the hardware layers of the machine. It is the case for Javascript, for instance. To deal with this case, Yoctopuce provides a solution in the form of a small piece of software called VirtualHub .
7.8. Programming, where to start? At this point of the user's guide, you should know the main theoretical points of your Yocto-Display. It is now time to practice. You must download the Yoctopuce library for your favorite programming language from the Yoctopuce web site .
8. Using the Yocto-Display in command line When you want to perform a punctual operation on your Yocto-Display, such as reading a value, assigning a logical name, and so on, you can obviously use the Virtual Hub, but there is a simpler, faster, and more efficient method: the command line API.
/help to obtain a detailed description of the parameters of a command. 8.3. Control of the Display function To control the Display function of your Yocto-Display, you need the YDisplay executable file. For instance, you can launch: C:\>YDisplay -layer 0 drawText 64 32 CENTER "Hello world!"...
8. Using the Yocto-Display in command line C:\>YModule describe Each property of the module can be obtained thanks to a command of the type, get_xxxx() and the properties which are not read only can be modified with the command. For...
EcmaScript 2017 to differentiate it from the previous Library for JavaScript, now deprecated in favor of this new version. This library provides access to Yoctopuce devices for modern JavaScript engines. It can be used within a browser as well as with Node.js. The library will automatically detect upon initialization whether the runtime environment is a browser or a Node.js virtual machine, and use the most...
JavaScript is one of those languages which do not generally allow you to directly access the hardware layers of your computer. Therefore the library can only be used to access network-enabled devices (connected through a YoctoHub), or USB devices accessible through Yoctopuce TCP/IP to USB gateway, named VirtualHub.
Page 43
For HTML examples, it is even simpler: there is nothing to install. Each example is a single HTML file that you can open in a browser to try it. In this context, loading the Yoctopuce library is no different from any standard HTML script include tag.
You can also rewrite this last asynchronous call as: myModule.get_syncProxy().then(logInfoProxy); 9.3. Control of the Display function A few lines of code are enough to use a Yocto-Display. Here is the skeleton of a JavaScript code snipplet to use the Display function. // For Node.js, we use function require() // For HTML, we would use <script src="...">...
Page 45
If your Yocto-Display is not connected on the host running the browser, replace in the example the address by the IP address of the host on which the Yocto-Display is connected and 127.0.0.1...
Page 46
9. Using Yocto-Display with JavaScript / EcmaScript async function startDemo() { await YAPI.LogUnhandledPromiseRejections(); await YAPI.DisableExceptions(); // Setup the API to use the VirtualHub on local machine errmsg = new YErrorMsg(); if (await YAPI.RegisterHub('127.0.0.1', errmsg) != YAPI.SUCCESS) { console.log('Cannot contact VirtualHub on 127.0.0.1: ' + errmsg.msg);...
Page 47
If you want to see how to use the library within a browser rather than with Node.js, switch to the directory example_html/Doc-GettingStarted-Yocto-Display. You will find there a single HTML file, with a JavaScript section similar to the code above, but with a few changes since it has to interact through an HTML page rather than through the JavaScript console.
Inevitably, there will be a time when a user will have unplugged the device, either before running the software, or even while the software is running. The Yoctopuce library is designed to help you support this kind of behavior, but your code must nevertheless be conceived to interpret in the best possible way the errors indicated by the library.
Page 51
The method recommended by most programming languages for unpredictable error handling is the use of exceptions. By default, it is the behavior of the Yoctopuce library. If an error happens while you try to access a module, the library throws an exception. In this case, there are three possibilities: •...
VirtualHub software, and you are ready to start your first tests. You do not need to install any driver. 10.2. Control of the Display function A few lines of code are enough to use a Yocto-Display. Here is the skeleton of a PHP code snipplet to use the Display function. include('yocto_api.php');...
Page 54
(the standard port used by 127.0.0.1:4444 4444 Yoctopuce). You can very well modify this address, and enter the address of another machine on which the VirtualHub software is running. yFindDisplay function allows you to find a display from the serial number of the module on yFindDisplay which it resides and from its function name.
10. Using Yocto-Display with PHP <HTML> <HEAD> <TITLE>Hello World</TITLE> </HEAD> <BODY> <FORM method='get'> <?php include('yocto_api.php'); include('yocto_display.php'); // Use explicit error handling rather than exceptions yDisableExceptions(); // Setup the API to use the VirtualHub on local machine if(yRegisterHub('http://127.0.0.1:4444/',$errmsg) != YAPI_SUCCESS) { die("Cannot contact VirtualHub on...
Page 56
10. Using Yocto-Display with PHP // Use explicit error handling rather than exceptions yDisableExceptions(); // Setup the API to use the VirtualHub on local machine if(yRegisterHub('http://127.0.0.1:4444/',$errmsg) != YAPI_SUCCESS) { die("Cannot contact VirtualHub on 127.0.0.1 : ".$errmsg); @$serial = $_GET['serial']; ($serial...
Page 57
10. Using Yocto-Display with PHP <BODY> <FORM method='get'> <?php include('yocto_api.php'); // Use explicit error handling rather than exceptions yDisableExceptions(); // Setup the API to use the VirtualHub on local machine if(yRegisterHub('http://127.0.0.1:4444/',$errmsg) != YAPI_SUCCESS) { die("Cannot contact VirtualHub on 127.0.0.1"); @$serial = $_GET['serial'];...
The PHP library is able to work in a specific mode called HTTP callback Yocto-API. With this mode, you can control Yoctopuce devices installed behind a NAT filter, such as a DSL router for example, and this without needing to open a port. The typical application is to control Yoctopuce devices, located on a private network, from a public web site.
Page 59
10. Using Yocto-Display with PHP Responses from request from LAN machines are routed. But requests from the outside are blocked. Seeing Internet without being seen provides an enormous security advantage. However, this signifies that you cannot, a priori, set up your own web server at home to control a home automation installation from the outside.
Page 60
10. Using Yocto-Display with PHP You must configure the VirtualHub so that it calls the PHP script on a regular basis. To do so: 1. Launch a VirtualHub 2. Access its interface, usually 127.0.0.1:4444 3. Click on the configure button of the line corresponding to the VirtualHub itself 4.
To code a web site which controls Yoctopuce modules interactively, you must create a user interface which stores in a file or in a database the actions to be performed on the Yoctopuce modules. These actions are then read and run by the control script.
Page 62
The method recommended by most programming languages for unpredictable error handling is the use of exceptions. By default, it is the behavior of the Yoctopuce library. If an error happens while you try to access a module, the library throws an exception. In this case, there are three possibilities: •...
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.
Page 64
// Use display->get_displayLayer(), ... Let's look at these lines in more details. yocto_api.h et yocto_display.h These two include files provide access to the functions allowing you to manage Yoctopuce modules. must always be used, is necessary to manage modules yocto_api.h yocto_display.h...
Page 65
11. Using Yocto-Display with C++ static void usage(void) cout << "Wrong command line arguments" << endl; cout << "usage: demo <serial_number>" << endl; cout << " demo <logical_name>" << endl; cout << " demo any (use any discovered device)" << endl;...
11. Using Yocto-Display with C++ l1->clear(); l1->drawCircle(h 8, h 8, h / 8); // and animate the layer cout << "Use Ctrl-C to stop"; = 0; = 0; = 1; = 1; while (disp->isOnline()) { += vx; += vy; < 0) || >...
Page 67
11. Using Yocto-Display with C++ cout << "USB current: " << module->get_usbCurrent() << " mA" << endl; cout << "Logs:" << endl << module->get_lastLogs() << endl; } else { cout << argv[1] << " not connected (check identification and USB cable)"...
The method recommended by most programming languages for unpredictable error handling is the use of exceptions. By default, it is the behavior of the Yoctopuce library. If an error happens while you try to access a module, the library throws an exception. In this case, there are three possibilities: •...
• It guaranties the respect of the compilation conventions of your project (32/64 bits, inclusion of debugging symbols, unicode or ASCII characters, etc.); • It facilitates debugging if you are looking for the cause of a problem linked to the Yoctopuce library;...
Page 70
11. Using Yocto-Display with C++ Then, for you project to build correctly, you need to link with your project the Yoctopuce library and the prerequisite system libraries: • For Windows: yocto-static.lib • For Mac OS X: libyocto-static.a, IOKit.framework, and CoreFoundation.framework •...
Lion. If you are still under Snow Leopard, you need to be registered as Apple developer to be able to download XCode 4.2. The Yoctopuce library is ARC compatible. You can therefore implement your projects either using the traditional retain / release method, or using the Automatic Reference Counting.
Page 72
12. Using Yocto-Display with Objective-C NSError *error; YDisplay *disp; YDisplayLayer *l0, *l1; h, w, y, x, vx, vy; @autoreleasepool { // Setup the API to use local USB devices if([YAPI RegisterHub:@"usb": &error] != YAPI_SUCCESS) { NSLog(@"RegisterHub error: %@", [error localizedDescription]);...
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. must always be used, is necessary to manage modules yocto_api.h...
Page 74
12. Using Yocto-Display with Objective-C if([YAPI RegisterHub:@"usb": &error] != YAPI_SUCCESS) { NSLog(@"RegisterHub error: %@", [error localizedDescription]); return if(argc < usage(argv[0]); NSString *serial_or_name [NSString stringWithUTF8String:argv[1]]; // use serial or logical name YModule *module [YModule FindModule:serial_or_name]; ([module isOnline]) { (argc > 2) { (strcmp(argv[2], "ON") == 0)
When you implement a program which must interact with USB modules, you cannot disregard error handling. Inevitably, there will be a time when a user will have unplugged the device, either before running the software, or even while the software is running. The Yoctopuce library is designed to help www.yoctopuce.com...
Page 76
The method recommended by most programming languages for unpredictable error handling is the use of exceptions. By default, it is the behavior of the Yoctopuce library. If an error happens while you try to access a module, the library throws an exception. In this case, there are three possibilities: •...
Yoctopuce modules that your project is going to manage. If in doubt, select all the files. You then have the choice between simply adding these files to your project, or to add them as links (the Add button is in fact a scroll-down menu).
Naturally, the libraries function in a strictly identical manner if you integrate them in an application with a graphical interface. 13.3. Control of the Display function A few lines of code are enough to use a Yocto-Display. Here is the skeleton of a Visual Basic code snipplet to use the Display function. [...]...
Page 79
13. Using Yocto-Display with Visual Basic .NET A real example Launch Microsoft VisualBasic and open the corresponding sample project provided in the directory Examples/Doc-GettingStarted-Yocto-Display of the Yoctopuce library. In this example, you will recognize the functions explained above, but this time used with all side materials needed to make it work nicely as a small demo.
13. Using Yocto-Display with Visual Basic .NET l0.lineTo(w 6, h - 1) l0.moveTo(w l0.lineTo(w l0.lineTo(w draw a circle the top left corner layer = disp.get_displayLayer(1) l1.clear() l1.drawCircle(CInt(h 8), CInt(h 8), CInt(h / 8)) REM and animate the layer Console.WriteLine("Use Ctrl-C to stop")
Page 81
13. Using Yocto-Display with Visual Basic .NET Console.WriteLine("upTime: " + Str(m.get_upTime() / 1000) + " sec") Console.WriteLine("USB current: " + Str(m.get_usbCurrent()) + " mA") Console.WriteLine("Logs:") Console.WriteLine(m.get_lastLogs()) Else Console.WriteLine(argv(1) + " not connected (check identification and USB cable)") End If yFreeAPI()
The method recommended by most programming languages for unpredictable error handling is the use of exceptions. By default, it is the behavior of the Yoctopuce library. If an error happens while you try to access a module, the library throws an exception. In this case, there are three possibilities: •...
Page 83
13. Using Yocto-Display with Visual Basic .NET follows the same logic: a method returns a value, a get_state() Y_STATE_INVALID method returns a value, and so on. In any get_currentValue Y_CURRENTVALUE_INVALID case, the returned value is of the expected type and is not a null pointer which would risk crashing your program.
14.2. Using the Yoctopuce API in a Visual C# project The Visual C#.NET Yoctopuce library is composed of a DLL and of source files in Visual C#. The DLL is not a .NET DLL, but a classic DLL, written in C, which manages the low level communications with the modules .
Naturally, the libraries function in a strictly identical manner if you integrate them in an application with a graphical interface. 14.3. 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. [...]...
Page 87
14. Using Yocto-Display with C# get_displayLayer method of the object returned by allows get_displayLayer() YDisplay.FindDisplay you to retrieve the object corresponding to one of the screen layers. This object implements all the graphical routines. A real example Launch Microsoft Visual C# and open the corresponding sample project provided in the directory Examples/Doc-GettingStarted-Yocto-Display of the Yoctopuce library.
14. Using Yocto-Display with C# l0.drawText(w 2, h 2, YDisplayLayer.ALIGN.CENTER, "Hello world!"); // visualize each corner l0.moveTo(0, l0.lineTo(0, l0.lineTo(5, l0.moveTo(0, h - 6); l0.lineTo(0, h - 1); l0.lineTo(5, h - 1); l0.moveTo(w 1, h - 6); l0.lineTo(w 1, h - 1);...
Page 89
14. Using Yocto-Display with C# (args.Length < 1) usage(); = YModule.FindModule(args[0]); // use serial or logical name if (m.isOnline()) { (args.Length >= 2) { if (args[1].ToUpper() == "ON") { m.set_beacon(YModule.BEACON_ON); if (args[1].ToUpper() == "OFF") { m.set_beacon(YModule.BEACON_OFF); Console.WriteLine("serial: " + m.get_serialNumber());...
Page 90
14. Using Yocto-Display with C# (args.Length != 2) usage(); (YAPI.RegisterHub("usb", ref errmsg) != YAPI.SUCCESS) { Console.WriteLine("RegisterHub error: " + errmsg); Environment.Exit(0); = YModule.FindModule(args[0]); // use serial or logical name if (m.isOnline()) { newname = args[1]; if (!YAPI.CheckLogicalName(newname)) { Console.WriteLine("Invalid name ("...
The method recommended by most programming languages for unpredictable error handling is the use of exceptions. By default, it is the behavior of the Yoctopuce library. If an error happens while you try to access a module, the library throws an exception. In this case, there are three possibilities: •...
However, using the new UWP API has some consequences: the Windows Runtime API to access the USB ports is asynchronous, and therefore the Yoctopuce library must be asynchronous as well. Concretely, the asynchronous methods do not return a result directly but a...
USB_DEVICE_ID section. Finally, the "Device" node must contain a "Function" node with the "Type" attribute with a value of "usage:ff00 0001". For the Yocto-Display, here is what you must add in the "Capabilities" node: <DeviceCapability Name="humaninterfacedevice"> <!-- Yocto-Display --> <Device Id="vidpid:24e0 002D">...
15.4. 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 snippet to use the Display function.
Page 96
Visual Studio projects contain numerous files, and most of them are not linked to the use of the Yoctopuce library. To simplify reading the code, we regrouped all the code that uses the library in the class, located in the file.
15. Using the Yocto-Display with Universal Windows Platform = await disp.get_displayLayer(1); await l1.clear(); await l1.drawCircle(h 8, h 8, h / 8); // and animate the layer = 0; = 0; = 1; = 1; while (await disp.isOnline()) { += vx;...
Page 98
15. Using the Yocto-Display with Universal Windows Platform WriteLine("upTime: " + (await m.get_upTime() / 1000) + " sec"); WriteLine("USB current: " + await m.get_usbCurrent() + " mA"); WriteLine("Logs:\r\n" + await m.get_lastLogs()); } else { WriteLine(Target " not connected on" HubURL "(check identification and USB...
Inevitably, there will be a time when a user will have unplugged the device, either before running the software, or even while the software is running. The Yoctopuce library is designed to help you support this kind of behavior, but your code must nevertheless be conceived to interpret in the best possible way the errors indicated by the library.
Page 100
15. Using the Yocto-Display with Universal Windows Platform try { ..} catch (YAPI_Exception ex) { Debug.WriteLine("Exception from Yoctopuce lib:" + ex.Message); } catch (Exception ex) { Debug.WriteLine("Other exceptions :" + ex.Message); www.yoctopuce.com...
Delphi libraries. By default, the Yoctopuce Delphi library uses the yapi.dll DLL, all the applications you will create with Delphi must have access to this DLL. The simplest way to ensure this is to make sure yapi.dll is located in the same directory as the executable file of your application.
Page 102
16. Using Yocto-Display with Delphi Procedure Usage(); exe : string; begin exe:= ExtractFileName(paramstr(0)); WriteLn(exe+' <serial_number>'); WriteLn(exe+' <logical_name>'); WriteLn(exe+' any'); sleep(2500); halt; End; disp : TYDisplay; l0,l1 : TYDisplayLayer; errmsg : string; : integer; x,y,vx,vy :integer; begin if (paramcount<1) then usage();...
There are only a few really important lines in this sample example. We will look at them in details. yocto_api and yocto_display These two units provide access to the functions allowing you to manage Yoctopuce modules. must always be used,...
Page 104
16. Using Yocto-Display with Delphi const serial = 'YD128X32-123456'; // use serial number or logical name procedure refresh(module:Tymodule) begin if (module.isOnline()) then begin Writeln(''); Writeln('Serial + module.get_serialNumber()); Writeln('Logical name : ' + module.get_logicalName()); Writeln('Luminosity + intToStr(module.get_luminosity())); Write('Beacon :'); (module.get_beacon()=Y_BEACON_ON) then Writeln('on') else Writeln('off');...
Page 105
16. Using Yocto-Display with Delphi SysUtils, yocto_api; const serial = 'YD128X32-123456'; // use serial number or logical name module : TYModule; errmsg : string; newname : string; begin // Setup the API to use local USB devices yRegisterHub('usb', errmsg)<>YAPI_SUCCESS then...
The method recommended by most programming languages for unpredictable error handling is the use of exceptions. By default, it is the behavior of the Yoctopuce library. If an error happens while you try to access a module, the library throws an exception. In this case, there are three possibilities: •...
Naturally, the libraries function in a strictly identical manner if you integrate them in an application with a graphical interface. 17.3. Control of the Display function A few lines of code are enough to use a Yocto-Display. Here is the skeleton of a Python code snipplet to use the Display function. http://www.python.org/download/ www.yoctopuce.com/EN/libraries.php...
Page 108
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".
Page 109
17. Using the Yocto-Display with Python scriptname = os.path.basename(sys.argv[0]) print("Usage:") print(scriptname + <serial_number>') print(scriptname + <logical_name>') print(scriptname + ' any sys.exit() die(msg): sys.exit(msg + ' (check USB cable)') errmsg = YRefParam() if len(sys.argv) < usage() target = sys.argv[1] # Setup the API to use local USB devices if YAPI.RegisterHub("usb", errmsg) !=...
17. Using the Yocto-Display with Python < > h - (h / 4): l1.setLayerPosition(x, y, 0) YAPI.Sleep(5, errmsg) YAPI.FreeAPI() 17.4. 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.
Inevitably, there will be a time when a user will have unplugged the device, either before running the software, or even while the software is running. The Yoctopuce library is designed to help you support this kind of behavior, but your code must nevertheless be conceived to interpret in the best possible way the errors indicated by the library.
Page 112
The method recommended by most programming languages for unpredictable error handling is the use of exceptions. By default, it is the behavior of the Yoctopuce library. If an error happens while you try to access a module, the library throws an exception. In this case, there are three possibilities: •...
Naturally, the libraries function in a strictly identical manner if you integrate them in an application with a graphical interface. 18.2. Control of the Display function A few lines of code are enough to use a Yocto-Display. Here is the skeleton of a Java code snippet to use the Display function. [...] // Get access to your device, connected locally on USB for instance YAPI.RegisterHub("127.0.0.1");...
Page 114
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".
Page 115
18. Using the Yocto-Display with Java public static void main(String[] args) YDisplay disp; YDisplayLayer h, w, y, x, vx, // API init try { // setup the API to use local VirtualHub YAPI.RegisterHub("127.0.0.1"); } catch (YAPI_Exception ex) { System.out.println("Cannot contact VirtualHub on 127.0.0.1 ("...
18. Using the Yocto-Display with Java YAPI.Sleep(5); } catch (YAPI_Exception ex) { System.out.println("Exception durring execution (" + ex.getLocalizedMessage() + ")"); YAPI.FreeAPI(); System.exit(1); 18.3. 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.
Page 117
18. Using the Yocto-Display with Java Each property of the module can be read thanks to a method of type YModule.get_xxxx() and properties which are not read-only can be modified with the help of the YModule.set_xxx() method. For more details regarding the used functions, refer to the API chapters.
Inevitably, there will be a time when a user will have unplugged the device, either before running the software, or even while the software is running. The Yoctopuce library is designed to help you support this kind of behavior, but your code must nevertheless be conceived to interpret in the best possible way the errors indicated by the library.
In an ideal world, you would only need to have a smart phone running under Android to be able to make Yoctopuce modules work. Unfortunately, it is not quite so in the real world. A machine running under Android must fulfil to a few requirements to be able to manage Yoctopuce USB modules natively.
The user can deny or authorize access to the device. If the user authorizes the access, the application can access the connected device as long as Yoctohubs are a plug and play way to add network connectivity to your Yoctopuce devices. more info on http:// www.yoctopuce.com/EN/products/category/extensions-and-networking...
Page 121
This file contains a list of USB vendorId and deviceID in decimal. The following example runs the application as soon as a Yocto-Relay or a YoctoPowerRelay is connected. You can find the vendorID and the deviceID of Yoctopuce modules in the characteristics section of the documentation.
19. Using the Yocto-Display with Android 19.5. Control of the Display function A few lines of code are enough to use a Yocto-Display. Here is the skeleton of a Java code snippet to use the Display function. [...] // Retrieving the object representing the module (connected here locally by USB) YAPI.EnableUSBHost(this);...
Page 123
19. Using the Yocto-Display with Android A real example Launch you Java environment and open the corresponding sample project provided in the directory Examples//Doc-Examples of the Yoctopuce library. In this example, you can recognize the functions explained above, but this time used with all the side materials needed to make it work nicely as a small demo.
19. Using the Yocto-Display with Android updateDisplay(null); @Override public void onNothingSelected(AdapterView<?> arg0) public void updateDisplay(View view) (display == null) return; EditText message = (EditText) findViewById(R.id.editText1); // clean up try { display.resetAll(); // retreive the display size = display.get_displayWidth(); = display.get_displayHeight();...
Page 125
19. Using the Yocto-Display with Android private ArrayAdapter<String> aa; private YModule module = null; @Override public void onCreate(Bundle savedInstanceState) super.onCreate(savedInstanceState); setContentView(R.layout.modulecontrol); Spinner my_spin = (Spinner) findViewById(R.id.spinner1); my_spin.setOnItemSelectedListener(this); = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item); aa.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); my_spin.setAdapter(aa); @Override protected void onStart() super.onStart(); try { aa.clear();...
Page 126
19. Using the Yocto-Display with Android @Override public void onNothingSelected(AdapterView<?> arg0) public void refreshInfo(View view) DisplayModuleInfo(); public void toggleBeacon(View view) (module == null) return; boolean = ((Switch) view).isChecked(); try { if (on) { module.setBeacon(YModule.BEACON_ON); } else { module.setBeacon(YModule.BEACON_OFF); } catch...
Page 127
19. Using the Yocto-Display with Android = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item); aa.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); my_spin.setAdapter(aa); @Override protected void onStart() super.onStart(); try { aa.clear(); YAPI.EnableUSBHost(this); YAPI.RegisterHub("usb"); YModule = YModule.FirstModule(); while != null) { String hwid = r.get_hardwareId(); aa.add(hwid); = r.nextModule(); } catch (YAPI_Exception e) { e.printStackTrace();...
Page 128
19. Using the Yocto-Display with Android ex.printStackTrace(); DisplayModuleInfo(); Warning: the number of write cycles of the nonvolatile memory of the module is limited. When this limit is reached, nothing guaranties that the saving process is performed correctly. This limit, linked to the technology employed by the module micro-processor, is located at about 100000 cycles.
Inevitably, there will be a time when a user will have unplugged the device, either before running the software, or even while the software is running. The Yoctopuce library is designed to help you support this kind of behavior, but your code must nevertheless be conceived to interpret in the best possible way the errors indicated by the library.
To be warned as soon as a module is connected, you need three pieces of code. The callback The callback is the function which is called each time a new Yoctopuce module is connected. It takes as parameter the relevant module. static void deviceArrival(YModule Console.WriteLine("New module...
Page 132
A classis issue of callback programming is that these callbacks can be triggered at any time, including at times when the main program is not ready to receive them. This can have undesired side effects, such as dead-locks and other race conditions. Therefore, in the Yoctopuce API, module arrival/departure callbacks are called only when the function is running.
(JavaScript, PHP, Java, ...). In fact, the VirtualHub is a small web server able to route HTTP requests to Yoctopuce modules. This means that if you can make an HTTP request from your programming language, you can drive Yoctopuce modules, even if this language is not officially supported.
Page 134
Rather logically, attributes can be modified in the same manner. http://127.0.0.1:4444/bySerial/YD128X32-12345/api/display?logicalName=myFunction You can find the list of available attributes for your Yocto-Display at the beginning of the Programming chapter. Accessing Yoctopuce data logger through the REST interface This section only applies to devices with a built-in data logger.
21.3. Using dynamic libraries The low level Yoctopuce API is available under several formats of dynamic libraries written in C. The sources are available with the C++ API. If you use one of these low level libraries, you do not need the VirtualHub anymore.
Page 136
(yapiHTTPRequest(serial,setValue,data,sizeof(dataBuffer),fullsize,errmsg)<0) then begin writeln(errmsg); halt; end; end. Module inventory To perform an inventory of Yoctopuce modules, you need two functions from the dynamic library: int yapiGetAllDevices(int *buffer,int maxsize,int *neededsize,char *errmsg); int yapiGetDeviceInfo(int devdesc,yDeviceSt *infos, char *errmsg); The yapiGetAllDevices function retrieves the list of all connected modules as a list of handles. buffer points to a 32-bit integer array which contains the returned handles.
Page 137
This data structure has the following format: Size Name Type Description (bytes) vendorid Yoctopuce USB ID deviceid Module USB ID devrelease Module version nbinbterfaces int Number of USB interfaces used by the module manufacturer char[]...
21.4. Porting the high level library As all the sources of the Yoctopuce API are fully provided, you can very well port the whole API in the language of your choice. Note, however, that a large portion of the API source code is automatically generated.
22. High-level API Reference This chapter summarizes the high-level API functions to drive your Yocto-Display. Syntax and exact type names may vary from one language to another, but, unless otherwise stated, all the functions are available in every language. For detailed information regarding the types of arguments and return...
22. High-level API Reference 22.1. General functions These general functions should be used to initialize and configure the Yoctopuce library. In most cases, a simple call to function should be enough. The module-specific functions yRegisterHub() should then be used to retrieve an object that provides interaction yFind...()
Page 141
Force a hub discovery, if a callback as been registered with will be called for each net work hub that will respond to the discovery. yUnregisterHub(url) Setup the Yoctopuce library to no more use modules connected on a previously registered machine with RegisterHub. yUpdateDeviceList(errmsg) Triggers a (re)detection of connected Yoctopuce modules.
Page 142
. If you A..Z a..z 0..9 try to configure a logical name with an incorrect string, the invalid characters are ignored. Parameters : a string containing the name to check. name Returns : true false if the name is valid, otherwise. www.yoctopuce.com...
Page 143
YAPI.ClearHTTPCallbackCacheDir() YAPI yClearHTTPCallbackCacheDir() Disables the HTTP callback cache. function yClearHTTPCallbackCacheDir( $bool_removeFiles) This method disables the HTTP callback cache, and can additionally cleanup the cache directory. Parameters : True to clear the content of the cache. bool_removeFiles Returns : nothing. www.yoctopuce.com...
Page 144
DisableExceptions( ) void DisableExceptions( ) def DisableExceptions( ) function yDisableExceptions( ) function DisableExceptions( ) When exceptions are disabled, every function returns a specific error value which depends on its type and which is documented in this reference manual. www.yoctopuce.com...
Page 145
Be aware than when exceptions are enabled, every function that fails triggers an exception. If the exception is not caught by the user code, it either fires the debugger or aborts (i.e. crash) the program. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
Page 146
USB host port of the system. This yRegisterHub("usb") function takes as argument, an object of class android.content.Context (or any subclass). It is not necessary to call this function to reach modules through the network. Parameters : osContext an object of class android.content.Context (or any subclass). www.yoctopuce.com...
Page 147
22. High-level API Reference YAPI.FreeAPI() YAPI yFreeAPI() Frees dynamically allocated memory blocks used by the Yoctopuce library. function yFreeAPI( ) void yFreeAPI( ) +(void) FreeAPI procedure yFreeAPI( ) procedure yFreeAPI( ) void FreeAPI( ) void FreeAPI( ) java void FreeAPI( )
Page 148
22. High-level API Reference YAPI.GetAPIVersion() YAPI yGetAPIVersion() Returns the version identifier for the Yoctopuce library in use. function yGetAPIVersion( ) string yGetAPIVersion( ) +(NSString*) GetAPIVersion function yGetAPIVersion( ): string function yGetAPIVersion( ) As String String GetAPIVersion( ) String GetAPIVersion( )
Page 149
) function GetCacheValidity( ) This method returns the cache validity of all attributes module functions. Note: This function must be called after yInitAPI Returns : an integer corresponding to the validity attributed to the loaded function parameters, in milliseconds www.yoctopuce.com...
Page 150
) As Integer int GetDeviceListValidity( ) int GetDeviceListValidity( ) java Task<int> GetDeviceListValidity( ) def GetDeviceListValidity( ) function yGetDeviceListValidity( ) function GetDeviceListValidity( ) Note: This function must be called after yInitAPI Returns : the number of seconds between each enumeration. www.yoctopuce.com...
Page 151
GetTickCount( ) def GetTickCount( ) function yGetTickCount( ) function GetTickCount( ) This counter can be used to compute delays in relation with Yoctopuce devices, which also uses the millisecond as timebase. Returns : a long integer corresponding to the millisecond counter.
Page 152
This function may signal an error in case there is a communication problem while contacting a module. Parameters : errmsg a string passed by reference to receive any error message. Returns : YAPI_SUCCESS when the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
Page 153
22. High-level API Reference YAPI.InitAPI() YAPI yInitAPI() Initializes the Yoctopuce programming library explicitly. function yInitAPI( mode, errmsg) YRETCODE yInitAPI( int mode, string& errmsg) +(YRETCODE) InitAPI :(int) mode :(NSError**) errmsg function yInitAPI( mode: integer, var errmsg: string): integer function yInitAPI( ByVal...
Page 154
"usb","callback" or the root URL of the hub to monitor a string passed by reference to receive any error message. errmsg Returns : YAPI_SUCCESS when the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
Page 155
RegisterDeviceArrivalCallback( arrivalCallback) function yRegisterDeviceArrivalCallback( $arrivalCallback) function RegisterDeviceArrivalCallback( arrivalCallback) This callback will be invoked while is running. You will have to call this function yUpdateDeviceList on a regular basis. Parameters : arrivalCallback YModule null a procedure taking a parameter, or www.yoctopuce.com...
Page 156
RegisterDeviceRemovalCallback( removalCallback) function yRegisterDeviceRemovalCallback( $removalCallback) function RegisterDeviceRemovalCallback( removalCallback) This callback will be invoked while is running. You will have to call this function yUpdateDeviceList on a regular basis. Parameters : removalCallback YModule null a procedure taking a parameter, or www.yoctopuce.com...
Page 157
API run in "HTTP Callback" mode. This a special mode allowing to take control of Yoctopuce devices through a NAT filter when using a VirtualHub or a networked YoctoHub. You only need to configure your hub to call your server script on a regular basis. This mode is currently available for PHP and Node.JS only.
Page 158
22. High-level API Reference On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
Page 159
URL of the network hub (this URL can be passed to RegisterHub). This callback will be invoked while yUpdateDeviceList is running. You will have to call this function on a regular basis. Parameters : hubDiscoveryCallback a procedure taking two string parameter, the serial www.yoctopuce.com...
Page 160
YAPI.RegisterHubWebsocketCallback() YAPI yRegisterHubWebsocketCallback() Variant to RegisterHub() used to initialize Yoctopuce API on an existing Websocket session, as happens for incoming websocket callbacks. Parameters : node WebSocket object for the incoming websocket callback connection errmsg a string passed by reference to receive any error message.
Page 161
RegisterLogFunction( LogCallback logfun) java void RegisterLogFunction( LogHandler logfun) def RegisterLogFunction( logfun) This callback will be called each time the API have something to say. Quite useful to debug the API. Parameters : logfun a procedure taking a string parameter, or null www.yoctopuce.com...
Page 162
For in this case, it is therefore recommended to manually select the proper architecture by calling before any other call to the library. SelectArchitecture() Parameters : arch "armhf" "armel" A string containing the architecture to use. Possibles value are: "i386" "x86_64" "32bit" "64bit" Returns : nothing. On failure, throws an exception. www.yoctopuce.com...
Page 163
USB traffic. This parameter does not affect value change callbacks Note: This function must be called after yInitAPI Parameters : cacheValidityMs an integer corresponding to the validity attributed to the loaded function parameters, in milliseconds. www.yoctopuce.com...
Page 164
+(void) SetDelegate :(id) object The methods will be invoked while yDeviceArrival yDeviceRemoval is running. You will have to call this function on a regular basis. yUpdateDeviceList Parameters : object an object that must follow the protocol YAPIDelegate , or www.yoctopuce.com...
Page 165
This is particularly useful when a YoctoHub is connected to a GSM network where the traffic is charged. This setting does not affect modules connected by USB, nor the operation of arrival/removal callbacks. Note: This function must be called after yInitAPI Parameters : deviceListValidity number of seconds between each enumeration. www.yoctopuce.com...
Page 166
This folder must exist and the PHP script needs to have write access to it. It is recommended to use a folder that is not published on the Web server since the library will save some data of Yoctopuce devices into this folder. Note: This feature is supported by YoctoHub and VirtualHub since version 27750.
Page 167
(not args supported on Microsoft Internet Explorer). Returns : YAPI_SUCCESS when the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
Page 168
USB packets. A delay of 50 milliseconds is generally enough. In case of doubt, contact Yoctopuce support. To disable USB packets acknowledge, call this function with the value 0. Note: this feature is only available on Android.
Page 169
This function implements a passive waiting loop, meaning that it does not consume CPU cycles significantly. The processor is left available for other threads and processes. During the pause, the library nevertheless reads from time to time information from the Yoctopuce modules by calling , in order to stay up-to-date.
Page 170
"usb","callback" or the root URL of the hub to monitor mstimeout the number of millisecond available to test the connection. a string passed by reference to receive any error message. errmsg Returns : YAPI_SUCCESS when the call succeeds. On failure returns a negative error code. www.yoctopuce.com...
Page 171
TriggerHubDiscovery( ) java Task<int> TriggerHubDiscovery( ) def TriggerHubDiscovery( errmsg=None) Parameters : errmsg a string passed by reference to receive any error message. Returns : YAPI_SUCCESS when the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
Page 172
22. High-level API Reference YAPI.UnregisterHub() YAPI yUnregisterHub() Setup the Yoctopuce library to no more use modules connected on a previously registered machine with RegisterHub. function yUnregisterHub( url) void yUnregisterHub( const string& url) +(void) UnregisterHub :(NSString *) procedure yUnregisterHub( url: string)
Page 173
22. High-level API Reference YAPI.UpdateDeviceList() YAPI yUpdateDeviceList() Triggers a (re)detection of connected Yoctopuce modules. function yUpdateDeviceList( errmsg) YRETCODE yUpdateDeviceList( string& errmsg) +(YRETCODE) UpdateDeviceList :(NSError**) errmsg function yUpdateDeviceList( var errmsg: string): integer function yUpdateDeviceList( ByRef errmsg As String) As YRETCODE YRETCODE UpdateDeviceList( ref string errmsg)
Page 174
22. High-level API Reference YAPI.UpdateDeviceList_async() YAPI yUpdateDeviceList_async() Triggers a (re)detection of connected Yoctopuce modules. function yUpdateDeviceList_async( callback, context) The library searches the machines or USB ports previously registered using , and yRegisterHub() invokes any user-defined callback function in case a change in the list of connected devices is detected.
22. High-level API Reference 22.2. Module control interface This interface is identical for all Yoctopuce USB modules. It can be used to control the module global parameters, and to enumerate the functions provided by each module. In order to use the functions described here, you should include: <script type='text/javascript' src='yocto_api.js'></script>...
Page 176
Returns a list of all the modules that are plugged into the current module. module→get_upTime() Returns the number of milliseconds spent since the module was powered on. module→get_url() Returns the URL used to access the module. module→get_usbCurrent() Returns the current consumed by the module on the USB bus, in milli-amps. module→get_userData() www.yoctopuce.com...
Page 177
Changes the logical name of the module. module→set_luminosity(newval) Changes the luminosity of the module informative leds. module→set_userData(data) Stores a user context provided as argument in the userData attribute of the function. module→set_userVar(newval) Stores a 32 bit value in the device RAM. module→triggerConfigChangeCallback() www.yoctopuce.com...
Page 178
Schedules a module reboot into special firmware update mode. module→updateFirmware(path) Prepares a firmware update of the module. module→updateFirmwareEx(path, force) Prepares a firmware update of the module. module→wait_async(callback, context) Waits for all pending asynchronous commands on the module to complete, and invoke the user-provided callback function. www.yoctopuce.com...
Page 179
Parameters : func a string containing either the serial number or the logical name of the desired module Returns : YModule object allowing you to drive the module or get additional information on the module. www.yoctopuce.com...
Page 180
The search is performed first by hardware name, then by logical name. Parameters : yctx a YAPI context a string that uniquely characterizes the module func Returns : YModule object allowing you to drive the module. www.yoctopuce.com...
Page 181
) function FirstModule( ) Use the method to iterate on the next modules. YModule.nextModule() Returns : YModule null a pointer to a object, corresponding to the first module currently online, or a pointer if there are none. www.yoctopuce.com...
Page 182
Returns : the path of the byn file to use or a empty string if no byn files matches the requirement On failure, throws an exception or returns a string that start with "error:". www.yoctopuce.com...
Page 183
) void clearCache( ) java def clearCache( ) function clearCache( ) function clearCache( ) Invalidates the cache of the module attributes. Forces the next call to get_xxx() or loadxxx() to use values that come from the device. www.yoctopuce.com...
Page 184
) String describe( ) java def describe( ) function describe( ) function describe( ) The text may include either the logical name or the serial number of the module. Returns : a string that describes the module www.yoctopuce.com...
Page 185
$pathname) function download( pathname) YModule target download pathname Parameters : pathname name of the new file to load Returns : a binary buffer with the file content On failure, throws an exception or returns YAPI_INVALID_STRING www.yoctopuce.com...
Page 186
0 for the first function. Returns : a string corresponding to the base type of the function On failure, throws an exception or returns an empty string. www.yoctopuce.com...
Page 187
) As Integer int functionCount( ) int functionCount( ) java def functionCount( ) function functionCount( ) function functionCount( ) Returns : the number of functions on the module On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
Page 188
0 for the first function. Returns : a string corresponding to the unambiguous hardware identifier of the requested module function On failure, throws an exception or returns an empty string. www.yoctopuce.com...
Page 189
0 for the first function. Returns : a string corresponding to the logical name of the requested module function On failure, throws an exception or returns an empty string. www.yoctopuce.com...
Page 190
0 for the first functionIndex function. Returns : a string corresponding to the type of the function On failure, throws an exception or returns an empty string. www.yoctopuce.com...
Page 191
0 for the first function. Returns : a short string (up to 6 characters) corresponding to the advertised value of the requested module function On failure, throws an exception or returns an empty string. www.yoctopuce.com...
Page 192
Useful to backup all the logical names, calibrations parameters, and uploaded files of a device. Returns : a binary buffer with all the settings. On failure, throws an exception or returns an binary object of size 0. www.yoctopuce.com...
Page 193
) java Task<int> get_beacon( ) def get_beacon( ) function get_beacon( ) function get_beacon( ) YModule target get_beacon Returns : either Y_BEACON_OFF Y_BEACON_ON , according to the state of the localization beacon On failure, throws an exception or returns Y_BEACON_INVALID www.yoctopuce.com...
Page 194
) function get_errorMessage( ) function get_errorMessage( ) This method is mostly useful when using the Yoctopuce library with exceptions disabled. Returns : a string corresponding to the latest error message that occured while using this module object www.yoctopuce.com...
Page 195
) function get_errorType( ) function get_errorType( ) This method is mostly useful when using the Yoctopuce library with exceptions disabled. Returns : a number corresponding to the code of the latest error that occurred while using this module object...
Page 196
Task<string> get_firmwareRelease( ) def get_firmwareRelease( ) function get_firmwareRelease( ) function get_firmwareRelease( ) YModule target get_firmwareRelease Returns : a string corresponding to the version of the firmware embedded in the module On failure, throws an exception or returns Y_FIRMWARERELEASE_INVALID www.yoctopuce.com...
Page 197
List<string> get_functionIds( string funType) ArrayList<String> get_functionIds( String funType) java Task<List<string>> get_functionIds( string funType) def get_functionIds( funType) function get_functionIds( $funType) function get_functionIds( funType) YModule target get_functionIds funType Parameters : funType The type of function (Relay, LightSensor, Voltage,...) Returns : an array of strings. www.yoctopuce.com...
Page 198
) String get_hardwareId( ) java def get_hardwareId( ) function get_hardwareId( ) function get_hardwareId( ) The unique hardware identifier is made of the device serial number followed by string ".module". Returns : a string that uniquely identifies the module www.yoctopuce.com...
Page 199
) function get_icon2d( ) YModule target get_icon2d The icon is a PNG image and does not exceeds 1536 bytes. Returns : a binary buffer with module icon, in png format. On failure, throws an exception or returns YAPI_INVALID_STRING www.yoctopuce.com...
Page 200
. O n f a i l u r e , t h r o w s a n e x c e p t i o n o r r e t u r n s YAPI_INVALID_STRING www.yoctopuce.com...
Page 201
String get_logicalName( ) java Task<string> get_logicalName( ) def get_logicalName( ) function get_logicalName( ) function get_logicalName( ) YModule target get_logicalName Returns : a string corresponding to the logical name of the module On failure, throws an exception or returns Y_LOGICALNAME_INVALID www.yoctopuce.com...
Page 202
Task<int> get_luminosity( ) def get_luminosity( ) function get_luminosity( ) function get_luminosity( ) YModule target get_luminosity Returns : an integer corresponding to the luminosity of the module informative leds (from 0 to 100) On failure, throws an exception or returns Y_LUMINOSITY_INVALID www.yoctopuce.com...
Page 203
) YModule target get_parentHub If the module is connected by USB, or if the module is the root YoctoHub, an empty string is returned. Returns : a string with the serial number of the YoctoHub or an empty string www.yoctopuce.com...
Page 204
Task<int> get_persistentSettings( ) def get_persistentSettings( ) function get_persistentSettings( ) function get_persistentSettings( ) YModule target get_persistentSettings Returns : a value among Y_PERSISTENTSETTINGS_LOADED Y_PERSISTENTSETTINGS_SAVED Y_PERSISTENTSETTINGS_MODIFIED corresponding to the current state of persistent module settings On failure, throws an exception or returns Y_PERSISTENTSETTINGS_INVALID www.yoctopuce.com...
Page 205
) java Task<int> get_productId( ) def get_productId( ) function get_productId( ) function get_productId( ) YModule target get_productId Returns : an integer corresponding to the USB device identifier of the module On failure, throws an exception or returns Y_PRODUCTID_INVALID www.yoctopuce.com...
Page 206
Task<string> get_productName( ) def get_productName( ) function get_productName( ) function get_productName( ) YModule target get_productName Returns : a string corresponding to the commercial name of the module, as set by the factory On failure, throws an exception or returns Y_PRODUCTNAME_INVALID www.yoctopuce.com...
Page 207
) java Task<int> get_productRelease( ) def get_productRelease( ) function get_productRelease( ) function get_productRelease( ) YModule target get_productRelease Returns : an integer corresponding to the hardware release version of the module On failure, throws an exception or returns Y_PRODUCTRELEASE_INVALID www.yoctopuce.com...
Page 208
) function get_rebootCountdown( ) YModule target get_rebootCountdown Returns : an integer corresponding to the remaining number of seconds before the module restarts, or zero when no reboot has been scheduled On failure, throws an exception or returns Y_REBOOTCOUNTDOWN_INVALID www.yoctopuce.com...
Page 209
Task<string> get_serialNumber( ) def get_serialNumber( ) function get_serialNumber( ) function get_serialNumber( ) YModule target get_serialNumber Returns : a string corresponding to the serial number of the module, as set by the factory On failure, throws an exception or returns Y_SERIALNUMBER_INVALID www.yoctopuce.com...
Page 210
) function get_subDevices( ) function get_subDevices( ) YModule target get_subDevices This method only makes sense when called for a YoctoHub/VirtualHub. Otherwise, an empty array will be returned. Returns : an array of strings containing the sub modules. www.yoctopuce.com...
Page 211
Task<long> get_upTime( ) def get_upTime( ) function get_upTime( ) function get_upTime( ) YModule target get_upTime Returns : an integer corresponding to the number of milliseconds spent since the module was powered on On failure, throws an exception or returns Y_UPTIME_INVALID www.yoctopuce.com...
Page 212
String get_url( ) java Task<string> get_url( ) def get_url( ) function get_url( ) function get_url( ) YModule target get_url If the module is connected by USB, the string 'usb' is returned. Returns : a string with the URL of the module. www.yoctopuce.com...
Page 213
Task<int> get_usbCurrent( ) def get_usbCurrent( ) function get_usbCurrent( ) function get_usbCurrent( ) YModule target get_usbCurrent Returns : an integer corresponding to the current consumed by the module on the USB bus, in milli-amps On failure, throws an exception or returns Y_USBCURRENT_INVALID www.yoctopuce.com...
Page 214
) function get_userData( ) function get_userData( ) This attribute is never touched directly by the API, and is at disposal of the caller to store a context. Returns : the object stored previously by the caller. www.yoctopuce.com...
Page 215
) YModule target get_userVar On startup and after a device reboot, the value is always reset to zero. Returns : an integer corresponding to the value previously stored in this attribute On failure, throws an exception or returns Y_USERVAR_INVALID www.yoctopuce.com...
Page 216
$funcId) function hasFunction( funcId) YModule target hasFunction funcId This method takes a function identifier and returns a boolean. Parameters : funcId the requested function identifier Returns : true if the device has the function identifier www.yoctopuce.com...
Page 217
If there are valid cached values for the module, that have not yet expired, the device is considered reachable. No exception is raised if there is an error while trying to contact the requested module. Returns : true if the module can be reached, and false otherwise www.yoctopuce.com...
Page 218
The callback function receives three arguments: the caller-specific context object, the receiving module object and the boolean result context caller-specific object that is passed as-is to the callback function Returns : nothing : the result is provided to the callback. www.yoctopuce.com...
Page 219
Parameters : msValidity an integer corresponding to the validity attributed to the loaded module parameters, in milliseconds Returns : YAPI_SUCCESS when the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
Page 220
The callback function receives three arguments: the caller-specific context object, the receiving module object and the error code (or YAPI_SUCCESS context caller-specific object that is passed as-is to the callback function Returns : nothing : the result is provided to the callback. www.yoctopuce.com...
Page 221
This function is useful in particular to trace the execution of HTTP callbacks. If a newline is desired after the message, it must be included in the string. Parameters : text the string to append to the logs. Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
Page 222
YModule nextModule( ) def nextModule( ) function nextModule( ) function nextModule( ) Returns : YModule null a pointer to a object, corresponding to the next module found, or a pointer if there are no more modules to enumerate. www.yoctopuce.com...
Page 223
$secBeforeReboot) function reboot( secBeforeReboot) YModule target reboot secBeforeReboot Parameters : secBeforeReboot number of seconds before rebooting Returns : YAPI_SUCCESS when the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
Page 224
The callback function should take two arguments: the YModule object of which the beacon has changed, and an integer describing the new beacon state. Parameters : callback null The callback function to call, or to unregister a www.yoctopuce.com...
Page 225
) As Integer int registerConfigChangeCallback( ConfigChangeCallback callback) int registerConfigChangeCallback( ConfigChangeCallback callback) java Task<int> registerConfigChangeCallback( ConfigChangeCallback callback) def registerConfigChangeCallback( callback) function registerConfigChangeCallback( $callback) function registerConfigChangeCallback( callback) change of unit, etc). Parameters : callback null a procedure taking a YModule parameter, or www.yoctopuce.com...
Page 226
This callback will be called each time that a module sends a new log message. Mostly useful to debug a Yoctopuce module. Parameters : the callback function to call, or a null pointer. The callback function should take two arguments: callback the module object that emitted the log message, and the character string containing the log.
Page 227
) int revertFromFlash( ) java Task<int> revertFromFlash( ) def revertFromFlash( ) function revertFromFlash( ) function revertFromFlash( ) YModule target revertFromFlash Returns : YAPI_SUCCESS when the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
Page 228
Warning: the number of allowed save operations during a module life is limited (about 100000 cycles). Do not call this function within a loop. Returns : YAPI_SUCCESS when the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
Page 229
Parameters : a binary buffer with all the settings. settings Returns : YAPI_SUCCESS when the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
Page 230
Parameters : a binary buffer with all the settings. settings Returns : YAPI_SUCCESS when the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
Page 231
Task<int> set_beacon( int newval) def set_beacon( newval) function set_beacon( $newval) function set_beacon( newval) YModule target set_beacon newval Parameters : newval either Y_BEACON_OFF Y_BEACON_ON Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
Page 232
Parameters : newval a string corresponding to the logical name of the module Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
Page 233
Parameters : an integer corresponding to the luminosity of the module informative leds newval Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
Page 234
$data) function set_userData( data) This attribute is never touched by the API, and is at disposal of the caller to store a context. Parameters : any kind of object to be stored data www.yoctopuce.com...
Page 235
This attribute is at programmer disposal, should he need to store a state variable. On startup and after a device reboot, the value is always reset to zero. Parameters : newval an integer Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
Page 236
) int triggerConfigChangeCallback( ) -(int) triggerConfigChangeCallback function triggerConfigChangeCallback( ): LongInt function triggerConfigChangeCallback( ) As Integer int triggerConfigChangeCallback( ) int triggerConfigChangeCallback( ) java Task<int> triggerConfigChangeCallback( ) def triggerConfigChangeCallback( ) function triggerConfigChangeCallback( ) function triggerConfigChangeCallback( ) YModule target triggerConfigChangeCallback www.yoctopuce.com...
Page 237
$secBeforeReboot) function triggerFirmwareUpdate( secBeforeReboot) YModule target triggerFirmwareUpdate secBeforeReboot Parameters : secBeforeReboot number of seconds before rebooting Returns : YAPI_SUCCESS when the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
Page 238
$path) function updateFirmware( path) YModule target updateFirmware path This method returns a object which handles the firmware update process. YFirmwareUpdate Parameters : path the path of the .byn file to use. Returns : YFirmwareUpdate object or NULL on error. www.yoctopuce.com...
Page 239
YFirmwareUpdate Parameters : path .byn the path of the file to use. force true to force the firmware update even if some prerequisites appear not to be met Returns : YFirmwareUpdate object or NULL on error. www.yoctopuce.com...
Page 240
The callback function receives two arguments: the caller-specific context object and the receiving function object. context caller-specific object that is passed as-is to the callback function Returns : nothing. www.yoctopuce.com...
22. High-level API Reference 22.3. Display function interface 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).
Page 242
Checks if the display is currently reachable, without raising any error (asynchronous version). display→load(msValidity) Preloads the display cache with a specified validity duration. display→loadAttribute(attrName) Returns the current value of a single function attribute, as a text string, as quickly as possible but without using the cached value. www.yoctopuce.com...
Page 243
Uploads an arbitrary file (for instance a GIF file) to the display, to the specified full path name. display→wait_async(callback, context) Waits for all pending asynchronous commands on the module to complete, and invoke the user-provided callback function. www.yoctopuce.com...
Page 244
If a call to this object's is_online() method returns FALSE although you are certain that the matching device is plugged, make sure that you did call registerHub() at application initialization time. Parameters : a string that uniquely characterizes the display func Returns : YDisplay object allowing you to drive the display. www.yoctopuce.com...
Page 245
The search is performed first by hardware name, then by logical name. Parameters : yctx a YAPI context a string that uniquely characterizes the display func Returns : YDisplay object allowing you to drive the display. www.yoctopuce.com...
Page 246
FirstDisplay( ) function yFirstDisplay( ) function FirstDisplay( ) Use the method to iterate on next displays. YDisplay.nextDisplay() Returns : YDisplay null a pointer to a object, corresponding to the first display currently online, or a pointer if there are none. www.yoctopuce.com...
Page 247
FirstDisplayInContext( yctx) Use the method to iterate on next displays. YDisplay.nextDisplay() Parameters : a YAPI context. yctx Returns : YDisplay null a pointer to a object, corresponding to the first display currently online, or a pointer if there are none. www.yoctopuce.com...
Page 248
) void clearCache( ) java def clearCache( ) function clearCache( ) function clearCache( ) Invalidates the cache of the display attributes. Forces the next call to get_xxx() or loadxxx() to use values that come from the device. www.yoctopuce.com...
Page 249
(a number in range 0..layerCount-1) dstLayerId the identifier of the destination layer (a number in range 0..layerCount-1) Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
Page 250
Returns : s t r i n g t h a t d e s c r i b e s t h e d i s p l a y ( e x : Relay(MyCustomName.relay1)=RELAYLO1-123456.relay1 www.yoctopuce.com...
Page 251
YDisplay target fade brightness duration Parameters : brightness the new screen brightness duration duration of the brightness transition, in milliseconds. Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
Page 252
Task<string> get_advertisedValue( ) def get_advertisedValue( ) function get_advertisedValue( ) function get_advertisedValue( ) YDisplay target get_advertisedValue Returns : a string corresponding to the current value of the display (no more than 6 characters). On failure, throws an exception or returns Y_ADVERTISEDVALUE_INVALID www.yoctopuce.com...
Page 253
Task<int> get_brightness( ) def get_brightness( ) function get_brightness( ) function get_brightness( ) YDisplay target get_brightness Returns : an integer corresponding to the luminosity of the module informative leds (from 0 to 100) On failure, throws an exception or returns Y_BRIGHTNESS_INVALID www.yoctopuce.com...
Page 254
) int get_displayHeight( ) java Task<int> get_displayHeight( ) def get_displayHeight( ) function get_displayHeight( ) function get_displayHeight( ) YDisplay target get_displayHeight Returns : an integer corresponding to the display height, in pixels On failure, throws an exception or returns Y_DISPLAYHEIGHT_INVALID www.yoctopuce.com...
Page 255
The content is displayed only when the layer is active on the screen (and not masked by other overlapping layers). Parameters : the identifier of the layer (a number in range 0..layerCount-1) layerId Returns : YDisplayLayer object On failure, throws an exception or returns null www.yoctopuce.com...
Page 256
) function get_displayType( ) function get_displayType( ) YDisplay target get_displayType Returns : a value among Y_DISPLAYTYPE_MONO Y_DISPLAYTYPE_GRAY Y_DISPLAYTYPE_RGB corresponding to the display type: monochrome, gray levels or full color On failure, throws an exception or returns Y_DISPLAYTYPE_INVALID www.yoctopuce.com...
Page 257
) int get_displayWidth( ) java Task<int> get_displayWidth( ) def get_displayWidth( ) function get_displayWidth( ) function get_displayWidth( ) YDisplay target get_displayWidth Returns : an integer corresponding to the display width, in pixels On failure, throws an exception or returns Y_DISPLAYWIDTH_INVALID www.yoctopuce.com...
Page 258
Task<int> get_enabled( ) def get_enabled( ) function get_enabled( ) function get_enabled( ) YDisplay target get_enabled Returns : either Y_ENABLED_FALSE Y_ENABLED_TRUE , according to true if the screen is powered, false otherwise On failure, throws an exception or returns Y_ENABLED_INVALID www.yoctopuce.com...
Page 259
) function get_errorMessage( ) function get_errorMessage( ) This method is mostly useful when using the Yoctopuce library with exceptions disabled. Returns : a string corresponding to the latest error message that occured while using the display object www.yoctopuce.com...
Page 260
) function get_errorType( ) function get_errorType( ) This method is mostly useful when using the Yoctopuce library with exceptions disabled. Returns : a number corresponding to the code of the latest error that occurred while using the display object...
Page 261
(for example: MyCustomName.relay1 Returns : a string that uniquely identifies the display using logical names (ex: MyCustomName.relay1 On failure, throws an exception or returns Y_FRIENDLYNAME_INVALID www.yoctopuce.com...
Page 262
, t h e r e t u r n e d v a l u e Y_FUNCTIONDESCRIPTOR_INVALID www.yoctopuce.com...
Page 263
) As String string get_functionId( ) String get_functionId( ) java def get_functionId( ) function get_functionId( ) function get_functionId( ) For example relay1 Returns : relay1 a string that identifies the display (ex: On failure, throws an exception or returns Y_FUNCTIONID_INVALID www.yoctopuce.com...
Page 264
The unique hardware identifier is composed of the device serial number and of the hardware identifier of the display (for example RELAYLO1-123456.relay1 Returns : RELAYLO1-123456.relay1 a string that uniquely identifies the display (ex: On failure, throws an exception or returns Y_HARDWAREID_INVALID www.yoctopuce.com...
Page 265
) java Task<int> get_layerCount( ) def get_layerCount( ) function get_layerCount( ) function get_layerCount( ) YDisplay target get_layerCount Returns : an integer corresponding to the number of available layers to draw on On failure, throws an exception or returns Y_LAYERCOUNT_INVALID www.yoctopuce.com...
Page 266
Task<int> get_layerHeight( ) def get_layerHeight( ) function get_layerHeight( ) function get_layerHeight( ) YDisplay target get_layerHeight Returns : an integer corresponding to the height of the layers to draw on, in pixels On failure, throws an exception or returns Y_LAYERHEIGHT_INVALID www.yoctopuce.com...
Page 267
Task<int> get_layerWidth( ) def get_layerWidth( ) function get_layerWidth( ) function get_layerWidth( ) YDisplay target get_layerWidth Returns : an integer corresponding to the width of the layers to draw on, in pixels On failure, throws an exception or returns Y_LAYERWIDTH_INVALID www.yoctopuce.com...
Page 268
String get_logicalName( ) java Task<string> get_logicalName( ) def get_logicalName( ) function get_logicalName( ) function get_logicalName( ) YDisplay target get_logicalName Returns : a string corresponding to the logical name of the display. On failure, throws an exception or returns Y_LOGICALNAME_INVALID www.yoctopuce.com...
Page 269
YModule get_module( ) java def get_module( ) function get_module( ) function get_module( ) If the function cannot be located on any module, the returned instance of is not shown as on- YModule line. Returns : an instance of YModule www.yoctopuce.com...
Page 270
The callback function receives three arguments: the caller-specific context object, the receiving function object and the requested YModule object caller-specific object that is passed as-is to the callback function context Returns : nothing : the result is provided to the callback. www.yoctopuce.com...
Page 271
Task<int> get_orientation( ) def get_orientation( ) function get_orientation( ) function get_orientation( ) YDisplay target get_orientation Returns : a value among Y_ORIENTATION_LEFT Y_ORIENTATION_UP Y_ORIENTATION_RIGHT Y_ORIENTATION_DOWN corresponding to the currently selected display orientation On failure, throws an exception or returns Y_ORIENTATION_INVALID www.yoctopuce.com...
Page 272
) function get_startupSeq( ) function get_startupSeq( ) YDisplay target get_startupSeq Returns : a string corresponding to the name of the sequence to play when the displayed is powered on On failure, throws an exception or returns Y_STARTUPSEQ_INVALID www.yoctopuce.com...
Page 273
) function get_userData( ) function get_userData( ) This attribute is never touched directly by the API, and is at disposal of the caller to store a context. Returns : the object stored previously by the caller. www.yoctopuce.com...
Page 274
If there is a cached value for the display in cache, that has not yet expired, the device is considered reachable. No exception is raised if there is an error while trying to contact the device hosting the display. Returns : true if the display can be reached, and false otherwise www.yoctopuce.com...
Page 275
The callback function receives three arguments: the caller-specific context object, the receiving function object and the boolean result context caller-specific object that is passed as-is to the callback function Returns : nothing : the result is provided to the callback. www.yoctopuce.com...
Page 276
Parameters : msValidity an integer corresponding to the validity attributed to the loaded function parameters, in milliseconds Returns : YAPI_SUCCESS when the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
Page 277
$attrName) function loadAttribute( attrName) Parameters : attrName the name of the requested attribute Returns : a string with the value of the the attribute On failure, throws an exception or returns an empty string. www.yoctopuce.com...
Page 278
The callback function receives three arguments: the caller-specific context object, the receiving function object and the error code YAPI_SUCCESS context caller-specific object that is passed as-is to the callback function Returns : nothing : the result is provided to the callback. www.yoctopuce.com...
Page 279
HTTP callback. Remember to call the method saveToFlash() of the module if the modification must be kept. Returns : YAPI_SUCCESS when the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
Page 280
YDisplay target newSequence The name used to store the sequence is specified when calling , once the saveSequence() recording is complete. Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
Page 281
YDisplay nextDisplay( ) def nextDisplay( ) function nextDisplay( ) function nextDisplay( ) Returns : YDisplay null a pointer to a object, corresponding to a display currently online, or a pointer if there are no more displays to enumerate. www.yoctopuce.com...
Page 282
To cancel a delay, call the same method with a zero delay. Parameters : delay_ms the duration to wait, in milliseconds Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
Page 283
$sequenceName) function playSequence( sequenceName) YDisplay target playSequence sequenceName Parameters : sequenceName the name of the newly created sequence Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
Page 284
To unregister a callback, pass a null pointer as argument. Parameters : callback the callback function to call, or a null pointer. The callback function should take two arguments: the function object of which the value has changed, and the character string describing the new advertised value. www.yoctopuce.com...
Page 285
Using this function in a sequence will kill the sequence play-back. Don't use that function to reset the display at sequence start-up. Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
Page 286
The sequence can be later replayed using playSequence() Parameters : sequenceName the name of the newly created sequence Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
Page 287
Parameters : an integer corresponding to the brightness of the display newval Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
Page 288
YDisplay target set_enabled newval Parameters : newval either Y_ENABLED_FALSE Y_ENABLED_TRUE , according to the power state of the display Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
Page 289
Parameters : newval a string corresponding to the logical name of the display. Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
Page 290
Y _ O R I E N T A T I O N _ U P v a l u e a m o n g Y_ORIENTATION_RIGHT Y_ORIENTATION_DOWN corresponding to the display orientation Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
Page 291
Parameters : a string corresponding to the name of the sequence to play when the displayed is powered on newval Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
Page 292
$data) function set_userData( data) This attribute is never touched by the API, and is at disposal of the caller to store a context. Parameters : any kind of object to be stored data www.yoctopuce.com...
Page 293
Task<int> stopSequence( ) def stopSequence( ) function stopSequence( ) function stopSequence( ) YDisplay target stopSequence The display is left as is. Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
Page 294
(it is always completely opaque). Parameters : layerIdA the first layer (a number in range 0..layerCount-1) layerIdB the second layer (a number in range 0..layerCount-1) Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
Page 295
This function reverts the effect of a previous call to . Remember to call the muteValueCallbacks() saveToFlash() method of the module if the modification must be kept. Returns : YAPI_SUCCESS when the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
Page 296
If a file already exists with the same path name, its content is overwritten. Parameters : pathname path and name of the new file to create content binary buffer with the content to set Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
Page 297
The callback function receives two arguments: the caller-specific context object and the receiving function object. context caller-specific object that is passed as-is to the callback function Returns : nothing. www.yoctopuce.com...
In order to use the functions described here, you should include: <script type='text/javascript' src='yocto_display.js'></script> #include "yocto_display.h" #import "yocto_display.h" uses yocto_display; yocto_display.vb yocto_display.cs import com.yoctopuce.YoctoAPI.YDisplay; java import com.yoctopuce.YoctoAPI.YDisplay; from yocto_display import * require_once('yocto_display.php'); in HTML: <script src="../../lib/yocto_display.js"></script> in node.js: require('yoctolib-es2017/yocto_display.js'); methods YDisplayLayer displaylayer→clear()
Page 299
Sets up display margins for the function. displaylayer→setConsoleWordWrap(wordwrap) consoleOut Sets up the wrapping behaviour used by the function. displaylayer→setLayerPosition(x, y, scrollTime) Sets the position of the layer relative to the display upper left corner. displaylayer→unhide() Shows the layer. www.yoctopuce.com...
Page 300
This method does not change any other attribute of the layer. To reinitialize the layer attributes to defaults settings, use the method instead. reset() Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
Page 301
) java Task<int> clearConsole( ) def clearConsole( ) function clearConsole( ) function clearConsole( ) YDisplay target [-layer layerId] clearConsole Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
Page 302
When the new text to display extends below the lower margin, the console area is automatically scrolled up. Parameters : text the message to display Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
Page 303
Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
Page 304
(0 = black, 255 = white), or -1 to leave the pixels bgcol unchanged Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
Page 305
Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
Page 306
Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
Page 307
GIF file name Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
Page 308
[-layer layerId] drawPixel Parameters : the distance from left of layer, in pixels the distance from top of layer, in pixels Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
Page 309
Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
Page 310
Y _ A L I G N _ B A S E L I N E _ D E C I M A L Y_ALIGN_BOTTOM_DECIMAL Y_ALIGN_TOP_RIGHT Y_ALIGN_CENTER_RIGHT Y_ALIGN_BASELINE_RIGHT Y_ALIGN_BOTTOM_RIGHT the text string to draw text Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
Page 311
): TYDisplay function get_display( ) As YDisplay YDisplay get_display( ) YDisplay get_display( ) java Task<YDisplay> get_display( ) def get_display( ) function get_display( ) function get_display( ) Returns the parent YDisplay object of the current YDisplayLayer. Returns : YDisplay object www.yoctopuce.com...
Page 312
) java Task<int> get_displayHeight( ) def get_displayHeight( ) function get_displayHeight( ) function get_displayHeight( ) YDisplay target [-layer layerId] get_displayHeight Returns : an integer corresponding to the display height, in pixels On failure, throws an exception or returns Y_DISPLAYHEIGHT_INVALID. www.yoctopuce.com...
Page 313
) java Task<int> get_displayWidth( ) def get_displayWidth( ) function get_displayWidth( ) function get_displayWidth( ) YDisplay target [-layer layerId] get_displayWidth Returns : an integer corresponding to the display width, in pixels On failure, throws an exception or returns Y_DISPLAYWIDTH_INVALID. www.yoctopuce.com...
Page 314
Task<int> get_layerHeight( ) def get_layerHeight( ) function get_layerHeight( ) function get_layerHeight( ) YDisplay target [-layer layerId] get_layerHeight Returns : an integer corresponding to the height of the layers to draw on, in pixels On failure, throws an exception or returns Y_LAYERHEIGHT_INVALID. www.yoctopuce.com...
Page 315
Task<int> get_layerWidth( ) def get_layerWidth( ) function get_layerWidth( ) function get_layerWidth( ) YDisplay target [-layer layerId] get_layerWidth Returns : an integer corresponding to the width of the layers to draw on, in pixels On failure, throws an exception or returns Y_LAYERWIDTH_INVALID. www.yoctopuce.com...
Page 316
. Hiding the layer can positively affect the drawing speed, since it postpones the rendering unhide() until all operations are completed (double-buffering). Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
Page 317
Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
Page 318
[-layer layerId] moveTo Parameters : the distance from left of layer, in pixels the distance from top of layer, in pixels Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
Page 319
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 instead. clear() Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
Page 320
The pen color is provided as an RGB value. For grayscale or monochrome displays, the value is automatically converted to the proper range. Parameters : color the desired pen color, as a 24-bit RGB value Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
Page 321
[-layer layerId] selectEraser Any point drawn using the eraser becomes transparent (as when the layer is empty), showing the other layers beneath it. Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
Page 322
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. Parameters : fontname the font file name Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
Page 323
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. Parameters : graylevel the desired gray level, from 0 to 255 Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
Page 324
This setting has no effect on monochrome displays. Parameters : mode true false to enable antialiasing, to disable it. Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
Page 325
Parameters : bgcol the background gray level to use when scrolling (0 = black, 255 = white), or -1 for transparent Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
Page 326
Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
Page 327
[-layer layerId] setConsoleWordWrap wordwrap Parameters : wordwrap true to wrap only between words, false to wrap on the last column anyway. Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
Page 328
0 if the scrolling should be immediate. scrollTime Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
Page 329
) function unhide( ) function unhide( ) YDisplay target [-layer layerId] unhide Shows the layer again after a hide command. Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
22. High-level API Reference 22.5. AnButton function interface Yoctopuce application programming interface allows you to measure the state of a simple button as well as to read an analog potentiometer (variable resistance). This can be use for instance with a continuous rotating knob, a throttle grip or a joystick.
Page 331
Checks if the analog input is currently reachable, without raising any error (asynchronous version). anbutton→load(msValidity) Preloads the analog input cache with a specified validity duration. anbutton→loadAttribute(attrName) Returns the current value of a single function attribute, as a text string, as quickly as possible but without using the cached value. anbutton→load_async(msValidity, callback, context) www.yoctopuce.com...
Page 332
Stores a user context provided as argument in the userData attribute of the function. anbutton→unmuteValueCallbacks() Re-enables the propagation of every new advertised value to the parent hub. anbutton→wait_async(callback, context) Waits for all pending asynchronous commands on the module to complete, and invoke the user-provided callback function. www.yoctopuce.com...
Page 333
If a call to this object's is_online() method returns FALSE although you are certain that the matching device is plugged, make sure that you did call registerHub() at application initialization time. Parameters : a string that uniquely characterizes the analog input func Returns : YAnButton object allowing you to drive the analog input. www.yoctopuce.com...
Page 334
The search is performed first by hardware name, then by logical name. Parameters : yctx a YAPI context a string that uniquely characterizes the analog input func Returns : YAnButton object allowing you to drive the analog input. www.yoctopuce.com...
Page 335
) function FirstAnButton( ) Use the method to iterate on next analog inputs. YAnButton.nextAnButton() Returns : YAnButton null a pointer to a object, corresponding to the first analog input currently online, or a pointer if there are none. www.yoctopuce.com...
Page 336
Use the method to iterate on next analog inputs. YAnButton.nextAnButton() Parameters : a YAPI context. yctx Returns : YAnButton null a pointer to a object, corresponding to the first analog input currently online, or a pointer if there are none. www.yoctopuce.com...
Page 337
) void clearCache( ) java def clearCache( ) function clearCache( ) function clearCache( ) Invalidates the cache of the analog input attributes. Forces the next call to get_xxx() or loadxxx() to use values that come from the device. www.yoctopuce.com...
Page 338
Returns : s t r i n g t h a t d e s c r i b e s t h e a n a l o g i n p u t ( e x : Relay(MyCustomName.relay1)=RELAYLO1-123456.relay1 www.yoctopuce.com...
Page 339
Task<string> get_advertisedValue( ) def get_advertisedValue( ) function get_advertisedValue( ) function get_advertisedValue( ) YAnButton target get_advertisedValue Returns : a string corresponding to the current value of the analog input (no more than 6 characters). On failure, throws an exception or returns Y_ADVERTISEDVALUE_INVALID www.yoctopuce.com...
Page 340
) As Integer int get_analogCalibration( ) int get_analogCalibration( ) java Task<int> get_analogCalibration( ) def get_analogCalibration( ) function get_analogCalibration( ) function get_analogCalibration( ) YAnButton target get_analogCalibration Returns : either Y_ANALOGCALIBRATION_OFF Y_ANALOGCALIBRATION_ON On failure, throws an exception or returns Y_ANALOGCALIBRATION_INVALID www.yoctopuce.com...
Page 341
Task<int> get_calibratedValue( ) def get_calibratedValue( ) function get_calibratedValue( ) function get_calibratedValue( ) YAnButton target get_calibratedValue Returns : an integer corresponding to the current calibrated input value (between 0 and 1000, included) On failure, throws an exception or returns Y_CALIBRATEDVALUE_INVALID www.yoctopuce.com...
Page 342
Task<int> get_calibrationMax( ) def get_calibrationMax( ) function get_calibrationMax( ) function get_calibrationMax( ) YAnButton target get_calibrationMax Returns : an integer corresponding to the maximal value measured during the calibration (between 0 and 4095, included) On failure, throws an exception or returns Y_CALIBRATIONMAX_INVALID www.yoctopuce.com...
Page 343
Task<int> get_calibrationMin( ) def get_calibrationMin( ) function get_calibrationMin( ) function get_calibrationMin( ) YAnButton target get_calibrationMin Returns : an integer corresponding to the minimal value measured during the calibration (between 0 and 4095, included) On failure, throws an exception or returns Y_CALIBRATIONMIN_INVALID www.yoctopuce.com...
Page 344
) function get_errorMessage( ) function get_errorMessage( ) This method is mostly useful when using the Yoctopuce library with exceptions disabled. Returns : a string corresponding to the latest error message that occured while using the analog input object...
Page 345
) function get_errorType( ) function get_errorType( ) This method is mostly useful when using the Yoctopuce library with exceptions disabled. Returns : a number corresponding to the code of the latest error that occurred while using the analog input object...
Page 346
(for example: MyCustomName.relay1 Returns : a string that uniquely identifies the analog input using logical names (ex: MyCustomName.relay1 On failure, throws an exception or returns Y_FRIENDLYNAME_INVALID www.yoctopuce.com...
Page 347
, t h e r e t u r n e d v a l u e Y_FUNCTIONDESCRIPTOR_INVALID www.yoctopuce.com...
Page 348
) As String string get_functionId( ) String get_functionId( ) java def get_functionId( ) function get_functionId( ) function get_functionId( ) For example relay1 Returns : relay1 a string that identifies the analog input (ex: On failure, throws an exception or returns Y_FUNCTIONID_INVALID www.yoctopuce.com...
Page 349
The unique hardware identifier is composed of the device serial number and of the hardware identifier of the analog input (for example RELAYLO1-123456.relay1 Returns : RELAYLO1-123456.relay1 a string that uniquely identifies the analog input (ex: On failure, throws an exception or returns Y_HARDWAREID_INVALID www.yoctopuce.com...
Page 350
) function get_isPressed( ) YAnButton target get_isPressed Returns : either Y_ISPRESSED_FALSE Y_ISPRESSED_TRUE , according to true if the input (considered as binary) is active (closed contact), and false otherwise On failure, throws an exception or returns Y_ISPRESSED_INVALID www.yoctopuce.com...
Page 351
(the input contact transitioned from open to closed) On failure, throws an exception or returns Y_LASTTIMEPRESSED_INVALID www.yoctopuce.com...
Page 352
(the input contact transitioned from closed to open) On failure, throws an exception or returns Y_LASTTIMERELEASED_INVALID www.yoctopuce.com...
Page 353
String get_logicalName( ) java Task<string> get_logicalName( ) def get_logicalName( ) function get_logicalName( ) function get_logicalName( ) YAnButton target get_logicalName Returns : a string corresponding to the logical name of the analog input. On failure, throws an exception or returns Y_LOGICALNAME_INVALID www.yoctopuce.com...
Page 354
YModule get_module( ) java def get_module( ) function get_module( ) function get_module( ) If the function cannot be located on any module, the returned instance of is not shown as on- YModule line. Returns : an instance of YModule www.yoctopuce.com...
Page 355
The callback function receives three arguments: the caller-specific context object, the receiving function object and the requested YModule object caller-specific object that is passed as-is to the callback function context Returns : nothing : the result is provided to the callback. www.yoctopuce.com...
Page 356
The value is a 32 bit integer. In case of overflow (>=2^32), the counter will wrap. To reset the counter, just call the resetCounter() method. Returns : an integer corresponding to the pulse counter value On failure, throws an exception or returns Y_PULSECOUNTER_INVALID www.yoctopuce.com...
Page 357
) java Task<long> get_pulseTimer( ) def get_pulseTimer( ) function get_pulseTimer( ) function get_pulseTimer( ) YAnButton target get_pulseTimer Returns : an integer corresponding to the timer of the pulses counter (ms) On failure, throws an exception or returns Y_PULSETIMER_INVALID www.yoctopuce.com...
Page 358
Task<int> get_rawValue( ) def get_rawValue( ) function get_rawValue( ) function get_rawValue( ) YAnButton target get_rawValue Returns : an integer corresponding to the current measured input value as-is (between 0 and 4095, included) On failure, throws an exception or returns Y_RAWVALUE_INVALID www.yoctopuce.com...
Page 359
) function get_sensitivity( ) function get_sensitivity( ) YAnButton target get_sensitivity Returns : an integer corresponding to the sensibility for the input (between 1 and 1000) for triggering user callbacks On failure, throws an exception or returns Y_SENSITIVITY_INVALID www.yoctopuce.com...
Page 360
) function get_userData( ) function get_userData( ) This attribute is never touched directly by the API, and is at disposal of the caller to store a context. Returns : the object stored previously by the caller. www.yoctopuce.com...
Page 361
If there is a cached value for the analog input in cache, that has not yet expired, the device is considered reachable. No exception is raised if there is an error while trying to contact the device hosting the analog input. Returns : true if the analog input can be reached, and false otherwise www.yoctopuce.com...
Page 362
The callback function receives three arguments: the caller-specific context object, the receiving function object and the boolean result context caller-specific object that is passed as-is to the callback function Returns : nothing : the result is provided to the callback. www.yoctopuce.com...
Page 363
Parameters : msValidity an integer corresponding to the validity attributed to the loaded function parameters, in milliseconds Returns : YAPI_SUCCESS when the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
Page 364
$attrName) function loadAttribute( attrName) Parameters : attrName the name of the requested attribute Returns : a string with the value of the the attribute On failure, throws an exception or returns an empty string. www.yoctopuce.com...
Page 365
The callback function receives three arguments: the caller-specific context object, the receiving function object and the error code YAPI_SUCCESS context caller-specific object that is passed as-is to the callback function Returns : nothing : the result is provided to the callback. www.yoctopuce.com...
Page 366
HTTP callback. Remember to call the method saveToFlash() of the module if the modification must be kept. Returns : YAPI_SUCCESS when the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
Page 367
YAnButton nextAnButton( ) def nextAnButton( ) function nextAnButton( ) function nextAnButton( ) Returns : YAnButton null a pointer to a object, corresponding to an analog input currently online, or a pointer if there are no more analog inputs to enumerate. www.yoctopuce.com...
Page 368
To unregister a callback, pass a null pointer as argument. Parameters : callback the callback function to call, or a null pointer. The callback function should take two arguments: the function object of which the value has changed, and the character string describing the new advertised value. www.yoctopuce.com...
Page 369
) int resetCounter( ) java Task<int> resetCounter( ) def resetCounter( ) function resetCounter( ) function resetCounter( ) YAnButton target resetCounter Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
Page 370
Parameters : newval Y_ANALOGCALIBRATION_OFF Y_ANALOGCALIBRATION_ON either Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
Page 371
(between 0 and 4095, newval included), without actually starting the automated calibration Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
Page 372
(between 0 and 4095, newval included), without actually starting the automated calibration Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
Page 373
Parameters : newval a string corresponding to the logical name of the analog input. Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
Page 374
Parameters : an integer corresponding to the sensibility for the input (between 1 and 1000) for triggering user newval callbacks Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
Page 375
$data) function set_userData( data) This attribute is never touched by the API, and is at disposal of the caller to store a context. Parameters : any kind of object to be stored data www.yoctopuce.com...
Page 376
This function reverts the effect of a previous call to . Remember to call the muteValueCallbacks() saveToFlash() method of the module if the modification must be kept. Returns : YAPI_SUCCESS when the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
Page 377
The callback function receives two arguments: the caller-specific context object and the receiving function object. context caller-specific object that is passed as-is to the callback function Returns : nothing. www.yoctopuce.com...
In order to use the functions described here, you should include: <script type='text/javascript' src='yocto_files.js'></script> #include "yocto_files.h" #import "yocto_files.h" uses yocto_files; yocto_files.vb yocto_files.cs import com.yoctopuce.YoctoAPI.YFiles; java import com.yoctopuce.YoctoAPI.YFiles; from yocto_files import * require_once('yocto_files.php'); in HTML: <script src="../../lib/yocto_files.js"></script> in node.js: require('yoctolib-es2017/yocto_files.js'); Global functions yFindFiles(func) Retrieves a filesystem for a given identifier.
Page 379
Continues the enumeration of filesystems started using files→registerValueCallback(callback) Registers the callback function that is invoked on every change of advertised value. files→remove(pathname) Deletes a file, given by its full path name, from the filesystem. files→set_logicalName(newval) Changes the logical name of the filesystem. files→set_userData(data) www.yoctopuce.com...
Page 380
Re-enables the propagation of every new advertised value to the parent hub. files→upload(pathname, content) Uploads a file to the filesystem, to the specified full path name. files→wait_async(callback, context) Waits for all pending asynchronous commands on the module to complete, and invoke the user-provided callback function. www.yoctopuce.com...
Page 381
If a call to this object's is_online() method returns FALSE although you are certain that the matching device is plugged, make sure that you did call registerHub() at application initialization time. Parameters : a string that uniquely characterizes the filesystem func Returns : YFiles object allowing you to drive the filesystem. www.yoctopuce.com...
Page 382
The search is performed first by hardware name, then by logical name. Parameters : yctx a YAPI context a string that uniquely characterizes the filesystem func Returns : YFiles object allowing you to drive the filesystem. www.yoctopuce.com...
Page 383
FirstFiles( ) function yFirstFiles( ) function FirstFiles( ) Use the method to iterate on next filesystems. YFiles.nextFiles() Returns : YFiles null a pointer to a object, corresponding to the first filesystem currently online, or a pointer if there are none. www.yoctopuce.com...
Page 384
FirstFilesInContext( yctx) Use the method to iterate on next filesystems. YFiles.nextFiles() Parameters : a YAPI context. yctx Returns : YFiles null a pointer to a object, corresponding to the first filesystem currently online, or a pointer if there are none. www.yoctopuce.com...
Page 385
) void clearCache( ) java def clearCache( ) function clearCache( ) function clearCache( ) Invalidates the cache of the filesystem attributes. Forces the next call to get_xxx() or loadxxx() to use values that come from the device. www.yoctopuce.com...
Page 386
Returns : s t r i n g t h a t d e s c r i b e s t h e f i l e s y s t e m ( e x : Relay(MyCustomName.relay1)=RELAYLO1-123456.relay1 www.yoctopuce.com...
Page 387
$pathname) function download( pathname) YFiles target download pathname Parameters : pathname path and name of the file to download Returns : a binary buffer with the file content On failure, throws an exception or returns an empty content. www.yoctopuce.com...
Page 388
The callback function receives three arguments: - the user-specific context object - the YFiles object whose download_async was invoked - a binary buffer with the file content context user-specific object that is passed as-is to the callback function Returns : nothing. www.yoctopuce.com...
Page 389
Task<bool> fileExist( string filename) def fileExist( filename) function fileExist( $filename) function fileExist( filename) YFiles target fileExist filename Parameters : filename the file name to test. Returns : a true if the file existe, false ortherwise. On failure, throws an exception. www.yoctopuce.com...
Page 390
Task<int> format_fs( ) def format_fs( ) function format_fs( ) function format_fs( ) YFiles target format_fs All files previously uploaded are permanently lost. Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
Page 391
Task<string> get_advertisedValue( ) def get_advertisedValue( ) function get_advertisedValue( ) function get_advertisedValue( ) YFiles target get_advertisedValue Returns : a string corresponding to the current value of the filesystem (no more than 6 characters). On failure, throws an exception or returns Y_ADVERTISEDVALUE_INVALID www.yoctopuce.com...
Page 392
) function get_errorMessage( ) function get_errorMessage( ) This method is mostly useful when using the Yoctopuce library with exceptions disabled. Returns : a string corresponding to the latest error message that occured while using the filesystem object www.yoctopuce.com...
Page 393
) function get_errorType( ) function get_errorType( ) This method is mostly useful when using the Yoctopuce library with exceptions disabled. Returns : a number corresponding to the code of the latest error that occurred while using the filesystem object...
Page 394
Task<int> get_filesCount( ) def get_filesCount( ) function get_filesCount( ) function get_filesCount( ) YFiles target get_filesCount Returns : an integer corresponding to the number of files currently loaded in the filesystem On failure, throws an exception or returns Y_FILESCOUNT_INVALID www.yoctopuce.com...
Page 395
Task<int> get_freeSpace( ) def get_freeSpace( ) function get_freeSpace( ) function get_freeSpace( ) YFiles target get_freeSpace Returns : an integer corresponding to the free space for uploading new files to the filesystem, in bytes On failure, throws an exception or returns Y_FREESPACE_INVALID www.yoctopuce.com...
Page 396
(for example: MyCustomName.relay1 Returns : a string that uniquely identifies the filesystem using logical names (ex: MyCustomName.relay1 On failure, throws an exception or returns Y_FRIENDLYNAME_INVALID www.yoctopuce.com...
Page 397
, t h e r e t u r n e d v a l u e Y_FUNCTIONDESCRIPTOR_INVALID www.yoctopuce.com...
Page 398
) As String string get_functionId( ) String get_functionId( ) java def get_functionId( ) function get_functionId( ) function get_functionId( ) For example relay1 Returns : relay1 a string that identifies the filesystem (ex: On failure, throws an exception or returns Y_FUNCTIONID_INVALID www.yoctopuce.com...
Page 399
The unique hardware identifier is composed of the device serial number and of the hardware identifier of the filesystem (for example RELAYLO1-123456.relay1 Returns : RELAYLO1-123456.relay1 a string that uniquely identifies the filesystem (ex: On failure, throws an exception or returns Y_HARDWAREID_INVALID www.yoctopuce.com...
Page 400
When an empty pattern is provided, all file records are returned. Returns : YFileRecord a list of objects, containing the file path and name, byte size and 32-bit CRC of the file content. On failure, throws an exception or returns an empty list. www.yoctopuce.com...
Page 401
String get_logicalName( ) java Task<string> get_logicalName( ) def get_logicalName( ) function get_logicalName( ) function get_logicalName( ) YFiles target get_logicalName Returns : a string corresponding to the logical name of the filesystem. On failure, throws an exception or returns Y_LOGICALNAME_INVALID www.yoctopuce.com...
Page 402
YModule get_module( ) java def get_module( ) function get_module( ) function get_module( ) If the function cannot be located on any module, the returned instance of is not shown as on- YModule line. Returns : an instance of YModule www.yoctopuce.com...
Page 403
The callback function receives three arguments: the caller-specific context object, the receiving function object and the requested YModule object caller-specific object that is passed as-is to the callback function context Returns : nothing : the result is provided to the callback. www.yoctopuce.com...
Page 404
) function get_userData( ) function get_userData( ) This attribute is never touched directly by the API, and is at disposal of the caller to store a context. Returns : the object stored previously by the caller. www.yoctopuce.com...
Page 405
If there is a cached value for the filesystem in cache, that has not yet expired, the device is considered reachable. No exception is raised if there is an error while trying to contact the device hosting the filesystem. Returns : true if the filesystem can be reached, and false otherwise www.yoctopuce.com...
Page 406
The callback function receives three arguments: the caller-specific context object, the receiving function object and the boolean result context caller-specific object that is passed as-is to the callback function Returns : nothing : the result is provided to the callback. www.yoctopuce.com...
Page 407
Parameters : msValidity an integer corresponding to the validity attributed to the loaded function parameters, in milliseconds Returns : YAPI_SUCCESS when the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
Page 408
$attrName) function loadAttribute( attrName) Parameters : attrName the name of the requested attribute Returns : a string with the value of the the attribute On failure, throws an exception or returns an empty string. www.yoctopuce.com...
Page 409
The callback function receives three arguments: the caller-specific context object, the receiving function object and the error code YAPI_SUCCESS context caller-specific object that is passed as-is to the callback function Returns : nothing : the result is provided to the callback. www.yoctopuce.com...
Page 410
HTTP callback. Remember to call the method saveToFlash() of the module if the modification must be kept. Returns : YAPI_SUCCESS when the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
Page 411
YFiles nextFiles( ) def nextFiles( ) function nextFiles( ) function nextFiles( ) Returns : YFiles null a pointer to a object, corresponding to a filesystem currently online, or a pointer if there are no more filesystems to enumerate. www.yoctopuce.com...
Page 412
To unregister a callback, pass a null pointer as argument. Parameters : callback the callback function to call, or a null pointer. The callback function should take two arguments: the function object of which the value has changed, and the character string describing the new advertised value. www.yoctopuce.com...
Page 413
If you need to ensure that no space is taken by previously deleted files, you can use to fully reinitialize the filesystem. format_fs Parameters : pathname path and name of the file to remove. Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
Page 414
Parameters : newval a string corresponding to the logical name of the filesystem. Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
Page 415
$data) function set_userData( data) This attribute is never touched by the API, and is at disposal of the caller to store a context. Parameters : any kind of object to be stored data www.yoctopuce.com...
Page 416
This function reverts the effect of a previous call to . Remember to call the muteValueCallbacks() saveToFlash() method of the module if the modification must be kept. Returns : YAPI_SUCCESS when the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
Page 417
If a file already exists with the same path name, its content is overwritten. Parameters : pathname path and name of the new file to create content binary buffer with the content to set Returns : YAPI_SUCCESS if the call succeeds. On failure, throws an exception or returns a negative error code. www.yoctopuce.com...
Page 418
The callback function receives two arguments: the caller-specific context object and the receiving function object. context caller-specific object that is passed as-is to the callback function Returns : nothing. www.yoctopuce.com...
23. Troubleshooting 23.1. Where to start? If it is the first time that you use a Yoctopuce module and you do not really know where to start, have a look at the Yoctopuce blog. There is a section dedicated to beginners 23.2.
23.5. Powered module but invisible for the OS If your Yocto-Display is connected by USB, if its blue led is on, but if the operating system cannot see the module, check that you are using a true USB cable with data wires, and not a charging cable.
Waste Electrical and Electronic Equipment (WEEE) If you really want to get rid of your Yocto-Display, do not throw it away in a trash bin but bring it to your local WEEE recycling point. In this way, it will be disposed properly by a specialized WEEE recycling center.
24. Characteristics You can find below a summary of the main technical characteristics of your Yocto-Display module. Display area 55 x 13.1 mm USB connector micro-B Width 58 mm Length 66 mm Weight 19 g Resolution 128 x 32 px...