no longer crashes the mc

refactor/wwvb-simple-timer
Jeffrey Paul 11 months ago
parent b56272cfc6
commit d52dc0263c
  1. 46
      wwvb/wwvb.ino

@ -197,19 +197,13 @@ void loop() {
TickSecond();
}
yield();
if(bitReadyForRead) {
bitReadyForRead = 0;
readBit();
}
yield();
PPSLowIfRequired();
yield();
if (displayUpdateRequired) {
updateDisplay();
displayUpdateRequired = 0;
@ -244,46 +238,34 @@ void TickSecond() {
}
void readBit() {
char buf[255];
unsigned int ms = lastBitHighMS;
sprintf(buf, "*** carrier was high for %sms befor \n", ms);
Serial.print(buf);
//char buf[255];
//sprintf(buf, "*** carrier was high for %sms befor \n", lastBitHighMS);
//Serial.print(buf);
displayUpdateRequired++;
registerBit(convertBit(ms));
registerBit(convertBit(lastBitHighMS));
}
int convertBit(unsigned int ms) {
char buf[255];
/*
20% - marker
50% - one bit
80% - zero bit
our cutoff points will be 50% and 80%
*/
char bitbuf[20];
int output = 0;
output = ZEROBIT;
sprintf(bitbuf, "ZERO");
return output;
/*
if (rawVal < 800) {
if (ms < 800) {
output = ONEBIT;
sprintf(bitbuf, "ONE");
}
}
if (rawVal < 680) {
if (ms < 400) {
output = MARKBIT;
sprintf(bitbuf, "MARK");
}
}
sprintf(buf, "frame rawVal=%d, bit=%s\n", rawVal, bitbuf);
Serial.print(buf);
return output;
*/
sprintf(buf, "frame prevHighMs=%s, bit=%s\n", ms, bitbuf);
Serial.print(buf);
return output;
}
void registerBit(int doot) {
@ -291,6 +273,7 @@ void registerBit(int doot) {
frameCounter++;
}
if (doot == MARKBIT) {
if (lastBitReceived == MARKBIT) {
// two mark bits in a row means we are in the first second of the minute
@ -363,11 +346,10 @@ void updateDisplay() {
if (lossOfSignal) {
sprintf(statusString, "LOS");
}
if (millisSinceBoot - frameStartTime < 10000) {
} else {
sprintf(statusString, "RX(syncing)");
}
if (minuteSync) {
sprintf(statusString, "RX(bit %d)", frameCounter);
}

Loading…
Cancel
Save