Fix bit, bthci, can, encoder, eth, i2s docs (#3432)
* Fix bit, bthci, can, encoder, eth, i2s docs * Fix bit, mqtt, qrcodegen, sigma-delta, sodium, time docs. * Add object name in http.md
This commit is contained in:
parent
1927b22c17
commit
39dc2e050f
|
@ -9,166 +9,166 @@ Bit manipulation support, on 32bit integers.
|
|||
## bit.arshift()
|
||||
Arithmetic right shift a number equivalent to `value >> shift` in C.
|
||||
|
||||
####Syntax
|
||||
#### Syntax
|
||||
`bit.arshift(value, shift)`
|
||||
|
||||
####Parameters
|
||||
#### Parameters
|
||||
- `value` the value to shift
|
||||
- `shift` positions to shift
|
||||
|
||||
####Returns
|
||||
#### Returns
|
||||
the number shifted right (arithmetically)
|
||||
|
||||
## bit.band()
|
||||
|
||||
Bitwise AND, equivalent to `val1 & val2 & ... & valn` in C.
|
||||
|
||||
####Syntax
|
||||
#### Syntax
|
||||
`bit.band(val1, val2 [, ... valn])`
|
||||
|
||||
####Parameters
|
||||
- `val1` first AND argument
|
||||
- `val2` second AND argument
|
||||
- `...valn` ...nth AND argument
|
||||
#### Parameters
|
||||
- `val1` first AND argument
|
||||
- `val2` second AND argument
|
||||
- `...valn` ...nth AND argument
|
||||
|
||||
####Returns
|
||||
#### Returns
|
||||
the bitwise AND of all the arguments (number)
|
||||
|
||||
## bit.bit()
|
||||
|
||||
Generate a number with a 1 bit (used for mask generation). Equivalent to `1 << position` in C.
|
||||
|
||||
####Syntax
|
||||
#### Syntax
|
||||
`bit.bit(position)`
|
||||
|
||||
####Parameters
|
||||
#### Parameters
|
||||
`position` position of the bit that will be set to 1
|
||||
|
||||
####Returns
|
||||
#### Returns
|
||||
a number with only one 1 bit at position (the rest are set to 0)
|
||||
|
||||
## bit.bnot()
|
||||
|
||||
Bitwise negation, equivalent to `~value in C.
|
||||
|
||||
####Syntax
|
||||
#### Syntax
|
||||
`bit.bnot(value)`
|
||||
|
||||
####Parameters
|
||||
#### Parameters
|
||||
`value` the number to negate
|
||||
|
||||
####Returns
|
||||
#### Returns
|
||||
the bitwise negated value of the number
|
||||
|
||||
## bit.bor()
|
||||
Bitwise OR, equivalent to `val1 | val2 | ... | valn` in C.
|
||||
|
||||
####Syntax
|
||||
#### Syntax
|
||||
`bit.bor(val1, val2 [, ... valn])`
|
||||
|
||||
####Parameters
|
||||
#### Parameters
|
||||
- `val1` first OR argument.
|
||||
- `val2` second OR argument.
|
||||
- `...valn` ...nth OR argument
|
||||
|
||||
####Returns
|
||||
#### Returns
|
||||
the bitwise OR of all the arguments (number)
|
||||
|
||||
## bit.bxor()
|
||||
|
||||
Bitwise XOR, equivalent to `val1 ^ val2 ^ ... ^ valn` in C.
|
||||
|
||||
####Syntax
|
||||
#### Syntax
|
||||
`bit.bxor(val1, val2 [, ... valn])`
|
||||
|
||||
####Parameters
|
||||
#### Parameters
|
||||
- `val1` first XOR argument
|
||||
- `val2` second XOR argument
|
||||
- `...valn` ...nth XOR argument
|
||||
|
||||
####Returns
|
||||
#### Returns
|
||||
the bitwise XOR of all the arguments (number)
|
||||
|
||||
## bit.clear()
|
||||
Clear bits in a number.
|
||||
|
||||
####Syntax
|
||||
#### Syntax
|
||||
`bit.clear(value, pos1 [, ... posn])`
|
||||
|
||||
####Parameters
|
||||
#### Parameters
|
||||
- `value` the base number
|
||||
- `pos1` position of the first bit to clear
|
||||
- `...posn` position of thet nth bit to clear
|
||||
|
||||
####Returns
|
||||
#### Returns
|
||||
the number with the bit(s) cleared in the given position(s)
|
||||
|
||||
## bit.isclear()
|
||||
|
||||
Test if a given bit is cleared.
|
||||
|
||||
####Syntax
|
||||
#### Syntax
|
||||
`bit.isclear(value, position)`
|
||||
|
||||
####Parameters
|
||||
#### Parameters
|
||||
- `value` the value to test
|
||||
- `position` bit position to test
|
||||
|
||||
####Returns
|
||||
true if the bit at the given position is 0, false othewise
|
||||
#### Returns
|
||||
`true` if the bit at the given position is 0, `false` othewise
|
||||
|
||||
## bit.isset()
|
||||
|
||||
Test if a given bit is set.
|
||||
|
||||
####Syntax
|
||||
#### Syntax
|
||||
`bit.isset(value, position)`
|
||||
|
||||
####Parameters
|
||||
#### Parameters
|
||||
- `value` the value to test
|
||||
- `position` bit position to test
|
||||
|
||||
####Returns
|
||||
true if the bit at the given position is 1, false otherwise
|
||||
#### Returns
|
||||
`true` if the bit at the given position is 1, `false` otherwise
|
||||
|
||||
## bit.lshift()
|
||||
Left-shift a number, equivalent to `value << shift` in C.
|
||||
|
||||
####Syntax
|
||||
#### Syntax
|
||||
`bit.lshift(value, shift)`
|
||||
|
||||
####Parameters
|
||||
#### Parameters
|
||||
- `value` the value to shift
|
||||
- `shift` positions to shift
|
||||
|
||||
####Returns
|
||||
#### Returns
|
||||
the number shifted left
|
||||
|
||||
## bit.rshift()
|
||||
|
||||
Logical right shift a number, equivalent to `( unsigned )value >> shift` in C.
|
||||
|
||||
####Syntax
|
||||
#### Syntax
|
||||
`bit.rshift(value, shift)`
|
||||
|
||||
####Parameters
|
||||
#### Parameters
|
||||
- `value` the value to shift.
|
||||
- `shift` positions to shift.
|
||||
|
||||
####Returns
|
||||
#### Returns
|
||||
the number shifted right (logically)
|
||||
|
||||
## bit.set()
|
||||
|
||||
Set bits in a number.
|
||||
|
||||
####Syntax
|
||||
#### Syntax
|
||||
`bit.set(value, pos1 [, ... posn ])`
|
||||
|
||||
####Parameters
|
||||
#### Parameters
|
||||
- `value` the base number.
|
||||
- `pos1` position of the first bit to set.
|
||||
- `...posn` position of the nth bit to set.
|
||||
|
||||
####Returns
|
||||
#### Returns
|
||||
the number with the bit(s) set in the given position(s)
|
||||
|
|
|
@ -11,7 +11,7 @@ Advertisements are an easy way of publishing sensor data to e.g. a
|
|||
smartphone app.
|
||||
|
||||
|
||||
# bthci.rawhci(hcibytes, callback)
|
||||
## bthci.rawhci(hcibytes, callback)
|
||||
|
||||
Sends a raw HCI command to the BlueTooth controller.
|
||||
|
||||
|
@ -63,7 +63,7 @@ bthci.reset(function(err) print(err or "Ok!") end)
|
|||
```
|
||||
|
||||
|
||||
# bthci.adv.enable(onoff, callback)
|
||||
## bthci.adv.enable(onoff, callback)
|
||||
|
||||
Enables or disables BlueTooth LE advertisements.
|
||||
|
||||
|
@ -86,7 +86,7 @@ bthci.adv.enable(1, function(err) print(err or "Ok!") end)
|
|||
```
|
||||
|
||||
|
||||
# bthci.adv.setdata(advbytes, callback)
|
||||
## bthci.adv.setdata(advbytes, callback)
|
||||
|
||||
Configures the data to advertise.
|
||||
|
||||
|
@ -109,7 +109,7 @@ bthci.adv.setdata(encoder.fromHex("080861626364656667"), function(err) print(err
|
|||
```
|
||||
|
||||
|
||||
# bthci.adv.setparams(paramtable, callback)
|
||||
## bthci.adv.setparams(paramtable, callback)
|
||||
|
||||
Configures advertisement parameters.
|
||||
|
||||
|
@ -118,21 +118,19 @@ Configures advertisement parameters.
|
|||
|
||||
#### Parameters
|
||||
- `paramtable` a table with zero or more of the following fields:
|
||||
- `interval_min` value in units of 0.625ms. Default 0x0400 (0.64s).
|
||||
- `interval_max` value in units of 0.625ms. Default 0x0800 (1.28s).
|
||||
- `type` advertising type, one of following constants:
|
||||
- `bthci.adv.CONN_UNDIR`, the default (ADV_IND in BT spec)
|
||||
- `bthci.adv.CONN_DIR_HI` (ADV_DIRECT_IND, high duty cycle in the BT spec)
|
||||
- `bthci.adv.SCAN_UNDIR` (ADV_SCAN_IND in the BT spec)
|
||||
- `bthci.adv.NONCONN_UNDIR` (ADV_NONCONN_IND in the BT spec)
|
||||
- `bthci.adv.CONN_DIR_LO` (ADV_DIRECT_IND, low duty cycle in the BT spec)
|
||||
- `own_addr_type` own address type. Default 0 (public address).
|
||||
- `peer_addr_type` peer address type. Default 0 (public address).
|
||||
- `peer_addr` TODO, not yet implemented
|
||||
- `channel_map` which channels to advertise on. The constants
|
||||
`bthci.adv.CHAN_37`, `bthci.adv.CHAN_38`, `bthci.adv.CHAN_39` or
|
||||
`bthci.adv.CHAN_ALL` may be used. Default is all channels.
|
||||
- `filter_policy` filter policy, default 0 (no filtering).
|
||||
- `interval_min` value in units of 0.625ms. Default 0x0400 (0.64s).
|
||||
- `interval_max` value in units of 0.625ms. Default 0x0800 (1.28s).
|
||||
- `type` advertising type, one of following constants:
|
||||
- `bthci.adv.CONN_UNDIR`, the default (ADV_IND in BT spec)
|
||||
- `bthci.adv.CONN_DIR_HI` (ADV_DIRECT_IND, high duty cycle in the BT spec)
|
||||
- `bthci.adv.SCAN_UNDIR` (ADV_SCAN_IND in the BT spec)
|
||||
- `bthci.adv.NONCONN_UNDIR` (ADV_NONCONN_IND in the BT spec)
|
||||
- `bthci.adv.CONN_DIR_LO` (ADV_DIRECT_IND, low duty cycle in the BT spec)
|
||||
- `own_addr_type` own address type. Default 0 (public address).
|
||||
- `peer_addr_type` peer address type. Default 0 (public address).
|
||||
- `peer_addr` TODO, not yet implemented
|
||||
- `channel_map` which channels to advertise on. The constants `bthci.adv.CHAN_37`, `bthci.adv.CHAN_38`, `bthci.adv.CHAN_39` or `bthci.adv.CHAN_ALL` may be used. Default is all channels.
|
||||
- `filter_policy` filter policy, default 0 (no filtering).
|
||||
- `callback` optional function to be invoked when the reset completes. Its
|
||||
only argument is the HCI error code, or `nil` on success.
|
||||
|
||||
|
@ -145,7 +143,7 @@ bthci.adv.setparams({type=bthci.adv.NONCONN_UNDIR}, function(err) print(err or "
|
|||
```
|
||||
|
||||
|
||||
# bthci.scan.enable(onoff, callback)
|
||||
## bthci.scan.enable(onoff, callback)
|
||||
|
||||
Enables or disable scanning for advertisements from other BlueTooth devices.
|
||||
|
||||
|
@ -166,7 +164,7 @@ bthci.scan.enable(1, function(err) print(err or "Ok!") end)
|
|||
```
|
||||
|
||||
|
||||
# bthci.scan.setparams(paramstable, callback)
|
||||
## bthci.scan.setparams(paramstable, callback)
|
||||
|
||||
Configures scan parameters.
|
||||
|
||||
|
@ -178,11 +176,11 @@ this will fully occupy the radio and no other activity takes place.
|
|||
|
||||
#### Parameters
|
||||
- `paramstable` a table with zero or more of the following fields:
|
||||
- `mode` scanning mode, 0 for passive, 1 for active. Default 0.
|
||||
- `interval` scanning interval in units of 0.625ms. Default 0x0010.
|
||||
- `window` length of scanning window in units of 0.625ms. Default 0x0010.
|
||||
- `own_addr_type` own address type. Default 0 (public).
|
||||
- `filter_policy` filtering policy. Default 0 (no filtering).
|
||||
- `mode` scanning mode, 0 for passive, 1 for active. Default 0.
|
||||
- `interval` scanning interval in units of 0.625ms. Default 0x0010.
|
||||
- `window` length of scanning window in units of 0.625ms. Default 0x0010.
|
||||
- `own_addr_type` own address type. Default 0 (public).
|
||||
- `filter_policy` filtering policy. Default 0 (no filtering).
|
||||
- `callback` optional function to be invoked when the reset completes. Its
|
||||
only argument is the HCI error code, or `nil` on success.
|
||||
|
||||
|
@ -194,7 +192,7 @@ this will fully occupy the radio and no other activity takes place.
|
|||
bthci.scan.setparams({mode=1,interval=40,window=20},function(err) print(err or "Ok!") end)
|
||||
```
|
||||
|
||||
# bthci.scan.on(event, callback)
|
||||
## bthci.scan.on(event, callback)
|
||||
|
||||
Registers the callback to be passed any received advertisements.
|
||||
|
||||
|
|
|
@ -18,13 +18,32 @@ Send a frame.
|
|||
- `data` CAN data, up to 8 bytes
|
||||
|
||||
#### Returns
|
||||
nil
|
||||
`nil`
|
||||
|
||||
|
||||
## can.setup()
|
||||
Configuration CAN controller.
|
||||
|
||||
#### Syntax
|
||||
`can.setup(config, callback)`
|
||||
|
||||
#### Parameters
|
||||
- `config` table.
|
||||
- `speed` kbps. One of following value: `1000`, `800`, `500`, `250`, `100`.
|
||||
- `tx` Pin num for TX.
|
||||
- `rx` Pin num for RX.
|
||||
- `dual_filter` `true` dual filter mode, `false` single filter mode (default)
|
||||
- `code` 4-bytes integer. Use this with mask to filter CAN frame. Default: `0`. See [SJA1000](http://www.nxp.com/documents/data_sheet/SJA1000.pdf)
|
||||
- `mask` 4-bytes integer. Default: `0xffffffff`
|
||||
- `callback` function to be called when CAN data received.
|
||||
- `format` Frame format. `can.STANDARD_FRAME` or `can.EXTENDED_FRAME`
|
||||
- `msg_id` CAN Message ID
|
||||
- `data` CAN data, up to 8 bytes
|
||||
|
||||
#### Returns
|
||||
`nil`
|
||||
|
||||
#### Example
|
||||
```lua
|
||||
can.setup({
|
||||
speed = 1000,
|
||||
|
@ -36,23 +55,6 @@ can.setup({
|
|||
}, function(format, msg_id, data) end)
|
||||
```
|
||||
|
||||
#### Parameters
|
||||
- `config`
|
||||
- `speed` kbps. One of following value: `1000`, `800`, `500`, `250`, `100`.
|
||||
- `tx` Pin num for TX.
|
||||
- `rx` Pin num for RX.
|
||||
- `dual_filter` `true` dual filter mode, `false` single filter mode (default)
|
||||
- `code` 4-bytes integer. Use this with mask to filter CAN frame. Default: `0`. See [SJA1000](http://www.nxp.com/documents/data_sheet/SJA1000.pdf)
|
||||
- `mask` 4-bytes integer. Default: `0xffffffff`
|
||||
- `callback` function to be called when CAN data received.
|
||||
- `format` Frame format. `can.STANDARD_FRAME` or `can.EXTENDED_FRAME`
|
||||
- `msg_id` CAN Messge ID
|
||||
- `data` CAN data, up to 8 bytes
|
||||
|
||||
#### Returns
|
||||
nil
|
||||
|
||||
|
||||
## can.start()
|
||||
Start CAN controller.
|
||||
|
||||
|
@ -60,9 +62,10 @@ Start CAN controller.
|
|||
`can.start()`
|
||||
|
||||
#### Parameters
|
||||
none
|
||||
|
||||
#### Returns
|
||||
nil
|
||||
`nil`
|
||||
|
||||
|
||||
## can.stop()
|
||||
|
@ -72,6 +75,7 @@ Stop CAN controller.
|
|||
`can.stop()`
|
||||
|
||||
#### Parameters
|
||||
none
|
||||
|
||||
#### Returns
|
||||
nil
|
||||
`nil`
|
||||
|
|
|
@ -15,7 +15,7 @@ Provides a Base64 representation of a (binary) Lua string.
|
|||
#### Parameters
|
||||
`binary` input string to Base64 encode
|
||||
|
||||
#### Return
|
||||
#### Returns
|
||||
A Base64 encoded string.
|
||||
|
||||
#### Example
|
||||
|
@ -34,7 +34,7 @@ thrown if the string is not a valid base64 encoding.
|
|||
#### Parameters
|
||||
`b64` Base64 encoded input string
|
||||
|
||||
#### Return
|
||||
#### Returns
|
||||
The decoded Lua (binary) string.
|
||||
|
||||
#### Example
|
||||
|
|
|
@ -46,7 +46,7 @@ Connection speed in Mbit/s, or error if not connected.
|
|||
## eth.init()
|
||||
Initialize the PHY chip and set up its tcpip adapter.
|
||||
|
||||
#### Synatx
|
||||
#### Syntax
|
||||
```lua
|
||||
eth.init(cfg)
|
||||
```
|
||||
|
|
|
@ -30,7 +30,7 @@ Creates a connection object which can be configured and then executed. Note this
|
|||
- `timeout` Network timeout, in milliseconds. If not specified, the default is `10000` (10 seconds).
|
||||
|
||||
#### Returns
|
||||
The connection object.
|
||||
`connection` The connection object.
|
||||
|
||||
#### Example
|
||||
```lua
|
||||
|
|
|
@ -16,7 +16,7 @@ The I2S module provides access to the in-built two I2S controllers.
|
|||
Mute the I2S channel. The hardware buffer is instantly filled with silence.
|
||||
|
||||
#### Syntax
|
||||
`i2s.mute(i2s_num)
|
||||
`i2s.mute(i2s_num)`
|
||||
|
||||
#### Parameters
|
||||
- `i2s_num` I2S peripheral 0 or 1
|
||||
|
|
|
@ -203,7 +203,7 @@ Publishes a message.
|
|||
|
||||
#### Parameters
|
||||
- `topic` the topic to publish to ([topic string](http://www.hivemq.com/blog/mqtt-essentials-part-5-mqtt-topics-best-practices))
|
||||
- `message` the message to publish, (buffer or string)
|
||||
- `payload` the message to publish, (buffer or string)
|
||||
- `qos` QoS level
|
||||
- `retain` retain flag
|
||||
- `function(client)` optional callback fired when PUBACK received. NOTE: When calling publish() more than once, the last callback function defined will be called for ALL publish commands.
|
||||
|
|
|
@ -47,6 +47,9 @@ Returns the side length in pixels of the given QR Code. The result is in the ran
|
|||
## qrcodegen.getPixel(qrcode, x, y)
|
||||
Get the color of the pixel at the given coordinates of the QR Code. `x` and `y` must be between `0` and the value returned by `qrcodegen.getSize()`.
|
||||
|
||||
#### Syntax
|
||||
`qrcodegen.getPixel(qrcode, x, y)`
|
||||
|
||||
#### Parameters
|
||||
- `qrcode` a QR Code string, as returned by `qrcodegen.encodeText()`.
|
||||
- `x`
|
||||
|
|
|
@ -23,7 +23,7 @@ Reenables GPIO functionality at the related pin.
|
|||
Sets the prescale value.
|
||||
|
||||
#### Syntax
|
||||
`sigma_delta.setprescale(channel, value)
|
||||
`sigma_delta.setprescale(channel, value)`
|
||||
|
||||
#### Parameters
|
||||
- `channel` 0~7, sigma-delta channel index
|
||||
|
|
|
@ -56,6 +56,9 @@ The keys created by `crypto_box.keypair()` can be used the `crypto_box.seal*()`
|
|||
## sodium.crypto_box.keypair()
|
||||
Generates a new keypair. Wifi must be started, by calling `wifi.start()`, before calling this function.
|
||||
|
||||
#### Syntax
|
||||
`sodium.crypto_box.keypair()`
|
||||
|
||||
#### Parameters
|
||||
None
|
||||
|
||||
|
@ -88,7 +91,7 @@ The encrypted message, as a string. Errors if `public_key` is not a valid public
|
|||
ciphertext = sodium.crypto_box.seal(message, public_key)
|
||||
```
|
||||
|
||||
## sodium.crypto_box.seal_open
|
||||
## sodium.crypto_box.seal_open()
|
||||
Decrypts a message encrypted with [`crypto_box.seal()`](#sodiumcryptoboxseal).
|
||||
|
||||
#### Syntax
|
||||
|
|
|
@ -43,7 +43,7 @@ time.set(timestamp)
|
|||
Converts timestamp in Unix epoch to calendar format
|
||||
|
||||
#### Syntax
|
||||
`time.epoch2cal(time)
|
||||
`time.epoch2cal(time)`
|
||||
|
||||
#### Parameters
|
||||
- `time` number of seconds since the Epoch
|
||||
|
@ -76,7 +76,7 @@ print(string.format("%04d-%02d-%02d %02d:%02d:%02d DST:%d", time["year"], time["
|
|||
Returns current system time in the Unix epoch (seconds from midnight 1970/01/01).
|
||||
|
||||
#### Syntax
|
||||
time.get()
|
||||
`time.get()`
|
||||
|
||||
#### Parameters
|
||||
none
|
||||
|
@ -100,7 +100,7 @@ sec, usec = time.get()
|
|||
Returns current system time adjusted for the locale in calendar format.
|
||||
|
||||
#### Syntax
|
||||
time.getlocal()
|
||||
`time.getlocal()`
|
||||
|
||||
#### Parameters
|
||||
none
|
||||
|
@ -155,7 +155,7 @@ Checks if NTP client is enabled.
|
|||
none
|
||||
|
||||
#### Returns
|
||||
`true' if NTP client is enabled.
|
||||
`true` if NTP client is enabled.
|
||||
|
||||
|
||||
## time.ntpstop()
|
||||
|
|
Loading…
Reference in New Issue