From 7d20f555dd3f5895b7eb15487687e09bacb6a080 Mon Sep 17 00:00:00 2001 From: Luca Borsari Date: Tue, 13 Jul 2021 14:35:06 +0200 Subject: [PATCH] code cleanup --- changelog.txt | 5 ++--- open-led-race/SerialCommand.cpp | 3 +-- open-led-race/open-led-race.ino | 9 +++++---- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/changelog.txt b/changelog.txt index ad9715e..d9163ba 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,9 +1,8 @@ Revisions history ----------------- - - * 2020-12-09: Ver 0.9.6 - Luca - ............................... + * 2020-12-17: Ver 0.9.6- Luca // Gitlab Commit = 0.9.6a + ....................................................... - Removed dependency from "AsyncSerialLib" - new class SerialCommand() - Remove delay() (blocking) in Countdown phase diff --git a/open-led-race/SerialCommand.cpp b/open-led-race/SerialCommand.cpp index 553e458..bae07a7 100644 --- a/open-led-race/SerialCommand.cpp +++ b/open-led-race/SerialCommand.cpp @@ -62,8 +62,7 @@ int SerialCommand::checkSerial() { void SerialCommand::sendCommand(char* str) { // get command length int dlen=0; -// for(; dlen<_bufLen; dlen++ ) { // limit transmitted command length to received command buffer - for(; dlen<80; dlen++ ) { // limit transmitted command length to received command buffer + for(; dlen<80; dlen++ ) { // "dlen<80" to avoid infinite loop on malformed str without EOC if(*(str+dlen) == _eoc ){ dlen++; // send EOC break; diff --git a/open-led-race/open-led-race.ino b/open-led-race/open-led-race.ino index bcd9cfd..fa11eda 100644 --- a/open-led-race/open-led-race.ino +++ b/open-led-race/open-led-race.ino @@ -15,7 +15,6 @@ the Free Software Foundation; either version 3 of the License, or (at your option) any later version. - First public version by: Angel Maldonado (https://gitlab.com/angeljmc) Gerardo Barbarov (gbarbarov AT singulardevices DOT com) @@ -23,7 +22,6 @@ Basen on original idea and 2 players code by: Gerardo Barbarov for Arduino day Seville 2019 https://github.com/gbarbarov/led-race - Public Repository for this code: https://gitlab.com/open-led-race/olr-arduino @@ -49,7 +47,8 @@ char const version[] = "0.9.6"; #define PIN_LED 2 // R 500 ohms to DI pin for WS2812 and WS2813, for WS2813 BI pin of first LED to GND , CAP 1000 uF to VCC 5v/GND,power supplie 5V 2A #define PIN_AUDIO 3 // through CAP 2uf to speaker 8 ohms -#define REC_COMMAND_BUFLEN 32 +#define REC_COMMAND_BUFLEN 32 // received command buffer size +#define TX_COMMAND_BUFLEN 80 // send command buffer size #define EOL '\n' // End of Command char used in Protocol #define COLOR1 track.Color(255,0,0) @@ -135,7 +134,7 @@ static track_t tck; static int const eeadrInfo = 0; -char txbuff[64]; + @@ -174,6 +173,8 @@ void draw_winner( track_t* tck, uint32_t color); char cmd[REC_COMMAND_BUFLEN]; // Stores command received by ReadSerialComand() SerialCommand serialCommand = SerialCommand(cmd, REC_COMMAND_BUFLEN, EOL, &Serial); // get complete command from serial +char txbuff[TX_COMMAND_BUFLEN]; + Adafruit_NeoPixel track;