lib/sphero/request.rb in hybridgroup-sphero-1.4.0 vs lib/sphero/request.rb in hybridgroup-sphero-1.5.2
- old
+ new
@@ -1,11 +1,11 @@
class Sphero
class Request
SOP1 = 0xFF
SOP2 = 0xFF
- attr_reader :data
+ attr_reader :data, :seq
def initialize seq, data = []
@seq = seq
@data = data
@did = 0x00
@@ -87,11 +87,11 @@
def packet_body
@data.pack 'CnC'
end
end
- class Heading < Request
+ class Heading < Sphero
def initialize seq, heading
super(seq, [heading])
@cid = 0x01
end
@@ -99,10 +99,22 @@
def packet_body
@data.pack 'n'
end
end
+ class Stabilization < Sphero
+ def initialize seq, on
+ super(seq, [on ? 1 : 0])
+ @cid = 0x02
+ end
+
+ private
+ def packet_body
+ @data.pack 'C'
+ end
+ end
+
class Sleep < Request
def initialize seq, wakeup, macro
super(seq, [wakeup, macro])
@cid = 0x22
end
@@ -112,13 +124,26 @@
def packet_body
@data.pack 'nC'
end
end
- class SetPowerNotification < Sphero
+ class SetPowerNotification < Request
def initialize seq, enable
super(seq, [enable])
@cid = 0x21
+ end
+ end
+
+ class SetTempOptionFlags < Request
+ def initialize seq, flag
+ super(seq, [flag])
+ @cid = 0x37
+ @did = 0x02
+ end
+
+ private
+ def packet_body
+ @data.pack 'N'
end
end
GYRO_AXIS_H_FILTERED = 0x0000_0001
GYRO_AXIS_M_FILTERED = 0x0000_0002