#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <error.h>
#include <errno.h>
#include <unistd.h>
#include <strings.h>
#include <stdbool.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <fcntl.h>
#include <sys/mman.h>
int main (int argc,char **argv)
{
int fd = open ("/dev/fb0", O_RDWR);
if (fd = =-1)
{
fprintf (stderr, "open (%s) failed:%s", "/dev/fb0", Strerror (errno));
Exit (0);
}
Char *p = mmap (Null,800*480*4,prot_read | prot_write,map_shared,fd,0);
if (p = = map_failed)
{
Perror ("Mmap failed!");
Exit (0);
}
unsigned long buff[3] = {0X000000FF,0X00FF0000,0X0000FF00};
int i,j = 0;
for (J;; J + +)//The use of the main variable J, if only I loop, without J, there will be a snowflake point,
{
for (i=0;i<800*480;i++)
{
memcpy (p+i*4,&buff[j%3],4);//There is less redundancy here, there will be a segment error, memory overflow.
}
Sleep (1);
}
return 0;
}
Stage Small Item 1: Cycle interval 1 seconds LCD display Red Green Blue