Hi @erkamtb -
Writing a lua script to accomplish your goals may be far faster and easier! There are some relevant threads here on the forum, and I’ve been keeping useful scripts here. The official examples are also helpful!
Basically this code lives in a specific place, and is run fresh with every autopilot restart. It can read values the autopilot has access too, and log things, control outputs, and react to user control of the vehicle, or take actions in some scenarios.