Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save JoeBlakeB/d4d9220b1b961b05a0409a63fea42d8e to your computer and use it in GitHub Desktop.

Select an option

Save JoeBlakeB/d4d9220b1b961b05a0409a63fea42d8e to your computer and use it in GitHub Desktop.
Inkplate 6Flick ESP-IDF LVGL Hello World - Loops between black text on white, and white text on black, showing full and partial updates.
#include "sdkconfig.h"
#ifndef CONFIG_INKPLATE_BOARD_INKPLATE6FLICK
#error "Select Inkplate6Flick in menuconfig"
#endif
#include "Inkplate.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
static Inkplate *display = nullptr;
static void createHelloWorld(bool topToBottom, bool inverted) {
lv_obj_t *screen = lv_scr_act();
lv_obj_clean(screen);
lv_color_t bg = inverted ? lv_color_black() : lv_color_white();
lv_color_t fg = inverted ? lv_color_white() : lv_color_black();
lv_obj_set_style_bg_color(screen, bg, 0);
lv_obj_set_style_bg_opa(screen, LV_OPA_COVER, 0);
const char *text = "Hello World!";
lv_obj_t *l1 = lv_label_create(screen);
lv_obj_t *l2 = lv_label_create(screen);
lv_obj_t *l3 = lv_label_create(screen);
lv_label_set_text(l1, text);
lv_label_set_text(l2, text);
lv_label_set_text(l3, text);
lv_obj_set_style_text_color(l1, fg, 0);
lv_obj_set_style_text_color(l2, fg, 0);
lv_obj_set_style_text_color(l3, fg, 0);
lv_obj_set_style_text_font(l1, &lv_font_montserrat_14, 0);
lv_obj_set_style_text_font(l2, &lv_font_montserrat_20, 0);
lv_obj_set_style_text_font(l3, &lv_font_montserrat_28, 0);
lv_obj_align(l1, LV_ALIGN_CENTER, 0, topToBottom ? -60 : 60);
lv_obj_align(l2, LV_ALIGN_CENTER, 0, 0);
lv_obj_align(l3, LV_ALIGN_CENTER, 0, topToBottom ? 60 : -60);
}
extern "C" void app_main(void) {
display = new Inkplate(LV_DISPLAY_RENDER_MODE_PARTIAL);
display->setDisplayMode(BLACK_AND_WHITE);
display->setFullUpdateThreshold(0);
display->frontlight.setState(false);
int step = 0;
bool topToBottom = true;
while (true) {
bool inverted = (step >= 2);
bool full = (step == 0 || step == 2);
createHelloWorld(topToBottom, inverted);
lv_refr_now(lv_display_get_default());
if (full)
display->display();
else
display->partialUpdate(true, true);
vTaskDelay(pdMS_TO_TICKS(1000));
topToBottom = !topToBottom;
step = (step + 1) % 4;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment