Class: Pigpio::Callback

Inherits:
Object
  • Object
show all
Defined in:
ext/pigpio/pigpio.c

Instance Method Summary collapse

Instance Method Details

#cancelObject

This function cancels a callback/event-callback.

The function returns 0 if OK, otherwise pigif_callback_not_found.

:call-seq:

cancel() -> Integer

See also: pigpio site event_callback_cancel See also: pigpio site callback_cancel



182
183
184
185
186
187
188
189
190
191
192
193
194
195
# File 'ext/pigpio/pigpio.c', line 182

VALUE pigpio_rbst_callback_id_cancel(VALUE self){
  int id;
  callback_id_t *st=TypedData_Get_Struct2(self,callback_id_t,&callback_id_data_type);
  id=st->id;
  if(id<0){return INT2NUM(pigif_callback_not_found);}
  id=(*(st->cancel))(st->id);
  if(st->thread!=Qnil){
    rb_funcall((VALUE)st->thread, rb_intern("kill"), 0);
  }
  st->id=-1;
  st->thread=Qnil;
  st->queue=Qnil;
  return INT2NUM(id);
}

#idObject

Get callback id.R eturn Integer.



167
168
169
170
# File 'ext/pigpio/pigpio.c', line 167

VALUE pigpio_rbst_callback_id_r_id(VALUE self){
  callback_id_t *st=TypedData_Get_Struct2(self,callback_id_t,&callback_id_data_type);
  return(INT2NUM(st->id));
}