An emitter (12) of electromagnetic radiation is configured for modes of operation providing fields of illumination of different widths, and a photodetector (11) is configured for time-of-flight and proximity measurements by detecting electromagnetic radiation that is emitted by the emitter and reflected to the photodetector. The emitter is operated by a driver (13), which is configured for an alternation between the modes of operation. A time-of-flight measurement is performed when the field of illumination is narrow, and a proximity or ambient light measurement is performed when the field of illumination is wide.
展开▼