119 pinMode(t->
data, OUTPUT);
120 pinMode(t->
clock, OUTPUT);
121 pinMode(t->
strobe, OUTPUT);
123 digitalWrite(t->
strobe, HIGH);
124 digitalWrite(t->
clock, HIGH);
125 delayMicroseconds(1);
195 for(
int i = 0; i < 8; i++)
197 digitalWrite(t->
clock, LOW);
198 delayMicroseconds(1);
200 digitalWrite(t->
data, x & 1 ? HIGH : LOW);
201 delayMicroseconds(1);
204 digitalWrite(t->
clock, HIGH);
205 delayMicroseconds(1);
225 pinMode (t->
data, INPUT);
227 for(
int i = 0; i < 8; i++)
231 digitalWrite(t->
clock, LOW);
232 delayMicroseconds(1);
234 uint8_t y = digitalRead(t->
data);
238 delayMicroseconds(1);
240 digitalWrite(t->
clock, HIGH);
241 delayMicroseconds(1);
245 pinMode (t->
data, OUTPUT);
261 digitalWrite(t->
strobe, LOW);
262 delayMicroseconds(1);
266 digitalWrite(t->
strobe, HIGH);
267 delayMicroseconds(1);
284 digitalWrite(t->
strobe, LOW);
285 delayMicroseconds(1);
290 digitalWrite(t->
strobe, HIGH);
291 delayMicroseconds(1);
305 for(
int i = 0, j = 1; i < 8; i++, j <<= 1)
330 for(
int i = 0, j = 128; i < 8; i++, j >>= 1)
341 digitalWrite(t->
strobe, LOW);
342 delayMicroseconds(1);
345 for(
int i = 0; i < 16; i++)
348 digitalWrite(t->
strobe, HIGH);
349 delayMicroseconds(1);
355 const uint8_t f[] = {
356 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
357 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
358 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
359 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
360 0x00, 0x86, 0x22, 0x7e, 0x6d, 0x00, 0x00, 0x02,
361 0x30, 0x06, 0x63, 0x00, 0x04, 0x40, 0x80, 0x52,
362 0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x27,
363 0x7f, 0x6f, 0x00, 0x00, 0x00, 0x48, 0x00, 0x53,
364 0x5f, 0x77, 0x7f, 0x39, 0x3f, 0x79, 0x71, 0x3d,
365 0x76, 0x06, 0x1f, 0x69, 0x38, 0x15, 0x37, 0x3f,
366 0x73, 0x67, 0x31, 0x6d, 0x78, 0x3e, 0x2a, 0x1d,
367 0x76, 0x6e, 0x5b, 0x39, 0x64, 0x0f, 0x00, 0x08,
368 0x20, 0x5f, 0x7c, 0x58, 0x5e, 0x7b, 0x31, 0x6f,
369 0x74, 0x04, 0x0e, 0x75, 0x30, 0x55, 0x54, 0x5c,
370 0x73, 0x67, 0x50, 0x6d, 0x78, 0x1c, 0x2a, 0x1d,
371 0x76, 0x6e, 0x47, 0x46, 0x06, 0x70, 0x01, 0x00
374 return (c > 127) ? 0 : f[(
unsigned char)c];
382 digitalWrite(t->
strobe, LOW);
383 delayMicroseconds(1);
388 for(
int i = 0; i < 4; i++)
394 digitalWrite(t->
strobe, HIGH);
395 delayMicroseconds(1);
406 for(
int i = 0; i < 4; i++)
void tm1638_set_7seg_text(const tm1638_p t, const char *str, uint8_t dots)
static void tm1638_send_config(const tm1638_p t)
uint32_t tm1638_read_buttons(const tm1638_p t)
tm1638_p tm1638_alloc(uint8_t data, uint8_t clock, uint8_t strobe)
static void tm1638_send_data(const tm1638_p t, uint8_t addr, uint8_t data)
void tm1638_free(tm1638_p *t)
void tm1638_set_7seg_raw(const tm1638_p t, uint8_t digit, uint8_t n)
void tm1638_send_cls(const tm1638_p t)
static void tm1638_send_raw(const tm1638_p t, uint8_t x)
void tm1638_set_led(const tm1638_p t, uint8_t led, uint8_t cols)
void tm1638_set_8leds(const tm1638_p t, uint8_t red)
static uint8_t tm1638_receive_raw(const tm1638_p t)
void tm1638_set_intensity(tm1638_p t, uint8_t intensity)
uint8_t tm1638_read_8buttons(const tm1638_p t)
uint8_t tm1638_font(char c)
static void tm1638_send_command(const tm1638_p t, uint8_t x)
void tm1638_enable(tm1638_p t, bool enable)
A simple interface to TM1638 based displays for the Raspberry Pi.
static uint8_t tm1638_calc_config(const tm1638_p t)