Pi_way
September 19, 2023, 2:41am
27
A vex::task object does not have to be a function reference:
yea, you have to use a static member function as a callback for tasks (and threads). However, you can pass the current class instance as a parameter to the callback and use that to do instance specific things. Here’s a simple example.
/*----------------------------------------------------------------------------*/
/* */
/* Module: main.cpp */
/* Author: …
There is …probably…? a hook in Python, which will yield to the brain’s task scheduler each loop iteration. (calling wait(20, MILLESECONDS) is not strictly required in Python).
Just use sleep (or wait, same thing), wait(1, MSEC) is the closest you can get, there is no binding for yield.
You may also find that just having no delay (sleep etc.) in the loop works, I think I have a hook that calls yield for each loop iteration so python doesn’t ever block the scheduler.
but yield is rarely needed even in C++ code, what’s the actual use case ?
Connecting 2 cortex brains:
Summary
The code linked at the end of this post allows two cortex controllers to be connected using their UART ports. The master cortex (with VEXnet and joystick) controls the slave cortex (no VEXnet) using the example communications protocol.
**Background
**
I’ve posted about serial communications before in the ROBOTC programming tips thread , however, I wanted to show an example that was a little more developed with bi-directional communication between two devices.
For some of the product…