|
| 1 | +#!/usr/bin/env python3 |
| 2 | +# -*- coding: utf-8 -*- |
| 3 | +# |
| 4 | +# Copyright (c) 2020, Raphael Lehmann |
| 5 | +# |
| 6 | +# This file is part of the modm project. |
| 7 | +# |
| 8 | +# This Source Code Form is subject to the terms of the Mozilla Public |
| 9 | +# License, v. 2.0. If a copy of the MPL was not distributed with this |
| 10 | +# file, You can obtain one at http://mozilla.org/MPL/2.0/. |
| 11 | +# ----------------------------------------------------------------------------- |
| 12 | + |
| 13 | +def init(module): |
| 14 | + module.name = ":lvgl" |
| 15 | + module.description = """ |
| 16 | +# LVGL graphics library |
| 17 | +
|
| 18 | +LVGL is a free and open-source graphics library providing everything you need |
| 19 | +to create embedded GUI with easy-to-use graphical elements, beautiful visual effects |
| 20 | +and low memory footprint. |
| 21 | +
|
| 22 | +- https://lvgl.io/ |
| 23 | +- https://github.com/lvgl/lvgl |
| 24 | +
|
| 25 | +
|
| 26 | +## Configuration |
| 27 | +
|
| 28 | +LVGL defines defaults for all it's configuration settings, which you can find in |
| 29 | +the [configuration template][conf_template]. |
| 30 | +
|
| 31 | +This module generates a `lv_conf.h` file to define the options necessary for |
| 32 | +integration with modm which are: |
| 33 | +
|
| 34 | +- `LV_MEM_CUSTOM = 1`: Heap is provided by the `modm:platform:heap` module. |
| 35 | +- `LV_TICK_CUSTOM = 1`: Tick is implemented via the `modm:platform:clock` module. |
| 36 | +- `LV_LOG_PRINTF = 0`: logging is redirected to `MODM_LOG_*` if the |
| 37 | + `modm:debug` module is included and `LV_USE_LOG = 1`. |
| 38 | +- `typedef int16_t lv_coord_t;`: Hardcoded choice for now. |
| 39 | +
|
| 40 | +To add your own configuration you can create a `<lv_conf_local.h>` file which |
| 41 | +will automatically be included at the *beginning* of our `lv_conf.h`. |
| 42 | +
|
| 43 | +Example `<lv_conf_local.h>` configuration: |
| 44 | +
|
| 45 | +```c |
| 46 | +// Maximal resolutions |
| 47 | +#define LV_HOR_RES_MAX 240 |
| 48 | +#define LV_VER_RES_MAX 320 |
| 49 | +#define LV_DPI 200 |
| 50 | +
|
| 51 | +/* Color depth: |
| 52 | + * - 1: 1 byte per pixel |
| 53 | + * - 8: RGB332 |
| 54 | + * - 16: RGB565 |
| 55 | + * - 32: ARGB8888 |
| 56 | + */ |
| 57 | +#define LV_COLOR_DEPTH 16 |
| 58 | +
|
| 59 | +// Enable logging at INFO level |
| 60 | +#define LV_USE_LOG 1 |
| 61 | +#define LV_LOG_LEVEL LV_LOG_LEVEL_INFO |
| 62 | +
|
| 63 | +// Disable anti-aliasing |
| 64 | +#define LV_ANTIALIAS 0 |
| 65 | +``` |
| 66 | +
|
| 67 | +[conf_template]: https://github.com/lvgl/lvgl/blob/master/lv_conf_template.h |
| 68 | +""" |
| 69 | + |
| 70 | +def prepare(module, options): |
| 71 | + module.depends(":architecture:clock") |
| 72 | + if options[":target"].identifier.platform != "hosted": |
| 73 | + module.depends(":platform:heap") |
| 74 | + |
| 75 | + return True |
| 76 | + |
| 77 | +def build(env): |
| 78 | + env.collect(":build:path.include", "modm/ext/lvgl") |
| 79 | + env.outbasepath = "modm/ext/lvgl" |
| 80 | + |
| 81 | + env.copy("lvgl/lvgl.h") |
| 82 | + env.template("lv_conf.h.in") |
| 83 | + env.copy("lvgl/src") |
| 84 | + env.copy("lv_modm_clock.h") |
| 85 | + env.copy("lv_modm_clock.cpp") |
| 86 | + |
| 87 | + if env.has_module(":debug"): |
| 88 | + env.copy("lv_modm_logging.cpp") |
0 commit comments