mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-18 21:30:38 +01:00
Merge "[ion] Migrate to ST7789V LCD controller"
This commit is contained in:
@@ -5,6 +5,12 @@ extern "C" {
|
||||
#include <assert.h>
|
||||
}
|
||||
|
||||
/* This driver interfaces with the ST7789V LCD controller.
|
||||
* This chip keeps a whole frame in SRAM memory and feeds it to the LCD panel as
|
||||
* needed. We use the STM32's FSMC to drive the bus between the ST7789V. Once
|
||||
* configured, we only need to write in the address space of the MCU to actually
|
||||
* send some data to the LCD controller. */
|
||||
|
||||
// Public Ion::Display methods
|
||||
|
||||
namespace Ion {
|
||||
@@ -128,35 +134,17 @@ void initFSMC() {
|
||||
|
||||
void initPanel() {
|
||||
|
||||
*CommandAddress = Command::Reset; //software reset
|
||||
*CommandAddress = Command::Reset;
|
||||
msleep(5);
|
||||
|
||||
*CommandAddress = Command::SleepOut;
|
||||
msleep(5);
|
||||
|
||||
SEND_COMMAND(PowerControlB, 0x00, 0x83, 0x30);
|
||||
SEND_COMMAND(PowerOnSequenceControl, 0x64, 0x03, 0x12, 0x81);
|
||||
SEND_COMMAND(DriverTimingControlA, 0x85, 0x01, 0x79);
|
||||
SEND_COMMAND(PowerControlA, 0x39, 0x2C, 0x00, 0x34, 0x02);
|
||||
SEND_COMMAND(PumpRatioControl, 0x20);
|
||||
SEND_COMMAND(DriverTimingControlB, 0x00, 0x00);
|
||||
SEND_COMMAND(PowerControl2, 0x11);
|
||||
SEND_COMMAND(VCOMControl1, 0x34, 0x3D);
|
||||
SEND_COMMAND(VCOMControl2, 0xC0);
|
||||
SEND_COMMAND(MemoryAccessControl, 0xA8);
|
||||
SEND_COMMAND(PixelFormatSet, 0x55);
|
||||
SEND_COMMAND(FrameRateControl, 0x00, 0x1D);
|
||||
SEND_COMMAND(DisplayFunctionControl, 0x0A, 0xA2, 0x27, 0x00);
|
||||
SEND_COMMAND(EntryMode, 0x07);
|
||||
SEND_COMMAND(Enable3G, 0x08);
|
||||
SEND_COMMAND(GammaSet, 0x01);
|
||||
SEND_COMMAND(PositiveGammaCorrection, 0x1f, 0x1a, 0x18, 0x0a, 0x0f, 0x06, 0x45, 0x87, 0x32, 0x0a, 0x07, 0x02, 0x07, 0x05, 0x00);
|
||||
SEND_COMMAND(NegativeGammaCorrection, 0x00, 0x25, 0x27, 0x05, 0x10, 0x09, 0x3a, 0x78, 0x4d, 0x05, 0x18, 0x0d, 0x38, 0x3a, 0x1f);
|
||||
SEND_COMMAND(InterfaceControl, 0x01, 0x00, 0x20); // Data is sent little-endian
|
||||
|
||||
//*CommandAddress = Command::SleepOut; //Exit Sleep
|
||||
//msleep(120);
|
||||
*CommandAddress = Command::DisplayOn; //Display on
|
||||
SEND_COMMAND(PixelFormatSet, 0x05);
|
||||
SEND_COMMAND(MemoryAccessControl, 0xA0);
|
||||
|
||||
*CommandAddress = Command::DisplayOn;
|
||||
//msleep(50);
|
||||
}
|
||||
|
||||
@@ -207,7 +195,7 @@ void pullPixels(KDColor * pixels, size_t numberOfPixels) {
|
||||
if (numberOfPixels == 0) {
|
||||
return;
|
||||
}
|
||||
SEND_COMMAND(PixelFormatSet, 0x66);
|
||||
SEND_COMMAND(PixelFormatSet, 0x06);
|
||||
*CommandAddress = Command::MemoryRead;
|
||||
uint16_t dummy = *DataAddress; // First read is dummy data, per datasheet
|
||||
while (true) {
|
||||
@@ -228,7 +216,7 @@ void pullPixels(KDColor * pixels, size_t numberOfPixels) {
|
||||
*pixels++ = KDColor::RGB16(secondPixel);
|
||||
numberOfPixels--;
|
||||
}
|
||||
SEND_COMMAND(PixelFormatSet, 0x55);
|
||||
SEND_COMMAND(PixelFormatSet, 0x05);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -57,28 +57,11 @@ enum class Command : uint16_t {
|
||||
DisplayOff = 0x28,
|
||||
DisplayOn = 0x29,
|
||||
ColumnAddressSet = 0x2A,
|
||||
GammaSet = 0x26,
|
||||
PageAddressSet = 0x2B,
|
||||
MemoryWrite = 0x2C,
|
||||
MemoryRead = 0x2E,
|
||||
MemoryAccessControl = 0x36,
|
||||
PixelFormatSet = 0x3A,
|
||||
FrameRateControl = 0xB1,
|
||||
DisplayFunctionControl = 0xB6,
|
||||
EntryMode = 0xB7,
|
||||
PowerControl2 = 0xC1,
|
||||
VCOMControl1 = 0xC5,
|
||||
VCOMControl2 = 0xC7,
|
||||
PowerControlA = 0xCB,
|
||||
PowerControlB = 0xCF,
|
||||
PositiveGammaCorrection = 0xE0,
|
||||
NegativeGammaCorrection = 0xE1,
|
||||
DriverTimingControlA = 0xE8,
|
||||
DriverTimingControlB = 0xEA,
|
||||
PowerOnSequenceControl = 0xED,
|
||||
Enable3G = 0xF2,
|
||||
InterfaceControl = 0xF6,
|
||||
PumpRatioControl = 0xF7,
|
||||
};
|
||||
|
||||
constexpr static int FSMCMemoryBank = 1;
|
||||
|
||||
Reference in New Issue
Block a user