Loading files
This file is pinned to the selected release. Download the original to open it in your design tool.
45bba471aThis file is pinned to the selected release. Download the original to open it in your design tool.
//Written by Dean Reading, 2012. deanreading@hotmail.com
//See .cpp file for info
#ifndef SevSeg_h
#define SevSeg_h
#if defined(ARDUINO) && ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif
#include <avr/pgmspace.h>
#define COMMON_CATHODE 0
#define COMMON_ANODE 1
#define BLANK 16 //Special character that turns off all segments (we chose 16 as it is the first spot that has this)
// framePeriod controls the length of time between display refreshes
// It's also closely linked to the brightness setting
#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
//3000 has good low brightness vs full brightness
//2000 works well
//500 seems like the low brightness is pretty bright, not great
//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 "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"
0b0111101, // 13 "d"
0b1001111, // 14 "E"
0b1000111, // 15 "F"
0b0000000, // 16 NO DISPLAY
0b0000000, // 17 NO DISPLAY
0b0000000, // 18 NO DISPLAY
0b0000000, // 19 NO DISPLAY
0b0000000, // 20 NO DISPLAY
0b0000000, // 21 NO DISPLAY
0b0000000, // 22 NO DISPLAY
0b0000000, // 23 NO DISPLAY
0b0000000, // 24 NO DISPLAY
0b0000000, // 25 NO DISPLAY
0b0000000, // 26 NO DISPLAY
0b0000000, // 27 NO DISPLAY
0b0000000, // 28 NO DISPLAY
0b0000000, // 29 NO DISPLAY
0b0000000, // 30 NO DISPLAY
0b0000000, // 31 NO DISPLAY
0b0000000, // 32 ' '
0b0000000, // 33 '!' NO DISPLAY
0b0100010, // 34 '"'
0b1010111, // 35 '#' S3 - 1
0b1110101, // 36 '$' S3 - 3
0b1111100, // 37 '%' S3 - 4
0b0000111, // 38 '&' S3 - 5
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'
0b0100001, // 58 ':' S4 - 1
0b0010010, // 59 ';' S4 - 2
0b1001000, // 60 '<' S4 - 3
0b0000110, // 61 '=' S4 - 4
0b1100001, // 62 '>' S4 - 5
0b0011011, // 63 '?' S6 - 2
0b1011110, // 64 '@' S7 - 2
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'
0b1000110, // 75 'K' S7 - 5
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
0b1011110, // 103 'G' SAME AS CAP
0b0010111, // 104 'h'
0b0010000, // 105 'i'
0b0111000, // 106 'j' SAME AS CAP
0b0000000, // 107 'k' NO DISPLAY
0b0110000, // 108 'l'
0b0000000, // 109 'm' NO DISPLAY
0b0010101, // 110 'n' SAME AS CAP
0b0011101, // 111 'o'
0b1100111, // 112 'p' SAME AS CAP
0b1110011, // 113 'q' SAME AS CAP
0b0000101, // 114 'r' SAME AS CAP
0b1011011, // 115 'S' SAME AS CAP
0b0001111, // 116 't' SAME AS CAP
0b0011100, // 117 'u'
0b0000000, // 118 'b' NO DISPLAY
0b0000000, // 119 'w' NO DISPLAY
0b0000000, // 120 'x' NO DISPLAY
0b0000000, // 121 'y' NO DISPLAY
0b0000000, // 122 'z' NO DISPLAY
0b0000000, // 123 '0b' NO DISPLAY
0b0000000, // 124 '|' NO DISPLAY
0b0000000, // 125 ',' NO DISPLAY
0b0000000, // 126 '~' NO DISPLAY
0b0000000, // 127 'DEL' NO DISPLAY
};
class SevSeg {
public:
SevSeg();
//Public Functions
void DisplayString(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 digit5, 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 digit5, 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);
//Public Variables
private:
//Private Functions
void displayCharacter(byte characterToDisplay); //Illuminates the correct segments
void SplitNumber(int);
//Private Variables
boolean mode, DigitOn, DigitOff, SegOn, SegOff;
byte digit1, digit2, digit3, digit4, digit5;
byte digitApostrophe, digitColon, segmentApostrophe, segmentColon;
byte segmentA, segmentB, segmentC, segmentD, segmentE, segmentF, segmentG, segmentDP;
byte numberOfDigits;
unsigned int brightnessDelay;
byte DigitPins[4];
byte SegmentPins[8];
boolean lights[4][8];
byte nums[4];
byte DecAposColon;
};
#endif