Skip to content

Commit

Permalink
init clj project
Browse files Browse the repository at this point in the history
  • Loading branch information
akiroz committed Aug 12, 2016
1 parent bffeaba commit 3f54813
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 30 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

node_modules/
target/

.DS_Store
._*
22 changes: 0 additions & 22 deletions embedded/index.js

This file was deleted.

8 changes: 0 additions & 8 deletions embedded/package.json

This file was deleted.

9 changes: 9 additions & 0 deletions embedded/project.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
(defproject com.oursky/doorlock "1.0.0-SNAPSHOT"
:min-lein-version "2.0.0"
:dependencies [[org.clojure/clojure "1.8.0"]
[org.clojure/core.async "0.2.385"]
[com.taoensso/timbre "4.7.0"]
[clj-gpio "0.2.0"]
]
:profiles {:uberjar {:aot :all}}
:main com.oursky.doorlock.core)
27 changes: 27 additions & 0 deletions embedded/src/com/oursky/doorlock/core.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
(ns com.oursky.doorlock.core
(:require [taoensso.timbre :as log]
[gpio.core :refer [open-port open-channel-port write-value! toggle!]]
[clojure.java.shell :refer [sh]]
[clojure.core.async :refer [<! go-loop timeout]]
))

; setup GPIO via wiringpi CLI interface
; the clj-gpio library does not support internal pull-up
(sh "gpio" "mode" "0" "up")
(sh "gpio" "mode" "1" "out")

(def button-chan (open-channel-port 0))
(def unlock-port (open-port 1))

(go-loop
[]
(<! (timeout 2000))
(toggle! unlock-port)
(recur))

(go-loop
[]
(log/info (<! button-chan))
(recur))

(log/info "=== Daemon Started ===")

0 comments on commit 3f54813

Please sign in to comment.