4ZeroBox Mobile¶
function next_expansion¶
next_expansion(e, selectors=None)
e is the next expansion type module. Use the following table to choose the right expansion.
| module | expansion |
|-----------|-------------|
| `io` | EXP-IO |
| `relay` | EXP-RELAY |
| `ser` | EXP-SER |
| `ain` | EXP-AIN |
selectorsis a tuple with information on position of rotative switches of the expansion. Order follow swiches indexes.
function expansions_on¶
expansions_on()
function expansions_off¶
expansions_off()
function led¶
led(color)
coloris the color to set. Possible colors are.BLACK,WHITE,RED,GREEN,BLUE,YELLOW,CYANandMAGENTA.
function on_button_press¶
on_button_press(fn, dir=FALLING_EDGE, debounce=0)
USER_BUTTON to call an interrupt callback when pressed. fnis the function to be called when the button is pressed;diris the wave edge that will trigger the callback. Default isFALLING_EDGE;debounceis the De-Bounce delay to set.
function init¶
init()
function set_adc_config¶
set_adc_config(pin, pga=1, sps=0)
pinis the pin to configure.pgais the gain. Not implemented yet.spsis the sample for seconds for the ADC pin. Default value use max speed.
function set_adc_callback¶
set_adc_callback(label, pin, cb=None, sens=None)
-
labelis the label of the adc configuration to use. Possible labels are the following:'vol'for voltage reading ADC;'res'for resistive reading ADC;'cur'for current reading ADC;'pow'for power reading ADC.
-
pinis the pin used by the ADC to configure. Possible choices areAIN1toAIN6 -
cbis the callback to setup to the specific channel. The callback should have the following signature:cb(value, sens)wherevaluewill be the electric value passed by the read andsensa some sort of structure with data needed by the conversion callback. The callback should return the converted value. -
sensis some sort of structure with data about the sensor to make the correct conversion.
function read_voltage¶
read_voltage(pin, raw=False, electric=False)
pin is the ADC pin to read from. Possible choices are AIN1 to AIN6 -
rawif set toTrueADC's bits are returned as result. -
electricif set toTrueVoltage value (V) read is returned as result.
Returns the value converted by the pin callback. Voltage value (V) if the callback is set to None.
function read_resistive¶
read_resistive(pin, raw=False, electric=False)
pin is the ADC pin to read from. Possible choices are AIN1 to AIN6 -
rawif set toTrueADC's bits are returned as result. -
electricif set toTrueResistance value (Ohm) read is returned as result.
Returns the value converted by the pin callback. Resistance value (Ohm) if the callback is set to None.
function read_current¶
read_current(pin, raw=False, electric=False)
pin is the ADC pin to read from. Possible choices are AIN1 to AIN6 -
rawif set toTrueADC's bits are returned as result. -
electricif set toTrueCurrent value (mA) read is returned as result.
Returns the value converted by the pin callback. Current value (mA) if the callback is set to None.
function read_power¶
read_power(pin, samples=400, raw=False, electric=False):
samples. Difference between max and min in bits is passed to the callback. -
pinis the ADC pin to read from. Possible choices areAIN1toAIN6 -
samplesis the number of samples to get to find min and max values. Default value is 400. -
rawif set toTrueADC's bits are returned as result. -
electricif set toTrueDiffernce (max - min) Current (mA) read is returned as result.
Returns the value converted by the pin callback. Differnce (max - min) Current (mA) if callback is set to None.
function out_off¶
out_off(out)
outis the relay to open. Possible choices areDOUT1andDOUT2.
function out_on¶
out_on(out)
outis the relay to close. Possible choices areDOUT1andDOUT2.
function is_out_on¶
is_out_on(out)
outis the relay to check. Possible choices areDOUT1andDOUT2.
Returns 1 if the relay is closed, 0 if open.
function get_can¶
get_can(nss=CTS1, spi_clk=20000000)
nssis the chip select pin used to control the CAN peripheral through SPI.spi_clkis the clock speed used by the SPI. Default is 20 MHz.
Returns the initialized CAN object.
function get_serial¶
get_serial(ser=SERIAL1, baud=115200, stopbits=serial.STOPBIT_1, parity=serial.PARITY_NONE, bitsize=serial.BITSIZE_8, mode=serial.MODE_UART, flow_ctrl=serial.HW_FLOWCTRL_DISABLE)
seris the serial port to use. DefaultSERIAL1baudis the baudrate of to use. Default 115200.stopbitsis the stopbits configuration to use. Default 1 stopbit. Seeserialfor possible values.parityis the parity check configuration to use. Default none. Seeserialfor possible values.bitsizeis the bitsize configuration to use. Default size 8. Seeserialfor possible values.modeis the mode to use for the serial. Default RS232. Seeserialfor possible values.flow_ctrlis the flow control configuration to use. Default disabled. Seeserialfor possible values.
Returns the initialized serial object.
function start_cellular¶
start_cellular(apn="", apn_user="", apn_password="",
dhcp=True, ip="", mask="", gateway="",
dns="8.8.8.8", timeout=10000)
apn: is the APN for the network connection. It depends from the SIM card provider.apn_user: the username for the network connection authentication. Usually it is empty. Default value empty string.apn_password: the password for the network connection authentication. Usually it is empty. Default value empty string.
If dhcp is True (the default) other following four IP related arguments are ignored. When dhcp is False, the four IP related arguments are:
ip: is the IP address.mask: the net mask expressed as A.B.C.D dotted address.gateway: the gateway to be used as default router.-
dns: the Domain Name Server to be used for name resolution. Default is "8.8.8.8", the Google DNS. -
timeout: Connection timeout in milliseconds.CellularExceptionis raised if connection do not succeed during this time. Default value 10000 ms.
The cellular module is returned.
function stop_cellular¶
stop_cellular()
function reset_cellular¶
reset_cellular()
function antenna_on¶
antenna_on()
start_cellular method. function antenna_off¶
antenna_off()
function get_status¶
get_status()
function get_psm_ind¶
get_psm_ind()
function get_ring¶
get_ring()
function setup_ring_cb¶
setup_ring_cb(cb)
function get_dcd¶
get_dcd()
function get_power_source¶
get_power_source()
"external", "battery" or "usb". function read_vin¶
read_vin()
function read_vbat¶
read_vbat()
function summary¶
summary()