@Override
protected
void
onStart
()
{
super
.
onStart
()
;
try
{
aa.
clear
()
;
YAPI.
EnableUSBHost
(this)
;
YAPI.
RegisterHub
(
"usb"
)
;
YModule r = YModule.
FirstModule
()
;
while
(
r !=
null
)
{
String
hwid = r.
get_hardwareId
()
;
aa.
add
(
hwid
)
;
r = r.
nextModule
()
;
}
}
catch
(
YAPI_Exception e
)
{
e.
printStackTrace
()
;
}
// refresh Spinner with detected relay
aa.
notifyDataSetChanged
()
;
}
@Override
protected
void
onStop
()
{
super
.
onStop
()
;
YAPI.
FreeAPI
()
;
}
private
void
DisplayModuleInfo
()
{
TextView field;
if
(
module ==
null
)
return
;
try
{
YAPI.
UpdateDeviceList
()
;
// fixme
field =
(
TextView
)
findViewById
(
R.
id
.
logicalnamefield
)
;
field.
setText
(
module.
getLogicalName
())
;
}
catch
(
YAPI_Exception e
)
{
e.
printStackTrace
()
;
}
}
@Override
public
void
onItemSelected
(
AdapterView<?> parent,
View
view,
int
pos,
long
id
)
{
String
hwid = parent.
getItemAtPosition
(
pos
)
.
toString
()
;
module = YModule.
FindModule
(
hwid
)
;
DisplayModuleInfo
()
;
}
@Override
public
void
onNothingSelected
(
AdapterView<?> arg0
)
{
}
public
void
saveName
(
View
view
)
{
if
(
module ==
null
)
return
;
EditText edit =
(
EditText
)
findViewById
(
R.
id
.
newname
)
;
String
newname = edit.
getText
()
.
toString
()
;
try
{
if
(
!YAPI.
CheckLogicalName
(
newname
))
{
Toast.
makeText
(
getApplicationContext
()
,
"Invalid name ("
+ n
")"
,
Toast.
LENGTH_LONG
)
.
show
()
;
return
;
}
module.
set_logicalName
(
newname
)
;
module.
saveToFlash
()
;
// do not forget this
edit.
setText
(
""
)
;
}
catch
(
YAPI_Exception ex
)
{
ex.
printStackTrace
()
;
}
DisplayModuleInfo
()
;
}
17. Using the Yocto-RangeFinder with Android
www.yoctopuce.com
111
Содержание Yocto-RangeFinder
Страница 1: ...Yocto RangeFinder User s guide...
Страница 2: ......
Страница 18: ...12 www yoctopuce com...
Страница 26: ...20 www yoctopuce com...
Страница 42: ...36 www yoctopuce com...
Страница 70: ...gcc lyocto lm lpthread lusb 1 0 lstdc 10 Using Yocto RangeFinder with C 64 www yoctopuce com...
Страница 90: ...84 www yoctopuce com...
Страница 120: ...114 www yoctopuce com...
Страница 130: ...124 www yoctopuce com...
Страница 158: ...21 High level API Reference On failure throws an exception or returns a negative error code 152 www yoctopuce com...
Страница 484: ...478 www yoctopuce com...
Страница 488: ...482 www yoctopuce com...
Страница 490: ...23 Characteristics 484 www yoctopuce com...
Страница 491: ......
Страница 492: ......