How to connect an I2C display to EmStat Pico?

How to connect an I2C display to EmStat Pico?

  • +1
    •  Analog Employees 
    on Jul 21, 2020 3:25 PM 4 months ago

    To extend the battery powered datalogger I was searching for a simple serial display without too much initialization work to be done at startup and without the need to create any library. The reason for this is, that I wanted to implement the code of the display control inside the MethodScript to demonstrate the standalone capabilities of the EmStat Pico Module.

    I think that I will be able to add the example code to the datalogger script to get some human readable feedback during operation.

    https://learn.adafruit.com/adafruit-led-backpack/0-54-alphanumeric

    The chip used on this board is Holtek HT16K33 with default slave adress 0x70

    The first try EmStat Pico example code example is attached. More details will follow.

    Thanks to PalmSens for the support!

     

    e
    # Declare I2C acknowledge bit var a
    var a
    # Declare loop var i
    var i
    # Declare 16 byte array for sending to HT16K33 device
    array w 16i
    # Init var a 
    store_var a 0i ja
    # Configure I2C GPIOs and set it to 100k clock, 7 bit address
    set_gpio_cfg 0x0300i 2
    i2c_config 100k 7
    # Turn on oscillator at HT16K33
    array_set w 0i 0x21i
    i2c_write 0x70i w 1i a
    # Turn on display at HT16K33
    array_set w 0i 0x81i
    i2c_write 0x70i w 1i a
    # Adjust dimming
    array_set w 0i 0xE1i
    i2c_write 0x70i w 1i a
    # Init var i
    store_var i 0i ja
    # Loop to power off all display segments
    loop i < 16i
    	array_set w i 0x00i
    	add_var i 1i
    endloop
    i2c_write 0x70i w 16i a
    # Power up segments
    # Write at address 0x00
    array_set w 0i 0x00i
    array_set w 1i 0xF3i
    array_set w 2i 0x00i
    i2c_write 0x70i w 3i a
    # Write at address 0x02
    array_set w 0i 0x02i
    array_set w 1i 0x09i
    array_set w 2i 0x12i
    i2c_write 0x70i w 3i a
    # Write at address 0x04
    array_set w 0i 0x04i
    array_set w 1i 0x39i
    array_set w 2i 0x00i
    i2c_write 0x70i w 3i a
    # Write at address 0x06
    array_set w 0i 0x06i
    array_set w 1i 0x3Fi
    array_set w 2i 0x00i
    i2c_write 0x70i w 3i a
    # Print var a content
    pck_start
    pck_add a
    pck_end
    
    #don't forget to copy the empty line 55 to close the script

  • 0
    •  Analog Employees 
    on Jul 24, 2020 8:01 AM 4 months ago in reply to joern3

    I updated the code today.

    don't forget a \n at the end of every methodscript. The Code viewer is removing empty lines when uploading examples.

  • 0
    •  Analog Employees 
    on Jul 27, 2020 3:23 PM 4 months ago in reply to joern3

    Some useful graphic to get your text created e.g.

    "P" == 1111 0011 == 0xF3

    "I" == 0000 1001 == 0x09 and 0001 0010 == 0x12

    "C" == 0011 1001 == 0x39

    "O" == 0011 1111 == 0x3F