0.3.3 TM1637_RT

This commit is contained in:
rob tillaart 2022-09-25 09:59:53 +02:00
parent 233811506c
commit 342c1d0c75
14 changed files with 141 additions and 73 deletions

View File

@ -0,0 +1,54 @@
# Change Log TM1637
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.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
- minor edits
- tested on 6 digits display (with decinal point).
## [0.3.0] - 2021-10-27
- improved keyscan - kudos to wfdudley
- 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
- update readme
- fix default values
## [0.1.1] - 2021-02-15
- first release
- added examples
## [0.1.0] - 2019-10-28
- initial version

View File

@ -1,8 +1,8 @@
[![Arduino CI](https://github.com/robtillaart/TM1637_RT/workflows/Arduino%20CI/badge.svg)](https://github.com/marketplace/actions/arduino_ci)
[![Arduino-lint](https://github.com/RobTillaart/TM1637_RT/actions/workflows/arduino-lint.yml/badge.svg)](https://github.com/RobTillaart/TM1637_RT/actions/workflows/arduino-lint.yml)
[![JSON check](https://github.com/RobTillaart/TM1637_RT/actions/workflows/jsoncheck.yml/badge.svg)](https://github.com/RobTillaart/TM1637_RT/actions/workflows/jsoncheck.yml)
[![GitHub release](https://img.shields.io/github/release/RobTillaart/TM1637_RT.svg?maxAge=3600)](https://github.com/RobTillaart/TM1637_RT/releases)
[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/RobTillaart/TM1637_RT/blob/master/LICENSE)
[![GitHub release](https://img.shields.io/github/release/RobTillaart/TM1637_RT.svg?maxAge=3600)](https://github.com/RobTillaart/TM1637_RT/releases)
# TM1637
@ -22,7 +22,7 @@ ESP32 is supported since 0.2.0 see https://github.com/RobTillaart/TM1637_RT/pull
## Interface
- **TM1637()** constructor
- **void init(uint8_t clockPin, uint8_t dataPin, uint8_t digits = 6)** set up the connection of the pins to the display.
- **void begin(uint8_t clockPin, uint8_t dataPin, uint8_t digits = 6)** set up the connection of the pins to the display.
As the display is only tested with a 6 digit display, this is used as the default of the digits parameter.
- **void displayRaw(uint8_t \* data, uint8_t pointPos)** low level write function.
- **void displayInt(long value)** idem
@ -49,6 +49,12 @@ See routine **ascii_to_7segment()** in the example TM1637_keyscan_cooked.ino. I
Routine **button_poll()** in the same example shows one way of polling and de-bouncing button presses.
#### Obsolete (0.4.0)
- **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.
@ -150,9 +156,15 @@ See examples
## Future
- elaborate documentation
- testing
- rename **init()** to **begin()** ?
- **keyScan()** camelCase ?
- separate CHANGELOG.md
### 0.4.0
- remove obsolete **init()** from code
### other
- testing platforms.
- investigate if code can be optimized
- performance measurement
- **keyScan()** camelCase ?

View File

@ -2,23 +2,9 @@
// FILE: TM1637.cpp
// AUTHOR: Rob Tillaart
// DATE: 2019-10-28
// VERSION: 0.3.2
// VERSION: 0.3.3
// 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.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 (decimal point) display
// 0.3.2 2022-04-16 fix #15 support for 4 digits.
// tested on 4 digit (clock) display.
// NOTE:
// on the inexpensive TM1637 boards @wfdudley has used, keyscan
@ -84,7 +70,14 @@ TM1637::TM1637()
}
// wrapper, will become obsolete 0.4.0.
void TM1637::init(uint8_t clockPin, uint8_t dataPin, uint8_t digits)
{
begin(clockPin, dataPin, digits);
}
void TM1637::begin(uint8_t clockPin, uint8_t dataPin, uint8_t digits)
{
_clock = clockPin;
_data = dataPin;

View File

@ -3,61 +3,67 @@
// FILE: TM1637.h
// AUTHOR: Rob Tillaart
// DATE: 2019-10-28
// VERSION: 0.3.2
// VERSION: 0.3.3
// PUPROSE: TM1637 library for Arduino
// URL: https://github.com/RobTillaart/TM1637_RT
// only tested on 6 digit display yet
// tested on 6 digit display + 4 digit (clock) display
#include "Arduino.h"
#define TM1637_LIB_VERSION (F("0.3.2"))
#define TM1637_LIB_VERSION (F("0.3.3"))
class TM1637
{
public:
TM1637();
public:
TM1637();
void init(uint8_t clockPin, uint8_t dataPin, uint8_t digits = 6);
// replaces init()
void begin(uint8_t clockPin, uint8_t dataPin, uint8_t digits = 6);
void displayRaw(uint8_t * data, uint8_t pointPos);
void displayInt(long value);
void displayFloat(float value);
void displayHex(uint32_t value);
void displayClear();
void displayRaw(uint8_t * data, uint8_t pointPos);
void displayInt(long value);
void displayFloat(float value);
void displayHex(uint32_t value);
void displayClear();
void setBrightness(uint8_t b);
uint8_t getBrightness() { return _brightness; };
void setBrightness(uint8_t b);
uint8_t getBrightness() { return _brightness; };
// tune the timing of writing bytes.
void setBitDelay(uint8_t bitDelay = 10) { _bitDelay = bitDelay; };
uint8_t getBitDelay() { return _bitDelay; };
uint8_t keyscan(void);
// tune the timing of writing bytes.
void setBitDelay(uint8_t bitDelay = 10) { _bitDelay = bitDelay; };
uint8_t getBitDelay() { return _bitDelay; };
uint8_t keyscan(void);
// the order the individual digits must be sent to the display.
void setDigitOrder(uint8_t a = 0, uint8_t b = 1,
uint8_t c = 2, uint8_t d = 3,
uint8_t e = 4, uint8_t f = 5,
uint8_t g = 6, uint8_t h = 7);
// the order the individual digits must be sent to the display.
void setDigitOrder(uint8_t a = 0, uint8_t b = 1,
uint8_t c = 2, uint8_t d = 3,
uint8_t e = 4, uint8_t f = 5,
uint8_t g = 6, uint8_t h = 7);
private:
uint8_t _clock = -1;
uint8_t _data = -1;
uint8_t _digits = 4;
uint8_t _brightness = 3;
uint8_t _bitDelay = 10;
// OBSOLETE
// init will be replaced by begin() in the future (0.4.0)
void init(uint8_t clockPin, uint8_t dataPin, uint8_t digits = 6);
uint8_t _digitOrder[8];
uint8_t writeByte(uint8_t data);
void start();
void stop();
private:
uint8_t _clock = -1;
uint8_t _data = -1;
uint8_t _digits = 4;
uint8_t _brightness = 3;
uint8_t _bitDelay = 10;
void writeSync(uint8_t pin, uint8_t val);
void nanoDelay(uint16_t n);
uint8_t _digitOrder[8];
uint8_t writeByte(uint8_t data);
void start();
void stop();
void writeSync(uint8_t pin, uint8_t val);
void nanoDelay(uint16_t n);
};

View File

@ -2,7 +2,6 @@
// FILE: TM1637_HEX.ino
// AUTHOR: Rob Tillaart
// PURPOSE: demo TM1637 library
// DATE: 2021-02-15
// URL: https://github.com/RobTillaart/TM1637
// test with 6 digits (decimal) display
@ -21,7 +20,8 @@ void setup()
Serial.begin(115200);
Serial.println(__FILE__);
TM.init(2, 3, 6);
TM.begin(2, 3, 6); // clockpin, datapin, #digits
TM.displayClear();
delay(2000);

View File

@ -17,7 +17,8 @@ void setup()
Serial.begin(115200);
Serial.println(__FILE__);
TM.init(2, 3);
TM.begin(2, 3); // clockpin, datapin
TM.setBrightness(2);
}

View File

@ -20,7 +20,8 @@ void setup()
Serial.begin(115200);
Serial.println(__FILE__);
TM.init(7, 6, 4);
TM.begin(7, 6, 4); // clockpin, datapin, #digits
TM.displayClear();
delay(2000);

View File

@ -2,7 +2,6 @@
// FILE: TM1637_float.ino
// AUTHOR: Rob Tillaart
// PURPOSE: demo TM1637 library
// DATE: 2021-02-15
// URL: https://github.com/RobTillaart/TM1637
@ -20,7 +19,8 @@ void setup()
Serial.begin(115200);
Serial.println(__FILE__);
TM.init(2, 3);
TM.begin(2, 3); // clockpin, datapin
TM.displayFloat(1.42425);
delay(2000);
TM.displayFloat(-1.42425);

View File

@ -2,7 +2,6 @@
// FILE: TM1637_int.ino
// AUTHOR: Rob Tillaart
// PURPOSE: demo TM1637 library
// DATE: 2021-02-15
// URL: https://github.com/RobTillaart/TM1637
@ -20,8 +19,8 @@ void setup()
Serial.begin(115200);
Serial.println(__FILE__);
TM.init(2, 3);
TM.begin(2, 3); // clockpin, datapin
TM.displayClear();
delay(1000);

View File

@ -36,8 +36,8 @@ void setup()
Serial.println(__TIME__);
Serial.println(__FILE__);
// TM.init(2, 3);
TM.init(dispCLOCK, dispDATA);
TM.begin(dispCLOCK, dispDATA);
TM.setBrightness(1);
TM.displayClear();
bptr = 0;

View File

@ -40,7 +40,8 @@ void setup()
Serial.println(__TIME__);
Serial.println(__FILE__);
TM.init(dispCLOCK, dispDATA);
TM.begin(dispCLOCK, dispDATA);
#ifdef TRIGGER
pinMode(TRIGGER, OUTPUT);
digitalWrite(TRIGGER, LOW);
@ -68,8 +69,8 @@ char button_poll(void) {
void loop()
{
char c;
c = button_poll();
button_poll();
#ifndef TRIGGER
// for oscilloscope testing, don't delay for faster repetition rate
delay(50);

View File

@ -6,7 +6,8 @@ TM1637 KEYWORD1
# Methods and Functions (KEYWORD2)
init KEYWORD2
begin KEYWORD2
displayRaw KEYWORD2
displayInt KEYWORD2

View File

@ -15,7 +15,7 @@
"type": "git",
"url": "https://github.com/RobTillaart/TM1637_RT"
},
"version": "0.3.2",
"version": "0.3.3",
"license": "MIT",
"frameworks": "arduino",
"platforms": "*",

View File

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