1
0
mirror of https://github.com/xtacocorex/CHIP_IO synced 2025-07-20 04:43:21 +00:00

Formal initial start at CHIP Pro support. Removed the custom DT Overlays, OverlayManager now pulls dtbo from chip-dt-overlays package from NTC. First commit to CHIP_IO from a CPro DevKit

This commit is contained in:
Robert Wolterman
2017-02-13 05:18:33 +00:00
parent 6bd2e61450
commit c5dbede3c4
16 changed files with 282 additions and 143 deletions

View File

@ -56,6 +56,41 @@ static PyObject *py_cleanup(PyObject *self, PyObject *args)
Py_RETURN_NONE;
}
static int init_module(void)
{
clear_error_msg();
// figure out if we're a chip pro
if (is_this_chippro() < 1) {
char err[2000];
snprintf(err, sizeof(err), "init_module error (%s)", get_error_msg());
PyErr_SetString(PyExc_RuntimeError, err);
return 0;
}
// After this point, ISCHIPPRO variable should be good to go
// If we make it here, we're good to go
if (DEBUG)
printf(" ** init_module: setup complete **\n");
module_setup = 1;
return 0;
}
// python function value = is_chip_pro
static PyObject *py_is_chip_pro(PyObject *self, PyObject *args)
{
PyObject *py_value;
if (!module_setup) {
init_module();
}
py_value = Py_BuildValue("i", ISCHIPPRO);
return py_value;
}
// python function start(channel, angle, range)
static PyObject *py_start_channel(PyObject *self, PyObject *args, PyObject *kwargs)
{
@ -73,6 +108,10 @@ static PyObject *py_start_channel(PyObject *self, PyObject *args, PyObject *kwar
}
ASSRT(channel != NULL);
if (!module_setup) {
init_module();
}
if (!get_key(channel, key)) {
PyErr_SetString(PyExc_ValueError, "Invalid Servo key or name.");
return NULL;
@ -218,6 +257,7 @@ PyMethodDef servo_methods[] = {
{"set_angle", (PyCFunction)py_set_angle, METH_VARARGS, "Change the servo angle\nangle - angle of the servo between +/-(range/2)" },
{"cleanup", (PyCFunction)py_cleanup, METH_VARARGS, "Clean up by resetting All or one Servo that have been used by this program."},
{"toggle_debug", py_toggle_debug, METH_VARARGS, "Toggles the enabling/disabling of Debug print output"},
{"is_chip_pro", py_is_chip_pro, METH_VARARGS, "Is hardware a CHIP Pro? Boolean False for normal CHIP/PocketCHIP (R8 SOC)"},
{NULL, NULL, 0, NULL}
};