Add some delay to TM1838 comms

Add some delay to TM1838 comms (#2226)
This commit is contained in:
Theo Arends 2018-06-30 14:41:40 +02:00
parent 2a62356172
commit 409fedf11c
1 changed files with 4 additions and 0 deletions

View File

@ -28,6 +28,8 @@
#define TM1638_COLOR_RED 1
#define TM1638_COLOR_GREEN 2
#define TM1638_CLOCK_DELAY 1 // uSec
uint8_t tm1638_type = 1;
uint8_t tm1638_clock_pin = 0;
uint8_t tm1638_data_pin = 0;
@ -44,6 +46,7 @@ void Tm16XXSend(byte data)
{
for (int i = 0; i < 8; i++) {
digitalWrite(tm1638_clock_pin, LOW);
delayMicroseconds(TM1638_CLOCK_DELAY);
digitalWrite(tm1638_data_pin, data & 1 ? HIGH : LOW);
data >>= 1;
digitalWrite(tm1638_clock_pin, HIGH);
@ -77,6 +80,7 @@ byte Tm16XXReceive()
for (int i = 0; i < 8; i++) {
temp >>= 1;
digitalWrite(tm1638_clock_pin, LOW);
delayMicroseconds(TM1638_CLOCK_DELAY);
if (digitalRead(tm1638_data_pin)) {
temp |= 0x80;
}