firmware/src/vfddriver.c
// initialize spi interface to hv5812 display driver with auxiliary pins
initialize spi interface to hv5812 display driver with auxiliary pins
initialize spi interface to hv5812 display driver with auxiliary pins
void vfd_init_spi(vfd_pin_t *pin) {
  vfd.pin = *pin;
  spi_bus_config_t buscfg = {
    .sclk_io_num   = vfd.pin.clock,
    .mosi_io_num   = vfd.pin.data,
    .miso_io_num   = -1,
    .quadhd_io_num = -1,
    .quadwp_io_num = -1,
  };
  ESP_ERROR_CHECK(spi_bus_initialize(VFD_SPI_HOST, &buscfg, 0));
  ESP_LOGI(TAG, "hspi bus configured with { clock: %d, data: %d }",
    vfd.pin.clock, vfd.pin.data);
  spi_device_interface_config_t devcfg = {
    .clock_speed_hz = 20*1000*1000,
    .mode = 0,
    .pre_cb  = vfd_strobe_low,
    .post_cb = vfd_strobe_high,
    .command_bits = 0,
    .address_bits = 0,
    .dummy_bits = 0,
    .duty_cycle_pos = 128,
    .spics_io_num = -1,
    .queue_size = 4,
  };
  ESP_ERROR_CHECK(spi_bus_add_device(VFD_SPI_HOST, &devcfg, &vfd.spidev));
  ESP_LOGI(TAG, "device added to bus with { strobe: %d }", vfd.pin.strobe);
  gpio_init_output( vfd.pin.strobe,   0 ); 
  gpio_init_output( vfd.pin.blank,    0 ); 
  gpio_init_output( vfd.pin.fil_shdn, 0 ); 
  gpio_init_output( vfd.pin.hv_shdn,  1 ); 
  gpio_init_output( vfd.pin.enable,   0 ); 
  vfd_transmit(0);
}
void vfd_init_spi ( vfd_pin_t * pin ) { vfd . pin = * pin ; spi_bus_config_t buscfg = { . sclk_io_num = vfd . pin . clock , . mosi_io_num = vfd . pin . data , . miso_io_num = -1 , . quadhd_io_num = -1 , . quadwp_io_num = -1 , } ; ESP_ERROR_CHECK ( spi_bus_initialize ( VFD_SPI_HOST , & buscfg , 0 ) ) ; ESP_LOGI ( TAG , " " , vfd . pin . clock , vfd . pin . data ) ; spi_device_interface_config_t devcfg = { . clock_speed_hz = 20 * 1000 * 1000 , . mode = 0 , . pre_cb = vfd_strobe_low , . post_cb = vfd_strobe_high , . command_bits = 0 , . address_bits = 0 , . dummy_bits = 0 , . duty_cycle_pos = 128 , . spics_io_num = -1 , . queue_size = 4 , } ; ESP_ERROR_CHECK ( spi_bus_add_device ( VFD_SPI_HOST , & devcfg , & vfd . spidev ) ) ; ESP_LOGI ( TAG , " " , vfd . pin . strobe ) ; gpio_init_output ( vfd . pin . strobe , 0 ) ; gpio_init_output ( vfd . pin . blank , 0 ) ; gpio_init_output ( vfd . pin . fil_shdn , 0 ) ; gpio_init_output ( vfd . pin . hv_shdn , 1 ) ; gpio_init_output ( vfd . pin . enable , 0 ) ; vfd_transmit ( 0 ) ; }
initialize spi interface to hv5812 display driver with auxiliary pins
initialize spi interface to hv5812 display driver with auxiliary pins
// configure the spi bus // add the device on the bus // HV5812 maximum rated frequency @ 125°C, 5V is 5 MHz // we're overclocking here, but it works for me™ // configure auxiliary gpios for display driver // don't latch immediately // don't blank outputs // filament supply on // high-voltage supply on // enable level shifter // set all hv pins to off once