// Maker Crown Peddle APP
// vgmlr
var UI = require('ui');
var ajax = require('ajax');
var Vector2 = require('vector2');
// Create Window
var main_window = new UI.Window();
// Open Button and Display
var txtOnLabel = new UI.Text({
position: new Vector2(0, 15),
size: new Vector2(144, 30),
font: 'Gothic 28 Bold',
text: 'RISE',
textAlign: 'center',
color: 'white'
});
//this is going to be our off button
var txtOffLabel = new UI.Text({
position: new Vector2(0, 95),
size: new Vector2(144, 30),
font: 'Gothic 28 Bold',
text: 'BATTLE',
textAlign: 'center',
color: 'white'
});
main_window.backgroundColor('black');
main_window.add(txtOnLabel);
main_window.add(txtOffLabel);
main_window.show();
// URL To MKR1000 (Change)
function Toggle(function_name){
var URL = 'http://192.168.1.9/' + function_name;
ajax(
{
url: URL,
method: 'post',
type: 'json',
data: { "args": function_name}
}
);
}
// Rise
main_window.on('click', 'up', function() {
Toggle('R');
});
// Battle
main_window.on('click', 'down', function() {
Toggle('B');
});
// Seated
main_window.on('click', 'select', function() {
Toggle('S');
});