This seems to be a nice solution.
https://www.electro-tech-online.com/custompdfs/2009/11/LS7642_LS7642FO.pdf
VOLTAGE CONTROLLED LIGHT DIMMER with SOFT ON/OFF
BCV (Pin 2) Brightness control input. The voltage applied at the BCV
input controls the triac conduction angle and hence the brightness of
the lamp. The brightness varies in direct proportion to the applied voltage.
For manual control of brightness, the BCV voltage can be supplied
from the center tap of a potentiometer connected between VDD
and VSS. In non-manual instrumentation application where a uC is the
controlling agent, the BCV voltage can directly be provided by the uC.
The dynamic range of the BCV voltage is between 25% and 88% of
the applied power supply. For VDD = 5.0V this translates to a range between
1.25V for the minimum brightness and 4.4V for the maximum
brightness. There are 81 discrete brightness steps of 1.4o/39mV increments
in the dynamic range of 1.25V and 4.4V of the BCV voltage.
The corresponding conduction angles are 45o at the dimmest and
159o at the brightest.