I want to build this Altimeter: https://www.youtube.com/watch?v=mMiMNTv25Bw. While I was waiting for the parts to arrive, I started looking over the code. I have a Splash.c file.
This is the code in the file:
*
// Splash.c
// Font type : Splash Screen
// Font size : 128x64 pixels
// Memory usage : 1024 bytes
#include <avr/pgmspace.h>
uint8_t Splash[] PROGMEM={
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x0f, 0xff, 0xbf, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x0f, 0xff, 0xbf, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00,
0x0f, 0xff, 0xbf, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x01, 0xc0,
0x0f, 0xff, 0xbf, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x01, 0xc0,
0x0f, 0xff, 0xbf, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x78, 0x01, 0xc0,
0x01, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0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xf8, 0x3f, 0x3f, 0x3f, 0x7e, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x18, 0x0f, 0xc0,
0x01, 0xf8, 0x3f, 0x3f, 0x3f, 0x7f, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x1c, 0x0f, 0xc0,
0x01, 0xf8, 0x3f, 0x3f, 0x3f, 0x7f, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x1c, 0x1f, 0xc0,
0x01, 0xf8, 0x3f, 0x3f, 0x3f, 0x3f, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x1c, 0xff, 0xc0,
0x01, 0xf8, 0x3f, 0x3f, 0x3f, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x09, 0xff, 0xc0,
0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x01, 0xff, 0xc0,
0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x3f, 0xff, 0xc0,
0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x7f, 0xff, 0xc0,
0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0x00, 0x7c, 0x0f, 0xff, 0x03, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0x00, 0x7c, 0x0f, 0xff, 0x03, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0x00, 0x7c, 0x0e, 0x0f, 0x03, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc1, 0xff, 0xff, 0xff, 0xff,
0xfe, 0x00, 0x7c, 0x0e, 0x0f, 0x03, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc1, 0xff, 0xff, 0xff, 0xff,
0xfe, 0x00, 0x3c, 0x0e, 0x0f, 0x03, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc1, 0xff, 0xff, 0xff, 0xff,
0xfe, 0x00, 0x3c, 0x0e, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc1, 0xff, 0xff, 0xff, 0xff,
0xfe, 0x08, 0x3c, 0x0c, 0x01, 0x03, 0x02, 0x06, 0x07, 0xe0, 0x07, 0x80, 0x3c, 0x00, 0xf0, 0x23,
0xfe, 0x08, 0x3c, 0x0c, 0x01, 0x03, 0x00, 0x00, 0x03, 0xc0, 0x01, 0x80, 0x38, 0x00, 0x30, 0x03,
0xfc, 0x08, 0x3c, 0x0c, 0x01, 0x03, 0x00, 0x00, 0x03, 0x80, 0x01, 0x80, 0x30, 0x00, 0x30, 0x03,
0xfc, 0x08, 0x1c, 0x0c, 0x01, 0x03, 0x00, 0x00, 0x03, 0x80, 0x01, 0x80, 0x30, 0x00, 0x30, 0x03,
0xfc, 0x18, 0x1c, 0x0c, 0x01, 0x03, 0x03, 0x03, 0x83, 0x80, 0x01, 0x80, 0x30, 0x00, 0x30, 0x3f,
0xfc, 0x1c, 0x1c, 0x0e, 0x0f, 0x03, 0x03, 0x03, 0x83, 0x81, 0xc1, 0xc1, 0xf0, 0x38, 0x30, 0x3f,
0xfc, 0x1c, 0x1c, 0x0e, 0x0f, 0x03, 0x03, 0x03, 0x83, 0x81, 0xc1, 0xc1, 0xf0, 0x38, 0x30, 0x3f,
0xfc, 0x1c, 0x1c, 0x0e, 0x0f, 0x03, 0x03, 0x03, 0x83, 0x81, 0x81, 0xc1, 0xf0, 0x30, 0x30, 0x3f,
0xf8, 0x00, 0x1c, 0x0e, 0x0f, 0x03, 0x03, 0x03, 0x83, 0x80, 0x01, 0xc1, 0xf0, 0x00, 0x30, 0x3f,
0xf8, 0x00, 0x0c, 0x0e, 0x0f, 0x03, 0x03, 0x03, 0x83, 0x80, 0xff, 0xc1, 0xf0, 0x1f, 0xf0, 0x3f,
0xf8, 0x00, 0x0c, 0x0e, 0x0f, 0x03, 0x03, 0x03, 0x83, 0x81, 0xff, 0xc1, 0xf0, 0x3f, 0xf0, 0x3f,
0xf8, 0x00, 0x0c, 0x0e, 0x0f, 0x03, 0x03, 0x03, 0x83, 0x81, 0xff, 0xc1, 0xf0, 0x3f, 0xf0, 0x3f,
0xf8, 0x00, 0x0c, 0x0e, 0x01, 0x03, 0x03, 0x03, 0x83, 0x80, 0x01, 0xc0, 0x30, 0x00, 0x30, 0x3f,
0xf8, 0x1c, 0x0c, 0x0e, 0x01, 0x03, 0x03, 0x03, 0x83, 0x80, 0x01, 0xc0, 0x30, 0x00, 0x30, 0x3f,
0xf0, 0x3c, 0x0c, 0x0e, 0x01, 0x03, 0x03, 0x03, 0x83, 0x80, 0x01, 0xc0, 0x30, 0x00, 0x30, 0x3f,
0xf0, 0x3c, 0x04, 0x0f, 0x01, 0x03, 0x03, 0x03, 0x83, 0xc0, 0x01, 0xe0, 0x38, 0x00, 0x30, 0x3f,
0xf0, 0x3e, 0x04, 0x0f, 0x81, 0x03, 0x03, 0x03, 0x83, 0xe0, 0x07, 0xf0, 0x3c, 0x00, 0xf0, 0x3f,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
};
*
This is for the splash screen when the device boots, right? ( see YT link )
Can someone explain what it means and how it's made? I want to create my custom splash screen but I don't understand this code. Thanks!
I believe that is just a bitmap. The values indicate where to draw a pixel. The 0x00 values are just the blank space (probably black screen), and any where where there is a value greater than zero there will be pixels drawn (a 1 will be a pixel). All the painted pixels come together to create an image.
I think if you search, you should be able to find some kind of editor that will let you draw what you want and it will generate the bitmap for you.
Related
I have an 128x64px display. Current picture on display is saved in
uint8_t bufferOLED[(HEIGHT * WIDTH / 8)+1]; // uint8_t bufferOLED[1025];
If I load bufferOLED with strcpy and print to display everything works fine.
Now I want to initialize bufferOLED with some logo that will show up when booting application.
uint8_t bufferOLED[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //0
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //1
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //2
...
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, //49
0x09, 0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, //50
...
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //100
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //101
0x00, 0x00, 0x00, 0x00 //102
}
Logo prints OK, but after I load bufferOLED with different content and print to display, image on display gets corrupted.
When writing to display I'm just sending bufferOLED with some commands to OLED:
for(int i=0; i<1024; i+=16) twiPrint(OLED, 0x40, bufferOLED+i, 16); //twiPrint(uint8_t twiAddress, uint8_t twiCommand, uint8_t *twiTransmitData, uint8_t twiTransmitDataLen)
I know that NULL character is used for terminating string. So is initialization with mix of NULL and not NULL characters allowed?
I'm working with the RSVP protocol in IPv6 and in order to make it work, I have to set the IPv6 router alert in the messages that I send. I have done lots of research on internet but with no luck, maybe someone here has already done this before. You can find below the code that I use for my tests.
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#define DATA_LENGTH 124
int main() {
int data_length = DATA_LENGTH;
unsigned char data[DATA_LENGTH] = {0x10, 0x01, 0xb0, 0x16, 0xff, 0x00, 0x00, 0x7c, 0x00, 0x18,
0x01, 0x02, 0x20, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x10, 0x32, 0x00, 0x20, 0xc2, 0x00, 0x18, 0x03, 0x02, 0x20, 0x02, 0x00, 0x01, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18,
0x0b, 0x02, 0x20, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x20, 0x00, 0x00, 0x5d, 0x27, 0x00, 0x08, 0x05, 0x01, 0x00, 0x00, 0x75, 0x30, 0x00, 0x24,
0x0c, 0x02, 0x00, 0x00, 0x00, 0x07, 0x01, 0x00, 0x00, 0x06, 0x7f, 0x00, 0x00, 0x05, 0x49, 0x55,
0x9f, 0x80, 0x4a, 0xba, 0xeb, 0x90, 0x4c, 0xee, 0xa8, 0x31, 0x00, 0x00, 0x00, 0x4b, 0x00, 0x00,
0x05, 0xdc};
unsigned char dest_address[16] = {0x20, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x05};
int socket_descriptor;
struct sockaddr_in6 dest;
const int yes = 1;
const int router_alert_value = 0;
socket_descriptor = socket(AF_INET6, SOCK_RAW, IPPROTO_RSVP);
if (socket_descriptor < 0) {
perror("Can't open socket to send path message\n");
}
memset(&dest, 0, sizeof(dest));
dest.sin6_family = AF_INET6;
memcpy(dest.sin6_addr.s6_addr, dest_address, sizeof(struct in6_addr));
dest.sin6_port = 0;
dest.sin6_flowinfo = 0;
if (setsockopt(socket_descriptor, SOL_SOCKET,
SO_REUSEADDR,(const void *)&yes, sizeof(yes)) < 0) {
printf("setsockopt(%d): %s\n", SO_REUSEADDR, strerror(errno));
}
if(setsockopt(socket_descriptor, IPPROTO_IPV6,
IPV6_HOPOPTS, &yes, sizeof(yes)) < 0) {
printf("Can't set Hop-by-hop Option: %s\n", strerror(errno));
}
if(setsockopt(socket_descriptor, IPPROTO_IPV6, IPV6_ROUTER_ALERT,
(const void *) &router_alert_value, sizeof(router_alert_value)) < 0) {
printf("Can't set IP Options: %s\n", strerror(errno));
}
if(sendto(socket_descriptor, data, data_length, 0,
(struct sockaddr*) &dest, sizeof(dest)) < 0) {
printf("Error in sending message : %s (%d)\n", strerror(errno), errno);
}
close(socket_descriptor);
return(0);
}
The previous code compiles and sends a RSVP Path message but without the IPv6 router alert option. Since I didn't have return when I got errors with the setsockopt method, I could provide you the console output which is:
Can't set Hop-by-hop Option: Invalid argument
Can't set IP Options: Protocol not available
I have done some tries using a socket with the protocol 0 (in order to use the hop-by-hop next header) and by adding the router alert option directly into the data, but it still not working.
Any idea or leads is appreciated.
On Windows with WinSock you can use IPV6_HDRINCL to build the IP header and set the Router Alert flag. On Linux and similar platforms this is simply not available and you would simply have to drop down to raw packets using AF_PACKET similar to Wireshark and tcpdump and hand build artisanal packets to your requirements.
Alternative of course is to propose and implement a new interface in the kernel to set IPv6 Router Alerts.
I am using the following display : https://www.adafruit.com/products/938
I ran the code they have on git and it works perfectly, I can see all their tests and all it's fine however the moment I add my own bitmap(via LCD assistant) as follows :
const unsigned char tedst [] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x80, 0xC0, 0xE0, 0xE0, 0xE0, 0xE0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x7C,
0x7C, 0x3C, 0x3E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x3E, 0x3E, 0xFE, 0xFE, 0xFE, 0xFE,
0xDE, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xFE, 0xFF, 0xFF, 0xFF, 0x07, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF,
0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80,
0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xFF, 0xFF, 0xFF, 0xFF,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xF8, 0xFE, 0xFF, 0xFF, 0x8F, 0x87, 0x87, 0x07,
0x07, 0x07, 0x07, 0x07, 0x07, 0x87, 0x8F, 0xFF, 0xFF, 0xFE, 0xFC, 0x78, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0xC0, 0xC0,
0xC0, 0xC0, 0xC0, 0x81, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 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, 0x00, 0x00, 0x00, 0x07, 0x7F, 0xFF, 0xFF, 0xFF, 0xC0, 0x80, 0x80, 0x00, 0x00,
0x00, 0x80, 0xE0, 0xFC, 0xFF, 0xFF, 0x7F, 0xFF, 0xFF, 0xFF, 0xF8, 0xC0, 0x80, 0x03, 0x07, 0x07,
0x03, 0x83, 0xC3, 0xFF, 0xFF, 0xFF, 0xFE, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x07, 0x0F,
0x0F, 0x1F, 0x1E, 0x3E, 0x3E, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3E, 0x1F, 0x1F, 0x0F, 0x07, 0x03,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x07, 0x0F, 0x0F, 0x0F, 0x0F,
0x0F, 0x0F, 0x0F, 0x07, 0x03, 0x01, 0x00, 0x00, 0x01, 0x03, 0x07, 0x07, 0x0F, 0x0F, 0x0F, 0x0F,
0x0F, 0x0F, 0x0F, 0x07, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
I then follow up with :
display.clearDisplay();
display.drawBitmap(0, 0, tedst, 128, 64, 1);
display.display();
As the image is as big as the screen and when I do so the screen flickers with half of your logo(the first image, I did not alter the loop so all animations will be there) and random artifacts. The moment I delete my 3 lines, it is all back to normal, ideas why please?
use dot factory at http://www.pavius.net/wp-content/uploads/the-dot-factory/versions/TheDotFactory-0.1.4.7z where you set the output as binary, the thing works perfectly
I need to compress the data of a 102x64 pixel black and white LCD screen using an 8-bit microprocessor. The data is coming in as a stream as shown below:
unsigned char data[8][102] =
{
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x38, 0x28, 0xfe, 0x82, 0xba, 0xba, 0x82, 0xba, 0xba, 0x82, 0xba, 0xba, 0x82, 0xfe, 0x00,
0x00, 0x38, 0x44, 0x44, 0x38, 0x00, 0x40, 0x4c, 0x50, 0x60, 0x00, 0x28, 0x00, 0x40, 0x7c, 0x00,
0x4c, 0x54, 0x54, 0x24, 0x00, 0x00 },
{0x00, 0x20, 0x20, 0x20, 0x3f, 0x3f, 0x20, 0x20, 0x20, 0x00, 0x6f, 0x6f, 0x00, 0x0f, 0x0f, 0x08,
0x08, 0x0f, 0x0f, 0x08, 0x08, 0x0f, 0x07, 0x00, 0x07, 0x0f, 0x0a, 0x0a, 0x0e, 0x06, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{0x00, 0x00, 0x00, 0x00, 0xc0, 0xcf, 0x0e, 0x0d, 0x0d, 0x0d, 0xce, 0xcf, 0x0d, 0xcd, 0xcd, 0x0d,
0x0c, 0xcf, 0xc0, 0x00, 0x00, 0xc0, 0xc2, 0x02, 0x83, 0xc0, 0x40, 0x40, 0x41, 0x42, 0x02, 0x02,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x01, 0x02, 0x02,
0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x07, 0xfb, 0xfb, 0xfb, 0x07, 0xff, 0xff, 0xfb, 0xc7, 0x3f,
0xff, 0xff, 0x00, 0x84, 0x00, 0x00, 0x04, 0x04, 0xfc, 0x04, 0x04, 0x00, 0x04, 0x0c, 0x14, 0x24,
0xc4, 0x00, 0x00, 0x84, 0x00, 0x00, 0x30, 0x50, 0x90, 0x10, 0xfc, 0x10, 0x00, 0xf8, 0x04, 0x04,
0x04, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{0x00, 0x3f, 0x3f, 0x20, 0x20, 0x30, 0x1f, 0x0f, 0x00, 0x01, 0x0b, 0x0a, 0x0a, 0x0f, 0x07, 0x00,
0x08, 0x3f, 0x3f, 0x08, 0x08, 0x00, 0x07, 0x0f, 0x0a, 0x0a, 0x0e, 0x06, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{0x00, 0xc0, 0xc0, 0x40, 0x40, 0xc0, 0x81, 0x02, 0x02, 0x82, 0xc1, 0x40, 0x42, 0xc2, 0xc3, 0x00,
0x00, 0xc0, 0xc0, 0x40, 0x40, 0x00, 0x81, 0xc2, 0x42, 0x42, 0x41, 0x40, 0x02, 0x02, 0x03, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x01, 0x00, 0x01, 0x02, 0x02, 0x02,
0x01, 0x00, 0x01, 0x02, 0x02, 0x02, 0x01, 0x00, 0x01, 0x02, 0x02, 0x02, 0x01, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x04, 0x04, 0x04, 0xf8, 0x00, 0x04, 0x04, 0xfc, 0x04,
0x04, 0x00, 0x00, 0x04, 0x00, 0x00, 0xf8, 0x04, 0x04, 0x04, 0xf8, 0x00, 0x04, 0x04, 0xfc, 0x04,
0x04, 0x00, 0x00, 0x04, 0x00, 0x00, 0x04, 0x0c, 0x14, 0x24, 0xc4, 0x00, 0xf8, 0x04, 0x04, 0x04,
0xf8, 0x00, 0xf8, 0x04, 0x04, 0x04, 0xf8, 0x00, 0xf8, 0x04, 0x04, 0x04, 0xf8, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }
};
However I'm unable to fit it completely into the microprocessor's RAM. I can only access it in 51 or less byte chunks.
For those who are curious - the data will produce the following image:
I like to transfer the data using a slow serial interface. It takes way too much time to send the data as is. My goal is to double the speed by shrinking the data by a factor of 2. A normal zip compression will achieve factor 2.46 by compressing the 816 byte to 332 bytes.
My first idea was to shrink the data by grouping the byte that do have the same value in a sequence. For instance the data {0x20, 0x20, 0x20, 0x3f, 0x3f, 0x20, 0x20, 0x20} will be compressed from 8 byte to 6 byte into this {{0x20, 0x03}, {0x3f, 0x02}, {0x20, 0x03}}.
Is there a method that works better for black & white pixel data and the limited recourses that a 8-bit microprocessor provides?
Fax machines use a combination of Huffman compression for lines, and then the following few lines only encode the differences from the last complete line.
It's the same principle as video compression: you compress one full frame, and then compress the differences for the next few frames (that's not 100% accurate, of course).
It should help the compression, but the code becomes a bit more complex.
I'd start with Huffman compression, as the image is definitely not random and should compress nicely. I don't think fax machines have a huge amount of memory so it might be possible to squeeze it in.
I don't know much about compression, but for something that's even more effective than RLE, specifically designed for a LCD, I'd perhaps consider something like this (inventing this algorithm as I write) :
{tag, x coord, y coord, data, data, data, ..., tag, x coord, ... and so on.
This is based on the idea that everything on the LCD is blank by default, and you just fill in the data. So it removes the need of storing a lot of 0x00. Instead, the value 0x00 can be used as a tag to describe where a new data segment begins and ends.
It would look like this:
uint8_t data[N] = {0x00, 0x05, 0x01, 0xFF, 0xFF, 0x00, 0x01, 0x02, 0xAA, 0xBB, 0xCC };
This will print the data FFFF at location (5,1) to (6,1) on the LCD, and then the data AABBCC at location (1,2) to (3,2). A wrap-around at end of line could easily be implemented. 0x00 may appear as one of the coordinates but never as data.
I created a test using the RLE method (which was really easy to implement) and compressed a similar image from 816 to 446 byte (factor 1.82) - which is more than I expected from such a simple method.
If you consider a huffman compression you can try a pre-processing like delta code or a move-to-the-front of the data. A delta code records the difference from the next byte and a mtf swaps the data using a dictionary. It can improve the compression rate of a statistial compressor. If a huffman is to expensive you may look into a golomb code. Mtf is used in bzip2 before a BWT transformation.
First off, if anyone would like to compile the server and run it
go to http://pastebin.com/qPnE3jV0
compile and run it
go to your browser and type http://localhost:7191/
The function I'm looking at particularly is:
void serveHTML (int socket) {
char *message;
int i;
int j;
//image data
char bmpheader[54] = {0x42, 0x4D, 0x5A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x13, 0x0B, 0x00, 0x00, 0x13, 0x0B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
char bmpimagedata[36] = {0x07, 0x07, 0xFF, 0x07, 0x07, 0x07, 0x07, 0x07, 0xFF, 0xFF, 0x07, 0x07, 0x07, 0x07, 0x07, 0x66, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0xFF, 0xFF, 0xFF, 0x46, 0x00, 0x00};
message = "HTTP/1.0 200 OK\r\n"
"Content-Type: image/bmp\r\n"
"Content-Length: 90\r\n";
printf ("%s\n", message);
write (socket, message, strlen(message));
// now send the contents of the web page to be displayed
i=0;
j=0;
while (i < 54) {
printf("%c", bmpheader[i]);
write (socket, &bmpheader[i], 1);
i++;
}
while (j < 36) {
printf("%c", bmpimagedata[j]);
write (socket, &bmpimagedata[j], 1);
j++;
}
}
What I've done here is stored the hex
data of a 3x3 bmp file into two
arrays (for convenience of
modification) the header and the
image data. I try to get it to
serve this bmp on a web browser.
However it fails.
I've placed printf's all over the
place to print what the server is
spitting out... however I think I'm
missing something (possibly a
footer?).
Any help would be appreciated, I'm pulling my hair out as to why it doesn't work.
Headers need to end with two \r\n - Append \r\n to your message constant.
A few points:
Don't use such bizarre code to write out the arrays. Just use plain write(socket, bmpheader, sizeof bmpheader); and the same for the data.
Inspect the return value of write(); it can fail.