Skip to content

Commit

Permalink
Fix things
Browse files Browse the repository at this point in the history
  • Loading branch information
mcm001 committed Oct 25, 2024
1 parent 30abd6a commit 64d4107
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,12 @@ public void setWhiteBalanceTemp(double temp) {}

@Override
public double getMaxWhiteBalanceTemp() {
return 1;
return 2;
}

@Override
public double getMinWhiteBalanceTemp() {
return 2;
return 1;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -273,11 +273,11 @@ public void setWhiteBalanceTemp(double temp) {

@Override
public double getMaxWhiteBalanceTemp() {
return 1;
return 2;
}

@Override
public double getMinWhiteBalanceTemp() {
return 2;
return 1;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,11 @@ public GenericUSBCameraSettables(CameraConfiguration configuration, UsbCamera ca
}

protected void setUpWhiteBalanceProperties() {
wbTempProp = findProperty("white_balance_temperature", "WhiteBalance").get();
this.minWhiteBalanceTemp = wbTempProp.getMin();
this.maxWhiteBalanceTemp = wbTempProp.getMax();
wbTempProp = findProperty("white_balance_temperature", "WhiteBalance").orElse(null);
if (wbTempProp != null) {
this.minWhiteBalanceTemp = wbTempProp.getMin();
this.maxWhiteBalanceTemp = wbTempProp.getMax();
}
}

protected void setUpExposureProperties() {
Expand Down Expand Up @@ -113,10 +115,14 @@ public void setAllCamDefaults() {

@Override
public void setWhiteBalanceTemp(double tempNumber) {
if (wbTempProp == null) {
// bail
return;
}

try {
int temp = (int) Math.round(tempNumber);

softSet("white_balance_auto_preset", 2);
softSet("white_balance_automatic", 0);

int propVal = (int) MathUtil.clamp(temp, minWhiteBalanceTemp, maxWhiteBalanceTemp);
Expand Down Expand Up @@ -145,13 +151,13 @@ public void setAutoWhiteBalance(boolean autoWB) {

if (autoWB) {
// Seems to be a rpi-specific property?
softSet("white_balance_auto_preset", 1); // Auto white-balance enabled
softSet("white_balance_automatic", 1);
} else {
softSet("white_balance_auto_preset", 2); // Auto white-balance disabled
softSet("white_balance_automatic", 0);

wbTempProp.set(this.lastWhiteBalanceTemp);
if (wbTempProp != null) {
wbTempProp.set(this.lastWhiteBalanceTemp);
}
}
}

Expand Down Expand Up @@ -353,11 +359,11 @@ protected Optional<VideoProperty> findProperty(String... options) {

@Override
public double getMaxWhiteBalanceTemp() {
return wbTempProp.getMax();
return maxWhiteBalanceTemp;
}

@Override
public double getMinWhiteBalanceTemp() {
return wbTempProp.getMin();
return minWhiteBalanceTemp;
}
}

0 comments on commit 64d4107

Please sign in to comment.