For embedded uPython, let's say the there is a function defined like this:
def step(time_ms):
. ...
. ...
. return True if .... else False
then I would like to call the function, step(), from C. How can I do this? I think it should be something like this but I couldn't figure out the ? part.
mp_obj_t result = mp_call_function_1(....?, mp_obj_new_float(16.0f))
if (result == mp_const_true) {
} else if (result == mp_const_false) {
}
Thanks
Calling uPython function from C?
Re: Calling uPython function from C?
You should find what you need in this thread: viewtopic.php?f=3&t=530
Re: Calling uPython function from C?
Thanks! The following worked.
mp_obj_t step_function = mp_load_global(qstr_from_str("step"));
result = mp_call_function_1(step_function, mp_obj_new_float(duration));
if (result == mp_const_true) {
} else if (result == mp_const_false) {
} else {
}
mp_obj_t step_function = mp_load_global(qstr_from_str("step"));
result = mp_call_function_1(step_function, mp_obj_new_float(duration));
if (result == mp_const_true) {
} else if (result == mp_const_false) {
} else {
}