Skip to content

Instantly share code, notes, and snippets.

@michalvalasek
Created June 30, 2016 08:37
Show Gist options
  • Save michalvalasek/62c33be18f7a639ac2d4ae88d80cff8f to your computer and use it in GitHub Desktop.
Save michalvalasek/62c33be18f7a639ac2d4ae88d80cff8f to your computer and use it in GitHub Desktop.
Weird crystal error
f = File.new("buffer_i_gen_batt.txt")
6.times do
_ = f.gets
end
interval = f.gets
def real_val(raw_val)
(raw_val - 520) * 0.191
end
def normalize
end
loop do
break unless n = f.gets
unless n.to_s == ""
puts n.to_s.to_i
end
# puts n.to_i
end
@akwiatkowski
Copy link

unless line == "" instead of if

file = File.open("buffer_i_gen_batt.txt")

values = Array(Float64).new

meas_offset = -512
linear_coefficient = 0.191

6.times do
    file.gets
end

interval = file.gets.to_s.to_i
puts interval

file.each_line do |raw_line|
    line = raw_line.to_s.strip
    puts line.inspect
    unless line == ""
        raw_value = line.to_i
        # real_value = (raw_value + meas_offset) * linear_coefficient
        # values << real_value
        # puts real_value
    end
end

file.close

min_value = values.min

values.each do |value|
    value -= min_value
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment