mirror of
https://github.com/bdnugget/Scoreboard.git
synced 2026-11-07 06:47:28 +00:00
Added support for turning sets segments to minute counter
This commit is contained in:
1 parent
cdb4ee5444
commit
ff4c386b96
7 files changed
+60
-1
No files matched your search
@@ -190,6 +190,29 @@ void displayController::showSets(uint8_t set1, uint8_t set2) {
|
||||
Serial.println("Display sets ends");
|
||||
}
|
||||
|
||||
void displayController::updateTime(uint8_t minutes) {
|
||||
Serial.println("Updating minutes starts");
|
||||
|
||||
if (minutes < 0 || minutes > 99) {
|
||||
showSets(0, 0);
|
||||
Serial.println("Minutes out of range");
|
||||
return;
|
||||
}
|
||||
|
||||
if (minutes < 10) {
|
||||
showSets(0, minutes);
|
||||
}
|
||||
else {
|
||||
uint8_t remind = 0;
|
||||
uint8_t digit = 0;
|
||||
remind = minutes/10;
|
||||
digit = minutes % 10;
|
||||
showSets(remind, digit);
|
||||
}
|
||||
|
||||
Serial.println("Updating minutes ends");
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays greetings on the display and blinks with it
|
||||
**/
|
||||
|
||||
@@ -37,6 +37,11 @@ void blink();
|
||||
**/
|
||||
void greetings();
|
||||
|
||||
/**
|
||||
* Updates sets segments with given minute information
|
||||
**/
|
||||
void updateTime(uint8_t minutes);
|
||||
|
||||
private:
|
||||
// Each number represents a segment on 7-segment, the last 8bit is not used = always 0
|
||||
// 1 means it's ON, 0 means it's OFF
|
||||
|
||||
@@ -23,6 +23,8 @@ uint8_t winningPoints = 1 ;
|
||||
bool enableServers = true;
|
||||
// true if displaying sets is enabled
|
||||
bool enableSets = true;
|
||||
// true if sets should display length of a game in minutes
|
||||
bool setsAsMinute = false;
|
||||
// true if the game supports tiebreak
|
||||
bool supportTiebreak = false;
|
||||
// the set that will be considered as tiebreak set, like 3
|
||||
|
||||
@@ -31,6 +31,8 @@ extern uint8_t winningPoints;
|
||||
extern bool enableServers;
|
||||
// true if displaying sets is enabled
|
||||
extern bool enableSets;
|
||||
// true if sets should display length of a game in minutes
|
||||
extern bool setsAsMinute;
|
||||
// true if the game supports tiebreak
|
||||
extern bool supportTiebreak;
|
||||
// the set that will be considered as tiebreak set, like 3
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
#include "VirtualWire.h"
|
||||
#include "settingController.h"
|
||||
|
||||
unsigned long minutes = 0;
|
||||
uint8_t lastDisplayedMinute = 0;
|
||||
bool inSettingsMode;
|
||||
bool inPlayerSettings;
|
||||
scoreController score;
|
||||
@@ -172,5 +174,22 @@ void loop() {
|
||||
}
|
||||
score.updateScore(message[0]);
|
||||
}
|
||||
|
||||
if (setsAsMinute) {
|
||||
// updates the minute on the board
|
||||
// if the minute has changed from last displayed state
|
||||
minutes = millis() / 60000;
|
||||
|
||||
if (minutes > 99) {
|
||||
// if it's over 99 minutes, starts from zero
|
||||
//TODO: Finish the logic in the scoreController
|
||||
}
|
||||
|
||||
if (minutes != lastDisplayedMinute) {
|
||||
display.updateTime(minutes);
|
||||
lastDisplayedMinute = minutes;
|
||||
}
|
||||
}
|
||||
|
||||
delay(50);
|
||||
}
|
||||
@@ -47,6 +47,12 @@ void settingsController::set(char *keyValuePair) {
|
||||
printMessage(DisplaySets);
|
||||
}
|
||||
|
||||
if ( strcmp(key, s_setsAsMinutes) == 0 ) {
|
||||
setsAsMinute = convertToBoolean(value);
|
||||
if (s_setsAsMinutes) enableSets = true;
|
||||
printMessage(SetsAsMinute);
|
||||
}
|
||||
|
||||
if ( strcmp(key, s_supportTiebreak) == 0 ) {
|
||||
supportTiebreak = convertToBoolean(value);
|
||||
printMessage(TieBreakSupport);
|
||||
|
||||
@@ -23,7 +23,7 @@ public:
|
||||
/**
|
||||
* Enumeration for messages
|
||||
**/
|
||||
enum Messages { SetsPerGame, PointsPerSets, SetPointsDifference, Server, DisplaySets, TieBreakSupport, TiebreakSet, PointsInTiebreak, PointsTiebreakDifference };
|
||||
enum Messages { SetsPerGame, PointsPerSets, SetPointsDifference, Server, DisplaySets, SetsAsMinute , TieBreakSupport, TiebreakSet, PointsInTiebreak, PointsTiebreakDifference };
|
||||
|
||||
private:
|
||||
|
||||
@@ -58,6 +58,7 @@ private:
|
||||
const char *msgDiff = "Set points difference:";
|
||||
const char *msgServe = "Display player on service:"; // should it lights the player on serve bar?
|
||||
const char *msgDisplaySets = "Display sets:";
|
||||
const char *msgSetsAsMinute = "Sets segments turned to minute counter";
|
||||
const char *msgTiebreakSupport = "Supports tiebreak:";
|
||||
const char *msgTiebreakSet = "Tiebreak set:";
|
||||
const char *msgTiebreakPoints = "Points in tiebreak:";
|
||||
@@ -74,6 +75,7 @@ private:
|
||||
const char *s_tiebreakSet = "q";
|
||||
const char *s_tiebreakPoints = "f";
|
||||
const char *s_tiebreakPointsDifference = "w";
|
||||
const char *s_setsAsMinutes = "u"; // this will turn the sets to be a minute timer
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in new issue
Block a user