mirror of
https://github.com/halleysfifthinc/AVCLAN-Mockingboard.git
synced 2026-08-07 01:13:18 +00:00
Fix mutebus and improve bool literal hygiene
This commit is contained in:
+23
-20
@@ -51,7 +51,7 @@ static void *outgoingSlots[CACHE_SIZE];
|
|||||||
|
|
||||||
static Queue_t cache, rcache, incoming, outgoing;
|
static Queue_t cache, rcache, incoming, outgoing;
|
||||||
|
|
||||||
volatile uint8_t enqueueStatus = 0;
|
volatile bool enqueueStatus = false;
|
||||||
|
|
||||||
void Setup();
|
void Setup();
|
||||||
void general_GPIO_init();
|
void general_GPIO_init();
|
||||||
@@ -90,19 +90,19 @@ static void set_flag(bool *flag, bool val, const char *msg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
uint8_t readSeq = 0;
|
|
||||||
uint8_t hexChars[2];
|
uint8_t hexChars[2];
|
||||||
uint8_t hexDigit = 0; // current digit being written to hexChars
|
uint8_t hexDigit = 0; // current digit being written to hexChars
|
||||||
|
|
||||||
|
bool readSeq = false;
|
||||||
bool seqIsUnicast = false;
|
bool seqIsUnicast = false;
|
||||||
bool lastPrintAllFrames = 1;
|
bool readBinary = false;
|
||||||
|
|
||||||
bool verbose = 1;
|
bool verbose = true;
|
||||||
bool printAllFrames = 1;
|
bool printAllFrames = true;
|
||||||
bool printBinary = 0;
|
bool lastPrintAllFrames = true;
|
||||||
bool echoCharacters = 1;
|
bool printBinary = false;
|
||||||
bool readBinary = 0;
|
bool echoCharacters = true;
|
||||||
bool muteBus = 0;
|
bool muteBus = false;
|
||||||
|
|
||||||
// Binary-mode REPL includes the full wire preamble (broadcast + 2*addr +
|
// Binary-mode REPL includes the full wire preamble (broadcast + 2*addr +
|
||||||
// control + length), so size for the worst case.
|
// control + length), so size for the worst case.
|
||||||
@@ -184,7 +184,7 @@ int main() {
|
|||||||
RS232_Print("Outgoing queue full; unable to send status update\n");
|
RS232_Print("Outgoing queue full; unable to send status update\n");
|
||||||
pushQueue(&rcache, resp);
|
pushQueue(&rcache, resp);
|
||||||
} else
|
} else
|
||||||
enqueueStatus = 0; // Only clear if successful
|
enqueueStatus = false; // Only clear if successful
|
||||||
}
|
}
|
||||||
// no further error handling needed; status isn't part of the cache
|
// no further error handling needed; status isn't part of the cache
|
||||||
}
|
}
|
||||||
@@ -201,13 +201,16 @@ int main() {
|
|||||||
case 'v': toggle_flag(&verbose, "Verbose errors: "); break;
|
case 'v': toggle_flag(&verbose, "Verbose errors: "); break;
|
||||||
case 'l': toggle_flag(&printAllFrames, "Logging: "); break;
|
case 'l': toggle_flag(&printAllFrames, "Logging: "); break;
|
||||||
case 'k': toggle_flag(&echoCharacters, "Echo characters: "); break;
|
case 'k': toggle_flag(&echoCharacters, "Echo characters: "); break;
|
||||||
case 'm': toggle_flag(&muteBus, "Mute device: "); break;
|
case 'm':
|
||||||
|
toggle_flag(&muteBus, "Mute device: ");
|
||||||
|
AVCLAN_muteDevice(muteBus);
|
||||||
|
break;
|
||||||
|
|
||||||
// X/x isn't a toggle interface because this is used
|
// X/x isn't a toggle interface because this is used
|
||||||
// programmatically and is simpler than reading back the toggle
|
// programmatically and is simpler than reading back the toggle
|
||||||
// state
|
// state
|
||||||
case 'X': set_flag(&printBinary, 1, "Binary: "); break;
|
case 'X': set_flag(&printBinary, true, "Binary: "); break;
|
||||||
case 'x': set_flag(&printBinary, 0, "Binary: "); break;
|
case 'x': set_flag(&printBinary, false, "Binary: "); break;
|
||||||
|
|
||||||
case 'E': // Beep
|
case 'E': // Beep
|
||||||
if (AVCLAN_frame_t *out = (AVCLAN_frame_t *)popQueue(&cache)) {
|
if (AVCLAN_frame_t *out = (AVCLAN_frame_t *)popQueue(&cache)) {
|
||||||
@@ -252,7 +255,7 @@ int main() {
|
|||||||
|
|
||||||
case 0x10: // Signals binary sequence incoming
|
case 0x10: // Signals binary sequence incoming
|
||||||
if (!readSeq && !readBinary) {
|
if (!readSeq && !readBinary) {
|
||||||
readSeq = readBinary = 1;
|
readSeq = readBinary = true;
|
||||||
seqIdx = 0;
|
seqIdx = 0;
|
||||||
break;
|
break;
|
||||||
} else
|
} else
|
||||||
@@ -261,8 +264,8 @@ int main() {
|
|||||||
case 'U': // Send command
|
case 'U': // Send command
|
||||||
RS232_Print("READ SEQUENCE (U)> \n");
|
RS232_Print("READ SEQUENCE (U)> \n");
|
||||||
lastPrintAllFrames = printAllFrames;
|
lastPrintAllFrames = printAllFrames;
|
||||||
printAllFrames = 0;
|
printAllFrames = false;
|
||||||
readSeq = 1;
|
readSeq = true;
|
||||||
seqIdx = hexDigit = 0;
|
seqIdx = hexDigit = 0;
|
||||||
hexChars[0] = hexChars[1] = 0;
|
hexChars[0] = hexChars[1] = 0;
|
||||||
seqIsUnicast = true;
|
seqIsUnicast = true;
|
||||||
@@ -270,8 +273,8 @@ int main() {
|
|||||||
case 'B': // Send broadcast
|
case 'B': // Send broadcast
|
||||||
RS232_Print("READ SEQUENCE (B)> \n");
|
RS232_Print("READ SEQUENCE (B)> \n");
|
||||||
lastPrintAllFrames = printAllFrames;
|
lastPrintAllFrames = printAllFrames;
|
||||||
printAllFrames = 0;
|
printAllFrames = false;
|
||||||
readSeq = 1;
|
readSeq = true;
|
||||||
seqIdx = hexDigit = 0;
|
seqIdx = hexDigit = 0;
|
||||||
hexChars[0] = hexChars[1] = 0;
|
hexChars[0] = hexChars[1] = 0;
|
||||||
seqIsUnicast = false;
|
seqIsUnicast = false;
|
||||||
@@ -290,7 +293,7 @@ int main() {
|
|||||||
} else
|
} else
|
||||||
pushQueue(&cache, out);
|
pushQueue(&cache, out);
|
||||||
}
|
}
|
||||||
readSeq = readBinary = 0;
|
readSeq = readBinary = false;
|
||||||
} else
|
} else
|
||||||
goto DEFAULT; // reading binary and this is a real data byte;
|
goto DEFAULT; // reading binary and this is a real data byte;
|
||||||
// fall through to default
|
// fall through to default
|
||||||
@@ -413,6 +416,6 @@ void print_help() {
|
|||||||
// Periodic interrupt with a 1 sec period; only enabled when playing
|
// Periodic interrupt with a 1 sec period; only enabled when playing
|
||||||
ISR(RTC_PIT_vect) {
|
ISR(RTC_PIT_vect) {
|
||||||
AVCLAN_incrementTime();
|
AVCLAN_incrementTime();
|
||||||
enqueueStatus = 1;
|
enqueueStatus = true;
|
||||||
RTC.PITINTFLAGS = RTC_PI_bm;
|
RTC.PITINTFLAGS = RTC_PI_bm;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user