forked from xtoolbox/TeenyUSB
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hidview.lua
36 lines (35 loc) · 1.18 KB
/
hidview.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
-- hidview.lua
--
dofile("hidparamview.lua")
class "HIDView"(QFrame)
function HIDView:__init(vid,pid)
QFrame.__init(self)
self.windowTitle = tr("HID View")
self.param = HIDParamView(vid,pid)
self.btnSend = QPushButton(tr("Send"))
self.btnClear = QPushButton(tr("Clear"))
self.sendEdit = QHexEdit{ readonly = false, overwriteMode = false}
self.recvEdit = QHexEdit { readonly = true, overwriteMode = false }
self.layout = QVBoxLayout{
self.param,
QHBoxLayout{QLabel(tr("Send data")), self.btnSend,QLabel(), strech = "0,0,1"},
self.sendEdit,
QHBoxLayout{QLabel(tr("Recv data")), self.btnClear,QLabel(), strech = "0,0,1"},
self.recvEdit,
}
self.btnSend.clicked = function()
local reportID = 0
r = self.param.hid:writeData(reportID, self.sendEdit.data)
if r ~= self.param.hid.caps.outputReportLength then
log(r, self.param.hid.errorString)
end
end
self.btnClear.clicked = function()
self.recvEdit:clear()
end
self.param.hid.readyRead = function()
r = self.param.hid:readAll()
self.recvEdit:append(r)
self.recvEdit:scrollToEnd()
end
end