Sure! I’m going to strip some pieces from it, other parts that shouldn’t be necessary.
Main class:
#include <Arduino.h>
#include "ZLVGL/ZLVSetup.h"
#include "ZLVGL/ZLVPanel.h"
#include "ZLVGL/ZLVTouch.h"
#include "Counter/LifeCounter.h"
#include "Counter/TwoPlayerCounterScreen.h"
void setup()
{
ZLVSetupTouch();
ZLVCreatePanel();
create2PlayerMtgScreen(40);
}
void loop()
{
lv_task_handler();
//lv_timer_handler();
delay( 5 );
}
ZLVSetup.h:
#pragma once
#include <Arduino.h>
#define TOUCH_SDA 33
#define TOUCH_SCL 32
#define TOUCH_INT 21
#define TOUCH_RST 25
#define TOUCH_WIDTH 480
#define TOUCH_HEIGHT 320
static const uint16_t width = 320;
static const uint16_t height = 480;
ZLVPanel.h:
ZLVTouch.h:
#pragma once
#include "ZLVSetup.h"
#include "TAMC_GT911.h"
#include <lvgl.h>
TAMC_GT911 touchPanel = TAMC_GT911(TOUCH_SDA, TOUCH_SCL, TOUCH_INT, TOUCH_RST, TOUCH_WIDTH, TOUCH_HEIGHT);
static bool touchSetup;
void ZLVSetupTouch()
{
touchSetup = true;
touchPanel.begin();
touchPanel.setRotation(ROTATION_RIGHT);
}
void ZLVReadTouch(lv_indev_drv_t* indev_driver, lv_indev_data_t* data)
{
if(!touchSetup) return;
touchPanel.read();
bool touched = touchPanel.isTouched;
if( !touched )
{
data->state = LV_INDEV_STATE_REL;
}
else
{
data->state = LV_INDEV_STATE_PR;
data->point.x = width - touchPanel.points[0].y;
data->point.y = touchPanel.points[0].x;
}
}
LifeCounter.h:
TwoPlayerCounterScreen.h:
#pragma once
#include "LifeCounter.h"
#include <Arduino.h>
void create2PlayerMtgScreen(int initialLife)
{
static lv_coord_t col_dsc[] = {LV_GRID_FR(1), LV_GRID_TEMPLATE_LAST};
static lv_coord_t row_dsc[] = {LV_GRID_FR(1), LV_GRID_FR(1), LV_GRID_TEMPLATE_LAST};
lv_obj_t* screen = lv_obj_create(NULL);
lv_obj_center(screen);
lv_obj_set_grid_dsc_array(screen, col_dsc, row_dsc);
lv_obj_t* counter = createCounter(initialLife, "Player 1", screen);
lv_obj_set_grid_cell(counter, LV_GRID_ALIGN_STRETCH, 0, 1, LV_GRID_ALIGN_STRETCH, 0, 1);
lv_obj_set_style_transform_pivot_x(counter, lv_pct(50), 0);
lv_obj_set_style_transform_pivot_y(counter, lv_pct(50), 0);
lv_obj_set_style_transform_angle(counter, 1800, 0);
counter = createCounter(initialLife, "Player 2", screen);
lv_obj_set_grid_cell(counter, LV_GRID_ALIGN_STRETCH, 0, 1, LV_GRID_ALIGN_STRETCH, 1, 1);
lv_obj_set_style_transform_pivot_x(counter, lv_pct(50), 0);
lv_obj_set_style_transform_pivot_y(counter, lv_pct(50), 0);
//lv_obj_set_style_transform_angle(counter, 0, 0);
lv_scr_load(screen);
}