Skip to content

Commit

Permalink
Mention sample program execution with Linux framebuffer and input system
Browse files Browse the repository at this point in the history
  • Loading branch information
shengwen-tw committed Oct 2, 2024
1 parent d406326 commit f27a255
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 7 deletions.
34 changes: 29 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,30 +60,54 @@ benefiting the entire application stack.

## Build and Verify

### Prerequisites

`Mado` is built with a minimalist design in mind. However, its verification
relies on certain third-party packages for full functionality and access to all
its features. To ensure proper operation, the development environment should
have the [SDL2 library](https://www.libsdl.org/), [libjpeg](https://www.ijg.org/), and [libpng](https://github.com/pnggroup/libpng) installed.
its features. We encourage the development environment to be installed with all optional
packages, including [libjpeg](https://www.ijg.org/), [libpng](https://github.com/pnggroup/libpng),
and the [SDL2 library](https://www.libsdl.org/).
* macOS: `brew install sdl2 jpeg libpng`
* Ubuntu Linux / Debian: `sudo apt install libsdl2-dev libjpeg-dev libpng-dev`

Configure via [Kconfiglib](https://pypi.org/project/kconfiglib/)
### Configuration

Configure via [Kconfiglib](https://pypi.org/project/kconfiglib/), you should select either SDL
video output or the Linux framebuffer.
```shell
$ make config
```

Build the library and demo program.
### Build and execution

Build the library and demo program:

```shell
$ make
```

Run sample `Mado` program:
To run demo program with SDL backend:

```shell
$ ./demo-sdl
```

Once the window appears, you should be able to move the windows and interact with the widgets.

To run demo program with the Linux framebuffer backend:

```shell
$ sudo ./demo-fbdev
```

Normal users don't have access to `/dev/fb0` so require `sudo`. Alternatively, you can add the user to the video group to avoid typing `sudo` every time:

```shell
$ sudo usermod -a -G video $USERNAME
```

In addition, the framebuffer device can be assigned via the environment variable `FRAMEBUFFER`.

## License

`Mado` is available under a MIT-style license, permitting liberal commercial use.
Expand Down
4 changes: 2 additions & 2 deletions backend/fbdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,9 @@ static void _twin_fbdev_put_span(twin_coord_t left,

twin_coord_t width = right - left;
off_t off = top * screen->width + left;
uint32_t *src = pixels;
uint32_t *dest =
(uint32_t *) ((uintptr_t) tx->fb_base + (off * sizeof(uint32_t)));
memcpy(dest, src, width * sizeof(uint32_t));
memcpy(dest, pixels, width * sizeof(uint32_t));
}

static void twin_fbdev_get_screen_size(twin_fbdev_t *tx,
Expand Down Expand Up @@ -159,6 +158,7 @@ static bool twin_vt_setup(twin_fbdev_t *tx)
{
/* Open VT0 to inquire information */
if ((tx->vt_fd = twin_vt_open(0)) < -1) {
log_error("Failed to open VT0");
return false;
}

Expand Down

0 comments on commit f27a255

Please sign in to comment.