Skip to content

Commit 0f4c997

Browse files
authored
Merge pull request #663 from facchinm/stm32h7_video_lib
Refactor Video Library for STM32H7 boards
2 parents 10b0d02 + 880f9bb commit 0f4c997

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+3810
-12304
lines changed

.github/workflows/compile-examples.yml

+6-3
Original file line numberDiff line numberDiff line change
@@ -57,20 +57,23 @@ jobs:
5757
fqbn: arduino:mbed:envie_m7:target_core=cm4
5858
additional-libraries: |
5959
- name: lvgl
60+
version: 8.3.5
61+
- name: ArduinoGraphics
6062
additional-sketch-paths: |
6163
- libraries/doom
6264
- libraries/KernelDebug
6365
- libraries/Portenta_SDCARD
6466
- libraries/Portenta_SDRAM
65-
- libraries/Portenta_Video
67+
- libraries/Arduino_H7_Video
6668
- libraries/RPC
6769
- board:
6870
fqbn: arduino:mbed:envie_m7
6971
additional-libraries: |
7072
- name: lvgl
71-
version: 7.11.0
73+
version: 8.3.5
7274
- name: MicroNMEA
7375
- name: ArduinoBLE
76+
- name: ArduinoGraphics
7477
additional-sketch-paths: |
7578
- libraries/PDM
7679
- libraries/doom
@@ -82,7 +85,7 @@ jobs:
8285
- libraries/Portenta_SDCARD
8386
- libraries/Portenta_SDRAM
8487
- libraries/STM32H747_System
85-
- libraries/Portenta_Video
88+
- libraries/Arduino_H7_Video
8689
- libraries/RPC
8790
- libraries/ThreadDebug
8891
- libraries/USBHID

libraries/Arduino_H7_Video/README.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# 📺 Arduino H7 Video Library
2+
3+
The Arduino H7 Video Library manages the video output on Arduino boards based on the STM32H7 microcontroller (Portenta H7, GIGA R1 WiFi), providing functions to draw on the screen and integrate third-party video libraries such as [LVGL](https://lvgl.io/) and [emWin](https://www.segger.com/products/user-interface/emwin/).
4+
5+
📖 For more information about this library, please refer to the documentation [here](./docs/).
+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Arduino H7 Video Library
2+
3+
[![License](https://img.shields.io/badge/License-LGPLv3-blue.svg)]()
4+
5+
The Arduino H7 Video library is a C++ library designed to handle the video output of Arduino boards based on the STM32H7 microcontroller with DSI video interface. DSI stands for Display Serial Interface, which is a serial interface used to connect a display to the microcontroller.
6+
7+
This library is based on the graphics primitives of the [ArduinoGraphics](https://github.com/arduino-libraries/ArduinoGraphics) library and currently supports the Arduino Portenta H7 and Arduino Giga R1 WiFi boards. The library offers two modes of operation for the Portenta H7 board: you can connect the display to the video output via a USB Type-C connection or use the Giga Display Shield. For the Giga R1 board, only the Giga Display Shield is supported.
8+
9+
The library allows you to draw graphics elements on the screen using simple graphics primitives such as lines, circles, images, etc. Additionally, you can integrate third-party graphic libraries like [LVGL](https://lvgl.io/) and [emWin](https://www.segger.com/products/user-interface/emwin/) to achieve more complex GUI.
10+
11+
The library provides methods for initializing the video controller, clearing the screen, and drawing basic graphics elements.
12+
13+
## Features
14+
15+
- Handles video output of Arduino boards based on the STM32H7 microcontroller with DSI video interface
16+
- Allows drawing graphics elements using simple primitives like lines, circles, images, etc.
17+
- Integration of third-party graphic libraries like LVGL and emWin for more complex GUI
18+
19+
## Usage
20+
21+
To use this library, you must have a supported Arduino board and a display. Once you have connected the display to the board, you can include the display library in your Arduino sketch and use its functions to draw graphic elements on the screen.
22+
Here is a minimal example for the Arduino GIGA R1 WiFi with Giga Display Shield:
23+
24+
```cpp
25+
#include "Arduino_H7_Video.h"
26+
#include "ArduinoGraphics.h"
27+
28+
Arduino_H7_Video Display(800, 480, GigaDisplayShield);
29+
30+
void setup() {
31+
Display.begin();
32+
33+
// Draw a green rectangle that covers the entire display
34+
Display.beginDraw();
35+
Display.clear();
36+
Display.noStroke();
37+
Display.fill(0, 255, 0);
38+
Display.rect(0, 0, Display.width(), Display.height());
39+
Display.endDraw();
40+
}
41+
42+
void loop() { }
43+
```
44+
## Examples
45+
46+
- **[ArduinoLogo](../examples/ArduinoLogo):** This example demonstrates how to display an Arduino logo image on the screen.
47+
- **[ArduinoLogoDrawing](../examples/ArduinoLogoDrawing):** This example demonstrates how to draw an Arduino logo image using graphics primitives (line, circle, rect, etc.).
48+
- **[LVGLDemo](../examples/LVGLDemo):** This example demonstrates how to create a graphical user interface (GUI) using the LVGL library. It includes the [Arduino_GigaDisplayTouch](https://github.com/arduino-libraries/Arduino_GigaDisplayTouch/) library to handle touch events.
49+
50+
## API
51+
52+
The API documentation can be found [here](./api.md).
53+
54+
## License
55+
56+
This library is released under the [LGPLv3 license]().
+117
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
# Summary
2+
3+
Members | Descriptions
4+
--------------------------------|---------------------------------------------
5+
`class` [`Arduino_H7_Video`](#class-arduino_h7_video) | The main class for managing the video controller and the display.
6+
7+
# class [`Arduino_H7_Video`](#class-arduino_h7_video)
8+
The main class for managing the video controller and the display.
9+
10+
## Summary
11+
12+
| Members | Descriptions |
13+
|-------------------------------------------------------------|---------------------------------------------|
14+
| `public ` [`Arduino_H7_Video`](#public-arduino_h7_videoint-width-int-height-h7displayshield-shield) | Construct a new Arduino_H7_Video object with the specified width, height, and display shield. |
15+
| `public int` [`begin`](#public-int-begin) | Initialize the video controller and display. |
16+
| `public void` [`end`](#public-void-end) | De-initialize the video controller and display. |
17+
| `public int` [`width`](#public-int-width) | Get the width of the display. |
18+
| `public int` [`height`](#public-int-height) | Get the height of the display. |
19+
| `public bool` [`isRotated`](#public-bool-isrotated) | Check if the display is rotated. |
20+
| `public void` [`clear`](#public-void-clear) | Clear the display. |
21+
| `public void` [`beginDraw`](#public-void-begindraw) | Begin drawing operations on the display. |
22+
| `public void` [`endDraw`](#public-void-enddraw) | End drawing operations on the display. |
23+
| `public void` [`set`](#public-void-setint-x-int-y-uint8_t-r-uint8_t-g-uint8_t-b) | Set the color of the pixel at the specified coordinates. |
24+
25+
> *Note: For all drawing functions, refer to the documentation of the [`ArduinoGraphics`](https://reference.arduino.cc/reference/en/libraries/arduinographics/) library.*
26+
27+
## Members
28+
29+
### `public ` [`Arduino_H7_Video`](#)`(int width, int height, H7DisplayShield &shield)`
30+
31+
Construct a new Arduino_H7_Video object with the specified width, height, and display shield.
32+
33+
#### Parameters
34+
- `width`: The width of the display.
35+
- `height`: The height of the display.
36+
- `shield`: The display shield used.
37+
- *GigaDisplayShield*: Giga Display Shield
38+
- *USBCVideo*: Display attach to the USB-C port
39+
40+
---
41+
42+
### `public int` [`begin`](#)`()`
43+
44+
Initialize the video controller and display.
45+
46+
#### Returns
47+
`int`: 0 if initialization is successful, otherwise an error code.
48+
49+
---
50+
51+
### `public void` [`end`](#)`()`
52+
53+
De-initialize the video controller and display.
54+
55+
---
56+
57+
### `public int` [`width`](#)`()`
58+
59+
Get the width of the display.
60+
61+
#### Returns
62+
`int`: The width of the display.
63+
64+
---
65+
66+
### `public int` [`height`](#)`()`
67+
68+
Get the height of the display.
69+
70+
#### Returns
71+
`int`: The height of the display.
72+
73+
---
74+
75+
### `public bool` [`isRotated`](#)`()`
76+
77+
Check if the display is rotated.
78+
79+
#### Returns
80+
`bool`: True if the display is rotated, false otherwise.
81+
82+
---
83+
84+
### `public void` [`clear`](#)`()`
85+
86+
Clear the display.
87+
88+
---
89+
90+
### `public void` [`beginDraw`](#)`()`
91+
92+
Begin drawing operations on the display.
93+
94+
---
95+
96+
### `public void` [`endDraw`](#)`()`
97+
98+
End drawing operations on the display.
99+
100+
---
101+
102+
### `public void` [`set`](#)`(int x, int y, uint8_t r, uint8_t g, uint8_t b)`
103+
104+
Set the color of the pixel at the specified coordinates.
105+
106+
#### Parameters
107+
- `x`: The x-coordinate of the pixel.
108+
- `y`: The y-coordinate of the pixel.
109+
- `r`: The red component of the color.
110+
- `g`: The green component of the color.
111+
- `b`: The blue component of the color.
112+
113+
---
114+
115+
> *Note: For detailed information on drawing functions, please refer to the documentation of the [`ArduinoGraphics`](https://reference.arduino.cc/reference/en/libraries/arduinographics/) library.*
116+
117+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
ArduinoLogo
3+
4+
created 17 Apr 2023
5+
by Leonardo Cavagnis
6+
*/
7+
8+
#include "Arduino_H7_Video.h"
9+
#include "ArduinoGraphics.h"
10+
11+
#include "img_arduinologo.h"
12+
// Alternatively, any raw RGB565 image can be included on demand using this macro
13+
// Online image converter: https://lvgl.io/tools/imageconverter (Output format: Binary RGB565)
14+
/*
15+
#define INCBIN_PREFIX
16+
#include "incbin.h"
17+
INCBIN(test, "/home/user/Downloads/test.bin");
18+
*/
19+
20+
Arduino_H7_Video Display(800, 480, GigaDisplayShield);
21+
//Arduino_H7_Video Display(1024, 768, USBCVideo);
22+
23+
Image img_arduinologo(ENCODING_RGB16, (uint8_t *) texture_raw, 300, 300);
24+
25+
void setup() {
26+
Display.begin();
27+
28+
Display.beginDraw();
29+
Display.image(img_arduinologo, (Display.width() - img_arduinologo.width())/2, (Display.height() - img_arduinologo.height())/2);
30+
Display.endDraw();
31+
}
32+
33+
void loop() { }
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
ArduinoLogoDrawing
3+
4+
created 17 Apr 2023
5+
by Leonardo Cavagnis
6+
*/
7+
8+
#include "Arduino_H7_Video.h"
9+
#include "ArduinoGraphics.h"
10+
11+
Arduino_H7_Video Display(800, 480, GigaDisplayShield);
12+
//Arduino_H7_Video Display(1024, 768, USBCVideo);
13+
14+
void setup() {
15+
Display.begin();
16+
17+
Display.beginDraw();
18+
Display.background(255, 255, 255);
19+
Display.clear();
20+
Display.fill(0x008184);
21+
Display.circle(Display.width()/2, Display.height()/2, 300);
22+
Display.stroke(255, 255, 255);
23+
Display.noFill();
24+
for (int i=0; i<30; i++) {
25+
Display.circle((Display.width()/2)-55+5, Display.height()/2, 110-i);
26+
Display.circle((Display.width()/2)+55-5, Display.height()/2, 110-i);
27+
}
28+
Display.fill(255, 255, 255);
29+
Display.rect((Display.width()/2)-55-16+5, (Display.height()/2)-5, 32, 10);
30+
Display.fill(255, 255, 255);
31+
Display.rect((Display.width()/2)+55-16-5, (Display.height()/2)-5, 32, 10);
32+
Display.fill(255, 255, 255);
33+
Display.rect((Display.width()/2)+55-5-5, (Display.height()/2)-16, 10, 32);
34+
Display.endDraw();
35+
}
36+
37+
void loop() { }

0 commit comments

Comments
 (0)