Cleanup. Stable 0..7
This commit is contained in:
parent
3ed2b30b1d
commit
2495c3b9d0
@ -1,15 +1,15 @@
|
||||
#include <TimerOne.h>
|
||||
|
||||
// config:
|
||||
const int pinData = 6;
|
||||
const int pinStatus = 7;
|
||||
|
||||
// fixed values
|
||||
const int timerDelay = 500;
|
||||
|
||||
void setup(void)
|
||||
{
|
||||
pinMode(pinData, OUTPUT);
|
||||
//Timer1.initialize(60);
|
||||
//Timer1.attachInterrupt(clockCycle);
|
||||
|
||||
Timer1.initialize(timerDelay);
|
||||
Timer1.attachInterrupt(clockCycle);
|
||||
@ -22,7 +22,6 @@ void setup(void)
|
||||
}
|
||||
|
||||
volatile long lastChange = 0;
|
||||
volatile long lastStart = 0;
|
||||
volatile int x = 0;
|
||||
volatile int dataWord = 0;
|
||||
volatile int dataState = 0;
|
||||
@ -36,8 +35,6 @@ void statusCycle() {
|
||||
long changeDiff = timeNow - lastChange;
|
||||
lastChange = timeNow;
|
||||
if (changeDiff >= 10) {
|
||||
lastStart = timeNow;
|
||||
|
||||
dataWord = (0 + x);
|
||||
dataState = 8;
|
||||
dataDelay = 0;
|
||||
@ -48,10 +45,6 @@ void statusCycle() {
|
||||
Timer1.initialize(timerDelay);
|
||||
Timer1.start();
|
||||
}
|
||||
if (timeNow - lastStart >= 7 && changeDiff >= 2) {
|
||||
//dataWord = 0b1000000011 | (('A' + x) << 2);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void clockCycle(void)
|
||||
@ -69,15 +62,12 @@ void clockCycle(void)
|
||||
dataBit = LOW;
|
||||
} else if (dataState > 0) {
|
||||
int bitToSend = (dataWord >> (dataState - 1)) & 1;
|
||||
//int bitToSend = dataWord & 1;
|
||||
//dataWord = dataWord >> 1;
|
||||
dataBit = !bitToSend ? LOW : HIGH;
|
||||
dataState--;
|
||||
} else if (packetTail > 0) {
|
||||
packetTail--;
|
||||
dataBit = LOW;
|
||||
} else {
|
||||
//digitalWrite(pinData, HIGH);
|
||||
Timer1.stop();
|
||||
}
|
||||
digitalWrite(pinData, dataBit);
|
||||
|
Loading…
Reference in New Issue
Block a user