Sends byte every time

This commit is contained in:
Dejvino 2023-03-28 17:00:33 +02:00
parent 829246c332
commit d9e9df964e

View File

@ -34,10 +34,10 @@ void statusCycle() {
if (changeDiff >= 10) {
lastStart = timeNow;
dataWord = (' ' + x);
dataState = 8;
dataDelay = 0;
x = (x + 1) % 100;
dataWord = ('1' + x);
dataState = 10;
dataDelay = 1;
x = (x + 1) % 3;
clkState = HIGH;
Timer1.start();
}
@ -49,28 +49,25 @@ void statusCycle() {
void clockCycle(void)
{
int dataBit = HIGH;
if (clkState == LOW) {
clkState = HIGH;
//digitalWrite(pinData, (dataState > 0) ? LOW : HIGH);
} else {
clkState = LOW;
if (dataDelay > 0) {
dataDelay--;
} else if (dataState > 0) {
int bitToSend = (dataWord >> (dataState - 1)) & 1;
//digitalWrite(pinData, bitToSend ? LOW : HIGH);
dataState--;
if (dataState <= 0) {
Timer1.stop();
}
} else {
//digitalWrite(pinData, HIGH);
}
}
if (dataDelay <= 0 && dataState > 0)
digitalWrite(pinData, clkState);
else
digitalWrite(pinData, HIGH);
if (dataDelay > 0) {
dataDelay--;
} else if (dataState > 0) {
int bitToSend = (dataWord >> (dataState - 1)) & 1;
//int bitToSend = dataWord & 1;
//dataWord = dataWord >> 1;
dataBit = !bitToSend ? LOW : HIGH;
dataState--;
} else {
//digitalWrite(pinData, HIGH);
Timer1.stop();
}
digitalWrite(pinData, dataBit);
}
void loop(void)