Skip to content

Commit

Permalink
#256 color implementation 1st draft
Browse files Browse the repository at this point in the history
  • Loading branch information
martinberlin committed Sep 14, 2023
1 parent b3a8ffa commit a7a9cba
Show file tree
Hide file tree
Showing 14 changed files with 2,662 additions and 44 deletions.
4 changes: 4 additions & 0 deletions examples/color/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 "../../")
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(color_example)
7 changes: 7 additions & 0 deletions examples/color/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
3 changes: 3 additions & 0 deletions examples/color/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 epdiy)
81 changes: 81 additions & 0 deletions examples/color/main/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/* Simple firmware for a ESP32 displaying a Color square in a DES epaper screen with CFA on top */
#include "esp_heap_caps.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"


#include "esp_sleep.h"
#include <epdiy.h>
#include "epd_highlevel.h"

EpdiyHighlevelState hl;
int temperature = 25;
// Buffers
uint8_t *fb; // EPD 2bpp buffer

int color_test() {
EpdRect epd_area = {
.x = 0,
.y = 0,
.width = epd_width()/2,
.height = epd_height()
};

uint8_t color_of = 0;
/**
* @brief PATTERN
* pix1 2 3 X
* B G R row:1
* G R B row:2
* R B G row:3
*/
for (uint16_t y=1; y<epd_area.height; y++) {
for (uint16_t x=1; x<epd_area.width; x++) {
// x, y, r, g, b
if (y < 560) {
epd_draw_cpixel(x, y, x/10, color_of, color_of, hl.front_fb);
} else if (y >= 560 && y < 1120) {
epd_draw_cpixel(x, y, color_of, x/10, color_of, hl.front_fb);
} else {
epd_draw_cpixel(x, y, color_of, color_of, x/10, hl.front_fb);
}
}
vTaskDelay(1);
}

enum EpdDrawError _err = epd_hl_update_screen(&hl, MODE_GC16, temperature);
epd_poweroff();
return _err;
}

// Deepsleep
#define DEEP_SLEEP_SECONDS 300
uint64_t USEC = 1000000;
int getFreePsram(){
multi_heap_info_t info;
heap_caps_get_info(&info, MALLOC_CAP_SPIRAM);
return info.total_free_bytes;
}

#ifndef ARDUINO_ARCH_ESP32
void app_main() {
printf("before epd_init() Free PSRAM: %d\n", getFreePsram());

epd_init(&epd_board_v7, &epdiy_GDEW101C01, EPD_LUT_64K);
// Set VCOM for boards that allow to set this in software (in mV).
epd_set_vcom(1560);
hl = epd_hl_init(EPD_BUILTIN_WAVEFORM);
fb = epd_hl_get_framebuffer(&hl);
printf("after epd_hl_init() Free PSRAM: %d\n", getFreePsram());


epd_poweron();
color_test();
printf("color example\n");

vTaskDelay(pdMS_TO_TICKS(5000));
esp_sleep_enable_timer_wakeup(DEEP_SLEEP_SECONDS * USEC);
esp_deep_sleep_start();
}

#endif
3 changes: 2 additions & 1 deletion examples/www-image/main/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
set(
app_sources "jpg-render.c"
#app_sources "jpg-render.c"
#app_sources "jpgdec-render.cpp"
app_sources "jpg-render-color.c"
)

idf_component_register(SRCS ${app_sources}
Expand Down
Loading

0 comments on commit a7a9cba

Please sign in to comment.