Close

SPI and Sharp Memory LCD

A project log for Wireless remote LCD

Battery powered remote display for logging station

muthMuth 08/02/2016 at 22:340 Comments

Memory LCD

The 'memory' LCD from sharp are somehow fascinating. Their main advantage is the low power consumption, but they are one of the rare passive reflective monochrome LCD. They are nearly as readable on sun light as the eink displays. I first had this module http://www.ebay.com/itm/201596712057, where the board had to be fixed (the ground does not cross from one side to the other... Cheap products... ) I finally opt for the larger 4.4" 320x240 version (http://www.digikey.com/product-detail/en/sharp-microelectronics/LS044Q7DH01/425-2910-ND/5054070) .

NodeMCU speaks SPI

LUA SPI module is nice, it is possible to use the hardware SPI at high speed. But I did not found a way to invert the CS line logic neither to send little endian bytes as the screen require. I had to use a GPIO for the ChipSelect line and do some trick to invert the byte reading:

gpio.mode(2, gpio.OUTPUT)
gpio.write(2, gpio.LOW)
spi.setup(1, spi.MASTER, spi.CPOL_LOW, spi.CPHA_LOW, 8, 400, spi.HALFDUPLEX)

function printLine(line_nb)
  gpio.write(2, gpio.HIGH)
  spi.send(1, 128)
  spi.send(1, bit_invert(line_nb+1))
  for i=0,39 do 
    spi.send(1, array[i])
  end
  spi.send(1, 0)
  spi.send(1, 0)
  gpio.write(2, gpio.LOW)
end

function clear()
  gpio.write(2, gpio.HIGH)
  spi.send(1, 32)
  spi.send(1, 0)
  gpio.write(2, gpio.LOW)
end

function bit_invert(byte)
  inv = 0
  if (bit.isset(byte, 0)) then inv = bit.set(inv, 7) end
  if (bit.isset(byte, 1)) then inv = bit.set(inv, 6) end
  if (bit.isset(byte, 2)) then inv = bit.set(inv, 5) end
  if (bit.isset(byte, 3)) then inv = bit.set(inv, 4) end
  if (bit.isset(byte, 4)) then inv = bit.set(inv, 3) end
  if (bit.isset(byte, 5)) then inv = bit.set(inv, 2) end
  if (bit.isset(byte, 6)) then inv = bit.set(inv, 1) end
  if (bit.isset(byte, 7)) then inv = bit.set(inv, 0) end
  return inv
end
Performances

Putting things all together, it works. But it is slow. Very slow. But it is not surprising. I used several heavy functions such as string operation string.gmatch(c, "%S+") and array[index] = encoder.fromHex(i).

Refreshing the entier screen takes approximately 30 seconds... Not really conceivable for a battery application. We have to simplify that!

Discussions