Permalink
Browse files

Pseudo near mode for non-K4W devices.

This adjusts the IR gain only which isn't as good as the K4W
near mode but avoids overexposure near the 50cm hard limit
on non-K4W devices.

Signed-off-by: Rene Wagner <rwagner@informatik.uni-bremen.de>
  • Loading branch information...
renewagner committed Mar 30, 2012
1 parent 34f4c1a commit e9e1f7a66d87ac6d3b50468bf21ebcfc02bdfd33
Showing with 15 additions and 8 deletions.
  1. +15 −8 src/cameras.c
View
@@ -1353,24 +1353,31 @@ int freenect_set_smoothing_mode(freenect_device* dev, const freenect_smoothing_m
int freenect_set_range_mode(freenect_device* dev, const freenect_range_mode mode)
{
- if (dev->hwrev != HWREV_K4W_0)
- return -1;
+ freenect_context *ctx = dev->parent;
int retval = 0;
switch(mode) {
case FREENECT_RANGE_DEFAULT:
retval = write_register(dev, 0x0015, 0x001E);
- if (retval != 0)
+ if (retval != 0) {
+ FN_ERROR("Failed to set IR gain\n");
return retval;
- usleep(100000);
- retval = write_register(dev, 0x02EF, 0x0190);
+ }
+ if (dev->hwrev == HWREV_K4W_0) {
+ usleep(100000);
+ retval = write_register(dev, 0x02EF, 0x0190);
+ }
break;
case FREENECT_RANGE_NEAR_MODE:
retval = write_register(dev, 0x0015, 0x0007);
- if (retval != 0)
+ if (retval != 0) {
+ FN_ERROR("Failed to set IR gain\n");
return retval;
- usleep(100000);
- retval = write_register(dev, 0x02EF, 0x0000);
+ }
+ if (dev->hwrev == HWREV_K4W_0) {
+ usleep(100000);
+ retval = write_register(dev, 0x02EF, 0x0000);
+ }
break;
}
return retval;

0 comments on commit e9e1f7a

Please sign in to comment.