Skip to content

Commit c4873f5

Browse files
committed
Initial code drop.
1 parent 4b07a6e commit c4873f5

14 files changed

+14178
-0
lines changed

Diff for: .gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
build/**
2+
obsolete/**

Diff for: CMakeLists.txt

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
cmake_minimum_required(VERSION 3.16)
2+
3+
idf_component_register(
4+
SRCS
5+
"firefly-display.c"
6+
INCLUDE_DIRS
7+
"include"
8+
REQUIRES
9+
driver
10+
)

Diff for: README.md

+24
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,30 @@ Firefly Display
33

44
A simple display driver for the ST7789 240x240 display.
55

6+
7+
Example
8+
-------
9+
10+
See the [example project](./examples/test-app) which merely
11+
displays a static image on the display.
12+
13+
14+
Using Locally
15+
-------------
16+
17+
Due to the way ESP IDF uses a component's folder name to determine
18+
its package name, the default folder when checking out from GitHub
19+
(i.e. `component-display`) prevents the component from working.
20+
21+
To resolve this, for example if contributing to the repository,
22+
checkout out the component in a target folder named `firefly-display`:
23+
24+
```shell
25+
/home/ricmoo> git clone [email protected]:firefly/component-display.git firefly-display
26+
# This is important!! -----------------------------------------------^
27+
```
28+
29+
630
License
731
-------
832

Diff for: examples/test-app/.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
build/**
2+
sdkconfig.old
3+
dependencies.lock

Diff for: examples/test-app/CMakeLists.txt

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
cmake_minimum_required(VERSION 3.16)
2+
3+
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
4+
project(test-app)

Diff for: examples/test-app/README.md

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Test App
2+
========
3+
4+
Very simple app that loads a static image and shows it on the
5+
display.
6+
7+
License
8+
-------
9+
10+
MIT License.

Diff for: examples/test-app/main/CMakeLists.txt

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
idf_component_register(
2+
SRCS
3+
"main.c"
4+
INCLUDE_DIRS
5+
"."
6+
)

Diff for: examples/test-app/main/idf_component.yml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
dependencies:
3+
idf:
4+
version: ">=4.1.0"
5+
6+
# The local component being tested
7+
firefly-display:
8+
path: ../../..

Diff for: examples/test-app/main/logo-color.h

+11,526
Large diffs are not rendered by default.

Diff for: examples/test-app/main/main.c

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
2+
#include <stdio.h>
3+
4+
#include "freertos/FreeRTOS.h"
5+
#include "freertos/task.h"
6+
7+
8+
#include "firefly-display.h"
9+
10+
#include "logo-color.h"
11+
12+
13+
#define DISPLAY_BUS (DisplaySpiBus2)
14+
#define PIN_DISPLAY_DC (4)
15+
#define PIN_DISPLAY_RESET (5)
16+
17+
static void delay(uint32_t duration) {
18+
vTaskDelay((duration + portTICK_PERIOD_MS - 1) / portTICK_PERIOD_MS);
19+
}
20+
21+
void renderFunc(uint8_t *buffer, uint32_t y0, void *context) {
22+
uint8_t *dst = &buffer[0];
23+
for (int y = y0; y < MIN(logo_height, y0 + DisplayFragmentHeight); y++) {
24+
const uint8_t *src = &logo[y * logo_width * 2];
25+
for (int x = 0; x < MIN(logo_width, DisplayFragmentWidth); x++) {
26+
*dst++ = *src++;
27+
*dst++ = *src++;
28+
}
29+
}
30+
}
31+
32+
void app_main(void) {
33+
printf("HELLO %d\n", display_fps(NULL));
34+
35+
DisplayContext display = display_init(DISPLAY_BUS, PIN_DISPLAY_DC, PIN_DISPLAY_RESET, DisplayRotationPinsLeft, renderFunc, NULL);
36+
37+
while (1) {
38+
uint32_t frameDone = display_renderFragment(display);
39+
if (frameDone) {
40+
printf("done!\n");
41+
while(1) { delay(1000); }
42+
}
43+
}
44+
}

0 commit comments

Comments
 (0)