Class: WallE::Piezo
- Inherits:
-
Object
- Object
- WallE::Piezo
- Defined in:
- lib/wall_e/components/piezo.rb
Instance Method Summary collapse
-
#initialize(pin) ⇒ Piezo
constructor
Public: Initialize a Piezo.
-
#off ⇒ Object
Public: Turn the piezo off.
-
#off? ⇒ Boolean
Pubilc: Indicates if the piezo is currently off.
-
#on(tone) ⇒ Object
Public: Turn the piezo on.
-
#on? ⇒ Boolean
Public: Indicates if the piezo is currently on.
Constructor Details
Instance Method Details
#off ⇒ Object
Public: Turn the piezo off.
Returns nothing.
26 27 28 29 |
# File 'lib/wall_e/components/piezo.rb', line 26 def off @is_on = false @pin.analog_write(0) end |
#off? ⇒ Boolean
Pubilc: Indicates if the piezo is currently off.
Returns Boolean.
41 42 43 |
# File 'lib/wall_e/components/piezo.rb', line 41 def off? !@is_on end |
#on(tone) ⇒ Object
Public: Turn the piezo on.
tone - the Integer tone to play.
Returns nothing.
18 19 20 21 |
# File 'lib/wall_e/components/piezo.rb', line 18 def on(tone) @is_on = true @pin.analog_write(tone) end |
#on? ⇒ Boolean
Public: Indicates if the piezo is currently on.
Returns Boolean.
34 35 36 |
# File 'lib/wall_e/components/piezo.rb', line 34 def on? @is_on end |