Added more info in README. Updated comments

This commit is contained in:
nedko 2025-12-15 14:49:33 +02:00
parent 8e276ab2ab
commit 3d45fc89fc
4 changed files with 27 additions and 8 deletions

View File

@ -1,22 +1,38 @@
# What is this
A utility which can be used to create custom images for TRMNL devices via code
# How to write new visual stuff
1. Inherit from `Widget` and then do your magic inside your own class.
2. Add your widget builder in `main.cpp` inside `init_builders`.
3. Write your config file. Either named `config.json` or added as the first command line parameter.
4. ???
5. Profit
# How to build
**NOTE: Tested on Ubuntu 24.04.**
# ImageMagick commands
You will need the following packages: `build-essential` `libsdl2-dev` `libsdl2-image-dev` `libsdl2-ttf-dev` `imagemagick`
Just run `make` and an executable called `trmnl_sdl` should be produced.
# How to use
1. You will need to write a JSON config file.
It can either be named `config.json` or you will need to pass it as the first command line parameter to the executable.
An example structure of the config file can be found in `config_example.json`.
You can find more info on the available Widgets and their parameters at the end of this file.
2. Run the executable
3. Convert the image to a suitable format via an ImageMagick command from below.
# ImageMagick commands to prepare image for TRMNL device
### Convert image without dithering
`convert trmnl.png -monochrome -colors 2 -depth 1 -strip png:output.png`
### Convert image with dithering
`convert trmnl.png -dither FloydSteinberg -remap pattern:gray50 -depth 1 -strip png:output.png`
### Resize image to fit with dithering
`convert image.png -resize 800x480 -background white -compose Copy -gravity center -extent 800x480 -dither FloydSteinberg -remap pattern:gray50 -depth 1 -strip png:output.png`
# How to write new visual stuff
1. Inherit from `Widget` and then do your magic inside your own class.
2. Add your widget builder in `main.cpp` inside `init_builders`.
3. Rebuild the executable.
# Notes
json.hpp from nlohmann/json v3.11.2
json.hpp from [nlohmann/json](https://github.com/nlohmann/json) v3.11.2
# List of special types
### color

View File

@ -5,6 +5,7 @@
#include "../json.hpp"
#include <memory>
// Base Widget class for the whole Widget system
class Widget
{
protected:

View File

@ -3,6 +3,7 @@
#include "Widget.h"
// Renders a rectangle with optional rounded corners using either fill or internal stroke
class WidgetRect : public Widget
{
protected:

View File

@ -8,6 +8,7 @@
#include "../sdl_helpers.h"
// Renders text within a specified box
class WidgetText : public Widget
{
protected: