-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.ts
122 lines (118 loc) · 4.44 KB
/
test.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
/**
* tests go here; this will not be compiled when this package is used as a library
*/
function inputSerialDisplay() {
serial.writeString("OPP: ")
serial.writeNumber(sumobit.oppSensorValue(SumobitSensorSelection1.Left))
serial.writeNumber(sumobit.oppSensorValue(SumobitSensorSelection1.FrontLeft))
serial.writeNumber(sumobit.oppSensorValue(SumobitSensorSelection1.Center))
serial.writeNumber(sumobit.oppSensorValue(SumobitSensorSelection1.FrontRight))
serial.writeNumber(sumobit.oppSensorValue(SumobitSensorSelection1.Right))
serial.writeString(" | ")
serial.writeString("EDGE_R: ")
serial.writeNumber(sumobit.fetchEdgeValue(SumobitEdgeSelection.Right))
serial.writeString(" EDGE_L: ")
serial.writeNumber(sumobit.fetchEdgeValue(SumobitEdgeSelection.Left))
serial.writeString(" | ")
serial.writeString("")
serial.writeString("Mode: ")
serial.writeNumber(sumobit.readModeValue())
serial.writeString(" | ")
serial.writeString("Battery: ")
serial.writeNumber(sumobit.readBatteryValue())
serial.writeLine("")
basic.pause(100)
}
sumobit.calibrateEdgeThreshold(5)
sumobit.setAllRgbPixelsColor(0xff0000)
sumobit.disableServo(SumobitServoChannel.All)
basic.pause(100)
sumobit.setRgbPixelColor(0, sumobit.rgb(0, 0, 255))
sumobit.setRgbPixelColor(1, 0x00ffff)
sumobit.setServoPosition(SumobitServoChannel.Servo1, 90, 5)
basic.pause(100)
sumobit.clearAllRgbPixels()
sumobit.countdown(SumobitCountdown.Three)
sumobit.setMotorsSpeed(100, 100, 9)
sumobit.setServoPosition(SumobitServoChannel.Servo2, 90, 5)
basic.pause(500)
sumobit.runMotor(SumobitMotorChannel.RightMotor, SumobitMotorDirection.Forward, 128, 9)
sumobit.runMotor(SumobitMotorChannel.RightMotor, SumobitMotorDirection.Backward, 128, 9)
sumobit.setServoPosition(SumobitServoChannel.Servo2, 180, 5)
basic.pause(300)
sumobit.stopMotor(SumobitMotorChannel.Both)
let StartVar = 1
basic.clearScreen()
basic.forever(function () {
inputSerialDisplay()
if (StartVar == 1) {
if (sumobit.checkMode(1)) {
if (sumobit.oppSensorDetection(SumobitSensorSelection2.Left)) {
basic.showLeds(`
# . . . .
. . . . .
. . . . .
. . . . .
. . . . .
`)
} else if (sumobit.oppSensorDetection(SumobitSensorSelection2.FrontLeft)) {
basic.showLeds(`
. # . . .
. . . . .
. . . . .
. . . . .
. . . . .
`)
} else if (sumobit.oppSensorDetection(SumobitSensorSelection2.Center)) {
basic.showLeds(`
. . # . .
. . . . .
. . . . .
. . . . .
. . . . .
`)
} else if (sumobit.oppSensorDetection(SumobitSensorSelection2.FrontRight)) {
basic.showLeds(`
. . . # .
. . . . .
. . . . .
. . . . .
. . . . .
`)
} else if (sumobit.oppSensorDetection(SumobitSensorSelection2.Right)) {
basic.showLeds(`
. . . . #
. . . . .
. . . . .
. . . . .
. . . . .
`)
} else {
basic.clearScreen()
}
} else {
}
if (sumobit.checkMode(2)) {
sumobit.attack(0, 9)
} else {
}
if (sumobit.checkMode(3)) {
if (sumobit.compareEdgeCalibrated(SumobitEdgeSelection.Right)) {
sumobit.setRgbPixelColor(1, 0xff0000)
basic.pause(500)
sumobit.backoff(SumobitDirection.Left, 50, 9)
} else if (sumobit.compareEdgeCalibrated(SumobitEdgeSelection.Left)) {
sumobit.setRgbPixelColor(0, 0xff0000)
basic.pause(500)
sumobit.backoff(SumobitDirection.Right, 50, 9)
} else {
sumobit.clearAllRgbPixels()
}
} else {
}
if (sumobit.checkMode(4)) {
sumobit.search(SumobitSearch.Normal, 50, 9)
} else {
}
}
})