da_funk 0.6.6 → 0.6.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 89f6f58be57a4a45bf02ae2cd90a1c64010d0c44
4
- data.tar.gz: e22bd2eb2bf8665858ea01c6e18b4f0ffd454542
3
+ metadata.gz: 4ecfc56704e73c282ee07fba23ce1fd9b80a3999
4
+ data.tar.gz: 23a3e8272e9b54cf3f83eb50f61935fda1c480d4
5
5
  SHA512:
6
- metadata.gz: 7667ba7a022b1688171194841dd3b95a74b18c99290dac956f6f14068f2f1a29ccbf88a605ed74e2a974e9b31609b1a98caf794ef2e458fe7577f9892a91aeed
7
- data.tar.gz: 4e59379bb67fbcad861f1a62c30120252a29a63a5d7d57fe0b06a16144dd79497f2d5497ccdc46244e07668ba872405d0300cb948dfc11c8f9364d642ea1c102
6
+ metadata.gz: 6332262e7d61471e94141fba3358a43130d35c64504fafb74ab494c8572ad9a9d29f185dc641fd7f3df35096232ef75b7b8082297f9b1ff2244c9669d7909dee
7
+ data.tar.gz: 750db4f4957e904bf1800c786cefcf5b7784c13cc6b0a0da041934c15f5ec9a4adbe3495d84aff5cc443f421d3160960db5d6021154ba4401d7c54b5c5d65cb3
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- da_funk (0.6.6)
4
+ da_funk (0.6.7)
5
5
  bundler (~> 1.7)
6
6
  cloudwalk_handshake (~> 0.5)
7
7
  posxml_parser (~> 0.6)
@@ -13,7 +13,7 @@ GEM
13
13
  specs:
14
14
  cloudwalk_handshake (0.5.4)
15
15
  funky-simplehttp (0.4.4)
16
- posxml_parser (0.7.2)
16
+ posxml_parser (0.7.3)
17
17
  rake (10.5.0)
18
18
  yard (0.8.7.6)
19
19
 
data/RELEASE_NOTES.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # DaFunk
2
2
 
3
+ ### 0.6.7 - 2016-02-29 - DaFunk::Engine and DaFunk::StatusBar
4
+
5
+ - Refactoring screen string manipulation.
6
+ - Only call signal if Network connected.
7
+ - Bug fix, only consider Network configured if Device::Setting.media is defined and Device::Setting.network_configured is 1.
8
+ - Implement DaFunk::Engine and support to display status bar icons(battery, wifi and mobile).
9
+ - Add support to remove all files from ./shared/ on Device::ParamsDat.format!(excluding main.bmp).
10
+ - Device::Display.main_image check if platform respond_to main_image and if the file exists to return the method.
11
+ - Update posxml_parser to version 0.7.3.
12
+
3
13
  ### 0.6.6 - 2016-02-18 - Update map keys adding some special chars
4
14
 
5
15
  - Update map keys adding some special chars.
data/Rakefile CHANGED
@@ -20,6 +20,8 @@ FILES = FileList[
20
20
  "lib/da_funk/i18n_error.rb",
21
21
  "lib/da_funk/i18n.rb",
22
22
  "lib/da_funk/file_parameter.rb",
23
+ "lib/da_funk/helper/status_bar.rb",
24
+ "lib/da_funk/engine.rb",
23
25
  "lib/device.rb",
24
26
  "lib/device/audio.rb",
25
27
  "lib/device/crypto.rb",
@@ -0,0 +1,15 @@
1
+ module DaFunk
2
+ class Engine
3
+ def self.setup
4
+ Device::Display.clear
5
+ puts "SETUP NOTIFICATIONS..."
6
+ Device::Notification.setup
7
+ end
8
+
9
+ def self.check
10
+ Device::Notification.check
11
+ DaFunk::Helper::StatusBar.check
12
+ end
13
+ end
14
+ end
15
+
@@ -0,0 +1,93 @@
1
+ module DaFunk
2
+ module Helper
3
+ class StatusBar
4
+ STATUS_TIMEOUT = 10
5
+ SLOT_CONNECTION = 0
6
+ SLOT_BATTERY = 7
7
+
8
+ BATTERY_IMAGES = {
9
+ 0 => "./shared/battery0.png",
10
+ 1 => "./shared/battery25.png",
11
+ 2 => "./shared/battery50.png",
12
+ 3 => "./shared/battery75.png",
13
+ 4 => "./shared/battery100.png",
14
+ 5 => "./shared/battery0c.png",
15
+ 6 => "./shared/battery100c.png",
16
+ 7 => nil
17
+ }
18
+
19
+ WIFI_IMAGES = {
20
+ 0..29 => "./shared/wifi0.png",
21
+ 30..59 => "./shared/wifi30.png",
22
+ 60..79 => "./shared/wifi60.png",
23
+ 80..100 => "./shared/wifi100.png"
24
+ }
25
+
26
+ MOBILE_IMAGES = {
27
+ 0..0 => "./shared/mobile0.png",
28
+ 1..20 => "./shared/mobile20.png",
29
+ 21..40 => "./shared/mobile40.png",
30
+ 41..60 => "./shared/mobile60.png",
31
+ 61..80 => "./shared/mobile80.png",
32
+ 81..100 => "./shared/mobile100.png"
33
+ }
34
+
35
+ class << self
36
+ attr_accessor :status_timeout, :signal, :battery
37
+ end
38
+
39
+ def self.check
40
+ if self.valid?
41
+ self.change_connection
42
+ self.change_battery
43
+ end
44
+ end
45
+
46
+ def self.change_connection
47
+ sig = Device::Network.signal
48
+ if self.signal != sig
49
+ self.signal = sig
50
+ if Device::Network.gprs?
51
+ Device::Display.print_status_bar(SLOT_CONNECTION,
52
+ get_image_path(:gprs, self.signal))
53
+ elsif Device::Network.wifi?
54
+ Device::Display.print_status_bar(SLOT_CONNECTION,
55
+ get_image_path(:wifi, self.signal))
56
+ end
57
+ end
58
+ end
59
+
60
+ def self.change_battery
61
+ bat = Device::System.battery
62
+ if self.battery != bat
63
+ self.battery = bat
64
+ Device::Display.print_status_bar(
65
+ SLOT_BATTERY, get_image_path(:battery, self.battery))
66
+ end
67
+ end
68
+
69
+ def self.get_image_path(type, sig)
70
+ return if sig.nil?
71
+ case type
72
+ when :gprs
73
+ MOBILE_IMAGES.each {|k,v| return v if k.include? sig }
74
+ when :wifi
75
+ WIFI_IMAGES.each {|k,v| return v if k.include? sig }
76
+ when :battery
77
+ BATTERY_IMAGES[sig]
78
+ else
79
+ nil
80
+ end
81
+ end
82
+
83
+ self.status_timeout ||= Time.now
84
+ def self.valid?
85
+ if self.status_timeout < Time.now
86
+ self.status_timeout = Time.now + STATUS_TIMEOUT
87
+ true
88
+ end
89
+ end
90
+ end
91
+ end
92
+ end
93
+
@@ -45,7 +45,7 @@ class Screen
45
45
  if n_strings?(args)
46
46
  args = args.map {|str| "#{str}\n" }
47
47
  else
48
- args[0] = "#{args[0]}\n"
48
+ args[0] = "#{args.first}\n"
49
49
  end
50
50
  print(*args)
51
51
  end
@@ -64,9 +64,9 @@ class Screen
64
64
  jump_line if string[-1] == "\n"
65
65
  else
66
66
  space = @max_x - @x
67
- Device::Display.print("#{string[0..(space - 1)]}", @y, @x)
67
+ Device::Display.print("#{string[0..(space - 1)]}", @y.to_i, @x.to_i)
68
68
  jump_line
69
- loop_split_strings("#{string[(space)..-1]}")
69
+ loop_split_strings("#{string[space..-1]}")
70
70
  end
71
71
  end
72
72
  end
@@ -1,4 +1,4 @@
1
1
  module DaFunk
2
- VERSION="0.6.6"
2
+ VERSION="0.6.7"
3
3
  end
4
4
 
@@ -32,13 +32,16 @@ class Device
32
32
  end
33
33
 
34
34
  def download(force = false)
35
- if force || outdated?
35
+ if force || self.outdated?
36
36
  ret = Device::Transaction::Download.request_file(remote, file, crc_local)
37
37
  else
38
38
  ret = Device::Transaction::Download::FILE_NOT_CHANGE
39
39
  end
40
40
  @crc_local = @crc if ret == Device::Transaction::Download::SUCCESS
41
41
  ret
42
+ rescue => e
43
+ puts "ERROR #{e.message}"
44
+ Device::Transaction::Download::IO_ERROR
42
45
  end
43
46
 
44
47
  def dir
@@ -63,6 +66,8 @@ class Device
63
66
  @crc_local = Device::Crypto.crc16_hex(handle.read)
64
67
  end
65
68
  @crc_local != @crc
69
+ rescue
70
+ true
66
71
  ensure
67
72
  handle.close if handle
68
73
  end
@@ -1,5 +1,7 @@
1
1
  class Device
2
2
  class Display
3
+ MAIN_BMP = "main.bmp"
4
+
3
5
  def self.adapter
4
6
  Device.adapter::Display
5
7
  end
@@ -44,5 +46,35 @@ class Device
44
46
  adapter.clear_line line
45
47
  end
46
48
  end
49
+
50
+ # Print image in slot of status bar
51
+ #
52
+ # @param slot [Fixnum] Status bar slot.
53
+ # @param image_path [String] Path to image, or send nil to clear the slot.
54
+ # @return [NilClass] Failure.
55
+ # @return [TrueClass] Success.
56
+ def self.print_status_bar(slot, image_path)
57
+ slots = self.adapter.status_bar_slots_available - 1
58
+ if (0..slots).include?(slot)
59
+ if image_path.nil? || File.exists?(image_path)
60
+ self.adapter.print_status_bar(slot, image_path)
61
+ end
62
+ end
63
+ end
64
+
65
+ def self.print_main_image
66
+ bmp = "./shared/#{self.main_image}"
67
+ self.print_bitmap(bmp,0,0) if File.exists?(bmp)
68
+ end
69
+
70
+ def self.main_image
71
+ if adapter.respond_to?(:main_image) &&
72
+ File.exists?("./shared/#{adapter.main_image}")
73
+ adapter.main_image
74
+ else
75
+ MAIN_BMP
76
+ end
77
+ end
47
78
  end
48
79
  end
80
+
@@ -70,7 +70,7 @@ class Device
70
70
  end
71
71
 
72
72
  def self.configured?
73
- Device::Setting.network_configured == "1"
73
+ Device::Setting.network_configured == "1" && ! Device::Setting.media.to_s.empty?
74
74
  end
75
75
 
76
76
  def self.ping(host, port)
@@ -82,10 +82,8 @@ class Device
82
82
  end
83
83
 
84
84
  def self.sim_id
85
- if adapter.respond_to? :sim_id
85
+ if self.adapter.started?
86
86
  adapter.sim_id
87
- else
88
- ""
89
87
  end
90
88
  end
91
89
 
@@ -93,7 +91,9 @@ class Device
93
91
  #
94
92
  # @return [Fixnum] Signal value between 0 and 5.
95
93
  def self.signal
96
- adapter.signal
94
+ if self.connected? == 0
95
+ adapter.signal
96
+ end
97
97
  end
98
98
 
99
99
  # Scan for wifi aps available
@@ -129,6 +129,13 @@ class Device
129
129
  File.delete(FILE_NAME) if exists?
130
130
  @apps = []
131
131
  @files = []
132
+ Dir.entries("./shared/").each do |f|
133
+ begin
134
+ path = "./shared/#{f}"
135
+ File.delete(path) if File.file?(path) && f != Device::Display::MAIN_BMP
136
+ rescue
137
+ end
138
+ end
132
139
  end
133
140
 
134
141
  def self.update_app(application, index = 1, all = 1, force = false)
@@ -118,6 +118,8 @@ class Device
118
118
  return_code
119
119
  rescue SocketError
120
120
  return COMMUNICATION_ERROR
121
+ rescue
122
+ return IO_ERROR
121
123
  end
122
124
 
123
125
  def generate_crc(local_path)
data/lib/device.rb CHANGED
@@ -19,11 +19,9 @@ class Device
19
19
  end
20
20
 
21
21
  def self.app_loop(&block)
22
- Device::Display.clear
23
- puts "SETUP NOTIFICATIONS..."
24
- Notification.setup
22
+ DaFunk::Engine.setup
25
23
  loop do
26
- Notification.check
24
+ DaFunk::Engine.check
27
25
  block.call(self)
28
26
  end
29
27
  end
data/out/da_funk.mrb CHANGED
Binary file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: da_funk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.6
4
+ version: 0.6.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thiago Scalone
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-18 00:00:00.000000000 Z
11
+ date: 2016-02-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -111,8 +111,10 @@ files:
111
111
  - imgs/daft-punk-da-funk.jpg
112
112
  - lib/da_funk.rb
113
113
  - lib/da_funk/callback_flow.rb
114
+ - lib/da_funk/engine.rb
114
115
  - lib/da_funk/file_parameter.rb
115
116
  - lib/da_funk/helper.rb
117
+ - lib/da_funk/helper/status_bar.rb
116
118
  - lib/da_funk/i18n.rb
117
119
  - lib/da_funk/i18n_error.rb
118
120
  - lib/da_funk/iso8583.rb