J'utilise ioctl pour écrire dans le Framebuffer, qui fonctionne très bien. Toutefois, lorsque je le ferme, l'image est toujours affichée à l'écran. Je voudrais restaurer le texte de la console à ce qu'il était avant que j'écrive dans le tampon. Quelqu'un sait-il comment faire? Le code ci-dessous est ce que j'utilise;Comment restaurer le test de la console lorsque vous avez terminé avec le frambuffer?
struct fb_var_screeninfo vinfo;
fbfd = open("/dev/fb0", O_RDWR);
if (!fbfd) {
printf("Error: cannot open framebuffer device.\n");
return(1);
}
// Get variable screen information
if (ioctl(fbfd, FBIOGET_VSCREENINFO, &vinfo)) {
printf("Error reading variable information.\n");
}
printf("Original %dx%d, %dbpp\n", vinfo.xres, vinfo.yres,
vinfo.bits_per_pixel);
// map fb to user mem
screensize = finfo.smem_len;
fbp = (char*)mmap(0,
screensize,
PROT_READ | PROT_WRITE,
MAP_SHARED,
fbfd,
0);
if ((int)fbp == -1) {
printf("Failed to mmap.\n");
}
else {
// draw...some lines
int x, y;
unsigned int pix_offset;
for (y = 0; y < (vinfo.yres/2); y++) {
for (x = 0; x < vinfo.xres; x++) {
// calculate the pixel's byte offset inside the buffer
// see the image above in the blog...
pix_offset = x + y * finfo.line_length;
// now this is about the same as fbp[pix_offset] = value
*((char*)(fbp + pix_offset)) = 16 * x/vinfo.xres;
}
}
sleep(5);
}
// cleanup
munmap(fbp, screensize);
if (ioctl(fbfd, FBIOPUT_VSCREENINFO, &orig_vinfo)) {
printf("Error re-setting variable information.\n");
}
close(fbfd);
return 0;
}