|
|
#1 |
|
Junior Member
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1
Karma: 20654
Join Date: Nov 2009
Device: Kindle DX
|
Drawing to the e-ink screen
Hello.
I have a code I would like to share with the community. It draws a rectangle on the e-ink screen. To execute: 1. Cross-compile the code and upload it to Kindle (usbnet assumed) Code:
$ arm-none-linux-gnueabi-gcc -o hello-kindle hello.c $ cat hello-kindle | ssh root@192.168.2.2 "cat - > /var/tmp/root/hello-arm" Code:
[root@kindle root]# /usr/sbin/eips -c [root@kindle root]# ./hello-arm Size: 824 x 1200 [root@kindle root]# echo 2 > /proc/eink_fb/update_display The code is below. Comments/Questions are welcomed. Code:
#include <stdio.h>
// Read in header files
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <linux/fb.h>
#include <unistd.h>
#include <string.h>
#include <sys/mman.h>
#include <sys/ioctl.h>
/*
ACCELEROMETER=/proc/accelerometer (cat works, tail -f doesnt)
/dev/input/event0 - keyboard
/dev/input/event1 - pointer
*/
#define putpixel(_x, _y, _c) \
if ((_x) & 01) { \
data[((_y)*width + (_x)) >> 1] &= 0xF0; \
data[((_y)*width + (_x)) >> 1] |= (_c & 0x0F); \
} else { \
data[((_y)*width + (_x)) >> 1] &= 0x0F; \
data[((_y)*width + (_x)) >> 1] |= ((_c & 0x0F) << 4); \
}
int main(int argc, char** argv) {
int width = 0;
int height = 0;
int row, column, i, j;
// open framebuffer device and read out info
int fd = open("/dev/fb0", O_RDWR);
struct fb_var_screeninfo screeninfo;
ioctl(fd, FBIOGET_VSCREENINFO, &screeninfo);
// determine size
width = screeninfo.xres;
height = screeninfo.yres;
printf("Size: %d x %d\n", width, height);
// embed framebuffer into memory
unsigned char *data = (unsigned char*)
mmap(0, width * height / 2,
PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
// Clear memory (4 bpp)
memset(data, 0, width * height / 2);
// Draw a box
for (i = 100; i <= 200; ++i) {
putpixel(300, i, 0xF);
putpixel(400, i, 0xF);
putpixel(i+200, 100, 0xF);
putpixel(i+200, 200, 0xF);
}
// mask framebuffer out of memory
munmap(data, width * height / 2);
}
|
|
|
|
|
|
#2 |
|
Junior Member
![]() Posts: 6
Karma: 10
Join Date: May 2014
Device: Kindle Paperwhite
|
Using mouse and drawing
I'm trying to create a kindle paperwhite drawing program as well as a framework for using the touch.
Spoiler:
Last edited by Dr. Drib; 05-08-2014 at 11:34 AM. |
|
|
|
| Advert | |
|
|
|
|
#3 |
|
Going Viral
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 17,212
Karma: 18210809
Join Date: Feb 2012
Location: Central Texas
Device: No K1, PW2, KV, KOA
|
Does your post contain a question?
|
|
|
|
![]() |
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Looking for reader that has e-ink screen | Lindsaym | Which one should I buy? | 3 | 05-17-2010 07:14 PM |
| ink spot on screen | starbuck | Sony Reader | 1 | 09-17-2009 03:13 AM |
| Nothing covering E-ink screen? | schulzmc | Amazon Kindle | 6 | 02-24-2009 09:34 PM |
| e- Ink secondary screen? | philippd | News | 3 | 05-19-2008 05:39 AM |
| New screen technology: P-Ink | |2eason | News | 5 | 09-22-2007 04:04 PM |