|
|||||||
|
You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community today, you will have fewer ads, access to post topics, communicate privately with other members, respond to polls, upload content and access many other special features. If you have any problems with the registration process or your account login, please contact us. Hint: Don't have time to visit us daily? Subscribe to our main RSS feed to receive our frontpage posts at your convenience. |
| Kindle Developer's Corner Linux, hacking and development of software and hardware |
![]() |
|
|
Thread Tools | Search this Thread | Display Modes |
|
|
#1 |
|
Junior Member
![]()
Posts: 1
Karma: 10
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);
}
|
|
|
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| ink spot on screen | starbuck | Reader Troubleshooting | 1 | 09-17-2009 03:13 AM |
| E-ink screen lifespan? | 301verbs | News and Commentary | 21 | 05-22-2009 12:54 PM |
| Nothing covering E-ink screen? | schulzmc | Amazon Kindle | 6 | 02-24-2009 09:34 PM |
| e- Ink secondary screen? | philippd | News and Commentary | 3 | 05-19-2008 05:39 AM |
| New screen technology: P-Ink | |2eason | News and Commentary | 5 | 09-22-2007 04:04 PM |