Android code
Below is the code structure for the Android application. The application begins by displaying the opening activity and then transitions to either the internal camera activity or the external camera activity depending on the user's preferences.
- Opening Activity
High Level Functionality: Allows the user to choose between two options:
- Using the smart phone's camera to take video
- Using an external camera to take video
This activity also provides the option to turn on airplane mode to avoid having the videoing disrupted by a phone call or text message.
- Internal Camera Activity
High Level Functionality:
- Smart Phone Camera: When the user clicks start, the smart phone's camera is enabled and begins taking video on a new processing thread. When the user stops the camera, this video is saved away on the phone's hard drive for later viewing.
- Sensor Reading: When the activity is started, the phone begins reading the Android gravity vector through Android's sensor Manager.
- Position Control: When the user clicks start, the phone sets its home orientation to be the current gravity vector. The phone then implements PID position control on the motor servos to continually return itself to its home orientation.
- External Camera Activity
High Level Functionality:
- Sensor Reading: When the activity is started, the phone begins reading the Android gravity vector through Android's sensor Manager.
- Position Control: When the user clicks start, the phone sets its home orientation to be the current gravity vector. The phone then implements position control on the motor servos to continually return them to the home orientation. Note: there is no feedback loop within the phone in this scenario since the phone's measured position is not dependent on the signal it sends to the motor servos.
Arduino Code
Below is the structure for the Arduino application.