Flashing the firmware

Uncomment and run the cell below to flash the hv513-board firmware to an Arduino that is connected to the computer's serial port.


In [ ]:
#!python -m hv513_board.bin.upload uno

In [ ]:
import numpy as np
from hv513_board import SerialProxy

In [ ]:
try:
    # cleanup serial proxy object (if it exists)
    proxy.terminate()
except NameError:
    pass

# create a new serial proxy object
proxy = SerialProxy()
print proxy.properties
print 'ram_free =', proxy.ram_free()

In [ ]:
proxy.channel_count

In [ ]:
# this is the auto-generated accessor of the state_of_channels byte array
proxy._state_of_channels()

In [ ]:
# set the state of all channels high using the auto-generated setter
proxy._set_state_of_channels([255] * (proxy.channel_count / 8))
proxy._state_of_channels()

In [ ]:
# access the state of channels through the new wrapped "property"
# (each byte in this array represents a single channel; 0 is low and 1 is high)
proxy.state_of_channels

In [ ]:
# set all channels to zero using the new wrapped "property"
proxy.state_of_channels = np.zeros(proxy.channel_count, dtype=np.uint8)
proxy.state_of_channels

In [ ]:
# set all channels to one using the new wrapped "property"
proxy.state_of_channels = np.ones(proxy.channel_count, dtype=np.uint8)
proxy.state_of_channels

In [ ]:
# reset the config fields to their defaults and print them
proxy.reset_config()
config = proxy.config
for k in config.DESCRIPTOR.fields_by_name.keys():
    exec('print "%s =", config.%s' % (k, k))

In [ ]:
# update some of the config fields (including custom fields)
proxy.update_config(i2c_address=10, serial_number=1, max_waveform_voltage=100)

# print all config fields
config = proxy.config
for k in config.DESCRIPTOR.fields_by_name.keys():
    exec('print "%s =", config.%s' % (k, k))

In [ ]: