Git Product home page Git Product logo

paperterminal's Introduction

PaperTerminal

Summary

This project provides a library to interact with the Waveshare E-Ink Displays written in OCaml. It is intended to run on a Raspberry Pi and interact with the IT8951 HAT via SPI. A future goal for this project is to provide executables which explore the usage of this library, some of which could be: a terminal, a VNC client, a kernel module to implement a graphics driver or a custom/adapted GUI library.

It is quite similar to PaperTTY(https://github.com/joukos/PaperTTY) which is implemented in Python and provides both a terminal and VNC client. As this is a personal hobby PaperTTY is superior in almost all aspects.

Structure

The source code is split into three directories:

  • lib: contains the library to interact with the display, more details below
  • bin: contains the executables which use the library, currently only contains the terminal emulator
  • tests: contains all the tests

The library is split into four layers, each of which is concerned with a specific abstraction:

  • Bus and bus.c/h: Implements the SPI interface with the IT8951
  • Command: Implements the commands defined by the IT8951 and memory/register access
  • Controller and State: Provides an interface to interact with the screen on a simplified level: It allows transmitting the buffer to the IT8951 and displaying it onto the E-Ink Display.
  • EPD and Bresenham: Provides facilities to quickly test the library, i.e. plotting dots and lines. This layer will perhaps be moved into the bin directory.

Dependencies

  • bcm2835 library
  • OCaml compiler
  • dune, ctypes, ctypes-foreign (see dune external-lib-deps $build_target)
  • utop for interactive usage

Building

Run either of the following commands. Root privileges are necessary to access the pins.

  • dune exec bin/term.exe for the terminal emulator
  • dune utop lib for interactive utop REPL with the library
  • dune test to run the tests specified in tests/dune

Additional Notes

My goal is to run this project on the Raspberry Pi 3A+. My distro of choice is Void Linux. Unfortunately Void does not have good support of the newer Pis and getting it to run involved some work. I chose to run U-Boot first to enable some flexibility in the future (Network boot, USB boot, independent layer below Linux which always works). This is in theory quite simple:

  • Flash the Linux image
  • Place the U-Boot image (see below) alongside the kernel in the /boot partition/directory
  • Append to config.txt:
    kernel=u-boot.img
    (the following are perhaps unnecessary)
    arm_64bit=1
    device_tree_address=0x100
    device_tree_end=0x8000\
  • Freeze the kernel and firmware as updates to them break the system via xbps-pkgdb -m hold rpi-firmware rpi-kernel

Be careful to gracefully shut down the Pi at all times as power loss corrupts the SD card (as indicated by the fsck after reboot)

Creating the U-Boot image

The mainline U-Boot repository has support for most Raspberry Pis and their features. The two main configuration options relevant here are:
CONFIG_BOOTARGS="root=/dev/mmcblk0p2 rw rootwait console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 smsc95xx.turbo_mode=N dwc_otg.lpm_enable=0 loglevel=4 elevator=noop"
and
CONFIG_BOOTCOMMAND="setenv fdtfile bcm2710-rpi-3-b-plus.dtb; mmc dev 0; fatload mmc 0:1 ${kernel_addr_r} kernel.img; fatload mmc 0:1 ${fdt_addr_r} ${fdtfile}; bootefi ${kernel_addr_r} ${fdt_addr_r}"\

paperterminal's People

Contributors

willenbrink avatar

Stargazers

 avatar  avatar  avatar

paperterminal's Issues

Respect modifiers in VCSA

The modifiers contained in the VCSA file describe color, which is also (probably) also used by vim for the visual mode.

Consider Rewrite of Driver in OCaml

Rewriting the driver in OCaml has the benefit of using only a single language. The performance impact of this should also be negligible because no weird pointer-arithmetic is used in C. The arrays used in C can also be translated to OCaml efficiently.

Implement sophisticated algorithm for redrawing

Currently the changes in the VCSA are fetched and a simple bounding box is updated on the screen. This can be improved by using multiple smaller boxes that encompass all the changes.
Before implementing this, the program should be profiled to ensure the best ratio between unnecessary redrawing and many inefficient tiny draws is found.

Use inotify or similar to prevent 100% usage

Currently the program loops over the file contents of the VCSA file, essentially busy-waiting for changes. This can be improved by using inotify and will also reduce the CPU-Usage.

Update to OCaml 4.07

Update to OCaml 4.07 (or at least 4.03) to get access to the improvements to stdlib and some packages (e.g. dune).
Raspbian only has OCaml 4.02 and opam in its repositories which should be enough to compile OCaml 4.07 or load it via opam but this did not work previously for some reason.

Polish the drawing algorithm

Currently the drawing algorithm results in weird artifacts. They seem benign but this should be adressed nonetheless at some point.
The position of the cursor can also be incorporated into the algorithm to show the most relevant information first.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.