Class BO.generators.Oscillator
Extends
BO.generators.GeneratorBase.
The Oscillator object can be attached to a Pin or LED object to output
a waveform. This is useful for blinking an LED or fading it on and off. In
most cases (unless you are simply using it to blink and LED on or off),
the Oscillator should be attached to a Pin or LED object associated with
a PWM pin on the I/O board. See Breakout/examples/generators/oscillator.html
for an example application.
Defined in: Oscillator.js.
| Constructor Attributes | Constructor Name and Description |
|---|---|
|
BO.generators.Oscillator(wave, freq, amplitude, offset, phase, times)
Osc outputs a waveform on the associated PWM pin.
|
| Field Attributes | Field Name and Description |
|---|---|
|
The service interval in milliseconds.
|
- Fields borrowed from class BO.generators.GeneratorBase:
- value
| Method Attributes | Method Name and Description |
|---|---|
| <static> |
BO.generators.Oscillator.IMPULSE(val, lastVal)
impulse
|
| <static> |
BO.generators.Oscillator.LINEAR(val, lastVal)
linear
|
|
reset()
Resets the oscillator.
|
|
| <static> |
BO.generators.Oscillator.SAW(val, lastVal)
saw wave
|
| <static> |
BO.generators.Oscillator.SIN(val, lastVal)
sine wave
|
| <static> |
BO.generators.Oscillator.SQUARE(val, lastVal)
square wave
|
|
start()
Starts the oscillator
|
|
|
stop()
Stops the oscillator.
|
|
| <static> |
BO.generators.Oscillator.TRIANGLE(val, lastVal)
triangle wave
|
|
update(interval)
By default the interval is 33 milliseconds.
|
- Methods borrowed from class JSUTILS.EventDispatcher:
- addEventListener, dispatchEvent, hasEventListener, removeEventListener
| Event Attributes | Event Name and Description |
|---|---|
|
The update event is dispatched at the rate specified
by the serviceInterval parameter (default = 33ms).
|
Class Detail
BO.generators.Oscillator(wave, freq, amplitude, offset, phase, times)
Osc outputs a waveform on the associated PWM pin. For example, this can be used to blink or fade
an LED on or off.
- Parameters:
- {Number} wave
- waveform
- {Number} freq
- frequency
- {Number} amplitude
- amplitude
- {Number} offset
- offset
- {Number} phase
- phase
- {Number} times
- The repeat count from 0 to infinite.
Field Detail
{Number}
serviceInterval
The service interval in milliseconds. Default is 33ms.
Method Detail
<static>
BO.generators.Oscillator.IMPULSE(val, lastVal)
impulse
- Parameters:
- val
- lastVal
<static>
BO.generators.Oscillator.LINEAR(val, lastVal)
linear
- Parameters:
- val
- lastVal
reset()
Resets the oscillator.
<static>
BO.generators.Oscillator.SAW(val, lastVal)
saw wave
- Parameters:
- val
- lastVal
<static>
BO.generators.Oscillator.SIN(val, lastVal)
sine wave
- Parameters:
- val
- lastVal
<static>
BO.generators.Oscillator.SQUARE(val, lastVal)
square wave
- Parameters:
- val
- lastVal
start()
Starts the oscillator
stop()
Stops the oscillator.
<static>
BO.generators.Oscillator.TRIANGLE(val, lastVal)
triangle wave
- Parameters:
- val
- lastVal
update(interval)
By default the interval is 33 milliseconds. The Osc is updated every 33ms.
- Parameters:
- {Number} interval
- The update interval in milliseconds.
Event Detail
{BO.generators.GeneratorEvent.UPDATE}
update
The update event is dispatched at the rate specified
by the serviceInterval parameter (default = 33ms).
- This event has the following properties:
- {BO.generators.Oscillator} target
- A reference to the Oscillator object.
