mirror of https://github.com/espruino/BangleApps
Final changes before pull request
parent
39fc56f0b0
commit
65e5a2a544
|
@ -1,7 +0,0 @@
|
||||||
{
|
|
||||||
"folders": [
|
|
||||||
{
|
|
||||||
"path": "/Users/hopkira/Documents/BangleApps"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
|
@ -28,10 +28,9 @@ declare global variables for the toggle button
|
||||||
statuses; if you add an additional toggle button
|
statuses; if you add an additional toggle button
|
||||||
you should declare it and initiase it here */
|
you should declare it and initiase it here */
|
||||||
|
|
||||||
var status_printer = {value: false};
|
var status_auto = {value: false};
|
||||||
var status_tv = {value: false};
|
var status_chess = {value: false};
|
||||||
var status_light_hall = {value: false};
|
var status_wake = {value: false};
|
||||||
var status_light_study = {value: false};
|
|
||||||
|
|
||||||
/* trsnsmit message
|
/* trsnsmit message
|
||||||
where
|
where
|
||||||
|
@ -71,16 +70,64 @@ with a unique name and the data from the Image Object
|
||||||
*/
|
*/
|
||||||
const icons = [
|
const icons = [
|
||||||
{
|
{
|
||||||
name: "switch",
|
name: "walk",
|
||||||
data: "gEBAP4B/AP4B/AP4B/AMgA3HPJdlVvI7/Hf47/Hf47/Hf47/Hf47/Hf4AvIPKRXAP4B/AP4B/AP4B/AJgA=="
|
data: "gEBAP4B/ALyh7b/YALHfY9tACY55HfYdNHto7pHpIbXbL5fXAD6VlHuYAjHf47/Hf47tHK47LDa45zHc4NHHeILJHeonTO9o9rHf47/eOoB/ANg="
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "light",
|
name: "sit",
|
||||||
data: "gEBAP4B/APi/Na67lfACZ/nNaI9lE6o9jEbI9hD7Y7dDsJZ3D6YRJHdIJHHfaz7Hf5Z/Hf4hZHMIjFEqIVVHsY5hDpI7TEqL1jVsqlTdM55THOJvHOuY7/HfI9JHOI9HHOoBgA=="
|
data: "gEBAP4B/AP4BacO4ANHPI/rACp1/Hf49rGtI5/He7n3ACY55HcYAZHf45/Hf45rHe4XHGbI7/Va47zZZrpbHfbtXD5Y/vHcYB/AP4BmA"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "joystick",
|
||||||
|
data: "gEBAP4B/AP4BMavIALHPI9vHf47/eP45vHpY5xHo451Hf47/FuYAHHNItHABa33AP6xpAD455HqY7/Hf47/Hd49pHKIB/AP4B/AMwA=="
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "left",
|
||||||
|
data: "gEBAP4B/AP4BKa9ojHAC5pfHJKDTUsYdZHb6ZfO+I9dABabdLbIBdHf473PP47NJdY7/ePIB/RJop5Ys7t/AP6PvD7o7fP8Y1zTZoHPf/4B/AP4B+A=="
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "right",
|
||||||
|
data: "gEBAP4B/AP4BKa+oAXDo45hCaqFbUbLBfbbo7bHMojTR7Y5LHa51ZALo75Ov47/FeY77AP4B5WdbF3dv4B/R94fdHb5/jGuabNA57//AP4B/APw="
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "forward",
|
||||||
|
data: "gEBAP4B/AKSX5avIALHPI9tACY55HsoAbHPI9fHfZFVGMo7/Hf47/Hf47/Hf47/Hf47/Hf47/Hf47/Hf49XHOIB/ALw="
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "backward",
|
||||||
|
data: "gEBAP4B/AKCZ5a/Y7/Hf47/Hf47/Hf47/Hf47/Hf47/Hf47/HfIAfHf491W/L15HMo9THNI9PHNo9LHOI9HHOoB/ALg="
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "back",
|
name: "back",
|
||||||
data: "gEBAP4B/AP4B/AKgADHPI71HP45/HP45/HP45/HP45/Hf49/Hv49/Hv49/Hv49/Hv497He4B/AP4B/AJAA=="
|
data: "gEBAP4B/AP4B/AKgADHPI71HP45/HP45/HP45/HP45/Hf49/Hv49/Hv49/Hv49/Hv497He4B/AP4B/AJAA=="
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "mic_on",
|
||||||
|
data: "gEBAP4B/AKCZ5a/Y7/Hf47/Hf47/Hf47/GbY7TIcY7/Hf47/Hf47/HdY9NCpp5lCb57fOdYvNeJo91HNrlvHf7tVIdY77AP4BiA="
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "comms",
|
||||||
|
data: "gEBAP4B+QvbF7ABo7/He49tACI7/Hf47zHtI7jJq47lRqoAVEqY7nHsoAZGJo71HrKxfQaY7bdKo7/Hdqz5B5Y7zHK47RD55FRHao3XHKo7JG7L1NHeJTbHboB/AP4BG"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "pawn",
|
||||||
|
data: "gEBAP4B/AP4B/AP4BEAA455HuY7/Hf47xAB47/PuI1xPZY7/Hf47/G9Y/zHfIATHPI9nHfYB/AOYAfHf4B/AP4B/APA="
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "sleep",
|
||||||
|
data: "gEBAP4B/AP4B2ACY7/Quq95HP45/HP4APOdY7fACZfnHcaZZAL45/HP45/E7YAHCaZFZHfbh/HP45/HOoAHHf4B/AP4B/AP4BIA="
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "awake",
|
||||||
|
data: "gEBAP4B/AKyb7HfIAFHPI77Ov451Hf453Hf453HdoAbHf45/Hf5HrHNY7NHNo7/HO47/HO47HHPJ1/Heo51HfoB/ALg="
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "wag_h",
|
||||||
|
data: "gEBAP4B/AP4B/AP4B/AP4B/AMwADD+oAFHb4hTHMIlXHMopTHNItPAG47/WfY9tFKY9lEq49hELY7ja8YB/AP4B/AP4B/AP4B/AP4BCA"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "wag_v",
|
||||||
|
data: "gEBAP4B/AP4BOafIAHHPI9xAB45vd449rFZIHLHsonJBKa7rGNo7/Hf47/Hf47/Hf47/Hf4xlBKY7hFIoHLQM4rHApK7rAB71xHOo9LHOI9HHOoB/AP4BYA="
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -110,61 +157,68 @@ the program and it may be adviable to use the 'status_name'
|
||||||
format to ensure it is clear.
|
format to ensure it is clear.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var lightBtn = {
|
var joystickBtn = {
|
||||||
primary_colour: 0x653E,
|
primary_colour: 0x653E,
|
||||||
primary_text: 'Lights',
|
primary_icon: 'joystick',
|
||||||
primary_icon: 'light',
|
primary_text: 'Joystick',
|
||||||
};
|
};
|
||||||
|
|
||||||
var socketsBtn = {
|
var turnLeftBtn = {
|
||||||
|
primary_colour: 0x653E,
|
||||||
|
primary_text: 'Left',
|
||||||
|
primary_icon: 'left',
|
||||||
|
};
|
||||||
|
|
||||||
|
var turnRightBtn = {
|
||||||
primary_colour: 0x33F9,
|
primary_colour: 0x33F9,
|
||||||
primary_text: 'Sockets',
|
primary_text: 'Right',
|
||||||
primary_icon: 'switch',
|
primary_icon: 'right',
|
||||||
};
|
};
|
||||||
|
|
||||||
var lightHallBtn = {
|
var tailHBtn = {
|
||||||
primary_colour: 0xE9C7,
|
primary_colour: 0x653E,
|
||||||
primary_text: 'Hall Off',
|
primary_text: 'Wag Tail',
|
||||||
primary_icon: 'light',
|
primary_icon: 'wag_h',
|
||||||
toggle: true,
|
|
||||||
secondary_colour: 0x3F48,
|
|
||||||
secondary_text: 'Hall On',
|
|
||||||
secondary_icon : 'light',
|
|
||||||
value: status_light_hall
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var lightStudyBtn = {
|
var tailVBtn = {
|
||||||
primary_colour: 0xE9C7,
|
primary_colour: 0x33F9,
|
||||||
primary_text: 'Study Off',
|
primary_text: 'Wag Tail',
|
||||||
primary_icon: 'light',
|
primary_icon: 'wag_v',
|
||||||
toggle: true,
|
|
||||||
secondary_colour: 0x3F48,
|
|
||||||
secondary_text: 'Study On',
|
|
||||||
secondary_icon : 'light',
|
|
||||||
value: status_light_study
|
|
||||||
};
|
|
||||||
|
|
||||||
var socketTVBtn = {
|
|
||||||
primary_colour: 0xE9C7,
|
|
||||||
primary_text: 'TV Off',
|
|
||||||
primary_icon: 'switch',
|
|
||||||
toggle: true,
|
|
||||||
secondary_colour: 0x3F48,
|
|
||||||
secondary_text: 'TV On',
|
|
||||||
secondary_icon : 'switch',
|
|
||||||
value: status_tv
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var socketPrinterBtn = {
|
var chessBtn = {
|
||||||
primary_colour: 0xE9C7,
|
primary_colour: 0xE9C7,
|
||||||
primary_text: 'Printer Off',
|
primary_text: 'Off',
|
||||||
primary_icon: 'switch',
|
primary_icon: 'pawn',
|
||||||
toggle: true,
|
toggle: true,
|
||||||
secondary_colour: 0x3F48,
|
secondary_colour: 0x3F48,
|
||||||
secondary_text: 'Printer On',
|
secondary_text: 'On',
|
||||||
secondary_icon : 'switch',
|
secondary_icon : 'pawn',
|
||||||
value: status_printer
|
value: status_chess
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var wakeBtn = {
|
||||||
|
primary_colour: 0xE9C7,
|
||||||
|
primary_text: 'Sleeping',
|
||||||
|
primary_icon: 'sleep',
|
||||||
|
toggle: true,
|
||||||
|
secondary_colour: 0x3F48,
|
||||||
|
secondary_text: 'Awake',
|
||||||
|
secondary_icon : 'awake',
|
||||||
|
value: status_wake
|
||||||
|
};
|
||||||
|
|
||||||
|
var autoBtn = {
|
||||||
|
primary_colour: 0xE9C7,
|
||||||
|
primary_text: 'Stop',
|
||||||
|
primary_icon: 'sit',
|
||||||
|
toggle: true,
|
||||||
|
secondary_colour: 0x3F48,
|
||||||
|
secondary_text: 'Move',
|
||||||
|
secondary_icon : 'walk',
|
||||||
|
value: status_auto
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
CONFIGURATION AREA - SCREEN DEFINITIONS
|
CONFIGURATION AREA - SCREEN DEFINITIONS
|
||||||
|
@ -176,23 +230,34 @@ the left hand side of the screen. These
|
||||||
are defined as btn1, bt2 and bt3. The
|
are defined as btn1, bt2 and bt3. The
|
||||||
values are names from the icon array.
|
values are names from the icon array.
|
||||||
*/
|
*/
|
||||||
const homeScreen = {
|
const menuScreen = {
|
||||||
left: lightBtn,
|
left: wakeBtn,
|
||||||
right: socketsBtn,
|
right: joystickBtn,
|
||||||
|
btn1: "pawn",
|
||||||
|
btn2: "wag_v",
|
||||||
};
|
};
|
||||||
|
|
||||||
const lightsScreen = {
|
const joystickScreen = {
|
||||||
left: lightHallBtn,
|
left: turnLeftBtn,
|
||||||
right: lightStudyBtn,
|
right: turnRightBtn,
|
||||||
|
btn1: "forward",
|
||||||
|
btn2: "backward",
|
||||||
btn3: "back"
|
btn3: "back"
|
||||||
};
|
};
|
||||||
|
|
||||||
const socketsScreen = {
|
const tailScreen = {
|
||||||
left: socketTVBtn,
|
left: tailHBtn,
|
||||||
right: socketPrinterBtn,
|
right: tailVBtn,
|
||||||
btn3: "back"
|
btn3: "back"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const chessScreen = {
|
||||||
|
left: chessBtn,
|
||||||
|
right: autoBtn,
|
||||||
|
btn3: "back"
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/* base state definition
|
/* base state definition
|
||||||
Each of the screens correspond to a state;
|
Each of the screens correspond to a state;
|
||||||
this class provides a constuctor for each
|
this class provides a constuctor for each
|
||||||
|
@ -232,36 +297,23 @@ inversed and the new value transmitted.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* The Home State/Page is where the application beings */
|
/* The Home State/Page is where the application beings */
|
||||||
|
|
||||||
const Home = new State({
|
const Home = new State({
|
||||||
state: "Home",
|
state: "K9Menu",
|
||||||
screen: homeScreen,
|
screen: menuScreen,
|
||||||
events: (event) => {
|
events: (event) => {
|
||||||
if ((event.object == "right") && (event.status == "end")) {
|
if ((event.object == "top") && (event.status == "end")) {
|
||||||
return SocketsMenu;
|
return Chess;
|
||||||
}
|
}
|
||||||
if ((event.object == "left") && (event.status == "end")) {
|
if ((event.object == "middle") && (event.status == "end")) {
|
||||||
return LightsMenu;
|
return Tail;
|
||||||
}
|
|
||||||
transmit(this.state, event.object, event.status);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
const LightsMenu = new State({
|
|
||||||
state: "LightsMenu",
|
|
||||||
screen: lightsScreen,
|
|
||||||
events: (event) => {
|
|
||||||
if ((event.object == "bottom") && (event.status == "end")) {
|
|
||||||
return Home;
|
|
||||||
}
|
}
|
||||||
if ((event.object == "right") && (event.status == "end")) {
|
if ((event.object == "right") && (event.status == "end")) {
|
||||||
status_light_study.value = !status_light_study.value;
|
return Joystick;
|
||||||
transmit(this.state, "study", onOff(status_light_study.value));
|
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
if ((event.object == "left") && (event.status == "end")) {
|
if ((event.object == "left") && (event.status == "end")) {
|
||||||
status_light_hall.value = !status_light_hall.value;
|
status_wake.value = !status_wake.value;
|
||||||
transmit(this.state, "hall", onOff(status_light_hall.value));
|
transmit(this.state, "wake", onOff(status_wake.value));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
transmit(this.state, event.object, event.status);
|
transmit(this.state, event.object, event.status);
|
||||||
|
@ -269,21 +321,21 @@ const LightsMenu = new State({
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const SocketsMenu = new State({
|
const Chess = new State({
|
||||||
state: "SocketsMenu",
|
state: "Chess",
|
||||||
screen: socketsScreen,
|
screen: chessScreen,
|
||||||
events: (event) => {
|
events: (event) => {
|
||||||
if ((event.object == "bottom") && (event.status == "end")) {
|
if ((event.object == "bottom") && (event.status == "end")) {
|
||||||
return Home;
|
return Home;
|
||||||
}
|
}
|
||||||
if ((event.object == "right") && (event.status == "end")) {
|
if ((event.object == "right") && (event.status == "end")) {
|
||||||
status_printer.value = !status_printer.value;
|
status_auto.value = !status_auto.value;
|
||||||
transmit(this.state, "printer", onOff(status_printer.value));
|
transmit(this.state, "follow", onOff(status_auto.value));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
if ((event.object == "left") && (event.status == "end")) {
|
if ((event.object == "left") && (event.status == "end")) {
|
||||||
status_tv.value = !status_tv.value;
|
status_chess.value = !status_chess.value;
|
||||||
transmit(this.state, "tv", onOff(status_tv.value));
|
transmit(this.state, "chess", onOff(status_chess.value));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
transmit(this.state, event.object, event.status);
|
transmit(this.state, event.object, event.status);
|
||||||
|
@ -291,6 +343,32 @@ const SocketsMenu = new State({
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const Tail = new State({
|
||||||
|
state: "Tail",
|
||||||
|
screen: tailScreen,
|
||||||
|
events: (event) => {
|
||||||
|
if ((event.object == "bottom") && (event.status == "end")) {
|
||||||
|
return Home;
|
||||||
|
}
|
||||||
|
transmit(this.state, event.object, event.status);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
/* Joystick page state */
|
||||||
|
const Joystick = new State({
|
||||||
|
state: "Joystick",
|
||||||
|
screen: joystickScreen,
|
||||||
|
events: (event) => {
|
||||||
|
if ((event.object == "bottom") && (event.status == "end")) {
|
||||||
|
transmit("Joystick", "joystick", "off");
|
||||||
|
return Home;
|
||||||
|
}
|
||||||
|
transmit(this.state, event.object, event.status);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
/* translate button status into english */
|
/* translate button status into english */
|
||||||
const startEnd = status => status ? "start" : "end";
|
const startEnd = status => status ? "start" : "end";
|
||||||
|
|
|
@ -28,9 +28,10 @@ declare global variables for the toggle button
|
||||||
statuses; if you add an additional toggle button
|
statuses; if you add an additional toggle button
|
||||||
you should declare it and initiase it here */
|
you should declare it and initiase it here */
|
||||||
|
|
||||||
var status_auto = {value: false};
|
var status_printer = {value: false};
|
||||||
var status_chess = {value: false};
|
var status_tv = {value: false};
|
||||||
var status_wake = {value: false};
|
var status_light_hall = {value: false};
|
||||||
|
var status_light_study = {value: false};
|
||||||
|
|
||||||
/* trsnsmit message
|
/* trsnsmit message
|
||||||
where
|
where
|
||||||
|
@ -70,64 +71,16 @@ with a unique name and the data from the Image Object
|
||||||
*/
|
*/
|
||||||
const icons = [
|
const icons = [
|
||||||
{
|
{
|
||||||
name: "walk",
|
name: "switch",
|
||||||
data: "gEBAP4B/ALyh7b/YALHfY9tACY55HfYdNHto7pHpIbXbL5fXAD6VlHuYAjHf47/Hf47tHK47LDa45zHc4NHHeILJHeonTO9o9rHf47/eOoB/ANg="
|
data: "gEBAP4B/AP4B/AP4B/AMgA3HPJdlVvI7/Hf47/Hf47/Hf47/Hf47/Hf4AvIPKRXAP4B/AP4B/AP4B/AJgA=="
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "sit",
|
name: "light",
|
||||||
data: "gEBAP4B/AP4BacO4ANHPI/rACp1/Hf49rGtI5/He7n3ACY55HcYAZHf45/Hf45rHe4XHGbI7/Va47zZZrpbHfbtXD5Y/vHcYB/AP4BmA"
|
data: "gEBAP4B/APi/Na67lfACZ/nNaI9lE6o9jEbI9hD7Y7dDsJZ3D6YRJHdIJHHfaz7Hf5Z/Hf4hZHMIjFEqIVVHsY5hDpI7TEqL1jVsqlTdM55THOJvHOuY7/HfI9JHOI9HHOoBgA=="
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "joystick",
|
|
||||||
data: "gEBAP4B/AP4BMavIALHPI9vHf47/eP45vHpY5xHo451Hf47/FuYAHHNItHABa33AP6xpAD455HqY7/Hf47/Hd49pHKIB/AP4B/AMwA=="
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "left",
|
|
||||||
data: "gEBAP4B/AP4BKa9ojHAC5pfHJKDTUsYdZHb6ZfO+I9dABabdLbIBdHf473PP47NJdY7/ePIB/RJop5Ys7t/AP6PvD7o7fP8Y1zTZoHPf/4B/AP4B+A=="
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "right",
|
|
||||||
data: "gEBAP4B/AP4BKa+oAXDo45hCaqFbUbLBfbbo7bHMojTR7Y5LHa51ZALo75Ov47/FeY77AP4B5WdbF3dv4B/R94fdHb5/jGuabNA57//AP4B/APw="
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "forward",
|
|
||||||
data: "gEBAP4B/AKSX5avIALHPI9tACY55HsoAbHPI9fHfZFVGMo7/Hf47/Hf47/Hf47/Hf47/Hf47/Hf47/Hf49XHOIB/ALw="
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "backward",
|
|
||||||
data: "gEBAP4B/AKCZ5a/Y7/Hf47/Hf47/Hf47/Hf47/Hf47/Hf47/HfIAfHf491W/L15HMo9THNI9PHNo9LHOI9HHOoB/ALg="
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "back",
|
name: "back",
|
||||||
data: "gEBAP4B/AP4B/AKgADHPI71HP45/HP45/HP45/HP45/Hf49/Hv49/Hv49/Hv49/Hv497He4B/AP4B/AJAA=="
|
data: "gEBAP4B/AP4B/AKgADHPI71HP45/HP45/HP45/HP45/Hf49/Hv49/Hv49/Hv49/Hv497He4B/AP4B/AJAA=="
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "mic_on",
|
|
||||||
data: "gEBAP4B/AKCZ5a/Y7/Hf47/Hf47/Hf47/GbY7TIcY7/Hf47/Hf47/HdY9NCpp5lCb57fOdYvNeJo91HNrlvHf7tVIdY77AP4BiA="
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "comms",
|
|
||||||
data: "gEBAP4B+QvbF7ABo7/He49tACI7/Hf47zHtI7jJq47lRqoAVEqY7nHsoAZGJo71HrKxfQaY7bdKo7/Hdqz5B5Y7zHK47RD55FRHao3XHKo7JG7L1NHeJTbHboB/AP4BG"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "pawn",
|
|
||||||
data: "gEBAP4B/AP4B/AP4BEAA455HuY7/Hf47xAB47/PuI1xPZY7/Hf47/G9Y/zHfIATHPI9nHfYB/AOYAfHf4B/AP4B/APA="
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "sleep",
|
|
||||||
data: "gEBAP4B/AP4B2ACY7/Quq95HP45/HP4APOdY7fACZfnHcaZZAL45/HP45/E7YAHCaZFZHfbh/HP45/HOoAHHf4B/AP4B/AP4BIA="
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "awake",
|
|
||||||
data: "gEBAP4B/AKyb7HfIAFHPI77Ov451Hf453Hf453HdoAbHf45/Hf5HrHNY7NHNo7/HO47/HO47HHPJ1/Heo51HfoB/ALg="
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "wag_h",
|
|
||||||
data: "gEBAP4B/AP4B/AP4B/AP4B/AMwADD+oAFHb4hTHMIlXHMopTHNItPAG47/WfY9tFKY9lEq49hELY7ja8YB/AP4B/AP4B/AP4B/AP4BCA"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "wag_v",
|
|
||||||
data: "gEBAP4B/AP4BOafIAHHPI9xAB45vd449rFZIHLHsonJBKa7rGNo7/Hf47/Hf47/Hf47/Hf4xlBKY7hFIoHLQM4rHApK7rAB71xHOo9LHOI9HHOoB/AP4BYA="
|
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -157,68 +110,61 @@ the program and it may be adviable to use the 'status_name'
|
||||||
format to ensure it is clear.
|
format to ensure it is clear.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var joystickBtn = {
|
var lightBtn = {
|
||||||
primary_colour: 0x653E,
|
primary_colour: 0x653E,
|
||||||
primary_icon: 'joystick',
|
primary_text: 'Lights',
|
||||||
primary_text: 'Joystick',
|
primary_icon: 'light',
|
||||||
};
|
};
|
||||||
|
|
||||||
var turnLeftBtn = {
|
var socketsBtn = {
|
||||||
primary_colour: 0x653E,
|
|
||||||
primary_text: 'Left',
|
|
||||||
primary_icon: 'left',
|
|
||||||
};
|
|
||||||
|
|
||||||
var turnRightBtn = {
|
|
||||||
primary_colour: 0x33F9,
|
primary_colour: 0x33F9,
|
||||||
primary_text: 'Right',
|
primary_text: 'Sockets',
|
||||||
primary_icon: 'right',
|
primary_icon: 'switch',
|
||||||
};
|
};
|
||||||
|
|
||||||
var tailHBtn = {
|
var lightHallBtn = {
|
||||||
primary_colour: 0x653E,
|
|
||||||
primary_text: 'Wag Tail',
|
|
||||||
primary_icon: 'wag_h',
|
|
||||||
};
|
|
||||||
|
|
||||||
var tailVBtn = {
|
|
||||||
primary_colour: 0x33F9,
|
|
||||||
primary_text: 'Wag Tail',
|
|
||||||
primary_icon: 'wag_v',
|
|
||||||
};
|
|
||||||
|
|
||||||
var chessBtn = {
|
|
||||||
primary_colour: 0xE9C7,
|
primary_colour: 0xE9C7,
|
||||||
primary_text: 'Off',
|
primary_text: 'Hall Off',
|
||||||
primary_icon: 'pawn',
|
primary_icon: 'light',
|
||||||
toggle: true,
|
toggle: true,
|
||||||
secondary_colour: 0x3F48,
|
secondary_colour: 0x3F48,
|
||||||
secondary_text: 'On',
|
secondary_text: 'Hall On',
|
||||||
secondary_icon : 'pawn',
|
secondary_icon : 'light',
|
||||||
value: status_chess
|
value: status_light_hall
|
||||||
};
|
};
|
||||||
|
|
||||||
var wakeBtn = {
|
var lightStudyBtn = {
|
||||||
primary_colour: 0xE9C7,
|
primary_colour: 0xE9C7,
|
||||||
primary_text: 'Sleeping',
|
primary_text: 'Study Off',
|
||||||
primary_icon: 'sleep',
|
primary_icon: 'light',
|
||||||
toggle: true,
|
toggle: true,
|
||||||
secondary_colour: 0x3F48,
|
secondary_colour: 0x3F48,
|
||||||
secondary_text: 'Awake',
|
secondary_text: 'Study On',
|
||||||
secondary_icon : 'awake',
|
secondary_icon : 'light',
|
||||||
value: status_wake
|
value: status_light_study
|
||||||
|
};
|
||||||
|
|
||||||
|
var socketTVBtn = {
|
||||||
|
primary_colour: 0xE9C7,
|
||||||
|
primary_text: 'TV Off',
|
||||||
|
primary_icon: 'switch',
|
||||||
|
toggle: true,
|
||||||
|
secondary_colour: 0x3F48,
|
||||||
|
secondary_text: 'TV On',
|
||||||
|
secondary_icon : 'switch',
|
||||||
|
value: status_tv
|
||||||
};
|
};
|
||||||
|
|
||||||
var autoBtn = {
|
var socketPrinterBtn = {
|
||||||
primary_colour: 0xE9C7,
|
primary_colour: 0xE9C7,
|
||||||
primary_text: 'Stop',
|
primary_text: 'Printer Off',
|
||||||
primary_icon: 'sit',
|
primary_icon: 'switch',
|
||||||
toggle: true,
|
toggle: true,
|
||||||
secondary_colour: 0x3F48,
|
secondary_colour: 0x3F48,
|
||||||
secondary_text: 'Move',
|
secondary_text: 'Printer On',
|
||||||
secondary_icon : 'walk',
|
secondary_icon : 'switch',
|
||||||
value: status_auto
|
value: status_printer
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
CONFIGURATION AREA - SCREEN DEFINITIONS
|
CONFIGURATION AREA - SCREEN DEFINITIONS
|
||||||
|
@ -230,34 +176,23 @@ the left hand side of the screen. These
|
||||||
are defined as btn1, bt2 and bt3. The
|
are defined as btn1, bt2 and bt3. The
|
||||||
values are names from the icon array.
|
values are names from the icon array.
|
||||||
*/
|
*/
|
||||||
const menuScreen = {
|
const homeScreen = {
|
||||||
left: wakeBtn,
|
left: lightBtn,
|
||||||
right: joystickBtn,
|
right: socketsBtn,
|
||||||
btn1: "pawn",
|
|
||||||
btn2: "wag_v",
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const joystickScreen = {
|
const lightsScreen = {
|
||||||
left: turnLeftBtn,
|
left: lightHallBtn,
|
||||||
right: turnRightBtn,
|
right: lightStudyBtn,
|
||||||
btn1: "forward",
|
|
||||||
btn2: "backward",
|
|
||||||
btn3: "back"
|
btn3: "back"
|
||||||
};
|
};
|
||||||
|
|
||||||
const tailScreen = {
|
const socketsScreen = {
|
||||||
left: tailHBtn,
|
left: socketTVBtn,
|
||||||
right: tailVBtn,
|
right: socketPrinterBtn,
|
||||||
btn3: "back"
|
btn3: "back"
|
||||||
};
|
};
|
||||||
|
|
||||||
const chessScreen = {
|
|
||||||
left: chessBtn,
|
|
||||||
right: autoBtn,
|
|
||||||
btn3: "back"
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/* base state definition
|
/* base state definition
|
||||||
Each of the screens correspond to a state;
|
Each of the screens correspond to a state;
|
||||||
this class provides a constuctor for each
|
this class provides a constuctor for each
|
||||||
|
@ -297,45 +232,36 @@ inversed and the new value transmitted.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* The Home State/Page is where the application beings */
|
/* The Home State/Page is where the application beings */
|
||||||
|
|
||||||
const Home = new State({
|
const Home = new State({
|
||||||
state: "K9Menu",
|
state: "Home",
|
||||||
screen: menuScreen,
|
screen: homeScreen,
|
||||||
events: (event) => {
|
events: (event) => {
|
||||||
if ((event.object == "top") && (event.status == "end")) {
|
|
||||||
return Chess;
|
|
||||||
}
|
|
||||||
if ((event.object == "middle") && (event.status == "end")) {
|
|
||||||
return Tail;
|
|
||||||
}
|
|
||||||
if ((event.object == "right") && (event.status == "end")) {
|
if ((event.object == "right") && (event.status == "end")) {
|
||||||
return Joystick;
|
return SocketsMenu;
|
||||||
}
|
}
|
||||||
if ((event.object == "left") && (event.status == "end")) {
|
if ((event.object == "left") && (event.status == "end")) {
|
||||||
status_wake.value = !status_wake.value;
|
return LightsMenu;
|
||||||
transmit(this.state, "wake", onOff(status_wake.value));
|
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
transmit(this.state, event.object, event.status);
|
transmit(this.state, event.object, event.status);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const Chess = new State({
|
const LightsMenu = new State({
|
||||||
state: "Chess",
|
state: "LightsMenu",
|
||||||
screen: chessScreen,
|
screen: lightsScreen,
|
||||||
events: (event) => {
|
events: (event) => {
|
||||||
if ((event.object == "bottom") && (event.status == "end")) {
|
if ((event.object == "bottom") && (event.status == "end")) {
|
||||||
return Home;
|
return Home;
|
||||||
}
|
}
|
||||||
if ((event.object == "right") && (event.status == "end")) {
|
if ((event.object == "right") && (event.status == "end")) {
|
||||||
status_auto.value = !status_auto.value;
|
status_light_study.value = !status_light_study.value;
|
||||||
transmit(this.state, "follow", onOff(status_auto.value));
|
transmit(this.state, "study", onOff(status_light_study.value));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
if ((event.object == "left") && (event.status == "end")) {
|
if ((event.object == "left") && (event.status == "end")) {
|
||||||
status_chess.value = !status_chess.value;
|
status_light_hall.value = !status_light_hall.value;
|
||||||
transmit(this.state, "chess", onOff(status_chess.value));
|
transmit(this.state, "hall", onOff(status_light_hall.value));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
transmit(this.state, event.object, event.status);
|
transmit(this.state, event.object, event.status);
|
||||||
|
@ -343,32 +269,28 @@ const Chess = new State({
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const Tail = new State({
|
const SocketsMenu = new State({
|
||||||
state: "Tail",
|
state: "SocketsMenu",
|
||||||
screen: tailScreen,
|
screen: socketsScreen,
|
||||||
events: (event) => {
|
events: (event) => {
|
||||||
if ((event.object == "bottom") && (event.status == "end")) {
|
if ((event.object == "bottom") && (event.status == "end")) {
|
||||||
return Home;
|
return Home;
|
||||||
}
|
}
|
||||||
|
if ((event.object == "right") && (event.status == "end")) {
|
||||||
|
status_printer.value = !status_printer.value;
|
||||||
|
transmit(this.state, "printer", onOff(status_printer.value));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
if ((event.object == "left") && (event.status == "end")) {
|
||||||
|
status_tv.value = !status_tv.value;
|
||||||
|
transmit(this.state, "tv", onOff(status_tv.value));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
transmit(this.state, event.object, event.status);
|
transmit(this.state, event.object, event.status);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/* Joystick page state */
|
|
||||||
const Joystick = new State({
|
|
||||||
state: "Joystick",
|
|
||||||
screen: joystickScreen,
|
|
||||||
events: (event) => {
|
|
||||||
if ((event.object == "bottom") && (event.status == "end")) {
|
|
||||||
transmit("Joystick", "joystick", "off");
|
|
||||||
return Home;
|
|
||||||
}
|
|
||||||
transmit(this.state, event.object, event.status);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
/* translate button status into english */
|
/* translate button status into english */
|
||||||
const startEnd = status => status ? "start" : "end";
|
const startEnd = status => status ? "start" : "end";
|
||||||
|
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 174 KiB |
Loading…
Reference in New Issue