diff --git a/.github/makecode/blocks.png b/.github/makecode/blocks.png index dd81b16..ac55480 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 d451f00..895f86f 100644 Binary files a/.github/makecode/blocksdiff.png and b/.github/makecode/blocksdiff.png differ diff --git a/main.blocks b/main.blocks index 40b4d3b..5543194 100644 --- a/main.blocks +++ b/main.blocks @@ -1,9 +1,2 @@ -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 +menuaskedForHelpsentHelpdistancetimeFormattempFormatcompassFormatrecievedMessagetimeFormat24menu0askedForHelp0sentHelp0recievedMessage0337FALSETRUEEQ0timeFormat12timeanddate.MornNight.AM524013300Button.ATRUELTE0menu3menu1menu0Button.BTRUEEQ0askedForHelp1sentHelp1HELPIconNames.Yesdistance0DigitalPin.P0DigitalPin.P2PingUnit.Centimeters500TRUEEQ0recievedMessage0TRUEEQ0menu0anita is a genius +ask anita if I forgotMINUS2010distance200TRUEEQ0menu1TRUEEQ0timeFormat12timeanddate.TimeFormat.HMMAMPMtimeanddate.TimeFormat.HMMTRUEEQ0menu2TRUEEQ0tempFormat0CTRUEEQ0tempFormat1MULTIPLY033.8FC+MULTIPLY033.8FTRUEEQ0menu3TRUEEQ0compassFormat0TRUEEQ0compassFormat1TRUEEQ0compassFormat2()()TRUEEQ0sentHelp0askedForHelp1HELP?receivedStringTRUEEQ0receivedString0HELPrecievedMessage1HELPrecievedMessage0EQ0receivedString0FALLrecievedMessage1FALLrecievedMessage0simpleCompassTRUEEQ03153600NTRUEEQ00440NTRUEEQ0451340ETRUEEQ01352240SWdetailedCompassTRUEEQ03383600NTRUEEQ00220NTRUEEQ023670NETRUEEQ0681120ETRUEEQ01131570SETRUEEQ01582020STRUEEQ02032470SWTRUEEQ02482920WNW \ No newline at end of file diff --git a/main.ts b/main.ts index 7797824..169eae2 100644 --- a/main.ts +++ b/main.ts @@ -1,8 +1,3 @@ -/** - * 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") @@ -23,26 +18,21 @@ input.onButtonPressed(Button.A, function () { menu = 0 } }) -/** - * 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") { +radio.onReceivedString(function (receivedString) { + if (receivedString == "HELP") { recievedMessage = 1 basic.showString("HELP") - } else if (bluetooth.uartReadUntil(serial.delimiters(Delimiters.NewLine)) == "e:FALL") { + recievedMessage = 0 + } else if (receivedString == "FALL") { recievedMessage = 1 basic.showString("FALL") + recievedMessage = 0 } }) input.onButtonPressed(Button.B, function () { if (askedForHelp == 1) { sentHelp = 1 - bluetooth.uartWriteString("e:HELP") + radio.sendString("HELP") basic.showIcon(IconNames.Yes) } }) @@ -67,24 +57,19 @@ function detailedCompass () { basic.showString("NW") } } -/** - * radio set group radioChannel - * - * (just delete, replace with start bluetooth) - */ let distance = 0 let recievedMessage = 0 let sentHelp = 0 let askedForHelp = 0 let menu = 0 let timeFormat = 24 -let radioChannel = 33 menu = 0 askedForHelp = 0 sentHelp = 0 recievedMessage = 0 -bluetooth.startUartService() -bluetooth.setTransmitPower(7) +radio.setGroup(33) +radio.setTransmitPower(7) +radio.setTransmitSerialNumber(false) if (timeFormat == 12) { timeanddate.setTime(5, 24, 0, timeanddate.MornNight.AM) } else { @@ -97,8 +82,8 @@ loops.everyInterval(500, function () { // anita is a genius // ask anita if I forgot led.plotBarGraph( - 101 - distance, - 100 + 201 - distance, + 200 ) } else if (menu == 1) { basic.clearScreen() diff --git a/pxt.json b/pxt.json index e0cc986..10a7411 100644 --- a/pxt.json +++ b/pxt.json @@ -6,7 +6,7 @@ "microphone": "*", "microbit-pxt-timeanddate": "github:bsiever/microbit-pxt-timeanddate#v2.0.24", "pxt-sonar": "github:microsoft/pxt-sonar#v0.0.5", - "bluetooth": "*" + "radio": "*" }, "files": [ "main.blocks",