A Generic eLua Module is a module that can be used by a Lua program running on any of the <ahref="status.html#platforms">supported eLua platforms</a>.<br>
<li>pio: only some platform have internal pullups for the pio pins, while Cortex is the only platform that also provides pulldowns for its pios. However, in this case you're safe, as eLua will signal an error if you try to execute a pullup operatin on a platform that does not support it.
<aname="gpio_setpinvalue"id="gpio_setpinvalue"></a> [pio.setpinvalue] pio.setpin( value, Pin1, Pin2 ... ): set the value to all the pins in the list
</p>
<p>
to "value" (0 or 1).
</p>
<p>
<aname="gpio_setpinhigh"id="gpio_setpinhigh"></a> [pio.setpinhigh] pio.set( Pin1, Pin2, ... ): set the value of all the pins in the list to 1.
</p>
<p>
<aname="gpio_getpinvalue"id="gpio_getpinvalue"></a> [pio.getpinvalue] Val1, Val2, ... = pio.get( Pin1, Pin2, ... ): reads one or more pins and returns
</p>
<p>
their values (0 or 1).
</p>
<p>
<aname="gpio_setpinlow"id="gpio_setpinlow"></a> [pio.setpinlow] pio.clear( Pin1, Pin2, ... ): set the value of all the pins in the list to 0.
</p>
<p>
<aname="gpio_configpin"id="gpio_configpin"></a> [pio.configpin(pio.DIR, pio.DIR_INPUT)] pio.input( Pin1, Pin2, ... ): set the specified pin(s) as input(s).
</p>
<p>
[pio.configpin(pio.DIR, pio.DIR_OUTPUT)] pio.output( Pin1, Pin2, ... ): set the specified pin(s) as output(s).
</p>
<p>
<aname="gpio_setportvalue"id="gpio_setportvalue"></a> [pio.setportvalue] pio.setport( value, Port1, Port2, ... ): set the value of all the ports in the
</p>
<p>
list to "value".
</p>
<p>
<aname="gpio_getportvalue"id="gpio_getportvalue"></a> [pio.getportvalue] Val1, Val2, ... = pio.getport( Port1, Port2, ... ): reads one or more ports and
<aname="gpio_getportname"id="gpio_getportname"></a> [pio.getportname] Port = pio.port( code ): return the physical port number associated with the given code. For example, "pio.port( pio.P0_20 )" will return 0.
[pio.configport(pio.DIR, pio.DIR_INPUT, [Port1], [Port2], ...)] pio.port_input( Port1, Port2, ... ): set the specified port(s) as input(s).
</p>
<p>
[pio.configport(pio.DIR, pio.DIR_OUTPUT, [Port1], [Port2], ...)] pio.port_output( Port1, Port2, ... ): set the specified port(s) as output(s).
</p>
<p>
[pio.configpin(pio.PULL, pio.PULL_UP, [Pin1], [Pin2], ...)] pio.pullup( Pin1, Pin2, ... ): enable internal pullups on the specified pins.Note that some CPUs might not provide this feature.
</p>
<p>
[pio.configpin(pio.PULL, pio.PULL_DOWN, [Pin1], [Pin2], ...)] pio.pulldown( Pin1, Pin2, ... ): enable internal pulldowns on the specified pins. Note that some CPUs might not provide this feature.
</p>
<p>
[pio.configpin(pio.PULL, pio.PULL_NO, [Pin1], [Pin2], ...)] pio.nopull( Pin1, Pin2, ... ): disable the pullups/pulldowns on the specifiedpins. Note that some CPUs might not provide this feature.
<strike><aname="pwm_setup"id="pwm_setup"></a>[pwm.setup]</strike>(pwm.setup( id, frequency, Active Cycle ) Data = pwm.setup( id, frequency, duty ): sets the PWM block 'id' to generate the specified frequency with the specified duty cycle (duty is an integer number from 0 to 100, specifying the duty cycle in percents). It returns the actual frequency set on the PWM block.
<aname="spi_sendrecv"id="spi_sendrecv"></a>[spi.sendrecv(id, Out1, Out2, ...)] In1, In2, ... = spi.send_recv( id, Out1, Out2, ... ): sends all the "out" bytes to the specified SPI interface and returts the data read after each sent byte.<br>
<br>
Returning several values in this blocking way would not complicate some queued send implementations ? (ok, this could be another function :)<br>
Sending multiple data/chars in a single call and not in a table argument does not allow the data to be built in run time (without some string massage, of course :)<br>
<li>timers: from all the platforms on which eLua runs, only the Luminary Cortex CPUs has rock solid 32-bit timers. You can do pretty much everything you need with them. All the other platforms have 16-bit timers, which imposes some limits on the range of delays you can achieve with them. Make sure to use tmr.mindelay(id) and tmr.maxdelay(id) to check the actual resolution of your timers, and adapt your code accordingly. To 'compensate' for this, it's not possible to change the base timer frequency on the Cortex CPUs, but it is possible on most other platforms :) So be sure to also check the result of tmr.setclock(id)
</li>
<li>also, when using timers, remember that if you're using XMODEM and/or the "term" module, TMR0 is used by both of them. So, if you change the TMR0 base clock in your code, be sure to restore the original setting before returning to the shell. You can change this static timer assignment by modifying src/main.c. It might also be possible to change it dynamically in the future, although I see little use for this.
</li>
<li>PWM: the Cortex CPUs have 6 PWM channels, but channels 0/1, 2/3 and 4/5 respectively share the same base clock setting. So, when you're changing the base clock for channel 1, you're also changing the base clock for channel 0; if channel 0 was already running, you won't like what will happen next. This time no eLua function can save you, you simply need you know your CPU architecture.
These modules make use of specifical devices and features offered by some kits and allow eLua aplications to make the best use of the external hardware on your platforms.<br>
Sets the frequency and clock source for sample collection. If <em>frequency</em> is zero (timer_id not needed), samples on <em>channel_id</em> are collected as fast as possible. If <em>frequency</em> is non-zero, <em>timer_id</em> is configured to trigger sampling on <em>channel_id</em> at <em>frequency.</em>
Returns 1 if samples are still being collected on <em>channel_id</em>, 0 if channel is inactive.
</p>
<p>
<aname="adc_setmode"id="adc_setmode"></a><strong>adc.setblocking(channel_id, mode)<br></strong><em>mode</em> 1 sets blocking mode (default). adc.getsample(s) will wait for requested samples to be captured before returning. <em>mode</em> 0 sets non-blocking mode<br>
<aname="adc_setsmoothing"id="adc_setsmoothing"></a><strong>adc.setsmoothing(channel_id, length)<br></strong> Set the <em>length</em> of the smoothing filter on <em>channel_id</em>. When greater than 1, and samples are requested, smoothing filter will fill to <em>length</em> with samples, and then put the requested number of samples into the adc buffer.<br>
<em>length</em> must be a power of 2 (maximum = 64)
This function will turn off the OLED display. This will stop the scanning of the panel and turn off the on-chip DC-DC converter, preventing damage to the panel due to burn-in (it has similar characters to a CRT in this respect).<br>
This function will draw a string on the display. Only the ASCII characters between 32 (space) and 126 (tilde) are supported; other characters will result in random data being draw on the display (based on whatever appears before/after the font in memory). The font is mono-spaced, so characters such as ``i'' and ``l'' have more white space around them than characters such as ``m'' or ``w''.<br>
If the drawing of the string reaches the right edge of the display, no more characters will be drawn. Therefore, special care is not required to avoid supplying a string that is ``too long'' to display.<br>
This function will display a bitmap graphic on the display. Because of the format of the display RAM, the starting column x and the number of columns y must be an integer multiple of two.<br>
The image data is organized with the first row of image data appearing left to right, followed immediately by the second row of image data. Each byte contains the data for two columns in the current row, with the leftmost column being contained in bits 7:4 and the rightmost column being contained in bits 3:0.<br>
For example, an image six columns wide and seven scan lines tall would be arranged as follows (showing how the twenty one bytes of the image would appear on the display):<br>
<br>
Because the OLED display packs 2 pixels of data in a single byte, the parameter x must be an even column number (for example, 0, 2, 4, and so on).