From 2ad7917a466655a2e8907ff73cdef4c8ea266872 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 28 Dec 2015 11:27:14 +0000 Subject: fix for different screen sizes --- eink_full_monochrome.c | 46 +++++++++++++++++++++++++++----------------- eink_full_update.c | 52 +++++++++++++++++++++++++++++++------------------- 2 files changed, 61 insertions(+), 37 deletions(-) diff --git a/eink_full_monochrome.c b/eink_full_monochrome.c index da4ecaa..ceaaf20 100644 --- a/eink_full_monochrome.c +++ b/eink_full_monochrome.c @@ -4,25 +4,37 @@ #include "mxcfb.h" #include - -int main(int argc, char *argv[]) +int +main (int argc, char *argv[]) { - struct mxcfb_update_data update_data = { - 0, 0, 800, 600, - WAVEFORM_MODE_AUTO, - }; - update_data.update_mode = UPDATE_MODE_PARTIAL; - update_data.flags = EPDC_FLAG_FORCE_MONOCHROME; + struct fb_var_screeninfo info = { 0 }; + struct mxcfb_update_data update_data = { 0 }; + int fd; + + fd = open ("/dev/fb0", O_RDWR); + if (fd == -1) { + perror ("open"); + return 1; + } + + if (ioctl (fd, FBIOGET_VSCREENINFO, &info)) { + perror ("FBIOGET_VSCREENINFO"); + return 1; + } + + update_data.waveform_mode = WAVEFORM_MODE_AUTO, + update_data.update_region.width = + info.xres_virtual ? info.xres_virtual : info.xres; + update_data.update_region.height = + info.yres_virtual ? info.yres_virtual : info.yres; + update_data.update_mode = UPDATE_MODE_PARTIAL; + update_data.flags = EPDC_FLAG_FORCE_MONOCHROME; - int framebuffer = open("/dev/fb0", O_RDWR); /* 0_RDONLY */ - if (framebuffer != -1) - { - ioctl(framebuffer, MXCFB_SET_UPDATE_SCHEME, UPDATE_SCHEME_QUEUE); - ioctl(framebuffer, MXCFB_SEND_UPDATE, &update_data); - close(framebuffer); + ioctl (fd, MXCFB_SET_UPDATE_SCHEME, UPDATE_SCHEME_QUEUE); + ioctl (fd, MXCFB_SEND_UPDATE, &update_data); + close (fd); - printf("E-ink display fully updated (monochrome).\n"); - } - return 0; + printf("E-ink display fully updated (monochrome).\n"); + return 0; } diff --git a/eink_full_update.c b/eink_full_update.c index 396de57..42118e2 100644 --- a/eink_full_update.c +++ b/eink_full_update.c @@ -1,28 +1,40 @@ #include #include -#include +#include #include "mxcfb.h" #include -int main(int argc, char *argv[]) +int +main (int argc, char *argv[]) { - struct mxcfb_update_data update_data = { - 0, 0, 800, 600, - WAVEFORM_MODE_AUTO, - }; - update_data.update_mode = UPDATE_MODE_FULL; - - - int framebuffer = open("/dev/fb0", O_RDWR); /* 0_RDONLY */ - if (framebuffer != -1) - { - ioctl(framebuffer, MXCFB_SET_UPDATE_SCHEME, UPDATE_SCHEME_QUEUE); - ioctl(framebuffer, MXCFB_SEND_UPDATE, &update_data); - close(framebuffer); - - printf("E-ink display fully updated.\n"); - } - return 0; -} + struct fb_var_screeninfo info = { 0 }; + struct mxcfb_update_data update_data = { 0 }; + int fd; + + fd = open ("/dev/fb0", O_RDWR); + if (fd == -1) { + perror ("open"); + return 1; + } + + if (ioctl (fd, FBIOGET_VSCREENINFO, &info)) { + perror ("FBIOGET_VSCREENINFO"); + return 1; + } + + update_data.waveform_mode = WAVEFORM_MODE_AUTO, + update_data.update_region.width = + info.xres_virtual ? info.xres_virtual : info.xres; + update_data.update_region.height = + info.yres_virtual ? info.yres_virtual : info.yres; + update_data.update_mode = UPDATE_MODE_FULL; + + ioctl (fd, MXCFB_SET_UPDATE_SCHEME, UPDATE_SCHEME_QUEUE); + ioctl (fd, MXCFB_SEND_UPDATE, &update_data); + close (fd); + + printf ("E-ink display fully updated.\n"); + return 0; +} -- cgit v1.2.3