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