In the last tutorial, we will change the battery warning level and will save the changes on the device. We will also save the variable, command and parameter list on the local machine. So, we don't always need to request the list from the device and can instead load it from a file.
The code is similar to the third tutorial:
To store data in a file, we have to define, which file we want to use, how to store and read the data, For that we define 4 functions:
We create a file called data with permissions to read and to write. If this file doesn't exist, it will be created. Then, we define, how to write and to read and how to reset the file. Now, we can open the file and set the necessary callbacks for reading and writing:
That's all about storing. ACI will do the rest for us. Also, if the data on the device are changed, then ACI will recognize it and load the list again and store the new one.
After that, we request all three lists from ACI. Only if we have all three lists, ACI will store it:
Now, let's change the battery warning levels. The default value is 10600mV. That means, that the UAV will beep, if the voltage will fall under this value. We now want to change this value to 20000mV, which means, that the UAV starts to beep (also if the battery is full). At the end of this tutorial, it is recommended to change the value back to 10600mV.
We now request the battery_warning_voltage_high parameter:
After getting the acknowledge, ACI sets the value of our battery variable to the value of the device. So, with the sending of the parameter package configuration, you will get all set parameters on the device automatically. After that, the menu is coming:
So, if we type in 0, the program quits. With 1, we send a command to the device, that the parameters shall be stored on the device. I.e. after turning your vehicle off and on again, the parameter you have set, will be loaded from the device and you don't have to set it again. E.g. you can see in the list of all parameters, there is the camera option 4 parameter included. It defines, which servo is used for the camera option. It would be senseless to set it again and again every time, when you turn on the device. With all other values you choose in the program (apart from 0 and 1), you set the new battery warning voltage. If you type in 20000, the vehicle will start to beep to inform you, that the first battery warning is active. When you store this value, you will notice, that after turning the vehicle off and on, it will beep again.
Please set the value of the device back to a normal warning value (like 10600), when you finished testing this tutorial.
This is the last tutorial about the basics of ACI remote in C. Now you are able to write your own program and realize your ideas with the ACI. If you like, you can send us your results with pictures, description and/or code, so we can present your work in this wiki. For that, send us a mail to email@example.com.