module Apa102Rbpi
Constants
- VERSION
Public Class Methods
base()
click to toggle source
# File lib/apa102_rbpi.rb, line 15 def self.base @base ||= Apa102.new end
clear_config!()
click to toggle source
# File lib/apa102_rbpi.rb, line 19 def self.clear_config! @base = nil @strip = nil end
configure() { |base| ... }
click to toggle source
# File lib/apa102_rbpi.rb, line 9 def self.configure clear_config! yield base strip.clear! end
strip()
click to toggle source
# File lib/apa102_rbpi.rb, line 24 def self.strip @strip ||= Strip.new end
Public Instance Methods
color_wheel(wheel_pos)
click to toggle source
Input a 1-byte value to get a color Colors are from r->g->b->r
# File lib/apa102_rbpi/utils.rb, line 4 def color_wheel(wheel_pos) wheel_pos &= 255 if wheel_pos < 85 rgb_to_hex(255 - wheel_pos * 3, wheel_pos * 3, 0) elsif wheel_pos < 170 wheel_pos -= 85 rgb_to_hex(0, 255 - wheel_pos * 3, wheel_pos * 3) else wheel_pos -= 170 rgb_to_hex(wheel_pos * 3, 0, 255 - wheel_pos * 3) end end
hex_to_rgb(hex)
click to toggle source
convert 3-byte hex color to [red, green, blue]
# File lib/apa102_rbpi/utils.rb, line 24 def hex_to_rgb(hex) [ (hex & 0xFF0000) >> 16, (hex & 0x00FF00) >> 8, (hex & 0x0000FF) ] end
rgb_to_hex(red, green, blue)
click to toggle source
convert to a 3-byte hex color value
# File lib/apa102_rbpi/utils.rb, line 19 def rgb_to_hex(red, green, blue) (red << 16) + (green << 8) + blue end