public static void Main() { // // Create a TSL2561 object operating in interrupt mode. // TSL2561 tsl2561 = new TSL2561(); // // Set up the sensor. // Debug.Print("TSL2561 Interrupt Application."); Debug.Print("Device ID: " + tsl2561.ID); tsl2561.TurnOff(); tsl2561.SensorGain = TSL2561.Gain.High; tsl2561.Timing = TSL2561.IntegrationTiming.Ms402; tsl2561.TurnOn(); tsl2561.LightLevelChanged += (s, e) => { Debug.Print("Light intensity: " + e.CurrentValue.ToString("f2")); }; // // Put the application to sleep as the interrupt handler will deal // with any changes in sensor data. // Thread.Sleep(Timeout.Infinite); }
public static void Main() { TSL2561 tsl2561 = new TSL2561(); Debug.Print("Polled TSL2561 Application."); Debug.Print("Device ID: " + tsl2561.ID); tsl2561.TurnOff(); tsl2561.SensorGain = TSL2561.Gain.High; tsl2561.Timing = TSL2561.IntegrationTiming.Ms402; tsl2561.TurnOn(); // // Repeatedly read the light intensity. // while (true) { var adcData = tsl2561.SensorReading; Debug.Print("Data0: " + adcData[0] + ", Data1: " + adcData[1]); Debug.Print("Light intensity: " + tsl2561.Luminosity.ToString("f2")); Thread.Sleep(2000); } }
// http://webge.github.io/TSL2561/ public static void Main() { // Création d'un objet TSL2561 // avec l'adresse 0x29 et la fréquence de bus F = 100kHz TSL2561 I2CLightSensor = new TSL2561(); I2CLightSensor.Init(TSL2561.Gain.x1, TSL2561.IntegrationTime._13MS); // Réglage des seuils I2CLightSensor.threshLowhigh = 0x20; I2CLightSensor.threshLowLow = 0x10; I2CLightSensor.threshhighhigh = 0x40; I2CLightSensor.threshhighLow = 0x20; while (true) { // Affichage du contenu des registres Debug.Print("Lecture des registres"); Debug.Print("---------------------"); Debug.Print("00h Control : " + I2CLightSensor.control); Debug.Print("01h Timing : " + I2CLightSensor.timing); Debug.Print("02h ThreshLowLow : " + I2CLightSensor.threshLowLow); Debug.Print("03h ThreshLowhigh : " + I2CLightSensor.threshLowhigh); Debug.Print("04h ThreshhighLow : " + I2CLightSensor.threshhighLow); Debug.Print("05h Threshhighhigh : " + I2CLightSensor.threshhighhigh); Debug.Print("06h Interrupt : " + I2CLightSensor.interrupt); Debug.Print("0Ah Part number / Rev Id : " + I2CLightSensor.id); Debug.Print("--------------------------"); Debug.Print("Valeurs des canaux 0 et 1"); Debug.Print("--------------------------"); Debug.Print("Canal 0: " + I2CLightSensor.channel0); Debug.Print("Canal 1: " + I2CLightSensor.channel1); if (I2CLightSensor.calculateLux() != 0) { Debug.Print("Luminosité: " + I2CLightSensor.calculateLux() + " lux"); } else { Debug.Print("Sensor overload"); } Thread.Sleep(3000); } }