Skip to content

Commit

Permalink
Merge pull request #40 from lovyan03/develop
Browse files Browse the repository at this point in the history
v0.2.0
  • Loading branch information
lovyan03 authored Sep 3, 2020
2 parents cdd368f + 7ce7d73 commit fdd4430
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 23 deletions.
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"type": "git",
"url": "https://github.com/lovyan03/LovyanGFX"
},
"version": "0.1.19",
"version": "0.2.0",
"framework": "arduino, espidf",
"platforms": "espressif32, atmelsam",
"build": {
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=LovyanGFX
version=0.1.19
version=0.2.0
author=lovyan03
maintainer=Lovyan <[email protected]>
sentence=LCD Graphics driver for ESP32 and SAMD51
Expand Down
2 changes: 1 addition & 1 deletion src/config/LGFX_Config_AutoDetectESP32.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ class LGFX : public lgfx::LGFX_SPI<lgfx::LGFX_Config>
p_tmp.freq_read = 8000000;
board = lgfx::board_t::board_unknown;
std::uint32_t id;

(void)id; // Suppressing Compiler Warnings

// TTGO T-Watch 判定 (GPIO33を使う判定を先に行うと振動モーターが作動する事に注意)
#if defined ( LGFX_AUTODETECT ) || defined ( LGFX_TTGO_TWATCH )
Expand Down
54 changes: 34 additions & 20 deletions src/lgfx/LGFX_Device.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,42 +145,56 @@ namespace lgfx

bool need_transaction = (_touch->bus_shared && _in_transaction);
if (need_transaction) { endTransaction(); }
std::uint_fast8_t res = _touch->getTouch(x, y, number);
auto res = _touch->getTouch(x, y, number);
if (need_transaction) { beginTransaction(); }
return res;
}

std::uint_fast8_t getTouch(std::uint16_t *px, std::uint16_t *py, std::uint_fast8_t number = 0)
std::uint_fast8_t getTouch(std::uint16_t *x, std::uint16_t *y, std::uint_fast8_t number = 0)
{
std::int32_t x, y;
auto res = getTouch(&x, &y, number);
if (px) *px = x;
if (py) *py = y;
std::int32_t tx, ty;
auto res = getTouch(&tx, &ty, number);
if (x) *x = tx;
if (y) *y = ty;
return res;
}

std::uint_fast8_t getTouch(std::int32_t *px, std::int32_t *py, std::uint_fast8_t number = 0)
std::uint_fast8_t getTouch(std::int32_t *x, std::int32_t *y, std::uint_fast8_t number = 0)
{
std::int32_t tx, ty;
std::uint_fast8_t res = getTouchRaw(&tx, &ty, number);
auto res = getTouchRaw(&tx, &ty, number);
if (0 == res) return 0;
convertRawXY(&tx, &ty);
if (x) *x = tx;
if (y) *y = ty;
return res;
}

int x = (_touch_affin[0] * (float)tx + _touch_affin[1] * (float)ty) + _touch_affin[2];
int y = (_touch_affin[3] * (float)tx + _touch_affin[4] * (float)ty) + _touch_affin[5];
void convertRawXY(std::uint16_t *x, std::uint16_t *y)
{
std::int32_t tx = *x, ty = *y;
convertRawXY(&tx, &ty);
*x = tx;
*y = ty;
}

int r = _panel->rotation & 7;
void convertRawXY(std::int32_t *x, std::int32_t *y)
{
std::int32_t tx = (_touch_affin[0] * (float)*x + _touch_affin[1] * (float)*y) + _touch_affin[2];
std::int32_t ty = (_touch_affin[3] * (float)*x + _touch_affin[4] * (float)*y) + _touch_affin[5];

std::uint_fast8_t r = _panel->rotation & 7;
if (r & 1) {
std::swap(x, y);
std::swap(tx, ty);
}
if (px) {
if (r & 2) x = (_width-1) - x;
*px = x;
if (x) {
if (r & 2) tx = (_width-1) - tx;
*x = tx;
}
if (py) {
if ((0 == ((r + 1) & 2)) != (0 == (r & 4))) y = (_height-1) - y;
*py = y;
if (y) {
if ((0 == ((r + 1) & 2)) != (0 == (r & 4))) ty = (_height-1) - ty;
*y = ty;
}
return res;
}

// This requires a uint16_t array with 8 elements. ( or nullptr )
Expand Down Expand Up @@ -374,7 +388,7 @@ namespace lgfx
std::int32_t px = (_width - 1) * ((i>>1) & 1);
std::int32_t py = (_height - 1) * ( i & 1);
draw_calibrate_point( px, py, size, fg_rawcolor, bg_rawcolor);

delay(500);
std::int32_t x_touch = 0, y_touch = 0;
static constexpr int _RAWERR = 20;
std::int32_t x_tmp, y_tmp, x_tmp2, y_tmp2;
Expand Down

0 comments on commit fdd4430

Please sign in to comment.