WindowsIoT.TouchSample/Util/BrightnessControl.cs
/// <summary>
/// Retrieves current lux value from MAX44009. Performs brightness correction (in auto mode)
/// Also increases timeout counter
/// </summary>
Retrieves current lux value from MAX44009. Performs brightness correction (in auto mode)
Also increases timeout counter
Retrieves current lux value from MAX44009 . Performs brightness correction ( in auto mode ) Also increases timeout counter
public void ReadLux()
        {
            if (!HWStatus)
                return;
            if (_timeout++ > 30)
            {
                _currentLvl = 0;
                SetDutyCycle();
                return;
            }
            try
            {
                max44009.WriteRead(new byte[] { 0x03 }, result);
                byte msb = result[0];
                max44009.WriteRead(new byte[] { 0x04 }, result);
                Lux = (((byte)(msb << 4) | result[0]) << (msb >> 4)) * .045f;
                if (Mode == ControlMode.Auto)
                {
                    _currentLvl = MinLevel + (Lux > 1 ?
                        (float)(Math.Log(Lux) * (1 - MinLevel) / Math.Log(MaxLux)) : 0);
                    SetDutyCycle();
                }
            }
            catch (Exception exc)
            {
                Debug.WriteLine(exc.Message);
            }
        }
public void ReadLux ( ) { if ( ! HWStatus ) return ; if ( _timeout ++ > 30 ) { _currentLvl = 0 ; SetDutyCycle ( ) ; return ; } try { max44009 . WriteRead ( new byte [ ] { 0x03 } , result ) ; byte msb = result [ 0 ] ; max44009 . WriteRead ( new byte [ ] { 0x04 } , result ) ; Lux = ( ( ( byte ) ( msb << 4 ) | result [ 0 ] ) << ( msb >> 4 ) ) * .045f ; if ( Mode == ControlMode . Auto ) { _currentLvl = MinLevel + ( Lux > 1 ? ( float ) ( Math . Log ( Lux ) * ( 1 - MinLevel ) / Math . Log ( MaxLux ) ) : 0 ) ; SetDutyCycle ( ) ; } } catch ( Exception exc ) { Debug . WriteLine ( exc . Message ) ; } }
Retrieves current lux value from MAX44009.
Retrieves current lux value from MAX44009 .