0.3.1 TM1637_RT

This commit is contained in:
rob tillaart 2021-12-29 12:48:28 +01:00
parent 0532be1da2
commit ebf4a7ed98
19 changed files with 67 additions and 28 deletions

View File

@ -1,6 +1,6 @@
MIT License
Copyright (c) 2019-2021 Rob Tillaart
Copyright (c) 2019-2022 Rob Tillaart
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@ -12,7 +12,7 @@ Library for TM1637 driven displays and keyscans.
## Description
The TM1637 drives 7 segment displays and can also scan a 16 key keyboard
The TM1637 drives 7 segment displays and can also scan a 16 key keyboard.
Library is tested with Arduino UNO and a 6 digits display.
@ -38,12 +38,15 @@ As the display is only tested with a 6 digit display, this is used as the defaul
**displayRaw()** can display some of the alphabet as follows:
- space (blank) is 0x10
- - (blank) is 0x11
- '-' (minus) is 0x11
- a-f are coded as 0x0a-0x0f
- g-z are coded as 0x12-0x25
- g-z are coded as 0x12-0x25. Characters that cannot be represented in 7 segments render as blank.
So "hello " is coded as 0x13, 0x0e, 0x17, 0x17, 0x1a, 0x10
See routine **ascii_to_7segment()** in the example TM1637_keyscan_cooked.ino. It presents a more convenient interface for displaying text messages on the display.
Routine **button_poll()** in the same example shows one way of polling and de-bouncing button presses.
### Tuning function
@ -112,6 +115,7 @@ Scope photo showing faster rise time of DIO pin (upper trace) with 1000 ohm pull
The scope photos were taken using the TM1637_keyscan_raw example, with the scope trigger hooked to the TRIGGER pin, and the two channel probes hooked to DIO and CLK. Vertical sensitivity is 2v/division, horizontal timebase is 20usec/division.
## Keyscan
Implemented in version 0.3.0 Please read the datasheet to understand the limitations.
@ -136,4 +140,6 @@ See examples
- elaborate documentation
- testing
- rename **init()** to **begin()** ?
-
- **keyScan()** camelCase ?
- separate releaseNotes ?

View File

@ -2,27 +2,27 @@
// FILE: TM1637.cpp
// AUTHOR: Rob Tillaart
// DATE: 2019-10-28
// VERSION: 0.3.0
// VERSION: 0.3.1
// PURPOSE: TM1637 library for Arduino
// URL: https://github.com/RobTillaart/TM1637_RT
//
// HISTORY:
// 0.1.0 2019-10-28 initial version
// 0.1.1 2021-02-15 first release + examples.
// 0.1.1 2021-02-15 first release + examples.
// 0.1.2 2021-04-16 update readme, fix default values.
// 0.2.0 2021-09-26 add ESP32 support - kudos to alexthomazo
// 2021-10-07 add support for letters g-z; added keyscan()
// tested on ESP8266
// 0.3.0 2021-10-27 improved keyscan + documentation - kudos to wfdudley
// 0.3.1 2021-12-29 update library.json, license, readme, minor edits
//
// tested on 6 digits display only for now.
// NOTE: on the inexpensive TM1637 boards @wfdudley has used, keyscan
// works if you add a 1000 ohm pullup resistor from DIO to 3.3v
// works if you add a 1000 ohm pull-up resistor from DIO to 3.3v
// This reduces the rise time of the DIO signal when reading the key info.
// If one only uses the pull-up inside the microcontroller,
// If one only uses the pull-up inside the microcontroller,
// the rise time is too long for the data to be read reliably.
@ -54,14 +54,17 @@
*/
// PROGMEM ?
static uint8_t seg[] =
{
0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x07, 0x7f, 0x6f, // 0 - 9
0x77, 0x7c, 0x39, 0x5e, 0x79, 0x71, 0x00, 0x40 // A - F, ' ', '-'
};
static uint8_t alpha_seg[] =
{
0x00, 0x74, 0x10, 0x00, // g, h, i, j,
@ -71,6 +74,7 @@ static uint8_t alpha_seg[] =
0x00, 0x00, 0x00, 0x00 // w, x, y, z
};
TM1637::TM1637()
{
_brightness = 0x03;
@ -267,7 +271,7 @@ void TM1637::stop()
}
void TM1637::writeSync(uint8_t pin, uint8_t val)
void TM1637::writeSync(uint8_t pin, uint8_t val)
{
digitalWrite(pin, val);
@ -319,7 +323,7 @@ uint8_t TM1637::keyscan(void)
}
// nanoDelay() makes it possible to go into the sub micron delays.
// nanoDelay() makes it possible to go into the sub micron delays.
// It is used to lengthen pulses to be minimal 400 ns but not much longer. See datasheet.
void TM1637::nanoDelay(uint16_t n)
{
@ -327,4 +331,6 @@ void TM1637::nanoDelay(uint16_t n)
while (i--);
}
// -- END OF FILE --

View File

@ -3,7 +3,7 @@
// FILE: TM1637.h
// AUTHOR: Rob Tillaart
// DATE: 2019-10-28
// VERSION: 0.3.0
// VERSION: 0.3.1
// PUPROSE: TM1637 library for Arduino
// URL: https://github.com/RobTillaart/TM1637_RT
@ -13,7 +13,7 @@
#include "Arduino.h"
#define TM1637_LIB_VERSION (F(0.3.0))
#define TM1637_LIB_VERSION (F("0.3.1"))
class TM1637
@ -37,6 +37,7 @@ class TM1637
uint8_t getBitDelay() { return _bitDelay; };
uint8_t keyscan(void);
private:
uint8_t _clock = -1;
uint8_t _data = -1;
@ -52,4 +53,6 @@ class TM1637
void nanoDelay(uint16_t n);
};
// -- END OF FILE --

View File

@ -1,7 +1,6 @@
//
// FILE: TM1637_HEX.ino
// AUTHOR: Rob Tillaart
// VERSION: 0.1.0
// PURPOSE: demo TM1637 library
// DATE: 2021-02-15
// URL: https://github.com/RobTillaart/TM1637
@ -11,9 +10,11 @@
TM1637 TM;
uint32_t start, stop;
volatile uint32_t val = 0;
void setup()
{
Serial.begin(115200);
@ -62,3 +63,4 @@ void test()
// -- END OF FILE --

View File

@ -11,6 +11,7 @@
TM1637 TM;
void setup()
{
Serial.begin(115200);
@ -20,6 +21,7 @@ void setup()
TM.setBrightness(2);
}
void ascii_to_7segment(char *buff, uint8_t *data) {
for(int8_t i = 0, j=5 ; j > -1 && i < 12 && buff[i] ; i++) {
if(isalpha(buff[i])) { buff[i] = tolower(buff[i]); }
@ -41,6 +43,7 @@ void ascii_to_7segment(char *buff, uint8_t *data) {
}
}
void loop()
{
char buff[20];
@ -54,4 +57,6 @@ uint8_t data[10];
delay(1000);
}
// -- END OF FILE --

View File

@ -1,7 +1,6 @@
//
// FILE: TM1637_float.ino
// AUTHOR: Rob Tillaart
// VERSION: 0.1.0
// PURPOSE: demo TM1637 library
// DATE: 2021-02-15
// URL: https://github.com/RobTillaart/TM1637
@ -9,11 +8,13 @@
#include "TM1637.h"
TM1637 TM;
uint32_t start, stop;
volatile float f = 3.14159265;
void setup()
{
Serial.begin(115200);
@ -52,3 +53,4 @@ void test()
// -- END OF FILE --

View File

@ -1,7 +1,6 @@
//
// FILE: TM1637_int.ino
// AUTHOR: Rob Tillaart
// VERSION: 0.1.0
// PURPOSE: demo TM1637 library
// DATE: 2021-02-15
// URL: https://github.com/RobTillaart/TM1637
@ -9,11 +8,13 @@
#include "TM1637.h"
TM1637 TM;
uint32_t start, stop;
volatile uint32_t val = 0;
void setup()
{
Serial.begin(115200);
@ -56,3 +57,4 @@ void test()
// -- END OF FILE --

View File

@ -11,16 +11,18 @@
TM1637 TM;
// Note: In my experience, the TM1637 boards need a pull up
// resistor from DIO to 3.3V for keyscan() to work. 1000 ohms
// seems to work well, but value isn't critical.
char buff[8];
uint8_t last_keypress, bptr;
#define dispCLOCK 3
#define dispDATA 4
#define dispCLOCK 3
#define dispDATA 4
@ -120,4 +122,6 @@ char c;
delay(50);
}
// -- END OF FILE --

View File

@ -25,10 +25,9 @@ TM1637 TM;
// can't pull the line down (a bad thing). Try 1000 ohms.
#define dispCLOCK 3
#define dispDATA 4
#define TRIGGER 5
#define dispCLOCK 3
#define dispDATA 4
#define TRIGGER 5
void setup()
@ -50,6 +49,7 @@ void setup()
TM.displayClear();
}
char button_poll(void) {
#ifdef TRIGGER
digitalWrite(TRIGGER, HIGH);
@ -65,6 +65,7 @@ char button_poll(void) {
return '\0';
}
void loop()
{
char c;
@ -75,4 +76,6 @@ char c;
#endif
}
// -- END OF FILE --

1
libraries/TM1637_RT/images/.gitignore vendored Normal file
View File

@ -0,0 +1 @@

Binary file not shown.

After

Width:  |  Height:  |  Size: 147 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 166 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 125 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 181 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 187 KiB

View File

@ -1,6 +1,6 @@
{
"name": "TM1637_RT",
"keywords": "TM1637 ",
"keywords": "TM1637, display",
"description": "TM1637 Library for Arduino.\nFor 6 digit 7 segment display.",
"authors":
[
@ -15,8 +15,9 @@
"type": "git",
"url": "https://github.com/RobTillaart/TM1637_RT"
},
"version": "0.3.0",
"version": "0.3.1",
"license": "MIT",
"frameworks": "arduino",
"platforms": "*"
"platforms": "*",
"headers": "TM1637.h"
}

View File

@ -1,5 +1,5 @@
name=TM1637_RT
version=0.3.0
version=0.3.1
author=Rob Tillaart <rob.tillaart@gmail.com>
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
sentence=TM1637 Library for Arduino.

View File

@ -40,12 +40,15 @@
unittest_setup()
{
fprintf(stderr, "TM1637_LIB_VERSION: %s\n", (char *) TM1637_LIB_VERSION);
}
unittest_teardown()
{
}
unittest(test_begin)
{
TM1637 TM;
@ -91,6 +94,7 @@ unittest(test_set_bit_delay)
}
unittest_main()
// --------