rb-blink1 0.0.6 → 0.0.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.
- data/ext/blink1/blink1-lib.c +106 -74
- data/ext/blink1/blink1-lib.h +9 -7
- data/ext/blink1/blink1.c +15 -0
- data/ext/blink1/hid.c.libusb +108 -109
- data/ext/blink1/hid.c.mac +115 -160
- data/ext/blink1/hid.c.windows +115 -112
- data/ext/blink1/hidapi.h +3 -2
- data/ext/blink1/osccal.h +7 -7
- data/ext/blink1/usbconfig.h +3 -3
- data/lib/blink1.rb +5 -5
- data/lib/blink1/version.rb +1 -1
- data/spec/blink1_spec.rb +11 -3
- data/spec/spec_helper.rb +7 -1
- metadata +2 -2
data/ext/blink1/hidapi.h
CHANGED
@@ -87,7 +87,7 @@ extern "C" {
|
|
87
87
|
needed. This function should be called at the beginning of
|
88
88
|
execution however, if there is a chance of HIDAPI handles
|
89
89
|
being opened by different threads simultaneously.
|
90
|
-
|
90
|
+
|
91
91
|
@ingroup API
|
92
92
|
|
93
93
|
@returns
|
@@ -112,6 +112,8 @@ extern "C" {
|
|
112
112
|
|
113
113
|
This function returns a linked list of all the HID devices
|
114
114
|
attached to the system which match vendor_id and product_id.
|
115
|
+
If @p vendor_id is set to 0 then any vendor matches.
|
116
|
+
If @p product_id is set to 0 then any product matches.
|
115
117
|
If @p vendor_id and @p product_id are both set to 0, then
|
116
118
|
all HID devices will be returned.
|
117
119
|
|
@@ -380,4 +382,3 @@ extern "C" {
|
|
380
382
|
#endif
|
381
383
|
|
382
384
|
#endif
|
383
|
-
|
data/ext/blink1/osccal.h
CHANGED
@@ -14,8 +14,8 @@ const uint8_t EEPROM_ADDR_OSCCAL = 0;
|
|
14
14
|
static void calibrationLoad(void)
|
15
15
|
{
|
16
16
|
uint8_t calibrationValue;
|
17
|
-
// calibration value from last time
|
18
|
-
calibrationValue = eeprom_read_byte(EEPROM_ADDR_OSCCAL);
|
17
|
+
// calibration value from last time
|
18
|
+
calibrationValue = eeprom_read_byte(EEPROM_ADDR_OSCCAL);
|
19
19
|
if(calibrationValue != 0xff){
|
20
20
|
OSCCAL = calibrationValue;
|
21
21
|
}
|
@@ -42,8 +42,8 @@ static void calibrateOscillator(void)
|
|
42
42
|
/* do a binary search: */
|
43
43
|
do{
|
44
44
|
OSCCAL = trialValue + step;
|
45
|
-
x = usbMeasureFrameLength(); // proportional to current real frequency
|
46
|
-
if(x < targetValue) // frequency still too low
|
45
|
+
x = usbMeasureFrameLength(); // proportional to current real frequency
|
46
|
+
if(x < targetValue) // frequency still too low
|
47
47
|
trialValue += step;
|
48
48
|
step >>= 1;
|
49
49
|
}while(step > 0);
|
@@ -76,10 +76,10 @@ both regions.
|
|
76
76
|
void usbEventResetReady(void)
|
77
77
|
{
|
78
78
|
calibrateOscillator();
|
79
|
-
// store the calibrated value in EEPROM
|
79
|
+
// store the calibrated value in EEPROM
|
80
80
|
eeprom_write_byte(EEPROM_ADDR_OSCCAL, OSCCAL);
|
81
|
-
|
81
|
+
|
82
82
|
usbHasBeenSetup++;
|
83
83
|
}
|
84
84
|
|
85
|
-
#endif
|
85
|
+
#endif
|
data/ext/blink1/usbconfig.h
CHANGED
@@ -269,8 +269,8 @@ extern void usbEventResetReady(void);
|
|
269
269
|
*/
|
270
270
|
/*#define USB_CFG_SERIAL_NUMBER 'N', 'o', 'n', 'e' */
|
271
271
|
/*#define USB_CFG_SERIAL_NUMBER_LEN 0 */
|
272
|
-
#define USB_CFG_SERIAL_NUMBER 'N', 'o', 'n', 't','h','i','n','g'
|
273
|
-
#define USB_CFG_SERIAL_NUMBER_LEN 8
|
272
|
+
#define USB_CFG_SERIAL_NUMBER 'N', 'o', 'n', 't','h','i','n','g'
|
273
|
+
#define USB_CFG_SERIAL_NUMBER_LEN 8
|
274
274
|
/* Same as above for the serial number. If you don't want a serial number,
|
275
275
|
* undefine the macros.
|
276
276
|
* It may be useful to provide the serial number through other means than at
|
@@ -385,4 +385,4 @@ extern void usbEventResetReady(void);
|
|
385
385
|
/* #define USB_INTR_PENDING_BIT INTF0 */
|
386
386
|
/* #define USB_INTR_VECTOR INT0_vect */
|
387
387
|
|
388
|
-
#endif /* __usbconfig_h_included__ */
|
388
|
+
#endif /* __usbconfig_h_included__ */
|
data/lib/blink1.rb
CHANGED
@@ -12,7 +12,7 @@ class Blink1
|
|
12
12
|
attr_accessor :delay_millis
|
13
13
|
|
14
14
|
# :call-seq:
|
15
|
-
# <span class="name">new</span> <span class="arguments">( {Fixnum} id )</span>
|
15
|
+
# <span class="name">new</span> <span class="arguments">( {Fixnum} id )</span>
|
16
16
|
# <span class="name">new</span> <span class="arguments">( {Boolean} auto_open )</span>
|
17
17
|
# <span class="name">new</span> <span class="arguments">( {String} serial_id )</span>
|
18
18
|
# <span class="name">new</span> <span class="arguments">( :path => <em>device_path</em> )</span>
|
@@ -43,7 +43,7 @@ class Blink1
|
|
43
43
|
|
44
44
|
#
|
45
45
|
# :call-seq:
|
46
|
-
# <span class="name">open</span> <span class="arguments">( {Fixnum} id ) { |blink1| }</span>
|
46
|
+
# <span class="name">open</span> <span class="arguments">( {Fixnum} id ) { |blink1| }</span>
|
47
47
|
# <span class="name">open</span> <span class="arguments">( {Boolean} autoopen ) { |blink1| }</span>
|
48
48
|
# <span class="name">open</span> <span class="arguments">( {String} serial_id ) { |blink1| }</span>
|
49
49
|
# <span class="name">open</span> <span class="arguments">( :path => <em>device_path</em> ) { |blink1| }</span>
|
@@ -133,9 +133,9 @@ class Blink1
|
|
133
133
|
devs = []
|
134
134
|
while i < count do
|
135
135
|
devs << {
|
136
|
-
id
|
137
|
-
serial
|
138
|
-
path
|
136
|
+
:id => i,
|
137
|
+
:serial => cached_serial(i),
|
138
|
+
:path => cached_path(i)
|
139
139
|
}
|
140
140
|
i += 1
|
141
141
|
end
|
data/lib/blink1/version.rb
CHANGED
data/spec/blink1_spec.rb
CHANGED
@@ -2,16 +2,24 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Blink1 do
|
4
4
|
|
5
|
-
|
5
|
+
context 'native extention methods' do
|
6
6
|
|
7
|
-
it 'vendor_id' do
|
7
|
+
it 'returns vendor_id' do
|
8
8
|
Blink1.vendor_id.should eql(10168)
|
9
9
|
end
|
10
10
|
|
11
|
-
it 'product_id' do
|
11
|
+
it 'returns product_id' do
|
12
12
|
Blink1.product_id.should eql(493)
|
13
13
|
end
|
14
14
|
|
15
15
|
end
|
16
16
|
|
17
|
+
context 'class methods', :device => true do
|
18
|
+
|
19
|
+
it 'returns list' do
|
20
|
+
Blink1.list.is_a?(Array).should be_true
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
17
25
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -8,9 +8,15 @@ Spork.prefork do; end
|
|
8
8
|
|
9
9
|
Spork.each_run do; end
|
10
10
|
|
11
|
+
require 'blink1'
|
12
|
+
|
13
|
+
RSpec.configure do |config|
|
14
|
+
if ENV['CI']
|
15
|
+
config.filter_run_excluding :device => true
|
16
|
+
end
|
17
|
+
end
|
11
18
|
|
12
19
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
13
20
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
14
21
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'ext'))
|
15
22
|
|
16
|
-
require 'blink1'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rb-blink1
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-05-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|