}
}
Each property
xxx
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.
Changing the module settings
When you want to modify the settings of a module, you only need to call the corresponding
YModule.set_xxx()
function. However, this modification is performed only in the random access
memory (RAM) of the module: if the module is restarted, the modifications are lost. To memorize
them persistently, it is necessary to ask the module to save its current configuration in its permanent
memory. To do so, use the
YModule.saveToFlash()
method. Inversely, it is possible to force
the module to forget its current settings by using the
YModule.revertFromFlash()
method.
The short example below allows you to modify the logical name of a module.
import
com.yoctopuce.YoctoAPI.*
;
public
class
Demo
{
public
static
void
main
(
String
[]
args
)
{
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 ("
+
ex.
getLocalizedMessage
()
+
")"
);
System
.
out
.
println
(
"Ensure that the VirtualHub application is running"
);
System
.
exit
(
1
);
}
if
(
args.
length
!=
2
)
{
System
.
out
.
println
(
"usage: demo <serial or logical name> <new logical name>"
);
System
.
exit
(
1
);
}
YModule
m
;
String
newname
;
m
=
YModule
.
FindModule
(
args
[
0
]);
// use serial or logical name
try
{
newname
=
args
[
1
];
if
(!
YAPI
.
CheckLogicalName
(
newname
))
{
System
.
out
.
println
(
"Invalid name ("
+
newname
+
")"
);
System
.
exit
(
1
);
}
m.
set_logicalName
(
newname
);
m.
saveToFlash
();
// do not forget this
System
.
out
.
println
(
"Module: serial= "
+
m.
get_serialNumber
());
System
.
out
.
println
(
" / name= "
+
m.
get_logicalName
());
}
catch
(
YAPI_Exception
ex
)
{
System
.
out
.
println
(
"Module "
+
args
[
0
]
+
"not connected (check identification
and USB cable)"
);
System
.
out
.
println
(
ex.
getMessage
());
System
.
exit
(
1
);
}
YAPI
.
FreeAPI
();
}
}
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. In short,
18. Using the Yocto-Display with Java
www.yoctopuce.com
111
Summary of Contents for Yocto-Display
Page 1: ...Yocto Display User Manual...
Page 2: ......
Page 40: ...34 www yoctopuce com...
Page 52: ...46 www yoctopuce com...
Page 84: ...78 www yoctopuce com...
Page 92: ...86 www yoctopuce com...
Page 130: ...124 www yoctopuce com...
Page 422: ...416 www yoctopuce com...