From a50e5c120b762014ea1c64e0102e0cba35f67eee Mon Sep 17 00:00:00 2001 From: thegroove Date: Wed, 27 Dec 2023 17:52:46 +0100 Subject: [PATCH 1/2] Create auto-night-mode-without-light-sensor.md --- en/auto-night-mode-without-light-sensor.md | 55 ++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 en/auto-night-mode-without-light-sensor.md diff --git a/en/auto-night-mode-without-light-sensor.md b/en/auto-night-mode-without-light-sensor.md new file mode 100644 index 0000000..5631f8e --- /dev/null +++ b/en/auto-night-mode-without-light-sensor.md @@ -0,0 +1,55 @@ +# OpenIPC Wiki +[Table of Content](../README.md) + +Auto nightmode on devices without a light sensor +============================== + +Not all devices have an onboard light sensor to determine whether night mode should be activated or not. +For these devices, we can use the image sensor's analog gain value to switch. In low-light conditions, this value will be high, indicating the image sensor is applying gain to boost brightness. In well-lit conditions, this value will be low. + +#### Step 1: determine if IR cut filter is set up correctly +This article assumes you have found and entered the correct GPIO pins for your IR cut filter and you are able to toggle the filter using the `IR-cut filter` button in the preview. During daylight conditions, in the preview, the image should not be pink. +If it is pink, most likely your pins are in the wrong order and they need to be swapped in `Majestic > Night Mode`. + +#### Step 2: install night mode scripts +We need 2 scripts: the actual night mode script and the startup script that enables the night mode script at boot. + +[autonight.sh](https://raw.githubusercontent.com/OpenIPC/device-mjsxj02hl/master/flash/autoconfig/usr/sbin/autonight.sh) + +Copy `autonight.sh` to `/usr/sbin` + +[S96autonight](https://raw.githubusercontent.com/OpenIPC/device-mjsxj02hl/master/flash/autoconfig/etc/init.d/S96autonight) + +Copy `S96autonight` to `/etc/init.d/` and make it executable with `chmod +x /etc/init.d/S96autonight` + +#### Step 3: tweak the sensor analog gain value +In `autonight.sh` you will find 3 settings: +``` +again_high_target=14000 +again_low_target=2000 +pollingInterval=5 +``` + +`again_high_target` is the gain value at which night mode will be enabled. Similarly, `again_low_target` is the value at which night mode is turned off. You can change these numbers to optimize for your particular setup. +`pollingInterval` indicates how often the script checks the sensor analog gain value. Lower values will result in quicker response, but may result in more "nervous" switching behavior in response to brief light flashes, etc. + +**Note:** to restart the `autonight.sh` script, required e.g. if you have changed a setting, use `/etc/init.d/S96autonight restart`. To stop the script, e.g. if you want to observe the analog gain values without switching the IR filter, +use `/etc/init.d/S96autonight stop`. +After stopping the script, you can run `/usr/sbin/autonight.sh` manually in a terminal to get log output. + +#### Extra: viewing sensor analog gain value and current night mode status +Metrics are displayed at the `/metrics` endpoint in the web interface. + +_The current analog gain value is displayed in `isp_again`:_ +``` +# HELP isp_again Analog Gain +# TYPE isp_again gauge +isp_again 2880 +``` + +_The current night mode setting displayed in `night_enabled`:_ +``` +# HELP night_enabled Is night mode enabled +# TYPE night_enabled gauge +night_enabled 0 +``` From 14a8112df26d0e4ad847c6e94e28f2964d1c53b1 Mon Sep 17 00:00:00 2001 From: thegroove Date: Wed, 27 Dec 2023 20:36:26 +0100 Subject: [PATCH 2/2] Update README.md Add frontpage link --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 1bf37a3..564768a 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,7 @@ OpenIPC Wiki - [YouTube streaming](en/youtube-streaming.md) - [WiFi XM530](en/wifi-xm530.md) - [HomeKit integration](en/homekit-integration.md) +- [Automatic night mode without light sensor](en/auto-night-mode-without-light-sensor.md) ### FPV