class DaFunk::Helper::StatusBar
Status bar class definition.
Constants
- BATTERY_CHARGING
- BATTERY_IMAGES
- BATTERY_PERCENTAGE_IMAGES
TODO: review the 'print_status_bar' API to reduce the number of files to eleven?
- MEDIA_PATH
- MOBILE_IMAGES
- SLOT_BATTERY_LEVEL
- SLOT_BATTERY_PERCENTUAL
- SLOT_MEDIA
- SLOT_SIGNAL_LEVEL
- SLOT_UPDATE
- STATUS_TIMEOUT
Class macros and constants
- WIFI_IMAGES
Attributes
battery[RW]
current_media[RW]
current_message[RW]
current_signal[RW]
managment[RW]
power[RW]
Public Class Methods
change_battery()
click to toggle source
Updates the battery slot whenever a capacity or power supply change is detected.
# File lib/da_funk/helper/status_bar.rb, line 173 def self.change_battery capacity_type = Device::System.battery_capacity_type capacity = Device::System.battery charging = Device::System.power_supply if self.battery != capacity || self.power != charging if self.battery.nil? # basic integrity check self.battery = capacity elsif charging capacity >= self.battery && self.battery = capacity else capacity <= self.battery && self.battery = capacity end if self.power == charging && capacity != self.battery return nil end self.power = charging rsc = self.get_image_path(self.power ? :battery_charge : :battery, self.battery) Device::Display.print_status_bar(SLOT_BATTERY_LEVEL, rsc) if capacity_type == 'percentage' || !self.power rsc = self.get_image_path(:battery_percentual, self.battery) else rsc = nil end Device::Display.print_status_bar(SLOT_BATTERY_PERCENTUAL, rsc) end end
change_connection()
click to toggle source
# File lib/da_funk/helper/status_bar.rb, line 145 def self.change_connection if ThreadScheduler.pause?(ThreadScheduler::THREAD_EXTERNAL_COMMUNICATION, 200) Device::Display.print_status_bar(SLOT_MEDIA, nil) Device::Display.print_status_bar(SLOT_SIGNAL_LEVEL, nil) self.current_media = nil self.current_signal = nil elsif Device::Network.connected? media = Device::Network.gprs? ? :gprs : :wifi signal = Device::Network.signal if media != self.current_media self.current_media = media Device::Display.print_status_bar(SLOT_MEDIA, MEDIA_PATH[self.current_media]) end if signal != self.current_signal self.current_signal = signal Device::Display.print_status_bar(SLOT_SIGNAL_LEVEL, self.get_image_path(self.current_media, self.current_signal)) end else Device::Display.print_status_bar(SLOT_MEDIA, nil) Device::Display.print_status_bar(SLOT_SIGNAL_LEVEL, "./shared/searching.png") self.current_media = nil self.current_signal = nil end end
change_message()
click to toggle source
# File lib/da_funk/helper/status_bar.rb, line 123 def self.change_message if ThreadScheduler.pause?(ThreadScheduler::THREAD_EXTERNAL_COMMUNICATION, 200) if self.current_message != :pause self.current_message = :pause Device::Display.print_status_bar(2, './shared/semsinal_01.png') Device::Display.print_status_bar(3, './shared/semsinal_02.png') end elsif Device::Network.connected? if self.current_message != :connected self.current_message = :connected Device::Display.print_status_bar(2, './shared/conectado_01.png') Device::Display.print_status_bar(3, './shared/conectado_02.png') end else if self.current_message != :searching self.current_message = :searching Device::Display.print_status_bar(2, './shared/buscando_01.png') Device::Display.print_status_bar(3, './shared/buscando_02.png') end end end
change_update()
click to toggle source
# File lib/da_funk/helper/status_bar.rb, line 114 def self.change_update if File.exists?('./shared/system_update') PAX::Display.print_status_bar(SLOT_UPDATE, "./shared/system_update_download.png") PAX::Display.print_status_bar(3, nil) else self.change_message end end
check()
click to toggle source
# File lib/da_funk/helper/status_bar.rb, line 106 def self.check if self.valid? self.change_connection self.change_battery self.change_update end end
get_image_path(type, sig)
click to toggle source
Searches for the correspondent image to 'type' and 'signal strength'.
# File lib/da_funk/helper/status_bar.rb, line 210 def self.get_image_path(type, sig) return if sig.nil? case type when :gprs MOBILE_IMAGES.each do |k, v| return v if k.include? sig end when :wifi WIFI_IMAGES.each do |k, v| return v if k.include? sig end when :battery BATTERY_IMAGES.each do |k, v| return v if k.include? sig end when :battery_charge if sig < 100 BATTERY_CHARGING[0] else BATTERY_CHARGING[1] end when :battery_percentual BATTERY_PERCENTAGE_IMAGES[sig] else nil end end
valid?()
click to toggle source
# File lib/da_funk/helper/status_bar.rb, line 239 def self.valid? if self.managment true end end