def on_sleep(obj=nil, &block)
      @on_sleep_obj = obj
      @on_sleep = Proc.new { |obj_ptr|
        yield object_for(obj_ptr)
      }
      Phidgets::FFI::Common.set_OnWillSleep_Handler(@on_sleep, pointer_for(obj))
	  true
	  
    end
def on_sleep(obj=nil, &block)
      @on_sleep_obj = obj
      @on_sleep = Proc.new { |obj_ptr|
        yield object_for(obj_ptr)
      }
      Phidgets::FFI::Common.set_OnWillSleep_Handler(@on_sleep, pointer_for(obj))
	  true
	  
    end
Sets a sleep handler callback function. This is called when the MacOS X is entering sleep mode.

 @param [String] obj Object to pass to the callback function. This is optional.
 @param [Proc] Block When the callback is executed, the device and object are yielded to this block.
 @example
     ifkit.on_sleep do |obj|
       puts "System sleeping"
     end
 As this runs in it's own thread, be sure that all errors are properly handled or the thread will halt and not fire any more.
 @return [Boolean] returns true or raises an error
 @note Used only in Mac OS X