public CuteBotController(I2cController i2cController, PwmChannel buzzer, GpioPin leftLineSensor, GpioPin rightLineSensor, GpioPin colorLedPin) { this.i2c = i2cController.GetDevice(new I2cConnectionSettings(0x10, 50_000)); this.buzzer = buzzer; this.leftLineSensor = leftLineSensor; this.leftLineSensor.SetDriveMode(GpioPinDriveMode.Input); this.rightLineSensor = rightLineSensor; this.rightLineSensor.SetDriveMode(GpioPinDriveMode.Input); this.ws2812 = new WS2812(colorLedPin, 2); }
static void Main() { var leds = new WS2812(SC20260.GpioPin.PA0, NUM_LED); leds.SetColor(0, 0xFF, 0xFF, 0xFF); leds.SetColor(1, 0x00, 0xFF, 0xFF); leds.SetColor(2, 0x00, 0x00, 0xFF); leds.SetColor(24, 0xFF, 0xFF, 0xFF); leds.SetColor(23, 0x00, 0xFF, 0xFF); leds.SetColor(22, 0xFF, 0x00, 0x00); while (true) { leds.Draw(); } }
public TinyBitController(I2cController i2cController, PwmChannel buzzer, AdcChannel voiceSensor, GpioPin leftLineSensor, GpioPin rightLineSensor, GpioPin distanceTrigger, GpioPin distanceEcho, int colorLedPin) { this.i2c = i2cController.GetDevice(new I2cConnectionSettings(0x01, 400_000)); this.buzzer = buzzer; this.voiceSensor = voiceSensor; this.leftLineSensor = leftLineSensor; this.leftLineSensor.SetDriveMode(GpioPinDriveMode.Input); this.rightLineSensor = rightLineSensor; this.rightLineSensor.SetDriveMode(GpioPinDriveMode.Input); this.ws2812 = new WS2812(GpioController.GetDefault().OpenPin(colorLedPin), 2); this.distanceEcho = distanceEcho; this.distanceTrigger = distanceTrigger; this.pulseFeedback = new PulseFeedback(distanceTrigger, this.distanceEcho, PulseFeedbackMode.EchoDuration) { DisableInterrupts = false, Timeout = TimeSpan.FromSeconds(1), PulseLength = TimeSpan.FromTicks(100), PulseValue = GpioPinValue.High, EchoValue = GpioPinValue.High, }; }
public YahboomPianoController(I2cController i2cController, PwmChannel buzzer, int colorLedPin) { this.i2c = i2cController.GetDevice(new I2cConnectionSettings(0x50, 100_000)); this.buzzer = buzzer; this.ws2812 = new WS2812(GpioController.GetDefault().OpenPin(colorLedPin), 2); }
static void Main() { var graphic = Graphics.FromImage(new Bitmap(16, 16)); var font = Resources.GetFont(Resources.FontResources.small); Graphics.OnFlushEvent += Graphics_OnFlushEvent; leds = new WS2812(SC20260.GpioPin.PA0, NUM_LED); var x = 9; var mode = 0; while (true) { graphic.Clear(Color.Black); var t1 = DateTime.Now.Ticks; switch (mode) { case 0: graphic.DrawString("" + x--, font, new SolidBrush(Color.Red), 5, 1); if (x < 0) { x = 0; mode++; } Thread.Sleep((int)(500 - (DateTime.Now.Ticks - t1) / 10000)); break; case 1: graphic.DrawEllipse(new Pen(Color.White), 8 - x, 8 - x, 2 * x, 2 * x); x++; if (x == 16) { mode++; x = 16; } break; case 2: graphic.DrawString(Text, font, new SolidBrush(Color.Blue), x--, 1); if (x < Text.Length * -6) { x = 9; mode = 0; } Thread.Sleep((int)(100 - (DateTime.Now.Ticks - t1) / 10000)); break; } graphic.Flush(); } }