title: Kivy: How to increment and decrement the count based on the mouse movement (on_touch_move)?
body: <p>I would like to be able to display a counter value (0-360) in the middle of a circular knob, and then it will increment and decrement based on the on_touch_move event. As of now, I'm able to increase the value regardless the on_touch_move (counter clockwise or clockwise), but not sure how to set a maximum value and how I can decrement the value when on_touch_move is going downward. Not sure how this can be achieved in Kivy. I have done some research but couldn't figure out how to do it, here's the code I have so far: </p>
  
  <pre><code>from kivy.app import App
  from kivy.uix.label import Label
  from kivy.uix.widget import Widget
  from kivy.lang import Builder
  from kivy.animation import Animation
  from kivy.properties import NumericProperty
  from kivy.uix.boxlayout import BoxLayout
  from kivy.config import Config
  from kivy.core.window import Window
  Window.size = (781.274, 599)
  import math
  kv = '''
  &lt;Dial&gt;
      canvas:
          PushMatrix
          Rotate:
              angle: root.angle
              origin: self.center            
          Color:
              rgb: 255,0,0            
          Line:
              circle:self.center_x, self.center_y, 112, 19, self.angle % -180
              width: 11        
          Color:
              rgb: 0,0,255    
          Line:
              circle:self.center_x, self.center_y, 112, 19, self.angle % 180
              width: 11
          Color:
              rgb: 255,255,255    
          Line:
              circle:self.center_x, self.center_y, 200, 500, self.angle % 45
              width: 10
          Color:
              rgba: .1, 1, .1, .9
          Line:
              width: 2
              circle:
                  (self.center_x, self.center_y, min(self.width, self.height)/ 8.5,)           
          Color:
              rgba: .502,.502,.502,1
          Ellipse: 
              pos: (850,410)
              size: (214,214)
          PopMatrix                      
  '''
  Builder.load_string(kv)
  class Dial(Widget):
      def __init__(self, **kwargs):
          super(Dial, self).__init__(**kwargs)
          self.touch_move_count = 0
          self.touch_move_Label = Label(text = " RPM", pos=(905,470), font_size=40, color=(10,10,255,1), halign="auto")
          self.update_count()
          self.add_widget(self.touch_move_Label)
      angle = NumericProperty(180)
      def update_count(self):
          self.touch_move_Label.text = str(self.touch_move_count) + "°F"
      def on_touch_down(self, touch):
          y = (touch.y - self.center[1])
          x = (touch.x - self.center[0])
          calc = math.degrees(math.atan2(y, x))
          self.prev_angle = calc if calc &gt; 0 else 360 + calc
          self.tmp = self.angle
      def on_touch_move(self, touch):
          y = (touch.y - self.center[1])
          x = (touch.x - self.center[0])
          calc = math.degrees(math.atan2(y, x))
          new_angle = calc if calc &gt; 0 else 360 + calc
          self.angle = self.tmp + (new_angle - self.prev_angle) % 360
          self.touch_move_count +=1
          self.update_count()
  class DialApp(App):
      def build(self):
          return Dial()
  if __name__ == "__main__":
      DialApp().run() 
  </code></pre>