Created
June 17, 2016 17:37
-
-
Save ceremcem/9f379b7f469f053c81efdb695e04811e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// Generated by LiveScript 1.4.0 | |
var sleep, rfid, stm, esp12, setup, rfidTest, run, onInit; | |
sleep = require('aea').sleep; | |
rfid = void 8; | |
stm = true; | |
esp12 = false; | |
setup = function(){ | |
var spiPins, cs; | |
if (stm && !esp12) { | |
console.log("----- this is STM32-DISCOVERY"); | |
spiPins = { | |
sck: A5, | |
mosi: A7, | |
miso: A6 | |
}; | |
cs = A4; | |
} else { | |
console.log("----- this is ESP-WIFI"); | |
spiPins = { | |
sck: D14, | |
mosi: D13, | |
miso: D12, | |
baud: 400000 | |
}; | |
cs = D15; | |
} | |
SPI1.setup(spiPins); | |
return rfid = require("MFRC522").connect(SPI1, cs); | |
}; | |
rfidTest = function(){ | |
console.log("trying to find card"); | |
return rfid.findCards(function(card){ | |
return console.log("Found " + card); | |
}); | |
}; | |
run = true; | |
onInit = function(){ | |
setup(); | |
return function lo(op){ | |
if (run) { | |
rfidTest(); | |
} | |
return sleep(1000, function(){ | |
return lo(op); | |
}); | |
}(function(){}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment