mirror of
https://github.com/RobTillaart/Arduino.git
synced 2024-10-03 18:09:02 -04:00
0.3.5 TM1637_RT
This commit is contained in:
parent
9d6075d4f9
commit
ae8aeb853f
@ -6,7 +6,7 @@ jobs:
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
- uses: arduino/arduino-lint-action@v1
|
||||
with:
|
||||
library-manager: update
|
||||
|
@ -8,7 +8,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
- uses: ruby/setup-ruby@v1
|
||||
with:
|
||||
ruby-version: 2.6
|
||||
|
@ -10,7 +10,7 @@ jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
- name: json-syntax-check
|
||||
uses: limitusus/json-syntax-check@v1
|
||||
with:
|
||||
|
@ -5,26 +5,32 @@ All notable changes to this project will be documented in this file.
|
||||
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
||||
and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
## [0.3.4] - 2022-10-07
|
||||
|
||||
## [0.3.5] - 2023-02-18
|
||||
- add **void displayFloat(float value, byte fixpoint)** Thanks to marshalab
|
||||
- edd example TM1637_float_point.ino
|
||||
- update readme.md
|
||||
- update GitHub actions
|
||||
- update license 2023
|
||||
- minor edits
|
||||
|
||||
|
||||
## [0.3.4] - 2022-10-07
|
||||
- added CHANGELOG.md
|
||||
- added **void displayPChar(char \* data)** thanks to radionerd
|
||||
- added **uint8_t asciiTo7Segment (char c)** thanks to radionerd
|
||||
- updated documentation
|
||||
|
||||
## [0.3.3] - 2022-09-24
|
||||
|
||||
- added CHANGELOG.md
|
||||
- added **begin()** to replace **init()** in due time.
|
||||
- updated documentation
|
||||
|
||||
## [0.3.2] - 2022-04-16
|
||||
|
||||
- fix #15 support for 4 digits.
|
||||
- tested on 4 digit (clock) display.
|
||||
|
||||
## [0.3.1] - 2021-12-29
|
||||
|
||||
- update library.json
|
||||
- update license
|
||||
- update readme.md
|
||||
@ -32,30 +38,28 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||
- tested on 6 digits display (with decinal point).
|
||||
|
||||
## [0.3.0] - 2021-10-27
|
||||
|
||||
- improved keyscan - kudos to wfdudley
|
||||
- update documentation
|
||||
- update documentation
|
||||
|
||||
----
|
||||
|
||||
## [0.2.1] - 2021-10-07
|
||||
|
||||
- add support for letters g-z; added keyscan()
|
||||
- tested on ESP8266
|
||||
|
||||
## [0.2.0] - 2021-09-26
|
||||
|
||||
- add ESP32 support - kudos to alexthomazo
|
||||
|
||||
## [0.1.2] - 2021-04-16
|
||||
----
|
||||
|
||||
## [0.1.2] - 2021-04-16
|
||||
- update readme
|
||||
- fix default values
|
||||
|
||||
## [0.1.1] - 2021-02-15
|
||||
|
||||
- first release
|
||||
- added examples
|
||||
|
||||
## [0.1.0] - 2019-10-28
|
||||
|
||||
- initial version
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2019-2022 Rob Tillaart
|
||||
Copyright (c) 2019-2023 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
|
||||
|
@ -28,11 +28,13 @@ As the display is only tested with a 6 digit display, this is used as the defaul
|
||||
- **void displayRaw(uint8_t \* data, uint8_t pointPos)** low level write function.
|
||||
- **void displayInt(long value)** idem
|
||||
- **void displayFloat(float value)** idem
|
||||
- **void displayFloat(float value, uint8_t fixedPoint)** display float with fixed point position.
|
||||
- **void displayHex(uint32_t value)** idem
|
||||
- **void displayClear()** writes spaces to all positions, effectively clearing the display.
|
||||
- **void setBrightness(uint8_t b)** brightness = 0 .. 7 default = 3.
|
||||
- **uint8_t getBrightness()** returns value set.
|
||||
- **uint8_t keyscan(void)** scans the keyboard once and return result. The keyscan() function cannot detect multiple keys.
|
||||
- **uint8_t keyscan(void)** scans the keyboard once and return result.
|
||||
The keyscan() function cannot detect multiple keys.
|
||||
|
||||
|
||||
**displayRaw()** can display multiple decimal points, by setting the high bit (0x80)
|
||||
@ -46,7 +48,7 @@ Or you can use the pointPos argument to light just one decimal at that position.
|
||||
- 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
|
||||
|
||||
**void displayPChar(char \*buff)** Attempts to display every ascii character 0x30 to 0x5F.
|
||||
**void displayPChar(char \*buff)** Attempts to display every ASCII character 0x30 to 0x5F.
|
||||
See example TM1637_custom.ino to insert your own 7 segment patterns.
|
||||
Also displayed are ' ' , '.' and '-' . Decimal points may also be displayed by setting the character sign bit.
|
||||
|
||||
@ -61,7 +63,6 @@ Routine **button_poll()** in the same example shows one way of polling and de-bo
|
||||
- **void init(uint8_t clockPin, uint8_t dataPin, uint8_t digits = 6)** replaced by begin().
|
||||
|
||||
|
||||
|
||||
### Display support
|
||||
|
||||
The library is tested with a 6 (=2x3) digit - decimal point - display and a 4 (=1x4) digit - clock - display.
|
||||
@ -71,7 +72,7 @@ To adjust the order for a not supported display, the following function can be u
|
||||
- **void setDigitOrder(uint8_t a, uint8_t b,... uint8_t h)** sets the order in which up to 8 digits should be clocked in.
|
||||
|
||||
If you have a (7 segment) display that is not supported by the library,
|
||||
please open an issue on Github so it can be build in.
|
||||
please open an issue on GitHub so it can be build in.
|
||||
|
||||
|
||||
### Tuning function
|
||||
@ -92,7 +93,9 @@ Feel free to file an issue to get your processor supported.
|
||||
### Keyboard Scanner usage and notes
|
||||
|
||||
|
||||
Calling keyscan() returns a uint8_t, whose value is 0xff if no keys are being pressed at the time. The TM1637 can only see one key press at a time, and there is no "rollover". If a key is pressed, then the values are as follows:
|
||||
Calling keyscan() returns a uint8_t, whose value is 0xff if no keys are being pressed at the time.
|
||||
The TM1637 can only see one key press at a time, and there is no "rollover".
|
||||
If a key is pressed, then the values are as follows:
|
||||
|
||||
<CENTER>
|
||||
<TABLE>
|
||||
@ -147,12 +150,12 @@ The scope photos were taken using the TM1637_keyscan_raw example, with the scope
|
||||
Implemented in version 0.3.0 Please read the datasheet to understand the limitations.
|
||||
|
||||
```
|
||||
// NOTE:
|
||||
// on the TM1637 boards tested by @wfdudley, keyscan() works well
|
||||
// if you add a 910 ohm or 1 Kohm 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,
|
||||
// the rise time is too long for the data to be read reliably.
|
||||
// NOTE:
|
||||
// on the TM1637 boards tested by @wfdudley, keyscan() works well
|
||||
// if you add a 910 ohm or 1 Kohm 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,
|
||||
// the rise time is too long for the data to be read reliably.
|
||||
```
|
||||
|
||||
|
||||
@ -163,16 +166,35 @@ See examples
|
||||
|
||||
## Future
|
||||
|
||||
### 0.4.0
|
||||
#### Must
|
||||
|
||||
- remove obsolete **init()** from code (0.4.0)
|
||||
|
||||
#### Should
|
||||
|
||||
- remove obsolete **init()** from code
|
||||
- investigate if code can be optimized
|
||||
- performance measurement
|
||||
|
||||
|
||||
### other
|
||||
|
||||
- testing other platforms.
|
||||
- move code from .h to .cpp
|
||||
- **setLeadingZeros(bool on = false)** leading zeros flag
|
||||
- getter.
|
||||
- set data array to 0.
|
||||
- 0.4.0
|
||||
|
||||
#### Could
|
||||
|
||||
- **keyScan()** camelCase ?
|
||||
- add debug flag for test without hardware.
|
||||
- simulate output to Serial? (HEX)?
|
||||
- **displayTest()** function ?
|
||||
|
||||
|
||||
#### Wont (unless requested)
|
||||
|
||||
- **rotate(bool rot = false)**
|
||||
- 180 degree rotation of all digits for mounting
|
||||
- reverse digit order
|
||||
- flip every digit (function to overwrite the char array)
|
||||
- **HUD(bool hud = false)** = Heads Up Display
|
||||
- flip every digit
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
// FILE: TM1637.cpp
|
||||
// AUTHOR: Rob Tillaart
|
||||
// DATE: 2019-10-28
|
||||
// VERSION: 0.3.4
|
||||
// VERSION: 0.3.5
|
||||
// PURPOSE: TM1637 library for Arduino
|
||||
// URL: https://github.com/RobTillaart/TM1637_RT
|
||||
|
||||
@ -70,7 +70,7 @@ TM1637::TM1637()
|
||||
}
|
||||
|
||||
|
||||
// wrapper, will become obsolete 0.4.0.
|
||||
// wrapper, init() will become obsolete 0.4.0.
|
||||
void TM1637::init(uint8_t clockPin, uint8_t dataPin, uint8_t digits)
|
||||
{
|
||||
begin(clockPin, dataPin, digits);
|
||||
@ -89,13 +89,13 @@ void TM1637::begin(uint8_t clockPin, uint8_t dataPin, uint8_t digits)
|
||||
digitalWrite(_data, HIGH);
|
||||
|
||||
// TODO: replace _digits by a display enumeration?
|
||||
if (_digits == 4 )
|
||||
if (_digits == 4)
|
||||
{
|
||||
setDigitOrder(3,2,1,0);
|
||||
setDigitOrder(3, 2, 1, 0);
|
||||
}
|
||||
else // (_digits == 6 ) // default
|
||||
else // (_digits == 6 ) // default
|
||||
{
|
||||
setDigitOrder(3,4,5,0,1,2);
|
||||
setDigitOrder(3, 4, 5, 0, 1, 2);
|
||||
}
|
||||
}
|
||||
|
||||
@ -111,13 +111,13 @@ void TM1637::displayInt(long value)
|
||||
{
|
||||
v = -v;
|
||||
last--;
|
||||
data[last] = 17; // minus sign;
|
||||
data[last] = 17; // minus sign;
|
||||
}
|
||||
|
||||
for (int i = 0; i < last; i++)
|
||||
{
|
||||
long t = v / 10;
|
||||
data[i] = v - 10 * t; // faster than %
|
||||
data[i] = v - 10 * t; // faster than %
|
||||
v = t;
|
||||
}
|
||||
|
||||
@ -129,8 +129,8 @@ void TM1637::displayFloat(float value)
|
||||
{
|
||||
uint8_t data[8] = { 16, 16, 16, 16, 16, 16, 16, 16};
|
||||
|
||||
float v = value;
|
||||
int dpos = _digits-1;
|
||||
float v = value;
|
||||
int dpos = _digits - 1;
|
||||
int last = _digits;
|
||||
bool neg = (v < 0);
|
||||
|
||||
@ -139,7 +139,7 @@ void TM1637::displayFloat(float value)
|
||||
v = -v;
|
||||
dpos--;
|
||||
last--;
|
||||
data[last] = 17; // minus sign;
|
||||
data[last] = 17; // minus sign;
|
||||
}
|
||||
|
||||
while (v >= 10)
|
||||
@ -158,6 +158,51 @@ void TM1637::displayFloat(float value)
|
||||
}
|
||||
|
||||
|
||||
void TM1637::displayFloat(float value, uint8_t fixedPoint)
|
||||
{
|
||||
// DEBUG
|
||||
// Serial.println(value);
|
||||
|
||||
uint8_t data[8] = { 16, 16, 16, 16, 16, 16, 16, 16};
|
||||
|
||||
float v = value;
|
||||
int dpos = _digits - 1;
|
||||
int last = _digits;
|
||||
bool neg = (v < 0);
|
||||
int point = fixedPoint + 1;
|
||||
|
||||
if (neg)
|
||||
{
|
||||
v = -v;
|
||||
dpos--;
|
||||
last--;
|
||||
}
|
||||
// v += 0.0001; // Bug fix for 12.999 <> 13.000
|
||||
v += 0.001; // Bug fix for 12.99 <> 13.00
|
||||
|
||||
while (v >= 10)
|
||||
{
|
||||
v /= 10;
|
||||
dpos--;
|
||||
point++;
|
||||
}
|
||||
|
||||
if (neg)
|
||||
{
|
||||
data[point] = 17; // minus sign;
|
||||
}
|
||||
|
||||
for (int i = point - 1; i > -1; i--)
|
||||
{
|
||||
int d = v;
|
||||
data[i] = d;
|
||||
v -= d;
|
||||
v *= 10;
|
||||
}
|
||||
displayRaw(data, fixedPoint);
|
||||
}
|
||||
|
||||
|
||||
void TM1637::displayHex(uint32_t value)
|
||||
{
|
||||
uint8_t data[8] = { 16, 16, 16, 16, 16, 16, 16, 16};
|
||||
@ -166,7 +211,7 @@ void TM1637::displayHex(uint32_t value)
|
||||
for (int i = 0; i < _digits; i++)
|
||||
{
|
||||
uint32_t t = v / 16;
|
||||
data[i] = v & 0x0F; // faster than %
|
||||
data[i] = v & 0x0F; // faster than %
|
||||
v = t;
|
||||
}
|
||||
displayRaw(data, -1);
|
||||
@ -180,13 +225,19 @@ void TM1637::displayClear()
|
||||
}
|
||||
|
||||
|
||||
void TM1637::setBrightness(uint8_t b)
|
||||
void TM1637::setBrightness(uint8_t brightness)
|
||||
{
|
||||
_brightness = b;
|
||||
_brightness = brightness;
|
||||
if (_brightness > 0x07) _brightness = 0x07;
|
||||
}
|
||||
|
||||
|
||||
uint8_t TM1637::getBrightness()
|
||||
{
|
||||
return _brightness;
|
||||
}
|
||||
|
||||
|
||||
void TM1637::setDigitOrder(uint8_t a, uint8_t b,
|
||||
uint8_t c, uint8_t d, uint8_t e,
|
||||
uint8_t f, uint8_t g, uint8_t h)
|
||||
@ -202,7 +253,7 @@ void TM1637::setDigitOrder(uint8_t a, uint8_t b,
|
||||
}
|
||||
|
||||
|
||||
// Set sign bit on any char to display decimal point
|
||||
// Set sign bit on any char to display decimal point
|
||||
void TM1637::displayPChar( char * data )
|
||||
{
|
||||
start();
|
||||
@ -227,6 +278,16 @@ void TM1637::displayPChar( char * data )
|
||||
|
||||
void TM1637::displayRaw(uint8_t * data, uint8_t pointPos)
|
||||
{
|
||||
// DEBUG
|
||||
// for (uint8_t d = 0; d < _digits; d++)
|
||||
// {
|
||||
// uint8_t x = data[_digits - d];
|
||||
// if (x < 0x10) Serial.print('0');
|
||||
// Serial.print(x, HEX);
|
||||
// Serial.print(' ');
|
||||
// }
|
||||
// Serial.println();
|
||||
|
||||
uint8_t b = 0;
|
||||
|
||||
start();
|
||||
@ -269,7 +330,7 @@ void TM1637::displayRaw(uint8_t * data, uint8_t pointPos)
|
||||
//
|
||||
uint8_t TM1637::writeByte(uint8_t data)
|
||||
{
|
||||
// shift out data 8 bits LSB first
|
||||
// shift out data 8 bits LSB first
|
||||
for (uint8_t i = 8; i > 0; i--)
|
||||
{
|
||||
writeSync(_clock, LOW);
|
||||
@ -282,12 +343,12 @@ uint8_t TM1637::writeByte(uint8_t data)
|
||||
writeSync(_data, HIGH);
|
||||
writeSync(_clock, HIGH);
|
||||
|
||||
// get ACKNOWLEDGE
|
||||
// get ACKNOWLEDGE
|
||||
pinMode(_data, INPUT);
|
||||
delayMicroseconds(_bitDelay);
|
||||
uint8_t rv = digitalRead(_data);
|
||||
|
||||
// FORCE OUTPUT LOW
|
||||
// FORCE OUTPUT LOW
|
||||
pinMode(_data, OUTPUT);
|
||||
digitalWrite(_data, LOW);
|
||||
delayMicroseconds(_bitDelay);
|
||||
@ -318,18 +379,19 @@ void TM1637::writeSync(uint8_t pin, uint8_t val)
|
||||
digitalWrite(pin, val);
|
||||
|
||||
#if defined(ESP32)
|
||||
nanoDelay(2);
|
||||
nanoDelay(21); // delay(2) is not enough in practice.
|
||||
#endif
|
||||
// other processors may need other "nanoDelay(n)"
|
||||
// other processors may need other "nanoDelay(n)"
|
||||
}
|
||||
|
||||
|
||||
// keyscan results are reversed left for right from the data sheet.
|
||||
// here are the values returned by keyscan():
|
||||
// pin 2 3 4 5 6 7 8 9
|
||||
// sg1 sg2 sg3 sg4 sg5 sg6 sg7 sg8
|
||||
// 19 k1 0xf7 0xf6 0xf5 0xf4 0xf3 0xf2 0xf1 0xf0
|
||||
// 20 k2 0xef 0xee 0xed 0xec 0xeb 0xea 0xe9 0xe8
|
||||
// keyscan results are reversed left for right from the data sheet.
|
||||
// here are the values returned by keyscan():
|
||||
//
|
||||
// pin 2 3 4 5 6 7 8 9
|
||||
// sg1 sg2 sg3 sg4 sg5 sg6 sg7 sg8
|
||||
// 19 k1 0xf7 0xf6 0xf5 0xf4 0xf3 0xf2 0xf1 0xf0
|
||||
// 20 k2 0xef 0xee 0xed 0xec 0xeb 0xea 0xe9 0xe8
|
||||
|
||||
uint8_t TM1637::keyscan(void)
|
||||
{
|
||||
@ -337,7 +399,7 @@ uint8_t TM1637::keyscan(void)
|
||||
uint8_t key;
|
||||
start();
|
||||
key = 0;
|
||||
writeByte(TM1637_READ_KEYSCAN); // includes the ACK, leaves DATA low
|
||||
writeByte(TM1637_READ_KEYSCAN); // includes the ACK, leaves DATA low
|
||||
pinMode(_data, INPUT_PULLUP);
|
||||
|
||||
for (uint8_t i = 0; i <= 7; i++) {
|
||||
@ -353,10 +415,10 @@ uint8_t TM1637::keyscan(void)
|
||||
delayMicroseconds(halfDelay);
|
||||
writeSync(_clock, HIGH);
|
||||
|
||||
// wait for ACK
|
||||
// wait for ACK
|
||||
delayMicroseconds(halfDelay);
|
||||
|
||||
// FORCE OUTPUT LOW
|
||||
// FORCE OUTPUT LOW
|
||||
pinMode(_data, OUTPUT);
|
||||
digitalWrite(_data, LOW);
|
||||
delayMicroseconds(halfDelay);
|
||||
@ -365,8 +427,8 @@ uint8_t TM1637::keyscan(void)
|
||||
}
|
||||
|
||||
|
||||
// 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.
|
||||
// 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)
|
||||
{
|
||||
volatile uint16_t i = n;
|
||||
@ -381,13 +443,13 @@ uint8_t TM1637::asciiTo7Segment ( char c )
|
||||
20 | | 02
|
||||
-40-
|
||||
10 | | 04
|
||||
-08- .80
|
||||
-08- .80
|
||||
*/
|
||||
// 7+1 Segment patterns for ASCII 0x30-0x5F
|
||||
const uint8_t asciiToSegments[] = {
|
||||
0x3f,0x06,0x5b,0x4f, 0x66,0x6d,0x7d,0x07, // 0123 4567
|
||||
const uint8_t asciiToSegments[] = {
|
||||
0x3f,0x06,0x5b,0x4f, 0x66,0x6d,0x7d,0x07, // 0123 4567
|
||||
0x7f,0x6f,0x09,0x89, 0x58,0x48,0x4c,0xD3, // 89:; <=>?
|
||||
0x5f,0x77,0x7c,0x39, 0x5E,0x79,0x71,0x3d, // @ABC DEFG
|
||||
0x5f,0x77,0x7c,0x39, 0x5E,0x79,0x71,0x3d, // @ABC DEFG
|
||||
0x76,0x06,0x0E,0x75, 0x38,0x37,0x54,0x5c, // HIJK LMNO
|
||||
0x73,0x67,0x50,0x6D, 0x78,0x3E,0x1C,0x9c, // PQRS TUVW
|
||||
0x76,0x6E,0x5B,0x39, 0x52,0x0F,0x23,0x08 // XYZ[ /]^_
|
||||
@ -405,5 +467,5 @@ uint8_t TM1637::asciiTo7Segment ( char c )
|
||||
}
|
||||
|
||||
|
||||
// -- END OF FILE --
|
||||
// -- END OF FILE --
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
// FILE: TM1637.h
|
||||
// AUTHOR: Rob Tillaart
|
||||
// DATE: 2019-10-28
|
||||
// VERSION: 0.3.4
|
||||
// VERSION: 0.3.5
|
||||
// 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.4"))
|
||||
#define TM1637_LIB_VERSION (F("0.3.5"))
|
||||
|
||||
|
||||
class TM1637
|
||||
@ -28,11 +28,12 @@ public:
|
||||
void displayRaw(uint8_t * data, uint8_t pointPos);
|
||||
void displayInt(long value);
|
||||
void displayFloat(float value);
|
||||
void displayFloat(float value, uint8_t fixedPoint);
|
||||
void displayHex(uint32_t value);
|
||||
void displayClear();
|
||||
|
||||
void setBrightness(uint8_t b);
|
||||
uint8_t getBrightness() { return _brightness; };
|
||||
void setBrightness(uint8_t brightness);
|
||||
uint8_t getBrightness();
|
||||
|
||||
// tune the timing of writing bytes.
|
||||
void setBitDelay(uint8_t bitDelay = 10) { _bitDelay = bitDelay; };
|
||||
@ -67,9 +68,9 @@ private:
|
||||
void nanoDelay(uint16_t n);
|
||||
|
||||
// Override in your own derived class for custom character translation
|
||||
virtual uint8_t asciiTo7Segment ( char c ) ;
|
||||
virtual uint8_t asciiTo7Segment ( char c ) ;
|
||||
};
|
||||
|
||||
|
||||
// -- END OF FILE --
|
||||
// -- END OF FILE --
|
||||
|
||||
|
@ -0,0 +1,59 @@
|
||||
//
|
||||
// FILE: TM1637_float_point.ino
|
||||
// AUTHOR: marshalab, Rob Tillaart
|
||||
// PURPOSE: demo TM1637 library
|
||||
// URL: https://github.com/RobTillaart/TM1637
|
||||
|
||||
|
||||
#include "TM1637.h"
|
||||
|
||||
|
||||
TM1637 TM;
|
||||
|
||||
uint32_t start, stop;
|
||||
volatile float f = 3.14159265;
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
Serial.println(__FILE__);
|
||||
|
||||
TM.begin(2, 3); // clockpin, datapin
|
||||
|
||||
TM.displayFloat(1.42425);
|
||||
delay(2000);
|
||||
TM.displayFloat(1.42425, 2);
|
||||
delay(2000);
|
||||
TM.displayFloat(-1.42425);
|
||||
delay(2000);
|
||||
TM.displayFloat(-1.42425, 2);
|
||||
delay(2000);
|
||||
TM.displayClear();
|
||||
delay(5000);
|
||||
}
|
||||
|
||||
|
||||
void loop()
|
||||
{
|
||||
test();
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
|
||||
void test()
|
||||
{
|
||||
start = millis();
|
||||
for (int i = 0; i < 1000; i++)
|
||||
{
|
||||
TM.displayFloat(f, 2); // there is loop overhead etc
|
||||
f += 1;
|
||||
}
|
||||
stop = millis();
|
||||
Serial.print("TIME:\t");
|
||||
Serial.print(stop - start);
|
||||
Serial.println(" ms");
|
||||
}
|
||||
|
||||
|
||||
// -- END OF FILE --
|
@ -15,7 +15,7 @@
|
||||
"type": "git",
|
||||
"url": "https://github.com/RobTillaart/TM1637_RT"
|
||||
},
|
||||
"version": "0.3.4",
|
||||
"version": "0.3.5",
|
||||
"license": "MIT",
|
||||
"frameworks": "arduino",
|
||||
"platforms": "*",
|
||||
|
@ -1,8 +1,8 @@
|
||||
name=TM1637_RT
|
||||
version=0.3.4
|
||||
version=0.3.5
|
||||
author=Rob Tillaart <rob.tillaart@gmail.com>
|
||||
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
|
||||
sentence=TM1637 Library for Arduino.
|
||||
sentence=TM1637 Library for Arduino.
|
||||
paragraph=For 6 digit 7 segment display.
|
||||
category=Display
|
||||
url=https://github.com/RobTillaart/TM1637_RT
|
||||
|
@ -1,7 +1,6 @@
|
||||
//
|
||||
// FILE: unit_test_001.cpp
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.1.0
|
||||
// DATE: 2021-04-16
|
||||
// PURPOSE: unit tests for the TM1637 library
|
||||
// https://github.com/RobTillaart/TM_1637_RT
|
||||
@ -97,4 +96,6 @@ unittest(test_set_bit_delay)
|
||||
|
||||
unittest_main()
|
||||
|
||||
// --------
|
||||
|
||||
// -- END OF FILE --
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user