I bought an 8 digit 7 segment display. SPI.
It works and I get most of how to use it.
But I am stuck when I want to display an IP number which is longer than the display.
This is the first bit of the code:
void Show_IP_on_Display()
{
header(3);
char message[16];
uint8_t *IpPtr = &(WiFi.localIP()[0]);
sprintf(message, "%u.%u.%u.%u", WiFi.localIP()[0], WiFi.localIP()[1], WiFi.localIP()[2], WiFi.localIP()[3]);
//Serial.println(message);
byte x = format(message);
message_display();
Serial.println("Message displayed. Wiping display");
delay(600);
//post_message_wipe();
wipe(15);
}
void message_display()
{
//
Serial.println("Displaying message on display now");
byte foo = 0;
byte data = 0; // What is read.
while (foo < bmessage_length)
{
//
data = bmessage[foo];
// Serial.print("Digit being sent to display ----> ");
// Serial.println(data);
// delay(100);
start(data);
foo = foo + 1;
delay(delay_time);
}
}
Which splits up the IP number to littler numbers then prints them on the display.
Before you complain:
I probably haven't shown enough of the code. Sorry.
The entire code is probably too big to want someone to sit down and go through it.
I am also going to re-write a lot of it as the needs have changed and HOW it does things is also re-designed.
I shall have two of these displays (16 digits in total) as two rows of eight.
They will be then divided into 4 x 4 areas.
I will control what is displayed in these 4 sections upstream.
If I want to display an 8 digit message (time/date eg) then it will be sent to the left most of the two places and the right one won't be sent anything.
But that's in the future and at some stage I will need to get this part working.
It is pretty well documented, but as I am kind of new here, I don't want to annoy anyone.
The idea to display the entire IP number is something like this:
1 - Brake the IP number into smaller parts.
2 - Wipe the display.
3 - Print the indexed digit on the display at position 0. (Right most actually)
4 - Loop:
5 - Move all digits right one position. Any at extreme left are lost.
6 - Increase index ++1 and display digit at position 0.
7 - repeat.
So if my IP is (say) 192.168.2.200
The display would be:
(x means blank)
xxxxxxx1
xxxxxx19
xxxxx192
xxxx192.1
xxx192.16
xx192.168.
x192.168.2.
192.168.2.2
92.168.2.20
2.168.2.200
168.2.200x
68.2.200xx
8.2.200xxx
2.200xxxx
200xxxxx
and so on until the display is wiped.
Then it goes back to what it was doing.
I nearly have it but it doesn't shunt the last 2 digits onto the display.
All I get to see is 192.168.2.2
I can post the entire code - but it has a lot of old code in it as it evolved, some of which is no longer used. Yeah, I should get it deleted.
But to the best of my knowledge, I split up the IP number into an array/thing and it is read from left to right and it prints the current digit at the right most position and shoves all others left one position before that.
Decimal points are handled ok. Or they seem to be.
Thanks in advance.