Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lvgl: Add initial support for LVGL library #2951

Merged
merged 13 commits into from
May 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion .rat-excludes
Original file line number Diff line number Diff line change
Expand Up @@ -499,4 +499,5 @@ startup_stm32l073xx.s
# MK64F12 SDK - BSD License
MK64F12


# LVGL configuration file - MIT license
lv_conf.h
3 changes: 3 additions & 0 deletions .style_ignored_dirs
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,6 @@ fs/littlefs/include/littlefs/lfs.h
fs/littlefs/include/littlefs/lfs_util.h
fs/littlefs/src/lfs.c
fs/littlefs/src/lfs_util.c

# LVGL formated file
hw/drivers/display/lvgl/default/lv_conf.h
4 changes: 4 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -748,3 +748,7 @@ license. Bundled files are:
* fs/littlefs/DESIGN.md
* fs/littlefs/README.md
* fs/littlefs/SPEC.md

This product bundles part of lvgl, which is available under the MIT license.
Bundled files are:
* hw/drivers/display/lvgl/default/lv_conf.h
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:
101 changes: 101 additions & 0 deletions hw/drivers/display/lcd_itf/include/lcd_itf.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
/*
* 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.
*/

#ifndef LCD_ITF_H
#define LCD_ITF_H

#include <stdint.h>
#include <stddef.h>
#include <syscfg/syscfg.h>

#ifdef LCD_ITF_INCLUDE
#include LCD_ITF_INCLUDE
#endif

#ifndef LCD_CS_PIN_ACTIVE
#if MYNEWT_VAL(LCD_CS_PIN) >= 0
#define LCD_CS_PIN_ACTIVE() hal_gpio_write(MYNEWT_VAL(LCD_CS_PIN), 0)
#else
#define LCD_CS_PIN_ACTIVE()
#endif
#endif

#ifndef LCD_CS_PIN_INACTIVE
#if MYNEWT_VAL(LCD_CS_PIN) >= 0
#define LCD_CS_PIN_INACTIVE() hal_gpio_write(MYNEWT_VAL(LCD_CS_PIN), 1)
#else
#define LCD_CS_PIN_INACTIVE()
#endif
#endif

#ifndef LCD_DC_PIN_DATA
#define LCD_DC_PIN_DATA() hal_gpio_write(MYNEWT_VAL(LCD_DC_PIN), 1)
#endif

#ifndef LCD_DC_PIN_COMMAND
#define LCD_DC_PIN_COMMAND() hal_gpio_write(MYNEWT_VAL(LCD_DC_PIN), 0)
#endif

#ifndef LCD_RESET_PIN_INACTIVE
#if MYNEWT_VAL(LCD_RESET_PIN) >= 0
#define LCD_RESET_PIN_INACTIVE() hal_gpio_write(MYNEWT_VAL(LCD_RESET_PIN), 1)
#else
#define LCD_RESET_PIN_INACTIVE()
#endif
#endif

#ifndef LCD_RESET_PIN_ACTIVE
#if MYNEWT_VAL(LCD_RESET_PIN) >= 0
#define LCD_RESET_PIN_ACTIVE() hal_gpio_write(MYNEWT_VAL(LCD_RESET_PIN), 0)
#else
#define LCD_RESET_PIN_ACTIVE()
#endif
#endif

#define LCD_SEQUENCE_DELAY_REQ 0xFE
#define LCD_SEQUENCE_DELAY_US_REQ 0xFD
#define LCD_SEQUENCE_LCD_CS_ACTIVATE_REQ 0xFC
#define LCD_SEQUENCE_LCD_CS_INACTIVATE_REQ 0xFB
#define LCD_SEQUENCE_LCD_DC_DATA_REQ 0xFA
#define LCD_SEQUENCE_LCD_DC_COMMAND_REQ 0xF9
#define LCD_SEQUENCE_LCD_RESET_ACTIVATE_REQ 0xF8
#define LCD_SEQUENCE_LCD_RESET_INACTIVATE_REQ 0xF7
#define LCD_SEQUENCE_GPIO_REQ 0xF6
#define LCD_SEQUENCE(name) \
static const uint8_t name[] = {
#define LCD_SEQUENCE_DELAY(n) LCD_SEQUENCE_DELAY_REQ, (uint8_t)n, ((uint8_t)(n >> 8))
#define LCD_SEQUENCE_DELAY_US(n) LCD_SEQUENCE_DELAY_US_REQ, (uint8_t)n, ((uint8_t)(n >> 8))
#define LCD_SEQUENCE_GPIO(pin, val) LCD_SEQUENCE_GPIO_REQ, n, val
#define LCD_SEQUENCE_LCD_CS_ACTIVATE() LCD_SEQUENCE_LCD_CS_ACTIVATE_REQ
#define LCD_SEQUENCE_LCD_CS_INACTIVATE() LCD_SEQUENCE_LCD_CS_INACTIVATE_REQ
#define LCD_SEQUENCE_LCD_DC_DATA() LCD_SEQUENCE_LCD_DC_DATA_REQ
#define LCD_SEQUENCE_LCD_DC_COMMAND() LCD_SEQUENCE_LCD_DC_COMMAND_REQ
#define LCD_SEQUENCE_LCD_RESET_ACTIVATE() LCD_SEQUENCE_LCD_RESET_ACTIVATE_REQ
#define LCD_SEQUENCE_LCD_RESET_INACTIVATE() LCD_SEQUENCE_LCD_RESET_INACTIVATE_REQ
#define LCD_SEQUENCE_END 0xFF };

void lcd_command_sequence(const uint8_t *cmds);

void lcd_itf_init(void);

/* Function implemented by LCD interface driver */
void lcd_ift_write_cmd(const uint8_t *cmd, int cmd_length);
void lcd_itf_write_color_data(const void *data, size_t size);

#endif /* LCD_ITF_H */
28 changes: 28 additions & 0 deletions hw/drivers/display/lcd_itf/itf_8080/pkg.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#
# 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: hw/drivers/display/lcd_itf/itf_8080
pkg.description: LCD Standard 8080 parallel interface
pkg.keywords:
- display

pkg.apis:
- lcd_interface

pkg.deps: