Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added basic implementation of a USV microbit library #2

Merged
merged 1 commit into from
Dec 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}


}