Skip to content

Commit

Permalink
Merge pull request #2 from Adam0Brien/usv-lib-basic
Browse files Browse the repository at this point in the history
Added basic implementation of a USV microbit library
  • Loading branch information
Adam O'Brien authored Dec 21, 2023
2 parents 72e920a + 934eb86 commit 0f5619b
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions microbit-usv-lib/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
namespace USV {

//% blockId=deploy
//% block="deploy sensor pod %v"
export function deploy(): void { }

//% blockId=initPod
//% block="Initialise Sensor pod %v"
export function initPod(): void { }

//% blockId=move
//% block="Move USV Forward%v"
export function move(): void { }



export enum direction {
//% block="Forward Fast"
FullSpeedForward = 120,
//% block="Backward Fast"
FullSpeedBackwards = 60,
//% block="Forward Slow"
HalfSpeedForward = 105,
//% block="Backward Slow"
HalfSpeedBackward = 75,
//% block="Stop"
Stop = 89,
}

export enum Servos {
//%blockId=kitronik_motordriver_motor_one
//% block="Servo 1"
Servo1 = 0,
//%blockId=kitronik_motordriver_motor_two
//% block="Servo 2"
Servo2 = 1
}

/**
* Configure the USV Servos.
*/
//% weight=50
//% blockId=USV_Servo block="Move |%Servo|%speed"
//% speed.min=60 speed.max=120
//% index.fieldEditor="gridpicker" index.fieldOptions.columns=2
export function USV_Servo(index: Servos, speed: direction): void {
let buf = pins.createBuffer(2);
if (index == 0) {
buf[0] = 0x14;
}
if (index == 1) {
buf[0] = 0x15;
}

buf[1] = speed;
pins.i2cWriteBuffer(0x16, buf);
}


}

0 comments on commit 0f5619b

Please sign in to comment.