Close

Entry 0x16 - VFD display working. Sort of

A project log for KOAT0 Portable Terminal

A cyberdeck with a fluorescent display for max cyberpunk looks

robsoncoutoRobsonCouto 08/24/2023 at 18:372 Comments

I haven't had the time to work on the framebuffer driver, since I spent most of the time modelling the shell. Still, I could not continue without taking some nice pictures with the display working. So I coded a little script to use the interface exposed at /dev/spidev and initialise and write to the display. 

Which worked fine. I just had to manually reverse the bytes before writing, since spi0 does not have a LSB option. Apart from that I just did the init sequence from the datasheet and got it working in no time.

Anyways. Like I said, my plan is to code a kernel space driver to be used by linux. The good thing is now at least I have a good setup since everything is wired up and held firmly in place. I can focus more on the software.


The following snippet is part of the display test script. The whole script is in the project files.

GP1294AI_CMD_RESET = 0xAA
GP1294AI_CMD_FRAME_SYNC = 0x08
GP1294AI_CMD_BRIGHTNESS = 0xA0
GP1294AI_CMD_DISPLAY_MODE = 0x80
GP1294AI_CMD_WRITE_GRAM = 0xF0
GP1294AI_CMD_DISPLAY_OFFSET = 0xC0
GP1294AI_CMD_VFD_MODE = 0xCC
GP1294AI_CMD_OSC_SETTING = 0x78
GP1294AI_CMD_EXIT_STANDBY = 0x6D
GP1294AI_CMD_ENTER_STANDBY = 0x61

GP1294AI_MAX_FREQ = 4167000
GP1294AI_DEFAULT_BRIGHTNESS = 0x0028

cmd_reset = [GP1294AI_CMD_RESET]
cmd_init = [GP1294AI_CMD_VFD_MODE, 0x01, 0x01F, 0x00, 0xFF, 0x2F, 0x00, 0x20]
cmd_brightness = [GP1294AI_CMD_BRIGHTNESS, GP1294AI_DEFAULT_BRIGHTNESS & 0xFF, (GP1294AI_DEFAULT_BRIGHTNESS >> 8) & 0xFF]
cmd_offset = [GP1294AI_CMD_DISPLAY_OFFSET, 0x00, 0x00]
cmd_mode = [GP1294AI_CMD_DISPLAY_MODE, 0x00]
cmd_init_osc = [GP1294AI_CMD_OSC_SETTING, 0x08]

# We only have SPI bus 0 available to us on the Pi
bus = 0

#Device is the chip select pin. Set to 0 or 1, depending on the connections
device = 0

# Enable SPI
spi = spidev.SpiDev()

# Open a connection to a specific bus and device (chip select pin)
spi.open(bus, device)

# Set SPI speed and mode
spi.max_speed_hz = 500000
spi.mode = 3

def reverse(array):
    for index, value in enumerate(array):
        array[index] = int('{:08b}'.format(value)[::-1], 2)
    return array

def spi_transfer(array):
    spi.xfer2(reverse(array))

def clear():
    empty_frame = [0] * (256*8)
    payload = [0xF0, 0, 0, 48] + empty_frame
    print(len(payload))
    spi_transfer(payload)

def init():
    spi_transfer(cmd_reset)
    spi_transfer(cmd_init)
    spi_transfer(cmd_brightness)
    clear()
    time.sleep(0.02)
    spi_transfer(cmd_offset)
    spi_transfer(cmd_mode)
    spi_transfer(cmd_init_osc)

   

Discussions

mkdxdx wrote 09/09/2023 at 09:33 point

Hey, i'm not well versed in linux, but have you considered to pipe only terminal output to display? 

Instead of translating virtual framebuffer data to pixel commands, make it purely character driven, maybe even with pseudographics, flow control characters and such.

What is then left is to run a script that starts a terminal that sends all of it's output to a display, but there will still be a big question of how to focus user input to it.

  Are you sure? yes | no

gavan1 wrote 09/09/2023 at 04:02 point

I can’t find the final display script in the project files. 

  Are you sure? yes | no