Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
lewisxhe committed Nov 26, 2024
2 parents 7e4b2a2 + 910c4ce commit 7dd03e2
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 4 deletions.
3 changes: 2 additions & 1 deletion keywords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ getBoardsConfigure KEYWORD2
getName KEYWORD2
getBoardID KEYWORD2
sleep KEYWORD2
wakeup KEYWORD2
disp_sleep KEYWORD2
disp_wakeup KEYWORD2
#######################################
# Constants (LITERAL1)
#######################################
Expand Down
26 changes: 24 additions & 2 deletions src/LilyGo_AMOLED.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
#define TFT_SPI_MODE SPI_MODE0
#define DEFAULT_SPI_HANDLER (SPI3_HOST)

LilyGo_AMOLED::LilyGo_AMOLED() : boards(NULL), _hasRTC(false)
LilyGo_AMOLED::LilyGo_AMOLED() : boards(NULL), _hasRTC(false), _disableTouch(false)
{
spiDev = NULL;
pBuffer = NULL;
Expand Down Expand Up @@ -139,6 +139,16 @@ bool LilyGo_AMOLED::isPressed()
return false;
}

void LilyGo_AMOLED::disableTouch()
{
_disableTouch = true;
}

void LilyGo_AMOLED::enableTouch()
{
_disableTouch = false;
}

uint8_t LilyGo_AMOLED::getPoint(int16_t *x, int16_t *y, uint8_t get_point )
{
uint8_t point = 0;
Expand All @@ -147,6 +157,12 @@ uint8_t LilyGo_AMOLED::getPoint(int16_t *x, int16_t *y, uint8_t get_point )
} else if (boards == &BOARD_AMOLED_191 || boards == &BOARD_AMOLED_241 || boards == &BOARD_AMOLED_191_SPI) {
point = TouchDrvCSTXXX::getPoint(x, y);
}

// Disable touch, just return the touch press touch point Set to 0, does not actually disable touch
// https://github.com/Xinyuan-LilyGO/LilyGo-AMOLED-Series/issues/70
if (_disableTouch) {
return 0;
}
return point;
}

Expand Down Expand Up @@ -1047,7 +1063,13 @@ void LilyGo_AMOLED::sleep(bool touchpad_sleep_enable)
}
}

void LilyGo_AMOLED::wakeup()
void LilyGo_AMOLED::disp_sleep()
{
lcd_cmd_t t = {LCD_CMD_SLPIN, {0x00}, 1};// Sleep in
writeCommand(t.addr, t.param, t.len);
}

void LilyGo_AMOLED::disp_wakeup()
{
lcd_cmd_t t = {0x11, {0x00}, 1};// Sleep Out
writeCommand(t.addr, t.param, t.len);
Expand Down
11 changes: 10 additions & 1 deletion src/LilyGo_AMOLED.h
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,11 @@ class LilyGo_AMOLED:
uint16_t width();
uint16_t height();

// Disable touch, just return the touch press touch point Set to 0, does not actually disable touch
// https://github.com/Xinyuan-LilyGO/LilyGo-AMOLED-Series/issues/70
void disableTouch();
void enableTouch();

// override
uint8_t getPoint(int16_t *x_array, int16_t *y_array, uint8_t get_point = 1) override;
bool isPressed() override;
Expand All @@ -388,7 +393,9 @@ class LilyGo_AMOLED:
uint8_t getBoardID();

void sleep(bool touchpad_sleep_enable = false);
void wakeup();

void disp_sleep();
void disp_wakeup();
bool hasTouch();
bool hasOTG();

Expand Down Expand Up @@ -421,6 +428,8 @@ class LilyGo_AMOLED:

bool _hasRTC;

bool _disableTouch;

SPIClass *spiDev;
};

Expand Down

0 comments on commit 7dd03e2

Please sign in to comment.