             label.centerYAnchor.constraint(equalTo: self.centerYAnchor)
         ])
 
-        tapGestureRecognizer = UILongPressGestureRecognizer(target: self, action: #selector(pinTapped))
-        tapGestureRecognizer.minimumPressDuration = 0
+        longTapGestureRecognizer = UILongPressGestureRecognizer(target: self, action: #selector(pinLongTapped))
+        longTapGestureRecognizer.minimumPressDuration = 1.0
+        longTapGestureRecognizer.cancelsTouchesInView = false
+        longTapGestureRecognizer.isEnabled = false
+
+        tapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(pinTapped))
         tapGestureRecognizer.cancelsTouchesInView = false
         tapGestureRecognizer.isEnabled = true
+        tapGestureRecognizer.delegate = self
+
+        self.addGestureRecognizer(longTapGestureRecognizer)
         self.addGestureRecognizer(tapGestureRecognizer)
     }
 
+    func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRequireFailureOf otherGestureRecognizer: UIGestureRecognizer) -> Bool {
+        if (gestureRecognizer == self.tapGestureRecognizer) && (otherGestureRecognizer == self.longTapGestureRecognizer) {
+            return true
+        }
+
+        return false
+    }
 
     @objc func pinTapped(sender: UIGestureRecognizer) {
-        switch (sender.state) {
-            case .began:
-                self.touchStartTime = Date()
-                UIView.animate(withDuration: 0.25) { () -> Void in
-                    self.button.alpha = 0.25
-                }
-            case .ended:
-                if let startTime = self.touchStartTime {
-                    if abs(startTime.timeIntervalSinceNow) >= 1.0
-                    {
-                        self.delegate?.pinViewLongTapped(pinView: self)
-                    } else {
-                        self.delegate?.pinViewTapped(pinView: self)
-                    }
-                }
-                self.touchStartTime = nil
-                UIView.animate(withDuration: 0.25) { () -> Void in
-                    self.button.alpha = 1.0
-                }
-            case .cancelled, .failed:
-                self.touchStartTime = nil
-                UIView.animate(withDuration: 0.25) { () -> Void in
-                    self.button.alpha = 1.0
-                }
-            case .changed:
-                let touchLocation = sender.location(in: self)
-
-                if !self.bounds.contains(touchLocation) {
-                    sender.isEnabled = false
-                    sender.isEnabled = true
-                }
-            case .possible:
-                //do nothing
-                break
-        }
-    }
+        NSLog("sender.state.rawValue = \(sender.state.rawValue)")
+        if (sender.state == .ended) {
+            self.pinShortTapped()
+        }
+    }
+
+    private func pinShortTapped() {
+        if let selectedFunction = self.selectedFunction {
+            if (selectedFunction.contains(.analogRead) || selectedFunction.contains(.digitalRead)) {
+//                self.delegate?.pinDidRequestToReadValue(self)
+            } else if (selectedFunction.contains(.analogWriteDAC) || selectedFunction.contains(.analogWritePWM)) {
+//                self.delegate?.pinDidRequestToHighlightPin(self)
+            } else if (selectedFunction.contains(.digitalWrite)) {
+//                self.delegate?.pinDidRequestToToggleValue(self)
+            }
+        } else {
+            self.delegate?.pinDidRequestToSelectFunction(self)
+        }
+    }
+
+
+    @objc func pinLongTapped(sender: UIGestureRecognizer) {
+        if (sender.state == .began) {
+            self.selectedFunction = nil
+            self.update()
+        }
+    }
+
+    func update() {
+        if let function = self.selectedFunction {
+            self.longTapGestureRecognizer.isEnabled = true
+
+            self.outerPieValueView.isHidden = false
+            self.outerPieFrameView.isHidden = false
+
+            self.outerPieValueView.pieFillColor = function.getColor()
+            self.outerPieFrameView.pieBorderColor = function.getColor()
+
+            switch function {
+                case DevicePinFunction.analogWritePWM:
+                    self.outerPieValueView.progress = 1
+                case DevicePinFunction.analogWriteDAC:
+                    self.outerPieValueView.progress = 1
+                case DevicePinFunction.analogRead:
+                    self.outerPieValueView.progress = 1
+                default:
+                    self.outerPieValueView.progress = 1
+            }
+
+        } else {
+            self.longTapGestureRecognizer.isEnabled = false
+
+            self.outerPieValueView.isHidden = true
+            self.outerPieFrameView.isHidden = true
+        }
+    }
+
 
     func beginUpdating() {
         self.alpha = 0.35

//    }


}

    }

    func setup() {
        outerPieValueView = PieProgressView(frame: .zero)
        outerPieValueView.translatesAutoresizingMaskIntoConstraints = false
        outerPieValueView.backgroundColor = UIColor.clear
        outerPieValueView.pieBackgroundColor = UIColor.clear
        outerPieValueView.progress = 1
        outerPieValueView.pieBorderWidth = 0
        outerPieValueView.pieFillColor = UIColor.white // will change
        outerPieValueView.isHidden = true
        addSubview(outerPieValueView)
        NSLayoutConstraint.activate([
