Class: BeagleBoard::FreeBSD::Adc
- Extended by:
- FFI::Library
- Defined in:
- lib/beagleboard/freebsd/adc.rb
Instance Attribute Summary collapse
-
#scale ⇒ Object
Returns the value of attribute scale.
Class Method Summary collapse
Instance Method Summary collapse
- #disable ⇒ Object
- #enable ⇒ Object
- #enabled? ⇒ Boolean
-
#initialize(adc) ⇒ Adc
constructor
A new instance of Adc.
- #raw_value ⇒ Object
Methods inherited from Base::Adc
Constructor Details
#initialize(adc) ⇒ Adc
Returns a new instance of Adc.
44 45 46 47 48 49 50 51 52 53 |
# File 'lib/beagleboard/freebsd/adc.rb', line 44 def initialize(adc) @enable_mib = FFI::MemoryPointer.new(:int, 6) @input_mib = FFI::MemoryPointer.new(:int, 6) size = FFI::MemoryPointer.new(:int).write_int(6) Adc.sysctlnametomib("dev.ti_adc.0.ain.#{adc}.enable", @enable_mib, size) Adc.sysctlnametomib("dev.ti_adc.0.ain.#{adc}.input", @input_mib, size) super end |
Instance Attribute Details
#scale ⇒ Object
Returns the value of attribute scale.
71 72 73 |
# File 'lib/beagleboard/freebsd/adc.rb', line 71 def scale @scale end |
Class Method Details
.disable(mib) ⇒ Object
30 31 32 33 34 |
# File 'lib/beagleboard/freebsd/adc.rb', line 30 def self.disable(mib) buf = FFI::MemoryPointer.new(:int).write_int(0) res = sysctl(mib, 6, nil, nil, buf, buf.size) raise StandardError, 'Write error' if res < 0 end |
.enable(mib) ⇒ Object
24 25 26 27 28 |
# File 'lib/beagleboard/freebsd/adc.rb', line 24 def self.enable(mib) buf = FFI::MemoryPointer.new(:int).write_int(1) res = sysctl(mib, 6, nil, nil, buf, buf.size) raise StandardError, 'Write error' if res < 0 end |
.enabled?(mib) ⇒ Boolean
16 17 18 19 20 21 22 |
# File 'lib/beagleboard/freebsd/adc.rb', line 16 def self.enabled?(mib) buf = FFI::MemoryPointer.new(:int) bufsiz = FFI::MemoryPointer.new(:int).write_int(buf.size) res = sysctl(mib, 6, buf, bufsiz, nil, 0) raise StandardError, 'Read error' if res < 0 buf.read_int == 1 end |
.input(mib) ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/beagleboard/freebsd/adc.rb', line 36 def self.input(mib) buf = FFI::MemoryPointer.new(:int) bufsiz = FFI::MemoryPointer.new(:int).write_int(buf.size) res = sysctl(mib, 6, buf, bufsiz, nil, 0) raise StandardError, 'Read error' if res < 0 buf.read_int end |
Instance Method Details
#disable ⇒ Object
63 64 65 |
# File 'lib/beagleboard/freebsd/adc.rb', line 63 def disable Adc.disable(@enable_mib) end |
#enable ⇒ Object
59 60 61 |
# File 'lib/beagleboard/freebsd/adc.rb', line 59 def enable Adc.enable(@enable_mib) end |