/// <summary>
        /// This event is called when the left button is pressed.  The left button can only be used
        /// to cycle through display pages.  A long press is used to change the display contrast.
        /// </summary>
        /// <param name="sender">ignored</param>
        /// <param name="args">button state</param>
        private void leftButton_OnInterrupt(object sender, AutoRepeatEventArgs args)
        {
            switch (args.State)
            {
            case AutoRepeatInputPort.AutoRepeatState.Press:
                this.longLeftPress = false;
                break;

            case AutoRepeatInputPort.AutoRepeatState.Tick:
                this.longLeftPress = true;
                CycleContrast();
                break;

            case AutoRepeatInputPort.AutoRepeatState.Release:
                if (!this.longLeftPress)
                {
                    lock (this.oled)
                    {
                        this.pages[this.currentPageIndex].Hidden();
                        this.currentPageIndex = (this.currentPageIndex + 1) % this.pages.Length;
                        this.oled.ClearDisplay();
                        this.pages[this.currentPageIndex].Visible();
                    }
                }
                break;
            }
        }
Exemplo n.º 2
0
 static void Button_StateChanged(object sender, AutoRepeatEventArgs e)
 {
     // We will only change when the button gets pressed
     if (Button.Read())
     {
         return;
     }
     // Toggles Red
     Red.Write(!Red.Read());
     // Makes green invert Red
     Green.Write(!Red.Read());
 }
Exemplo n.º 3
0
        /// <summary>
        /// Triggered when a button is pressed, still pressed, or released
        /// </summary>
        /// <param name="Sender">The AutoRepeatInputPort object</param>
        /// <param name="EventArgs">Event arguments</param>
        static void Button_StateChanged(object Sender, AutoRepeatEventArgs EventArgs)
        {
            switch (EventArgs.State)
            {
            case AutoRepeatInputPort.AutoRepeatState.Press:
                Debug.Print("Pressed");
                break;

            case AutoRepeatInputPort.AutoRepeatState.Release:
                Debug.Print("Released");
                break;

            case AutoRepeatInputPort.AutoRepeatState.Tick:
                Debug.Print("Tick-Tock Goes the Clock");
                break;
            }
        }
Exemplo n.º 4
0
        public void ButtonEvent(object sender, AutoRepeatEventArgs e)
        {
            switch (e.State)
            {
            case AutoRepeatInputPort.AutoRepeatState.Press:
                this.longPress = false;
                ButtonPress();
                break;

            case AutoRepeatInputPort.AutoRepeatState.Tick:
                this.longPress = true;
                ButtonTick();
                break;

            case AutoRepeatInputPort.AutoRepeatState.Release:
                ButtonRelease(this.longPress);
                break;
            }
        }
 /// <summary>
 /// This method is called when the right button is pressed.  It is passed to the display
 /// page.
 /// </summary>
 /// <param name="sender">ignored</param>
 /// <param name="args">button state</param>
 void rightButton_OnInterrupt(object sender, AutoRepeatEventArgs args)
 {
     this.pages[this.currentPageIndex].ButtonEvent(sender, args);
 }