Skip to content

Commit

Permalink
apps: Add LVGL demos
Browse files Browse the repository at this point in the history
This adds application that allows to run LVGL provided
demos. Several demos can be selected by LVGL_DEMO syscfg value.
  • Loading branch information
kasjer committed Apr 25, 2023
1 parent 84c3afd commit fb7fc68
Show file tree
Hide file tree
Showing 4 changed files with 208 additions and 0 deletions.
91 changes: 91 additions & 0 deletions apps/lvgl/demo/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<!--
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
-->

# LVGL demo

## Overview

This application allows to run LVGL demos in mynewt environment.
Following LVGL demos can be selected in the syscfg.yml of the target by settings **LVGL_DEMO** variable to one of the following:
- benchmark
- flex_layout
- keypad_encoder
- music
- stress
- widgets

#### Several displays are supported:
- ILI9341 (240x320)
- ILI9486 (320x480)
- ST7735S (128x160)
- ST7789 (240x320)
- GC9A01 (240x240)

#### Two touch screen controllers:
- XPT2046
- STMPE610

### Example display boards with configuration
- Adafruit 2.8" https://www.adafruit.com/product/1651
suscfg.yml values
```yaml
LVGL_ILI9341: 1
LVGL_STMPE610: 1

LCD_ITF: spi
LCD_SPI_DEV_NAME: '"spi0"'
LCD_SPI_FREQ: 16000
LCD_CS_PIN: ARDUINO_PIN_D10
LCD_DC_PIN: ARDUINO_PIN_D9
LCD_BL_PIN: ARDUINO_PIN_D3
LCD_RESET_PIN: -1

STMPE610_SPI_DEV_NAME: '"spi0"'
STMPE610_SPI_CS_PIN: ARDUINO_PIN_D8
STMPE610_SPI_FREQ: 1200

```
- Waveshare 3.5" https://www.waveshare.com/3.5inch-tft-touch-shield.htm
suscfg.yml values
```yaml
LVGL_ILI9486: 1
LVGL_XPT2046: 1

LCD_ITF: spi
LCD_SPI_DEV_NAME: '"spi0"'
LCD_SPI_WITH_SHIFT_REGISTER: 1
LCD_SPI_FREQ: 32000
LCD_CS_PIN: ARDUINO_PIN_D10
LCD_DC_PIN: ARDUINO_PIN_D7
LCD_BL_PIN: ARDUINO_PIN_D9
LCD_RESET_PIN: ARDUINO_PIN_D8

XPT2046_SPI_DEV_NAME: '"spi0"'
XPT2046_SPI_FREQ: 1200
XPT2046_SPI_CS_PIN: ARDUINO_PIN_D4
XPT2046_INT_PIN: ARDUINO_PIN_D3
XPT2046_XY_SWAP: 1
XPT2046_X_INV: 1
XPT2046_Y_INV: 1
XPT2046_MIN_X: 300
XPT2046_MIN_Y: 300

```
32 changes: 32 additions & 0 deletions apps/lvgl/demo/pkg.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#

pkg.name: apps/lvgl/demo
pkg.type: app
pkg.description: Application that runs LVGL demos.
pkg.author: "Apache Mynewt <dev@mynewt.apache.org>"
pkg.homepage: "http://mynewt.apache.org/"
pkg.keywords:

pkg.deps:
- "@apache-mynewt-core/sys/log"
- "@apache-mynewt-core/sys/console"
- "@apache-mynewt-core/hw/drivers/display/lvgl"

pkg.cflags:
54 changes: 54 additions & 0 deletions apps/lvgl/demo/src/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

#include <assert.h>

#include <sysinit/sysinit.h>
#include <os/os.h>
#include <demos/benchmark/lv_demo_benchmark.h>
#include <demos/music/lv_demo_music.h>
#include <demos/stress/lv_demo_stress.h>
#include <demos/widgets/lv_demo_widgets.h>
#include <examples/widgets/lv_example_widgets.h>
#include "hal/hal_gpio.h"
#include <console/console.h>

int
main(int argc, char **argv)
{
sysinit();

if (MYNEWT_VAL_CHOICE(LVGL_DEMO, benchmark)) {
lv_demo_benchmark_run_scene(31);
} else if (MYNEWT_VAL_CHOICE(LVGL_DEMO, keypad_encoder)) {
lv_demo_keypad_encoder();
} else if (MYNEWT_VAL_CHOICE(LVGL_DEMO, music)) {
lv_demo_music();
} else if (MYNEWT_VAL_CHOICE(LVGL_DEMO, stress)) {
lv_demo_stress();
} else if (MYNEWT_VAL_CHOICE(LVGL_DEMO, widgets)) {
lv_demo_widgets();
}

while (1) {
os_eventq_run(os_eventq_dflt_get());
}
return 0;
}

31 changes: 31 additions & 0 deletions apps/lvgl/demo/syscfg.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#

syscfg.defs:
LVGL_DEMO:
description: LVGL demo to run.
choices:
- benchmark
- flex_layout
- keypad_encoder
- music
- stress
- widgets
value: widgets

syscfg.vals:

0 comments on commit fb7fc68

Please sign in to comment.