reflow-firmware2.0/src/st7735/init.rs

128 lines
7.1 KiB
Rust

use st7735::commands::Command;
// Initialization commands for 7735B screens
pub const ST7735_BLUE_INIT : [(Command, u32); 18] = [
(Command::SWRESET, 50), // 1: Software reset, 50 ms delay
(Command::SLPOUT, 500), // 2: Out of sleep mode, 500ms delay
(Command::COLMOD(0x05), 10), // 3: Set color mode, 16-bit color, 10ms delay
(Command::FRMCTR1([0x00, 0x06, 0x03]), 10), // 4: Frame rate control,
// fastest refresh,
// 6 lines front porch,
// 3 lines back porch
// 10ms delay
(Command::MADCTL(0x08), 0), // 5: Memory access ctrl (directions)
// Row addr/col addr, bottom to top refresh
(Command::DISSET5([0x15,0x02]), 0), // 6: Display settings #5,
// 1 clk cycle nonoverlap, 2 cycle gate
// Fix on VTL
(Command::INVCTR(0x00), 0), // 7: Display inversion control,
// Line inversion
(Command::PWCTR1([0x02, 0x07]), 10), // 8: Power control,
// GVDD = 4.7V
// 1.0uA
// 10 ms delay
(Command::PWCTR2(0x05), 0), // 9: Power control,
// GH = 14.7V, VGL = -7.35V
(Command::PWCTR3([0x01, 0x02]), 0), // 10: Power control,
// Opamp current small
// Boost frequency
(Command::VMCTR1([0x3C, 0x38]), 10), // 11: Power control
// VCOMH = 4V
// VCOML = -1.1V
// 10 ms delay
(Command::PWCTR6([0x11, 0x15]), 0), // 12: Power control
(Command::GMCTRP1([0x09, 0x16, 0x09, 0x20, // 13: Magical unicorn dust
0x21, 0x1B, 0x13, 0x19,
0x17, 0x15, 0x1E, 0x2B,
0x04, 0x05, 0x02, 0x0E]), 0),
(Command::GMCTRN1([0x0B, 0x14, 0x08, 0x1E, // 14: Sparkles and rainbows
0x22, 0x1D, 0x18, 0x1E,
0x1B, 0x1A, 0x24, 0x2B,
0x06, 0x06, 0x02, 0x0F]), 10), // 10ms delay
(Command::CASET([0x00, 0x02, 0x00, 0x81]), 0), // 15: Column addr set
// XSTART = 2
// XEND = 129
(Command::RASET([0x00, 0x02, 0x00, 0x81]), 0), // 16: Row addr set
// XSTART = 1
// XEND = 160
(Command::NORON, 10), // 17: Normal display on, 10ms delay
(Command::DISPON, 500) // 18: Main screen turn on, 500ms delay
];
// Init for 7735R, part 1 (red or green tab)
pub const ST7735_RED_INIT1 : [(Command, u32); 15] = [
(Command::SWRESET, 150), // 1: Software reset, 150ms delay
(Command::SLPOUT, 500), // 2: Out of sleep mode
(Command::FRMCTR1([0x01, 0x2C, 0x2D]), 0), // 3: Frame rate ctrl - normal mode
// Rate = fosc/(1x2+40) * (LINE+2C+2D)
(Command::FRMCTR2([0x01, 0x2C, 0x2D]), 0), // 4: Frame rate control - idle mode
// Rate = fosc/(1x2+40) * (LINE+2C+2D)
(Command::FRMCTR3([0x01, 0x2C, 0x2D, // 5: Frame rate ctrl - partial mode
0x01, 0x2C, 0x2D]), 0), // Dot inversion mode
// Line inversion mode
(Command::INVCTR(0x07), 0), // 6: Display inversion ctrl
// No inversion
(Command::PWCTR1([0xA2, 0x02]), 0), // 7: Power control, -4.6V AUTO mode
(Command::PWCTR2(0xC5), 0), // 8: Power control
// VGH25 = 2.4C VGSEL = -10 VGH = 3 * AVDD
(Command::PWCTR3([0x0A, 0x00]), 0), // 9: Power control:
// Opamp current small
// Boost frequency
(Command::PWCTR4([0x8A, 0x2A]),0), // 10: Power control, 2 args, no delay:
// BCLK/2, Opamp current small & Medium low
(Command::PWCTR5([0x8A, 0xEE]), 0), // 11: Power control
(Command::VMCTR1([0x0E, 0x4D]), 0), // 12: Power control
(Command::INVOFF, 0), // 13: Don't invert display
(Command::MADCTL(0xC8), 0), // 14: Memory access control (directions), 1 arg:
// row addr/col addr, bottom to top refresh
(Command::COLMOD(0x05), 0) // 15: set color mode, 1 arg, no delay:
// 16-bit color
];
// Init for 7735R, part 2 (green tab only)
pub const ST7735_RED_INIT_GREEN2 : [(Command, u32); 2] = [
(Command::CASET([0x00, 0x02, 0x00, 0x7F+0x02]), 0), // 1: Column addr set
// XSTART = 0
// XEND = 127
(Command::RASET([0x00, 0x01, 0x00, 0x9F+0x01]), 0) // 2: Row addr set
// XSTART = 0
// XEND = 159
];
// Init for 7735R, part 2 (red tab only)
pub const ST7735_RED_INIT_RED2 : [(Command, u32); 2] = [
(Command::CASET([0x00, 0x00, 0x00, 0x7F]), 0), // 1: Column addr set, 4 args, no delay:
// XSTART = 0
// XEND = 127
(Command::RASET([0x00, 0x00, 0x00, 0x9F]),0) // 2: Row addr set, 4 args, no delay:
// XSTART = 0
// XEND = 159
];
// Init for 7735R, part 2 (green 1.44 tab)
pub const ST7735_RED_INIT_GREEN1442 : [(Command, u32); 2] = [
(Command::CASET([0x00, 0x00, 0x00, 0x7F]), 0), // 1: Column addr set, 4 args, no delay:
// XSTART = 0
// XEND = 127
(Command::RASET([0x00, 0x00, 0x00, 0x7F]), 0) // 2: Row addr set, 4 args, no delay:
// XSTART = 0
// XEND = 127
];
// Init for 7735R, part 3 (red or green tab)
pub const ST7735_RED_INIT3: [(Command, u32); 4] = [
(Command::GMCTRP1([0x02, 0x1c, 0x07, 0x12, // 1: Magical unicorn dust
0x37, 0x32, 0x29, 0x2d,
0x29, 0x25, 0x2B, 0x39,
0x00, 0x01, 0x03, 0x10]), 0),
(Command::GMCTRN1([0x03, 0x1d, 0x07, 0x06, // 2: Sparkles and rainbows
0x2E, 0x2C, 0x29, 0x2D,
0x2E, 0x2E, 0x37, 0x3F,
0x00, 0x00, 0x02, 0x10]), 0),
(Command::NORON, 10), // 3: Normal display, 10 ms delay
(Command::DISPON, 100) // 4: Main screen turn on, 100 ms delay
];