0

I need to write a library for a display I created with eight segments. So, I decided to try to use SevSeg (https://github.com/DeanIsMe/SevSeg) as a starting off point. It can't be that different, right?

Well, I think I have hit a roadblock that indicates I must basically do everything from scratch. Here is how the information on what segments correspond to letters are stored in SevSeg:

 // The codes below indicate which segments must be 
//illuminated to display each number.
static const byte digitCodeMap[] = {
 // GFEDCBA Segments 7-segment map:
 B00111111, // 0 "0" AAA
 B00000110, // 1 "1" F B
 B01011011, // 2 "2" F B
 B01001111, // 3 "3" GGG
 B01100110, // 4 "4" E C
 B01101101, // 5 "5" E C
 B01111101, // 6 "6" DDD
 B00000111, // 7 "7"
 B01111111, // 8 "8"
 B01101111, // 9 "9"
 B01110111, // 65 'A'
 B01111100, // 66 'b'
 B00111001, // 67 'C'
 B01011110, // 68 'd'
 B01111001, // 69 'E'
 B01110001, // 70 'F'
 B00111101, // 71 'G'
 B01110110, // 72 'H'
 B00000110, // 73 'I'
 B00001110, // 74 'J'
 B01110110, // 75 'K' Same as 'H'
 B00111000, // 76 'L'
 B00000000, // 77 'M' NO DISPLAY
 B01010100, // 78 'n'
 B00111111, // 79 'O'
 B01110011, // 80 'P'
 B01100111, // 81 'q'
 B01010000, // 82 'r'
 B01101101, // 83 'S'
 B01111000, // 84 't'
 B00111110, // 85 'U'
 B00111110, // 86 'V' Same as 'U'
 B00000000, // 87 'W' NO DISPLAY
 B01110110, // 88 'X' Same as 'H'
 B01101110, // 89 'y'
 B01011011, // 90 'Z' Same as '2'
 B00000000, // 32 ' ' BLANK
 B01000000, // 45 '-' DASH
};

As you can see this is a one dimensional array of 8-byte binaries that encode the segment. I don't understand the purpose of the B0 at the beginning of each byte. Could I use the 0 column to encode my eighth segment?

Am I right to assume this will change everything about the code and maybe I should start from scratch with a 2-D array?

This is roughly what I want:

// ABCDEFGH Segments 8-segment map:
 11000011, // 0 "0" A BBBBB H
 10000000, // 1 "1" A C D H
 01011010, // 2 "2" A C D H
 11101010, // 3 "3" A C D H
 00110101, // 4 "4" A E F H
 01011010, // 5 "5" A E F H
 11101110, // 6 "6" A E F H
 01011000, // 7 "7" A GGGGG H
 01111110, // 8 "8"
 01100101, // 9 "9"
 11111101, // 10 "A"
 10001110, // 11 "b"
 11000010, // 12 "C"
 00001111, // 13 "d"

What data type should I use for the array? Would byte work since I'm not using the B0?

Thanks.

asked Jan 10, 2017 at 4:44

1 Answer 1

3

I don't understand the purpose of the B0 at the beginning of each byte.

That's just Arduino's rather weird way of doing binary constants. For example, in the file binary.h are lines and lines of stuff like this:

#define B1011 11
#define B01011 11
#define B001011 11
#define B0001011 11
#define B00001011 11
#define B1100 12
#define B01100 12
#define B001100 12
#define B0001100 12
#define B00001100 12

A better way is to use standard C++ constants, eg.

0b00001100

instead of:

B00001100

Could I use the 0 column to encode my eighth segment?

Yes, they are just bytes, so you can use all 8 bits.

answered Jan 10, 2017 at 5:14

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.