# BITBANG BITSTREAM | WS2812

Compatible with:
DOS Maximite CMM MM150 MM170 MM+ MMX Picromite ArmiteL4 Armite F4 ArmiteH7 Picomite CMM2

Syntax:
BITBANG BITSTREAM pinno, n_transitions, array%()
BITBANG WS2812 type, pin, colours%()

Description:

BITBANG BITSTREAM pinno, n_transitions, array%()
This command is used to generate an extremely accurate bit sequence on the pin specified.
The pin must have previously been set up as an output and set to the required starting level.
The array contains the length of each level in the bitstream in microseconds. The maximum period allowed is 65.5 mSec
The first transition will occur immediately on executing the command.
The last period in the array is ignored other than defining the time before control returns to the program or command line.
The pin is left in the starting state if the number of transitions is even and the opposite state if the number of transitions is odd.

This is equivalent to the 'bitbang' Cfunction for the micromites.

BITBANG WS2812 type, pin, colours%()
This command outputs the required signals to drive one or more WS2812 LED chips connected to 'pin'.
Note that the pin must be set to a digital output before this command is used.
'type' is a single character specifying the type of chip being driven:
O = original WS2812
B = WS2812B
S = SK6812
The 'colours%()' array should be an integer array sized to have exactly the same number of elements as the number of LEDs to be driven.
Each element in the array should contain the colour in the normal RGB888 format (ie, 0 to &HFFFFFF).

Additional options for the picomite:

Syntax:
BITBANG HUMID pin, tvar, hvar [,DHT11]
BITBANG LCD INIT d4, d5, d6, d7, rs, en
BITBANG LCD line, pos, text$
BITBANG LCD CLEAR
BITBANG LCD CLOSE
BITBANG LCD CMD d1 [, d2 [, etc]]
BITBANG LCD DATA d1 [, d2 [, etc]]

Description:

BITBANG HUMID pin, tvar, hvar [,DHT11]
Returns the temperature and humidity using the DHT22 sensor.
Alternative versions of the DHT22 are the AM2303 or the RHT03 (all are compatible).
'pin' is the I/O pin connected to the sensor. Any I/O pin may be used.
'tvar' is the variable that will hold the measured temperature and 'hvar' is the same for humidity. Both must be present and both must be floating point variables.
For example:
BITBANG HUMID 3, TEMP!, HUMIDITY!
Temperature is measured in ºC and the humidity is percent relative humidity.
Both will be measured with a resolution of 0.1. If an error occurs (sensor not connected or corrupt signal) both values will be 1000.0.
Normally the DHT22 should powered by 3.3V to keep its output below 3.6V for the PicoMite.
The signal pin of should be pulled up by a 1K to 10K resistor (4.7K recommended) to 3.3V.
The optional DHT11 parameter modifies the timings to work with the DHT11. Set to 1 for DHT11 and 0 or omit for DHT22.

BITBANG LCD INIT d4, d5, d6, d7, rs, en
BITBANG LCD line, pos, text$
BITBANG LCD CLEAR
BITBANG LCD CLOSE
Display text on an LCD character display module. This command will work with most 1-line, 2-line or 4-line LCD modules that use the KS0066,
HD44780 or SPLC780 controller (however this is not guaranteed).
The BITBANG LCD INIT command is used to initialise the LCD module for use.
'd4' to 'd7' are the I/O pins that connect to inputs D4 to D7 on the LCD module (inputs D0 to D3 should be connected to ground).
'rs' is the pin connected to the register select input on the module (sometimes called CMD).
'en' is the pin connected to the enable or chip select input on the module.
The R/W input on the module should always be grounded. The above I/O pins are automatically set to outputs by this command.
When the module has been initialised data can be written to it using the BITBANG LCD command. 'line' is the line on the display (1 to 4) and 'pos' is the character
location on the line (the first location is 1). 'text$' is a string containing the text to write to the LCD display.
'pos' can also be C8, C16, C20 or C40 in which case the line will be cleared and the text centred on a 8 or 16, 20 or 40 line display.
For example:
BITBANG LCD 1, C16, "Hello"
BITBANG LCD CLEAR will erase all data displayed on the LCD and BITBANG LCD CLOSE will terminate the LCD function and return all I/O pins to the not configured state.

BITBANG LCD CMD d1 [, d2 [,etc]]
BITBANG LCD DATA d1 [, d2[, etc]]
These commands will send one or more bytes to an LCD display as either a command (BITBANG LCD CMD) or as data (BITBANG LCD DATA).
Each byte is a number between 0 and 255 and must be separated by commas. The LCD must have been previously initialised using the BITBANG LCD INIT command (see above).
These commands can be used to drive a non standard LCD in "raw mode" or they can be used to enable specialised features such as scrolling, cursors and custom character sets.
You will need to refer to the data sheet for your LCD to find the necessary command and data values.

Last edited: 22 August, 2022