Skip to content

Instantly share code, notes, and snippets.

@alfanick
Created April 10, 2013 09:30
Show Gist options
  • Save alfanick/5353177 to your computer and use it in GitHub Desktop.
Save alfanick/5353177 to your computer and use it in GitHub Desktop.
module TLC5947
class << self
def upscale(i)
(i / 255.0 * 4095.0).to_i % 4096
end
def compress(data)
data.map{|v|upscale(v).to_s(2).rjust(12, '0')}.join.scan(/.{8}/).map{|v|v.to_i(2)}
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment