split actionBrightness etc into two different functions for get/set. This allows negative values to be set

This commit is contained in:
Isaac Connor 2021-10-05 19:48:53 -04:00
parent e394248baf
commit 7f09cddcd7
2 changed files with 144 additions and 114 deletions

View File

@ -1304,8 +1304,12 @@ void Monitor::actionResume() {
}
int Monitor::actionBrightness(int p_brightness) {
if (purpose != CAPTURE) {
if (p_brightness >= 0) {
if (purpose == CAPTURE) {
// We are the capture process, so take the action
return camera->Brightness(p_brightness);
}
// If we are an outside actor, sending the command
shared_data->brightness = p_brightness;
shared_data->action |= SET_SETTINGS;
int wait_loops = 10;
@ -1317,7 +1321,16 @@ int Monitor::actionBrightness(int p_brightness) {
return -1;
}
}
} else {
return shared_data->brightness;
}
int Monitor::actionBrightness() {
if (purpose == CAPTURE) {
// We are the capture process, so take the action
return camera->Brightness();
}
// If we are an outside actor, sending the command
shared_data->action |= GET_SETTINGS;
int wait_loops = 10;
while (shared_data->action & GET_SETTINGS) {
@ -1328,15 +1341,14 @@ int Monitor::actionBrightness(int p_brightness) {
return -1;
}
}
}
return shared_data->brightness;
}
return camera->Brightness(p_brightness);
} // end int Monitor::actionBrightness(int p_brightness)
} // end int Monitor::actionBrightness()
int Monitor::actionContrast(int p_contrast) {
if (purpose != CAPTURE) {
if (p_contrast >= 0) {
if (purpose == CAPTURE) {
return camera->Contrast(p_contrast);
}
shared_data->contrast = p_contrast;
shared_data->action |= SET_SETTINGS;
int wait_loops = 10;
@ -1348,7 +1360,15 @@ int Monitor::actionContrast(int p_contrast) {
return -1;
}
}
} else {
return shared_data->contrast;
}
int Monitor::actionContrast() {
if (purpose == CAPTURE) {
// We are the capture process, so take the action
return camera->Contrast();
}
shared_data->action |= GET_SETTINGS;
int wait_loops = 10;
while (shared_data->action & GET_SETTINGS) {
@ -1359,15 +1379,14 @@ int Monitor::actionContrast(int p_contrast) {
return -1;
}
}
}
return shared_data->contrast;
}
return camera->Contrast(p_contrast);
} // end int Monitor::actionContrast(int p_contrast)
} // end int Monitor::actionContrast()
int Monitor::actionHue(int p_hue) {
if (purpose != CAPTURE) {
if (p_hue >= 0) {
if (purpose == CAPTURE) {
return camera->Hue(p_hue);
}
shared_data->hue = p_hue;
shared_data->action |= SET_SETTINGS;
int wait_loops = 10;
@ -1379,7 +1398,13 @@ int Monitor::actionHue(int p_hue) {
return -1;
}
}
} else {
return shared_data->hue;
}
int Monitor::actionHue() {
if (purpose == CAPTURE) {
return camera->Hue();
}
shared_data->action |= GET_SETTINGS;
int wait_loops = 10;
while (shared_data->action & GET_SETTINGS) {
@ -1390,15 +1415,13 @@ int Monitor::actionHue(int p_hue) {
return -1;
}
}
}
return shared_data->hue;
}
return camera->Hue(p_hue);
} // end int Monitor::actionHue(int p_hue)
int Monitor::actionColour(int p_colour) {
if (purpose != CAPTURE) {
if (p_colour >= 0) {
if (purpose == CAPTURE) {
return camera->Colour(p_colour);
}
shared_data->colour = p_colour;
shared_data->action |= SET_SETTINGS;
int wait_loops = 10;
@ -1410,7 +1433,13 @@ int Monitor::actionColour(int p_colour) {
return -1;
}
}
} else {
return shared_data->colour;
}
int Monitor::actionColour() {
if (purpose == CAPTURE) {
return camera->Colour();
}
shared_data->action |= GET_SETTINGS;
int wait_loops = 10;
while (shared_data->action & GET_SETTINGS) {
@ -1421,10 +1450,7 @@ int Monitor::actionColour(int p_colour) {
return -1;
}
}
}
return shared_data->colour;
}
return camera->Colour(p_colour);
} // end int Monitor::actionColour(int p_colour)
void Monitor::DumpZoneImage(const char *zone_string) {

View File

@ -567,10 +567,14 @@ public:
void actionSuspend();
void actionResume();
int actionBrightness( int p_brightness=-1 );
int actionHue( int p_hue=-1 );
int actionColour( int p_colour=-1 );
int actionContrast( int p_contrast=-1 );
int actionBrightness(int p_brightness);
int actionBrightness();
int actionHue(int p_hue);
int actionHue();
int actionColour(int p_colour);
int actionColour();
int actionContrast(int p_contrast);
int actionContrast();
int PrimeCapture();
int PreCapture() const;