Class: RoadToRubykaigi::CalibrationScreen

Inherits:
Object
  • Object
show all
Defined in:
lib/road_to_rubykaigi/calibration_screen.rb

Constant Summary collapse

COUNTDOWN_FROM =
5
MESSAGES =
{
  title: [5, 3, '=== Sensor Calibration ==='],
  intro: [
    [5, 10, '[Enter/Space] start'],
    [5, 11, '[ESC]         return'],
  ],
  cancel: [5, 11, '[ESC] cancel'],
  instructions: [
    [5, 13, '🧍 Hold -> 🚶‍➡️ Walk -> 🤸 Jump!'],
    [5, 14, "#{CalibrationSampler::PHASE_SECONDS}s each"],
  ],
  clear_instructions: [
    [5, 13, ' ' * 30],
    [5, 14, ' ' * 30],
  ],
  countdown:    [5, 8, 'Starting in %d...'],
  countdown_clear: [5, 8, ' ' * 20],
  done_static:  [5, 6, 'Static: %.6f (%d samples)'],
  done_walk:    [5, 7, 'Walk:   %.3f Hz (%d samples)'],
  done_jump:    [5, 8, 'Jump:   %.3f g (%d samples)'],
  done_return:  [5, 10, '[Enter/ESC] return'],
  not_connected: [
    [5, 6, 'Sensor not connected.'],
    [5, 7, 'Connect the sensor and try again.'],
    [5, 10, '[Enter/ESC] return'],
  ],
}.freeze

Instance Method Summary collapse

Instance Method Details

#displayObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/road_to_rubykaigi/calibration_screen.rb', line 33

def display
  if Config.serial? && !File.exist?(Config.serial_port)
    enter_not_connected
  else
    Config.signal_source.start
    enter_intro
  end
  $stdin.raw do
    loop do
      case tick
      when :done then return
      end
      sleep Manager::GameManager::FRAME_RATE
    end
  end
end