Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Path: blob/master/Tools/cameras_gimbals/xacti-config/main.cpp
Views: 1799
#include <stdio.h>1#include <iostream>2#include <cstring>3#include "CX-GBXXXCtrl.h"45const char* this_app_str = "xacti-config";67// display help8void display_help()9{10printf("Usage: sudo %s option [value]\n", this_app_str);11printf(" --dronecan\tenable (value=1) or disable (value=0) dronecan parsing\n");12printf(" --format\tformat SD card\n");13printf(" --help\t\tdisplay usage\n");14printf(" --irpalette\t\tIR pallete (0:white hot, 1:black hot, 2:rainbow, 3:rainHC, 4:ironbow, 5:lava, 6:arctic, 7:glowbow, 8:graded fire, 9:hottest)\n");15printf(" --msc\t\tchange to mass storage class mode (for downloading from SD card)\n");16}1718int main(int argc, char **argv)19{20// display help21if ((argc <= 1) || ((argc >= 2) && (strcmp(argv[1], "--help") == 0))) {22display_help();23return 0;24}2526// open camera27CX_GBXXXCtrl camera_ctrl;28if (!camera_ctrl.Open(NULL)) {29printf("%s: failed to open camera\n", this_app_str);30return 1;31}3233// args_ok set to true when command line processed correctly34bool args_ok = false;35bool ret_ok = true;3637// enable DroneCAN38if ((argc >= 3) && (strcmp(argv[1], "--dronecan") == 0)) {39args_ok = true;40uint8_t enable = (strcmp(argv[2], "1") == 0);41ret_ok = camera_ctrl.SetCameraCtrl(0x07, 0x1e, &enable, sizeof(enable));42const char* enable_or_disable_str = enable ? "enable" : "disable";43if (ret_ok) {44printf("%s: %s DroneCAN\n", this_app_str, enable_or_disable_str);45} else {46printf("%s: failed to %s DroneCAN\n", this_app_str, enable_or_disable_str);47}48}4950// format SD card51if ((argc >= 2) && (strcmp(argv[1], "--format") == 0)) {52args_ok = true;53uint8_t format_sd = 0;54ret_ok = camera_ctrl.SetCameraCtrl(0x07, 0x15, &format_sd, sizeof(format_sd));55if (ret_ok) {56printf("%s: formatted SD card\n", this_app_str);57} else {58printf("%s: failed format SD card\n", this_app_str);59}60}6162// IR palette63if ((argc >= 3) && (strcmp(argv[1], "--irpalette") == 0)) {64args_ok = true;65int palette_int = 0;66sscanf(argv[2], "%d", &palette_int);67uint8_t palette_uint8 = (uint8_t)palette_int;68ret_ok = camera_ctrl.SetCameraCtrl(0x07, 0x19, &palette_uint8, sizeof(palette_uint8));69if (ret_ok) {70printf("%s: IR palette set to %d\n", this_app_str, (int)palette_uint8);71} else {72printf("%s: failed to set IR palette to %d\n", this_app_str, (int)palette_uint8);73}74}7576// change to Mass Storage Mode to allow downloading of images and videos77if ((argc >= 2) && (strcmp(argv[1], "--msc") == 0)) {78args_ok = true;79uint8_t msc_mode = 1;80ret_ok = camera_ctrl.SetCameraCtrl(0x06, 0x07, &msc_mode, sizeof(msc_mode));81if (ret_ok) {82printf("%s: changed to mass storage mode\n", this_app_str);83} else {84printf("%s: failed to change to mass storage mode\n", this_app_str);85}86}8788// close camera89camera_ctrl.Close();9091// display help if args could not be processed92if (!args_ok) {93display_help();94}9596// return 0 if OK, 1 if not OK97return ret_ok ? 0 : 1;98}99100101