-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
akiroz
committed
Aug 12, 2016
1 parent
bffeaba
commit 3f54813
Showing
5 changed files
with
37 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
|
||
node_modules/ | ||
target/ | ||
|
||
.DS_Store | ||
._* |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ===") |