Skip to content

Commit c2d39f9

Browse files
committed
Adding all BLE properties
1 parent b6be2a1 commit c2d39f9

File tree

1 file changed

+25
-12
lines changed

1 file changed

+25
-12
lines changed

FlappyLED.ino

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ static uint16_t score = 0, time_to_wait = 70;
5858
static uint8_t gameMode = MENU;
5959
static float tofOldDistance = 0;
6060
static bool mute = false;
61-
static int localRecord = 0;
6261

6362
byte frame[8][12] = {
6463
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
@@ -74,8 +73,11 @@ byte frame[8][12] = {
7473

7574
#ifdef BLE_SYNC
7675
/* BT Service and properties */
77-
BleSync ble("FlappyLed", "d4d1cb67-d83e-41b6-bfc9-95d25ca6a91d", 2);
76+
BleSync ble("FlappyLed", "d4d1cb67-d83e-41b6-bfc9-95d25ca6a91d", 5);
7877
BleSyncValue bleRecordEncoder("a3cd7bd3-4d6e-492f-9f18-f9bf181be541", BLERead | BLEWrite);
78+
BleSyncValue bleGamesEncoder("59802c1a-c0d8-4b35-9c6c-b258304e078b", BLERead | BLEWrite);
79+
BleSyncValue bleRecordTof("2380e50e-562d-4e46-aeaf-d73b9d258f73", BLERead | BLEWrite);
80+
BleSyncValue bleGamesTof("a8dd61cd-02b9-465b-8f6d-a185aa65bce0", BLERead | BLEWrite);
7981
BleSyncValue bleCounter("17a8a342-41bd-4dc0-98af-62d30a0d4432", BLERead | BLEWrite);
8082
#endif
8183

@@ -130,6 +132,10 @@ void setup() {
130132

131133
ble.addValue(&bleRecordEncoder);
132134
ble.addValue(&bleCounter);
135+
ble.addValue(&bleGamesEncoder);
136+
ble.addValue(&bleRecordTof);
137+
ble.addValue(&bleGamesTof);
138+
ble.addValue(&bleCounter);
133139
ble.initBLE();
134140

135141
#endif
@@ -541,6 +547,23 @@ void clear_text()
541547
void resetGameState()
542548
{
543549

550+
#ifdef BLE_SYNC
551+
/* Store local record */
552+
553+
if(gameMode == ENCODER) {
554+
if(score > bleRecordEncoder.getValue()){
555+
bleRecordEncoder.setValue(score);
556+
}
557+
bleGamesEncoder.setValue(bleGamesEncoder.getValue()+1);
558+
} else if(gameMode == TOF) {
559+
if(score > bleRecordTof.getValue()){
560+
bleRecordTof.setValue(score);
561+
}
562+
bleGamesTof.setValue(bleGamesTof.getValue()+1);
563+
}
564+
bleCounter.setValue(bleCounter.getValue()+1);
565+
#endif
566+
544567
/* Reset game mode*/
545568
gameMode = MENU;
546569

@@ -572,16 +595,6 @@ void resetGameState()
572595
buttons.setLeds(false, mute, false);
573596
#endif
574597

575-
#ifdef BLE_SYNC
576-
/* Store local record */
577-
if(score > localRecord){
578-
localRecord = score;
579-
bleRecordEncoder.setValue(localRecord);
580-
}
581-
582-
bleCounter.setValue(bleCounter.getValue()+1);
583-
#endif
584-
585598
print_score(score);
586599
score = 0;
587600
wall_pos_x = WIDTH-1;

0 commit comments

Comments
 (0)