Skip to content

Commit

Permalink
Show estimated photo luminance on the main VIEW screen during timelapse
Browse files Browse the repository at this point in the history
  • Loading branch information
naixx committed Jun 10, 2024
1 parent 2015234 commit 9d59d3e
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 44 deletions.
30 changes: 15 additions & 15 deletions hardware/oled.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ function textInitPos(setMode) {
for(var i = 0; i < TEXT_MODES.length; i++) {
mode = textGetMode(TEXT_MODES[i]);
var list = TEXT_LIST[mode];
if(TEXT_MODES[i] == 'lcase') list = list.toLowerCase();
if(TEXT_MODES[i] == 'lcase') list = list.toLowerCase();
if(list.indexOf(textValue.charAt(oled.selected)) !== -1) {
textMode = TEXT_MODES[i];
console.log("set text mode to", textMode);
Expand All @@ -183,15 +183,15 @@ function textUpdateCurrent() {

oled.textMoveForward = function() {
if(oled.mode == 'text' || oled.mode == 'number') {
if(oled.selected < TEXT_MAX_CHARS) oled.selected++;
if(oled.selected < TEXT_MAX_CHARS) oled.selected++;
if(textMode == 'number') {
var textLength = textValue.length;
textValue = textValue.replace(/ /g, '');
oled.selected -= textLength - textValue.length;
}
textInitPos(true);
} else if(oled.mode == 'time' || oled.mode == "date") {
if(oled.selected < 2) oled.selected++; else oled.selected = 0;
if(oled.selected < 2) oled.selected++; else oled.selected = 0;
}
oled.writeMenu();
oled.update();
Expand All @@ -213,7 +213,7 @@ oled.textMoveBackward = function() {
function textGetMode(currentMode) {
if(!currentMode) currentMode = textMode;
var mode;
if(currentMode == 'ucase' || currentMode == 'lcase') mode = 'alpha'; else mode = currentMode == 'number' ? 'num' : currentMode;
if(currentMode == 'ucase' || currentMode == 'lcase') mode = 'alpha'; else mode = currentMode == 'number' ? 'num' : currentMode;
return mode;
}

Expand All @@ -236,7 +236,7 @@ function getTextList() {
return TEXT_LIST['num'].concat(['.']);
} else {
return TEXT_LIST['num'];
}
}
} else {
return TEXT_LIST[textGetMode()];
}
Expand Down Expand Up @@ -274,7 +274,7 @@ function drawTimeLapseStatus(status) {
fb.text(upperTextStart, 37, status.apertureText || "---");
fb.text(upperTextStart, 50, status.shutterText || "---");
fb.text(upperTextStart, 63, status.evText || "---");
fb.text(upperTextStart, 76, status.rampModeText);
fb.text(upperTextStart, 76, status.lastPhotoLum || "---");

var m = Math.round(status.durationSeconds / 60);
var hours = Math.floor(m / 60);
Expand All @@ -284,7 +284,7 @@ function drawTimeLapseStatus(status) {

fb.text(0, 100, "Interval: " + (Math.round(status.intervalSeconds * 10) / 10).toString() + "s (" + status.intervalModeText + ")");
fb.text(0, 113, "Frames: " + (status.frames || 0).toString() + "/" + status.remaining.toString());
fb.text(0, 126, "Duration: " + hours.toString() + "h" + minutes.toString() + "m");
fb.text(0, 126, "Dur: " + hours.toString() + "h" + minutes.toString() + "m " + status.rampModeText);

// ramp chart window
//color("background");
Expand All @@ -305,7 +305,7 @@ function drawTimeLapseStatus(status) {
fb.line(x, histY + 1 + histH - h, x, histY + 1 + histH, 1);
}
} else {
fb.rect(histX, histY, histW, histH, false);
fb.rect(histX, histY, histW, histH, false);
}

// interval/exposure status line
Expand All @@ -324,9 +324,9 @@ function drawTimeLapseStatus(status) {
var bufferLineEnd = shutterLineEnd + Math.ceil(status.bufferSeconds * secondsRatio);

color("background");
fb.line(4, 84.5, lw, 84.5, 1);
fb.line(4, 84.5, lw, 84.5, 1);
color("alert");
fb.line(shutterLineStart, 84.5, shutterLineEnd, 84.5, 1);
fb.line(shutterLineStart, 84.5, shutterLineEnd, 84.5, 1);
color("secondary");
fb.line(bufferLineStart, 84.5, bufferLineEnd, 84.5, 1);

Expand All @@ -349,7 +349,7 @@ oled.updateTimelapseStatus = function(status) {
if(status) {
oled.timelapseStatus = status;
if(status.running) {
if(oled.mode == 'timelapse') statusIntervalHandle = setInterval(function(){drawTimeLapseStatus(status);}, 150);
if(oled.mode == 'timelapse') statusIntervalHandle = setInterval(function(){drawTimeLapseStatus(status);}, 150);
} else {
statusDetails = {};
}
Expand Down Expand Up @@ -545,7 +545,7 @@ oled.writeMenu = function() {
color("primary");
} else {
color("secondary");
}
}
fb.text(160 - 48 + i * xAdvance, 125, modes[i]);
}

Expand Down Expand Up @@ -767,7 +767,7 @@ oled.writeMenu = function() {
var parts = list[i].split('~');

var textSize = fb.text(MENU_XOFFSET, MENU_YOFFSET + i * MENU_LINE_HEIGHT, parts[0]);

if(parts[1]) { // menu item value
color("secondary");
fb.text(MENU_XOFFSET + textSize.width, MENU_YOFFSET + i * MENU_LINE_HEIGHT, ' ' + parts[1]);
Expand Down Expand Up @@ -1060,7 +1060,7 @@ oled.exposure = function(jpegFile, textArray, highlightTextIndex) {
var sectionSize = 160 / textArray.length;
for(var i = 0; i < textArray.length; i++) {
var textSize = fb.textSize(textArray[i]);
var x = sectionSize * i + sectionSize / 2 - textSize.width / 2;
var x = sectionSize * i + sectionSize / 2 - textSize.width / 2;
//console.log("OLED: writing", textArray[i], "at x =", x, "textSize =", textSize.width);
fb.text(x, 126, textArray[i]);
if(highlightTextIndex === i) {
Expand Down Expand Up @@ -1169,4 +1169,4 @@ oled.videoSkipFrames = function(frames) {
skipFrames = frames;
}
}
module.exports = oled;
module.exports = oled;
60 changes: 31 additions & 29 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -889,7 +889,7 @@ if (VIEW_HARDWARE) {
var intervalPlan = function(planIndex) {
if(!core.currentProgram.exposurePlans[planIndex]) core.currentProgram.exposurePlans[planIndex] = {};
if(!core.currentProgram.exposurePlans[planIndex].interval) core.currentProgram.exposurePlans[planIndex].interval = 6;

var res = {
name: "interval",
type: "options",
Expand Down Expand Up @@ -1356,7 +1356,7 @@ if (VIEW_HARDWARE) {
action: ui.set(core.currentProgram.exposurePlans[planIndex], 'hdrCount', 15)
}]
}
}
}

var hdrCountOptions = {
name: "HDR Exposures",
Expand Down Expand Up @@ -1445,7 +1445,7 @@ if (VIEW_HARDWARE) {
action: ui.set(core.currentProgram.exposurePlans[planIndex], 'hdrStops', 2)
}]
}
}
}

var hdrStopsOptions = {
name: "HDR Bracket Step",
Expand Down Expand Up @@ -1690,7 +1690,7 @@ if (VIEW_HARDWARE) {
core.getCurrentTimelapseFrames(null, function(err, framesPaths) {
if(framesPaths) {
oled.video(null, framesPaths, 30, cb);
}
}
});
}
}
Expand All @@ -1711,7 +1711,7 @@ if (VIEW_HARDWARE) {
// oled.video(null, framesPaths, 30, cb);
// }
// });
// }
// }
// });
// }
// },
Expand All @@ -1735,7 +1735,7 @@ if (VIEW_HARDWARE) {
oled.video(null, framesPaths, 30, function(){
ui.reload();
});
}
}
});
},
button3: function(){
Expand Down Expand Up @@ -1871,7 +1871,7 @@ if (VIEW_HARDWARE) {

var getMotor = function(motorName, callback) {
db.get('motion-'+motorName, callback);
}
}

var exposurePlansReview = function() {
var info = "";
Expand All @@ -1881,11 +1881,11 @@ if (VIEW_HARDWARE) {
var plan = core.currentProgram.exposurePlans[i];
info += plan.name + '\t';
if(i < core.currentProgram.exposurePlans.length - 1 && core.currentProgram.exposurePlans[i + 1].start < now) {
info += pad + "(skipping)\n";
info += pad + "(skipping)\n";
continue;
}
if(i > 0) info += pad + moment(plan.start).fromNow() + '\t';
info += pad;
info += pad;
if(plan.mode == 'preset') {
info += lists.getNameFromEv(lists.shutter, plan.shutter) + ', ';
info += 'f/' + lists.getNameFromEv(lists.aperture, plan.aperture) + ', ';
Expand Down Expand Up @@ -1926,7 +1926,7 @@ if (VIEW_HARDWARE) {
var motorOrientationKnown = function() {
if(!core.motionStatus.motors) return false;

var motors = [];
var motors = [];
for(var i = 0; i < core.motionStatus.motors.length; i++) {
if(core.motionStatus.motors[i].connected) motors.push(core.motionStatus.motors[i]);
}
Expand Down Expand Up @@ -2368,7 +2368,7 @@ if (VIEW_HARDWARE) {
});
checkDone();
});

})(clips[i]);
} else {
checkDone();
Expand Down Expand Up @@ -2765,7 +2765,7 @@ if (VIEW_HARDWARE) {
}
});
}
},
},
condition: function() {
return core.sdPresent;
}
Expand Down Expand Up @@ -2888,7 +2888,7 @@ if (VIEW_HARDWARE) {
// }
//});
}
}
}

var wifiScanWait = function() {
if(wifi.list.length > 0) {
Expand Down Expand Up @@ -2918,7 +2918,7 @@ if (VIEW_HARDWARE) {
type: "menu"
}
m.items = wifi.list.map(function(item){return {
name:item.ssid + ((wifi.connected && wifi.connected.address == item.address) ? "~connected" : ""),
name:item.ssid + ((wifi.connected && wifi.connected.address == item.address) ? "~connected" : ""),
help: help.wifiConnect,
action: {
type: 'function',
Expand Down Expand Up @@ -2974,7 +2974,7 @@ if (VIEW_HARDWARE) {
details += "Encryption: WPA2\t";
} else {
details += "Encryption: NONE\t";
}
}
details += "BSSID: " + w.address + "\t";
details += "Channel: " + w.channel + "\t";
ui.alert('Wifi details', details);
Expand Down Expand Up @@ -4357,8 +4357,8 @@ if (VIEW_HARDWARE) {
info += "Moon sets at " + moonset.format("h:mm:ss A") + "\t (" + moonset.fromNow() + ")\t";
var phase = "unknown";
var phaseNumber = (sunmoon.mooninfo.phase * 180 / Math.PI) / 180 + 0.5
if(phaseNumber == 0 || phaseNumber == 1) phase = "New Moon";
else if(phaseNumber < 0.25) phase = "Waxing Crescent";
if(phaseNumber == 0 || phaseNumber == 1) phase = "New Moon";
else if(phaseNumber < 0.25) phase = "Waxing Crescent";
else if(phaseNumber == 0.25) phase = "First Quarter";
else if(phaseNumber > 0.25 && phaseNumber < 0.5) phase = "Waxing Gibbous";
else if(phaseNumber == 0.5) phase = "Full Moon";
Expand Down Expand Up @@ -4414,10 +4414,10 @@ if (VIEW_HARDWARE) {
info += "This is a partial eclipse with " + Math.round(data.coverage * 100) + "% coverage observable from the current location " + currentLocation + ".";
}
} else {
info += "No upcoming eclipses were found for the current location " + currentLocation + ".";
info += "No upcoming eclipses were found for the current location " + currentLocation + ".";
}
} else {
info += "No upcoming eclipses were found for the current location " + currentLocation + ".";
info += "No upcoming eclipses were found for the current location " + currentLocation + ".";
}
} else {
info = "GPS position info unavailable\t";
Expand Down Expand Up @@ -4757,7 +4757,7 @@ if (VIEW_HARDWARE) {
} else {
cb();
}
});
});
} else {
ui.back();
//cb();
Expand All @@ -4780,7 +4780,7 @@ if (VIEW_HARDWARE) {
} else {
cb();
}
});
});
} else {
ui.back();
//cb();
Expand Down Expand Up @@ -4875,7 +4875,7 @@ if (VIEW_HARDWARE) {
});

app.on('logs-uploaded', function(count) {
ui.alert('Success', help.logFilesUploaded);
ui.alert('Success', help.logFilesUploaded);
})

core.on('media.insert', function(type) {
Expand Down Expand Up @@ -4986,8 +4986,8 @@ if (VIEW_HARDWARE) {
} else {
gestureVideoPlaying = false;
gestureModeTimer();
}
})
}
})
}
}
});
Expand Down Expand Up @@ -5286,7 +5286,7 @@ app.on('message', function(msg) {
});
break;

case 'motion':
case 'motion':
if (msg.key == "move" && msg.motor && msg.driver) {
console.log("moving motor " + msg.motor);
(function(driver, motor, steps, reply) {
Expand Down Expand Up @@ -5426,7 +5426,7 @@ app.on('message', function(msg) {
});
})(liveviewOn);
break;

case 'capture-test':
core.captureTest(function(err){
if(err) {
Expand Down Expand Up @@ -5553,7 +5553,7 @@ app.on('message', function(msg) {
};
sendFragment(msg.start);
}
}
}
});
break;

Expand Down Expand Up @@ -5967,7 +5967,7 @@ ui.defaultStatus(defaultStatus);
ui.status(defaultStatus);
console.log("Setting default status to '" + defaultStatus + "'")

core.on('camera.exiting', function() {
core.on('camera.exiting', function() {
if(btBlockedForSony) {
wifi.unblockBt();
wifi.noReset = false;
Expand Down Expand Up @@ -6041,13 +6041,15 @@ core.on('intervalometer.status', function(msg) {
}

//img116x70, isoText, apertureText, shutterText, intervalSeconds, intervalModeChar, hist60, ramp30, frames, remaining, durationSeconds, bufferSeconds, shutterSeconds

var evText = (Math.round(lists.getEvFromSettings(msg.cameraSettings) * 10) / 10).toString();
var lastPhotoLum = (Math.round(msg.lastPhotoLum * 10) / 10).toString();
var statusScreen = {
isoText: msg.cameraSettings ? ((typeof msg.cameraSettings.iso == 'object') ? msg.cameraSettings.iso.name : msg.cameraSettings.iso) : "--",
shutterText: msg.cameraSettings ? ((typeof msg.cameraSettings.shutter == 'object') ? msg.cameraSettings.shutter.name : msg.cameraSettings.shutter) : "--",
apertureText: msg.cameraSettings ? (((msg.cameraSettings.aperture && msg.cameraSettings.aperture.ev != null) || (msg.cameraSettings.details && msg.cameraSettings.details.aperture && msg.cameraSettings.details.aperture.ev != null)) ? ("f/" + (msg.cameraSettings.details ? msg.cameraSettings.details.aperture.name : msg.cameraSettings.aperture.name)) : ("f/" + lists.getNameFromEv(lists.aperture, core.currentProgram.manualAperture) + ' (m)')) : "--",
evText: evText + " EV",
lastPhotoLum: lastPhotoLum + " L",
intervalSeconds: msg.intervalMs / 1000,
bufferSeconds: msg.autoSettings ? msg.autoSettings.paddingTimeMs / 1000 : 5,
rampModeText: core.currentProgram.rampMode,
Expand Down

0 comments on commit 9d59d3e

Please sign in to comment.