Sunday Work

  • Look at pinout for TFT featherwing
  • Look at pinout for airlift featherwing
  • Probably start directly on an nrf52840 feather
  • Get the display up and running
  • Implement an embedded-graphics driver
  • Mess around with layout and style
  • Invent some style primitives
  • Find/rearrange some pins for the black pill
    • Chip selects
    • SPI peripheral (not the LED)

Feather Pinouts

               USB
               ---
       RST |         | }
       3v3 |         | } LiPo Connector
       ??? |         | }
       GND |         | }
    D18/A0 |         | VBAT
    D19/A1 |         | En
    D20/A2 |         | VBUS
    D21/A3 |         | D13
    D22/A4 |         | D12
    D23/A5 |         | D11
  SCLK/D15 |         | D10/A10
  COPI/D16 |         | D9/A9
  CIPO/D14 |         | D6/A7
UART RX/D0 |         | D5
UART TX/D1 |         | SCL/D3
       ??? |         | SDA/D2

Note: ??? pins change per feather

Adafruit TFT FeatherWing - 3.5" 480x320

Product link: https://www.adafruit.com/product/3651

               USB
               ---
    nRESET |         | }
       3v3 |         | } LiPo Connector
         x |         | }
       GND |         | }
         x |         | VBAT---.
         x |         | EN     |-- Power Path ("+5V")
         x |         | VBUS---'
         x |         | x
         x |         | x
         x |         | x
      SCLK |         | TFT_DC   (Display Data/Command)
      COPI |         | TFT_CSn  (Display Select)
      CIPO |         | RT_CSn   (Touch Control Select)
         x |         | SD_CSn   (SD Card Select)
         x |         | x
         x |         | x

Schematic Link: https://cdn-learn.adafruit.com/assets/assets/000/047/657/original/adafruit_products_schem.png?1508965762

I may also want an extra pin for backlight control (PWM) or touch IRQs.

The main chips used for control are:

  • HX8357D - Display Control
  • STMPE610 - Touch Control

Adafruit AirLift FeatherWing – ESP32 WiFi Co-Processor

Product link: https://www.adafruit.com/product/4264

               USB
               ---
      RST? |         | }
         x |         | } LiPo Connector
         x |         | }
       GND |         | }
        x? |         | VBAT---.
        x? |         | En     |-- Power Path (to 3v3 reg)
        x? |         | VBUS---'
        x? |         | ESP_CSn (gates CIPO)
        x? |         | ESP_RESET
        x? |         | ESP_BUSY
SCK        |         | ESP_GPIO0(nc)
COSI       |         | x?
CIPO       |         | x?
ESP_TX(nc) |         | x?
ESP_RX(nc) |         | SCL (ATECC)
           |         | SDA (ATECC)

Schematic Link: https://cdn-learn.adafruit.com/assets/assets/000/076/198/original/adafruit_products_AirLift_FeatherWing_Sch.png?1559155254

  • En is part of of the power path routing, enables 3v3 reg
    • Common with main EN, hard to just gate wifi power
    • Maybe held in reset is enough? or dont common en?
  • CIPO is gated by ESP_CSn through a 74AHC1G125
  • ESP does not seem to connect directly to ATECC
  • ESP_RESET and RESET seem not to be connected

Boards seem compatible as long as we don't connect ESP_GPIO0, which is disconnected by default.

Feathers and the Calculator

We probably don't have enough feather pins to control:

  • Keyboard
  • Keyboard LEDs
  • WiFi
  • Display
  • Touch

Without some kind of port expander for either some of the selects, or for some kind of keypad controller.

What might make sense is to take an approach like BB Q10 Keyboard PMOD, and have a keyboard controller MCU that can connect via SPI or I2C.

I might want to pick something cheap + USB, like an STMG0 TSSPO20, and have the keyboard be standalone USB or SPI/I2C controlled. JLC seems to stock the STM32G031F8P6 (no USB, TSSOP-20, 0.88 EUR @ 10, extended part), the STM32G030C8T6 (no USB, LQFP-48, 0.78 EUR @ 10, extended part), or the classic STM32F103R8T6 (USB, LQFP64, 2.65 EUR @ 1, basic part)

I set up a poll to see what people think:

Display Notes

Initial command sequence for the HX8357D


// Step one: SW Reset and delay
HX8357_SWRESET, // 0x01
0x80 + 100 / 5, // Soft reset, then delay 10 ms(sic)
                // NOTE(AJM): actually 100ms

// Step two: SETC and delay
//   "Enable extension command"
HX8357D_SETC,   // 0xB9
3,              // NOTE(AJM): Three, because the next part
0xFF,           //   is the NOP+sleep command
0x83,
0x57,
0xFF,           // NOP command to cause a delay
0x80 + 500 / 5, // No command, just delay 300 ms(sic)
                // NOTE(AJM): actually 500ms

// Step three: SETRGB
//   "Set RGB interface"
HX8357_SETRGB,  // 0xB3
4,
0x80,
0x00,
0x06,
0x06,           // 0x80 enables SDO pin (0x00 disables)

// Step four: SETCOM
//   "Set VCOM voltage"
HX8357D_SETCOM, // 0xB6
1,
0x25,           // -1.52V

// Step five: SETOSC
//   "Set oscillator"
HX8357_SETOSC,  // 0xB0
1,
0x68,           // Normal mode 70Hz, Idle mode 55 Hz

// Step six: SETPANEL
//   "Set Panel"
HX8357_SETPANEL,    // 0xCC
1,
0x05,               // BGR, Gate direction swapped

// Step seven: SETPWR1
//   "Set power control"
HX8357_SETPWR1,     // 0xB1
6,
0x00,               // Not deep standby
0x15,               // BT
0x1C,               // VSPR
0x1C,               // VSNR
0x83,               // AP
0xAA,               // FS

// Step eight: SETSTBA
//   "Set source option"
HX8357D_SETSTBA,    // 0xC0
6,
0x50,               // OPON normal
0x50,               // OPON idle
0x01,               // STBA
0x3C,               // STBA
0x1E,               // STBA
0x08,               // GEN

// Step nine: SETCYC
//   "Set display cycle reg"
HX8357D_SETCYC,     // 0xB4
7,
0x02,               // NW 0x02
0x40,               // RTN
0x00,               // DIV
0x2A,               // DUM
0x2A,               // DUM
0x0D,               // GDON
0x78,               // GDOFF

// Step ten: SETGAMMA
//   "Set Gamma"
HX8357D_SETGAMMA,   // 0xE0
34,
0x02,
0x0A,
0x11,
0x1d,
0x23,
0x35,
0x41,
0x4b,
0x4b,
0x42,
0x3A,
0x27,
0x1B,
0x08,
0x09,
0x03,
0x02,
0x0A,
0x11,
0x1d,
0x23,
0x35,
0x41,
0x4b,
0x4b,
0x42,
0x3A,
0x27,
0x1B,
0x08,
0x09,
0x03,
0x00,
0x01,

// Step eleven: COLMOD
//   "Color mode"
HX8357_COLMOD,  // 0x3A
1,
0x55,           // 16 bit

// Step twelve: MADCTL
//   "Memory access control"
HX8357_MADCTL,  // 0x36
1,
0xC0,

// Step thirteen: TEON
//   "Tear enable on"
HX8357_TEON,    // 0x35
1,
0x00,           // TW off

// Step fourteen: TEARLINE
//   "(unknown)"
HX8357_TEARLINE,    // 0x44
2,
0x00,
0x02,

// Step fifteen: SLPOUT and delay
//   "Exit sleep mode"
HX8357_SLPOUT,  // 0x11
0x80 + 150 / 5, // Exit Sleep, then delay 150 ms

// Step sixteen: DISPON and delay
//   "Display off(sic)"
HX8357_DISPON, // 0x29
0x80 + 50 / 5, // Main screen turn on, delay 50 ms

// End.
0,             // END OF COMMAND LIST

Initial transaction uses "sendCommand", which includes:

  • Begin transaction
  • Set CS Low
  • Set DC Low
  • Send command byte
  • Set DC High
  • Send data (N)
  • Set CS High

setAddrWindow uses "writeCommand", which

  • Sets DC low
  • Writes command (1B)
  • Sets DC high

Comments state that CS and transaction must already be set

Hmm, it seems the HX8357 is somewhat similar/compatible with the ILI9341? Seems like the biggest differences are in the command IDs, and some extended control options.

I should probably base my library on the style of the existing ILI9341 crate

It seems the Adafruit driver basically:

  • Set CS Low
  • Sets the bounding box + starts write to ram command
    • HX8357_CASET (x1, x2)
    • HX8357_PASET (y1, y2)
    • HX8357_RAMWR (...)
  • Writes pixels
  • Sets CS high