Skip to content

Commit

Permalink
Replace radio with bluetooth
Browse files Browse the repository at this point in the history
  • Loading branch information
fredster33 committed Nov 6, 2021
1 parent 98ae752 commit 494d621
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 9 deletions.
Binary file modified .github/makecode/blocks.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .github/makecode/blocksdiff.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 9 additions & 2 deletions main.blocks

Large diffs are not rendered by default.

28 changes: 23 additions & 5 deletions main.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/**
* radio send string HELP
*
* replace with "bluetooth uart write string e:HELP"
*/
function simpleCompass () {
if (Math.constrain(input.compassHeading(), 315, 360) == input.compassHeading()) {
basic.showString("N")
Expand All @@ -18,19 +23,26 @@ input.onButtonPressed(Button.A, function () {
menu = 0
}
})
radio.onReceivedString(function (receivedString) {
if (receivedString == "HELP") {
/**
* on radio recieved recievedstring
*
* if recievedstring
*
* else if recievedstring
*/
bluetooth.onUartDataReceived(serial.delimiters(Delimiters.NewLine), function () {
if (bluetooth.uartReadUntil(serial.delimiters(Delimiters.NewLine)) == "e:HELP") {
recievedMessage = 1
basic.showString("HELP")
} else if (receivedString == "FALL") {
} else if (bluetooth.uartReadUntil(serial.delimiters(Delimiters.NewLine)) == "e:FALL") {
recievedMessage = 1
basic.showString("FALL")
}
})
input.onButtonPressed(Button.B, function () {
if (askedForHelp == 1) {
sentHelp = 1
radio.sendString("HELP")
bluetooth.uartWriteString("e:HELP")
basic.showIcon(IconNames.Yes)
}
})
Expand All @@ -55,6 +67,11 @@ function detailedCompass () {
basic.showString("NW")
}
}
/**
* radio set group radioChannel
*
* (just delete, replace with start bluetooth)
*/
let distance = 0
let recievedMessage = 0
let sentHelp = 0
Expand All @@ -66,7 +83,8 @@ menu = 0
askedForHelp = 0
sentHelp = 0
recievedMessage = 0
radio.setGroup(radioChannel)
bluetooth.startUartService()
bluetooth.setTransmitPower(7)
if (timeFormat == 12) {
timeanddate.setTime(5, 24, 0, timeanddate.MornNight.AM)
} else {
Expand Down
4 changes: 2 additions & 2 deletions pxt.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
"description": "",
"dependencies": {
"core": "*",
"radio": "*",
"microphone": "*",
"microbit-pxt-timeanddate": "github:bsiever/microbit-pxt-timeanddate#v2.0.24",
"pxt-sonar": "github:microsoft/pxt-sonar#v0.0.5"
"pxt-sonar": "github:microsoft/pxt-sonar#v0.0.5",
"bluetooth": "*"
},
"files": [
"main.blocks",
Expand Down

1 comment on commit 494d621

@fredster33
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please # to comment.