From f16965948efb15869e9ea1422d6fc53a9183a496 Mon Sep 17 00:00:00 2001 From: jimblom Date: Fri, 24 Apr 2015 16:25:42 -0600 Subject: [PATCH 01/14] Revising structure to match 1.6 standard. --- Libraries/README.md | 3 --- Libraries/SevSeg/keywords.txt | 3 --- .../Bubble_Display_Counter.ino | 0 .../Bubble_Display_SHT15/Bubble_Display_SHT15.ino | 0 .../Bubble_Display_Text/Bubble_Display_Text.ino | 0 {Libraries/SevSeg/Example => examples}/Example.jpg | Bin .../SevSeg_Counter/SevSeg_Counter.ino | 0 keywords.txt | 5 +++++ library.properties | 9 +++++++++ {Libraries/SevSeg => src}/SevSeg.cpp | 0 {Libraries/SevSeg => src}/SevSeg.h | 0 11 files changed, 14 insertions(+), 6 deletions(-) delete mode 100644 Libraries/README.md delete mode 100644 Libraries/SevSeg/keywords.txt rename {Libraries/SevSeg/Example => examples}/Bubble_Display_Counter/Bubble_Display_Counter.ino (100%) rename {Libraries/SevSeg/Example => examples}/Bubble_Display_SHT15/Bubble_Display_SHT15.ino (100%) rename {Libraries/SevSeg/Example => examples}/Bubble_Display_Text/Bubble_Display_Text.ino (100%) rename {Libraries/SevSeg/Example => examples}/Example.jpg (100%) rename {Libraries/SevSeg/Example => examples}/SevSeg_Counter/SevSeg_Counter.ino (100%) create mode 100644 keywords.txt create mode 100644 library.properties rename {Libraries/SevSeg => src}/SevSeg.cpp (100%) rename {Libraries/SevSeg => src}/SevSeg.h (100%) diff --git a/Libraries/README.md b/Libraries/README.md deleted file mode 100644 index 30967d0..0000000 --- a/Libraries/README.md +++ /dev/null @@ -1,3 +0,0 @@ -This includes the Arduino library SevSeg. This was developed in Arduino v 1.0, so you will need that version or newer to run the program. - -To add this to your Arduino libraries, please follow the instructions [here](http://arduino.cc/en/Guide/Libraries). \ No newline at end of file diff --git a/Libraries/SevSeg/keywords.txt b/Libraries/SevSeg/keywords.txt deleted file mode 100644 index 21ff6f8..0000000 --- a/Libraries/SevSeg/keywords.txt +++ /dev/null @@ -1,3 +0,0 @@ -SevSeg KEYWORD1 -NewNum KEYWORD2 -PrintOutput KEYWORD2 \ No newline at end of file diff --git a/Libraries/SevSeg/Example/Bubble_Display_Counter/Bubble_Display_Counter.ino b/examples/Bubble_Display_Counter/Bubble_Display_Counter.ino similarity index 100% rename from Libraries/SevSeg/Example/Bubble_Display_Counter/Bubble_Display_Counter.ino rename to examples/Bubble_Display_Counter/Bubble_Display_Counter.ino diff --git a/Libraries/SevSeg/Example/Bubble_Display_SHT15/Bubble_Display_SHT15.ino b/examples/Bubble_Display_SHT15/Bubble_Display_SHT15.ino similarity index 100% rename from Libraries/SevSeg/Example/Bubble_Display_SHT15/Bubble_Display_SHT15.ino rename to examples/Bubble_Display_SHT15/Bubble_Display_SHT15.ino diff --git a/Libraries/SevSeg/Example/Bubble_Display_Text/Bubble_Display_Text.ino b/examples/Bubble_Display_Text/Bubble_Display_Text.ino similarity index 100% rename from Libraries/SevSeg/Example/Bubble_Display_Text/Bubble_Display_Text.ino rename to examples/Bubble_Display_Text/Bubble_Display_Text.ino diff --git a/Libraries/SevSeg/Example/Example.jpg b/examples/Example.jpg similarity index 100% rename from Libraries/SevSeg/Example/Example.jpg rename to examples/Example.jpg diff --git a/Libraries/SevSeg/Example/SevSeg_Counter/SevSeg_Counter.ino b/examples/SevSeg_Counter/SevSeg_Counter.ino similarity index 100% rename from Libraries/SevSeg/Example/SevSeg_Counter/SevSeg_Counter.ino rename to examples/SevSeg_Counter/SevSeg_Counter.ino diff --git a/keywords.txt b/keywords.txt new file mode 100644 index 0000000..eed4ffb --- /dev/null +++ b/keywords.txt @@ -0,0 +1,5 @@ +SevSeg KEYWORD1 +NewNum KEYWORD2 +PrintOutput KEYWORD2 +COMMON_CATHODE LITERAL1 +COMMON_ANODE LITERAL1 \ No newline at end of file diff --git a/library.properties b/library.properties new file mode 100644 index 0000000..e842e4e --- /dev/null +++ b/library.properties @@ -0,0 +1,9 @@ +name=SevSeg +version=1.0.0 +author=SparkFun Electronics +maintainer=SparkFun Electronics +sentence=Seven Segment library for Arduino +paragraph=Seven Segment library for Arduino +category=Display +url=https://github.com/sparkfun/SevSeg +architectures=* diff --git a/Libraries/SevSeg/SevSeg.cpp b/src/SevSeg.cpp similarity index 100% rename from Libraries/SevSeg/SevSeg.cpp rename to src/SevSeg.cpp diff --git a/Libraries/SevSeg/SevSeg.h b/src/SevSeg.h similarity index 100% rename from Libraries/SevSeg/SevSeg.h rename to src/SevSeg.h From 5f225898299c22d8614179848e0f768450801637 Mon Sep 17 00:00:00 2001 From: Valentin Funk Date: Sun, 14 Jun 2015 11:06:44 +0200 Subject: [PATCH 02/14] Fixes decimal point in example and improves the examples * Default example shows no decimal point although the comment mentions one, fix it and adds one at the third position * Adds a hint to the usage of decimal point argument (binary number) * Improves the other examples for more variety --- examples/Bubble_Display_Counter/Bubble_Display_Counter.ino | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/examples/Bubble_Display_Counter/Bubble_Display_Counter.ino b/examples/Bubble_Display_Counter/Bubble_Display_Counter.ino index 5c8cc90..89569f2 100644 --- a/examples/Bubble_Display_Counter/Bubble_Display_Counter.ino +++ b/examples/Bubble_Display_Counter/Bubble_Display_Counter.ino @@ -79,11 +79,12 @@ void loop() //sprintf(tempString, "%4X", deciSecond); //Count in HEX, right adjusted //Produce an output on the display - myDisplay.DisplayString(tempString, 0); //(numberToDisplay, decimal point location) + myDisplay.DisplayString(tempString, 4); //(numberToDisplay, decimal point location in binary number [4 means the third digit]) //Other examples //myDisplay.DisplayString(tempString, 0); //Display string, no decimal point - //myDisplay.DisplayString("-23b", 3); //Display string, decimal point in third position + //myDisplay.DisplayString("-235", 2); //Display string, decimal point in second position + //myDisplay.DisplayString("8888", 15); //Everything on! //Check if 10ms has elapsed if (millis() - timer >= 100) From 5ea151149423c1e9aa79886d1a1eba574d64e0ab Mon Sep 17 00:00:00 2001 From: Toni Klopfenstein Date: Thu, 3 Dec 2015 15:59:10 -0700 Subject: [PATCH 03/14] Update README.md Adding documentation links. --- README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 7f38e73..526cd70 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,13 @@ Connect the four digit pins with four limiting resistors in series to any digita Repository Contents ------------------- -* **/Libraries** - All Arduino libraries and board examples +* **/examples** - Arduino example sketches +* **/src** - Source files for Arduino library + +Documentation +-------------- +* **[Hookup Guide](https://learn.sparkfun.com/tutorials/using-the-serial-7-segment-display)** - Basic hookup guide for the Serial Segment Displays. +* **[Compatible Displays](https://www.sparkfun.com/wish_lists/120699)** - Products that work with this code. License Information ------------------- From b9e1ac113256e04e32d9aba1c422b3fff9332c1d Mon Sep 17 00:00:00 2001 From: Olivier Cornu Date: Fri, 30 Sep 2016 22:19:12 +0200 Subject: [PATCH 04/14] Include 7-segment map in comment. --- src/SevSeg.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/SevSeg.h b/src/SevSeg.h index c162f53..ed7f9ab 100644 --- a/src/SevSeg.h +++ b/src/SevSeg.h @@ -37,14 +37,14 @@ //This is the combined array that contains all the segment configurations for many different characters and symbols const uint8_t characterArray[] PROGMEM = { -// ABCDEFG Segments - 0b1111110, // 0 - 0b0110000, // 1 - 0b1101101, // 2 - 0b1111001, // 3 - 0b0110011, // 4 - 0b1011011, // 5 - 0b1011111, // 6 +// ABCDEFG Segments 7-segment map: + 0b1111110, // 0 AAA + 0b0110000, // 1 F B + 0b1101101, // 2 F B + 0b1111001, // 3 GGG + 0b0110011, // 4 E C + 0b1011011, // 5 E C + 0b1011111, // 6 DDD 0b1110000, // 7 0b1111111, // 8 0b1111011, // 9 From 73b2dc7d5f834aa799fc9de1fef178f20fa3e44b Mon Sep 17 00:00:00 2001 From: Olivier Cornu Date: Fri, 30 Sep 2016 22:51:33 +0200 Subject: [PATCH 05/14] More faithfull representation of the character displayed on the LCD. --- src/SevSeg.h | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/SevSeg.h b/src/SevSeg.h index ed7f9ab..ca9db83 100644 --- a/src/SevSeg.h +++ b/src/SevSeg.h @@ -49,9 +49,9 @@ const uint8_t characterArray[] PROGMEM = { 0b1111111, // 8 0b1111011, // 9 0b1110111, // 10 "A" - 0b0011111, // 11 "B" + 0b0011111, // 11 "b" 0b1001110, // 12 "C" - 0b0111101, // 13 "D" + 0b0111101, // 13 "d" 0b1001111, // 14 "E" 0b1000111, // 15 "F" 0b0000000, // 16 NO DISPLAY @@ -104,9 +104,9 @@ const uint8_t characterArray[] PROGMEM = { 0b0000000, // 63 '?' NO DISPLAY 0b0000000, // 64 '@' NO DISPLAY 0b1110111, // 65 'A' - 0b0011111, // 66 'B' + 0b0011111, // 66 'b' 0b1001110, // 67 'C' - 0b0111101, // 68 'D' + 0b0111101, // 68 'd' 0b1001111, // 69 'E' 0b1000111, // 70 'F' 0b1011110, // 71 'G' @@ -116,18 +116,18 @@ const uint8_t characterArray[] PROGMEM = { 0b0000000, // 75 'K' NO DISPLAY 0b0001110, // 76 'L' 0b0000000, // 77 'M' NO DISPLAY - 0b0010101, // 78 'N' + 0b0010101, // 78 'n' 0b1111110, // 79 'O' 0b1100111, // 80 'P' - 0b1110011, // 81 'Q' - 0b0000101, // 82 'R' + 0b1110011, // 81 'q' + 0b0000101, // 82 'r' 0b1011011, // 83 'S' - 0b0001111, // 84 'T' + 0b0001111, // 84 't' 0b0111110, // 85 'U' 0b0000000, // 86 'V' NO DISPLAY 0b0000000, // 87 'W' NO DISPLAY 0b0000000, // 88 'X' NO DISPLAY - 0b0111011, // 89 'Y' + 0b0111011, // 89 'y' 0b0000000, // 90 'Z' NO DISPLAY 0b1001110, // 91 '[' 0b0000000, // 92 '\' NO DISPLAY @@ -140,8 +140,8 @@ const uint8_t characterArray[] PROGMEM = { 0b0001101, // 99 'c' 0b0111101, // 100 'd' SAME AS CAP 0b1101111, // 101 'e' - 0b1000111, // 102 'f' SAME AS CAP - 0b1011110, // 103 'g' SAME AS CAP + 0b1000111, // 102 'F' SAME AS CAP + 0b1011110, // 103 'G' SAME AS CAP 0b0010111, // 104 'h' 0b0010000, // 105 'i' 0b0111000, // 106 'j' SAME AS CAP @@ -153,7 +153,7 @@ const uint8_t characterArray[] PROGMEM = { 0b1100111, // 112 'p' SAME AS CAP 0b1110011, // 113 'q' SAME AS CAP 0b0000101, // 114 'r' SAME AS CAP - 0b1011011, // 115 's' SAME AS CAP + 0b1011011, // 115 'S' SAME AS CAP 0b0001111, // 116 't' SAME AS CAP 0b0011100, // 117 'u' 0b0000000, // 118 'b' NO DISPLAY From 75c9221204bca3ca7266c20b2f27e42621e48fa0 Mon Sep 17 00:00:00 2001 From: Olivier Cornu Date: Fri, 30 Sep 2016 22:58:41 +0200 Subject: [PATCH 06/14] Nicer characterArray comments. Align columns. --- src/SevSeg.h | 136 +++++++++++++++++++++++++-------------------------- 1 file changed, 68 insertions(+), 68 deletions(-) diff --git a/src/SevSeg.h b/src/SevSeg.h index ca9db83..d90cda4 100644 --- a/src/SevSeg.h +++ b/src/SevSeg.h @@ -70,74 +70,74 @@ const uint8_t characterArray[] PROGMEM = { 0b0000000, // 29 NO DISPLAY 0b0000000, // 30 NO DISPLAY 0b0000000, // 31 NO DISPLAY - 0b0000000, // 32 ' ' - 0b0000000, // 33 '!' NO DISPLAY - 0b0100010, // 34 '"' - 0b0000000, // 35 '#' NO DISPLAY - 0b0000000, // 36 '$' NO DISPLAY - 0b0000000, // 37 '%' NO DISPLAY - 0b0000000, // 38 '&' NO DISPLAY - 0b0100000, // 39 ''' - 0b1001110, // 40 '(' - 0b1111000, // 41 ')' - 0b0000000, // 42 '*' NO DISPLAY - 0b0000000, // 43 '+' NO DISPLAY - 0b0000100, // 44 ',' - 0b0000001, // 45 '-' - 0b0000000, // 46 '.' NO DISPLAY - 0b0000000, // 47 '/' NO DISPLAY - 0b1111110, // 48 '0' - 0b0110000, // 49 '1' - 0b1101101, // 50 '2' - 0b1111001, // 51 '3' - 0b0110011, // 52 '4' - 0b1011011, // 53 '5' - 0b1011111, // 54 '6' - 0b1110000, // 55 '7' - 0b1111111, // 56 '8' - 0b1111011, // 57 '9' - 0b0000000, // 58 ':' NO DISPLAY - 0b0000000, // 59 ';' NO DISPLAY - 0b0000000, // 60 '<' NO DISPLAY - 0b0000000, // 61 '=' NO DISPLAY - 0b0000000, // 62 '>' NO DISPLAY - 0b0000000, // 63 '?' NO DISPLAY - 0b0000000, // 64 '@' NO DISPLAY - 0b1110111, // 65 'A' - 0b0011111, // 66 'b' - 0b1001110, // 67 'C' - 0b0111101, // 68 'd' - 0b1001111, // 69 'E' - 0b1000111, // 70 'F' - 0b1011110, // 71 'G' - 0b0110111, // 72 'H' - 0b0110000, // 73 'I' - 0b0111000, // 74 'J' - 0b0000000, // 75 'K' NO DISPLAY - 0b0001110, // 76 'L' - 0b0000000, // 77 'M' NO DISPLAY - 0b0010101, // 78 'n' - 0b1111110, // 79 'O' - 0b1100111, // 80 'P' - 0b1110011, // 81 'q' - 0b0000101, // 82 'r' - 0b1011011, // 83 'S' - 0b0001111, // 84 't' - 0b0111110, // 85 'U' - 0b0000000, // 86 'V' NO DISPLAY - 0b0000000, // 87 'W' NO DISPLAY - 0b0000000, // 88 'X' NO DISPLAY - 0b0111011, // 89 'y' - 0b0000000, // 90 'Z' NO DISPLAY - 0b1001110, // 91 '[' - 0b0000000, // 92 '\' NO DISPLAY - 0b1111000, // 93 ']' - 0b0000000, // 94 '^' NO DISPLAY - 0b0001000, // 95 '_' - 0b0000010, // 96 '`' - 0b1110111, // 97 'a' SAME AS CAP - 0b0011111, // 98 'b' SAME AS CAP - 0b0001101, // 99 'c' + 0b0000000, // 32 ' ' + 0b0000000, // 33 '!' NO DISPLAY + 0b0100010, // 34 '"' + 0b0000000, // 35 '#' NO DISPLAY + 0b0000000, // 36 '$' NO DISPLAY + 0b0000000, // 37 '%' NO DISPLAY + 0b0000000, // 38 '&' NO DISPLAY + 0b0100000, // 39 ''' + 0b1001110, // 40 '(' + 0b1111000, // 41 ')' + 0b0000000, // 42 '*' NO DISPLAY + 0b0000000, // 43 '+' NO DISPLAY + 0b0000100, // 44 ',' + 0b0000001, // 45 '-' + 0b0000000, // 46 '.' NO DISPLAY + 0b0000000, // 47 '/' NO DISPLAY + 0b1111110, // 48 '0' + 0b0110000, // 49 '1' + 0b1101101, // 50 '2' + 0b1111001, // 51 '3' + 0b0110011, // 52 '4' + 0b1011011, // 53 '5' + 0b1011111, // 54 '6' + 0b1110000, // 55 '7' + 0b1111111, // 56 '8' + 0b1111011, // 57 '9' + 0b0000000, // 58 ':' NO DISPLAY + 0b0000000, // 59 ';' NO DISPLAY + 0b0000000, // 60 '<' NO DISPLAY + 0b0000000, // 61 '=' NO DISPLAY + 0b0000000, // 62 '>' NO DISPLAY + 0b0000000, // 63 '?' NO DISPLAY + 0b0000000, // 64 '@' NO DISPLAY + 0b1110111, // 65 'A' + 0b0011111, // 66 'b' + 0b1001110, // 67 'C' + 0b0111101, // 68 'd' + 0b1001111, // 69 'E' + 0b1000111, // 70 'F' + 0b1011110, // 71 'G' + 0b0110111, // 72 'H' + 0b0110000, // 73 'I' + 0b0111000, // 74 'J' + 0b0000000, // 75 'K' NO DISPLAY + 0b0001110, // 76 'L' + 0b0000000, // 77 'M' NO DISPLAY + 0b0010101, // 78 'n' + 0b1111110, // 79 'O' + 0b1100111, // 80 'P' + 0b1110011, // 81 'q' + 0b0000101, // 82 'r' + 0b1011011, // 83 'S' + 0b0001111, // 84 't' + 0b0111110, // 85 'U' + 0b0000000, // 86 'V' NO DISPLAY + 0b0000000, // 87 'W' NO DISPLAY + 0b0000000, // 88 'X' NO DISPLAY + 0b0111011, // 89 'y' + 0b0000000, // 90 'Z' NO DISPLAY + 0b1001110, // 91 '[' + 0b0000000, // 92 '\' NO DISPLAY + 0b1111000, // 93 ']' + 0b0000000, // 94 '^' NO DISPLAY + 0b0001000, // 95 '_' + 0b0000010, // 96 '`' + 0b1110111, // 97 'a' SAME AS CAP + 0b0011111, // 98 'b' SAME AS CAP + 0b0001101, // 99 'c' 0b0111101, // 100 'd' SAME AS CAP 0b1101111, // 101 'e' 0b1000111, // 102 'F' SAME AS CAP From ef4ef310d9dbfca94873836e91e81f77db2aab85 Mon Sep 17 00:00:00 2001 From: Olivier Cornu Date: Fri, 30 Sep 2016 22:59:02 +0200 Subject: [PATCH 07/14] Nicer characterArray comments. Streamline format (add first numeric characters). --- src/SevSeg.h | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/SevSeg.h b/src/SevSeg.h index d90cda4..8525727 100644 --- a/src/SevSeg.h +++ b/src/SevSeg.h @@ -38,16 +38,16 @@ //This is the combined array that contains all the segment configurations for many different characters and symbols const uint8_t characterArray[] PROGMEM = { // ABCDEFG Segments 7-segment map: - 0b1111110, // 0 AAA - 0b0110000, // 1 F B - 0b1101101, // 2 F B - 0b1111001, // 3 GGG - 0b0110011, // 4 E C - 0b1011011, // 5 E C - 0b1011111, // 6 DDD - 0b1110000, // 7 - 0b1111111, // 8 - 0b1111011, // 9 + 0b1111110, // 0 "0" AAA + 0b0110000, // 1 "1" F B + 0b1101101, // 2 "2" F B + 0b1111001, // 3 "3" GGG + 0b0110011, // 4 "4" E C + 0b1011011, // 5 "5" E C + 0b1011111, // 6 "6" DDD + 0b1110000, // 7 "7" + 0b1111111, // 8 "8" + 0b1111011, // 9 "9" 0b1110111, // 10 "A" 0b0011111, // 11 "b" 0b1001110, // 12 "C" From d36435e06418407393504483be35dbc237a467c4 Mon Sep 17 00:00:00 2001 From: Olivier Cornu Date: Fri, 30 Sep 2016 23:01:49 +0200 Subject: [PATCH 08/14] Remove unecessary comment. --- src/SevSeg.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/SevSeg.h b/src/SevSeg.h index 8525727..e3b10d3 100644 --- a/src/SevSeg.h +++ b/src/SevSeg.h @@ -26,7 +26,6 @@ // framePeriod controls the length of time between display refreshes // It's also closely linked to the brightness setting #define FRAMEPERIOD 2000 -//#define FRAMEPERIOD 2000 //Total amount of time (in microseconds) for the display frame. 1,000us is roughly 1000Hz update rate //A framePeriod of: //5000 is flickery From afc5cd646e156613beed3c13363089c6a36d23a1 Mon Sep 17 00:00:00 2001 From: Olivier Cornu Date: Fri, 30 Sep 2016 23:02:41 +0200 Subject: [PATCH 09/14] Remove segment map (better one available below). --- src/SevSeg.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/SevSeg.h b/src/SevSeg.h index e3b10d3..153008d 100644 --- a/src/SevSeg.h +++ b/src/SevSeg.h @@ -1,12 +1,6 @@ //Written by Dean Reading, 2012. deanreading@hotmail.com //See .cpp file for info -// - A -// F | | B -// _ G -// E | | C -// _ D - #ifndef SevSeg_h #define SevSeg_h From 447fb23fcda9b78a37540519391ce11ff176c9e6 Mon Sep 17 00:00:00 2001 From: Olivier Cornu Date: Fri, 30 Sep 2016 23:28:17 +0200 Subject: [PATCH 10/14] Factorize PROGMEM reads in a local var. --- src/SevSeg.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/SevSeg.cpp b/src/SevSeg.cpp index c34cd0b..51cfa2c 100644 --- a/src/SevSeg.cpp +++ b/src/SevSeg.cpp @@ -225,13 +225,14 @@ void SevSeg::DisplayString(char* toDisplay, byte DecAposColon) } else { - if (pgm_read_byte(&characterArray[characterToDisplay]) & (1<<6)) digitalWrite(segmentA, SegOn); - if (pgm_read_byte(&characterArray[characterToDisplay]) & (1<<5)) digitalWrite(segmentB, SegOn); - if (pgm_read_byte(&characterArray[characterToDisplay]) & (1<<4)) digitalWrite(segmentC, SegOn); - if (pgm_read_byte(&characterArray[characterToDisplay]) & (1<<3)) digitalWrite(segmentD, SegOn); - if (pgm_read_byte(&characterArray[characterToDisplay]) & (1<<2)) digitalWrite(segmentE, SegOn); - if (pgm_read_byte(&characterArray[characterToDisplay]) & (1<<1)) digitalWrite(segmentF, SegOn); - if (pgm_read_byte(&characterArray[characterToDisplay]) & (1<<0)) digitalWrite(segmentG, SegOn); + const uint8_t chr = pgm_read_byte(&characterArray[characterToDisplay]); + if (chr & (1<<6)) digitalWrite(segmentA, SegOn); + if (chr & (1<<5)) digitalWrite(segmentB, SegOn); + if (chr & (1<<4)) digitalWrite(segmentC, SegOn); + if (chr & (1<<3)) digitalWrite(segmentD, SegOn); + if (chr & (1<<2)) digitalWrite(segmentE, SegOn); + if (chr & (1<<1)) digitalWrite(segmentF, SegOn); + if (chr & (1<<0)) digitalWrite(segmentG, SegOn); } //Service the decimal point, apostrophe and colon if ((DecAposColon & (1<<(digit-1))) && (digit < 5)) //Test DecAposColon to see if we need to turn on a decimal point From a1e00db3505baeb4e55bb0376904f365f7eda347 Mon Sep 17 00:00:00 2001 From: Brent Wilkins Date: Mon, 13 Feb 2017 13:55:23 -0700 Subject: [PATCH 11/14] Incremented verion number for Arduino library --- library.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library.properties b/library.properties index e842e4e..07284c3 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=SevSeg -version=1.0.0 +version=1.0.1 author=SparkFun Electronics maintainer=SparkFun Electronics sentence=Seven Segment library for Arduino From 9d7a9b724bc4294a0296a4304aacb79e237ae70d Mon Sep 17 00:00:00 2001 From: Brent Wilkins Date: Mon, 13 Feb 2017 13:57:47 -0700 Subject: [PATCH 12/14] Incremented verion number for Arduino library --- library.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library.properties b/library.properties index 07284c3..47c3b78 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=SevSeg -version=1.0.1 +version=1.0.2 author=SparkFun Electronics maintainer=SparkFun Electronics sentence=Seven Segment library for Arduino From 3a0425e20e69a8732ddfb9d68d1f1ba0a5045d01 Mon Sep 17 00:00:00 2001 From: Brent Wilkins Date: Mon, 13 Feb 2017 14:18:17 -0700 Subject: [PATCH 13/14] Changed type of characterToDisplay to unsigned since it's used to index an array --- src/SevSeg.cpp | 70 +++++++++++++++++++++++++------------------------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/src/SevSeg.cpp b/src/SevSeg.cpp index 51cfa2c..f6cdb02 100644 --- a/src/SevSeg.cpp +++ b/src/SevSeg.cpp @@ -1,5 +1,5 @@ /* - This library allows an Arduino to easily display numbers and characters on a 4 digit 7-segment + This library allows an Arduino to easily display numbers and characters on a 4 digit 7-segment display without a separate 7-segment display controller. If you have feature suggestions or need support please use the github support page: https://github.com/sparkfun/SevSeg @@ -7,23 +7,23 @@ Original Library by Dean Reading (deanreading@hotmail.com: http://arduino.cc/playground/Main/SevenSegmentLibrary), 2012 Improvements by Nathan Seidle, 2012 - Now works for any digital pin arrangement, common anode and common cathode displays. + Now works for any digital pin arrangement, common anode and common cathode displays. Added character support including letters A-F and many symbols. - Hardware Setup: 4 digit 7 segment displays use 12 digital pins. You may need more pins if your display has colons or + Hardware Setup: 4 digit 7 segment displays use 12 digital pins. You may need more pins if your display has colons or apostrophes. - There are 4 digit pins and 8 segment pins. Digit pins are connected to the cathodes for common cathode displays, or anodes - for common anode displays. 8 pins control the individual segments (seven segments plus the decimal point). + There are 4 digit pins and 8 segment pins. Digit pins are connected to the cathodes for common cathode displays, or anodes + for common anode displays. 8 pins control the individual segments (seven segments plus the decimal point). - Connect the four digit pins with four limiting resistors in series to any digital or analog pins. Connect the eight segment + Connect the four digit pins with four limiting resistors in series to any digital or analog pins. Connect the eight segment pins to any digital or analog pins (no limiting resistors needed). See the SevSeg example for more connection information. - + SparkFun has a large, 1" 7-segment display that has four digits. https://www.sparkfun.com/products/11408 - Looking at the display like this: 8.8.8.8. pin 1 is on the lower row, starting from the left. + Looking at the display like this: 8.8.8.8. pin 1 is on the lower row, starting from the left. Pin 12 is the top row, upper left pin. - + Pinout: 1: Segment E 2: Segment D @@ -40,23 +40,23 @@ Software: - Call SevSeg.Begin in setup. + Call SevSeg.Begin in setup. The first argument (boolean) tells whether the display is common cathode (0) or common anode (1). The next four arguments (bytes) tell the library which arduino pins are connected to the digit pins of the seven segment display. Put them in order from left to right. The next eight arguments (bytes) tell the library which arduino pins are connected to the segment pins of the seven segment display. Put them in order a to g then the dp. - + In summary, Begin(type, digit pins 1-4, segment pins a-g, dp) - + The calling program must run the DisplayString() function repeatedly to get the number displayed. - Any number between -999 and 9999 can be displayed. + Any number between -999 and 9999 can be displayed. To move the decimal place one digit to the left, use '1' as the second - argument. For example, if you wanted to display '3.141' you would call + argument. For example, if you wanted to display '3.141' you would call myDisplay.DisplayString("3141", 1); - + */ #include "SevSeg.h" @@ -67,11 +67,11 @@ SevSeg::SevSeg() DecAposColon = 0; //This variable tracks the decimal place, apostrophe, and colon (if the display has support) } -void SevSeg::Begin(boolean mode_in, byte numOfDigits, - byte dig1, byte dig2, byte dig3, byte dig4, +void SevSeg::Begin(boolean mode_in, byte numOfDigits, + byte dig1, byte dig2, byte dig3, byte dig4, byte digitCol, byte digitApos, - byte segA, byte segB, byte segC, byte segD, byte segE, byte segF, byte segG, - byte segDP, + byte segA, byte segB, byte segC, byte segD, byte segE, byte segF, byte segG, + byte segDP, byte segCol, byte segApos) { //Bring all the variables in from the caller @@ -92,7 +92,7 @@ void SevSeg::Begin(boolean mode_in, byte numOfDigits, segmentDP = segDP; segmentApostrophe = segApos; segmentColon = segCol; - + //Assign input values to variables //mode is what the digit pins must be set at for it to be turned on. 0 for common cathode, 1 for common anode mode = mode_in; @@ -103,7 +103,7 @@ void SevSeg::Begin(boolean mode_in, byte numOfDigits, SegOn = LOW; SegOff = HIGH; } - else + else { DigitOn = LOW; DigitOff = HIGH; @@ -126,13 +126,13 @@ void SevSeg::Begin(boolean mode_in, byte numOfDigits, //Turn everything Off before setting pin as output //Set all digit pins off. Low for common anode, high for common cathode - for (byte digit = 0 ; digit < numberOfDigits ; digit++) + for (byte digit = 0 ; digit < numberOfDigits ; digit++) { digitalWrite(DigitPins[digit], DigitOff); pinMode(DigitPins[digit], OUTPUT); } //Set all segment pins off. High for common anode, low for common cathode - for (byte seg = 0 ; seg < 8 ; seg++) + for (byte seg = 0 ; seg < 8 ; seg++) { digitalWrite(SegmentPins[seg], SegOff); pinMode(SegmentPins[seg], OUTPUT); @@ -159,9 +159,9 @@ void SevSeg::Begin(boolean mode_in, byte numOfDigits, //Set pin modes and turns all displays off //This second begin is used when the display does not support a colon and apostrophe //The digitApostrophe, segmentApostrophe, and dig/segColon are set to 255 and the normal .Begin is called -void SevSeg::Begin(boolean mode_in, byte numOfDigits, - byte dig1, byte dig2, byte dig3, byte dig4, - byte segA, byte segB, byte segC, byte segD, byte segE, byte segF, byte segG, +void SevSeg::Begin(boolean mode_in, byte numOfDigits, + byte dig1, byte dig2, byte dig3, byte dig4, + byte segA, byte segB, byte segC, byte segD, byte segE, byte segF, byte segG, byte segDP) { Begin(mode_in, numOfDigits, dig1, dig2, dig3, dig4, 255, 255, segA, segB, segC, @@ -189,9 +189,9 @@ void SevSeg::SetBrightness(byte percentBright) void SevSeg::DisplayString(char* toDisplay, byte DecAposColon) { //For the purpose of this code, digit = 1 is the left most digit, digit = 4 is the right most digit - for(byte digit = 1 ; digit < (numberOfDigits+1) ; digit++) + for(byte digit = 1 ; digit < (numberOfDigits+1) ; digit++) { - switch(digit) + switch(digit) { case 1: digitalWrite(digit1, DigitOn); @@ -212,7 +212,7 @@ void SevSeg::DisplayString(char* toDisplay, byte DecAposColon) //This could be cleaned up a bit but it works //displayCharacter(toDisplay[digit-1]); //Now display this digit // displayArray (defined in SevSeg.h) decides which segments are turned on for each number or symbol - char characterToDisplay = toDisplay[digit-1]; + unsigned char characterToDisplay = toDisplay[digit-1]; if (characterToDisplay & 0x80) // bit 7 enables bit-per-segment control { // Each bit of characterToDisplay turns on a single segment (from A-to-G) if (characterToDisplay & 0x01) digitalWrite(segmentA, SegOn); @@ -237,7 +237,7 @@ void SevSeg::DisplayString(char* toDisplay, byte DecAposColon) //Service the decimal point, apostrophe and colon if ((DecAposColon & (1<<(digit-1))) && (digit < 5)) //Test DecAposColon to see if we need to turn on a decimal point digitalWrite(segmentDP, SegOn); - + delayMicroseconds(brightnessDelay + 1); //Display this digit for a fraction of a second (between 1us and 5000us, 500-2000 is pretty good) //The + 1 is a bit of a hack but it removes the possible zero display (0 causes display to become bright and flickery) //If you set this too long, the display will start to flicker. Set it to 25000 for some fun. @@ -253,7 +253,7 @@ void SevSeg::DisplayString(char* toDisplay, byte DecAposColon) digitalWrite(segmentDP, SegOff); //Turn off this digit - switch(digit) + switch(digit) { case 1: digitalWrite(digit1, DigitOff); @@ -270,11 +270,11 @@ void SevSeg::DisplayString(char* toDisplay, byte DecAposColon) //This only currently works for 4 digits } // The display is on for microSeconds(brightnessLevel + 1), now turn off for the remainder of the framePeriod - delayMicroseconds(FRAMEPERIOD - brightnessDelay + 1); //the +1 is a hack so that we can never have a delayMicroseconds(0), causes display to flicker + delayMicroseconds(FRAMEPERIOD - brightnessDelay + 1); //the +1 is a hack so that we can never have a delayMicroseconds(0), causes display to flicker } //After we've gone through the digits, we control the colon and apostrophe (if the display supports it) - + //Turn on the colon and/or apostrophe if ((digitColon != 255) || (digitApostrophe != 255)) { @@ -294,8 +294,8 @@ void SevSeg::DisplayString(char* toDisplay, byte DecAposColon) digitalWrite(digitColon, DigitOff); digitalWrite(segmentColon, SegOff); digitalWrite(digitApostrophe, DigitOff); - digitalWrite(segmentApostrophe, SegOff); + digitalWrite(segmentApostrophe, SegOff); delayMicroseconds(FRAMEPERIOD - brightnessDelay + 1); //the +1 is a hack so that we can never have a delayMicroseconds(0), causes display to flicker } - + } From aeb5fcd281cbf81d700f4232cc060736e6137b6a Mon Sep 17 00:00:00 2001 From: Brent Wilkins Date: Mon, 13 Feb 2017 15:56:23 -0700 Subject: [PATCH 14/14] Made c string parameter const to allow passing of string literal w/o warnings. Removed trailing whitespace --- src/SevSeg.cpp | 2 +- src/SevSeg.h | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/SevSeg.cpp b/src/SevSeg.cpp index f6cdb02..ae6286d 100644 --- a/src/SevSeg.cpp +++ b/src/SevSeg.cpp @@ -186,7 +186,7 @@ void SevSeg::SetBrightness(byte percentBright) //Each digit is displayed for ~2000us, and cycles through the 4 digits //After running through the 4 numbers, the display is turned off //Will turn the display on for a given amount of time - this helps control brightness -void SevSeg::DisplayString(char* toDisplay, byte DecAposColon) +void SevSeg::DisplayString(const char* toDisplay, byte DecAposColon) { //For the purpose of this code, digit = 1 is the left most digit, digit = 4 is the right most digit for(byte digit = 1 ; digit < (numberOfDigits+1) ; digit++) diff --git a/src/SevSeg.h b/src/SevSeg.h index 153008d..43093e9 100644 --- a/src/SevSeg.h +++ b/src/SevSeg.h @@ -19,7 +19,7 @@ // framePeriod controls the length of time between display refreshes // It's also closely linked to the brightness setting -#define FRAMEPERIOD 2000 +#define FRAMEPERIOD 2000 //Total amount of time (in microseconds) for the display frame. 1,000us is roughly 1000Hz update rate //A framePeriod of: //5000 is flickery @@ -168,8 +168,8 @@ class SevSeg { SevSeg(); //Public Functions - void DisplayString(char*, byte); -// void NewNumber(int number_in, byte DecPlace_in); + void DisplayString(const char*, byte); +// void NewNumber(int number_in, byte DecPlace_in); void Begin(boolean mode_in, byte numOfDigits, byte digit1, byte digit2, byte digit3, byte digit4, byte segment1, byte segment2, byte segment3, byte segment4, byte segment5, byte segment6, byte segment7, byte segmentDP); void Begin(boolean mode_in, byte numOfDigits, byte digit1, byte digit2, byte digit3, byte digit4, byte digitColon, byte digitApostrophe, byte segment1, byte segment2, byte segment3, byte segment4, byte segment5, byte segment6, byte segment7, byte segmentDP, byte segmentColon, byte segmentApostrophe); void SetBrightness(byte percentBright); @@ -187,9 +187,9 @@ class SevSeg { byte digit1, digit2, digit3, digit4; byte digitApostrophe, digitColon, segmentApostrophe, segmentColon; byte segmentA, segmentB, segmentC, segmentD, segmentE, segmentF, segmentG, segmentDP; - + byte numberOfDigits; - + unsigned int brightnessDelay; byte DigitPins[4]; pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy