public override void Draw(MicroWorld.Graphics.Renderer renderer) { if (texture0cw == null) { return; } if (!CanDraw()) { return; } Photoresistor p = parent as Photoresistor; switch (parent.ComponentRotation) { case Component.Rotation.cw0: renderer.Draw(texture0cw, new Rectangle((int)Position.X, (int)Position.Y, (int)GetSizeRotated(parent.ComponentRotation).X, (int)GetSizeRotated(parent.ComponentRotation).Y), null, Color.White); break; case Component.Rotation.cw90: renderer.Draw(texture90cw, new Rectangle((int)Position.X, (int)Position.Y, (int)GetSizeRotated(parent.ComponentRotation).X, (int)GetSizeRotated(parent.ComponentRotation).Y), null, Color.White); break; case Component.Rotation.cw180: case Component.Rotation.cw270: default: break; } }
public override void CircuitUpdate() { base.CircuitUpdate(); Photoresistor p = ((Photoresistor)parent); Brightness = ComponentsManager.GetBrightness(parent.Graphics.Position.X, parent.Graphics.Position.Y); double res = p.MaxResistance * (1 - Brightness) + 1f; if (p.W.Resistance != res) { p.W.Resistance = res; MicroWorld.Logics.CircuitManager.ScheduleReupdate(p.W); } }
public static void Main() { //Remember to use the 10K resistor and take the reading in parallel //using the 3.3V output makes you less likely to hit the 255 cap var photocell = new Photoresistor(Pins.GPIO_PIN_A0); var dimableLED1 = new VariableLED(Pins.GPIO_PIN_D10); var dimableLED2 = new VariableLED(Pins.GPIO_PIN_D5); while (true) { double light = photocell.Read(); Debug.Print(light.ToString()); if (light < 300) { if (light < 200) { dimableLED1.Brighten(); dimableLED2.Dim(); } if (light < 100) { dimableLED1.Brighten(); dimableLED2.Brighten(); } } else { if (light > 200) { dimableLED1.Dim(); } if (light > 400) { dimableLED2.Dim(); } } Thread.Sleep(500); } }
void OnMouseDown() { print("Clicked"); Photoresistor.SendRed(); }