The bw_tool is meant to provide a basic commandline access to the bitwizard expansion boards. It was written for the raspberry pi, but has now been proven to work on other Linux platforms with an spidev device as well.
You can download the bw_tool here. If you are using git just type
Each folder contains a make file, so using the command
should work fine.
The simplest invocation:
bw_tool -t "Hello World!"
will display the shown text on an SPI_LCD on the default SPI bus (SPI0). Options modify the defaults.
The above command needs access to the SPI bus. By default Linux does not know if letting users access this bus is going to compromise the system or not. So by default Linux chooses to only allow the root user access to the SPI or I2C bus. So you have the following choices:
- You can run your whole session as root. I use "sudo -s" others recommend "sudo su", while "sudo bash" will also work.
- You can issue only the commands that require spi-bus access as root by prefixing them with "sudo". e.g.:
sudo bw_tool -t "Hello World!"
- you can change the permissions on the device files:
sudo chmod 666 /dev/spidev* sudo chmod 666 /dev/i2c-*
Nowadays the "/dev" filesystem is kept in RAM, not somewhere on disk. So you will need to do that again, at every boot. You could add those commmands to your rc.local (in /etc/) to issue them automatically at every boot. Or you can tell udev that you want those devices world writable. I haven't figured out yet how to do that exactly, so if you want to do the research, feel free to do it that way and report how it's done. (just create a WIKI account and add it here yourself or you can Email to info@ ... and let me do that.)
options specifying the device
will switch to I2C mode.
will use that device. Specify /dev/spidev0.1 for the second SPI bus on the raspberry pi for example. Or /dev/i2c-1 to specify the second I2C bus. This second i2c bus is the one that is broken out on the gpio's of rev2 raspberry pi's.
specifies the address of the device to use. Note that BitWizard uses the full 8 bits that are sent to the device. Add one for "read" operation. In some circles, notably I2C, it is customary to specify just those 7 bits. Thus when the I2C_LCD is at the default address of 0x82, i2cdetect will scan it at address 0x41.
options sending data
will send the text to the device, at port zero. The port cannot be changed, but all BitWizard PCBs that have the option of displaying text have the text port at port zero.
will write the byte to the port at addr. For LCD-equipped boards for example -w 12:50 will set the contrast to 0x50.
will write the 16-bit short to the port at addr. For example -W 81:1000 will write the value 0x1000 to the numsamples port on an analog-equipped board.
reads the data at port from the device. Datasize can be 'b' for byte (default), 's' for short (16 bits), or 'i' for a 32-bit integer.
To test sending data to SPI devices, there is the
option. This simply sends the bytes specified, and reports back what was received. Note that bitwizard boards will not send any data until they have been selected, so the first byte received will represent whatever static is found on the bus.