BO.generators.Oscillator Class
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.
Constructor
BO.generators.Oscillator
    
        - 
                    
                        
wave - 
                    
                        
freq - 
                    
                        
amplitude - 
                    
                        
offset - 
                    
                        
phase - 
                    
                        
times 
Parameters:
- 
                    
                        
waveNumberwaveform
 - 
                    
                        
freqNumberfrequency
 - 
                    
                        
amplitudeNumberamplitude
 - 
                    
                        
offsetNumberoffset
 - 
                    
                        
phaseNumberphase
 - 
                    
                        
timesNumberThe repeat count from 0 to infinite.
 
Item Index
Methods
- addEventListener
 - autoUpdate
 - computeValue
 - dispatchEvent
 - hasEventListener
 - Oscillator.IMPULSE static
 - Oscillator.LINEAR static
 - Oscillator.SAW static
 - Oscillator.SIN static
 - Oscillator.SQUARE static
 - Oscillator.TRIANGLE static
 - removeEventListener
 - reset
 - start
 - stop
 - update
 
Properties
Events
Methods
addEventListener
    
        - 
                    
                        
type - 
                    
                        
listener 
Parameters:
- 
                    
                        
typeStringThe event type
 - 
                    
                        
listenerFunctionThe function to be called when the event is fired
 
autoUpdate
    
        ()
    
    
    
    
        private
    
    
    
    
    
    
    computeValue
    
        ()
    
    
    
    
        private
    
    
    
    
    
    
    dispatchEvent
    
        - 
                    
                        
type - 
                    
                        
optionalParams 
Parameters:
- 
                    
                        
typeEventThe Event object.
 - 
                    
                        
optionalParamsObjectOptional parameters passed as an object. return {boolean} True if dispatch is successful, false if not.
 
hasEventListener
    
        - 
                    
                        
type 
Parameters:
- 
                    
                        
typeStringThe event type return {boolean} True is listener exists for this type, false if not.
 
Oscillator.IMPULSE
    
        ()
    
    
    
    
    
    
        static
    
    
    
    
    impulse
Oscillator.LINEAR
    
        ()
    
    
    
    
    
    
        static
    
    
    
    
    linear
Oscillator.SAW
    
        ()
    
    
    
    
    
    
        static
    
    
    
    
    saw wave
Oscillator.SIN
    
        ()
    
    
    
    
    
    
        static
    
    
    
    
    sine wave
Oscillator.SQUARE
    
        ()
    
    
    
    
    
    
        static
    
    
    
    
    square wave
Oscillator.TRIANGLE
    
        ()
    
    
    
    
    
    
        static
    
    
    
    
    triangle wave
removeEventListener
    
        - 
                    
                        
type - 
                    
                        
listener 
Parameters:
- 
                    
                        
typeStringThe event type
 - 
                    
                        
listenerFunctionThe function to be called when the event is fired
 
reset
    
        ()
    
    
    
    
    
    
    
    
    
    Resets the oscillator.
start
    
        ()
    
    
    
    
    
    
    
    
    
    Starts the oscillator.
stop
    
        ()
    
    
    
    
    
    
    
    
    
    Stops the oscillator.
update
    
        - 
                    
                        
interval 
By default the interval is 33 milliseconds. The Osc is updated every 33ms.
Parameters:
- 
                    
                        
intervalNumberThe update interval in milliseconds.
 
Properties
serviceInterval
    Number
    
    
    
    
    
    The service interval in milliseconds. Default is 33ms.
value
    Number
    
    
        protected
    
    
    
    
    [read-only] Get a generated number.
Events
update
    BO.generators.GeneratorEvent.UPDATE
    
    
    
    
    
    The update event is dispatched at the rate specified by the serviceInterval parameter (default = 33ms).
Event Payload:
- 
                    
                        
targetBO.generators.OscillatorA reference to the Oscillator object.
 
