Skip to content

Add ESP-IDF grayscale test #11

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions examples/esp_idf/grayscale_test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
cmake_minimum_required(VERSION 3.5)

set(EXTRA_COMPONENT_DIRS "../../..")

include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(grayscale_test)
11 changes: 11 additions & 0 deletions examples/esp_idf/grayscale_test/main/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

set(
app_sources "grayscale_test.cpp"
)

idf_component_register(SRCS ${app_sources}
REQUIRES
esp_wifi driver esp_lcd
nvs_flash esp-tls esp_http_client esp_timer
FastEPD #Must be the same name as the git root folder
)
47 changes: 47 additions & 0 deletions examples/esp_idf/grayscale_test/main/grayscale_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#include <FastEPD.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"

#include "esp_log.h"

#include <string>

FASTEPD epaper;

unsigned int WIDTH = 1872;
unsigned int HEIGHT = 1404;
int PANNEL = BB_PANEL_V7_103;

extern "C" {
void app_main();
}

static const char *TAG = "GRAYSCALE_TEST";

void drawTest(bool flipped) {
epaper.fillScreen(0xf);
int color = (flipped) ? 15 : 0;
epaper.setFont(FONT_12x16);
epaper.setTextColor(BBEP_BLACK);
for (int i=0; i<WIDTH; i+=WIDTH/16) {
std::string str = std::to_string(color);
epaper.drawString(str.c_str(), i+(WIDTH/32), HEIGHT-50+5);
epaper.fillRect(i, 0, WIDTH/16, HEIGHT-50, flipped ? color-- : color++);
}
epaper.fullUpdate();
}
void app_main(void)
{
epaper.initPanel(PANNEL);
epaper.setPanelSize(WIDTH, HEIGHT);
epaper.setMode(BB_MODE_4BPP);

ESP_LOGI(TAG, "Starting grayscale test");
bool flipped = false;
while (1) {
ESP_LOGI(TAG, "Drawing test with orientation %d", flipped);
drawTest(flipped);
flipped = !flipped;
vTaskDelay(5000 / portTICK_PERIOD_MS);
}
}
Loading