Fix ledc, otaupgrade, pulsecnt, sdmmc, sjson, touch docs (#3436)
ledc.md - formatting, add object name otaupgrade.md - formatting, add 'Syntax' section pulsecnt.md - formatting, fix syntax pulsecnt.create, add object name sdmmc.md - fix typos sjson.md - formatting, add `Parameters` section touch.md - formatting, add object name, fix Returns in tp:read()
This commit is contained in:
parent
39dc2e050f
commit
8e0e0cb31c
|
@ -49,7 +49,7 @@ List of configuration tables:
|
|||
- `duty` Channel duty, the duty range is [0, (2**bit_num) - 1]. Example: if ledc.TIMER_13_BIT is used maximum value is 4096 x 2 -1 = 8091
|
||||
|
||||
#### Returns
|
||||
`ledc.channel`
|
||||
`channel` ledc.channel
|
||||
|
||||
#### Example
|
||||
```lua
|
||||
|
@ -79,7 +79,7 @@ Disable LEDC output, and set idle level.
|
|||
- `ledc.IDLE_HIGH`
|
||||
|
||||
#### Returns
|
||||
nil
|
||||
`nil`
|
||||
|
||||
#### Example
|
||||
```lua
|
||||
|
@ -96,7 +96,7 @@ Set channel frequency (Hz)
|
|||
- `frequency` What frequency should be set
|
||||
|
||||
#### Returns
|
||||
nil
|
||||
`nil`
|
||||
|
||||
#### Example
|
||||
```lua
|
||||
|
@ -133,7 +133,7 @@ Set channel duty
|
|||
- `duty` What duty should be set
|
||||
|
||||
#### Returns
|
||||
nil
|
||||
`nil`
|
||||
|
||||
#### Example
|
||||
```lua
|
||||
|
@ -170,7 +170,7 @@ Resets the timer
|
|||
None
|
||||
|
||||
#### Returns
|
||||
nil
|
||||
`nil`
|
||||
|
||||
|
||||
#### Example
|
||||
|
@ -189,7 +189,7 @@ Pauses the timer
|
|||
None
|
||||
|
||||
#### Returns
|
||||
nil
|
||||
`nil`
|
||||
|
||||
#### Example
|
||||
```lua
|
||||
|
@ -207,7 +207,7 @@ Resumes a paused timer
|
|||
None
|
||||
|
||||
#### Returns
|
||||
nil
|
||||
`nil`
|
||||
|
||||
#### Example
|
||||
```lua
|
||||
|
@ -229,7 +229,7 @@ Set LEDC fade function, with a limited time.
|
|||
- `ledc.FADE_WAIT_DONE`
|
||||
|
||||
#### Returns
|
||||
nil
|
||||
`nil`
|
||||
|
||||
#### Example
|
||||
```lua
|
||||
|
@ -252,7 +252,7 @@ Set LEDC fade function, with step.
|
|||
- `ledc.FADE_WAIT_DONE`
|
||||
|
||||
#### Returns
|
||||
nil
|
||||
`nil`
|
||||
|
||||
#### Example
|
||||
```lua
|
||||
|
@ -279,7 +279,7 @@ Set LEDC fade function.
|
|||
- `ledc.FADE_WAIT_DONE`
|
||||
|
||||
#### Returns
|
||||
nil
|
||||
`nil`
|
||||
|
||||
#### Example
|
||||
```lua
|
||||
|
|
|
@ -54,18 +54,22 @@ marking a new firmware as valid is to ensure the upgrade server can be
|
|||
reached, on the basis that as long as the firmware can be remotely
|
||||
upgraded, it's "good enough" to accept.
|
||||
|
||||
# otaupgrade.info()
|
||||
## otaupgrade.info()
|
||||
|
||||
The boot info and application state and version info can be queried with
|
||||
this function. Typically it will be used to check the version of the
|
||||
running application, to compare against a "desired" version in order
|
||||
to decide whether an upgrade is required.
|
||||
|
||||
#### Syntax
|
||||
`otaupgrade.info()`
|
||||
|
||||
#### Parameters
|
||||
None.
|
||||
|
||||
#### Returns
|
||||
A list of three values:
|
||||
|
||||
- the name of the partition of the running application
|
||||
- the name of the partition currently marked for boot next (typically the
|
||||
same as the running application, but after `otaupgrade.complete()` it
|
||||
|
@ -99,7 +103,7 @@ end
|
|||
print("Running version: "..info[boot_part].version)
|
||||
```
|
||||
|
||||
# otaupgrade.commence()
|
||||
## otaupgrade.commence()
|
||||
|
||||
Wipes the spare application partition and prepares to receive the new
|
||||
application firmware.
|
||||
|
@ -121,7 +125,7 @@ A Lua error may be raised if the OTA upgrade cannot be commenced for some
|
|||
reason (such as due to incorrect partition setup).
|
||||
|
||||
|
||||
# otaupgrade.write(data)
|
||||
## otaupgrade.write(data)
|
||||
|
||||
Write a chunk of application firmware data to the correct partition and
|
||||
location. Data must be streamed sequentially, the IDF does not support
|
||||
|
@ -141,7 +145,7 @@ data not being a valid OTA image (the IDF performs some checks in this
|
|||
regard).
|
||||
|
||||
|
||||
# otaupgrade.complete(reboot)
|
||||
## otaupgrade.complete(reboot)
|
||||
|
||||
Finalises the upgrade, and optionally reboots into the new application
|
||||
firmware right away.
|
||||
|
@ -192,7 +196,7 @@ end)
|
|||
|
||||
```
|
||||
|
||||
# otaupgrade.accept()
|
||||
## otaupgrade.accept()
|
||||
|
||||
When the installed boot loader is built with rollback support, a new
|
||||
application image is by default only booted once. During this "test run"
|
||||
|
@ -211,7 +215,7 @@ None.
|
|||
`nil`
|
||||
|
||||
|
||||
# otaupgrade.rollback()
|
||||
## otaupgrade.rollback()
|
||||
|
||||
A new firmware may decide that it is not performing as expected, and
|
||||
request an explicit rollback to the previous version. If the call to this
|
||||
|
|
|
@ -14,18 +14,18 @@ a control GPIO for ignoring or decrementing pulses when the control signal is hi
|
|||
|
||||
Create the pulse counter object.
|
||||
|
||||
### Syntax
|
||||
`pulsecnt.create(unit, callbackOnEvents)`
|
||||
#### Syntax
|
||||
`pulsecnt.create(unit, callbackOnEvents [, isDebug])`
|
||||
|
||||
### Parameters
|
||||
#### Parameters
|
||||
- `unit` Required. ESP32 has 0 thru 7 units to count pulses on.
|
||||
- `callbackOnEvents` Optional. Your Lua method to call on event. myfunction(unit, isThr0, isThr1, isLLim, isHLim, isZero) will be called. Event will be PCNT_EVT_THRES_0 (Threshold 0 hit), PCNT_EVT_THRES_1 (Threshold 1 hit), PCNT_EVT_L_LIM (Minimum counter value), PCNT_EVT_H_LIM (Maximum counter value), or PCNT_EVT_ZERO (counter value zero event)
|
||||
- `isDebug` Optional. Turn on extra logging by passing in true.
|
||||
|
||||
### Returns
|
||||
`pulsecnt` object
|
||||
#### Returns
|
||||
`pulsecntObj` pulsecnt object
|
||||
|
||||
### Example
|
||||
#### Example
|
||||
```lua
|
||||
-- Example Pulse Counter for 1 channel with polling of pulse count
|
||||
|
||||
|
@ -54,7 +54,7 @@ pcnt:clear()
|
|||
print("Current pulse counter val:" .. pcnt:getCnt())
|
||||
```
|
||||
|
||||
### Example
|
||||
#### Example
|
||||
```lua
|
||||
-- Example Pulse Counter for 1 channel with callback
|
||||
|
||||
|
@ -104,7 +104,7 @@ pcnt:setThres(thr0, thr1)
|
|||
print("Current pulse counter val:" .. pcnt:getCnt())
|
||||
```
|
||||
|
||||
### Example
|
||||
#### Example
|
||||
```lua
|
||||
-- Example Pulse Counter for 2 push buttons
|
||||
-- Button 1 increments the counter (chan0)
|
||||
|
@ -184,10 +184,10 @@ pcnt:setThres(thr0, thr1)
|
|||
|
||||
Configure channel 0 of the pulse counter object you created from the create() method.
|
||||
|
||||
### Syntax
|
||||
#### Syntax
|
||||
`pulsecntObj:chan0Config(pulse_gpio_num, ctrl_gpio_num, pos_mode, neg_mode, lctrl_mode, hctrl_mode, counter_l_lim, counter_h_lim)`
|
||||
|
||||
### Parameters
|
||||
#### Parameters
|
||||
- `pulse_gpio_num` Required. Any GPIO pin can be used.
|
||||
- `ctrl_gpio_num` Required (although you can specify pulsecnt.PIN_NOT_USED to ignore). Any GPIO pin can be used. If you are trying to use a pin you use as gpio.OUT in other parts of your code, you can instead configure the pin as gpio.IN_OUT and write high or low to it to achieve your gpio.OUT task while still enabling the pulse counter to successfully read the pin state.
|
||||
- `pos_mode` Required. Positive rising edge count mode, i.e. count the pulse when the rising edge occurs.
|
||||
|
@ -209,17 +209,17 @@ Configure channel 0 of the pulse counter object you created from the create() me
|
|||
- `counter_l_lim` Required. Range -32768 to 32767. The lower limit counter. You get a callback at this count and the counter is reset to zero after this lower limit is hit.
|
||||
- `counter_h_lim` Required. Range -32768 to 32767. The high limit counter. You get a callback at this count and the counter is reset to zero after this high limit is hit.
|
||||
|
||||
### Returns
|
||||
#### Returns
|
||||
`nil`
|
||||
|
||||
## pulsecntObj:chan1Config()
|
||||
|
||||
Configure channel 1 of the pulse counter object you created from the create() method.
|
||||
|
||||
### Syntax
|
||||
#### Syntax
|
||||
`pulsecntObj:chan1Config(pulse_gpio_num, ctrl_gpio_num, pos_mode, neg_mode, lctrl_mode, hctrl_mode, counter_l_lim, counter_h_lim)`
|
||||
|
||||
### Parameters
|
||||
#### Parameters
|
||||
- `pulse_gpio_num` Required. Any GPIO pin can be used.
|
||||
- `ctrl_gpio_num` Required (although you can specify pulsecnt.PIN_NOT_USED to ignore). Any GPIO pin can be used. If you are trying to use a pin you use as gpio.OUT in other parts of your code, you can instead configure the pin as gpio.IN and toggle gpio.PULL_UP or gpio.PULL_DOWN to achieve your gpio.OUT task while still enabling the pulse counter to successfully read the pin state.
|
||||
- `pos_mode` Required. Positive rising edge count mode, i.e. count the pulse when the rising edge occurs.
|
||||
|
@ -241,10 +241,10 @@ Configure channel 1 of the pulse counter object you created from the create() me
|
|||
- `counter_l_lim` Required. Range -32768 to 32767. The lower limit counter. You get a callback at this count and the counter is reset to zero after this lower limit is hit.
|
||||
- `counter_h_lim` Required. Range -32768 to 32767. The high limit counter. You get a callback at this count and the counter is reset to zero after this high limit is hit.
|
||||
|
||||
### Returns
|
||||
#### Returns
|
||||
`nil`
|
||||
|
||||
### Example
|
||||
#### Example
|
||||
```lua
|
||||
-- Button 1 increment counter
|
||||
pcnt:chan0Config(
|
||||
|
@ -275,17 +275,17 @@ pcnt:chan1Config(
|
|||
|
||||
Set the threshold values to establish watchpoints for getting callbacks on.
|
||||
|
||||
### Syntax
|
||||
#### Syntax
|
||||
`pulsecntObj:setThres(thr0, thr1)`
|
||||
|
||||
### Parameters
|
||||
#### Parameters
|
||||
- `thr0` Required. Threshold 0 value. Range -32768 to 32767. This is a watchpoint value to get a callback with isThr0 set to true on this count being reached.
|
||||
- `thr1` Required. Threshold 1 value. Range -32768 to 32767. This is a watchpoint value to get a callback with isThr1 set to true on this count being reached.
|
||||
|
||||
### Returns
|
||||
#### Returns
|
||||
`nil`
|
||||
|
||||
### Example
|
||||
#### Example
|
||||
```lua
|
||||
pcnt:setThres(-2000, 2000) -- get callbacks when counter is -2000 or 2000
|
||||
```
|
||||
|
@ -297,16 +297,16 @@ pcnt:setThres(500, 10000) -- get callbacks when counter is 500 or 10000
|
|||
|
||||
Set a filter to ignore pulses on the `pulse_gpio_num` pin and the `ctrl_gpio_num` to avoid short glitches. Any pulses lasting shorter than this will be ignored.
|
||||
|
||||
### Syntax
|
||||
#### Syntax
|
||||
`pulsecntObj:setFilter(clkCycleCnt)`
|
||||
|
||||
### Parameters
|
||||
#### Parameters
|
||||
- `clkCycleCnt` Required. 0 to 1023 allowd. Any pulses lasting shorter than this will be ignored. A pulse needs to be high or low for longer than this filter clock cycle. Clock is 80Mhz APB clock, so one cycle is 1000/80,000,000 = 0.0000125 ms. The longest value of 1023 cycles = 0.0127875 ms.
|
||||
|
||||
### Returns
|
||||
#### Returns
|
||||
`nil`
|
||||
|
||||
### Example
|
||||
#### Example
|
||||
```lua
|
||||
pcnt:setFilter(1023) -- set max filter clock cylce count to ignore pulses shorter than 12.7us
|
||||
```
|
||||
|
@ -315,16 +315,16 @@ pcnt:setFilter(1023) -- set max filter clock cylce count to ignore pulses shorte
|
|||
|
||||
Clear the counter. Sets it back to zero.
|
||||
|
||||
### Syntax
|
||||
#### Syntax
|
||||
`pulsecntObj:clear()`
|
||||
|
||||
### Parameters
|
||||
#### Parameters
|
||||
None
|
||||
|
||||
### Returns
|
||||
#### Returns
|
||||
`nil`
|
||||
|
||||
### Example
|
||||
#### Example
|
||||
```lua
|
||||
pcnt:clear() -- set counter back to zero
|
||||
```
|
||||
|
@ -333,16 +333,16 @@ pcnt:clear() -- set counter back to zero
|
|||
|
||||
Get the current pulse counter.
|
||||
|
||||
### Syntax
|
||||
#### Syntax
|
||||
`pulsecntObj:getCnt()`
|
||||
|
||||
### Parameters
|
||||
#### Parameters
|
||||
None
|
||||
|
||||
### Returns
|
||||
#### Returns
|
||||
`integer`
|
||||
|
||||
### Example
|
||||
#### Example
|
||||
```lua
|
||||
val = pcnt:getCnt() -- get counter
|
||||
print("Pulse counter:", val)
|
||||
|
|
|
@ -69,7 +69,7 @@ Initialize the SDMMC and probe the attached SD card.
|
|||
- `slot` SDMMC slot, one of `sdmmc.HS1` or `sdmmc.HS2`
|
||||
- `cfg` optional table containing slot configuration:
|
||||
- `cd_pin` card detect pin, none if omitted
|
||||
- `wp_pin` write-protcet pin, none if omitted
|
||||
- `wp_pin` write-protect pin, none if omitted
|
||||
- `fmax` maximum communication frequency, defaults to 20 if omitted
|
||||
- `width` bis width, defaults to `sdmmc.W1BIT` if omitted, one of:
|
||||
- `sdmmc.W1BIT`
|
||||
|
@ -84,7 +84,7 @@ Initialize the SDMMC and probe the attached SD card.
|
|||
- `miso_pin`, SPI MISO pin, mandatory
|
||||
- `cs_pin`, SPI CS pin, mandatory
|
||||
- `cd_pin` card detect pin, none if omitted
|
||||
- `wp_pin` write-protcet pin, none if omitted
|
||||
- `wp_pin` write-protect pin, none if omitted
|
||||
- `fmax` maximum communication frequency, defaults to 20 if omitted
|
||||
|
||||
#### Returns
|
||||
|
|
|
@ -41,7 +41,7 @@ This creates an encoder object that can convert a Lua object into a JSON encoded
|
|||
#### Returns
|
||||
A `sjson.encoder` object.
|
||||
|
||||
## sjson.encoder:read
|
||||
## sjson.encoder:read()
|
||||
|
||||
This gets a chunk of JSON encoded data.
|
||||
|
||||
|
@ -152,7 +152,7 @@ The reason for being able to filter is that it enables processing of very large
|
|||
which would exceed the memory budget of the platform. For example, `https://api.github.com/repos/nodemcu/nodemcu-firmware/contents` is over 13kB, and yet, if
|
||||
you only need the `download_url` keys, then the total size is around 600B. This can be handled with a simple `__newindex` method.
|
||||
|
||||
## sjson.decoder:write
|
||||
## sjson.decoder:write()
|
||||
|
||||
This provides more data to be parsed into the Lua object.
|
||||
|
||||
|
@ -170,7 +170,7 @@ The constructed Lua object or `nil` if the decode is not yet complete.
|
|||
If a parse error occurrs during this decode, then an error is thrown and the parse is aborted. The object cannot be used again.
|
||||
|
||||
|
||||
## sjson.decoder:result
|
||||
## sjson.decoder:result()
|
||||
|
||||
This gets the decoded Lua object, or raises an error if the decode is not yet complete. This can be called multiple times and will return the
|
||||
same object each time.
|
||||
|
@ -178,6 +178,9 @@ same object each time.
|
|||
#### Syntax
|
||||
`decoder:result()`
|
||||
|
||||
#### Parameters
|
||||
none
|
||||
|
||||
#### Errors
|
||||
If the decode is not complete, then an error is thrown.
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ The touch sensors are on the following GPIO pins
|
|||
| 3 | GPIO15 | | 8 | GPIO33 |
|
||||
| 4 | GPIO13 | | 9 | GPIO32 |
|
||||
|
||||
### Example Lua Code
|
||||
#### Example Lua Code
|
||||
|
||||
Example code showing how to configure 8 pads.
|
||||
- Main run file [touch_8pads_showlist_test.lua](../../lua_examples/touch/touch_8pads_showlist_test.lua)
|
||||
|
@ -38,7 +38,7 @@ Example code showing how to use 5 touch pads to jog a stepper motor at different
|
|||
|
||||
Create the touch sensor object. You must call this method first. Only one touch object may be created since most settings on the touch driver are global in nature such as threshold trigger mode, interrupt callbacks, and reference voltages.
|
||||
|
||||
### Syntax
|
||||
#### Syntax
|
||||
```lua
|
||||
tp = touch.create({
|
||||
pad = 0 || {0,1,2,3,4,5,6,7,8,9}, -- 0=GPIO4, 1=GPIO0, 2=GPIO2, 3=GPIO15, 4=GPIO13, 5=GPIO12, 6=GPIO14, 7=GPIO27, 8=GPIO33, 9=GPIO32
|
||||
|
@ -54,7 +54,7 @@ tp = touch.create({
|
|||
})
|
||||
```
|
||||
|
||||
### Parameters
|
||||
#### Parameters
|
||||
List of values for configuration table:
|
||||
|
||||
- `pad` Required. padNum || {table of padNums}. Specify one pad like `pad = 4`, or provide a table list of pads. For example use `pad = {0,1,2,3,4,5,6,7,8,9}` to specify all pads. Pads allowed are 0=GPIO4, 1=GPIO0, 2=GPIO2, 3=GPIO15, 4=GPIO13, 5=GPIO12, 6=GPIO14, 7=GPIO27, 8=GPIO33, 9=GPIO32.
|
||||
|
@ -82,10 +82,10 @@ List of values for configuration table:
|
|||
- touch.TOUCH_HVOLT_ATTEN_1V5
|
||||
- `isDebug` Optional. Defaults to false. Set to true to get debug information during development. The info returned while debug is on can be very helpful in understanding polling vs interrupts, configuration, and threshold settings. Set to false during production.
|
||||
|
||||
### Returns
|
||||
`touch` object
|
||||
#### Returns
|
||||
`tp` touch object
|
||||
|
||||
### Example 1 - Polling
|
||||
#### Example 1 - Polling
|
||||
```lua
|
||||
-- Touch sensor with 5 touch pads for polling counter state
|
||||
|
||||
|
@ -108,7 +108,7 @@ end
|
|||
read()
|
||||
```
|
||||
|
||||
### Example 2 - Polling with Filtering
|
||||
#### Example 2 - Polling with Filtering
|
||||
```lua
|
||||
-- Touch sensor with 3 touch pads for polling with filtering
|
||||
|
||||
|
@ -135,7 +135,7 @@ read()
|
|||
tmr.create():alarm(1000, tmr.ALARM_SINGLE, read)
|
||||
```
|
||||
|
||||
### Example 3 - Interrupt Touch / Untouch
|
||||
#### Example 3 - Interrupt Touch / Untouch
|
||||
```lua
|
||||
-- Touch sensor with 1 pad for touch / untouch using threshold trigger mode
|
||||
-- Swap TOUCH_TRIGGER_BELOW / TOUCH_TRIGGER_ABOVE on each callback
|
||||
|
@ -204,7 +204,7 @@ read()
|
|||
config()
|
||||
```
|
||||
|
||||
### Example 4 - Interrupt Touch / Untouch with Timer
|
||||
#### Example 4 - Interrupt Touch / Untouch with Timer
|
||||
```lua
|
||||
-- Touch sensor with 1 pad for touch / untouch using timer
|
||||
-- Shows how to detect a touch and then an untouch
|
||||
|
@ -290,17 +290,17 @@ m.config()
|
|||
|
||||
Read the touch sensor counter values for all pads configured in `touch.create()` method.
|
||||
|
||||
### Syntax
|
||||
#### Syntax
|
||||
`raw, filter = tp:read()`
|
||||
|
||||
### Parameters
|
||||
#### Parameters
|
||||
None
|
||||
|
||||
### Returns
|
||||
#### Returns
|
||||
- `raw` Lua table of touch sensor counter values per pad
|
||||
- `raw, filter` A 2nd Lua table of touch sensor filtered counter values per pad is returned if `filterMs` is specified during the touch.create() method.
|
||||
- `filter` A 2nd Lua table of touch sensor filtered counter values per pad is returned if `filterMs` is specified during the touch.create() method.
|
||||
|
||||
### Example 1 - Raw
|
||||
#### Example 1 - Raw
|
||||
```lua
|
||||
raw = tp:read()
|
||||
print("Pad", "Val")
|
||||
|
@ -309,7 +309,7 @@ for key,value in pairs(raw) do
|
|||
end
|
||||
```
|
||||
|
||||
### Example 2 - Raw / Filter
|
||||
#### Example 2 - Raw / Filter
|
||||
```lua
|
||||
-- You get a filter Lua table if you specified filterMs in touch.create()
|
||||
raw, filter = tp:read()
|
||||
|
@ -324,23 +324,23 @@ end
|
|||
|
||||
Set touch sensor interrupt threshold per pad. The threshold only matters if you are in interrupt mode, which only activates if you specify a callback in the `touch.create()` configuration.
|
||||
|
||||
### Syntax
|
||||
#### Syntax
|
||||
`tp:setThres(padNum, thresVal)`
|
||||
|
||||
### Parameters
|
||||
#### Parameters
|
||||
- `padNum` Required. One pad number can be specified here. If you did multiple pads you must call this per pad.
|
||||
- `thresVal` Required. The threshold value to set for the pad interrupt trigger. If you set touch.TOUCH_TRIGGER_BELOW then the interrupt occurs when the touch counter goes below this threshold value, or vice versa for touch.TOUCH_TRIGGER_ABOVE.
|
||||
|
||||
### Returns
|
||||
#### Returns
|
||||
`nil`
|
||||
|
||||
### Example 1
|
||||
#### Example 1
|
||||
```lua
|
||||
-- Set threshold for pad 2 where baseline counter is around 800 and
|
||||
-- when touched is around 200, so trigger at mid-point around 500
|
||||
tp:setThres(2, 500)
|
||||
```
|
||||
### Example 2
|
||||
#### Example 2
|
||||
```lua
|
||||
-- Configure by reading baseline, then setting threshold to 30% below base
|
||||
local raw = tp:read()
|
||||
|
@ -361,16 +361,16 @@ tp:intrEnable()
|
|||
|
||||
Set the trigger mode globally for all touch pads. The trigger mode only matters in interrupt mode where you can tell the hardware to give you an interrupt if the counter on the pad falls above or below the threshold you specify.
|
||||
|
||||
### Syntax
|
||||
#### Syntax
|
||||
`tp:setTriggerMode(mode)`
|
||||
|
||||
### Parameters
|
||||
#### Parameters
|
||||
- `mode` Required. touch.TOUCH_TRIGGER_BELOW or touch.TOUCH_TRIGGER_ABOVE can be specified. If your pad's baseline counter value is around 600 when not touched, and sits around 300 when touched, then you would set your threshold around 450. If you set touch.TOUCH_TRIGGER_BELOW then when the counter drops to 300 it would fall BELOW the threshold of 450, thus triggering the interrupt. This process works in the reverse for touch.TOUCH_TRIGGER_ABOVE.
|
||||
|
||||
### Returns
|
||||
#### Returns
|
||||
`nil`
|
||||
|
||||
### Example 1
|
||||
#### Example 1
|
||||
```lua
|
||||
-- Trigger callback when pad counter goes above threshold value
|
||||
tp:setTriggerMode(touch.TOUCH_TRIGGER_ABOVE)
|
||||
|
@ -378,7 +378,7 @@ tp:setTriggerMode(touch.TOUCH_TRIGGER_ABOVE)
|
|||
tp:setTriggerMode(touch.TOUCH_TRIGGER_BELOW)
|
||||
```
|
||||
|
||||
### Example 2
|
||||
#### Example 2
|
||||
```lua
|
||||
-- Configure touch hardware to callback on TOUCH_TRIGGER_BELOW during touch.create()
|
||||
-- Then on first callback swap to TOUCH_TRIGGER_ABOVE when detecting touch
|
||||
|
@ -414,16 +414,16 @@ end
|
|||
|
||||
Enable interrupt on the touch sensor hardware. You can specify `intrInitAtStart=false` during `touch.create()` and thus you would want to call this method later on after configuring your pad thresholds.
|
||||
|
||||
### Syntax
|
||||
#### Syntax
|
||||
`tp:intrEnable()`
|
||||
|
||||
### Parameters
|
||||
#### Parameters
|
||||
None
|
||||
|
||||
### Returns
|
||||
#### Returns
|
||||
`nil`
|
||||
|
||||
### Example
|
||||
#### Example
|
||||
```lua
|
||||
tp:intrEnable() -- Enable interrupt
|
||||
```
|
||||
|
@ -432,16 +432,16 @@ tp:intrEnable() -- Enable interrupt
|
|||
|
||||
Disable interrupt on the touch sensor hardware.
|
||||
|
||||
### Syntax
|
||||
#### Syntax
|
||||
`tp:intrDisable()`
|
||||
|
||||
### Parameters
|
||||
#### Parameters
|
||||
None
|
||||
|
||||
### Returns
|
||||
#### Returns
|
||||
`nil`
|
||||
|
||||
### Example
|
||||
#### Example
|
||||
```lua
|
||||
tp:intrDisable() -- Disable interrupt
|
||||
```
|
Loading…
Reference in New Issue