public CPUFanController(ArduinoController arduino, IFanSpeedConverter speedConverter, int cpuNumber) { this.arduino = arduino; this.speedConverter = speedConverter; this.cpuNumber = cpuNumber; fanStuckCounter = 0; }
IEnumerator UpdateRotation() { slideLock = true; ArduinoController con = GetComponentInParent <ArduinoController> (); AnimationClip prevAnimation = con.runAnimation; float prevAnimationSpeed = con.runMaxAnimationSpeed; // set animation to sliding if (slideAnimation != null) { con.runAnimation = slideAnimation; con.runMaxAnimationSpeed = slideAnimation.length / slideTime; } con.canJump = false; yield return(new WaitForSeconds(slideTime)); if (slideAnimation != null) { con.runAnimation = prevAnimation; con.runMaxAnimationSpeed = prevAnimationSpeed; } con.canJump = true; slideLock = false; }
protected override void OnExperimentSetup() { BeepManager = BeeperManager.Instance; CanvasManager.Show(); Arduino = ArduinoController.Instance; Arduino.Connect(); }
//////////////////////////////////////////// // // Function // //////////////////////////////////////////// void Awake() { m_Layers = new List <GameObject>(); m_DropSound = GetComponent <AudioSource>(); m_InformationMgr = InformationMgr.instance; m_ArduinoController = GameObject.Find("MainArduinoController").GetComponent <ArduinoController>(); Init(); }
void Start() { instance = this; serial = new SerialPort("COM" + port, 9600); serial.Open(); serial.ReadTimeout = 10; }
private void btnTest_Click(object sender, EventArgs e) { var dev = ArduinoController.CreateDevice(lbSerialPorts.SelectedItem as SerialPortInfo, (ControllerType)cbDeviceType.SelectedItem); if (dev != null) { new GamepadTesterForm(dev).ShowDialog(); } }
public void DeviceIdentifier_IsSet() { var majoro = new Mock <IMajoro>(); var settings = getSettingsWithPins(); var controller = new ArduinoController(majoro.Object, settings); Assert.Equal(settings.Name, controller.Device.Name); }
public SesionSoloBrazo(RespuestaToken token, SesionViewModel sesionVM, RepeticionViewModel ejercicioVM) { InitializeComponent(); Sesion = sesionVM; Ejercicio = ejercicioVM; Ejercicio.Duracion = new TimeSpan(0, 0, 0); Token = token; arduinoController = new ArduinoController(); videoController = new VideoController(); }
void UpdateDevices() { munias = MuniaController.ListDevices().ToList(); lbMuniaDevices.DataSource = munias; nspys = ArduinoController.ListDevices().ToList(); lbNintendoSpyDevices.DataSource = nspys; generics = GenericController.ListDevices().ToList(); lbGenericDevices.DataSource = generics; }
public void Disconnect() { var majoro = new Mock <IMajoro>(); var settings = getSettingsWithoutPins(); var controller = new ArduinoController(majoro.Object, settings); controller.Disconnect(); majoro.Verify(x => x.Disconnect(), Times.Once); }
static void Main(string[] args) { IDeviceController deviceController = new ArduinoController(); Console.WriteLine("Trying to detect Arduino..."); deviceController.InitiateConnection(); Console.WriteLine("Detecting Arduino finished"); Console.WriteLine("Beginning to read from Arduino"); deviceController.BeginReading(); Console.Read(); }
public void ConnectionNOTAcknowledgeTest() { ArduinoController.SerialPortName = System.IO.Ports.SerialPort.GetPortNames() [0]; Console.WriteLine("Connecting to " + ArduinoController.SerialPortName); ArduinoController.Setup(false); Assert.AreEqual(true, ArduinoController.IsConnected); Thread.Sleep(3000); Assert.AreEqual(false, ArduinoController.IsConnected); }
public void TurnOff() { var majoro = new Mock <IMajoro>(); majoro.Setup(x => x.WriteHigh(8)).Returns(true); majoro.Setup(x => x.WriteLow(9)).Returns(true); var settings = getSettingsWithPins(); var controller = new ArduinoController(majoro.Object, settings); bool successful = controller.TurnOff(new Socket(1, string.Empty)); Assert.True(successful); }
public void TurnOn_NoPins() { var majoro = new Mock <IMajoro>(); majoro.Verify(x => x.WriteLow(It.IsAny <int>()), Times.Never); majoro.Verify(x => x.WriteLow(It.IsAny <int>()), Times.Never); var settings = getSettingsWithoutPins(); var controller = new ArduinoController(majoro.Object, settings); bool successful = controller.TurnOn(new Socket(-1, string.Empty)); Assert.True(successful); }
// At the start of the game.. void Start() { // Assign the Rigidbody component to our private rb variable rb = GetComponent <Rigidbody>(); // Set the count to zero count = 0; // Run the SetCountText function to update the UI (see below) SetCountText(); // Set the text property of our Win Text UI to an empty string, making the 'You Win' (game over message) blank winText.text = ""; AC = this.GetComponent <ArduinoController>(); }
public Principal(RespuestaToken token, SesionViewModel sesionVM, RepeticionViewModel ejercicioVM) { InitializeComponent(); flagSkeleton = false; flagObjeto = false; datosDistancia = null; colorImagenDistancia = null; RespuestaToken = token; Sesion = sesionVM; Ejercicio = ejercicioVM; angulos = new Angulos(); puntos = new Puntos(); Ejercicio.Duracion = new TimeSpan(DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second); arduinoController = new ArduinoController(); videoController = new VideoController(); }
public MainWindow() { InitializeComponent(); Closed += MainWindow_Closed; Loaded += MainWindow_Loaded; StateChanged += MainWindow_StateChanged; Controller = new ArduinoController(); Controller.MessageReceived += OnMessageReceived; DataContext = Controller; PreviewKeyDown += MainWindow_PreviewKeyDown; SystemEvents.PowerModeChanged += SystemEvents_PowerModeChanged;; }
// Our singleton pattern to make sure there is only ever one ArduinoController instance void Awake() { // Check if there is already an instance of ArduinoController if (instance == null) { // If not, set the ArduinoController instance to this instance = this; } // If the instance already exists: else if (instance != this) { // Then destroy this game object with the duplicate instace of ArduinoController, this enforces our singleton pattern so there can only ever be one instance of ArduinoController Destroy(gameObject); } // Set ArduinoController to DontDestroyOnLoad so that it won't be destroyed when reloading our scene. DontDestroyOnLoad(gameObject); }
public static void LoadControllers() { Controllers.Clear(); foreach (var dev in MuniaController.ListDevices()) { Controllers.Add(dev); } foreach (var dev in ArduinoController.ListDevices()) { Controllers.Add(dev); } foreach (var dev in XInputController.ListDevices()) { Controllers.Add(dev); } foreach (var dev in MappedController.ListDevices()) { Controllers.Add(dev); } }
private void Form1_Load(object sender, EventArgs e) { // Get a reference to the GraphPane instance in the ZedGraphControl GraphPane myPane = zg1.GraphPane; // Set the titles and axis labels myPane.Title.Text = "A0 ADC Graph"; myPane.XAxis.Title.Text = "Sample Timeline"; myPane.YAxis.Title.Text = "Sample Voltage"; // Save the last 300 points in this structure. RollingPointPairList list = new RollingPointPairList(300); // Initially, a curve is added with no data points (list is empty) // Color is blue, and there will be no symbols LineItem curve = myPane.AddCurve("A0 Voltage", list, Color.Blue, SymbolType.None); // Fill the axis background with a gradient myPane.Chart.Fill = new Fill(Color.White, Color.LightGray, 45.0f); // Just manually control the X axis range so it scrolls continuously // instead of discrete step-sized jumps myPane.XAxis.Scale.Min = 0; myPane.XAxis.Scale.Max = 300; myPane.XAxis.Scale.MinorStep = 1; myPane.XAxis.Scale.MajorStep = 5; //myPane.YAxis.Scale.Min = 0; //myPane.YAxis.Scale.Max = 260; //myPane.YAxis.Scale.MinorStep = 1; //myPane.YAxis.Scale.MajorStep = 5; // Scale the axes zg1.AxisChange(); //Create a reference to my Arduino controller. arduinoController = new ArduinoController(zg1); //Send command to start getting readings from arduino arduinoController.sendCmd(ArduinoControllerCmd.sampleA0); }
private void InicializarArduino() { AngulosDefault = new AngulosServos(ArduinoController.BRAZO_GB); try { Arduino = new ArduinoController(); if (String.IsNullOrEmpty(Ejercicio.EstadoInicial)) { Angulos = new AngulosServos(AngulosDefault.ToString()); } else { Angulos = new AngulosServos(Ejercicio.EstadoInicial); } Arduino.Inicializar(Angulos.ToString()); } catch (Exception) { Arduino = null; } }
void Awake() { filteredDockingObject = GameObject.Find("FilteredDockingObject"); arduinoControllerObject = GameObject.FindGameObjectWithTag("ArduinoController"); arduinoController = arduinoControllerObject.GetComponent <ArduinoController>(); dockingObject = GameObject.FindGameObjectWithTag("DockingCircle"); //GameObject.Find("ReferenceCircle").GetComponent<Image>().sprite = Resources.Load<Sprite>("Images/Pie" + pieMenuSize); // xRan = Mathf.Cos(angle) * radius; // yRan = Mathf.Sin(angle) * radius; pieMenuDisplay = GameObject.Find("ReferenceCircle").GetComponent <Image>(); // targetCircle.transform.position = new Vector3(xRan + dockingCircle.transform.position.x, yRan + dockingCircle.transform.position.y, 0.0f); SceneControllerObject = GameObject.FindGameObjectWithTag("SceneController"); sceneController = SceneControllerObject.GetComponent <SceneControllerScript>(); width = (float)Screen.width / 2.0f; height = (float)Screen.height / 2.0f; // Position used for the cube. position = new Vector3(0.0f, 0.0f, 0.0f); }
public void SendSpeed(float temp) { float speed = speedConverter.FanRPM(temp); speed = SwingSpeed(speed); lastSpeed = speed; fanStuckCounter++; if (fanStuckCounter > 10) { fanStuckCounter = 0; if (speed < 0.6f) { arduino.SendRawData(ConvertRPMForCpu("f", cpuNumber)[0]);//Send full power to that fan for some time Thread.Sleep(200); } } string rpm_send = ArduinoController.RPM2Char(speed); rpm_send = ConvertRPMForCpu(rpm_send, cpuNumber); foreach (char c in rpm_send) { arduino.SendRawData(c); } }
private void Awake() { Arduino = GameObject.Find("ArduinoController").GetComponent <ArduinoController>(); }
////////////////////////////////// // // Function // ////////////////////////////////// private void Awake() { m_ArduinoController = GameObject.Find("SensorArduinoController").GetComponent <ArduinoController>(); }
void Start() { arduinoController = FindObjectOfType <ArduinoController>(); _canvasLed.SetActive(isLocalPlayer); }
public ArduinoControlCentreService() { arduinoController = new ArduinoController(); }
static void Main(string[] args) { var curve_idle = new FanCurve(); curve_idle.AddCurveLine(new FanCurveLine(0, 50, 0.3f, 0.3f)); curve_idle.AddCurveLine(new FanCurveLine(50, 70, 0.3f, 0.7f)); var curve_mid = new FanCurve(); curve_mid.AddCurveLine(new FanCurveLine(0, 55, 0.3f, 0.3f)); curve_mid.AddCurveLine(new FanCurveLine(55, 75, 0.3f, 0.8f)); var curve_high = new FanCurve(); curve_high.AddCurveLine(new FanCurveLine(0, 50, 0.3f, 0.3f)); curve_high.AddCurveLine(new FanCurveLine(50, 70, 0.3f, 0.6f)); curve_high.AddCurveLine(new FanCurveLine(70, 80, 0.6f, 1.0f)); var global_curve = new FanCurvePerLoad(); global_curve.AddCurve(curve_idle, 0, 0.2f); global_curve.AddCurve(curve_mid, 0.2f, 0.5f); global_curve.AddCurve(curve_high, 0.5f, 1.0f); var ard = new ArduinoController(); var c1 = new CPUFanController(ard, global_curve, 1); var c2 = new CPUFanController(ard, global_curve, 0); DateTime lasttime = DateTime.Now; var coreInfo = new CoreInfoProducer(); while (true) { var cores = coreInfo.GetCoreInfo(); var cpu0 = cores.FindAll(s => s.cpuno == 0);//Classify cores by CPU var cpu1 = cores.FindAll(s => s.cpuno == 1); var cpu0Temp = cpu0.Max(s => s.temp).Value; var cpu1Temp = cpu1.Max(s => s.temp).Value; var cpu0Load = cpu0.Average(s => s.load).Value; var cpu1Load = cpu1.Average(s => s.load).Value; global_curve.SetCPULoad(cpu0Load); c1.SendSpeed(cpu0Temp); global_curve.SetCPULoad(cpu1Load); c2.SendSpeed(cpu1Temp); while (ard.ReadRawData() != Convert.ToChar(0)) { } ; //Remove all pending return information double waittime = 500f; while (true) { Thread.Sleep(50); DateTime newtime = DateTime.Now; double timediff = (newtime - lasttime).TotalMilliseconds; if (timediff >= waittime) { lasttime = lasttime.AddMilliseconds(timediff); break; } } Console.WriteLine(cpu0Temp); Console.WriteLine(cpu1Temp); Console.WriteLine(c1.LastFanSpeed()); Console.WriteLine(c2.LastFanSpeed()); Console.WriteLine("==="); } }