Implement button mmap
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
namespace pxsim {
|
||||
|
||||
export class EV3ButtonState extends CommonButtonState{
|
||||
export class EV3ButtonState extends CommonButtonState {
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
@ -13,6 +13,24 @@ namespace pxsim {
|
||||
new CommonButton(DAL.BUTTON_ID_ESCAPE),
|
||||
new CommonButton(DAL.BUTTON_ID_ALL)
|
||||
];
|
||||
let data = new Uint8Array(this.buttons.length)
|
||||
MMapMethods.register("/dev/lms_ui", {
|
||||
data,
|
||||
beforeMemRead: () => {
|
||||
for (let i = 0; i < this.buttons.length; ++i)
|
||||
data[i] = this.buttons[i].isPressed() ? 1 : 0
|
||||
},
|
||||
read: buf => {
|
||||
let v = "vSIM"
|
||||
for (let i = 0; i < buf.data.length; ++i)
|
||||
buf.data[i] = v.charCodeAt(i) || 0
|
||||
return buf.data.length
|
||||
},
|
||||
write: buf => {
|
||||
pxsim.output.setLights(buf.data[0] - 48)
|
||||
return 2
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user