Skip to content

Commit

Permalink
Don't modify light settings until first data
Browse files Browse the repository at this point in the history
  • Loading branch information
albus522 committed Aug 2, 2024
1 parent 9034079 commit 0749170
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions pi/listener.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,26 +30,17 @@ def self.startup
export_pin(YELLOW_LED)
export_pin(GREEN_LED)

sleep 1

write_colors

sleep 1

set_colors("red" => false, "yellow" => false, "green" => false)
write_colors

trap_signals
SdNotify.ready
setup_watchdog
start_light_thread
start_client
end

def self.set_colors(colors)
@red = colors["red"]
@yellow = colors["yellow"]
@green = colors["green"]
start_light_thread
end

def self.write_colors
Expand All @@ -67,6 +58,8 @@ def self.export_pin(pin)
end

def self.start_light_thread
return if @started_light_thread

Thread.new do
loop do
start = Time.now
Expand All @@ -76,6 +69,7 @@ def self.start_light_thread
sleep Time.now - start + 1
end
end
@started_light_thread = true
end

def self.setup_watchdog
Expand Down

0 comments on commit 0749170

Please sign in to comment.