Skip to content

Commit

Permalink
add dragon example
Browse files Browse the repository at this point in the history
  • Loading branch information
vroland committed Apr 24, 2020
1 parent 04f9811 commit d90737e
Show file tree
Hide file tree
Showing 12 changed files with 22,477 additions and 0 deletions.
4 changes: 4 additions & 0 deletions examples/dragon/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
cmake_minimum_required(VERSION 3.16.0)
set(EXTRA_COMPONENT_DIRS "../../components/")
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(dragon_example)
7 changes: 7 additions & 0 deletions examples/dragon/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
A demo showing a Full-Screen Image
==================================

*The image size is chosen to fit a 1200 * 825 display!*

Image by David REVOY / CC BY (https://creativecommons.org/licenses/by/3.0)
https://commons.wikimedia.org/wiki/File:Durian_-_Sintel-wallpaper-dragon.jpg
Binary file added examples/dragon/cc_dragon.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions examples/dragon/main/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
set(app_sources "main.c")

idf_component_register(SRCS ${app_sources} REQUIRES epd_driver)
829 changes: 829 additions & 0 deletions examples/dragon/main/dragon.h

Large diffs are not rendered by default.

12,111 changes: 12,111 additions & 0 deletions examples/dragon/main/firasans.h

Large diffs are not rendered by default.

6,755 changes: 6,755 additions & 0 deletions examples/dragon/main/firasans_12pt.h

Large diffs are not rendered by default.

772 changes: 772 additions & 0 deletions examples/dragon/main/giraffe.h

Large diffs are not rendered by default.

827 changes: 827 additions & 0 deletions examples/dragon/main/image.h

Large diffs are not rendered by default.

400 changes: 400 additions & 0 deletions examples/dragon/main/img_board.h

Large diffs are not rendered by default.

60 changes: 60 additions & 0 deletions examples/dragon/main/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/* Simple firmware for a ESP32 displaying a static image on an EPaper Screen.
*
* Write an image into a header file using a 3...2...1...0 format per pixel,
* for 4 bits color (16 colors - well, greys.) MSB first. At 80 MHz, screen
* clears execute in 1.075 seconds and images are drawn in 1.531 seconds.
*/

#include "esp_heap_caps.h"
#include "esp_log.h"
#include "esp_timer.h"
#include "esp_types.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "sdkconfig.h"
#include <stdio.h>
#include <string.h>

#include "epd_driver.h"
#include "dragon.h"

uint8_t *img_buf;

void delay(uint32_t millis) { vTaskDelay(millis / portTICK_PERIOD_MS); }

uint32_t millis() { return esp_timer_get_time() / 1000; }

void loop() {
epd_poweron();
epd_clear();
volatile uint32_t t1 = millis();
epd_draw_grayscale_image(epd_full_screen(), img_buf);
volatile uint32_t t2 = millis();
printf("EPD draw took %dms.\n", t2 - t1);

epd_poweroff();

delay(5000);
}

void epd_task() {
epd_init();

while (1) {
loop();
};
}

void app_main() {
// copy the image data to SRAM for faster display time
img_buf = (uint8_t *)heap_caps_malloc(EPD_WIDTH * EPD_HEIGHT / 2, MALLOC_CAP_SPIRAM);
if (img_buf == NULL) {
ESP_LOGE("epd_task", "Could not allocate framebuffer in PSRAM!");
}

memcpy(img_buf, dragon_data, EPD_WIDTH * EPD_HEIGHT / 2);
heap_caps_print_heap_info(MALLOC_CAP_INTERNAL);
heap_caps_print_heap_info(MALLOC_CAP_SPIRAM);

xTaskCreatePinnedToCore(&epd_task, "epd task", 10000, NULL, 2, NULL, 1);
}

0 comments on commit d90737e

Please sign in to comment.