/// <summary> /// This is where all sensor and motor properties are initialized /// </summary> /// <param name="bluetoothPortName"></param> public Scorpio(string bluetoothPortName) { Brick = new AForgeNxtBrickFacade(); BluetoothPortName = bluetoothPortName; // Sensors: // 1 TouchSensor = new TouchSensor(Brick, NxtBrick.Sensor.First); // 2 LightIntensitySensor = new LightSensor(Brick, NxtBrick.Sensor.Second); // 3 (shared) SoundLevelSensor = new SoundSensor(Brick, NxtBrick.Sensor.Third); SoundRatioSensor = new SoundDbaRatioSensor(Brick, NxtBrick.Sensor.Third); // 4 UltrasonicSensor = new UltrasonicSensor(Brick, NxtBrick.Sensor.Fourth); // Motor sensors: // 1 // Motors: // A,B,C MotorTail = new Motor(Brick, NxtBrick.Motor.A); MotorRight = new Motor(Brick, NxtBrick.Motor.B); MotorLeft = new Motor(Brick, NxtBrick.Motor.C); // Walk: WalkBehavior = new TwoMotorWalkBehavior(MotorLeft, MotorRight); }
void OnSceneGUI() { LightSensor sensor = target as LightSensor; // Draw test sunlight raycasts Info <List <Vector3>, List <Vector3>, List <bool> > testInfo = sensor.GetRaycastInfo(); if (testInfo != null) { for (int i = 0; i < testInfo.arg1.Count; i++) { Handles.color = (testInfo.arg2[i]) ? Color.green : Color.red; Handles.DrawLine(testInfo.arg0[i], testInfo.arg0[i] + testInfo.arg1[i]); } } // Draw light check points if (drawLightCheckPoints) { Handles.color = Color.yellow; // draw custom points foreach (Vector3 point in sensor.GetUnmodifiedPoints()) { Handles.SphereHandleCap(0, point, Quaternion.identity, pointSize, EventType.Repaint); } } }
public async static void AutoLights() { if (IsLightSensorEnabled) { if (LightSensor.Read() == GpioPinValue.High) { foreach (string item in lightSensorDevices) { lightsList[item].LightOn = true; } } else { foreach (string item in lightSensorDevices) { lightsList[item].LightOn = false; } } await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { if (GroundFloorPage.Current != null) { GroundFloorPage.Current.SetLightButtonStatus(); } if (FirstFloorPage.Current != null) { FirstFloorPage.Current.SetLightButtonStatus(); } }); } }
public void UpdateSensorValues(string[] rawValues) { if (rawValues == null || rawValues.Length == 0) { throw new Exception("Incomming data is incomplete"); } Slider.UpdateValue(Convert.ToInt16(rawValues[SensorValuesOrderTable.SliderOrder])); LightSensor.UpdateValue(Convert.ToInt16(rawValues[SensorValuesOrderTable.LightSensorOrder])); Temperature.UpdateValue(Convert.ToInt16(rawValues[SensorValuesOrderTable.TemperatureOrder])); Microphone.UpdateValue(Convert.ToInt16(rawValues[SensorValuesOrderTable.MicrophoneOrder])); JoystickSwitch.UpdateValue(Convert.ToInt16(rawValues[SensorValuesOrderTable.JoystickSwitchOrder])); JoystickButton.UpdateValue(rawValues[SensorValuesOrderTable.JoystickButtonOrder] != "1"); AccelerometerX.UpdateValue(Convert.ToInt16(rawValues[SensorValuesOrderTable.AccelerometerXOrder])); AccelerometerY.UpdateValue(Convert.ToInt16(rawValues[SensorValuesOrderTable.AccelerometerYOrder])); AccelerometerZ.UpdateValue(Convert.ToInt16(rawValues[SensorValuesOrderTable.AccelerometerZOrder])); ButtonDown.UpdateValue(rawValues[SensorValuesOrderTable.ButtonDownOrder] != "1"); ButtonLeft.UpdateValue(rawValues[SensorValuesOrderTable.ButtonLeftOrder] != "1"); ButtonUp.UpdateValue(rawValues[SensorValuesOrderTable.ButtonUpOrder] != "1"); ButtonRight.UpdateValue(rawValues[SensorValuesOrderTable.ButtonRightOrder] != "1"); JoystickX.UpdateValue(Convert.ToInt16(rawValues[SensorValuesOrderTable.JoystickXOrder])); JoystickY.UpdateValue(Convert.ToInt16(rawValues[SensorValuesOrderTable.JoystickYOrder])); LedRed.UpdateValue(Convert.ToByte(rawValues[SensorValuesOrderTable.LedRedOrder])); LedGreen.UpdateValue(Convert.ToByte(rawValues[SensorValuesOrderTable.LedGreenOrder])); LedBlue.UpdateValue(Convert.ToByte(rawValues[SensorValuesOrderTable.LedBlueOrder])); }
public MyLightSensor(int hubPort, string type, string hubName, double minThreshold, double maxThreshold, bool wireless) : base(hubPort, type, hubName, minThreshold, maxThreshold, wireless) { device = new LightSensor(); device.HubPort = hubPort; device.IsHubPortDevice = false; device.IlluminanceChange += Device_IlluminanceChange; }
async void MainPage_ReadingChanged(LightSensor sender, LightSensorReadingChangedEventArgs args) { await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { TextLight.Text = string.Format(@"Light Sensor : {0}", args.Reading.IlluminanceInLux.ToString()); }); }
void Start() { rb = GetComponent <Rigidbody>(); lightSensor = GetComponent <LightSensor>(); jumpCollider = GetComponentInChildren <JumpCollider>(); footDist = GetComponent <MeshFilter>().mesh.bounds.size.y; }
private async void Sensor_ReadingChanged(LightSensor sender, LightSensorReadingChangedEventArgs args) { float lux = args.Reading.IlluminanceInLux; LightStateEnum state = GetState(lux); await Dispatcher.RunAsync( CoreDispatcherPriority.Normal, () => ChangeMode(state)); }
async void sensor_ReadingChanged(LightSensor sender, LightSensorReadingChangedEventArgs args) { await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { Lux.Text = args.Reading.IlluminanceInLux.ToString(); TimeStamp.Text = args.Reading.Timestamp.ToString(); }); }
public void RegisterReading() { var lightSens = new LightSensor(); _station.RegisterReadingDevice("Guybrush Inc", "Light Intensity", "1", lightSens.Id.ToString(), "Guybrush light intensity sensor", lightSens); Assert.IsTrue(_station.Readers.Any(x => x.Equals(lightSens))); }
public ThemeClass() { _lightSensor = LightSensor.GetDefault(); _autoLightDetectionEnabled = false; SetWindowsVersion(); SetWindowsRegistryKey(); }
/// <summary> /// Constructor of LightSensorAdapter. /// </summary> public LightSensorAdapter() { sensor = new LightSensor { Interval = 100, PausePolicy = SensorPausePolicy.None }; }
public CapteurDeLuminosité() { lightsensor = LightSensor.GetDefault(); if (lightsensor == null) { capteurDeLumièrePresent = false; } }
private void OnGetLight2(object sender, RoutedEventArgs e) { sensor = LightSensor.GetDefault(); sensor.ReportInterval = sensor.MinimumReportInterval; sensor.ReadingChanged += (sender1, e1) => { this.DefaultViewModel["LightResult"] = string.Format("{0:T}\tIlluminance: {1} Lux", e1.Reading.Timestamp, e1.Reading.IlluminanceInLux); }; }
public void Initialize() { LightSwitcher.TurnOff(); Door.TurnOff(); LightSensor.TurnOff(); MotionSensor.TurnOff(); ClassRoomObjects.Counter = 0; }
private async void lightSensor_ReadingChanged(LightSensor sender, LightSensorReadingChangedEventArgs args) { await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { LightSensorReading reading = args.Reading; illumination.Text = String.Format("{0,2:0.00}", reading.IlluminanceInLux.ToString()); }); }
public MainPage() { InitializeComponent(); _sensor = LightSensor.GetDefault(); if (_sensor != null) { _sensor.ReportInterval = Math.Max(16, _sensor.MinimumReportInterval); _sensor.ReadingChanged += Sensor_ReadingChanged; } }
void OnLightStatusNotification(object sender, object args) { LightSensor sensor = target as LightSensor; Info <GameObject, float> info = (Info <GameObject, float>)args; if (info.arg0.GetComponent <LightSensor>() == sensor) { intensity = info.arg1.ToString(); } }
public ButtonTimerHostedService(IPIManager Pimanager) { _piManager = Pimanager; button = new Button(_piManager.grovePi, GrovePort.DigitalPin7); buzzer = new Buzzer(_piManager.grovePi, GrovePort.DigitalPin6); buzzer.Value = 10; lightSensor = new LightSensor(_piManager.grovePi, GrovePort.AnalogPin0); soundSesnor = new SoundSensor(_piManager.grovePi, GrovePort.AnalogPin1); ultrasonicSensor = new UltrasonicSensor(_piManager.grovePi, GrovePort.DigitalPin8); }
public LightSensorExample() { var sensor = new LightSensor(Connectors.GPIO17); sensor.Start(); Console.WriteLine("Light:"); for (int i = 0; i < 500; i++) { Console.WriteLine(sensor.Brightness); Thread.Sleep(250); } }
public void TestCreator() { LightSensor ls = new LightSensor(); Assert.IsNotNull(ls); FireSensor fs = new FireSensor(); Assert.IsNotNull(fs); DoorSensor ds = new DoorSensor(); Assert.IsNotNull(ds); }
void _lightSensor_ReadingChanged(LightSensor sender, LightSensorReadingChangedEventArgs args) { _dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { Lux = args.Reading.IlluminanceInLux; AppFrame.RequestedTheme = State.Equals("Dark", StringComparison.CurrentCultureIgnoreCase) ? ElementTheme.Dark : ElementTheme.Light; }); Debug.WriteLine("Lux: {0}", Lux); }
/// <summary> /// Attempts to get ambient light illuminance. /// </summary> /// <param name="illuminance">Illuminance in lux</param> /// <returns>True if successfully gets</returns> public static bool TryGetAmbientLight(out float illuminance) { var reading = LightSensor.GetDefault()?.GetCurrentReading(); if (reading is null) { illuminance = default; return(false); } illuminance = reading.IlluminanceInLux; return(true); }
public static IProducer <double> CreateComponent(this LightSensor lightSensor, Pipeline pipeline, TimeSpan samplingInterval) { if (lightSensor == null) { throw new ArgumentNullException(nameof(lightSensor)); } if (pipeline == null) { throw new ArgumentNullException(nameof(pipeline)); } return(Generators.Sequence(pipeline, 0.0, _ => lightSensor.Value, samplingInterval)); }
public void CheckStatusTest() { LightSensor ls = new LightSensor(); FireSensor fs = new FireSensor(); DoorSensor ds = new DoorSensor(); bool lsStatus = ls.checkStatus(); bool fsStatus = fs.checkStatus(); bool dsStatus = ds.checkStatus(); Assert.IsFalse(lsStatus); Assert.IsFalse(fsStatus); Assert.IsFalse(dsStatus); }
public Glance() { _updateSensor = new DispatcherTimer(); _updateSensor.Interval = TimeSpan.FromSeconds(0.25); _updateSensor.Tick += UpdateSensor_Tick; sensor = LightSensor.GetDefault(); if (sensor != null) { //sensor.ReportInterval = sensor.MinimumReportInterval; lastEffectiveReadingTime = DateTime.Now; lastState = sensor.GetCurrentReading().IlluminanceInLux <= Dark ? GlanceEventArgs.Dark : GlanceEventArgs.Light; } }
public void GetUIDTest() { LightSensor ls = new LightSensor(); FireSensor fs = new FireSensor(); LightSensor ls2 = new LightSensor(); FireSensor fs2 = new FireSensor(); DoorSensor ds = new DoorSensor(); DoorSensor ds2 = new DoorSensor(); Assert.AreNotEqual(ls.getSensorUID(), ls2.getSensorUID()); Assert.AreNotEqual(fs.getSensorUID(), fs2.getSensorUID()); Assert.AreNotEqual(ds.getSensorUID(), ds2.getSensorUID()); }
protected override void OnNavigatedTo(NavigationEventArgs e) { sensor = LightSensor.GetDefault(); if (sensor != null) { sensor.ReadingChanged += sensor_ReadingChanged; Data.Visibility = Visibility.Visible; } else { NoSensorMessage.Visibility = Visibility.Visible; } }
public void OnGetLight() { LightSensor sensor = LightSensor.GetDefault(); if (sensor != null) { LightSensorReading reading = sensor.GetCurrentReading(); Illuminance = $"Illuminance: {reading?.IlluminanceInLux}"; } else { Illuminance = "Light sensor not found"; } }
private void OnGetLight(object sender, RoutedEventArgs e) { LightSensor sensor = LightSensor.GetDefault(); if (sensor != null) { LightSensorReading reading = sensor.GetCurrentReading(); this.DefaultViewModel["LightResult"] = string.Format("Illuminance: {0} Lux", reading.IlluminanceInLux); } else { this.DefaultViewModel["LightResult"] = "No light sensor found"; } }
public TemperatureReader(TemperatureHumidity temperatureHumidity, LightSensor lightSensor, ILoggerDisplay loggerDisplay) { if (temperatureHumidity == null) throw new ArgumentNullException("temperatureHumidity"); if (lightSensor == null) throw new ArgumentNullException("lightSensor"); if (loggerDisplay == null) throw new ArgumentNullException("loggerDisplay"); _temperatureHumidity = temperatureHumidity; _lightSensor = lightSensor; _temperatureHumidity.MeasurementComplete += TemperatureHumidityMeasurementComplete; _loggerDisplay = loggerDisplay; // Take measurement on timer tick // and hence update UI and Monitor. _temperatureCheckTimer.Tick += TemperatureCheckTimerTick; }