Skip to content

Commit

Permalink
modified nfc shield libs
Browse files Browse the repository at this point in the history
  • Loading branch information
nelsonz committed Jul 22, 2012
1 parent 31c70bc commit 475b636
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 6 deletions.
Expand Up @@ -132,17 +132,12 @@ void Adafruit_NFCShield_I2C::PrintHex(const byte * data, const uint32_t numBytes
uint32_t szPos;
for (szPos=0; szPos < numBytes; szPos++)
{
Serial.print("0x");
// Append leading 0 for small values
if (data[szPos] <= 0xF)
Serial.print("0");
Serial.print(data[szPos], HEX);
if ((numBytes > 1) && (szPos != numBytes - 1))
{
Serial.print(" ");
}
}
Serial.println("");
Serial.print("\n");
}

/**************************************************************************/
Expand Down
10 changes: 10 additions & 0 deletions spotify/index.html
@@ -0,0 +1,10 @@
<html>
<head>
<script src="jquery.js"></script>
<script src="syncpad.js"></script>
<link rel="stylesheet" href="syncpad.css">
</head>
<body>
<a href="#" class="button" id="write">Write tag</a>
</body>
</html>
12 changes: 12 additions & 0 deletions spotify/manifest.json
@@ -0,0 +1,12 @@
{
"BundleType": "Application",
"BundleIdentifier": "syncpad",
"AppName": "SyncPad",
"AppDescription": "NFC Sync",
"RequiredPermissions": [

],
"SupportedLanguages": [
"en"
]
}
31 changes: 31 additions & 0 deletions spotify/syncpad.css
@@ -0,0 +1,31 @@
.button {
-moz-box-shadow:inset 0px 1px 0px 0px #ffffff;
-webkit-box-shadow:inset 0px 1px 0px 0px #ffffff;
box-shadow:inset 0px 1px 0px 0px #ffffff;
background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #ededed), color-stop(1, #dfdfdf) );
background:-moz-linear-gradient( center top, #ededed 5%, #dfdfdf 100% );
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ededed', endColorstr='#dfdfdf');
background-color:#ededed;
-moz-border-radius:6px;
-webkit-border-radius:6px;
border-radius:6px;
border:1px solid #dcdcdc;
display:inline-block;
color:#777777;
font-family:arial;
font-size:15px;
font-weight:bold;
padding:6px 24px;
text-decoration:none;
text-shadow:1px 1px 0px #ffffff;
}
.classname:hover {
background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #dfdfdf), color-stop(1, #ededed) );
background:-moz-linear-gradient( center top, #dfdfdf 5%, #ededed 100% );
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#dfdfdf', endColorstr='#ededed');
background-color:#dfdfdf;
}
.classname:active {
position:relative;
top:1px;
}
35 changes: 35 additions & 0 deletions spotify/syncpad.js
@@ -0,0 +1,35 @@
var LOCAL = 'ws://localhost:9000',
CLOUD = 'http://192.168.1.192';

var sp = getSpotifyApi(1),
player = sp.require('sp://import/scripts/api/models').player,
exports.init = init;

function init() {
var ws = new WebSocket(LOCAL);

ws.onopen = function(){
ws.send(JSON.stringify({type: 'announce', announce: 'song'}));
};

ws.onclose = function(){
setTimeout(init, 5000);
};

ws.onmessage = function(msg) {
var data = JSON.parse(msg.data);
if (!data.write) {
player.play("spotify:track:" + data.track);
player.position = data.position;
}
if (data.write) {
$.post(CLOUD + '/store/' + data.id, {type: 'song', track: player.track.uri, position: player.position});
}
}

$("#write").on('click', function(e) {
ws.send(JSON.stringify({type: 'write'}));
});
}


0 comments on commit 475b636

Please sign in to comment.