From 15182c052a4f79c8761b43ba4afebf82683636f4 Mon Sep 17 00:00:00 2001 From: noqman <140384051+noqman@users.noreply.github.com> Date: Mon, 18 Nov 2024 16:13:45 +0800 Subject: [PATCH] Moved opponent sensor software pull-up into the oppSensorValue --- main.ts | 8 -------- opponent.ts | 7 +++++++ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/main.ts b/main.ts index df3481d..8f9cfa0 100644 --- a/main.ts +++ b/main.ts @@ -44,14 +44,6 @@ const REG_VIN_R2 = 34; const REG_ADD_DIP = 35; const REG_ADD_RESET = 36; -// Software pullup for the opponent sensors -pins.setPull(DigitalPin.P16, PinPullMode.PullUp) -pins.setPull(DigitalPin.P15, PinPullMode.PullUp) -pins.setPull(DigitalPin.P14, PinPullMode.PullUp) -pins.setPull(DigitalPin.P13, PinPullMode.PullUp) -pins.setPull(DigitalPin.P12, PinPullMode.PullUp) - - /** * Blocks for SUMO:BIT. */ diff --git a/opponent.ts b/opponent.ts index a7c0fb2..ef271f8 100644 --- a/opponent.ts +++ b/opponent.ts @@ -63,6 +63,13 @@ namespace sumobit { //% position.fieldEditor="gridpicker" position.fieldOptions.columns=5 export function oppSensorValue(sensor: SumobitSensorSelection1): number { + // Software pullup for the opponent sensors + pins.setPull(DigitalPin.P16, PinPullMode.PullUp) + pins.setPull(DigitalPin.P15, PinPullMode.PullUp) + pins.setPull(DigitalPin.P14, PinPullMode.PullUp) + pins.setPull(DigitalPin.P13, PinPullMode.PullUp) + pins.setPull(DigitalPin.P12, PinPullMode.PullUp) + switch (sensor) { case SumobitSensorSelection1.Left: return pins.digitalReadPin(DigitalPin.P16);