久久久久久久999_99精品久久精品一区二区爱城_成人欧美一区二区三区在线播放_国产精品日本一区二区不卡视频_国产午夜视频_欧美精品在线观看免费
標(biāo)題:
Android串口顯示加+MVAndroidchart圖表
[打印本頁]
作者:
herui123456
時間:
2021-11-17 10:47
標(biāo)題:
Android串口顯示加+MVAndroidchart圖表
IMG_20211110_193229.jpg
(2.62 MB, 下載次數(shù): 90)
下載附件
2021-11-17 10:47 上傳
1.串口使用
private fun openSerialPort(){
serialPortFinder = SerialPortFinder()
serialHelper = object : SerialHelper() {
override fun onDataReceived(comBean: ComBean) {
runOnUiThread {
// Toast.makeText(
// baseContext,
// FuncUtil.ByteArrToHex(comBean.bRec),
// Toast.LENGTH_SHORT
// ).show()
/*
* TODO 將獲取的數(shù)據(jù)進(jìn)行列表適配
* */
map = HashMap()
(map as HashMap<String, Any>)["Value"] =comBean.sRecTime + ": " +
ByteUtil.hexStringToString(ByteUtil.bytesToHexString(comBean.bRec))
list.add(map as HashMap<String, Any>)
Handler(Looper.getMainLooper()).postDelayed({
/**
* 列表數(shù)據(jù)的溢處理已經(jīng)適配
* */
if (list.size>12){
map = list[0]
list.remove(map)
}
initAdapter()
}, 300)
}
}
}
//獲取串口地址
val ports = serialPortFinder!!.allDevicesPath
//設(shè)置波特率地址
val botes = arrayOf(
"0",
"50",
"75",
"110",
"134",
"150",
"200",
"300",
"600",
"1200",
"1800",
"2400",
"4800",
"9600",
"19200",
"38400",
"57600",
"115200",
"230400",
"460800",
"500000",
"576000",
"921600",
"1000000",
"1152000",
"1500000",
"2000000",
"2500000",
"3000000",
"3500000",
"4000000"
)
val spAdapter = SpAdapter(this)
/*
* TODO 適配下拉列表(串口地址)
* */
spAdapter.setDatas(ports)
binding.spSerial.adapter = spAdapter
binding.spSerial.onItemSelectedListener = object : OnItemSelectedListener {
override fun onItemSelected(
parent: AdapterView<*>?,
view: View,
position: Int,
id: Long
) {
serialHelper?.close()
serialHelper?.port = ports[position]
binding.EditText1.setText(ports[position])
binding.open.text = "關(guān)閉串口"
}
override fun onNothingSelected(parent: AdapterView<*>?) {}
}
/*
* TODO 適配下拉列表(波特率地址)
* */
val spAdapter2 = SpAdapter(this)
spAdapter2.setDatas(botes)
binding.spBote.adapter = spAdapter2
binding.spBote.onItemSelectedListener = object : OnItemSelectedListener {
override fun onItemSelected(
parent: AdapterView<*>?,
view: View,
position: Int,
id: Long
) {
serialHelper?.close()
serialHelper?.setBaudRate(botes[position])
binding.EditText2.setText(botes[position])
binding.open.text = "關(guān)閉串口"
}
override fun onNothingSelected(parent: AdapterView<*>?) {}
}
}
override fun initListener() {
//打開串口
binding.open.setOnClickListener{
try {
serialHelper?.open()
binding.open.text = "打開成功"
showToast("打開成功")
} catch (e: IOException) {
e.printStackTrace()
}
}
//發(fā)送消息
binding.send.setOnClickListener{
if (binding.radioGroup.getCheckedRadioButtonId() == R.id.radioButton1) {
if (binding.SendText.text.toString().isNotEmpty()) {
if (serialHelper!!.isOpen) {
serialHelper!!.sendTxt(binding.SendText.text.toString())
} else {
showToast("搞毛啊,串口都沒打開")
}
} else {
showToast("填數(shù)據(jù)吧")
}
} else {
if (binding.SendText.text.toString().length > 0) {
if (serialHelper!!.isOpen) {
serialHelper!!.sendHex(binding.SendText.text.toString())
} else {
showToast("搞毛啊,串口都沒打開")
}
} else {
showToast("填數(shù)據(jù)吧")
}
}
}
//toolbar返回按鈕監(jiān)聽
binding.toolbar.setNavigationOnClickListener { finish() }
}
復(fù)制代碼
項(xiàng)目地址:HTTPS ://gitee.com/herui12/教MVAndroidchart
歡迎光臨 (http://m.zg4o1577.cn/bbs/)
Powered by Discuz! X3.1
主站蜘蛛池模板:
中文在线一区
|
国产亚洲视频在线观看
|
国产一区欧美
|
精品视频在线播放
|
天堂av网站
|
国产一区二区在线播放
|
亚洲 欧美 激情 另类 校园
|
一本色道久久综合亚洲精品小说
|
日韩高清在线播放
|
日韩理论在线
|
成人黄色av
|
久久免费精品视频
|
欧美午夜在线观看
|
日韩视频在线免费观看
|
中国一级毛片免费看
|
欧美精品区
|
在线播放av网站
|
亚洲激情成人
|
亚洲在线视频观看
|
毛片毛片毛片
|
日本久久久久久久久
|
人人爱av
|
成人久久av
|
日本一级片在线观看
|
日本黄色片视频
|
日本不卡在线播放
|
欧美a级成人淫片免费看
|
五月天婷婷网站
|
在线观看av片
|
亚洲国产精品一区二区三区
|
第一福利视频导航
|
长河落日连续剧48集免费观看
|
日韩一区二区三区视频
|
天天澡天天狠天天天做
|
久久精品久久久精品美女
|
欧美在线亚洲
|
免费看黄色aaaaaa 片
|
91精品国产乱码久久久
|
a一级黄色片
|
激情91
|
99re视频在线
|