forked from keigan-motor/pxt-KeiganMotor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.ts
716 lines (608 loc) · 21.8 KB
/
main.ts
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
/**
* This extension enables to control KeiganMotor via "RADIO"
*
* Refer to https://ukbaz.github.io/howto/ubit_radio.html
* to know RADIO Packet data structure
*
* Packet Spec:
* 0 1 2 | 3 | 4 ... 7 | 8 ... 11 | 12 ... 31
* --------------------------------------------------------------------------
* dal header | packet type | system time | serial number | payload
*
* --- DAL HEADER
01 raw payload
00 group number
01 version 1
*
* Packet from KeiganMotor also meets this packet structure.
* The serial number is KeiganMotor's serial number.
*/
/**
* LED state
*/
enum led_state {
OFF = 0,
ON_SOLID = 1,
ON_FLASH = 2,
ON_DIM = 3
}
/**
* Playback motion start option
*/
enum playback_option {
START_FROM_RAW = 0, // Start from the raw position.
START_FROM_CURRENT = 1, // Start from the current position.
}
/**
* Functions to operate KeiganMotor
*/
//% weight=5 color=#D82317 icon="\uf110"
namespace keiganmotor {
const RPM_TO_RADIANPERSEC = 0.10471975511965977
const RADIANPERSEC_TO_RPM = 9.54929658551
const DEGREE_TO_RADIAN = 0.017453292519943295
const RADIAN_TO_DEGREE = 57.2957795131
const CMD_REG_MAX_SPEED = 0x02
const CMD_REG_MAX_TORQUE = 0x0E
const CMD_ACT_DISABLE = 0x50
const CMD_ACT_ENABLE = 0x51
const CMD_ACT_SPEED = 0x58
const CMD_ACT_RUN_FORWARD = 0x60
const CMD_ACT_RUN_REVERSE = 0x61
const CMD_ACT_RUN_AT_VELOCITY = 0x62
const CMD_ACT_FREE = 0x6C
const CMD_ACT_STOP = 0x6D
const CMD_ACT_MOVE_TO_POSITION = 0x66
const CMD_ACT_MOVE_BY_DISTANCE = 0x68
const CMD_ACT_PRESET_POSITION = 0x5A
const CMD_ACT_PREPARE_PLAYBACK_MOTION = 0x86
const CMD_ACT_START_PLAYBACK_MOTION_FROM_PREP = 0x87
const CMD_ACT_STOP_PLAYBACK_MOTION = 0x88
const CMD_DT_START_TEACH_MOTION = 0xA9
const CMD_DT_STOP_TEACH_MOTION = 0xAC
const CMD_DT_ERASE_MOTION = 0xAD
const CMD_READ_STATUS = 0x9A
const CMD_READ_MOTOR_MEASUREMENT = 0xB4
// TODO const CMD_READ_IMU_MEASUREMENT = 0xB5
const CMD_LED_SET = 0xE0
const CMD_OTHERS_REBOOT = 0xF0
const RECEIVE_TYPE_READ = 0x40
const RECEIVE_TYPE_ERROR = 0xBE
const RECEIVE_TYPE_MOTOR_MEASUREMENT = CMD_READ_MOTOR_MEASUREMENT
// TODO const RECEIVE_TYPE_IMU_MEASUREMENT = CMD_READ_IMU_MEASUREMENT
let motorArray: KeiganMotor[] = [] // Array to put KeiganMotor
let serialNumberArray: number[] = [] // Array to put Number array from KeiganMotor's device name
let mIndex: number = 0
let initialized = false;
let motorReceived: KeiganMotor
/**
* Create a new KeiganMotor by specifying its 4 digit of device name .
* @param name included by KeiganMotor's device name
*/
//% blockId="KeiganMotor_create" block="KeiganMotor %name"
//% weight=90 blockGap=8
//% parts="KeiganMotor"
//% trackArgs=0,2
//% blockSetVariable=m
export function create(name: string): KeiganMotor {
let m = new KeiganMotor(name)
addKeiganMotor(m)
return m
}
/*
* Set RADIO groupId
*/
//% blockId="KeiganMotor_radio" block="Set KeiganMotor RADIO group %id"
//% weight=90 blockGap=8
//% parts="KeiganMotor"
//% advanced=true
export function setGroup(id: number) {
if (0 <= id && id <= 255) radio.setGroup(id);
}
/*
* Add KeiganMotor to mArray
*/
function addKeiganMotor(m: KeiganMotor) {
motorArray[mIndex] = m
serialNumberArray[mIndex] = m.serialNumber
mIndex++
}
/**
* A KeiganMotor
*/
export class KeiganMotor {
name: string
nameBuffer: Buffer
serialNumber: number;
group: number
packetId: number
public velocity: number // [radians per second]
public position: number // [radians]
public torque: number // [N*m]
public rpm: number // [rotation per minute] velocity's another expression
public degree: number // [degree] position's another expression
constructor(name: string) {
this.name = name
this.makeNameBuffer()
this.packetId = 0
radio.setTransmitSerialNumber(true) // Include micro:bit serial number to packet
radio.setGroup(1) // TODO
}
private makeNameBuffer() {
let buf = pins.createBuffer(4)
for (let index = 0; index < 4; index++) {
buf.setNumber(NumberFormat.UInt8BE, index, this.name.charCodeAt(index))
}
this.nameBuffer = buf
this.serialNumber = buf.getNumber(NumberFormat.UInt32LE, 0)
}
/**
* Send Buffer by RADIO
*/
send(buf: Buffer) {
radio.sendBuffer(buf)
this.packetId++
if (this.packetId == 65536) this.packetId = 0
}
/**
* Send command after prepending name = "XXXX"
* [ X X X X | CMD | packetId ]
*/
write(command: number) {
let buf = pins.createBuffer(7) // 4 + 1 + 2
buf.write(0, this.nameBuffer)
buf.setNumber(NumberFormat.UInt8BE, 4, command)
buf.setNumber(NumberFormat.UInt16BE, 5, this.packetId)
this.send(buf)
}
/**
* Send command and float value after prepending name = "XXXX"
* [ X X X X | CMD | packetId | VALUES(BYTES) ]
*/
writeFloat32(command: number, value: number) {
let buf = pins.createBuffer(7 + 4)
buf.write(0, this.nameBuffer)
buf.setNumber(NumberFormat.UInt8BE, 4, command)
buf.setNumber(NumberFormat.UInt16BE, 5, this.packetId)
buf.setNumber(NumberFormat.Float32BE, 7, value)
this.send(buf)
}
/**
* Send command and UInt32 value after prepending name = "XXXX"
* [ X X X X | CMD | packetId | VALUES(BYTES) ]
*/
writeUInt32(command: number, value: number) {
let buf = pins.createBuffer(7 + 4)
buf.write(0, this.nameBuffer)
buf.setNumber(NumberFormat.UInt8BE, 4, command)
buf.setNumber(NumberFormat.UInt16BE, 5, this.packetId)
buf.setNumber(NumberFormat.UInt32LE, 7, value)
this.send(buf)
}
/**
* Send command, UInt16 and UInt32 values after prepending name = "XXXX"
* [ X X X X | CMD | packetId | VALUE1 | VALUE2 ]
*/
writeUInt16UInt32(command: number, value1: number, value2: number) {
let buf = pins.createBuffer(7 + 2 + 4)
buf.write(0, this.nameBuffer)
buf.setNumber(NumberFormat.UInt8BE, 4, command)
buf.setNumber(NumberFormat.UInt16BE, 5, this.packetId)
buf.setNumber(NumberFormat.UInt16BE, 7, value1)
buf.setNumber(NumberFormat.UInt32BE, 9, value2)
this.send(buf)
}
/**
* Send command, UInt16, UInt32, and UInt8 value after prepending name = "XXXX"
* [ X X X X | CMD | packetId | VALUE1 | VALUE2 | VALUE3 ]
*/
writeUInt16UInt32UInt8(command: number, value1: number, value2: number, value3: number) {
let buf = pins.createBuffer(7 + 2 + 4 + 1)
buf.write(0, this.nameBuffer)
buf.setNumber(NumberFormat.UInt8BE, 4, command)
buf.setNumber(NumberFormat.UInt16BE, 5, this.packetId)
buf.setNumber(NumberFormat.UInt16BE, 7, value1)
buf.setNumber(NumberFormat.UInt32BE, 9, value2)
buf.setNumber(NumberFormat.UInt8BE, 13, value3)
this.send(buf)
}
/**
* Send command and UInt16 value after prepending name = "XXXX"
* [ X X X X | CMD | packetId | VALUE ]
*/
writeUInt16(command: number, value: number) {
let buf = pins.createBuffer(7 + 2)
buf.write(0, this.nameBuffer)
buf.setNumber(NumberFormat.UInt8BE, 4, command)
buf.setNumber(NumberFormat.UInt16BE, 5, this.packetId)
buf.setNumber(NumberFormat.UInt16BE, 7, value)
this.send(buf)
}
/**
* Send command and UInt8 values after prepending name = "XXXX"
* [ X X X X | CMD | packetId | VALUES(BYTES) ]
*/
writeUInt8Array(command: number, values: number[]) {
let buf = pins.createBuffer(7 + values.length)
buf.write(0, this.nameBuffer)
buf.setNumber(NumberFormat.UInt8BE, 4, command)
buf.setNumber(NumberFormat.UInt16BE, 5, this.packetId)
for (let i = 0; i < values.length; i++) {
buf.setNumber(NumberFormat.UInt8BE, 7 + i, values[i])
}
radio.sendBuffer(buf)
}
/**
* Disable action
*/
//% blockId="disable" block="%KeiganMotor|disable action"
//% weight=85 blockGap=8
//% parts="KeiganMotor"
disable() {
this.write(CMD_ACT_DISABLE)
}
/**
* Enable action
*/
//% blockId="enable" block="%KeiganMotor|enable action"
//% weight=85 blockGap=8
//% parts="KeiganMotor"
enable() {
this.write(CMD_ACT_ENABLE)
}
/**
* Set speed [radians/sec]
* @param speed [radians/sec]
*/
speed(value: number) {
this.writeFloat32(CMD_ACT_SPEED, value)
}
/**
* Set speed [rotation/minute]
* @param speed [rotation/minute]
*/
//% blockId="speedRpm" block="%KeiganMotor|set speed [rpm] %value"
//% weight=85 blockGap=8
//% parts="KeiganMotor"
speedRpm(value: number) {
this.speed(RPM_TO_RADIANPERSEC * value)
}
/**
* Run forward
*/
//% blockId="runForward" block="%KeiganMotor|run forward"
//% weight=85 blockGap=8
//% parts="KeiganMotor"
runForward() {
this.write(CMD_ACT_RUN_FORWARD)
}
/**
* Run Reverse
*/
//% blockId="runReverse" block="%KeiganMotor|run reverse"
//% weight=85 blockGap=8
//% parts="KeiganMotor"
runReverse() {
this.write(CMD_ACT_RUN_REVERSE)
}
/**
* Run At Velocity [radian/sec]
* @param velocity [radian/sec]
*/
run(velocity: number) {
this.writeFloat32(CMD_ACT_RUN_AT_VELOCITY, velocity)
}
/**
* Run At Velocity [rotation/minute]
* @param velocity [rotation/minute]
*/
//% blockId="runRpm" block="%KeiganMotor|run at velocity [rpm] %velocity"
//% weight=85 blockGap=8
//% parts="KeiganMotor"
runRpm(velocity: number) {
this.run(RPM_TO_RADIANPERSEC * velocity)
}
/**
* Move To Position [radian]
* @param position [radian]
*/
moveTo(position: number) {
this.writeFloat32(CMD_ACT_MOVE_TO_POSITION, position)
}
/**
* Move To Position [degree]
* @param position [degree]
*/
//% blockId="moveToDeg" block="%KeiganMotor|move to position [degree] %position"
//% weight=85 blockGap=8
//% parts="KeiganMotor"
moveToDeg(position: number) {
this.moveTo(DEGREE_TO_RADIAN * position)
}
/**
* Move By Distance [radian]
* @param distance [radian]
*/
moveBy(distance: number) {
this.writeFloat32(CMD_ACT_MOVE_BY_DISTANCE, distance)
}
/**
* Move To Position [degree]
* @param distance [degree]
*/
//% blockId="moveByDeg" block="%KeiganMotor|move by distance [degree] %distance"
//% weight=85 blockGap=8
//% parts="KeiganMotor"
moveByDeg(distance: number) {
this.moveBy(DEGREE_TO_RADIAN * distance)
}
/**
* Preset Position [radian]
* @param position [radian]
*/
presetPosition(position: number) {
this.writeFloat32(CMD_ACT_PRESET_POSITION, position)
}
/**
* Preset Position [degree]
* @param position [degree]
*/
presetPositionDeg(position: number) {
this.presetPosition(DEGREE_TO_RADIAN * position)
}
/**
* Free (de-energize Motor)
*/
//% blockId="free" block="%KeiganMotor|free"
//% weight=85 blockGap=8
//% parts="KeiganMotor"
free() {
this.write(CMD_ACT_FREE)
}
/**
* Stop (Set speed 0)
*/
//% blockId="stop" block="%KeiganMotor|stop"
//% weight=85 blockGap=8
//% parts="KeiganMotor"
stop() {
this.write(CMD_ACT_STOP)
}
/**
* Erase Motion at Index
* @param index
*/
//% blockId="eraseMotion" block="%KeiganMotor|erase motion at index %index"
//% weight=85 blockGap=8
//% parts="KeiganMotor"
//% advanced=true
eraseMotion(index: number) {
this.writeUInt16(CMD_DT_ERASE_MOTION, index)
}
/**
* Start Teaching Motion at Index
* @param index
* @param time [milliseconds]
*/
//% blockId="startTeachingMotion" block="%KeiganMotor|start teaching motion at index %index"
//% weight=85 blockGap=8
//% parts="KeiganMotor"
//% advanced=true
startTeachingMotion(index: number, time: number) {
this.writeUInt16UInt32(CMD_DT_START_TEACH_MOTION, index, time)
}
/**
* Stop Teaching Motion
*/
//% blockId="stopTeachingMotion" block="%KeiganMotor|stop teaching motion"
//% weight=85 blockGap=8
//% parts="KeiganMotor"
//% advanced=true
stopTeachingMotion() {
this.write(CMD_DT_STOP_TEACH_MOTION)
}
/**
* Prepare Playback Motion at Index
* @param index
* @param repeating // times
* @param option // playback start option
*/
//% blockId="preparePlaybackMotion" block="%KeiganMotor|prepare playback motion at index %index"
//% weight=85 blockGap=8
//% parts="KeiganMotor"
//% advanced=true
preparePlaybackMotion(index: number, repeating: number, option: playback_option) {
let start_op: number = option
this.writeUInt16UInt32UInt8(CMD_ACT_PREPARE_PLAYBACK_MOTION, index, repeating, start_op)
}
/**
* Start Playback Motion at Index
*/
//% blockId="startPlaybackMotion" block="%KeiganMotor|start playback motion"
//% weight=85 blockGap=8
//% parts="KeiganMotor"
//% advanced=true
startPlaybackMotion() {
this.write(CMD_ACT_START_PLAYBACK_MOTION_FROM_PREP)
}
/**
* Stop Playback Motion at Index
*/
//% blockId="stopPlaybackMotion" block="%KeiganMotor|stop playback motion"
//% weight=85 blockGap=8
//% parts="KeiganMotor"
//% advanced=true
stopPlaybackMotion() {
this.write(CMD_ACT_STOP_PLAYBACK_MOTION)
}
/**
* Set LED state to led_state and colors
* @param led_state
* @param red value between 0 and 255. eg: 255
* @param green value between 0 and 255. eg: 255
* @param blue value between 0 and 255. eg: 255
*/
//% blockId="KeiganMotor_led" block="%KeiganMotor|led state %led_state|red %red|green %green|blue %blue"
//% weight=85 blockGap=8
//% parts="KeiganMotor"
led(state: led_state, red: number, green: number, blue: number) {
let s: number = state
this.writeUInt8Array(CMD_LED_SET, [s, red, green, blue])
}
/**
* Reboot
*/
//% blockId="reboot" block="%KeiganMotor|reboot"
//% weight=85 blockGap=8
//% parts="KeiganMotor"
//% advanced=true
reboot() {
this.write(CMD_OTHERS_REBOOT)
}
/**
* Get KeiganMotor parameters
* @return position, velocity, torque
*/
//% blockId="getPosition" block="%KeiganMotor|position [rad]"
//% weight=85 blockGap=8
//% parts="KeiganMotor"
//% advanced=true
getPosition(): number {
return this.position
}
/**
* Get the current position [degree]
* @return the current degree
*/
//% blockId="getDegree" block="%KeiganMotor|degree [deg]"
//% weight=85 blockGap=8
//% parts="KeiganMotor"
getDegree(): number {
let deg = Math.round(this.position * RADIAN_TO_DEGREE * 100) * 0.01 // TODO to long
return deg
}
/**
* Get the current velocity [rad/s]
*/
//% blockId="getVelocity" block="%KeiganMotor|velocity [rad/s]"
//% weight=85 blockGap=8
//% parts="KeiganMotor"
//% advanced=true
getVelocity(): number {
return this.velocity
}
/**
* Get the current velocity [rotation/minute]
*/
//% blockId="getRpm" block="%KeiganMotor|rotations per minute"
//% weight=85 blockGap=8
//% parts="KeiganMotor"
getRpm(): number {
let rpm = Math.roundWithPrecision(this.velocity * RADIANPERSEC_TO_RPM, 1)
return rpm
}
/**
* Get the current torque [Nm]
*/
//% blockId="getTorque" block="%KeiganMotor|torque [Nm]"
//% weight=85 blockGap=8
//% parts="KeiganMotor"
getTorque(): number {
return this.torque
}
/**
* Set Max Torque [Nm]
* @param torque [N*m]
*/
//% blockId="mxTorque" block="%KeiganMotor|set max torque [Nm] %value"
//% weight=85 blockGap=8
//% parts="KeiganMotor"
maxTorque(value: number) {
this.writeFloat32(CMD_REG_MAX_TORQUE, value)
}
/**
* Read Motor Measurement (Position, Velocity and Torque)
*/
//% blockId="readMotor" block="%KeiganMotor|read motor measurement"
//% weight=85 blockGap=8
//% parts="KeiganMotor"
readMotorMeasurement() {
this.write(CMD_READ_MOTOR_MEASUREMENT)
}
}
/*
* Event handler when received packet from KeiganMotor
*/
export const MAKECODE_RADIO_EVT_KEIGAN_READ = 0x140;
export const MAKECODE_RADIO_EVT_KEIGAN_ERROR = 0x1BE;
export const MAKECODE_RADIO_EVT_KEIGAN_MOTOR_MEAS = 0x1B4;
export const MAKECODE_RADIO_EVT_KEIGAN_IMU_MEAS = 0x1B5;
function init_DataReceived() {
if (initialized) return;
initialized = true;
radio.onDataPacketReceived(function (packet: radio.Packet) {
let s = packet.serial
let b = packet.receivedBuffer
let index = serialNumberArray.indexOf(s)
// Returns if packet.serial not matched with any KeiganMotor
if (index < 0) {
console.log("Not found")
return
}
let m = motorArray[index]
let dataType = b.getNumber(NumberFormat.UInt8BE, 4)
switch (dataType) {
case RECEIVE_TYPE_READ:
control.raiseEvent(DAL.MICROBIT_ID_RADIO, MAKECODE_RADIO_EVT_KEIGAN_READ);
break;
case RECEIVE_TYPE_ERROR:
// TODO
let cmd = b.getNumber(NumberFormat.UInt8BE, 7)
let errorCode = b.getNumber(NumberFormat.UInt8BE, 8)
console.logValue("Command", cmd)
console.logValue("Error Code:", errorCode)
control.raiseEvent(DAL.MICROBIT_ID_RADIO, MAKECODE_RADIO_EVT_KEIGAN_ERROR);
break;
case CMD_READ_MOTOR_MEASUREMENT:
// Initialize 4 bytes buffer
// NOTE) getNumber(NumberFormat.Float32BE, 0) causes the following error without these initialize.
// error: "Floar32Array should be multiple of 4"
let posBuffer = pins.createBuffer(4)
let velBuffer = pins.createBuffer(4)
let trqBuffer = pins.createBuffer(4)
let posSourceBuffer = b.slice(5, 4)
let velSourceBuffer = b.slice(9, 4)
let trqSourceBuffer = b.slice(13, 4)
posBuffer.write(0, posSourceBuffer)
velBuffer.write(0, velSourceBuffer)
trqBuffer.write(0, trqSourceBuffer)
let pos = posBuffer.getNumber(NumberFormat.Float32BE, 0)
let vel = velBuffer.getNumber(NumberFormat.Float32BE, 0)
let trq = trqBuffer.getNumber(NumberFormat.Float32BE, 0)
m.position = pos
m.velocity = vel
m.torque = trq
motorReceived = m
//console.logValue("pos", pos)
//console.logValue("vel", vel)
//console.logValue("trq", trq)
control.raiseEvent(DAL.MICROBIT_ID_RADIO, MAKECODE_RADIO_EVT_KEIGAN_MOTOR_MEAS);
break;
default:
break;
}
})
}
/**
* Event handler when received motor measurement from KeiganMotor
*/
//% blockId="Received_Motor_Meas" block="on received motor measurement"
//% weight=90 blockGap=8
//% parts="KeiganMotor"
export function onReceivedMotorMeasurement(cb: (motor: KeiganMotor) => void) {
init_DataReceived();
control.onEvent(DAL.MICROBIT_ID_RADIO, MAKECODE_RADIO_EVT_KEIGAN_MOTOR_MEAS, () => {
cb(motorReceived)
});
}
}