The LCD's backlight: LEDs that PWM1 channel 2 dims, through the kernel's
pwm-backlight driver. Brightness follows lightness: 50 looks half as
bright as 100.
NanoKVMGo.Backlight.set_brightness(40)
NanoKVMGo.Backlight.off()
NanoKVMGo.Backlight.on()The PWM runs at 25 kHz, or at a frequency of your own; brightness and power stay as they are:
NanoKVMGo.Backlight.set_frequency(100_000)
NanoKVMGo.Backlight.info()
#=> {:ok, %{on: true, brightness: 40, period: 10_000, frequency: 100_000.0,
#=> default_period: 40_000}}
NanoKVMGo.Backlight.set_frequency(:default)The frequency goes to the driver's pwm_period_ns attribute, which this
system's kernel adds. The timer counts 24 MHz, so a period is a whole
number of 41.7 ns steps, and fewer steps make coarser brightness. Below
about 100 Hz the light flickers. If the LEDs are switched by a small
bipolar transistor, as in the panel's reference design, each pulse lasts
about 0.3 µs longer than asked, which brightens low levels noticeably
from about 100 kHz.
The functions read and write the driver's attributes, with no process.
Options
:backlight- the backlight's sysfs directory,/sys/class/backlight/backlightby default
Summary
Functions
The brightness in percent, see set_brightness/2.
Whether the light is on, its brightness, and the PWM's period in ns and
frequency in Hz, now and by default; nil for what the kernel does not
tell.
Turns the light off, keeping its brightness for on/1.
Turns the light on, at the brightness it had.
Sets the brightness in percent: 0 is dark, 100 the brightest, and each step looks as much brighter as the one before.
Runs the PWM at a frequency in Hz, up to 2 GHz, rounded to a period of
whole nanoseconds, or at the device tree's with :default. The kernel
refuses a period the timer cannot make with {:error, :einval}.
Types
@type info() :: %{ on: boolean(), brightness: 0..100, period: pos_integer() | nil, frequency: float() | nil, default_period: pos_integer() | nil }
@type option() :: {:backlight, Path.t()}
Functions
The brightness in percent, see set_brightness/2.
Whether the light is on, its brightness, and the PWM's period in ns and
frequency in Hz, now and by default; nil for what the kernel does not
tell.
@spec off([option()]) :: :ok | {:error, File.posix()}
Turns the light off, keeping its brightness for on/1.
@spec on([option()]) :: :ok | {:error, File.posix()}
Turns the light on, at the brightness it had.
Sets the brightness in percent: 0 is dark, 100 the brightest, and each step looks as much brighter as the one before.
Runs the PWM at a frequency in Hz, up to 2 GHz, rounded to a period of
whole nanoseconds, or at the device tree's with :default. The kernel
refuses a period the timer cannot make with {:error, :einval}.