Simple Windowing System for the M5Paper

Related tags

CLI M5PaperUI
Overview

M5PaperUI

This project is a proof-of-concept on how to build a UI framework for the M5Paper device. The factory M5Paper device comes pre-loaded with an application called "FactoryTest" that shows very nicely how beautiful applications can look like on the device.

Initially, I tried to extend the code of the application to build my own applications, but the code was not badly documented and did not feel very easy to use and extend.

Since I wanted to understand better how to build similarity beautiful, but better designed applications, I started on this project by trying to apply well-known patterns that I've seen in other UI frameworks to the M5Paper.

The main difference I found between traditional UI frameworks and building a framework for the M5Paper is that the E-Paper display behaves differently to update the screen.

Usually, you would expect that on every loop iteration the screen is re-drawn and this is done as often as the display refreshes. In contrast, refreshing the e-paper display is an expensive operation, and issuing a refresh is only done upon state changes. Furthermore, it is possible to refresh only a subset of the whole screen much faster than the whole screen.

main scren

The goal?

Provide a good sample library with lot's of documentation in the code that makes it easier to learn about how to build UIs for e-paper displays.

What now?

If you like the approach, take the code and fork it, extend it or built a better version. If I ever figure out how to make this a platformio library, I'll try to push it there.

Architecture

On top of the stack is the WidgetContext, it keeps track of all known object and its Draw() method should be invoked on every loop iteration.

Drawable objects are grouped in a Frame. A Frame contains a collection of Widgets and must be registered in the WidgetContext before the Frame is drawn for the first time. As long as a Frame is registered, its state is available on subsequent reuse. All Widgets drawn on a Frame can share the same canvas and delegate refreshing the canvas to the Frame. The upside is fewer refresh events on the screen, but the downside is that the Frame can only be updated in one operation rather than performing a partial refresh of the screen.

The general idea of the refresh loop is outlined below. The key principle is that even though Frame::Draw() or Widget::Draw() are executed on every application loop iteration, they will only issue an actual event to the device when the view is marked as dirty.

Loop:
  -> WidgetContext::Draw
    -> for Frame f in view_stack:
        -> f::Draw()
        -> for Widget w in f::widgets:
          -> w::Draw()

A Widget is the smallest drawable unit, a widget comes with traditional properties like WidgetStyle, background color, text size etc. By default, the Widget shares the canvas of the parent Frame. However, it is possible to make the Widget use a separate canvas. One example for this use case is the implementation of the WButton. The button has two states: normal and pushed. If the button is in the normal state the regular canvas is drawn, if the button is pushed a secondary canvas is pushed to the screen.

Current Sample Applications

Right now, the following sample applications are part of the repository.

  • Paint - A simple widget that can be embedded in any Frame and lets the user draw with their finger on the screen. In addition to drawing the line, the size of the line depends on the size of the touch events. Change the positioning of your finger on the screen to draw bigger or smaller arcs.

    Paint App

  • Tic Tac Toe - Very simple implementation of the well-known game. The main idea behind this game is to show how to combine using the canvas of the parent frame together with individual other frames during partial refreshes of the screen.

    Tic Tac Toe

You might also like...
Simple command line tool that processes image files using the FidelityFX Super Resolution (FSR) or Contrast Adaptive Sharpening (CAS) shader systems.

Simple command line tool that processes image files using the FidelityFX Super Resolution (FSR) or Contrast Adaptive Sharpening (CAS) shader systems.

A simple header-only C++ argument parser library. Supposed to be flexible and powerful, and attempts to be compatible with the functionality of the Python standard argparse library (though not necessarily the API).

args Note that this library is essentially in maintenance mode. I haven't had the time to work on it or give it the love that it deserves. I'm not add

⛳ Simple, extensible, header-only C++17 argument parser released into the public domain.

⛳ flags Simple, extensible, header-only C++17 argument parser released into the public domain. why requirements api get get (with default value) posit

Simple, command line based player toolkit for the Ironsworn tabletop RPG
Simple, command line based player toolkit for the Ironsworn tabletop RPG

isscrolls - Command line based player toolkit for the Ironsworn tabletop RPG isscrolls is a simple toolkit for players of the Ironsworn tabletop RPG.

Simple Unix Terminal Football Manager-like game.

Superleage 2020/2021 It is a "work in progress" simple game based on some mechanics of Football Manager. The game is in a very early stage of Developm

My customized version of the Simple Terminal (st) by suckless.org
My customized version of the Simple Terminal (st) by suckless.org

st This is my customized version of Simple Terminal (st) by suckless.org . There are only three patches applied to this software, alpha, scrollback, a

Simple command line utilities for extracting data from Fallout 4 and 76 files

fo76utils Simple command line utilities for extracting data from Fallout 4 and 76 files. baunpack - list the contents of, or extract from .BA2 archive

A simple command line application in order to create new Code workspaces.

mkcws Summary A simple command line application in order to create new Code workspaces. License This project's license is GPL 2. The whole license tex

Luke's build of st - the simple (suckless) terminal

Luke's build of st - the simple (suckless) terminal The suckless terminal (st) with some additional features that make it literally the best terminal

Owner
Martin Grund
Systems and stuff
Martin Grund
Operating system in Terminal written in pure C++

terminal-OS Operating system in Terminal written in pure C++ Features: Mouse tracking Colorful print Window move/resize Hide windows to Taskbar Apps:

Egor Zheltkevich 22 Dec 5, 2022
C++ Library for pulling system and hardware information, without hitting the command line.

infoware C++ Library for pulling system and hardware information, without hitting the command line. Requirements No non-built-in ones by default. Some

The Phantom Derpstorm 323 Dec 23, 2022
A simple header-only C++ argument parser library. Supposed to be flexible and powerful, and attempts to be compatible with the functionality of the Python standard argparse library (though not necessarily the API).

args Note that this library is essentially in maintenance mode. I haven't had the time to work on it or give it the love that it deserves. I'm not add

Taylor C. Richberger 1.1k Jan 4, 2023
A simple to use, composable, command line parser for C++ 11 and beyond

Clara v1.1.5 !! This repository is unmaintained. Go here for a fork that is somewhat maintained. !! A simple to use, composable, command line parser f

Catch Org 648 Dec 27, 2022
CLI11 is a command line parser for C++11 and beyond that provides a rich feature set with a simple and intuitive interface.

CLI11: Command line parser for C++11 What's new • Documentation • API Reference CLI11 is a command line parser for C++11 and beyond that provides a ri

null 2.4k Dec 30, 2022
A simple to use, composable, command line parser for C++ 11 and beyond

Lyra A simple to use, composing, header only, command line arguments parser for C++ 11 and beyond. Obtain License Standards Stats Tests License Distri

Build Frameworks Group 388 Dec 22, 2022
a simple to use linux terminal

a simple to use linux terminal

notaweeb 7 Feb 17, 2022
Simple benchmark for terminal output

TermBench This is a simple timing utility you can use to see how slow your terminal program is at parsing escape-sequence-coded color output. It can b

Casey Muratori 174 Dec 4, 2022
White-Stuff - a simple xor encoder/decoder for your shellcode

White-Stuff - a simple xor encoder/decoder for your shellcode

null 14 Nov 9, 2022
LSH is a simple implementation of a shell in C

It demonstrates the basics of how a shell works. That is: read, parse, fork, exec, and wait. Since its purpose is demonstration (not feature completeness or even fitness for casual use), it has many limitations

Stephen Brennan 1.2k Dec 31, 2022