diff --git a/.github/makecode/blocks.png b/.github/makecode/blocks.png index e24c572..dd81b16 100644 Binary files a/.github/makecode/blocks.png and b/.github/makecode/blocks.png differ diff --git a/.github/makecode/blocksdiff.png b/.github/makecode/blocksdiff.png index 40fc6b9..d451f00 100644 Binary files a/.github/makecode/blocksdiff.png and b/.github/makecode/blocksdiff.png differ diff --git a/main.blocks b/main.blocks index b80243c..40b4d3b 100644 --- a/main.blocks +++ b/main.blocks @@ -1,2 +1,9 @@ -menuaskedForHelpsentHelpdistancetimeFormattempFormatcompassFormatradioChannelrecievedMessagetimeFormat24radioChannel33menu0askedForHelp0sentHelp0recievedMessage00radioChannelTRUEEQ0timeFormat12timeanddate.MornNight.AM524013300Button.ATRUELTE0menu3menu1menu0Button.BTRUEEQ0askedForHelp1sentHelp1HELPIconNames.Yesdistance0DigitalPin.P0DigitalPin.P2PingUnit.Centimeters500TRUEEQ0recievedMessage0TRUEEQ0menu0anita is a genius -ask anita if I forgotMINUS1010distance100TRUEEQ0menu1TRUEEQ0timeFormat12timeanddate.TimeFormat.HMMAMPMtimeanddate.TimeFormat.HMMTRUEEQ0menu2TRUEEQ0tempFormat0CTRUEEQ0tempFormat1MULTIPLY033.8FC+MULTIPLY033.8FTRUEEQ0menu3TRUEEQ0compassFormat0TRUEEQ0compassFormat1TRUEEQ0compassFormat2()()TRUEEQ0sentHelp0askedForHelp1HELP?simpleCompassTRUEEQ03153600NTRUEEQ00440NTRUEEQ0451340ETRUEEQ01352240SWreceivedStringTRUEEQ0receivedString0HELPrecievedMessage1HELPEQ0receivedString0FALLrecievedMessage1FALLdetailedCompassTRUEEQ03383600NTRUEEQ00220NTRUEEQ023670NETRUEEQ0681120ETRUEEQ01131570SETRUEEQ01582020STRUEEQ02032470SWTRUEEQ02482920WNW \ No newline at end of file +menuaskedForHelpsentHelpdistancetimeFormattempFormatcompassFormatradioChannelrecievedMessageradio send string HELP +replace with "bluetooth uart write string e:HELP"radio set group radioChannel + +(just delete, replace with start bluetooth)on radio recieved recievedstring + +if recievedstring + +else if recievedstringtimeFormat24radioChannel33menu0askedForHelp0sentHelp0recievedMessage07TRUEEQ0timeFormat12timeanddate.MornNight.AM524013300Button.ATRUELTE0menu3menu1menu0Button.BTRUEEQ0askedForHelp1sentHelp1e:HELPIconNames.Yesdistance0DigitalPin.P0DigitalPin.P2PingUnit.Centimeters500TRUEEQ0recievedMessage0TRUEEQ0menu0anita is a genius +ask anita if I forgotMINUS1010distance100TRUEEQ0menu1TRUEEQ0timeFormat12timeanddate.TimeFormat.HMMAMPMtimeanddate.TimeFormat.HMMTRUEEQ0menu2TRUEEQ0tempFormat0CTRUEEQ0tempFormat1MULTIPLY033.8FC+MULTIPLY033.8FTRUEEQ0menu3TRUEEQ0compassFormat0TRUEEQ0compassFormat1TRUEEQ0compassFormat2()()TRUEEQ0sentHelp0askedForHelp1HELP?simpleCompassTRUEEQ03153600NTRUEEQ00440NTRUEEQ0451340ETRUEEQ01352240SWDelimiters.NewLineTRUEEQ0Delimiters.NewLine0e:HELPrecievedMessage1HELPEQ0Delimiters.NewLine0e:FALLrecievedMessage1FALLdetailedCompassTRUEEQ03383600NTRUEEQ00220NTRUEEQ023670NETRUEEQ0681120ETRUEEQ01131570SETRUEEQ01582020STRUEEQ02032470SWTRUEEQ02482920WNW \ No newline at end of file diff --git a/main.ts b/main.ts index 6a35b12..7797824 100644 --- a/main.ts +++ b/main.ts @@ -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") @@ -18,11 +23,18 @@ 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") } @@ -30,7 +42,7 @@ radio.onReceivedString(function (receivedString) { input.onButtonPressed(Button.B, function () { if (askedForHelp == 1) { sentHelp = 1 - radio.sendString("HELP") + bluetooth.uartWriteString("e:HELP") basic.showIcon(IconNames.Yes) } }) @@ -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 @@ -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 { diff --git a/pxt.json b/pxt.json index a2fba7d..e0cc986 100644 --- a/pxt.json +++ b/pxt.json @@ -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",