void _getReading_Tick(GT.Timer timer) { if (!Scheduler.Instance().gasContinue()) return; gs.SetHeatingElement(true); _preheat.Start(); }
void camera_PictureCaptured(Camera sender, GT.Picture picture) { wifi.SendPictureData(picture.PictureData, PhotoType.Central.ToString()); Debug.Print("foto"); sendingPicture = false; Scheduler.Instance().Working = false; }
void hideMessage_Tick(GT.Timer timer) { timer.Stop(); label.Visibility = Visibility.Collapsed; imageDisplay.Visibility = Visibility.Visible; }
void timer_Tick(Gadgeteer.Timer timer) { //You only need to enter pairing mode once with a device. After you pair for the first time, it will //automatically connect in the future. if (!bluetooth.IsConnected) bluetooth.ClientMode.EnterPairingMode(); }
void timer_Tick(GT.Timer timer) { led_Strip.TurnLEDOff(_ledNumberToModify); if (_ledNumberToModify == LastLed) _ledNumberToModify = FirstLed; else _ledNumberToModify++; led_Strip.TurnLEDOn(_ledNumberToModify); }
void DataReceived(GT.Interfaces.Serial sender, System.IO.Ports.SerialData daten) { int BytesToRead = usbSerial.SerialLine.BytesToRead; byte[] buffer = new byte[BytesToRead]; usbSerial.SerialLine.Read(buffer, 0, BytesToRead); Debug.Print("Data received: " + BytesToRead + " Bytes" ); GT.Interfaces.PWMOutput ServoA = extender1.SetupPWMOutput(GT.Socket.Pin.Seven); GT.Interfaces.PWMOutput ServoB = extender1.SetupPWMOutput(GT.Socket.Pin.Eight); GT.Interfaces.PWMOutput ServoC = extender1.SetupPWMOutput(GT.Socket.Pin.Nine); GT.Interfaces.PWMOutput ServoD = extender2.SetupPWMOutput(GT.Socket.Pin.Nine); String bufferString = new String(UTF8Encoding.UTF8.GetChars(buffer)); Debug.Print("DATA: " + bufferString); String servo = bufferString.Substring(0, 1); UInt32 position = UInt32.Parse(bufferString.Substring(1, bufferString.Length - 1)); switch (servo) { case "g": setServo(ServoA, position); break; case "1": setServo(ServoB, position); break; case "2": setServo(ServoC, position); break; case "r": setServo(ServoD, position); break; } }
private void joystickTimer_Tick(GT.Timer timer) { const double X_DEADZONE = 0.25; const double Y_DEADZONE = 0.25; // If Misilelauncher is initializated, handle joystick position if (launcherPod != null){ joystickPosition = joystick.GetPosition(); if (joystickPosition.X > X_DEADZONE) { launcherPod.MisileDO(MisileLauncher.MisileCommand.RIGHT); } else if (joystickPosition.X < -X_DEADZONE) { launcherPod.MisileDO(MisileLauncher.MisileCommand.LEFT); } if (joystickPosition.Y > Y_DEADZONE) { launcherPod.MisileDO(MisileLauncher.MisileCommand.UP); } else if (joystickPosition.Y < -Y_DEADZONE) { launcherPod.MisileDO(MisileLauncher.MisileCommand.DOWN); } launcherPod.MisileDO(MisileLauncher.MisileCommand.STOP); } }
/// <summary> /// c'tor /// </summary> /// <param name="socket">the Gadgeteer socket that the strip is on</param> /// <param name="numLeds">the number of LEDs in the strip</param> public LedStripLPD8806(GT.Socket socket, int numLeds) { var spiConfig = new SPI.Configuration(Cpu.Pin.GPIO_NONE, false, // chip select active state 0, // chip select setup time 0, // chip select hold time false, // clock idle state true, // clock edge (true = rising) 2000, // 2mhz SPI.SPI_module.SPI1 ); // the protocol seems to be that we need to write 1 + (1 per 64 LEDs) bytes // at the end of each update (I've only tested this on a 32-LED strip) int latchBytes = ((numLeds + 63) / 64) * 3; mLedByteCount = numLeds * 3; mData = new byte[mLedByteCount + latchBytes]; mNumLeds = numLeds; // mLedStrip = new SPI(socket, spiConfig, SPI.Sharing.Exclusive, null); mLedStrip = new SPI(spiConfig); // start with all the LEDs off for (int i = 0; i < mLedByteCount; i++) { mData[i] = MASK; } // give the strip an inital poke of the latch bytes (no idea // why this is needed) mLedStrip.Write(new byte[latchBytes]); // push the initial values (all off) to the strip SendUpdate(); }
public Wifi(Gadgeteer.Modules.GHIElectronics.WiFi_RS21 wifi_RS21) { this.wifi_RS21 = wifi_RS21; t = new GT.Timer(3000); t.Tick += new GT.Timer.TickEventHandler(start); t.Start(); }
public override void JoystickPressed(Gadgeteer.Modules.GHIElectronics.Joystick sender, Gadgeteer.Modules.GHIElectronics.Joystick.JoystickState state) { _Data = new ExampleData(); _Data.LastDate = DateTime.Now; SaveData(); PrintLastDate(); }
private void _timer_Tick(GT.Timer timer) { Debug.Print("thermocouple temperature " + max31855Thermocouple.TemperatureCelsius()); ////Debug.Print("calculated temperature " + max31855Thermocouple.correctedCelsius().ToString()); Debug.Print("junction temperature " + max31855Thermocouple.InternalCelsius()); Debug.Print("Fault " + max31855Thermocouple.Fault); }
private void MainTimerCallback(GT.Timer timer) { Debug.Print("Event: time to request server for orders"); var request = HttpHelper.CreateHttpGetRequest(STATUS_URL); request.ResponseReceived += ServerResponseCallback; request.SendRequest(); }
void start(GT.Timer timer) { Debug.Print("timer start"); t.Stop(); button.ButtonPressed += button_ButtonPressed; blueT.DeviceInquired += blueT_DeviceInquired; blueT.DataReceived += blueT_DataReceived; blueT.BluetoothStateChanged += blueT_BluetoothStateChanged; }
void monitor_Tick(GT.Timer timer) { int currentdistance = distance.GetDistanceInCentimeters(); Debug.Print("Current distance : " + currentdistance); if (currentdistance <= 20) { serial.WriteLine("SYou are too close at " + currentdistance + " centimeters. Please move back"); } }
void DataReceived(GT.Interfaces.Serial sender, System.IO.Ports.SerialData data) { int BytesToRead = usbSerial.SerialLine.BytesToRead; byte[] Buffer = new byte[BytesToRead]; usbSerial.SerialLine.Read(Buffer, 0, BytesToRead); Debug.Print("Data received: " + BytesToRead + " Bytes"); String BufferString = "DATA: " + ByteArrayToString(Buffer); Debug.Print(BufferString); }
private int Move(GT.Interfaces.PWMOutput pwm, int position, int minPosition, int maxPosition, int pwmMin, int pwmMax) { position = position > maxPosition ? maxPosition : position; position = position < minPosition ? minPosition : position; Servo(pwm, GetPwmPulseValue(pwmMax, pwmMin, position)); return position; }
/// <summary> /// Constructor, initalizes all the needed elements /// </summary> /// <param name="display"></param> /// <param name="button"></param> /// <param name="joystick"></param> public ModeSelection(Gadgeteer.Modules.Module.DisplayModule display, Gadgeteer.Modules.GHIElectronics.Joystick joystick, EventHandler handler) { this.display = display; this.joystick = joystick; this.pos_joystick = new Gadgeteer.Modules.GHIElectronics.Joystick.Position(); display.SimpleGraphics.Clear(); inputFinished = handler; }
void Port_DataReceived(Gadgeteer.SocketInterfaces.Serial sender) { if (this.DataReceived == null) return; var buffer = new byte[sender.BytesToRead]; sender.Read(buffer, 0, buffer.Length); this.DataReceived(this, buffer); }
void camera_PictureCaptured(Camera sender, GT.Picture e) { Debug.Print("imagen capturada"); button.TurnLedOn(); sdCard.StorageDevice.WriteFile("picture.bmp", e.PictureData); Debug.Print("imagen guardada"); button.TurnLedOff(); timer.Start(); }
void blueT_DataReceived(GT.Bluetooth sender, string data) { if (!Scheduler.Instance().canContinue()) return; int index = data.IndexOf(bluetoothMessage); if (index > -1) { wifi.SendData("device", data.Substring(index + bluetoothMessage.Length, data.Length - (index + bluetoothMessage.Length + 1)), "sendMovement"); } }
void blueT_DeviceInquired(GT.Bluetooth sender, string macAddress, string name) { Debug.Print("inquired"); if (name.IndexOf("HomeSecurity") > -1) { blueT.HostMode.InputPinCode("1234"); Debug.Print("Conectado a un dispositivo!!!"); blueT.HostMode.Connect(macAddress); } }
void timer_Tick(GT.Timer timer) { char_Display.Clear(); char_Display.PrintString("Security Alerted..."); multicolorLed.TurnOff(); _rfidEnabled = false; }
private void cardReader_Mounted(SDCard sender, Gadgeteer.StorageDevice device) { if (sender.StorageDevice.Volume.IsFormatted) { if (sdCard.IsCardMounted) { Logger.WriteInfo("RPTR", "Media directory/file listing: "); FileListing(sdCard.StorageDevice.RootDirectory); } } }
/// <summary> /// �R���X�g���N�^ /// </summary> /// <param name="socket">�ڑ��\�P�b�g</param> /// <param name="addr">�h���C�o���W���[���A�h���X</param> public I2CMotrorDriver(GT.Socket socket, ushort addr, byte max = MTR_DRV_MAX_SPEED) { i2c = new GTI.I2CBus(socket, addr, 100, null); if (max < 0 || MTR_DRV_MAX_SPEED < max) { max = MTR_DRV_MAX_SPEED; } maxSpeed = max; }
/// <summary> /// Default constructor for MasterMind class. Initializes variables /// </summary> /// <param name="display">display module</param> /// <param name="joystick">joystick module</param> /// <param name="button">button module</param> /// <param name="led">led module</param> public MasterMind(Gadgeteer.Modules.Module.DisplayModule display, Gadgeteer.Modules.GHIElectronics.Joystick joystick, Gadgeteer.Modules.GHIElectronics.Button button, Gadgeteer.Modules.GHIElectronics.MulticolorLED led) { //storing device referenceslocally ingame logic. this.display = display; this.joystick = joystick; this.led = led; this.button = button; //game restart button button.ButtonPressed += button_ButtonPressed; }
void sdCard_SDCardMounted(SDCard sender, GT.StorageDevice SDCard) { sdCard.MountSDCard(); if (sdCard.IsCardMounted) { Debug.Print("SD card is mounted"); Thread.Sleep(2000); } else { Debug.Print("Problem with sd card"); } }
void setServo(GT.Interfaces.PWMOutput servo, UInt32 position) { if (position < 1) position = 1; else if (position > 100) position = 100; UInt32 pulse = (MAX_TIME - MIN_TIME) * position / 100; servo.Active = true; servo.SetPulse(PERIOD, pulse); Debug.Print("Position: " + position + " % - Pulselength: " + pulse + "ns"); servo.Active = false; }
public CameraClass(Gadgeteer.Modules.GHIElectronics.Camera camera, Motion_Sensor motion_Sensor, Wifi wf) { this.wifi = wf; this.camera = camera; this.camera.CurrentPictureResolution = Camera.PictureResolution.Resolution160x120; this.motion_Sensor = motion_Sensor; this.motion_Sensor.Motion_Sensed += new GTM.Motion_Sensor.Motion_SensorEventHandler(motion_Sensor_Motion_Sensed); this.camera.PictureCaptured += new Camera.PictureCapturedEventHandler(camera_PictureCaptured); this.camera.DebugPrintEnabled = false; timer = new GT.Timer(sleepTime); timer.Tick += timer_Tick; }
private void Timer_Tick(GT.Timer timer) { byte[] elfBuffer = Resources.GetBytes(Resources.BinaryResources.G120RLP); //Make sure to load the ELF file you compiled into this array. var elfImage = new RuntimeLoadableProcedures.ElfImage(elfBuffer); var yourFunction = elfImage.FindFunction("TestFungsi"); var arr = new byte[] { 1, 2, 3, 4, 5 }; var result = yourFunction.Invoke(10, 3, arr); Debug.Print("Hasil invoke fungsi " + result.ToString()); //Should be 5 Debug.Print("Nilai array ke 0 = " + arr[0].ToString()); //Should be 5 }
void _preheat_Tick(GT.Timer timer) { _preheat.Stop(); double gs1 = gs.ReadVoltage(); if (!Scheduler.Instance().gasContinue()) return; wifi.SendGasData(gs1); if (gs1 > maxGas) { gasDetected(gs1); } }