summaryrefslogtreecommitdiffstats
path: root/tinyusb/test/vendor/ceedling/plugins/beep/lib/beep.rb
blob: 6a6d01ab281f09c3077ff6efae882d5445467b68 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
require 'ceedling/plugin'
require 'ceedling/constants'

class Beep < Plugin

  attr_reader :config

  def setup
    @config = {
      :on_done  => ((defined? TOOLS_BEEP_ON_DONE)  ? TOOLS_BEEP_ON_DONE  : :bell  ),
      :on_error => ((defined? TOOLS_BEEP_ON_ERROR) ? TOOLS_BEEP_ON_ERROR : :bell  ),
    }
  end

  def post_build
    beep @config[:on_done]
  end

  def post_error
    beep @config[:on_error]
  end

  private

  def beep(method = :none)
    case method
    when :bell
      if (SystemWrapper.windows?)
        puts "echo '\007'"
      else
        puts "echo -ne '\007'"
      end
    when :speaker_test
      `speaker-test -t sine -f 1000 -l 1`
    else
      #do nothing with illegal or :none
    end
  end
end