turgu1 / EPub-InkPlate

An EPub Reader for the ESP32 based InkPlate e-Ink devices.
228 stars 8 forks source link
epub esp32 inkplate

EPub-InkPlate An EPub Reader for InkPlate devices

Last news

(Updated 2022.5.01)

Update to version 2.0.1

Unresolved issue

[ ] A device reset may happen reading a book, and changing the current font as the background process is computing pages location.


This is an EPub reader for the e-Radionica made Inkplate devices.

Here are the main characterics:

Some vidos are available on YouTube:

Some pictures from the InkPlate-6 version:

picturepicture

picture

Some pictures from the Linux version:

drawingdrawing

A picture of the Web Server in a browser:

drawing

Books Directory List: Linear vs Matrix View:

picturepicture

Runtime environment

The EPub-InkPlate application requires that a micro-SD Card be present in the device. This micro-SD Card must be pre-formatted with a FAT32 partition. Two folders must be present in the partition: fonts and books. You must put the base fonts in the fonts folder and your EPub books in the books folder. The books must have the extension .epub in lowercase.

Height font types are supplied with the application. For each type, there are four fonts supplied, to support regular, bold, oblique, and bold-italic glyphs. The application offers the user to select one of those font types as the default font. The fonts have been cleaned-up and contain only Latin-1 glyphs.

Another font is mandatory. It can be found in SDCard/fonts/drawings.otf and must also be located in the micro-SD Card fonts folder. It contains the icons presented in parameters/options menus.

The SDCard folder under GitHub reflects what the micro-SD Card should look like. One file is missing there is the books_dir.db that is managed by the application. It contains the meta-data required to display the list of available ebooks on the card and is automatically maintained by the application. It is refreshed at boot time and when the user requires it to do so through the parameters menu. The refresh process takes some time (between 5 and 10 seconds per ebook) but is required to get fast ebook directory list on screen.

Fonts cleanup

All fonts have been subsetted to Latin-1 plus some usual characters. The fonts/orig folder in the GitHub project contains all original fonts that are processed using the script fonts/subsetter.sh. This script uses the Python pyftsubset tool that is part of the fontTools package. To install the tool, you need to execute the following command:

$ pip install fonttools brotli zopfli

The script takes all font from the orig folder and generate the new subset fonts in subset-latin1/otf folder. The following commands must be executed:

$ cd fonts
$ ./subsetter.sh

After that, all fonts in the subset-latin1/otf folder must be copied back in the SDCard/fonts folder.

Development environment

Visual Studio Code is the code editor I'm using. The PlatformIO extension is used to manage application configuration for both Linux and the ESP32.

All source code is located in various folders:

The file platformio.ini contains the configuration options required to compile both Linux and InkPlate applications.

Note that source code located in folders old and test is not used. It will be deleted from the project when the application development will be completed.

Dependencies

The following are the libraries currently in use by the application:

The following are imported C header and source files, that implement some algorithms:

The following libraries were used at first but replaced with counterparts:

FreeType library compilation for ESP32

The FreeType library is using a complex makefile structure to simplify (!) the compilation process. Here are the steps used to get a library suitable for integration in the EPub-InkPlate ESP32 application. As this process is already done, there is no need to run it again, unless a new version of the library is required or some changes to the modules selection are done.

  1. The folder named lib_freetype is created to receive the library and its dependencies at install time:

    $ mkdir lib_freetype
  2. The ESP-IDF SDK must be installed in the main user folder. Usually, it is in folder ~/esp. The following location documents the installation procedure: https://docs.espressif.com/projects/esp-idf/en/latest/esp32/get-started/index.html . Look at Steps 1 to 4 (Setting Up Development Environment). This is important as the configuration setup below will access ESP32 related compilation tools.

  3. The files freetype-2.10.4/modules.cfg and freetype-2.10.4/include/freetype/config/ftoption.h are modified to only keep the capabilities required to support TrueType and OpenType fonts. The original files have been saved in *.orig files.

  4. A file named freetype-2.10.4/myconf.sh is created to simplify the configuration of the makefile structure. The --prefix option may require some modification to take into account the location where the EPub-InkPlate source code has been put. The --prefix must point to the lib_freetype folder.

  5. The following commands are executed:

    $ cd freetype-2.10.4
    $ bash myconf.sh
    $ make
    $ make install

    This will have created several files in the folder lib_freetype.

  6. Edit file named lib_freetype/lib/pkgconfig/freetype2.pc and remove the entire line that contains harfbuzz reference.

  7. Voilà...

ESP-IDF configuration specifics

The EPub-InkPlate application requires some functionalities to be properly set up within the ESP-IDF. To do so, some parameters located in the sdkconfig file must be set accordingly. This must be done using the menuconfig application that is part of the ESP-IDF.

The following is not required to be done as the file sdkconfig.defaults contains the changes that will trigger the generation of the suitable sdkconfig.<project_name> file related to the project being compiled.

The current release of PlatformIO allow for editing the sdkconfig through the PlatformIO's Run Menuconfig command located in the Project Tasks.

The application will show a list of configuration aspects.

The following elements have been done (No need to do it again as they are defined in file sdkconfig.defaults):

The following is not configured through menuconfig:

In Memoriam

When I started this effort, I was aiming at supplying a tailored ebook reader for a friend of mine that has been impaired by a spinal cord injury for the last 13 years and a half. Reading books and looking at TV were the only activities she was able to do as she lost control of her body, from the neck down to the feet. After several years of physiotherapy, she was able to do some movement with her arms, without any control of her fingers. She was then able to push on buttons of an ebook reader with a lot of difficulties. I wanted to build a joystick-based interface to help her with any standard ebook reader but none of the commercially available readers allowed for this kind of integration.

On September 27th, 2020, we learned that she was diagnosed with the Covid-19 virus. She passed away during the night of October 1st.

I dedicate this effort to her. Claudette, my wife and I will always remember you!