mirror of https://github.com/espruino/BangleApps
Advertise app name as Espruino manufacturer data when idle
parent
b10de5aa7b
commit
53cc58845a
|
@ -4387,7 +4387,7 @@
|
||||||
"id": "emojuino",
|
"id": "emojuino",
|
||||||
"name": "Emojuino",
|
"name": "Emojuino",
|
||||||
"shortName": "Emojuino",
|
"shortName": "Emojuino",
|
||||||
"version": "0.02",
|
"version": "0.03",
|
||||||
"description": "Emojis & Espruino: broadcast Unicode emojis via Bluetooth Low Energy.",
|
"description": "Emojis & Espruino: broadcast Unicode emojis via Bluetooth Low Energy.",
|
||||||
"icon": "emojuino.png",
|
"icon": "emojuino.png",
|
||||||
"screenshots": [
|
"screenshots": [
|
||||||
|
|
|
@ -1,2 +1,3 @@
|
||||||
0.01: New App!
|
0.01: New App!
|
||||||
0.02: Upgraded text to images, added welcome screen and subtitles.
|
0.02: Upgraded text to images, added welcome screen and subtitles.
|
||||||
|
0.03: Advertise app name as Espruino manufacturer data when idle.
|
||||||
|
|
|
@ -32,6 +32,7 @@ const CYCLE_BUZZ_MILLISECONDS = 50;
|
||||||
const WELCOME_MESSAGE = 'Emojuino:\r\n\r\n< Swipe >\r\nto select\r\n\r\nTap\r\nto transmit';
|
const WELCOME_MESSAGE = 'Emojuino:\r\n\r\n< Swipe >\r\nto select\r\n\r\nTap\r\nto transmit';
|
||||||
|
|
||||||
// Non-user-configurable constants
|
// Non-user-configurable constants
|
||||||
|
const APP_ID = 'emojuino';
|
||||||
const IMAGE_INDEX = 0;
|
const IMAGE_INDEX = 0;
|
||||||
const CODE_POINT_INDEX = 1;
|
const CODE_POINT_INDEX = 1;
|
||||||
const EMOJI_PX = 96;
|
const EMOJI_PX = 96;
|
||||||
|
@ -40,12 +41,11 @@ const EMOJI_Y = (g.getHeight() - EMOJI_PX) / 2;
|
||||||
const TX_X = 68;
|
const TX_X = 68;
|
||||||
const TX_Y = 12;
|
const TX_Y = 12;
|
||||||
const FONT_SIZE = 24;
|
const FONT_SIZE = 24;
|
||||||
const BTN_WATCH_OPTIONS = { repeat: true, debounce: 20, edge: "falling" };
|
const ESPRUINO_COMPANY_CODE = 0x0590;
|
||||||
const UNICODE_CODE_POINT_ELIDED_UUID = [ 0x49, 0x6f, 0x49, 0x44, 0x55,
|
const UNICODE_CODE_POINT_ELIDED_UUID = [ 0x49, 0x6f, 0x49, 0x44, 0x55,
|
||||||
0x54, 0x46, 0x2d, 0x33, 0x32 ];
|
0x54, 0x46, 0x2d, 0x33, 0x32 ];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Global variables
|
// Global variables
|
||||||
let emojiIndex = 0;
|
let emojiIndex = 0;
|
||||||
let isToggleOn = false;
|
let isToggleOn = false;
|
||||||
|
@ -100,9 +100,22 @@ function transmitEmoji(image, codePoint, duration) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Transmit the app name under the Espruino company code to facilitate discovery
|
||||||
|
function transmitAppName() {
|
||||||
|
let options = {
|
||||||
|
showName: false,
|
||||||
|
manufacturer: ESPRUINO_COMPANY_CODE,
|
||||||
|
manufacturerData: JSON.stringify({ name: APP_ID }),
|
||||||
|
interval: 2000
|
||||||
|
}
|
||||||
|
|
||||||
|
NRF.setAdvertising({}, options);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Terminate the emoji transmission
|
// Terminate the emoji transmission
|
||||||
function terminateEmoji(displayIntervalId) {
|
function terminateEmoji(displayIntervalId) {
|
||||||
NRF.setAdvertising({ });
|
transmitAppName();
|
||||||
isTransmitting = false;
|
isTransmitting = false;
|
||||||
clearInterval(displayIntervalId);
|
clearInterval(displayIntervalId);
|
||||||
drawImage(EMOJIS[emojiIndex][IMAGE_INDEX], false);
|
drawImage(EMOJIS[emojiIndex][IMAGE_INDEX], false);
|
||||||
|
@ -169,3 +182,4 @@ g.setFontAlign(0, 0);
|
||||||
g.drawString(WELCOME_MESSAGE, g.getWidth() / 2, g.getHeight() / 2);
|
g.drawString(WELCOME_MESSAGE, g.getWidth() / 2, g.getHeight() / 2);
|
||||||
Bangle.on('touch', handleTouch);
|
Bangle.on('touch', handleTouch);
|
||||||
Bangle.on('drag', handleDrag);
|
Bangle.on('drag', handleDrag);
|
||||||
|
transmitAppName();
|
||||||
|
|
Loading…
Reference in New Issue