Skip to content

Only allow class-internal (private) access for TFT driver library. #36

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

Merged
merged 1 commit into from
Jan 25, 2022
Merged
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
32 changes: 19 additions & 13 deletions src/Braccio++.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ BraccioClass::BraccioClass()
, _motors_connected_mtx{}
, _motors_connected_thd{}
, _customMenu{nullptr}
, _gfx{}
{

}
Expand Down Expand Up @@ -120,10 +121,10 @@ bool BraccioClass::begin(voidFuncPtr customMenu)

lv_style_init(&_lv_style);

gfx.init();
gfx.setRotation(4);
gfx.fillScreen(TFT_WHITE);
gfx.setAddrWindow(0, 0, 240, 240);
_gfx.init();
_gfx.setRotation(4);
_gfx.fillScreen(TFT_WHITE);
_gfx.setAddrWindow(0, 0, 240, 240);

p_objGroup = lv_group_create();
lv_group_set_default(p_objGroup);
Expand Down Expand Up @@ -232,6 +233,19 @@ void BraccioClass::connectJoystickTo(lv_obj_t* obj) {
lv_indev_set_group(kb_indev, p_objGroup);
}

void BraccioClass::lvgl_disp_flush(lv_disp_drv_t *disp, const lv_area_t *area, lv_color_t *color_p)
{
uint32_t w = (area->x2 - area->x1 + 1);
uint32_t h = (area->y2 - area->y1 + 1);

_gfx.startWrite();
_gfx.setAddrWindow(area->x1, area->y1, w, h);
_gfx.pushColors(&color_p->full, w * h, true);
_gfx.endWrite();

lv_disp_flush_ready(disp);
}

void BraccioClass::pd_thread() {
start_pd_burst = millis();
size_t last_time_ask_pps = 0;
Expand Down Expand Up @@ -374,15 +388,7 @@ int BraccioClass::getKey() {
/* Display flushing */
extern "C" void braccio_disp_flush(lv_disp_drv_t *disp, const lv_area_t *area, lv_color_t *color_p)
{
uint32_t w = (area->x2 - area->x1 + 1);
uint32_t h = (area->y2 - area->y1 + 1);

Braccio.gfx.startWrite();
Braccio.gfx.setAddrWindow(area->x1, area->y1, w, h);
Braccio.gfx.pushColors(&color_p->full, w * h, true);
Braccio.gfx.endWrite();

lv_disp_flush_ready(disp);
Braccio.lvgl_disp_flush(disp, area, color_p);
}

/* Reading input device (simulated encoder here) */
Expand Down
5 changes: 3 additions & 2 deletions src/Braccio++.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,13 @@ class BraccioClass
inline bool isJoystickPressed_DOWN() { return (digitalRead(BTN_DOWN) == LOW); }
inline bool isButtonPressed_ENTER() { return (digitalRead(BTN_ENTER) == LOW); }

TFT_eSPI gfx = TFT_eSPI();

static BraccioClass& get_default_instance() {
static BraccioClass dev;
return dev;
}

void lvgl_disp_flush(lv_disp_drv_t *disp, const lv_area_t *area, lv_color_t *color_p);

protected:
// ioexpander APIs
void digitalWrite(int pin, uint8_t value);
Expand Down Expand Up @@ -114,6 +114,7 @@ class BraccioClass
const int BTN_SEL = A0;
const int BTN_ENTER = A1;

TFT_eSPI _gfx;
lv_disp_drv_t disp_drv;
lv_indev_drv_t indev_drv;
lv_disp_draw_buf_t disp_buf;
Expand Down