Changeset 119

Show
Ignore:
Timestamp:
06/01/07 00:37:42 (2 years ago)
Author:
dsmith
Message:

added get_acc_cal to python

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/dev/python/Makefile.in

    r118 r119  
    2121 
    2222distclean: clean 
     23        rm Makefile 
    2324 
    2425.PHONY: all install uninstall clean distclean 
  • branches/dev/python/Wiimote.c

    r118 r119  
    2222 * 2007-06-01 L. Donnie Smith <cwiid@abstrakraft.org> 
    2323 * * added Wiimote_FromC 
     24 * * added get_acc_cal 
    2425 * 
    2526 * 2007-05-27 Arthur Peters <amp@singingwizard.org> 
     
    6869static PyObject *Wiimote_get_mesg(Wiimote *self); 
    6970static PyObject *Wiimote_get_state(Wiimote *self, void *closure); 
     71static PyObject *Wiimote_get_acc_cal(Wiimote *self, PyObject *args, 
     72                                     PyObject *kwds); 
    7073 
    7174static PyObject *Wiimote_request_status(Wiimote *self); 
     
    9598        {"get_mesg", (PyCFunction)Wiimote_get_mesg, METH_NOARGS, 
    9699         "blocking call to get messages"}, 
     100        {"get_acc_cal", (PyCFunction)Wiimote_get_acc_cal, 
     101         METH_VARARGS | METH_KEYWORDS, "get accelerometer calibration"}, 
    97102        {"request_status", (PyCFunction)Wiimote_request_status, METH_NOARGS, 
    98103         "request status message"}, 
     
    487492} 
    488493 
     494static PyObject *Wiimote_get_acc_cal(Wiimote *self, PyObject *args, 
     495                                     PyObject *kwds) 
     496{ 
     497        static char *kwlist[] = { "ext_type", NULL }; 
     498        int ext_type; 
     499        struct acc_cal acc_cal; 
     500        PyObject *PyAccCal; 
     501 
     502        if (!PyArg_ParseTupleAndKeywords(args, kwds, 
     503                                         "i:cwiid.Wiimote.get_acc_cal", kwlist, 
     504                                         &ext_type)) { 
     505                return NULL; 
     506        } 
     507 
     508        if (cwiid_get_acc_cal(self->wiimote, ext_type, &acc_cal)) { 
     509                PyErr_SetString(PyExc_IOError, "Wiimote get acc cal error"); 
     510                return NULL; 
     511        } 
     512 
     513        if (!(PyAccCal = Py_BuildValue("([i,i,i],[i,i,i])", acc_cal.zero[0], 
     514                                       acc_cal.zero[1], acc_cal.zero[2], 
     515                                       acc_cal.one[0], acc_cal.one[1], 
     516                                       acc_cal.one[2]))) { 
     517                return NULL; 
     518        } 
     519 
     520        return PyAccCal; 
     521} 
     522 
    489523static PyObject *Wiimote_request_status(Wiimote *self) 
    490524{