public ModeContext( RotaryEncoder re) { this.State = new RPMMode(this); rotaryEncoderInstance = re; re.RotationEventHandler += OnRotationEvent;//attach to Context's Handler rotationCount = 0; }
public MeadowApp() { var led = new RgbLed(Device, Device.Pins.OnboardLedRed, Device.Pins.OnboardLedGreen, Device.Pins.OnboardLedBlue); led.SetColor(RgbLed.Colors.Red); shiftRegister = new x74595(Device, Device.CreateSpiBus(), Device.Pins.D00, 8); shiftRegister.Clear(); IDigitalOutputPort[] ports = { Device.CreateDigitalOutputPort(Device.Pins.D14), Device.CreateDigitalOutputPort(Device.Pins.D15), shiftRegister.CreateDigitalOutputPort(shiftRegister.Pins.GP0,false, OutputType.PushPull), shiftRegister.CreateDigitalOutputPort(shiftRegister.Pins.GP1,false, OutputType.PushPull), shiftRegister.CreateDigitalOutputPort(shiftRegister.Pins.GP2,false, OutputType.PushPull), shiftRegister.CreateDigitalOutputPort(shiftRegister.Pins.GP3,false, OutputType.PushPull), shiftRegister.CreateDigitalOutputPort(shiftRegister.Pins.GP4,false, OutputType.PushPull), shiftRegister.CreateDigitalOutputPort(shiftRegister.Pins.GP5,false, OutputType.PushPull), shiftRegister.CreateDigitalOutputPort(shiftRegister.Pins.GP6,false, OutputType.PushPull), shiftRegister.CreateDigitalOutputPort(shiftRegister.Pins.GP7,false, OutputType.PushPull), }; ledBarGraph = new LedBarGraph(ports); ledBarGraph.Percentage = 1; rotaryEncoder = new RotaryEncoder(Device, Device.Pins.D02, Device.Pins.D03); //Device.CreateDigitalInputPort(Device.Pins.D02, InterruptMode.EdgeRising, ResistorMode.InternalPullUp, 0, 5), //Device.CreateDigitalInputPort(Device.Pins.D03, InterruptMode.EdgeRising, ResistorMode.InternalPullUp, 0, 5)); rotaryEncoder.Rotated += RotaryEncoderRotated; led.SetColor(RgbLed.Colors.Green); }
public static RotaryEncoderApplication BuildRotaryEncoder(ID appId, RotaryEncoder rotEnc, ushort inputRessource, ID targetAppId) { return(new RotaryEncoderApplication { ApplicationId = appId.ToString(), InputRotaryRessource = rotEnc, InputPushRessource = inputRessource, CommandsOnPressed = new List <Command> { new Command { TargetAppId = targetAppId.ToString(), CommandType = CommandType.TOGGLE, } }, CommandsOnTurned = new List <Command> { new Command { TargetAppId = targetAppId.ToString(), CommandType = CommandType.STEP_VERTICAL, } } }); }
public async Task Run() { var board = await ConnectionService.Instance.GetFirstDeviceAsync(); await board.ConnectAsync(); var driver = new Apa102(board.Spi, 32); driver.AutoFlush = false; var encoder = new RotaryEncoder(board.Pins[13], board.Pins[12], 4); long oldPosition = 0; encoder.PositionChanged += async(s, e) => { var encoderAngle = 360 * e.NewPosition / 20f; // 20 clicks per rotation for (int i = 0; i < driver.Leds.Count; i++) { driver.Leds[i].SetHsl((360f / driver.Leds.Count) * i + encoderAngle, 100, 5); } await driver.FlushAsync(); if (e.NewPosition > oldPosition) { mouse_event(0x0800, 0, 0, -120, 0); } if (e.NewPosition < oldPosition) { mouse_event(0x0800, 0, 0, 120, 0); } oldPosition = e.NewPosition; }; }
public MeadowApp() { var led = new RgbLed(Device, Device.Pins.OnboardLedRed, Device.Pins.OnboardLedGreen, Device.Pins.OnboardLedBlue); led.SetColor(RgbLed.Colors.Red); servo = new Servo(Device.CreatePwmPort(Device.Pins.D08), NamedServoConfigs.SG90); servo.RotateTo(0); rotaryEncoder = new RotaryEncoder(Device, Device.Pins.D02, Device.Pins.D03); rotaryEncoder.Rotated += (s, e) => { if (e.Direction == Meadow.Peripherals.Sensors.Rotary.RotationDirection.Clockwise) { angle++; } else { angle--; } if (angle > 180) { angle = 180; } else if (angle < 0) { angle = 0; } servo.RotateTo(angle); }; led.SetColor(RgbLed.Colors.Green); }
void InitGPIO() { var gpio = GpioController.GetDefault(); // Show an error if there is no GPIO controller if (gpio == null) { GpioStatus.Text = "There is no GPIO controller on this device."; return; } _pinA = gpio.OpenPin(DT); _pinB = gpio.OpenPin(CLK); _pinC = gpio.OpenPin(SW); _pinA.SetDriveMode(GpioPinDriveMode.Input); _pinB.SetDriveMode(GpioPinDriveMode.Input); _pinC.SetDriveMode(GpioPinDriveMode.Input); _encoder = new RotaryEncoder { ClockPin = _pinB, DirectionPin = _pinA, ButtonPin = _pinC }; _encoder.Rotated += EncoderOnRotated; GpioStatus.Text = "GPIO pin initialized correctly."; }
public RotaryEncoderApp() { Console.WriteLine("Initializing..."); rotaryEncoder = new RotaryEncoder(Device, Device.Pins.D00, Device.Pins.D01); rotaryEncoder.Rotated += RotaryEncoderRotated; Console.WriteLine("Start rotating the encoder..."); }
/// <summary> /// Perform action based on Serial input /// </summary> /// <param name="msg">The Serial input message</param> public static void PerformAction(string msg) { // Check if the received message is not empty: if (msg == "") { return; } if (!msg.Contains(":")) { return; } string[] data = msg.Split(':'); string id = data[0]; string state = data[1]; //PushButtonEvents if (id.StartsWith(PushButton.PushButtonIdentifier)) { id.Replace(PushButton.PushButtonIdentifier, ""); if (!InputDataMapping.HasInitializedAsMatrix) { int btnId = int.Parse(id); PushButton btn = InputDataMapping.PushButtons.Find(e => e.Identifier == btnId); btn.UpdateState(MathHelper.BoolFromInt(int.Parse(state))); Console.WriteLine(btn.Identifier + " " + btn.IsPressed); } else { int i = 0; foreach (char c in state.TrimEnd()) { // Update PushButton's state for each button: PushButton btn = InputDataMapping.PushButtons.Find(e => e.Identifier == i); btn.UpdateState(MathHelper.BoolFromChar(c)); i++; } } } else if (id.StartsWith(RotaryEncoder.RotaryEncoderIdentifier)) //Encoder events { int encId = int.Parse(id.Replace(RotaryEncoder.RotaryEncoderIdentifier, "")); RotaryEncoder enc = InputDataMapping.RotaryEncoders.Find(e => e.ComponentIdentifier == encId); enc.UpdateValue(long.Parse(state)); } else if (id.StartsWith(RotaryEncoder.RotaryEncoderButtonIdentifier)) { int encId = int.Parse(id.Replace(RotaryEncoder.RotaryEncoderButtonIdentifier, "")); RotaryEncoder enc = InputDataMapping.RotaryEncoders.Find(e => e.ComponentIdentifier == encId); enc.UpdateButtonState(MathHelper.BoolFromInt(int.Parse(state))); } //TODO add knobs here else { Console.WriteLine("Unknown action: {0}", msg); } }
public static void Main() { // Initializes a new rotary encoder object RotaryEncoder Knob = new RotaryEncoder(Pins.GPIO_PIN_D0, Pins.GPIO_PIN_D1); // Bounds the event to the rotary encoder Knob.Rotated += new NativeEventHandler(Knob_Rotated); // Wait infinitely Thread.Sleep(Timeout.Infinite); }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Use this to return your custom view for this Fragment View outerView = base.OnCreateView(inflater, container, savedInstanceState); View view = inflater.Inflate(Resource.Layout.fragment_weather_details, outerView as ViewGroup, true); outerView.FocusableInTouchMode = true; outerView.GenericMotion += (sender, e) => { if (e.Event.Action == MotionEventActions.Scroll && RotaryEncoder.IsFromRotaryEncoder(e.Event)) { // Don't forget the negation here float delta = -RotaryEncoder.GetRotaryAxisValue(e.Event) * RotaryEncoder.GetScaledScrollFactor(Activity); // Swap these axes if you want to do horizontal scrolling instead scrollView.ScrollBy(0, (int)Math.Round(delta)); e.Handled = true; } e.Handled = false; }; scrollView = view.FindViewById <NestedScrollView>(Resource.Id.scrollView); // Details detailsPanel = view.FindViewById(Resource.Id.details_panel); humidity = view.FindViewById <TextView>(Resource.Id.humidity); pressureState = view.FindViewById <TextView>(Resource.Id.pressure_state); pressure = view.FindViewById <TextView>(Resource.Id.pressure); visiblity = view.FindViewById <TextView>(Resource.Id.visibility_val); feelslike = view.FindViewById <TextView>(Resource.Id.feelslike); windDirection = view.FindViewById <TextView>(Resource.Id.wind_direction); windSpeed = view.FindViewById <TextView>(Resource.Id.wind_speed); sunrise = view.FindViewById <TextView>(Resource.Id.sunrise_time); sunset = view.FindViewById <TextView>(Resource.Id.sunset_time); // Additional Details precipitationPanel = view.FindViewById <RelativeLayout>(Resource.Id.precipitation_card); precipitationPanel.Visibility = ViewStates.Gone; chanceLabel = view.FindViewById <TextView>(Resource.Id.chance_label); chance = view.FindViewById <TextView>(Resource.Id.chance_val); cloudinessLabel = view.FindViewById <TextView>(Resource.Id.cloudiness_label); cloudiness = view.FindViewById <TextView>(Resource.Id.cloudiness); qpfRain = view.FindViewById <TextView>(Resource.Id.qpf_rain_val); qpfSnow = view.FindViewById <TextView>(Resource.Id.qpf_snow_val); // Cloudiness only supported by OWM cloudinessLabel.Visibility = ViewStates.Gone; cloudiness.Visibility = ViewStates.Gone; weatherCredit = view.FindViewById <TextView>(Resource.Id.weather_credit); return(outerView); }
public override bool OnGenericMotionEvent(MotionEvent ev) { if (ev.Action == MotionEventActions.Scroll && RotaryEncoder.IsFromRotaryEncoder(ev)) { float delta = -RotaryEncoder.GetRotaryAxisValue(ev) * RotaryEncoder.GetScaledScrollFactor(this.Context); this.Delta = Math.Clamp(delta, -PaddleView.RotationLimit, PaddleView.RotationLimit); return(true); } return(base.OnGenericMotionEvent(ev)); }
public MainPage() { this.InitializeComponent(); RotaryEncoder rotaryEncoder = new RotaryEncoder(); rotaryEncoder.DebounceTime = TimeSpan.FromTicks(1); rotaryEncoder.OpenPin(18, 25, 10); rotaryEncoder.RotaryValueChanged += RotaryEncoder_ValueChanged; rotaryEncoder.ButtonValueChanged += RotaryEncoder_ButtonValueChanged; }
static async Task App() { var board = await ConnectionService.Instance.GetFirstDeviceAsync(); await board.ConnectAsync(); var encoder = new RotaryEncoder(board.Pins[0], board.Pins[1], 4); encoder.MinValue = 0; encoder.MaxValue = 19; encoder.PositionChanged += Encoder_PositionChanged; }
protected new RotaryEncoder AddEncoder(string name, Point posn, Size size, string knobImage, double stepValue, double rotationStep, string interfaceDeviceName, string interfaceElementName, bool fromCenter, RotaryClickType clickType = RotaryClickType.Swipe) { if (fromCenter) { posn = FromCenter(posn, size); } string componentName = GetComponentName(name); RotaryEncoder knob = new RotaryEncoder { Name = componentName, KnobImage = knobImage, StepValue = stepValue, RotationStep = rotationStep, Top = posn.Y, Left = posn.X, Width = size.Width, Height = size.Height, ClickType = clickType }; Children.Add(knob); foreach (IBindingTrigger trigger in knob.Triggers) { AddTrigger(trigger, componentName); } foreach (IBindingAction action in knob.Actions) { if (action.Name != "hidden") { AddAction(action, componentName); } } AddDefaultOutputBinding( componentName, "encoder.incremented", interfaceDeviceName + ".increment." + interfaceElementName ); AddDefaultOutputBinding( componentName, "encoder.decremented", interfaceDeviceName + ".decrement." + interfaceElementName ); return(knob); }
private void AddEncoder(string name, Point posn, Size size, string interfaceElementName) { RotaryEncoder _enc = AddEncoder( name: name, size: size, posn: posn, knobImage: "{AV-8B}/Images/Fuel Bingo Knob.png", stepValue: 0.1, rotationStep: 5, interfaceDeviceName: _interfaceDeviceName, interfaceElementName: interfaceElementName, fromCenter: false ); _enc.Name = "Fuel Panel_" + name; }
public void OnDecreasePerformsActionWhenSet() { //arrange var increasePin = new StubPinInterface(1); var decreasePin = new StubPinInterface(2); var dial = new RotaryEncoder(increasePin, decreasePin); var called = false; dial.OnDecrease(() => called = true); //act decreasePin.Spike(); //assert Assert.True(called); }
public Game(RaspberryPi pi) { _cpuRed = pi.Pin11; _cpuYellow = pi.Pin13; _cpuGreen = pi.Pin15; _redButton = pi.Pin16; _yellowButton = pi.Pin18; _greenButton = pi.Pin22; _score1 = pi.Pin36; _score2 = pi.Pin38; _score3 = pi.Pin40; _difficultyDial = new RotaryEncoder(pi.Pin32, pi.Pin31); _random = new Random(); }
private void StartRotary() { // Create rotary var rotary = new RotaryEncoder() { ButtonPin = gpioController.OpenPin(26), ClockPin = gpioController.OpenPin(22), DirectionPin = gpioController.OpenPin(13), }; // Subscribe to events rotary.Click += Rotary_Click; rotary.Rotated += Rotary_Rotated; // Add to device list devices.Add(rotary); }
public static void Main() { // Defines all 16 LEDs linked to two 74HC595 ICs in a chain Ic74hc595 IcChain = new Ic74hc595(SPI_Devices.SPI1, Pins.GPIO_PIN_D10, 2); Led = IcChain.Pins; // Defines the rotary encoder RotaryEncoder Knob = new RotaryEncoder(Pins.GPIO_PIN_D0, Pins.GPIO_PIN_D1); Knob.Rotated += new NativeEventHandler(Knob_Rotated); // Links the event to the button Button.StateChanged += new AutoRepeatEventHandler(Button_StateChanged); // Wait infinitely Thread.Sleep(Timeout.Infinite); }
public MeadowApp() { this.onboardLed = new RgbPwmLed(Device, Device.Pins.OnboardLedRed, Device.Pins.OnboardLedGreen, Device.Pins.OnboardLedBlue, 3.3f, 3.3f, 3.3f, Meadow.Peripherals.Leds.IRgbLed.CommonType.CommonAnode); this.onboardLed.SetColor(Color.Red); this.shiftRegister = new x74595(Device, Device.CreateSpiBus(), Device.Pins.D00, 8); this.shiftRegister.Clear(); IDigitalOutputPort[] ports = { Device.CreateDigitalOutputPort(Device.Pins.D14), Device.CreateDigitalOutputPort(Device.Pins.D15), shiftRegister.CreateDigitalOutputPort( shiftRegister.Pins.GP0, false, OutputType.PushPull), shiftRegister.CreateDigitalOutputPort( shiftRegister.Pins.GP1, false, OutputType.PushPull), shiftRegister.CreateDigitalOutputPort( shiftRegister.Pins.GP2, false, OutputType.PushPull), shiftRegister.CreateDigitalOutputPort( shiftRegister.Pins.GP3, false, OutputType.PushPull), shiftRegister.CreateDigitalOutputPort( shiftRegister.Pins.GP4, false, OutputType.PushPull), shiftRegister.CreateDigitalOutputPort( shiftRegister.Pins.GP5, false, OutputType.PushPull), shiftRegister.CreateDigitalOutputPort( shiftRegister.Pins.GP6, false, OutputType.PushPull), shiftRegister.CreateDigitalOutputPort( shiftRegister.Pins.GP7, false, OutputType.PushPull), }; this.ledBarGraph = new LedBarGraph(ports); this.rotaryEncoder = new RotaryEncoder( Device, Device.Pins.D02, Device.Pins.D03); this.rotaryEncoder.Rotated += this.RotaryEncoderRotated; this.onboardLed.SetColor(Color.Green); }
protected RotaryEncoder AddEncoder(string name, Point posn, Size size, string knobImage, double stepValue, double rotationStep, string interfaceDeviceName, string interfaceElementName, bool fromCenter) { if (fromCenter) { posn = FromCenter(posn, size); } string componentName = GetComponentName(name); RotaryEncoder _knob = new RotaryEncoder { Name = componentName, KnobImage = knobImage, StepValue = stepValue, RotationStep = rotationStep, Top = posn.Y, Left = posn.X, Width = size.Width, Height = size.Height }; Children.Add(_knob); foreach (IBindingTrigger trigger in _knob.Triggers) { AddTrigger(trigger, componentName); } foreach (IBindingAction action in _knob.Actions) { AddAction(action, componentName); } AddDefaultOutputBinding( childName: componentName, deviceTriggerName: "encoder.incremented", interfaceActionName: interfaceDeviceName + ".increment." + interfaceElementName ); AddDefaultOutputBinding( childName: componentName, deviceTriggerName: "encoder.decremented", interfaceActionName: interfaceDeviceName + ".decrement." + interfaceElementName ); return(_knob); }
void Initialize() { Console.WriteLine("Initialize hardware..."); // this causes unterrupts to fail, for some reason: //IDigitalInputPort test = Device.CreateDigitalInputPort(Device.Pins.D07); // this does not. IDigitalOutputPort test = Device.CreateDigitalOutputPort(Device.Pins.D07); Console.WriteLine("Made it here."); button1 = new PushButton(Device, Device.Pins.D13, ResistorMode.InternalPullDown); button2 = new PushButton(Device, Device.Pins.D12, ResistorMode.InternalPullDown); button1.PressStarted += Button1_PressStarted; button1.PressEnded += Button1_PressEnded; button2.PressStarted += Button2_PressStarted; button2.PressEnded += Button2_PressEnded; motorDriver = new Tb67h420ftg(Device, inA1: Device.Pins.D04, inA2: Device.Pins.D03, pwmA: Device.Pins.D01, inB1: Device.Pins.D05, inB2: Device.Pins.D06, pwmB: Device.Pins.D00, fault1: Device.Pins.D02, fault2: Device.Pins.D07, hbMode: Device.Pins.D11, tblkab: Device.Pins.D10); // 6V motors with a 12V input. this clamps them to 6V motorDriver.Motor1.MotorCalibrationMultiplier = 0.5f; motorDriver.Motor2.MotorCalibrationMultiplier = 0.5f; Console.WriteLine("Init encoder"); encoder = new RotaryEncoder(Device, Device.Pins.D09, Device.Pins.D15); // encoder.Rotated += Encoder_Rotated; Console.WriteLine("Init display"); var ssd1306 = new Ssd1306(Device.CreateI2cBus(), 60, Ssd1306.DisplayType.OLED128x32); display = new GraphicsLibrary(ssd1306); display.CurrentFont = new Font8x12(); Console.WriteLine("Initialization complete."); UpdateDisplay("Initialization", "Complete"); }
public MeadowApp() { Console.WriteLine("Initializing..."); rotaryEncoder = new RotaryEncoder(Device, Device.Pins.D05, Device.Pins.D06); rotaryEncoder.Rotated += (s, e) => { if (e.Direction == Meadow.Peripherals.Sensors.Rotary.RotationDirection.Clockwise) { value--; Console.WriteLine("Value = {0} CCW", value); } else { value++; Console.WriteLine("Value = {0} CW", value); } }; Console.WriteLine("RotaryEncoder ready..."); }
public MeadowApp() { var onboardLed = new RgbPwmLed( device: Device, redPwmPin: Device.Pins.OnboardLedRed, greenPwmPin: Device.Pins.OnboardLedGreen, bluePwmPin: Device.Pins.OnboardLedBlue); onboardLed.SetColor(Color.Red); servo = new Servo(Device.CreatePwmPort(Device.Pins.D08), NamedServoConfigs.SG90); servo.RotateTo(new Angle(0, AU.Degrees)); rotaryEncoder = new RotaryEncoder(Device, Device.Pins.D02, Device.Pins.D03); rotaryEncoder.Rotated += (s, e) => { if (e.New == Meadow.Peripherals.Sensors.Rotary.RotationDirection.Clockwise) { angle += new Angle(1, AU.Degrees); } else { angle -= new Angle(1, AU.Degrees); } if (angle > new Angle(180, AU.Degrees)) { angle = new Angle(180, AU.Degrees); } else if (angle < new Angle(0, AU.Degrees)) { angle = new Angle(0, AU.Degrees); } servo.RotateTo(angle); }; onboardLed.SetColor(Color.Green); }
public static void Main() { // Defines all 16 LEDs linked to two 74HC595 ICs in a chain Ic74HC595Chain IcChain = new Ic74HC595Chain(SPI_Devices.SPI1, Pins.GPIO_PIN_D10, 2); Ic74HC595 Ic1 = new Ic74HC595(IcChain, 0); Ic74HC595 Ic2 = new Ic74HC595(IcChain, 1); for (int Counter = 0; Counter < 8; ++Counter) { Led[Counter] = new OutputPortShift(Ic1, (Ic74HC595.Pins)Counter, true); Led[Counter + 8] = new OutputPortShift(Ic2, (Ic74HC595.Pins)Counter, true); } // Defines the rotary encoder RotaryEncoder Knob = new RotaryEncoder(Pins.GPIO_PIN_D0, Pins.GPIO_PIN_D1); Knob.Rotated += new NativeEventHandler(Knob_Rotated); // Links the event to the button Button.StateChanged += new AutoRepeatEventHandler(Button_StateChanged); // Wait infinitely Thread.Sleep(Timeout.Infinite); }
void Initialize() { var onboardLed = new RgbPwmLed( device: Device, redPwmPin: Device.Pins.OnboardLedRed, greenPwmPin: Device.Pins.OnboardLedGreen, bluePwmPin: Device.Pins.OnboardLedBlue); onboardLed.SetColor(Color.Red); motor = new HBridgeMotor ( device: Device, a1Pin: Device.Pins.D05, a2Pin: Device.Pins.D06, enablePin: Device.Pins.D09 ); motor.Power = 0f; rotary = new RotaryEncoder(Device, Device.Pins.D02, Device.Pins.D03); rotary.Rotated += RotaryRotated; onboardLed.SetColor(Color.Green); }
void Initialize() { Console.WriteLine("Initialize hardware..."); onboardLed = new RgbPwmLed(device: Device, redPwmPin: Device.Pins.OnboardLedRed, greenPwmPin: Device.Pins.OnboardLedGreen, bluePwmPin: Device.Pins.OnboardLedBlue, 3.3f, 3.3f, 3.3f, Meadow.Peripherals.Leds.IRgbLed.CommonType.CommonAnode); bus = Device.CreateI2cBus(400000); pca = new Pca9685(bus, 64, 500); pca.Initialize(); lPwm = pca.CreatePwmPort(14, 0); rPwm = pca.CreatePwmPort(15, 0); currentPort = rPwm; encoder = new RotaryEncoder(Device, Device.Pins.D15, Device.Pins.D11); encoder.Rotated += Encoder_Rotated; }
public Scii() { _lcdDisplay = new CharDisplay(); PrintScreen("Schedulon II", "by Technomad LLC"); Thread.Sleep(1000); PrintScreen("Audio.", " Anywhere."); Thread.Sleep(1000); _lcdDisplay.Clear(); PrintScreen("Schedulon II"); Log.LogFileName = Settings.FileSystem.RootDir + Settings.FileSystem.SystemDir + @"log\logfile.txt"; Log.InsertBlankLine(); Log.WriteString(LogMessageType.Info, "Application start"); IRotaryEncoder rotaryEncoder = new RotaryEncoder(); IAudioRecordPlayer audioplayer = new AudioPlayer(); var audioCore = new AudioCore(audioplayer); audioCore.NowPlaying += OnNowPlaying; audioCore.NowRecording += OnNowRecording; var lcm = new LocalControlModule(_lcdDisplay, rotaryEncoder, audioCore); var schedulingCore = new SchedulingCore(audioCore, _lcdDisplay, lcm); var knobSet = new KnobSet(rotaryEncoder, _lcdDisplay, audioCore, schedulingCore, lcm); var fileCore = new FileCore(); try { Settings.Load(); } catch (Exception e) { Log.WriteException(e, "Error loading system settings. System locked"); PrintScreen("System halted", "Settings error"); Thread.Sleep(Timeout.Infinite); } if (Settings.Web.UseLlmnr) { _llmnr = new LinkLocalMultiCastNameResolution("Schedulon"); _llmnr.Start(IPAddress.Parse("10.0.0.110")); } var webServer = new WebServer(schedulingCore, knobSet, audioCore, fileCore); var webserverThread = new Thread(webServer.Run); webserverThread.Start(); }
public void RequestEncoder(RotaryEncoder action) { PendingCommands.Add(new UsbCommand((byte)action)); }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment View view = inflater.Inflate(Resource.Layout.fragment_weather_now, container, false); view.FocusableInTouchMode = true; view.GenericMotion += (sender, e) => { if (e.Event.Action == MotionEventActions.Scroll && RotaryEncoder.IsFromRotaryEncoder(e.Event)) { // Don't forget the negation here float delta = -RotaryEncoder.GetRotaryAxisValue(e.Event) * RotaryEncoder.GetScaledScrollFactor(Activity); // Swap these axes if you want to do horizontal scrolling instead scrollView.ScrollBy(0, (int)Math.Round(delta)); e.Handled = true; } e.Handled = false; }; refreshLayout = (SwipeRefreshLayout)view; scrollView = view.FindViewById <NestedScrollView>(Resource.Id.fragment_weather_now); // Condition locationName = view.FindViewById <TextView>(Resource.Id.label_location_name); updateTime = view.FindViewById <TextView>(Resource.Id.label_updatetime); weatherIcon = view.FindViewById <TextView>(Resource.Id.weather_icon); weatherCondition = view.FindViewById <TextView>(Resource.Id.weather_condition); weatherTemp = view.FindViewById <TextView>(Resource.Id.weather_temp); // SwipeRefresh refreshLayout.SetColorSchemeColors(ContextCompat.GetColor(Activity, Resource.Color.colorPrimary)); refreshLayout.Refresh += delegate { Task.Run(async() => { if (Settings.FollowGPS && await UpdateLocation()) { // Setup loader from updated location wLoader = new WeatherDataLoader(this.location, this, this); } await RefreshWeather(true); }); }; weatherCredit = view.FindViewById <TextView>(Resource.Id.weather_credit); loaded = true; refreshLayout.Refreshing = true; timer = new System.Timers.Timer(30000); // 30sec timer.Elapsed += async(sender, e) => { // We hit the interval // Data syncing is taking a long time to setup // Stop and load saved data await CancelDataSync(); }; return(view); }
public App() { // instantiate our peripherals this._rotary = new RotaryEncoder(N.Pins.GPIO_PIN_D6, N.Pins.GPIO_PIN_D7); this._led = new PwmLed(N.PWMChannels.PWM_PIN_D11, TypicalForwardVoltage.Green); }