-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from Adam0Brien/sensor-pod-comms
feat: Added Sensor Pod to USV Comms.
- Loading branch information
Showing
2 changed files
with
83 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// Starter Implementation | ||
// Change on button A and B pressed to physical circuit | ||
input.onButtonPressed(Button.A, function () { | ||
isSubmerged = 0 | ||
}) | ||
input.onButtonPressed(Button.B, function () { | ||
isSubmerged = 1 | ||
}) | ||
let isSubmerged = 0 | ||
radio.setGroup(213) | ||
basic.showIcon(IconNames.Yes) | ||
USVSensorPod.initLocalDisplay() | ||
let ph_list: number[] = [] | ||
let light_list: number[] = [] | ||
let temp_list: number[] = [] | ||
isSubmerged = 1 | ||
basic.forever(function () { | ||
USVSensorPod.ShowString("Temp:" + USVSensorPod.calculateTempC() + "°C", 0, 0) | ||
USVSensorPod.ShowString("pH:" + USVSensorPod.calculatePh(), 0, 1) | ||
}) | ||
basic.forever(function () { | ||
if (isSubmerged == 1) { | ||
ph_list.push(USVSensorPod.calculatePh()) | ||
temp_list.push(USVSensorPod.calculateTempC()) | ||
light_list.push(USVSensorPod.getLight()) | ||
basic.pause(100) | ||
led.toggle(4, 0) | ||
} | ||
}) | ||
basic.forever(function () { | ||
if (isSubmerged == 0) { | ||
for (let value of ph_list) { | ||
radio.sendValue("pH", value) | ||
basic.pause(1000) | ||
ph_list.removeAt(ph_list.indexOf(value)) | ||
} | ||
} | ||
}) | ||
basic.forever(function () { | ||
if (isSubmerged == 0) { | ||
for (let value of light_list) { | ||
radio.sendValue("light", value) | ||
basic.pause(1000) | ||
led.toggle(0, 0) | ||
light_list.removeAt(light_list.indexOf(value)) | ||
} | ||
} | ||
}) | ||
basic.forever(function () { | ||
if (isSubmerged == 0) { | ||
for (let value of temp_list) { | ||
radio.sendValue("tempC", value) | ||
basic.pause(100) | ||
temp_list.removeAt(temp_list.indexOf(value)) | ||
} | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters