commit e09fe56554342acddbd128c40258aa15d83e3848 Author: Google Code Exporter Date: Sun Mar 15 10:11:53 2015 -0400 Migrating wiki contents from Google Code diff --git a/.project b/.project new file mode 100644 index 0000000..7edcde8 --- /dev/null +++ b/.project @@ -0,0 +1,11 @@ + + + wiki + + + + + + + + diff --git a/DefaultConstrutor.md b/DefaultConstrutor.md new file mode 100644 index 0000000..b2899d4 --- /dev/null +++ b/DefaultConstrutor.md @@ -0,0 +1,55 @@ +# Default Construtor Reference # + +Instantiate a TM1638 module specifying the display state, the starting intensity and the _data_, _clock_ and _stobe_ pins. + +``` +TM1638(byte dataPin, byte clockPin, byte strobePin, boolean activateDisplay, byte intensity); +``` + +For the inverted module + +``` +InvertedTM1638(byte dataPin, byte clockPin, byte strobePin, boolean activateDisplay, byte intensity); +``` + +For the TM1640 module + +``` +TM1640(byte dataPin, byte clockPin, boolean activateDisplay, byte intensity); +``` + +| Argument | Detail | Default | +|:---------|:-------|:--------| +| dataPin | The pin to use for Data I/O | _required_ | +| clockPin | The pin to use for Clock | _required_ | +| strobePin | The pin to use for Strobe (selector) | _required_ | +| activateDisplay | True to activate display on constructing, false otherwise. | true | +| intensity | The starting intensity from 0 (lowest) to 7 (highest) | 7 | + + +# Example # + +Define a module on data pin 8, clock pin 9 and strobe pin 7: +``` +TM1638 module1(8, 9, 7); +``` + +Define a module on data pin 8, clock pin 9 and strobe pin 6, with the display inactive at start: +``` +TM1638 module2(8, 9, 6, false); +``` + +Define a module on data pin 8, clock pin 9 and strobe pin 5, with the display active and the starting intensity at 1: +``` +TM1638 module3(8, 9, 5, true, 1); +``` + +Define an inverted module on data pin 8, clock pin 9 and strobe pin 4, with the display active and the starting intensity at 1: +``` +InvertedTM1638 module4(8, 9, 4, true, 1); +``` + +Define an TM1640 module on data pin 8 and clock pin 9 with the display active and the starting intensity at 1: +``` +TM1640 module5(8, 9, true, 1); +``` \ No newline at end of file diff --git a/ProjectHome.md b/ProjectHome.md new file mode 100644 index 0000000..02d6f13 --- /dev/null +++ b/ProjectHome.md @@ -0,0 +1,118 @@ +# TM1638/TM1640 library # + +## A library for interacting an arduino with a TM1638 or a TM1640. ## + * Support for the TM1638 and TM1640; + * Helper methods for displaying numbers in decimal, hexadecimal and binary; + * Support for multiple chained TM1638; + * Reading simultaneous button presses; + * Support for dimming the display and LEDs; + * Support for writing text; + * Support for module in inverted position; + * Examples for using the library with multiple TM1638 and with a TM1640. + +## [Download latest version (v2.1.3)](http://tm1638-library.googlecode.com/files/TM1638%20Library%20v2.1.3.zip) ## + +## [Library Reference](http://code.google.com/p/tm1638-library/wiki/Reference) ## + +## Author ## +Ricardo Batista + +Portugal + +#### See: #### + +[Library example usage video](http://www.youtube.com/watch?v=Vg3faVyApJY) + +[Text scroller example video](http://www.youtube.com/watch?v=0B5GQWyF5SQ) + +[Text scroller with several different TM1638 modules](http://www.youtube.com/watch?v=r8r8hdhNItU) + +[TM1638 Display/LED module (Red display)](http://www.dx.com/p/81873?Utm_rid=68099021&Utm_source=affiliate) +[(older link)](http://www.dealextreme.com/p/81873?r=68099021) + +[TM1638 Display/LED module (Green display)](http://www.dx.com/p/104329?Utm_rid=68099021&Utm_source=affiliate) +[(older link)](http://www.dealextreme.com/p/104329?r=68099021) + +[TM1640 module](http://www.dx.com/p/104311?Utm_rid=68099021&Utm_source=affiliate) +[(older link)](http://www.dealextreme.com/p/104311?r=68099021) + +##### This library is done as an hobby and it's free for everybody to use. ##### +##### You can contribute to the project by _using it_ (drop me a line if you're doing something with it :) ), _submitting ideas_ or _donating_ via Paypal: ##### +[![](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&encrypted=-----BEGIN%20PKCS7-----MIIHFgYJKoZIhvcNAQcEoIIHBzCCBwMCAQExggEwMIIBLAIBADCBlDCBjjELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKEwtQY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kqhkiG9w0BAQEFAASBgFbyH6ahYdM4lSBGNMDUrpkFVbHUxRoLiVLyJedir5AHr7ro8SQySMxiKUvhrrFg%2FinqyCvt2NDjboNQ9%2FC9tWe7yqpJKsj9eit57KYzGjwbxPs2oxuJb0U0wgAFojCNLXfkIgfsdRP7A18lr2aimjvuihKZfzRh8CVux9ME0jux-----END%20PKCS7-----) + + +#### Changes: #### + +Version 2.1.3 released: + + * added a define TM1638\_COLOR\_NONE for clarity when clearing a single LED ([issue #26](https://code.google.com/p/tm1638-library/issues/detail?id=#26)). + +Version 2.1.2 released: + + * corrected setDisplayDigit repeatedly with the dot set to true ([issue #22](https://code.google.com/p/tm1638-library/issues/detail?id=#22)); + * correction on setDisplayToDecNumber bug (thanks to hbx3485) ([issue #24](https://code.google.com/p/tm1638-library/issues/detail?id=#24)). + +Version 2.1.1 released: + * problems on clearDisplay and setupDisplay ([issue #21](https://code.google.com/p/tm1638-library/issues/detail?id=#21)). + +Version 2.1.0 released: + + * support for negative decimal numbers ([issue #20](https://code.google.com/p/tm1638-library/issues/detail?id=#20)); + * corrected setDisplayToString dot bug ([issue #19](https://code.google.com/p/tm1638-library/issues/detail?id=#19)). + +Version 2.0.1 released: + + * backwards compatibility with previous Arduino IDE - pure virtual functions were not supported ([issue #15](https://code.google.com/p/tm1638-library/issues/detail?id=#15)); + * corrected problem with setLEDs() caused by changes in the previous version ([issue #18](https://code.google.com/p/tm1638-library/issues/detail?id=#18)). + +Version 2.0.0 released: + + * support for the TM1640; + * restructuring for supporting other modules. + * _WARNING: some restructuring for supporting the TM1640 but code for older versions using the TM1638 shouldn't be affected_ + +Version 1.6.0 released: + * support for starting position on setDisplayToString() methods ([issue #10](https://code.google.com/p/tm1638-library/issues/detail?id=#10)) + * _WARNING: setDisplayToString methods have changed prototype and are incompatible with code compiled for 1.5.x (if you specified a custom font)_ + +Version 1.5.2 released: + * backwards compatibility with previous Arduino IDE - pre IDE version 1.0 ([issue #9](https://code.google.com/p/tm1638-library/issues/detail?id=#9)). + +Version 1.5.1 released: + * new character data in default font for '`*`' ([issue #7](https://code.google.com/p/tm1638-library/issues/detail?id=#7)); + * minor optimization on inverted TM1638. + +Version 1.5.0 released: + * support for inverted module; + * support for Arduino IDE 1.0; + * new functions usage example added; + * some restructuring. + +Version 1.4.0 released: + * support for specifying dots on setDisplayToString ([issue #6](https://code.google.com/p/tm1638-library/issues/detail?id=#6)) + * _WARNING: setDisplayToString methods have changed prototype and are incompatible with code compiled for 1.3.x (if you specified a custom font)_ + +Version 1.3.2 released: + * correction of string library import ([issue #5](https://code.google.com/p/tm1638-library/issues/detail?id=#5)). + +Version 1.3.1 released: + * changed pins on the examples to match schematics on project site. + +Version 1.3.0 released: + * added support for String Object; + * added support for removing leading zeros in displaying numbers. + +Version 1.2.0 released: added support for writing text. + + +Version 1.1.0: restructuring and added 2 proper examples, available in the arduino ide. + +#### Example schematics #### + +[Example schematic for one module](http://tm1638-library.googlecode.com/files/tm1638%20-%20one%20module_schem.svg) + +[Example schematic](http://tm1638-library.googlecode.com/files/tm1638_schem.svg) + +![http://tm1638-library.googlecode.com/files/tm1638helper.png](http://tm1638-library.googlecode.com/files/tm1638helper.png) +![http://tm1638-library.googlecode.com/files/tm1638%20-%20one%20module_schem.png](http://tm1638-library.googlecode.com/files/tm1638%20-%20one%20module_schem.png) +![http://tm1638-library.googlecode.com/files/tm1638_schem.png](http://tm1638-library.googlecode.com/files/tm1638_schem.png) \ No newline at end of file diff --git a/Reference.md b/Reference.md new file mode 100644 index 0000000..57adf46 --- /dev/null +++ b/Reference.md @@ -0,0 +1,70 @@ +# TM1638/TM1640 library # + +This is a library for interacting an arduino with a TM1638/TM1640 module. + +The [TM1638 module](http://www.dealextreme.com/p/81873?r=68099021) is a module with 8x 7-segment display (8 digits), 8x 2 color (red and green) LED and 8x buttons and is controlled using serial commands. + +The TM1638 module is designed to be chainable. It uses only one pin for _clock_, one pin for _data_ and an additional pin (_strobe_) for each module you chain up to 6... that's a total of 8 pins for controlling 48 (8x6) 7-segment digits, 48 buttons and 96 LEDs (48 red and 48 green). + +Great to use as a "helper/debugging" module. + +The [TM1640 module](http://www.dealextreme.com/p/104311?r=68099021) is a module with 16x 7-segment display (8 digits) and is controlled using serial commands. + + +# Usage # + +This library is designed to allow usage of simultaneous independent modules (chained or unchained). + +Basic usage is (after including "TM1638.h"): +``` +TM1638 module(8, 9, 7); +``` + +This defines a module with data on pin 8, clock on pin 9 and strobe on pin 7. + +Chaining modules is as easy as: +``` +TM1638 module1(8, 9, 7); +TM1638 module2(8, 9, 6); +``` + +This defines two modules with data on pin 8, clock on pin 9 and strobes on pin 6 and 7. + +There is also support for inverted TM1638 modules. They are used just like regular TM1638 and can be instantiated (after including "InvertedTM1638.h") with: +``` +InvertedTM1638 module(8, 9, 7); +``` + +The TM1640 modules are used just like regular TM1638 and can be instantiated (after including "TM1640.h") with: +``` +TM1640 module(8, 9); +``` + + +# Library Reference # + +[Full Reference](TableOfContents.md) + +## Constructors ## + +[Default Constructor](DefaultConstrutor.md) + +## Methods ## + +| **Method** | **Description** | +|:-----------|:----------------| +| [clearDisplay](clearDisplay.md) | Clears the display. (TM1638/TM1640) | +| [clearDisplayDigit](clearDisplayDigit.md) | Clear a single 7-segment display. (TM1638/TM1640) | +| [getButtons](getButtons.md) | Returns the pressed buttons as a bit set (left to right). (TM1638) | +| [setDisplay](setDisplay.md) | Set the 7-segment displays to the 8 values (left to right). (TM1638/TM1640) | +| [setDisplayDigit](setDisplayDigit.md) | Set a single display to a digit. (TM1638/TM1640) | +| [setDisplayToBinNumber](setDisplayToBinNumber.md) | Set the display to a binary number. (TM1638) | +| [setDisplayToDecNumber](setDisplayToDecNumber.md) | Set the display to a unsigned decimal number, with or without leading zeros. (TM1638) | +| [setDisplayToSignedDecNumber](setDisplayToSignedDecNumber.md) | Set the display to a signed decimal number, with or without leading zeros. (TM1638) | +| [setDisplayToError](setDisplayToError.md) | Set the display to an error message. (TM1638/TM1640) | +| [setDisplayToHexNumber](setDisplayToHexNumber.md) | Set the display to a unsigned hexadecimal number, with or without leading zeros. (TM1638) | +| [setDisplayToString(char\*)](setDisplayToString.md) | Set the display to the string. (TM1638/TM1640) | +| [setDisplayToString(String)](setDisplayToString2.md) | Set the display to the string. (TM1638/TM1640) | +| [setLED](setLED.md) | Controls a LED. (TM1638) | +| [setLEDs](setLEDs.md) | Set all the LEDs. (TM1638) | +| [setupDisplay](setupDisplay.md) | Set the display (all 7-segments) and LEDs on or off and the specifies the intensity. (TM1638/TM1640) | \ No newline at end of file diff --git a/TableOfContents.md b/TableOfContents.md new file mode 100644 index 0000000..e69de29 diff --git a/clearDisplay.md b/clearDisplay.md new file mode 100644 index 0000000..aa3339b --- /dev/null +++ b/clearDisplay.md @@ -0,0 +1,18 @@ +# clearDisplay Reference (TM1638/TM1640) # + +Clears the display. + +``` +void clearDisplay(); +``` + +| Argument | Detail | Default | +|:---------|:-------|:--------| +| | | + +# Example # + +Clear the display on _module1_. +``` +module1.clearDisplay(); +``` \ No newline at end of file diff --git a/clearDisplayDigit.md b/clearDisplayDigit.md new file mode 100644 index 0000000..65693b5 --- /dev/null +++ b/clearDisplayDigit.md @@ -0,0 +1,24 @@ +# clearDisplayDigit Reference (TM1638/TM1640) # + +Clear a single 7-segment display. + +``` +void clearDisplayDigit(byte pos, boolean dot); +``` + +| Argument | Detail | Default | +|:---------|:-------|:--------| +| pos | The display to clear, starting at position 0 (leftmost). | _required_ | +| dot | The dot state on the 7-segment display | _required_ | + +# Example # + +Clear the second 7-segment display (counting from the left), but leave the dot lit. +``` +module1.clearDisplayDigit(1, true); +``` + +Clear the third 7-segment display (counting from the left), including the dot. +``` +module1.clearDisplayDigit(2, false); +``` \ No newline at end of file diff --git a/getButtons.md b/getButtons.md new file mode 100644 index 0000000..c5bc113 --- /dev/null +++ b/getButtons.md @@ -0,0 +1,28 @@ +# getButtons Reference (TM1638) # + +Returns the pressed buttons as a bit set (left to right). + +``` +byte getButtons(); +``` + +| Argument | Detail | Default | +|:---------|:-------|:--------| +| | | | + +# Example # + +The expression is true if the leftmost button is pressed: +``` +module1.getButtons() == 0b00000001 +``` + +The expression is true if the rightmost button is pressed: +``` +module1.getButtons() == 0b10000000 +``` + +The expression is true if both middle buttons are pressed: +``` +module1.getButtons() == 0b00011000 +``` \ No newline at end of file diff --git a/setDisplay.md b/setDisplay.md new file mode 100644 index 0000000..30ee9da --- /dev/null +++ b/setDisplay.md @@ -0,0 +1,20 @@ +# setDisplay Reference (TM1638/TM1640) # + +Set the 7-segment displays to the 8 values (left to right) + +``` +void setDisplay(const byte values[]); +``` + +| Argument | Detail | Default | +|:---------|:-------|:--------| +| values | The values for each of the 8 7-segment displays from the the leftmost to the rightmost. | _required_ | + +# Example # + +Light a single segment on each of the 7-segment displays (and only the dot on the rightmost one): +``` +byte values[] = { 1, 2, 4, 8, 16, 32, 64, 128 }; + +module1.setDisplay(values); +``` \ No newline at end of file diff --git a/setDisplayDigit.md b/setDisplayDigit.md new file mode 100644 index 0000000..049b816 --- /dev/null +++ b/setDisplayDigit.md @@ -0,0 +1,21 @@ +# setDisplayDigit Reference (TM1638/TM1640) # + +Set a single display to a digit. + +``` +void setDisplayDigit(byte digit, byte pos, boolean dot, const byte numberFont[]); +``` + +| Argument | Detail | Default | Since | +|:---------|:-------|:--------|:------| +| digit| The digit to set | _required_ | | +| pos| The 7-segment display to set. 0 for the leftmost, 7 for the rightmost | _required_ | | +| dot | The dot status for the display | _required_ | | +| numberFont | The font (segment data) to use for numbers, defaulting to the built-in font. | NUMBER\_FONT, the built-in number font | v1.5.0 | + +# Example # + +Set the leftmost display to a "6.": +``` +module1.setDisplayDigit(6, 0, true); +``` \ No newline at end of file diff --git a/setDisplayToBinNumber.md b/setDisplayToBinNumber.md new file mode 100644 index 0000000..f40447c --- /dev/null +++ b/setDisplayToBinNumber.md @@ -0,0 +1,25 @@ +# setDisplayToBinNumber Reference (TM1638) # + +Set the display to a binary number. + +``` +void setDisplayToBinNumber(byte number, byte dots, const byte numberFont[]); +``` + +| Argument | Detail | Default | Since | +|:---------|:-------|:--------|:------| +| number | The number to display | _required_ | | +| dots | The dots to set (bitwise) | _required_ | | +| numberFont | The font (segment data) to use for numbers, defaulting to the built-in font. | NUMBER\_FONT, the built-in number font | v1.5.0 | + +# Example # + +Display "1.0.1.0.1.0.1.0.": +``` +module1.setDisplayToBinNumber(0b10101010, 0xFF); +``` + +Display 15 in binary with no dots: +``` +module1.setDisplayToBinNumber(15, 0); +``` \ No newline at end of file diff --git a/setDisplayToDecNumber.md b/setDisplayToDecNumber.md new file mode 100644 index 0000000..bae7a6d --- /dev/null +++ b/setDisplayToDecNumber.md @@ -0,0 +1,26 @@ +# setDisplayToDecNumber Reference (TM1638) # + +Set the display to a unsigned decimal number, with or without leading zeros. + +``` +void setDisplayToDecNumber(unsigned long number, byte dots, boolean leadingZeros, const byte numberFont[]); +``` + +| Argument | Detail | Default | Since | +|:---------|:-------|:--------|:------| +| number | The number to display | _required_ | | +| dots | The dots to set (bitwise) | _required_ | | +| leadingZeros | _true_ to display leading zeros, false otherwise | true | | +| numberFont | The font (segment data) to use for numbers, defaulting to the built-in font. | NUMBER\_FONT, the built-in number font | v1.5.0 | + +# Example # + +Display "00000033.": +``` +module1.setDisplayToDecNumber(33, 1); +``` + +Display 15 in decimal with no dots and no leading zeroes: +``` +module1.setDisplayToDecNumber(15, 0, false); +``` \ No newline at end of file diff --git a/setDisplayToError.md b/setDisplayToError.md new file mode 100644 index 0000000..12c62ff --- /dev/null +++ b/setDisplayToError.md @@ -0,0 +1,18 @@ +# setDisplayToError Reference (TM1638/TM1640) # + +Set the display to an error message. Is called on overflow in [setDisplayToDecNumber](setDisplayToDecNumber.md) + +``` +void setDisplayToError(); +``` + +| Argument | Detail | Default | Since | +|:---------|:-------|:--------|:------| +| | | | | + +# Example # + +Display an error: +``` +module1.setDisplayToError(); +``` \ No newline at end of file diff --git a/setDisplayToHexNumber.md b/setDisplayToHexNumber.md new file mode 100644 index 0000000..6a78fe8 --- /dev/null +++ b/setDisplayToHexNumber.md @@ -0,0 +1,26 @@ +# setDisplayToHexNumber Reference (TM1638) # + +Set the display to a unsigned hexadecimal number, with or without leading zeros. + +``` +void setDisplayToHexNumber(unsigned long number, byte dots, boolean leadingZeros, const byte numberFont[]); +``` + +| Argument | Detail | Default | Since | +|:---------|:-------|:--------|:------| +| number | The number to display | _required_ | | +| dots | The dots to set (bitwise) | _required_ | | +| leadingZeros | _true_ to display leading zeros, false otherwise | true | | +| numberFont | The font (segment data) to use for numbers, defaulting to the built-in font. | NUMBER\_FONT, the built-in number font | v1.5.0 | + +# Example # + +Display "00000A1A.": +``` +module1.setDisplayToHexNumber(0x0a1a, 1); +``` + +Display 15 in hexadecimal with no dots and no leading zeroes: +``` +module1.setDisplayToHexNumber(15, 0, false); +``` \ No newline at end of file diff --git a/setDisplayToSignedDecNumber.md b/setDisplayToSignedDecNumber.md new file mode 100644 index 0000000..f0b2bdf --- /dev/null +++ b/setDisplayToSignedDecNumber.md @@ -0,0 +1,26 @@ +# setDisplayToSignedDecNumber Reference (TM1638) # + +Set the display to a signed decimal number, with or without leading zeros. + +``` +void setDisplayToSignedDecNumber(unsigned long number, byte dots, boolean leadingZeros, const byte numberFont[]); +``` + +| Argument | Detail | Default | Since | +|:---------|:-------|:--------|:------| +| number | The number to display | _required_ | | +| dots | The dots to set (bitwise) | _required_ | | +| leadingZeros | _true_ to display leading zeros, false otherwise | true | | +| numberFont | The font (segment data) to use for numbers, defaulting to the built-in font. | NUMBER\_FONT, the built-in number font | v1.5.0 | + +# Example # + +Display "-0000033.": +``` +module1.setDisplayToDecNumber(-33, 1); +``` + +Display -15 in decimal with no dots and no leading zeroes: +``` +module1.setDisplayToDecNumber(-15, 0, false); +``` \ No newline at end of file diff --git a/setDisplayToString.md b/setDisplayToString.md new file mode 100644 index 0000000..75fbc49 --- /dev/null +++ b/setDisplayToString.md @@ -0,0 +1,143 @@ +# setDisplayToString Reference (TM1638/TM1640) # + +Set the display to the string. + +``` +void setDisplayToString(const char* string, const word dots, const byte pos, const byte font[]); +``` + +| Argument | Detail | Default | Since | +|:---------|:-------|:--------|:------| +| string | The text to display | _required_ | | +| dots | The dots to set (bitwise) | 0 | v1.4.0 | +| pos | The position to start. 0 for the leftmost, 7 for the rightmost | required | v1.6.0 | +| font | The font (segment data) to use, defaulting to the built-in font. | FONT\_DEFAULT, the built-in font | | + +# Example # + +Display "Ricardo." using the built-in font: +``` +char* name = "Ricardo."; + +module.setDisplayToString(name); +``` + +Display "Ricardo " with dots on every other letter: +``` +char* name = "Ricardo "; + +module.setDisplayToString(name, 0b10101010); +``` + +Display "foo bar": +``` +char* foo = "foo"; +char* bar = "bar"; + +module.setDisplayToString(foo, 0); +module.setDisplayToString(bar, 0, 4); +``` + +# Font character data # + +Fonts can be created like the built-in font: +``` +// definition for the displayable ASCII chars +const byte FONT_DEFAULT[] = { + 0b00000000, // (32) + 0b10000110, // (33) ! + 0b00100010, // (34) " + 0b01111110, // (35) # + 0b01101101, // (36) $ + 0b00000000, // (37) % + 0b00000000, // (38) & + 0b00000010, // (39) ' + 0b00110000, // (40) ( + 0b00000110, // (41) ) + 0b00000000, // (42) * + 0b00000000, // (43) + + 0b00000100, // (44) , + 0b01000000, // (45) - + 0b10000000, // (46) . + 0b01010010, // (47) / + 0b00111111, // (48) 0 + 0b00000110, // (49) 1 + 0b01011011, // (50) 2 + 0b01001111, // (51) 3 + 0b01100110, // (52) 4 + 0b01101101, // (53) 5 + 0b01111101, // (54) 6 + 0b00100111, // (55) 7 + 0b01111111, // (56) 8 + 0b01101111, // (57) 9 + 0b00000000, // (58) : + 0b00000000, // (59) ; + 0b00000000, // (60) < + 0b01001000, // (61) = + 0b00000000, // (62) > + 0b01010011, // (63) ? + 0b01011111, // (64) @ + 0b01110111, // (65) A + 0b01111111, // (66) B + 0b00111001, // (67) C + 0b00111111, // (68) D + 0b01111001, // (69) E + 0b01110001, // (70) F + 0b00111101, // (71) G + 0b01110110, // (72) H + 0b00000110, // (73) I + 0b00011111, // (74) J + 0b01101001, // (75) K + 0b00111000, // (76) L + 0b00010101, // (77) M + 0b00110111, // (78) N + 0b00111111, // (79) O + 0b01110011, // (80) P + 0b01100111, // (81) Q + 0b00110001, // (82) R + 0b01101101, // (83) S + 0b01111000, // (84) T + 0b00111110, // (85) U + 0b00101010, // (86) V + 0b00011101, // (87) W + 0b01110110, // (88) X + 0b01101110, // (89) Y + 0b01011011, // (90) Z + 0b00111001, // (91) [ + 0b01100100, // (92) \ (this can't be the last char on a line, even in comment or it'll concat) + 0b00001111, // (93) ] + 0b00000000, // (94) ^ + 0b00001000, // (95) _ + 0b00100000, // (96) ` + 0b01011111, // (97) a + 0b01111100, // (98) b + 0b01011000, // (99) c + 0b01011110, // (100) d + 0b01111011, // (101) e + 0b00110001, // (102) f + 0b01101111, // (103) g + 0b01110100, // (104) h + 0b00000100, // (105) i + 0b00001110, // (106) j + 0b01110101, // (107) k + 0b00110000, // (108) l + 0b01010101, // (109) m + 0b01010100, // (110) n + 0b01011100, // (111) o + 0b01110011, // (112) p + 0b01100111, // (113) q + 0b01010000, // (114) r + 0b01101101, // (115) s + 0b01111000, // (116) t + 0b00011100, // (117) u + 0b00101010, // (118) v + 0b00011101, // (119) w + 0b01110110, // (120) x + 0b01101110, // (121) y + 0b01000111, // (122) z + 0b01000110, // (123) { + 0b00000110, // (124) | + 0b01110000, // (125) } + 0b00000001, // (126) ~ +}; +``` \ No newline at end of file diff --git a/setDisplayToString2.md b/setDisplayToString2.md new file mode 100644 index 0000000..7f598c4 --- /dev/null +++ b/setDisplayToString2.md @@ -0,0 +1,143 @@ +# setDisplayToString Reference (TM1638/TM1640) # + +Set the display to the string. + +``` +void setDisplayToString(String string, const word dots, const byte pos, const byte font[]); +``` + +| Argument | Detail | Default | Since | +|:---------|:-------|:--------|:------| +| string | The text to display | _required_ | | +| dots | The dots to set (bitwise) | 0 | v1.4.0 | +| pos | The position to start. 0 for the leftmost | required | v1.6.0 | +| font | The font (segment data) to use, defaulting to the built-in font. | FONT\_DEFAULT, the built-in font | | + +# Example # + +Display "Ricardo." using the built-in font: +``` +String name = "Ricardo."; + +module.setDisplayToString(name); +``` + +Display "Ricardo " with dots on every other word: +``` +String name = "Ricardo "; + +module.setDisplayToString(name, 0b10101010); +``` + +Display "foo bar": +``` +String foo = "foo"; +String bar = "bar"; + +module.setDisplayToString(foo, 0); +module.setDisplayToString(bar, 0, 4); +``` + +# Font character data # + +Fonts can be created like the built-in font: +``` +// definition for the displayable ASCII chars +const byte FONT_DEFAULT[] = { + 0b00000000, // (32) + 0b10000110, // (33) ! + 0b00100010, // (34) " + 0b01111110, // (35) # + 0b01101101, // (36) $ + 0b00000000, // (37) % + 0b00000000, // (38) & + 0b00000010, // (39) ' + 0b00110000, // (40) ( + 0b00000110, // (41) ) + 0b00000000, // (42) * + 0b00000000, // (43) + + 0b00000100, // (44) , + 0b01000000, // (45) - + 0b10000000, // (46) . + 0b01010010, // (47) / + 0b00111111, // (48) 0 + 0b00000110, // (49) 1 + 0b01011011, // (50) 2 + 0b01001111, // (51) 3 + 0b01100110, // (52) 4 + 0b01101101, // (53) 5 + 0b01111101, // (54) 6 + 0b00100111, // (55) 7 + 0b01111111, // (56) 8 + 0b01101111, // (57) 9 + 0b00000000, // (58) : + 0b00000000, // (59) ; + 0b00000000, // (60) < + 0b01001000, // (61) = + 0b00000000, // (62) > + 0b01010011, // (63) ? + 0b01011111, // (64) @ + 0b01110111, // (65) A + 0b01111111, // (66) B + 0b00111001, // (67) C + 0b00111111, // (68) D + 0b01111001, // (69) E + 0b01110001, // (70) F + 0b00111101, // (71) G + 0b01110110, // (72) H + 0b00000110, // (73) I + 0b00011111, // (74) J + 0b01101001, // (75) K + 0b00111000, // (76) L + 0b00010101, // (77) M + 0b00110111, // (78) N + 0b00111111, // (79) O + 0b01110011, // (80) P + 0b01100111, // (81) Q + 0b00110001, // (82) R + 0b01101101, // (83) S + 0b01111000, // (84) T + 0b00111110, // (85) U + 0b00101010, // (86) V + 0b00011101, // (87) W + 0b01110110, // (88) X + 0b01101110, // (89) Y + 0b01011011, // (90) Z + 0b00111001, // (91) [ + 0b01100100, // (92) \ (this can't be the last char on a line, even in comment or it'll concat) + 0b00001111, // (93) ] + 0b00000000, // (94) ^ + 0b00001000, // (95) _ + 0b00100000, // (96) ` + 0b01011111, // (97) a + 0b01111100, // (98) b + 0b01011000, // (99) c + 0b01011110, // (100) d + 0b01111011, // (101) e + 0b00110001, // (102) f + 0b01101111, // (103) g + 0b01110100, // (104) h + 0b00000100, // (105) i + 0b00001110, // (106) j + 0b01110101, // (107) k + 0b00110000, // (108) l + 0b01010101, // (109) m + 0b01010100, // (110) n + 0b01011100, // (111) o + 0b01110011, // (112) p + 0b01100111, // (113) q + 0b01010000, // (114) r + 0b01101101, // (115) s + 0b01111000, // (116) t + 0b00011100, // (117) u + 0b00101010, // (118) v + 0b00011101, // (119) w + 0b01110110, // (120) x + 0b01101110, // (121) y + 0b01000111, // (122) z + 0b01000110, // (123) { + 0b00000110, // (124) | + 0b01110000, // (125) } + 0b00000001, // (126) ~ +}; +``` \ No newline at end of file diff --git a/setDisplayToString_String.md b/setDisplayToString_String.md new file mode 100644 index 0000000..d5b335c --- /dev/null +++ b/setDisplayToString_String.md @@ -0,0 +1,133 @@ +# setDisplayToString Reference (TM1638/TM1640) # + +Set the display to the string. + +``` +void setDisplayToString(String string, const byte dots, const byte font[]); +``` + +| Argument | Detail | Default | +|:---------|:-------|:--------| +| string | The text to display | _required_ | +| dots | The dots to set (bitwise) | 0 | +| font | The font (segment data) to use, defaulting to the built-in font. | FONT\_DEFAULT, the built-in font | + +# Example # + +Display "Ricardo." using the built-in font: +``` +String name = "Ricardo."; + +module.setDisplayToString(name); +``` + +Display "Ricardo " with dots on every other word: +``` +String name = "Ricardo "; + +module.setDisplayToString(name, 0b10101010); +``` + +# Font character data # + +Fonts can be created like the built-in font: +``` +// definition for the displayable ASCII chars +const byte FONT_DEFAULT[] = { + 0b00000000, // (32) + 0b10000110, // (33) ! + 0b00100010, // (34) " + 0b01111110, // (35) # + 0b01101101, // (36) $ + 0b00000000, // (37) % + 0b00000000, // (38) & + 0b00000010, // (39) ' + 0b00110000, // (40) ( + 0b00000110, // (41) ) + 0b00000000, // (42) * + 0b00000000, // (43) + + 0b00000100, // (44) , + 0b01000000, // (45) - + 0b10000000, // (46) . + 0b01010010, // (47) / + 0b00111111, // (48) 0 + 0b00000110, // (49) 1 + 0b01011011, // (50) 2 + 0b01001111, // (51) 3 + 0b01100110, // (52) 4 + 0b01101101, // (53) 5 + 0b01111101, // (54) 6 + 0b00100111, // (55) 7 + 0b01111111, // (56) 8 + 0b01101111, // (57) 9 + 0b00000000, // (58) : + 0b00000000, // (59) ; + 0b00000000, // (60) < + 0b01001000, // (61) = + 0b00000000, // (62) > + 0b01010011, // (63) ? + 0b01011111, // (64) @ + 0b01110111, // (65) A + 0b01111111, // (66) B + 0b00111001, // (67) C + 0b00111111, // (68) D + 0b01111001, // (69) E + 0b01110001, // (70) F + 0b00111101, // (71) G + 0b01110110, // (72) H + 0b00000110, // (73) I + 0b00011111, // (74) J + 0b01101001, // (75) K + 0b00111000, // (76) L + 0b00010101, // (77) M + 0b00110111, // (78) N + 0b00111111, // (79) O + 0b01110011, // (80) P + 0b01100111, // (81) Q + 0b00110001, // (82) R + 0b01101101, // (83) S + 0b01111000, // (84) T + 0b00111110, // (85) U + 0b00101010, // (86) V + 0b00011101, // (87) W + 0b01110110, // (88) X + 0b01101110, // (89) Y + 0b01011011, // (90) Z + 0b00111001, // (91) [ + 0b01100100, // (92) \ (this can't be the last char on a line, even in comment or it'll concat) + 0b00001111, // (93) ] + 0b00000000, // (94) ^ + 0b00001000, // (95) _ + 0b00100000, // (96) ` + 0b01011111, // (97) a + 0b01111100, // (98) b + 0b01011000, // (99) c + 0b01011110, // (100) d + 0b01111011, // (101) e + 0b00110001, // (102) f + 0b01101111, // (103) g + 0b01110100, // (104) h + 0b00000100, // (105) i + 0b00001110, // (106) j + 0b01110101, // (107) k + 0b00110000, // (108) l + 0b01010101, // (109) m + 0b01010100, // (110) n + 0b01011100, // (111) o + 0b01110011, // (112) p + 0b01100111, // (113) q + 0b01010000, // (114) r + 0b01101101, // (115) s + 0b01111000, // (116) t + 0b00011100, // (117) u + 0b00101010, // (118) v + 0b00011101, // (119) w + 0b01110110, // (120) x + 0b01101110, // (121) y + 0b01000111, // (122) z + 0b01000110, // (123) { + 0b00000110, // (124) | + 0b01110000, // (125) } + 0b00000001, // (126) ~ +}; +``` \ No newline at end of file diff --git a/setLED.md b/setLED.md new file mode 100644 index 0000000..3b3520b --- /dev/null +++ b/setLED.md @@ -0,0 +1,32 @@ +# setLED Reference (TM1638) # + +Controls a LED. + +``` +void setLED(byte color, byte pos); +``` + +| Argument | Detail | Default | +|:---------|:-------|:--------| +| color | The color of the LED. Can be set to _TM1638\_COLOR\_RED_ (for red), _TM1638\_COLOR\_GREEN_ (for green) or both. Can be set to TM1638\_COLOR\_NONE to clear the LED. | _required_ | +| pos | The LED to set. 0 for the leftmost, 7 for the rightmost | _required_ | + +# Example # + +Sets the leftmost LED to green: +``` +module1.setLED(TM1638_COLOR_GREEN, 0); +``` + + +Sets the leftmost LED to green **and** red: +``` +module1.setLED(TM1638_COLOR_GREEN + TM1638_COLOR_RED, 0); +``` + + + +Clears the leftmost LED: +``` +module1.setLED(TM1638_COLOR_NONE, 0); +``` \ No newline at end of file diff --git a/setLEDs.md b/setLEDs.md new file mode 100644 index 0000000..322a5e4 --- /dev/null +++ b/setLEDs.md @@ -0,0 +1,28 @@ +# setLEDs Reference (TM1638) # + +Set all the LEDs. + +``` +void setLEDs(word led); +``` + +| Argument | Detail | Default | +|:---------|:-------|:--------| +| led | The LEDs to set. MSB byte for the green LEDs, LSB for the red LEDs. | _required_ | + +# Example # + +Light up all the red LEDs. +``` +module1.setLEDs(0x00FF); +``` + +Light up all the green LEDs. +``` +module1.setLEDs(0xFF00); +``` + +Light up all the LEDs. +``` +module1.setLEDs(0xFFFF); +``` \ No newline at end of file diff --git a/setupDisplay.md b/setupDisplay.md new file mode 100644 index 0000000..a994d2c --- /dev/null +++ b/setupDisplay.md @@ -0,0 +1,25 @@ +# setupDisplay Reference (TM1638/TM1640) # + +Set the display (all 7-segments) and LEDs on or off and the specifies the intensity. + +``` +void setupDisplay(boolean active, byte intensity); +``` + +| Argument | Detail | Default | +|:---------|:-------|:--------| +| active | _true_ for on, _false_ for off | _required_ | +| intensity | The starting intensity from 0 (lowest) to 7 (highest) | _required_ | + +# Example # + +Activate display at maximum intensity: +``` +module1.setupDisplay(true, 7); +``` + + +Inactivate the display and set the intensity to the lowest: +``` +module1.setupDisplay(false, 0); +``` \ No newline at end of file