Skip to content

Commit

Permalink
Enable/disable the "function to send NOP command at the end of commun…
Browse files Browse the repository at this point in the history
…ication" can be configured in the derived class. ( thanks @unos ! related #397. )
  • Loading branch information
lovyan03 committed Jun 10, 2023
1 parent dd02ba4 commit 37b57a6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 20 deletions.
22 changes: 3 additions & 19 deletions src/lgfx/v1/panel/Panel_GC9A01.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,28 +83,12 @@ namespace lgfx
_cfg.panel_height = _cfg.memory_height = 240;

_cfg.dummy_read_pixel = 16;
}

public:
void endTransaction(void)
{
end_transaction();
// GC9A01 malfunctions when sending NOP.
// Therefore, the function to send a NOP at the end of communication should be disabled.
_nop_closing = false;
}
void end_transaction(void)
{
if (!_in_transaction) return;
_in_transaction = false;

if (_has_align_data)
{
_has_align_data = false;
_bus->writeData(0, 8);
}

_bus->endTransaction();
cs_control(true);
}

protected:

const uint8_t* getInitCommands(uint8_t listno) const override
Expand Down
10 changes: 9 additions & 1 deletion src/lgfx/v1/panel/Panel_LCD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ namespace lgfx
return false;
}

// pin_csが設定されておらずバスタイプがi2cでない場合は、
// トランザクション終了時にnopを送信する。
// これによってSPIバスをSDカード等と共有が可能となる。
// ※ _nop_closingがtrueであることをチェックしている理由は、
// 派生クラス側でこの機能を無効化できるようにするため。
// 具体的には、GC9A01はNOPを受信すると誤動作を起こすため無効化する必要がある。
_nop_closing = _nop_closing && (_cfg.pin_cs < 0) && (_bus->busType() != bus_type_t::bus_i2c);

startWrite(true);

for (uint8_t i = 0; auto cmds = getInitCommands(i); i++)
Expand Down Expand Up @@ -72,7 +80,7 @@ namespace lgfx
_bus->writeData(0, 8);
}

if (_cfg.pin_cs < 0 && _bus->busType() != bus_type_t::bus_i2c)
if (_nop_closing)
{
write_command(_cmd_nop); // NOP command
}
Expand Down
1 change: 1 addition & 0 deletions src/lgfx/v1/panel/Panel_LCD.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ namespace lgfx
bool _in_transaction = false;
uint8_t _cmd_nop = CMD_NOP;
uint8_t _cmd_ramrd = CMD_RAMRD;
bool _nop_closing = true; // トランザクション終了時にnopを送るか否か

enum mad_t
{ MAD_MY = 0x80
Expand Down

0 comments on commit 37b57a6

Please sign in to comment.