Exemplo n.º 1
0
        protected void Rotary_Rotated(object sender, RotaryTurnedEventArgs e)
        {
            //Debug.Print("Rotated " + ((e.Direction == RotationDirection.Clockwise) ? "clockwise." : "counter-clockwise."));

            // if clockwise, turn it up! clamp to 1, so we don't go over.
            if (e.Direction == RotationDirection.Clockwise)
            {
                if (this._led.Brightness >= 1)
                {
                    return;
                }
                else
                {
                    this._led.SetBrightness((this._led.Brightness + _brightnessStepChange).Clamp(0, 1));
                }
            }
            else     // otherwise, turn it down. clamp to 0 so we don't go below.
            {
                if (this._led.Brightness <= 0)
                {
                    return;
                }
                else
                {
                    this._led.SetBrightness((this._led.Brightness - _brightnessStepChange).Clamp(0, 1));
                }
            }
        }
Exemplo n.º 2
0
    void RotaryYRotated(object sender, RotaryTurnedEventArgs e)
    {
        if (e.Direction == RotationDirection.Clockwise)
        {
            y++;
        }
        else
        {
            y--;
        }

        if (y > 239)
        {
            y = 239;
        }
        else if (y < 0)
        {
            y = 0;
        }

        graphics.DrawPixel(x + 1, y, Color.Red);
        graphics.DrawPixel(x, y, Color.Red);
        graphics.DrawPixel(x - 1, y, Color.Red);
        graphics.Show();
    }
Exemplo n.º 3
0
    void RotaryXRotated(object sender, RotaryTurnedEventArgs e)
    {
        if (e.Direction == RotationDirection.Clockwise)
        {
            x++;
        }
        else
        {
            x--;
        }

        if (x > 239)
        {
            x = 239;
        }
        else if (x < 0)
        {
            x = 0;
        }

        graphics.DrawPixel(x, y + 1, Color.Red);
        graphics.DrawPixel(x, y, Color.Red);
        graphics.DrawPixel(x, y - 1, Color.Red);
        graphics.Show();
    }
 protected override void HandleRotated(object sender, RotaryTurnedEventArgs e)
 {
     if (e.Direction == RotationDirection.Clockwise)
     {
         DoNext();
     }
     else
     {
         DoPrevious();
     }
 }
Exemplo n.º 5
0
        private void HandlEncoderRotation(object sender, RotaryTurnedEventArgs e)
        {
            bool moved = false;

            if (e.Direction == RotationDirection.Clockwise)
            {
                moved = this.MoveNext();
            }
            else
            {
                moved = this.MovePrevious();
            }

            if (!moved)
            {
                // play a sound?
                Console.WriteLine("end of items");
            }
        }
Exemplo n.º 6
0
 private void HandleRotated(object sender, RotaryTurnedEventArgs e)
 {
     if (e.Direction == RotationDirection.Clockwise)
     {
         if (_pos == 0)
         {
             if (_numberParts[_pos] < _max)
             {
                 _numberParts[_pos]++;
             }
             else
             {
                 _numberParts[_pos + 1] = 0;
             }
         }
         else
         {
             if (_numberParts[_pos - 1] != _max && _numberParts[_pos] < (InputHelpers.Exp(10, _scale) - 1))
             {
                 _numberParts[_pos]++;
             }
         }
     }
     else
     {
         if (_pos == 0)
         {
             if (_numberParts[_pos] > _min)
             {
                 _numberParts[_pos]--;
             }
         }
         else
         {
             if (_numberParts[_pos] > 0)
             {
                 _numberParts[_pos]--;
             }
         }
     }
     RewriteInputLine(NumericDisplay);
 }
Exemplo n.º 7
0
        private void HandleRotated(object sender, RotaryTurnedEventArgs e)
        {
            int min = 0, max = 0;

            if (_pos == 0)
            {
                if (_timeMode == TimeMode.HH_MM_SS)
                {
                    max = 23;
                }
                if (_timeMode == TimeMode.HH_MM)
                {
                    max = 23;
                }
                if (_timeMode == TimeMode.MM_SS)
                {
                    max = 59;
                }
            }
            else
            {
                max = 59;
            }

            if (e.Direction == RotationDirection.Clockwise)
            {
                if (_timeParts[_pos] < max)
                {
                    _timeParts[_pos]++;
                }
            }
            else
            {
                if (_timeParts[_pos] > min)
                {
                    _timeParts[_pos]--;
                }
            }

            RewriteInputLine(TimeDisplay);
        }
Exemplo n.º 8
0
        void RotaryEncoderRotated(object sender, RotaryTurnedEventArgs e)
        {
            Console.WriteLine("Hey");

            if (e.Direction == RotationDirection.Clockwise)
            {
                percentage += 0.05f;
            }
            else
            {
                percentage -= 0.05f;
            }

            if (percentage > 1f)
            {
                percentage = 1f;
            }
            else if (percentage < 0f)
            {
                percentage = 0f;
            }

            ledBarGraph.Percentage = percentage;
        }
Exemplo n.º 9
0
        void RotaryEncoderRotated(object sender, RotaryTurnedEventArgs e)
        {
            if (e.Direction == RotationDirection.Clockwise)
            {
                this.percentage += 0.05f;
            }
            else
            {
                this.percentage -= 0.05f;
            }

            if (this.percentage > 1f)
            {
                this.percentage = 1f;
            }
            else if (percentage < 0f)
            {
                this.percentage = 0f;
            }

            this.ledBarGraph.Percentage = this.percentage;

            Console.WriteLine($"Percentage is {this.percentage}");
        }
Exemplo n.º 10
0
 protected abstract void HandleRotated(object sender, RotaryTurnedEventArgs e);