This is a programming question which has hardware limitations. I am working on a reverse engineering / hacking project of a "smart" thermostat. (which was not so smart, but it will be able to handle MQTT traffic.)
My problem is with the built in LED matrix display. There are 5 seven segments, two of those have DP as well and 19 icons all around the display.
Normally I would resolve the display like this:
#define MAKE_BINARY(a,b,c,d,e,f,g,h) (((a)<<7)|(b)<<6)|((c)<<5)|((d)<<4)|((e)<<3|((f)<<2)|((g<<1)|h))
static unsigned char int_to_7leds [] = {
MAKE_BINARY (0,0,0,0,0,0,1,1), // 0
MAKE_BINARY (1,0,0,1,1,1,1,1), // 1
MAKE_BINARY (0,0,1,0,0,1,0,1), // 2
MAKE_BINARY (0,0,0,0,1,1,0,1), // 3
MAKE_BINARY (1,0,0,1,1,0,0,1), // 4
MAKE_BINARY (0,1,0,0,1,0,0,1), // 5
MAKE_BINARY (0,1,0,0,0,0,0,1), // 6
MAKE_BINARY (0,0,0,1,1,1,1,1), // 7
MAKE_BINARY (0,0,0,0,0,0,0,1), // 8
MAKE_BINARY (0,0,0,0,1,0,0,1), // 9
However, there is a slight problem with this. there are five 74HC595 shift registers on the board, which are tied to the LEDs like this:
This is not something you would normally want to do when designing stuff, at least I try to keep it like 8 bits (1 SR) / 7 segment and at the end take care of the rest.
As I have already mentioned this is pure hacking, I do not have the original code or the schematics. I would like to ask for some help on how to manipulate the 7 bytes to break it down to something like:
- 5 characters
- 21 boolean variables to set everything else
I have started to think about a 56 bit long variable and a huge switch-case structure to set each of the characters, but there should be some other nicer solution out there.
Thank you for reading this!
All suggestions are welcome.