Add bluetooth symbol when connected (alternate between APRS symbol and BT)
This commit is contained in:
parent
2f44fb527d
commit
b8e78d298b
|
|
@ -0,0 +1,66 @@
|
|||
# Generated from CLion C/C++ Code Style settings
|
||||
BasedOnStyle: LLVM
|
||||
AccessModifierOffset: -4
|
||||
AlignAfterOpenBracket: Align
|
||||
AlignConsecutiveAssignments: None
|
||||
AlignOperands: Align
|
||||
AllowAllArgumentsOnNextLine: false
|
||||
AllowAllConstructorInitializersOnNextLine: false
|
||||
AllowAllParametersOfDeclarationOnNextLine: false
|
||||
AllowShortBlocksOnASingleLine: Always
|
||||
AllowShortCaseLabelsOnASingleLine: false
|
||||
AllowShortFunctionsOnASingleLine: All
|
||||
AllowShortIfStatementsOnASingleLine: Always
|
||||
AllowShortLambdasOnASingleLine: All
|
||||
AllowShortLoopsOnASingleLine: true
|
||||
AlwaysBreakAfterReturnType: None
|
||||
AlwaysBreakTemplateDeclarations: Yes
|
||||
BreakBeforeBraces: Custom
|
||||
BraceWrapping:
|
||||
AfterCaseLabel: false
|
||||
AfterClass: false
|
||||
AfterControlStatement: Never
|
||||
AfterEnum: false
|
||||
AfterFunction: false
|
||||
AfterNamespace: false
|
||||
AfterUnion: false
|
||||
BeforeCatch: false
|
||||
BeforeElse: false
|
||||
IndentBraces: false
|
||||
SplitEmptyFunction: false
|
||||
SplitEmptyRecord: true
|
||||
BreakBeforeBinaryOperators: None
|
||||
BreakBeforeTernaryOperators: true
|
||||
BreakConstructorInitializers: BeforeColon
|
||||
BreakInheritanceList: BeforeColon
|
||||
ColumnLimit: 0
|
||||
CompactNamespaces: false
|
||||
ContinuationIndentWidth: 8
|
||||
IndentCaseLabels: true
|
||||
IndentPPDirectives: None
|
||||
IndentWidth: 2
|
||||
KeepEmptyLinesAtTheStartOfBlocks: true
|
||||
MaxEmptyLinesToKeep: 2
|
||||
NamespaceIndentation: All
|
||||
ObjCSpaceAfterProperty: false
|
||||
ObjCSpaceBeforeProtocolList: true
|
||||
PointerAlignment: Right
|
||||
ReflowComments: false
|
||||
SpaceAfterCStyleCast: true
|
||||
SpaceAfterLogicalNot: false
|
||||
SpaceAfterTemplateKeyword: false
|
||||
SpaceBeforeAssignmentOperators: true
|
||||
SpaceBeforeCpp11BracedList: false
|
||||
SpaceBeforeCtorInitializerColon: true
|
||||
SpaceBeforeInheritanceColon: true
|
||||
SpaceBeforeParens: ControlStatements
|
||||
SpaceBeforeRangeBasedForLoopColon: false
|
||||
SpaceInEmptyParentheses: false
|
||||
SpacesBeforeTrailingComments: 0
|
||||
SpacesInAngles: false
|
||||
SpacesInCStyleCastParentheses: false
|
||||
SpacesInContainerLiterals: false
|
||||
SpacesInParentheses: false
|
||||
SpacesInSquareBrackets: false
|
||||
TabWidth: 2
|
||||
UseTab: Never
|
||||
|
|
@ -48,6 +48,7 @@ bool sendUpdate = true;
|
|||
int updateCounter = Config.sendCommentAfterXBeacons;
|
||||
bool sendStandingUpdate = false;
|
||||
bool statusState = true;
|
||||
bool bluetoothConnected = false;
|
||||
|
||||
uint32_t lastTx = 0.0;
|
||||
uint32_t txInterval = 60000L;
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ extern Configuration Config;
|
|||
extern BluetoothSerial SerialBT;
|
||||
extern logging::Logger logger;
|
||||
extern TinyGPSPlus gps;
|
||||
extern bool bluetoothConnected;
|
||||
|
||||
namespace BLUETOOTH_Utils {
|
||||
String serialReceived;
|
||||
|
|
@ -47,9 +48,11 @@ namespace BLUETOOTH_Utils {
|
|||
|
||||
void bluetoothCallback(esp_spp_cb_event_t event, esp_spp_cb_param_t *param) {
|
||||
if (event == ESP_SPP_SRV_OPEN_EVT) {
|
||||
logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "Bluetooth", "Bluetooth client connected !");
|
||||
logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "Bluetooth", "Client connected !");
|
||||
bluetoothConnected = true;
|
||||
} else if (event == ESP_SPP_CLOSE_EVT) {
|
||||
logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "Bluetooth", "Bluetooth client disconnected !");
|
||||
logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "Bluetooth", "Client disconnected !");
|
||||
bluetoothConnected = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -77,8 +80,8 @@ namespace BLUETOOTH_Utils {
|
|||
|
||||
shouldSendToLoRa = !serialReceived.isEmpty()
|
||||
// Test true APRS frame and not a NMEA (case when RX buffer overflow)
|
||||
&& serialReceived.indexOf(">") != -1
|
||||
&& serialReceived.indexOf(":") != -1
|
||||
&& serialReceived.indexOf('>') != -1
|
||||
&& serialReceived.indexOf(':') != -1
|
||||
&& serialReceived.indexOf("$G") == -1
|
||||
&& serialReceived.indexOf("$B") == -1;
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,23 @@
|
|||
|
||||
#include <Arduino.h>
|
||||
|
||||
static const unsigned char bluetoothSymbol[] PROGMEM = {
|
||||
0b00001100, 0b00000000,
|
||||
0b00001111, 0b00000000,
|
||||
0b00001100, 0b11000000,
|
||||
0b11001100, 0b00110000,
|
||||
0b00111100, 0b11000000,
|
||||
0b00001111, 0b00000000,
|
||||
0b00001111, 0b00000000,
|
||||
0b00111100, 0b11000000,
|
||||
0b11001100, 0b00110000,
|
||||
0b00001100, 0b11000000,
|
||||
0b00001111, 0b00000000,
|
||||
0b00001100, 0b00000000,
|
||||
0b00000000, 0b00000000,
|
||||
0b00000000, 0b00000000
|
||||
};
|
||||
|
||||
static const unsigned char runnerSymbol[] PROGMEM = {
|
||||
0b00000000, 0b11100000,
|
||||
0b00000000, 0b11100000,
|
||||
|
|
|
|||
|
|
@ -15,11 +15,14 @@ extern Configuration Config;
|
|||
extern Beacon *currentBeacon;
|
||||
extern int menuDisplay;
|
||||
extern bool symbolAvailable;
|
||||
extern bool bluetoothConnected;
|
||||
|
||||
String symbolArray[10] = {"[", ">", "j", "b", "<", "s", "u", "R", "v"};
|
||||
int symbolArraySize = sizeof(symbolArray)/sizeof(symbolArray[0]);
|
||||
const uint8_t *symbolsAPRS[] = {runnerSymbol, carSymbol, jeepSymbol, bikeSymbol, motorcycleSymbol, shipSymbol, truckSymbol, recreationalVehicleSymbol, vanSymbol};
|
||||
|
||||
uint32_t symbolTime = millis();
|
||||
|
||||
// T-Beams bought with soldered OLED Screen comes with only 4 pins (VCC, GND, SDA, SCL)
|
||||
// If your board didn't come with 4 pins OLED Screen and comes with 5 and one of them is RST...
|
||||
// Uncomment Next Line (Remember ONLY if your OLED Screen has a RST pin). This is to avoid memory issues.
|
||||
|
|
@ -182,12 +185,26 @@ void show_display(String header, String line1, String line2, String line3, Strin
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Symbol alternate every 2.5s (+/- 500ms due to 1s tick of display refresh)
|
||||
* If bluetooth is disconnected or if we are in the first part of the clock, then we show the APRS symbol
|
||||
* Otherwise, we are in the second part of the clock, then we show BT connected
|
||||
*/
|
||||
if (!bluetoothConnected || millis() - symbolTime <= 2500) {
|
||||
if (symbol != 100) {
|
||||
symbolAvailable = true;
|
||||
display.drawBitmap((display.width() - SYM_WIDTH), 0, symbolsAPRS[symbol], SYM_WIDTH, SYM_HEIGHT, 1);
|
||||
} else {
|
||||
symbolAvailable = false;
|
||||
}
|
||||
} else if (bluetoothConnected) {
|
||||
display.drawBitmap((display.width() - SYM_WIDTH), 0, bluetoothSymbol, SYM_WIDTH, SYM_HEIGHT, 1);
|
||||
}
|
||||
|
||||
if (millis() - symbolTime >= 5000) {
|
||||
symbolTime = millis();
|
||||
}
|
||||
}
|
||||
|
||||
display.display();
|
||||
|
|
|
|||
Loading…
Reference in New Issue