/lcd-ws0010

Library for Winstar Display Controller WS0010

Primary LanguagePythonMIT LicenseMIT

lcd-ws0010

Library for Winstar Display Controller WS0010

I. Algorithm for 4-bit mode via PCF8574 in short.

Write high nibble of command byte

  1. Copy command byte to var1, shift var1 4 times to the right (>>)
  2. Write var1 to I2C bus
  3. Set bit 6 (EN) in var1
  4. Write var1 to I2C bus
  5. Clear bit 6 (EN) in var1
  6. Write var1 to I2C bus

Write low nibble of command byte

  1. Copy command byte to var1, clear high nibble of var1
  2. Write var1 to I2C bus
  3. Set bit 6 (EN) in var1
  4. Write var1 to I2C bus
  5. Clear bit 6 (EN) in var1
  6. Write var1 to I2C bus

Check busy flag

  1. Zeroize var1
  2. Set bit 5 (R/W) in var1
  3. Write var1 to I2C bus
  4. Set bit 6 (EN) in var1
  5. Write var1 to I2C bus
  6. Read byte from I2C bus into var2
  7. Clear bit 6 (EN) in var1
  8. Write var1 to I2C bus
  9. Shift var2 4 times to the left (<<)
  10. Set bit 6 (EN) in var1
  11. Write var1 to I2C bus
  12. Read byte from I2C bus into var3
  13. Clear bit 6 (EN) in var1
  14. Write var1 to I2C bus
  15. Clear high nibble of var3
  16. Logically OR var2 and var3, save result to var2
  17. Test bit 7 (BF, Busy Flag) in var2
  18. If bit 7 set, sleep WAIT_BF, go to step 13
  19. If bit 7 cleared, go further
  20. Zeroize var1
  21. Write var1 to I2C bus

Steps 3-6 and 9-12 are identical and can be implemented as a separate procedure

II. Initialization sequence for 4-bit mode.

Synchronization

  1. Write 0x0 nibble 5 times

Function set

Two lines (bit 3, N=1), 5x8 font size (bit 2, F=0), EN/RU character font table (bits 1 and 0, FT1=1, FT0=0)

  1. Write high nibble of command byte as 0x2 (DL=0) 2 times
  2. Write low nibble of command byte as 0xA (N=1, F=0, FT1=1, FT0=0)
  3. Check BF

Display ON/OFF Control

Display on (bit 2, D=1), cursor on (bit 1, C=1), blinking on (bit 0, B=1)

  1. Write high nibble of command byte as 0x0
  2. Write low nibble of command byte as 0xF (D=1, C=1, B=1)
  3. Check BF

Clear Display

  1. Write high nibble of command byte as 0x0
  2. Write low nibble of command byte as 0x1
  3. Check BF

Return Home

  1. Write high nibble of command byte as 0x0
  2. Write low nibble of command byte as 0x2
  3. Check BF

Entry Mode Set

Increment (bit 1, I/D=1), no shift (bit 0, S=0)

  1. Write high nibble of command byte as 0x0
  2. Write low nibble of command byte as 0x6 (I/D=1, S=0)
  3. Check BF

...