1414#include " MotionDetection.h"
1515#include < AnalogDeviceAbstraction.h>
1616#include < tcMenuVersion.h>
17+ #include < stockIcons/wifiAndConnectionIcons16x12.h>
1718
1819// on the analog menu, we both have an analog input and an analog output (PWM). You can configure those pins here.
1920const int analogInputPin = A0;
@@ -25,6 +26,8 @@ SensorManager sensorManager;
2526// We create an event class extending BaseEvent to manage the motion detection
2627MotionDetection motionDetection;
2728
29+ TitleWidget bleRssiWidget (iconsWifi, 5 , 16 , 12 , nullptr );
30+
2831void setup () {
2932 // start up serial and wait for it to actually begin, needed on this board.
3033 Serial.begin (115200 );
@@ -45,6 +48,17 @@ void setup() {
4548 // We can also define overrides for a particular menu item
4649 menuMgr.addEncoderWrapOverride (menuAnalogReadingsOutputPWM, true );
4750
51+ // add a title widget that represents the ble signal strength / connection
52+ // and create a task that updates its status each second.
53+ renderer.setFirstWidget (&bleRssiWidget);
54+ taskManager.schedule (repeatSeconds (1 ), [] {
55+ if (!BLE.connected ()) bleRssiWidget.setCurrentState (0 );
56+ else if (BLE.rssi () > 80 ) bleRssiWidget.setCurrentState (1 );
57+ else if (BLE.rssi () > 65 ) bleRssiWidget.setCurrentState (2 );
58+ else if (BLE.rssi () > 55 ) bleRssiWidget.setCurrentState (3 );
59+ else bleRssiWidget.setCurrentState (4 );
60+ });
61+
4862 // and set up the menu itself, so it starts displaying and accepting input
4963 setupMenu ();
5064
0 commit comments