summaryrefslogtreecommitdiffstats
path: root/eink_full_monochrome.c
blob: ceaaf208e66950187b8a7d848e95042dbe16510b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <stdio.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include "mxcfb.h"
#include <linux/fb.h>

int
main (int argc, char *argv[])
{
  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;

  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;
}