-
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 #2 from Adam0Brien/usv-lib-basic
Added basic implementation of a USV microbit library
- Loading branch information
Showing
1 changed file
with
60 additions
and
0 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,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); | ||
} | ||
|
||
|
||
} |