Character display connection tutorial

From Sim Innovations Wiki
Jump to navigation Jump to search
Example Max7219 display

Description

Character displays come in various designs. Right now the MAX7219 and HD44780 based character boards are supported, and the control of 8-segment modules.

Examples

MAX7219

This example will focus on the MAX7219 character boards, which are available on internet for reasonable prices. The MAX7219 character displays consist of a small board with eight 7-segment LED displays, controlled by the MAX7219 driver chip. The boards can be daisy chained up to about 5 to 8 boards, depending on your power supply. You can use the display to create for example a radio. It can also display a alphabet characters, but since it is a 7-segment display, this is limited to A, b, C, c, d, E, F, H, h, L, l, O, o, P, and S. In the first example we will set the frequency of COM1 on the display.

The naming of the pins might be different on these boards.
Data pin:  DIN
Clock pin: CLK
Load pin:  CS
display_chr_com1 = hw_chr_display_add("COM1 frequency", "MAX7219", 1)

function new_frequency(com1)
    -- Set text COM1 frequency on display 0 (first), line 0
    hw_chr_display_set_text(display_chr_com1, 0, 0, string.format("%07.03f", com1 / 1000) )
end

xpl_dataref_subscribe("sim/cockpit2/radios/actuators/com1_frequency_hz_833", "INT", new_frequency)

When using two of these displays daisy chained showing COM1 and NAV1.

display_chr_radio1 = hw_chr_display_add("Radio 1", "MAX7219", 2)

function new_frequency(com1, nav1)
    -- Set the COM1 frequency on display 0 (first), line 0
    hw_chr_display_set_text(display_chr_radio1, 0, 0, string.format("%07.03f", com1 / 1000) )
    -- Set the NAV1 frequency on display 1 (second), line 0
    hw_chr_display_set_text(display_chr_radio1, 1, 0, string.format("%06.02f", nav1 / 100) )
end

xpl_dataref_subscribe("sim/cockpit2/radios/actuators/com1_frequency_hz_833", "INT", 
                      "sim/cockpit2/radios/actuators/nav1_frequency_hz", "INT", new_frequency)