diff options
author | David Crocker <dcrocker@eschertech.com> | 2020-07-17 17:46:09 +0300 |
---|---|---|
committer | David Crocker <dcrocker@eschertech.com> | 2020-07-17 17:46:09 +0300 |
commit | 19bfef5b6a42fbad7669523fda47e6d0c12c141a (patch) | |
tree | ad52e573b6105801149d27cc35f4ebee32556b42 /src/Display | |
parent | 8363d09520ae4727c3112a0bb2a4710cddbf92c7 (diff) |
Various fixes
Corrections to ST7567 LCD driver (but still not working on Duet 3 Mini)
Fixed CS rising before clock had finished on shared SPI on Duet 3 Mini
Diffstat (limited to 'src/Display')
-rw-r--r-- | src/Display/Lcd/Lcd.cpp | 22 | ||||
-rw-r--r-- | src/Display/Lcd/ST7567/Lcd7567.cpp | 25 |
2 files changed, 30 insertions, 17 deletions
diff --git a/src/Display/Lcd/Lcd.cpp b/src/Display/Lcd/Lcd.cpp index 7c6a3087..2b44792d 100644 --- a/src/Display/Lcd/Lcd.cpp +++ b/src/Display/Lcd/Lcd.cpp @@ -24,13 +24,14 @@ Lcd::~Lcd() delete image; } -// Initialise. cControllerType is 1 for ST7567 controller, 0 for ST7920. a0Pin is only used by the ST7567. +// Initialise. a0Pin is only used by the ST7567. void Lcd::Init(Pin csPin, Pin p_a0Pin, bool csPolarity, uint32_t freq) noexcept { a0Pin = p_a0Pin; device.SetClockFrequency(freq); device.SetCsPin(csPin); device.SetCsPolarity(csPolarity); // normally active high chip select for ST7920, active low for ST7567 + pinMode(csPin, (csPolarity) ? OUTPUT_LOW : OUTPUT_HIGH); #ifdef __LPC17xx__ device.sspChannel = LcdSpiChannel; #endif @@ -69,16 +70,7 @@ PixelNumber Lcd::GetFontHeight(size_t fontNumber) const noexcept return fonts[fontNumber]->height; } -// Flag a pixel as dirty. The r and c parameters must be no greater than NumRows-1 and NumCols-1 respectively. -void Lcd::SetDirty(PixelNumber r, PixelNumber c) noexcept -{ - if (c < startCol) { startCol = c; } - if (c >= endCol) { endCol = c + 1; } - if (r < startRow) { startRow = r; } - if (r >= endRow) { endRow = r + 1; } -} - -// Flag a rectangle as dirty. Inline because it is called from only one place. +// Flag a rectangle as dirty. Inline because it is called from only two places. inline void Lcd::SetRectDirty(PixelNumber top, PixelNumber left, PixelNumber bottom, PixelNumber right) noexcept { if (top < startRow) startRow = top; @@ -87,6 +79,12 @@ inline void Lcd::SetRectDirty(PixelNumber top, PixelNumber left, PixelNumber bot if (right > endCol) endCol = right; } +// Flag a pixel as dirty. The r and c parameters must be no greater than NumRows-1 and NumCols-1 respectively. +void Lcd::SetDirty(PixelNumber r, PixelNumber c) noexcept +{ + SetRectDirty(r, c, r + 1, c + 1); +} + // Write a UTF8 byte. // If textYpos is off the end of the display, then don't write anything, just update textXpos and lastCharColData size_t Lcd::write(uint8_t c) noexcept @@ -335,7 +333,7 @@ void Lcd::ClearToMargin() noexcept else { mask ^= 0xFF >> (rightMargin & 7); - nextColumn = rightMargin;; + nextColumn = rightMargin; } for (uint8_t i = 0; i < fontHeight && p < (image + imageSize); ++i) diff --git a/src/Display/Lcd/ST7567/Lcd7567.cpp b/src/Display/Lcd/ST7567/Lcd7567.cpp index 8ac59f36..2fb2a955 100644 --- a/src/Display/Lcd/ST7567/Lcd7567.cpp +++ b/src/Display/Lcd/ST7567/Lcd7567.cpp @@ -13,14 +13,14 @@ constexpr unsigned int TILE_WIDTH = 1; constexpr unsigned int TILE_HEIGHT = 8; Lcd7567::Lcd7567(const LcdFont * const fnts[], size_t nFonts) noexcept - : Lcd(132, 64, fnts, nFonts) + : Lcd(64, 128, fnts, nFonts) { } // Get the display type const char *Lcd7567::GetDisplayTypeName() const noexcept { - return "132x64 mono graphics with ST7567 controller"; + return "128x64 mono graphics with ST7567 controller"; } void Lcd7567::HardwareInit() noexcept @@ -58,9 +58,24 @@ void Lcd7567::HardwareInit() noexcept // 10101100 Set static indicator off SendByte(0xAC); - // Exit sleep mode, display on - SendByte(PixelOff); - SendByte(DisplayOn); + // Enter sleep mode + // 10101110 Set display enable to off + SendByte(0xAE); + // 10100101 Set all pixel on + SendByte(0xA5); + + device.Deselect(); + + Clear(); + FlushAll(); + + device.Select(); + + // Enable display + // 10100100 Set all pixel off + SendByte(0xA4); + // 10101111 Set display enable to on + SendByte(0xAF); device.Deselect(); } |