Surprisingly, the old Sony prs-505 e-book is a very cool designer of all kinds of homemade products. Once again I took this book to make myself a “paper” watch. I like this solution because the numbers are large and bright, while they do not glow in the dark and do not interfere with sleep. The idea of a clock on electronic paper is not new at all, but I just wanted to play around with this cool e-book again. The result is a kind of weekend project, because I can. As usual, I collected all the possible mistakes and mistakes. I described my thorny path in this article.
Background
Surely many will remember my post " E-book as a display " in which I told how to work with the display of an e-book.
Photo from the post " E-book as a display ".
There, in fact, I was working with the framebuffer of the video device, in which I displayed the image. The main problem in that article was transferring the image to the device. Then, I did not find enough gunpowder and motivation in myself to bring my plan to the end, because the book was given to someone, and the idea of making such a device was forgotten. But everything changed after the release of a wonderful article from the authoralexshnup: " Electronic ink for Wirenboard 5 or drawing barcodes on Go ". In this articlealexshnupsolved the problem of displaying barcodes on the screen of this book to debug the barcode scanner. And just solved the problem of transferring images to the book.
In short, then alexshnupcreated a kernel module that, when a book is connected via USB, creates an additional virtual hard disk, 600x800 = 480,000 bytes in size. More precisely, the disk will be 1 MB, but the visible area is only 480,000 bytes. In fact, everything that goes into the disk's memory will go to the book's screen. In general, this is a brilliant thing, you can even visually see how the disk layout is going, if, for example, you create a file system there. For example, you can send an image to a book with the following command:
djpeg -pnm -grayscale test.jpg | dd bs=1 skip=15 | dd of=/dev/sdx bs=480k
Everything described further in this article is the ideological continuation of these two experiments.
Let's start, fix it and do it again
After reading the article , I contacted its authoralexshnup... And he decided to give me one disassembled book for experiments. As a result, having working equipment on hand, I happily embarked on the experiments. The first thing I needed to do was install the prs-plus firmware . And after that you can try to create that virtual hard drive to transfer images according to the articlealexshnup... I will not quote the article, it is a comprehensive guide. After that, I try to transfer the image using the dd command.
The image is transmitted in a new way.
Joyfully realizing that everything, all the cards are in my hands, there is an interface for transferring images, you can use it as you like, I began to do a bunch of experiments. I began to write a clock program, and debug their output to a book. As a result, as is usually the case with the command "dd" ("disk destroyer"), I made a mistake with the disk, and ...
As a result, I wrote it instead of a virtual disk, to the disk (flash drive) of the book itself, turning it into a brick ... I just took and wrote 480,000 bytes fat -section. I cannot even convey all the feelings that I experienced at that moment.
Opened book.
The main thing, how to restore this book, was not clear. It was clear that you need to take another book of the same and reinstall the prs-plus firmware on it. Then take these first 480,000 bytes from it and transfer them to this brick.
In general, I was sad, freaked out and bought a new Sony prs-505 e-book on Avito. At the same time, the book was with all the working buttons, in a case, the trains were not torn. It could even be used for its intended purpose, the only thing was that the battery was half dead. But for my purposes, that was enough. Now, with dead batteries, these books can be found up to a thousand rubles, in my opinion the ideal price for a Linux device, with open source and such a gorgeous power-saving system.
Freshly bought e-book.
With this book, I repeated the procedure for installing the firmware in the same way, then, as planned, I transferred 480,000 bytes of the fat-section from one e-book to another. Thus, I got two books, with which I already had fun. True, the one that was disassembled completely began to be godlessly buggy, and I practically did not use it.
We write software
The idea of the watch is quite simple. We will simply form an image of time on a canvas, and then send it to the framebuffer. To do this, we will form numbers and colons. Let me remind you that the resolution of the book is 600x800 (I was not mistaken, namely 600x800), if you look at it like a sheet.
CC: MM: SS - that's what we get eight characters. In total, each digit is 100x600. For numbers I chose a nice font “Gideon's-Army-”. Next, using imagemagick, we form numbers and colons with the following commands:
for i in `seq 0 9`; do convert -font Gideon’s-Army- -pointsize 150 -size 100x600\
-gravity center -rotate 90 -depth 8 caption:"$i" $i.pgm;done
convert -font Gideon’s-Army- -pointsize 150 -size 100x600 -gravity center -depth 8\
-rotate 90 caption:':' dots.pgm
As a result, we get numbers from 0 to 9 and a colon. Here is an example of number 2:
If you cut off the header of a given pgm file, then this data is suitable immediately for writing to the book. I talked about this in detail in my article " An electronic book as a display ", so I will not dwell on this in detail.
Then it was a matter of technology to form a bitmap from these digits for writing to the framebuffer by simply copying the matrix using the file mapping into memory. The whole project lives in the repository: github.com/dlinyj/sony_prs-505_clock .
The whole program is contained in the file time.c... I will not analyze the entire code, but I will dwell on a few points. In this program, I just do a file mapping into memory (either a frame buffer, or a test file, or a file device of an e-book virtual disk). Next, we are already working with the file as a memory area. I copy the images of clock symbols into it, depending on the current time.
We display a file in memory in which I will form an image.
image = mmap (0, file_lenght, PROT_WRITE, MAP_SHARED, fd, 0);
Images are copied in the print_symbol function, into which I pass the digit position number and the name of the digit file to copy.
void print_symbol (unsigned int position, char * filename) {
void * numer_im;
int numer;
numer = open (filename, O_RDWR);
numer_im = mmap (0, NUMER_SIZE, PROT_WRITE, MAP_SHARED, numer, 0);
memcpy(&image[first_header + NUMER_PIXELS * position], &numer_im[16], NUMER_PIXELS);
munmap (numer_im, NUMER_SIZE);
close(numer);
}
Here I open the digit file, and copy it to the appropriate position in the memory area of the mapped image.
In principle, it was possible each time not to open the file, read it, then close it, but simply make a copy in memory and copy from there, but a good idea came only now.
If you want to run this program on your computer to form an image, do not forget to change the compiler in the Makefile and remove define:
# Makefile .
#CFLAGS=-D __BOOK__
CC = gcc
#CC= /opt/cross/gcc-3.2.3-glibc-2.2.5/arm-unknown-linux-gnu/bin/arm-unknown-linux-gnu-gcc
We compile the program and run it without parameters. As a result, we get the file “test.pgm” with the current time.
If you specify a specific file device, then already the formation of the image will be without the header of the pgm file, suitable for uploading to the book. Also, this program can be loaded into the book, and then automatically update the time.
I ran this program on a PC with a USB book connected, and displayed the time on it. The program is started simply (the start.sh script, accepts the device file):
#!/bin/bash
while true;do ./time $1;done
As a result, you can watch the clock running on the screen.
conclusions
The program is written in such a way that it can be collected and filled into an e-book to turn it into a clock. It may seem funny to use such a complex technical device as a clock, but why not. Now batteries are dying in these books, and replacing them is a rather laborious task. If the battery was replaced with its emulator (a blank that allows the book to work, but does not store energy), and the book was connected to a charger, then it would work constantly.
My experiments have shown that the book on the charger does not go into sleep mode and the watch can work continuously. Plus, the book itself has a built-in clock, and it can show the time correctly.
One of the problems that I encountered, and could not resolve, is how to add the clock program to the auto-loading of the book, while stifling the loading of the graphical interface itself, so that there is no competition for the display. In general, there is still room for further experimentation and experimentation. But that will be a completely different story, I won this book, displays the clock, you can start other projects.
What crazy suggestions do you have for using the Sony prs-505 e-book?
Links:
- "E-book as a display."
- "Electronic ink for Wirenboard 5 or drawing barcodes on Go."
- Project repository.
- History of my experiments 1 , 2 , 3 , 4 .