 (def service-id "00ff")
 (def characteristic-id "ff01")
 
-(defn control-button [label on-press on-release]
+(defn touch-button [label on-press on-release]
   [v.common/touchable-highlight
    {:style {:background-color "#494" :width 100 :height 100 :margin 5 :border-radius 5}
     :justify-content "center"

             (:name @current-device)]
            [v.common/text (:id @current-device)]]
         (if @connected?
           [v.common/view {:style {:align-content "center" :align-self "center"}}
            [v.common/view {:style {:flex-direction "row"}}
             [control-button "left forward"  #(ble-send @current-device :rf 255)]
             [control-button "forward"       #(ble-send @current-device :lf 255 :rf 255)]
             [control-button "right-forward" #(ble-send @current-device :lf 255)]]
            [v.common/view {:style {:flex-direction "row"}}
             [control-button "turn left"     #(ble-send @current-device :lb 255 :rf 255)]
             [control-button "stop"          #(ble-send @current-device)]
             [control-button "trun right"    #(ble-send @current-device :lf 255 :rb 255)]]
            [v.common/view {:style {:flex-direction "row"}}
             [control-button "back left"     #(ble-send @current-device :rb 255)]
             [control-button "back"          #(ble-send @current-device :lb 255 :rb 255)]
             [control-button "back right"    #(ble-send @current-device :lb 255)]]]
           [v.common/view {:style {:align-content "center" :align-self "center"}}
            [v.common/text "connecting"]])])
      :component-will-mount (fn []

   [v.common/text {:style {:color "#fff" :text-align "center" :height 100}}
    label]])

(defn ble-send [device & [{:keys [lf lb rf rb]}]]
  (let [data (map #(if (nil? %) 0 %) [lf lb rf rb])]
    (ble/write (:id device) service-id characteristic-id data)))

(defn tile-buttons []
  (let [current-device (subscribe [:get-current-device])
        stop #(ble-send @current-device)
        control-button (fn [label signals]
                             [touch-button label #(ble-send @current-device signals) stop])]
    [v.common/view {:style {:align-content "center" :align-self "center"}}
     [v.common/view {:style {:flex-direction "row"}}
      [control-button "left foreward" {:rf 255}]
      [control-button "forward"       {:lf 255 :rf 255}]
      [control-button "right-forward" {:lf 255}]]
     [v.common/view {:style {:flex-direction "row"}}
      [control-button "turn left"     {:lb 255 :rf 255}]
      [v.common/view {:style {:width 100 :height 100 :margin 5}}]
      [control-button "trun right"    {:lf 255 :rb 255}]]
     [v.common/view {:style {:flex-direction "row"}}
      [control-button "back left"     {:rb 255}]
      [control-button "back"          {:lb 255 :rb 255}]
      [control-button "back right"    {:lb 255}]]]))

(defn ble-control-page []
  (let [current-device (subscribe [:get-current-device])
