Class: ADXL345
- Inherits:
-
Object
- Object
- ADXL345
- Defined in:
- ext/bonekit/adxl345_class.c
Class Method Summary collapse
-
.initialize ⇒ ADXL345
Returns a new ADXL345 object.
Instance Method Summary collapse
-
#raw_acceleration ⇒ Array
Returns an Array with the raw acceleration values ([x,y,z]).
Class Method Details
.initialize ⇒ ADXL345
Returns a new ADXL345 object.
49 50 51 52 53 54 |
# File 'ext/bonekit/adxl345_class.c', line 49
static VALUE ADXL345_new(VALUE class)
{
adxl345_t * ptr = adxl345_create();
VALUE wrap_struct = Data_Wrap_Struct(class, 0, ADXL345_free, ptr);
return wrap_struct;
}
|
Instance Method Details
#raw_acceleration ⇒ Array
Returns an Array with the raw acceleration values ([x,y,z]). The ADXL345 is pre-configured for measuring values in the +/-4g range.
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'ext/bonekit/adxl345_class.c', line 63
static VALUE ADXL345_raw_acceleration(VALUE self)
{
adxl345_t * ptr;
Data_Get_Struct(self, adxl345_t, ptr);
adxl345_vec3_raw_t * raw_acceleration = adxl345_raw_acceleration(ptr);
VALUE value = rb_ary_new2(3);
rb_ary_push(value, INT2FIX(raw_acceleration->x));
rb_ary_push(value, INT2FIX(raw_acceleration->y));
rb_ary_push(value, INT2FIX(raw_acceleration->z));
return value;
}
|