class Elemac::Output::Pwm

Constants

REG_DATA_SIZE
REG_LEVEL
REG_MAX_LEVEL
REG_MIN_LEVEL
REG_OFFSET

Reg -> regulated -> PWM

REG_TRANS_COUNT
REG_TRANS_TIME

Public Class Methods

new(device:, index: 0, dim_index: 0) click to toggle source
Calls superclass method Elemac::Output::Default::new
# File lib/elemac/output/pwm.rb, line 15
def initialize(device:, index: 0, dim_index: 0)
        super(device: device, index: index)
        @dimm_index = dim_index
        @voltage = 12
        @dimmable = true
end

Public Instance Methods

get_reg_offset() click to toggle source
# File lib/elemac/output/pwm.rb, line 22
def get_reg_offset
        throw "Bad offset. Can be only 0..8. #{@index} given." unless (0..8).cover?(@index)
        REG_OFFSET + (@dimm_index * REG_DATA_SIZE)
end
inspect() click to toggle source
Calls superclass method Elemac::Output::Default#inspect
# File lib/elemac/output/pwm.rb, line 52
def inspect
        super
        puts "LEVEL:\t\t#{level}"
        puts "MIN LEVEL:\t#{min_level}"
        puts "MAX_LEVEL:\t#{max_level}"
        puts "TRANS TIME:\t#{Converter.seconds_to_hsm(trans_time)}"
        puts "TRANS COUNT:\t#{trans_count}"
end
level() click to toggle source
# File lib/elemac/output/pwm.rb, line 27
def level
        prop = Property.new(offset: get_reg_offset, address: REG_LEVEL, type: :char)
        get_data(prop.to_s)
end
max_level() click to toggle source
# File lib/elemac/output/pwm.rb, line 37
def max_level
        prop = Property.new(offset: get_reg_offset, address: REG_MAX_LEVEL, type: :char)
        get_data(prop.to_s)
end
min_level() click to toggle source
# File lib/elemac/output/pwm.rb, line 32
def min_level
        prop = Property.new(offset: get_reg_offset, address: REG_MIN_LEVEL, type: :char)
        get_data(prop.to_s)
end
trans_count() click to toggle source
# File lib/elemac/output/pwm.rb, line 47
def trans_count
        prop = Property.new(offset: get_reg_offset, address: REG_TRANS_COUNT, type: :char)
        get_data(prop.to_s)
end
trans_time() click to toggle source
# File lib/elemac/output/pwm.rb, line 42
def trans_time
        prop = Property.new(offset: get_reg_offset, address: REG_TRANS_TIME, type: :short)
        get_data(prop.to_s)
end