Skip to content

Commit

Permalink
Version 1.9
Browse files Browse the repository at this point in the history
  • Loading branch information
gavinlyonsrepo committed Oct 24, 2022
1 parent b2f4914 commit 104cf20
Show file tree
Hide file tree
Showing 13 changed files with 344 additions and 189 deletions.
File renamed without changes.
44 changes: 14 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[![Website](https://img.shields.io/badge/Website-Link-blue.svg)](https://gavinlyonsrepo.github.io/) [![Rss](https://img.shields.io/badge/Subscribe-RSS-yellow.svg)](https://gavinlyonsrepo.github.io//feed.xml) [![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/paypalme/whitelight976)


![ module pics ](https://github.com/gavinlyonsrepo/TM1638plus/blob/master/extra/images/tm16383.jpg)

Table of contents
Expand All @@ -10,7 +13,6 @@ Table of contents
* [Model Two](#model-two)
* [Model Three](#model-three)
* [Notes](#notes)
* [Memory](#memory)
* [Ports](#ports)

Overview
Expand All @@ -24,7 +26,6 @@ This library supports 3 different models, pictured above from left to right.
2. Model 2, The (QYF 16 KEY) variant which has 16 pushbuttons.
3. Model 3, The (LKM1638) variant which has 8 bi-colour LED's and 8 Push buttons.


* Main Author: Gavin Lyons.

* Tested on Development platforms:
Expand All @@ -37,10 +38,6 @@ This library supports 3 different models, pictured above from left to right.
6. Teensy 4.0. (may not work at highest frequency see notes section)

* History: see CHANGELOG.md in extra folder
* Contributors: [gabormay](https://github.com/gabormay) [centic9](https://github.com/centic9) [wunderbaum](https://github.com/wunderbaum)

[![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/paypalme/whitelight976)


Installation
------------------------------
Expand Down Expand Up @@ -106,8 +103,9 @@ For more information see the commented headers in header file.
1. Print an ASCII character.
2. Print an ASCII character with a dot/decimal point.
3. Print a Hexadecimal digit(0-15).
4. Print a long integer number with or without leading zeros.
5. Print two integer numbers (0-9999) to each nibble with or without leading zeros.
4. Print a long integer number with or without leading zeros, and right and left aligned text.
5. Print two integer numbers (0-9999) to each nibble with or without leading zeros,
and right and left aligned text.
6. Print a text string(dots are replaced and dot is turned on preceding digit),
"abc.def" becomes "abcdef" with c decimal point segment switched on.
7. Read buttons status. User may have to debounce buttons depending on application.
Expand Down Expand Up @@ -142,10 +140,11 @@ The commented functions can be found in library header file TM1638plus_Model2.h.
The library support Strings,decimal ,Hex ,raw ASCII data, setting individual segments,
and the decimal point. For more detailed information on functions see commented headers in header file(.h).

1. Print a Hexadecimal number with or without leading zeros
2. Print a decimal number with or without leading zeros
1. Print a Hexadecimal number with or without leading zeros, and right and left aligned text.
2. Print a decimal number with or without leading zeros, and right and left aligned text.
3. Manually set segments to create custom patterns.
4. Print two 4 digit decimal number(0-9999) to each nibble with or without leading zeros.
4. Print two 4 digit decimal number(0-9999) to each nibble with or without leading zeros,
and right and left aligned text.
5. Print a text string, dot function supported.
6. Read buttons status. User may want to debounce buttons depending on application.
See TM1638plus_ADC_TEST_Model2.ino for debounce button example.
Expand Down Expand Up @@ -199,7 +198,7 @@ Notes
3. Driving multiple displays.
4. Detecting multiple buttons pressed together.

*Note A* : Swapped display Issue: Model 2 only
*Note 1* : Swapped display Issue: Model 2 only

For Some users using this library the nibbles in information display byte
where swapped around. This is because there are different versions of modules on market with different wiring. See issue #3 on github called Swapped display :: "12345678" becomes "56781234".
Expand All @@ -211,7 +210,7 @@ Object, set the fourth parameter "swap_nibbles" to True, The default is false.
| QYF-TM1638 | default operation | false |
| QYF-TM1638 -Ver 1.0 | Swapped display Fix | true |

*Note B* : High frequency micro-controllers.
*Note 2* : High frequency micro-controllers.

This library uses a software SPI-like protocol and may not work fully on
micro-controllers running at a very high frequency, without some adjustments to timing.
Expand All @@ -236,12 +235,12 @@ The Teensy results have been sent in by email, I don't have these MCU's them at
| Teensy 4.0| 150Mhz | Working model 1, no Data rest of models |
| Teensy 4.0| 396Mhz | Not working on m1 pre v1.6, no data after, no Data rest of models |

*Note C* : Driving multiple displays.
*Note 3* : Driving multiple displays.

It is possible to drive multiple modules. Share the DIO and CLK lines and use a unique
STB line for each device. see issue number 10 at github for example code.

*Note D* : Detecting multiple buttons pressed together.
*Note 4* : Detecting multiple buttons pressed together.

Model 1 and Model 3 CAN detect multiple buttons pressed.

Expand All @@ -256,21 +255,6 @@ Pressing Certain combinations of buttons will cause the data on Seven Segments
change. So the simultaneous use of multiple key presses and the seven segments display
is problematic. See issue 12 on github for more details.

Memory
-------------------------------

Version 1.4.

1. Model 1 memory usage NANO, basic hello world sketch.

Sketch uses 1488 bytes (4%) of program storage space.
Global variables use 22 bytes (1%) of dynamic memory.

2. Model 2 memory usage NANO, basic hello world sketch.

Sketch uses 1536 bytes (5%) of program storage space.
Global variables use 23 bytes (1%) of dynamic memory.


Ports
-------------------
Expand Down
135 changes: 78 additions & 57 deletions examples/TM1638plus_TEST_Model1/TM1638plus_TEST_Model1.ino
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Project Name: TM1638
File: TM1638plus_TEST_Model1.ino
Description: demo file library for TM1638 module(LED & KEY). Model 1
Carries out series of tests demonstrating arduino library TM1638plus.
Carries out series of tests to demo arduino library TM1638plus.
TESTS:
TEST 0 Reset
Expand Down Expand Up @@ -42,8 +42,7 @@ TM1638plus tm(STROBE_TM, CLOCK_TM , DIO_TM, high_freq);
// Some vars and defines for the tests.
#define myTestDelay 5000
#define myTestDelay1 1000
uint8_t testcount = 0;

#define myTestDelay3 3000

void setup()
{
Expand All @@ -57,24 +56,20 @@ void setup()

void loop()
{
switch (testcount)
{
case 1: Test1(); break; // Brightness
case 2: Test2(); break; // ASCII display
case 3: Test3(); break; // Set a single segment
case 4: Test4(); break; // Hex digits
case 5: Test5(); break; // Text String with Decimal point
case 6: Test6(); break; // TEXT + ASCII combo
case 7: Test7(); break; // Integer Decimal number
case 8: Test8(); break; // Text String + Float hack
case 9: Test9(); break; // Text String + decimal number
case 10: Test10(); break; // Multiple Decimal points
case 11: Test11(); break; // Display Overflow
case 12: Test12(); break; // Scrolling text
case 13: Test13(); break; // setLED and setLEDs
case 14: Test14(); break; // Buttons + LEDS
}
testcount++;
Test1(); // Brightness
Test2(); // ASCII display
Test3(); // Set a single segment in each digit
Test4(); // Hex digits
Test5(); // Text String with Decimal point
Test6(); // TEXT + ASCII combo
Test7(); // Integer Decimal number
Test8(); // Text String + Float hack
Test9(); // Text String + decimal number
Test10(); // Multiple Decimal points
Test11(); // Display Overflow
Test12(); // Scrolling text
Test13(); // setLED and setLEDs
Test14(); // Buttons + LEDS
}

void Test0()
Expand Down Expand Up @@ -105,38 +100,48 @@ void Test2() {
tm.displayASCII(1, '3');
tm.displayASCII(2, '4');
tm.displayASCII(3, '1');
delay(myTestDelay);
delay(myTestDelay3);
tm.reset();
}

void Test3() {
//TEST 3 single segment (pos, (dp)gfedcba)
//In this case segment g (middle dash) of digit position 7
tm.display7Seg(7, 0b01000000); // Displays " -"
delay(myTestDelay);
//TEST 3 single segment (digit position, (dp)gfedcba)
// (dp)gfedcba = seven segments positions
uint8_t pos = 0;
for (pos = 0 ; pos<8 ; pos++)
{
tm.display7Seg(pos, 1<<7-pos); // Displays a single seg in (dp)gfedcba) in each pos 0-7
delay(myTestDelay1);
}
}

void Test4() {
// Test 4 Hex digits.
tm.displayHex(0, 1);
tm.displayHex(1, 2);
tm.displayHex(2, 3);
tm.displayHex(3, 4);
tm.displayHex(4, 5);
tm.displayHex(5, 6);
tm.displayHex(6, 7);
tm.displayHex(7, 8);
delay(myTestDelay); // display 12345678
tm.displayHex(0, 0);
tm.displayHex(1, 1);
tm.displayHex(2, 2);
tm.displayHex(3, 3);
tm.displayHex(4, 4);
tm.displayHex(5, 5);
tm.displayHex(6, 6);
tm.displayHex(7, 7);
delay(myTestDelay3); // display 01234567

tm.displayHex(0, 8);
tm.displayHex(1, 9);
tm.displayHex(2, 10);
tm.displayHex(3, 11);
tm.displayHex(4, 12);
tm.displayHex(5, 13);
tm.displayHex(6, 14);
tm.displayHex(7, 15);
delay(myTestDelay); // display 89ABCDEF
tm.displayHex(2, 0x0A);
tm.displayHex(3, 0x0B);
tm.displayHex(4, 0x0C);
tm.displayHex(5, 0x0D);
tm.displayHex(6, 0x0E);
tm.displayHex(7, 0x0F);
delay(myTestDelay3); // display 89ABCDEF
tm.reset();

tm.displayHex(1, 0xFFFE);
tm.displayHex(7, 0x10);
delay(myTestDelay3); // display " E 0"

}

void Test5() {
Expand All @@ -160,18 +165,33 @@ void Test6() {
}

void Test7() {
// TEST 7a Integer
tm.displayIntNum(45, false); // "45 "
// TEST 7a Integer left aligned , NO leading zeros
tm.displayIntNum(45, false, TMAlignTextLeft); // "45 "
delay(myTestDelay);
// TEST 7b Integer
tm.displayIntNum(99991, true); // "00099991"
// TEST 7b Integer left aligned , leading zeros
tm.displayIntNum(99991, true, TMAlignTextLeft); // "00099991"
delay(myTestDelay);
tm.reset();
// TEST 7b tm.DisplayDecNumNIbble
tm.DisplayDecNumNibble(1234, 5678, false); // "12345678"
// TEST 7c Integer right aligned , NO leading zeros
tm.displayIntNum(35, false, TMAlignTextRight); // " 35"
delay(myTestDelay);
tm.DisplayDecNumNibble(123, 662, true); // "01230662"
// TEST 7d Integer right aligned , leading zeros
tm.displayIntNum(9983551, true, TMAlignTextRight); // "09983551"
delay(myTestDelay);

// TEST 7e tm.DisplayDecNumNIbble left aligned
tm.DisplayDecNumNibble(134, 70, false, TMAlignTextLeft); // "134 " "70" , left aligned, NO leading zeros
delay(myTestDelay);
tm.DisplayDecNumNibble(23, 662, true, TMAlignTextLeft); // "0023" "0662" , left aligned , leading zeros
delay(myTestDelay);
tm.reset();

// TEST 7f tm.DisplayDecNumNIbble right aligned
tm.DisplayDecNumNibble(43, 991, false, TMAlignTextRight); // " 43" " 991" , right aligned, NO leading zeros
delay(myTestDelay);
tm.DisplayDecNumNibble(53, 8, true, TMAlignTextRight); // "0053" "0008" , right aligned , leading zeros
delay(myTestDelay);

}

void Test8() {
Expand All @@ -180,7 +200,7 @@ void Test8() {
uint16_t data = 234;
sprintf(workStr, "ADC=.%04d", data); // "ADC=.0234"
tm.displayText(workStr);
delay(myTestDelay);
delay(myTestDelay3);
}

void Test9() {
Expand All @@ -198,7 +218,7 @@ void Test9() {

sprintf(workStr, "ADC=.%d%d.%d%d", digit1, digit2, digit3, digit4);
tm.displayText(workStr); //12.45.VOLT
delay(myTestDelay);
delay(myTestDelay3);
tm.reset();
}

Expand All @@ -215,7 +235,7 @@ void Test11()
{
//TEST11 user overflow
tm.displayText("1234567890abc"); //should display just 12345678
delay(myTestDelay);
delay(myTestDelay3);
tm.reset();
}

Expand Down Expand Up @@ -262,20 +282,21 @@ void Test13()
// NOTE passed L8-L1 and on display L8 is on right hand side. i.e. 0x01 turns on L1. LXXX XXXX
// For model 1 just use upper byte , lower byte is is used by model3 for bi-color leds leave at 0x00 for model 1.
tm.setLEDs(0xFF00); // all LEDs on
delay(3000);
delay(myTestDelay3);
tm.setLEDs(0x0100); // Displays as LXXX XXXX (L1-L8) , NOTE on display L8 is on right hand side.
delay(3000);
delay(myTestDelay3);
tm.setLEDs(0xF000); // Displays as XXXX LLLL (L1-L8) , NOTE on display L8 is on right hand side.
delay(3000);
delay(myTestDelay3);
tm.setLEDs(0x0000); // all off
delay(3000);
delay(myTestDelay3);

}

void Test14() {
//Test 14 buttons and LED test, press switch number S-X to turn on LED-X, where x is 1-8.
//The HEx value of switch is also sent to Serial port.
tm.displayText("buttons ");
delay(myTestDelay3);
while (1) // Loop here forever
{
uint8_t buttons = tm.readButtons();
Expand All @@ -292,7 +313,7 @@ void Test14() {
*/
Serial.println(buttons, HEX);
doLEDs(buttons);
tm.displayIntNum(buttons, true);
tm.displayIntNum(buttons, true, TMAlignTextLeft);
delay(250);
}
}
Expand Down
Loading

0 comments on commit 104cf20

Please sign in to comment.