forked from AITosee/pxt-sentry2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.ts
More file actions
56 lines (56 loc) · 2.52 KB
/
Copy pathtest.ts
File metadata and controls
56 lines (56 loc) · 2.52 KB
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
function kVisionQrCode() {
Sentry2VisionSensor.VisionSetStatus(sentry2_status.Enable, sentry_vision_e.kVisionQrCode)
while (true) {
count = Sentry2VisionSensor.Detected(sentry_vision_e.kVisionQrCode)
serial.writeValue("count", count)
if (count) {
for (let index = 0; index < count; index++) {
serial.writeValue("x", Sentry2VisionSensor.QrcodeValue(sentry_qr_info_e.kXValue, count))
serial.writeValue("y", Sentry2VisionSensor.QrcodeValue(sentry_qr_info_e.kXValue, count))
serial.writeValue("w", Sentry2VisionSensor.QrcodeValue(sentry_qr_info_e.kXValue, count))
serial.writeValue("h", Sentry2VisionSensor.QrcodeValue(sentry_qr_info_e.kXValue, count))
serial.writeString(Sentry2VisionSensor.QrcodeValueString())
}
}
}
Sentry2VisionSensor.VisionSetStatus(sentry2_status.Disable, sentry_vision_e.kVisionQrCode)
}
function kVisionColor() {
Sentry2VisionSensor.VisionSetStatus(sentry2_status.Enable, sentry_vision_e.kVisionColor)
Sentry2VisionSensor.SetParamNum(sentry_vision_e_2.kVisionColor, 4)
Sentry2VisionSensor.SetColorParam(10, 50, 3, 4, 1)
Sentry2VisionSensor.SetColorParam(40, 50, 3, 4, 2)
Sentry2VisionSensor.SetColorParam(60, 50, 3, 4, 3)
Sentry2VisionSensor.SetColorParam(80, 50, 3, 4, 4)
while (true) {
count = Sentry2VisionSensor.Detected(sentry_vision_e.kVisionColor)
if (count) {
serial.redirectToUSB()
serial.writeValue("count", count)
for (let index = 0; index < count; index++) {
serial.writeValue("l", Sentry2VisionSensor.ColorRcgValue(sentry_color_info_e.kLabel, 1))
serial.writeValue("r", Sentry2VisionSensor.ColorRcgValue(sentry_color_info_e.kRValue, 1))
serial.writeValue("g", Sentry2VisionSensor.ColorRcgValue(sentry_color_info_e.kGValue, 1))
serial.writeValue("b", Sentry2VisionSensor.ColorRcgValue(sentry_color_info_e.kBValue, 1))
}
serial.redirect(
SerialPin.P14,
SerialPin.P13,
BaudRate.BaudRate9600
)
}
}
Sentry2VisionSensor.VisionSetStatus(sentry2_status.Disable, sentry_vision_e.kVisionColor)
}
let count = 0
serial.redirect(
SerialPin.P14,
SerialPin.P13,
BaudRate.BaudRate9600
)
Sentry2VisionSensor.Begin(sentry_mode_e.kSerialMode, sentry2_addr_e.ADDR1)
basic.forever(function () {
kVisionColor()
basic.pause(1000)
kVisionQrCode()
})