Merge pull request #506 from JamesH65/defines_to_enums

Converted all the command ID's to enums, code tidy
This commit is contained in:
James Hughes
2018-12-03 11:27:09 +00:00
committed by GitHub
7 changed files with 266 additions and 258 deletions

View File

@@ -146,36 +146,38 @@ static XREF_T stereo_mode_map[] =
static const int stereo_mode_map_size = sizeof(stereo_mode_map)/sizeof(stereo_mode_map[0]);
#define CommandSharpness 0
#define CommandContrast 1
#define CommandBrightness 2
#define CommandSaturation 3
#define CommandISO 4
#define CommandVideoStab 5
#define CommandEVComp 6
#define CommandExposure 7
#define CommandAWB 8
#define CommandImageFX 9
#define CommandColourFX 10
#define CommandMeterMode 11
#define CommandRotation 12
#define CommandHFlip 13
#define CommandVFlip 14
#define CommandROI 15
#define CommandShutterSpeed 16
#define CommandAwbGains 17
#define CommandDRCLevel 18
#define CommandStatsPass 19
#define CommandAnnotate 20
#define CommandStereoMode 21
#define CommandStereoDecimate 22
#define CommandStereoSwap 23
#define CommandAnnotateExtras 24
#define CommandFlicker 25
#define CommandAnalogGain 26
#define CommandDigitalGain 27
#define CommandSettings 28
enum
{
CommandSharpness,
CommandContrast,
CommandBrightness,
CommandSaturation,
CommandISO,
CommandVideoStab,
CommandEVComp,
CommandExposure,
CommandAWB,
CommandImageFX,
CommandColourFX,
CommandMeterMode,
CommandRotation,
CommandHFlip,
CommandVFlip,
CommandROI,
CommandShutterSpeed,
CommandAwbGains,
CommandDRCLevel,
CommandStatsPass,
CommandAnnotate,
CommandStereoMode,
CommandStereoDecimate,
CommandStereoSwap,
CommandAnnotateExtras,
CommandFlicker,
CommandAnalogGain,
CommandDigitalGain,
CommandSettings
};
static COMMAND_LIST cmdline_commands[] =
{
@@ -1075,28 +1077,27 @@ int raspicamcontrol_set_all_parameters(MMAL_COMPONENT_T *camera, const RASPICAM_
result += raspicamcontrol_set_DRC(camera, params->drc_level);
result += raspicamcontrol_set_stats_pass(camera, params->stats_pass);
result += raspicamcontrol_set_annotate(camera, params->enable_annotate, params->annotate_string,
params->annotate_text_size,
params->annotate_text_colour,
params->annotate_bg_colour,
params->annotate_justify,
params->annotate_x,
params->annotate_y
);
params->annotate_text_size,
params->annotate_text_colour,
params->annotate_bg_colour,
params->annotate_justify,
params->annotate_x,
params->annotate_y);
result += raspicamcontrol_set_gains(camera, params->analog_gain, params->digital_gain);
if (params->settings)
{
MMAL_PARAMETER_CHANGE_EVENT_REQUEST_T change_event_request =
{{MMAL_PARAMETER_CHANGE_EVENT_REQUEST, sizeof(MMAL_PARAMETER_CHANGE_EVENT_REQUEST_T)},
MMAL_PARAMETER_CAMERA_SETTINGS, 1};
MMAL_PARAMETER_CHANGE_EVENT_REQUEST_T change_event_request =
{{MMAL_PARAMETER_CHANGE_EVENT_REQUEST, sizeof(MMAL_PARAMETER_CHANGE_EVENT_REQUEST_T)},
MMAL_PARAMETER_CAMERA_SETTINGS, 1};
MMAL_STATUS_T status = mmal_port_parameter_set(camera->control, &change_event_request.hdr);
if ( status != MMAL_SUCCESS )
{
vcos_log_error("No camera settings events");
}
MMAL_STATUS_T status = mmal_port_parameter_set(camera->control, &change_event_request.hdr);
if ( status != MMAL_SUCCESS )
{
vcos_log_error("No camera settings events");
}
result += status;
result += status;
}
return result;
@@ -1826,13 +1827,12 @@ void default_camera_control_callback(MMAL_PORT_T *port, MMAL_BUFFER_HEADER_T *bu
{
MMAL_PARAMETER_CAMERA_SETTINGS_T *settings = (MMAL_PARAMETER_CAMERA_SETTINGS_T*)param;
vcos_log_error("Exposure now %u, analog gain %u/%u, digital gain %u/%u",
settings->exposure,
settings->analog_gain.num, settings->analog_gain.den,
settings->digital_gain.num, settings->digital_gain.den);
settings->exposure,
settings->analog_gain.num, settings->analog_gain.den,
settings->digital_gain.num, settings->digital_gain.den);
vcos_log_error("AWB R=%u/%u, B=%u/%u",
settings->awb_red_gain.num, settings->awb_red_gain.den,
settings->awb_blue_gain.num, settings->awb_blue_gain.den
);
settings->awb_red_gain.num, settings->awb_red_gain.den,
settings->awb_blue_gain.num, settings->awb_blue_gain.den);
}
break;
}

View File

@@ -44,10 +44,13 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "RaspiPreview.h"
#include "RaspiCLI.h"
#define CommandPreview 1
#define CommandFullScreen 2
#define CommandOpacity 3
#define CommandDisablePreview 4
enum
{
CommandPreview,
CommandFullScreen,
CommandOpacity,
CommandDisablePreview
};
static COMMAND_LIST cmdline_commands[] =
{

View File

@@ -105,13 +105,16 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define MAX_EXIF_PAYLOAD_LENGTH 128
/// Frame advance method
#define FRAME_NEXT_SINGLE 0
#define FRAME_NEXT_TIMELAPSE 1
#define FRAME_NEXT_KEYPRESS 2
#define FRAME_NEXT_FOREVER 3
#define FRAME_NEXT_GPIO 4
#define FRAME_NEXT_SIGNAL 5
#define FRAME_NEXT_IMMEDIATELY 6
enum
{
FRAME_NEXT_SINGLE,
FRAME_NEXT_TIMELAPSE,
FRAME_NEXT_KEYPRESS,
FRAME_NEXT_FOREVER,
FRAME_NEXT_GPIO,
FRAME_NEXT_SIGNAL,
FRAME_NEXT_IMMEDIATELY
};
/// Amount of time before first image taken to allow settling of
/// exposure etc. in milliseconds.
@@ -197,34 +200,37 @@ static GPS_READER_DATA gps_reader_data;
static void display_valid_parameters(char *app_name);
static void store_exif_tag(RASPISTILL_STATE *state, const char *exif_tag);
/// Comamnd ID's and Structure defining our command line options
#define CommandHelp 0
#define CommandWidth 1
#define CommandHeight 2
#define CommandQuality 3
#define CommandRaw 4
#define CommandOutput 5
#define CommandVerbose 6
#define CommandTimeout 7
#define CommandThumbnail 8
#define CommandDemoMode 9
#define CommandEncoding 10
#define CommandExifTag 11
#define CommandTimelapse 12
#define CommandFullResPreview 13
#define CommandLink 14
#define CommandKeypress 15
#define CommandSignal 16
#define CommandGL 17
#define CommandGLCapture 18
#define CommandCamSelect 20
#define CommandBurstMode 21
#define CommandSensorMode 22
#define CommandDateTime 23
#define CommandTimeStamp 24
#define CommandFrameStart 25
#define CommandRestartInterval 26
#define CommandGpsdExif 27
/// Command ID's and Structure defining our command line options
enum
{
CommandHelp,
CommandWidth,
CommandHeight,
CommandQuality,
CommandRaw,
CommandOutput,
CommandVerbose,
CommandTimeout,
CommandThumbnail,
CommandDemoMode,
CommandEncoding,
CommandExifTag,
CommandTimelapse,
CommandFullResPreview,
CommandLink,
CommandKeypress,
CommandSignal,
CommandGL,
CommandGLCapture,
CommandCamSelect,
CommandBurstMode,
CommandSensorMode,
CommandDateTime,
CommandTimeStamp,
CommandFrameStart,
CommandRestartInterval,
CommandGpsdExif
};
static COMMAND_LIST cmdline_commands[] =
{
@@ -420,12 +426,12 @@ static void dump_status(RASPISTILL_STATE *state)
}
fprintf(stderr, "Width %d, Height %d, quality %d, filename %s\n", state->width,
state->height, state->quality, state->filename);
state->height, state->quality, state->filename);
fprintf(stderr, "Time delay %d, Raw %s\n", state->timeout,
state->wantRAW ? "yes" : "no");
state->wantRAW ? "yes" : "no");
fprintf(stderr, "Thumbnail enabled %s, width %d, height %d, quality %d\n",
state->thumbnailConfig.enable ? "Yes":"No", state->thumbnailConfig.width,
state->thumbnailConfig.height, state->thumbnailConfig.quality);
state->thumbnailConfig.enable ? "Yes":"No", state->thumbnailConfig.width,
state->thumbnailConfig.height, state->thumbnailConfig.quality);
fprintf(stderr, "Link to latest frame enabled ");
if (state->linkname)
{
@@ -447,18 +453,18 @@ static void dump_status(RASPISTILL_STATE *state)
if (state->enableExifTags)
{
if (state->numExifTags)
{
fprintf(stderr, "User supplied EXIF tags :\n");
if (state->numExifTags)
{
fprintf(stderr, "User supplied EXIF tags :\n");
for (i=0;i<state->numExifTags;i++)
{
fprintf(stderr, "%s", state->exifTags[i]);
if (i != state->numExifTags-1)
fprintf(stderr, ",");
}
fprintf(stderr, "\n\n");
}
for (i=0;i<state->numExifTags;i++)
{
fprintf(stderr, "%s", state->exifTags[i]);
if (i != state->numExifTags-1)
fprintf(stderr, ",");
}
fprintf(stderr, "\n\n");
}
}
else
fprintf(stderr, "EXIF tags disabled\n");
@@ -1747,19 +1753,19 @@ static int wait_for_next_frame(RASPISTILL_STATE *state, int *frame)
case FRAME_NEXT_KEYPRESS :
{
int ch;
int ch;
if (state->verbose)
if (state->verbose)
fprintf(stderr, "Press Enter to capture, X then ENTER to exit\n");
ch = getchar();
*frame+=1;
if (ch == 'x' || ch == 'X')
return 0;
else
{
return keep_running;
}
ch = getchar();
*frame+=1;
if (ch == 'x' || ch == 'X')
return 0;
else
{
return keep_running;
}
}
case FRAME_NEXT_IMMEDIATELY :
@@ -1967,7 +1973,7 @@ int main(int argc, const char **argv)
}
if (state.timeout == -1)
state.timeout = 5000;
state.timeout = 5000;
// Setup for sensor specific parameters
set_sensor_defaults(&state);
@@ -2130,30 +2136,30 @@ int main(int argc, const char **argv)
while (keep_looping)
{
keep_looping = wait_for_next_frame(&state, &frame);
keep_looping = wait_for_next_frame(&state, &frame);
if (state.datetime)
{
time_t rawtime;
struct tm *timeinfo;
if (state.datetime)
{
time_t rawtime;
struct tm *timeinfo;
time(&rawtime);
timeinfo = localtime(&rawtime);
time(&rawtime);
timeinfo = localtime(&rawtime);
frame = timeinfo->tm_mon+1;
frame *= 100;
frame += timeinfo->tm_mday;
frame *= 100;
frame += timeinfo->tm_hour;
frame *= 100;
frame += timeinfo->tm_min;
frame *= 100;
frame += timeinfo->tm_sec;
}
if (state.timestamp)
{
frame = (int)time(NULL);
}
frame = timeinfo->tm_mon+1;
frame *= 100;
frame += timeinfo->tm_mday;
frame *= 100;
frame += timeinfo->tm_hour;
frame *= 100;
frame += timeinfo->tm_min;
frame *= 100;
frame += timeinfo->tm_sec;
}
if (state.timestamp)
{
frame = (int)time(NULL);
}
// Open the file
if (state.filename)

View File

@@ -94,13 +94,16 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define VIDEO_OUTPUT_BUFFERS_NUM 3
/// Frame advance method
#define FRAME_NEXT_SINGLE 0
#define FRAME_NEXT_TIMELAPSE 1
#define FRAME_NEXT_KEYPRESS 2
#define FRAME_NEXT_FOREVER 3
#define FRAME_NEXT_GPIO 4
#define FRAME_NEXT_SIGNAL 5
#define FRAME_NEXT_IMMEDIATELY 6
enum
{
FRAME_NEXT_SINGLE,
FRAME_NEXT_TIMELAPSE,
FRAME_NEXT_KEYPRESS,
FRAME_NEXT_FOREVER,
FRAME_NEXT_GPIO,
FRAME_NEXT_SIGNAL,
FRAME_NEXT_IMMEDIATELY
};
#define CAMERA_SETTLE_TIME 1000
@@ -148,23 +151,26 @@ typedef struct
static void display_valid_parameters(char *app_name);
/// Comamnd ID's and Structure defining our command line options
#define CommandHelp 0
#define CommandWidth 1
#define CommandHeight 2
#define CommandOutput 3
#define CommandVerbose 4
#define CommandTimeout 5
#define CommandTimelapse 6
#define CommandUseRGB 7
#define CommandCamSelect 8
#define CommandFullResPreview 9
#define CommandLink 10
#define CommandKeypress 11
#define CommandSignal 12
#define CommandBurstMode 14
#define CommandOnlyLuma 15
#define CommandSensorMode 16
#define CommandUseBGR 17
enum
{
CommandHelp,
CommandWidth,
CommandHeight,
CommandOutput,
CommandVerbose,
CommandTimeout,
CommandTimelapse,
CommandUseRGB,
CommandCamSelect,
CommandFullResPreview,
CommandLink,
CommandKeypress,
CommandSignal,
CommandBurstMode,
CommandOnlyLuma,
CommandSensorMode,
CommandUseBGR
};
static COMMAND_LIST cmdline_commands[] =
{
@@ -543,13 +549,6 @@ static void display_valid_parameters(char *app_name)
return;
}
/**
* buffer header callback function for camera control
*
* @param port Pointer to port from which callback originated
* @param buffer mmal buffer header pointer
*/
/**
* buffer header callback function for camera output port
*
@@ -1072,19 +1071,19 @@ static int wait_for_next_frame(RASPISTILLYUV_STATE *state, int *frame)
case FRAME_NEXT_KEYPRESS :
{
int ch;
int ch;
if (state->verbose)
if (state->verbose)
fprintf(stderr, "Press Enter to capture, X then ENTER to exit\n");
ch = getchar();
*frame+=1;
if (ch == 'x' || ch == 'X')
return 0;
else
{
return keep_running;
}
ch = getchar();
*frame+=1;
if (ch == 'x' || ch == 'X')
return 0;
else
{
return keep_running;
}
}
case FRAME_NEXT_IMMEDIATELY :

View File

@@ -93,8 +93,11 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define DEFAULT_WIDTH 640
#define DEFAULT_HEIGHT 480
#define CommandGLScene 1
#define CommandGLWin 2
enum
{
CommandGLScene,
CommandGLWin
};
static COMMAND_LIST cmdline_commands[] =
{

View File

@@ -119,17 +119,14 @@ const int ABORT_INTERVAL = 100; // ms
/// Capture/Pause switch method
/// Simply capture for time specified
#define WAIT_METHOD_NONE 0
/// Cycle between capture and pause for times specified
#define WAIT_METHOD_TIMED 1
/// Switch between capture and pause on keypress
#define WAIT_METHOD_KEYPRESS 2
/// Switch between capture and pause on signal
#define WAIT_METHOD_SIGNAL 3
/// Run/record forever
#define WAIT_METHOD_FOREVER 4
enum
{
WAIT_METHOD_NONE, /// Simply capture for time specified
WAIT_METHOD_TIMED, /// Cycle between capture and pause for times specified
WAIT_METHOD_KEYPRESS, /// Switch between capture and pause on keypress
WAIT_METHOD_SIGNAL, /// Switch between capture and pause on signal
WAIT_METHOD_FOREVER /// Run/record forever
};
int mmal_status_to_int(MMAL_STATUS_T status);
static void signal_handler(int signal_number);
@@ -290,41 +287,43 @@ static int raw_output_fmt_map_size = sizeof(raw_output_fmt_map) / sizeof(raw_out
static void display_valid_parameters(char *app_name);
/// Command ID's and Structure defining our command line options
#define CommandHelp 0
#define CommandWidth 1
#define CommandHeight 2
#define CommandBitrate 3
#define CommandOutput 4
#define CommandVerbose 5
#define CommandTimeout 6
#define CommandDemoMode 7
#define CommandFramerate 8
#define CommandPreviewEnc 9
#define CommandIntraPeriod 10
#define CommandProfile 11
#define CommandTimed 12
#define CommandSignal 13
#define CommandKeypress 14
#define CommandInitialState 15
#define CommandQP 16
#define CommandInlineHeaders 17
#define CommandSegmentFile 18
#define CommandSegmentWrap 19
#define CommandSegmentStart 20
#define CommandSplitWait 21
#define CommandCircular 22
#define CommandIMV 23
#define CommandCamSelect 24
#define CommandSensorMode 26
#define CommandIntraRefreshType 27
#define CommandFlush 28
#define CommandSavePTS 29
#define CommandCodec 30
#define CommandLevel 31
#define CommandRaw 32
#define CommandRawFormat 33
#define CommandNetListen 34
#define CommandSPSTimings 35
enum {
CommandHelp,
CommandWidth,
CommandHeight,
CommandBitrate,
CommandOutput,
CommandVerbose,
CommandTimeout,
CommandDemoMode,
CommandFramerate,
CommandPreviewEnc,
CommandIntraPeriod,
CommandProfile,
CommandTimed,
CommandSignal,
CommandKeypress,
CommandInitialState,
CommandQP,
CommandInlineHeaders,
CommandSegmentFile,
CommandSegmentWrap,
CommandSegmentStart,
CommandSplitWait,
CommandCircular,
CommandIMV,
CommandCamSelect,
CommandSensorMode,
CommandIntraRefreshType,
CommandFlush,
CommandSavePTS,
CommandCodec,
CommandLevel,
CommandRaw,
CommandRawFormat,
CommandNetListen,
CommandSPSTimings
};
static COMMAND_LIST cmdline_commands[] =
{
@@ -1037,7 +1036,6 @@ static void display_valid_parameters(char *app_name)
return;
}
/**
* Open a file based on the settings in state
*
@@ -1264,8 +1262,6 @@ static void update_annotation_data(RASPIVID_STATE *state)
}
}
/**
* buffer header callback function for encoder
*

View File

@@ -103,16 +103,14 @@ const int ABORT_INTERVAL = 100; // ms
/// Capture/Pause switch method
/// Simply capture for time specified
#define WAIT_METHOD_NONE 0
/// Cycle between capture and pause for times specified
#define WAIT_METHOD_TIMED 1
/// Switch between capture and pause on keypress
#define WAIT_METHOD_KEYPRESS 2
/// Switch between capture and pause on signal
#define WAIT_METHOD_SIGNAL 3
/// Run/record forever
#define WAIT_METHOD_FOREVER 4
enum
{
WAIT_METHOD_NONE, /// Simply capture for time specified
WAIT_METHOD_TIMED, /// Cycle between capture and pause for times specified
WAIT_METHOD_KEYPRESS, /// Switch between capture and pause on keypress
WAIT_METHOD_SIGNAL, /// Switch between capture and pause on signal
WAIT_METHOD_FOREVER /// Run/record forever
};
int mmal_status_to_int(MMAL_STATUS_T status);
static void signal_handler(int signal_number);
@@ -189,24 +187,27 @@ static int initial_map_size = sizeof(initial_map) / sizeof(initial_map[0]);
static void display_valid_parameters(char *app_name);
/// Command ID's and Structure defining our command line options
#define CommandHelp 0
#define CommandWidth 1
#define CommandHeight 2
#define CommandOutput 3
#define CommandVerbose 4
#define CommandTimeout 5
#define CommandDemoMode 6
#define CommandFramerate 7
#define CommandTimed 8
#define CommandSignal 9
#define CommandKeypress 10
#define CommandInitialState 11
#define CommandCamSelect 12
#define CommandSensorMode 14
#define CommandOnlyLuma 15
#define CommandUseRGB 16
#define CommandSavePTS 17
#define CommandNetListen 18
enum
{
CommandHelp,
CommandWidth,
CommandHeight,
CommandOutput,
CommandVerbose,
CommandTimeout,
CommandDemoMode,
CommandFramerate,
CommandTimed,
CommandSignal,
CommandKeypress,
CommandInitialState,
CommandCamSelect,
CommandSensorMode,
CommandOnlyLuma,
CommandUseRGB,
CommandSavePTS,
CommandNetListen
};
static COMMAND_LIST cmdline_commands[] =
{