Browse files

wappers/ruby: Updated to use new frame mode code.

Signed-off-by: Alex Weiss <algrs@cacography.net>
  • Loading branch information...
1 parent 4e6f165 commit 6b21e4128414d62663ea3bfc05f927884ea61bbd @algrs committed Jul 25, 2011
View
52 wrappers/ruby/ffi-libfreenect/lib/freenect/device.rb
@@ -132,39 +132,35 @@ def stop_video
end
end
- def set_depth_format(fmt)
- l_fmt = fmt.is_a?(Numeric)? fmt : Freenect::DEPTH_FORMATS[fmt]
- ret = ::FFI::Freenect.freenect_set_depth_format(self.device, l_fmt)
- if (ret== 0)
- @depth_format = fmt
- else
- raise DeviceError, "Error calling freenect_set_depth_format(self, #{fmt})"
- end
- end
-
- alias depth_format= set_depth_format
-
+ def set_depth_mode(mode)
+ mode = Freenect.depth_mode(:medium, mode) unless mode.is_a?(Freenect::FrameMode)
+ raise ArgumentError, "Unkown depth mode #{mode}" if mode.nil?
+ ret = ::FFI::Freenect.freenect_set_depth_mode(self.device, mode)
+ raise DeviceError, "Error calling freenect_set_depth_mode(self, #{mode})" unless ret == 0
+ end
+ alias depth_mode= set_depth_mode
+
# returns the symbolic constant for the current depth format
- def depth_format
- (@depth_format.is_a?(Numeric))? Freenect::DEPTH_FORMATS[@depth_format] : @depth_format
+ def depth_mode
+ x = ::FFI::Freenect.freenect_get_current_depth_mode(self.device)
+ x.frame_mode_type = :depth unless x.nil?
+ x
end
# Sets the video format to one of the following accepted values:
#
- def set_video_format(fmt)
- l_fmt = fmt.is_a?(Numeric)? fmt : Freenect::VIDEO_FORMATS[fmt]
- ret = ::FFI::Freenect.freenect_set_video_format(self.device, l_fmt)
- if (ret== 0)
- @video_format = fmt
- else
- raise DeviceError, "Error calling freenect_set_video_format(self, #{fmt})"
- end
- end
-
- alias video_format= set_video_format
-
- def video_format
- (@video_format.is_a?(Numeric))? ::Freenect::VIDEO_FORMATS[@video_format] : @video_format
+ def set_video_mode(mode)
+ mode = Freenect.video_mode(:medium, mode) unless mode.is_a?(Freenect::FrameMode)
+ raise ArgumentError, "Unkown video mode #{mode}" if mode.nil?
+ ret = ::FFI::Freenect.freenect_set_video_mode(self.device, mode)
+ raise DeviceError, "Error calling freenect_set_video_mode(self, #{mode})" unless ret == 0
+ end
+ alias video_mode= set_video_mode
+
+ def video_mode
+ x = ::FFI::Freenect.freenect_get_current_video_mode(self.device)
+ x.frame_mode_type = :video unless x.nil?
+ x
end
# Sets the led to one of the following accepted values:
View
21 wrappers/ruby/ffi-libfreenect/spec/device_spec.rb
@@ -69,20 +69,21 @@
end
it "should allow the video_format to be set and retrieved" do
- @dev.video_format.should be_nil # at first
- @dev.video_format = :bayer
- @dev.video_format.should == :bayer
- @dev.video_format = Freenect::VIDEO_RGB
- @dev.video_format.should == :rgb
+ @dev.video_mode.should be_nil # at first
+ @dev.video_mode = Freenect.video_mode(:medium, :bayer)
+ @dev.video_mode.format.should == :bayer
+ @dev.video_mode = Freenect.video_mode(:medium, :rgb)
+ @dev.video_mode.format.should == :rgb
+ @dev.video_mode.frame_mode_type.shoud == :video
end
it "should allow the depth_format to be set and retrieved" do
- @dev.depth_format.should be_nil # at first
- @dev.depth_format = :depth_10bit
- @dev.depth_format.should == :depth_10bit
- @dev.depth_format = Freenect::DEPTH_11BIT
- @dev.depth_format = :depth_11bit
+ @dev.depth_mode.should be_nil # at first
+ @dev.depth_mode = :depth_10bit
+ @dev.depth_mode.should == :depth_10bit
+ @dev.depth_mode = Freenect::DEPTH_11BIT
+ @dev.depth_mode = :depth_11bit
end
it "should allow itself to be looked up by it's object reference ID" do

0 comments on commit 6b21e41

Please sign in to comment.