Hi there,
I am using Firefly for Grasshopper to send a UDP 'HEX' string representation of an 84x48 pixel bitmap to a Nokia 5110 display.
I believe firefly sends a String and NOT an array.
I can format the string however I want, currently I have '0x' notation as that is what I have found inside the ADAfruit GFX & PCD8544 library.
//A snippet of the string sent from FireFly
//0xFF, 0x7F, 0x7F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x79...
//Basic UDP read
void loop() {
if (Udp.parsePacket()) {
int len = Udp.read(packetBuffer, UDP_TX_PACKET_MAX_SIZE);
packetBuffer[len] = 0;
Serial.println(packetBuffer);
}
}
//Serial monitor correctly displays the string
//0xFF, 0x7F, 0x7F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x79
I know it's possible to condense the string to reduce the length to something like: FF7F3F3F3F3F.. which is not a problem, it's just the bitmap for the bootloader inside the ADAfruit library looks like so:
//ADAFruit_PCD8544.cpp
uint8_t pcd8544_buffer[LCDWIDTH * LCDHEIGHT / 8] = {
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, ... }
How would I go about splitting/traversing the received UDP string, extracting the pair of characters after the '0x' and putting the HEX value into an array like in the ADAfruit PCD library? I believe the HEX value is simply another way of representing an 8 bit long binary eg 00001111 number and is the same thing?
Any help would be greatly appreciated!