Loading files
1b73fd9c3This file is pinned to the selected release. Download the original to open it in your design tool.
<!DOCTYPE html>
<html lang="en" class="js csstransforms3d">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<meta name="generator" content="Hugo 0.49" />
<meta name="description" content="All about the NodeConf EU 2017 Badge">
<meta name="author" content="nearForm">
<link rel="shortcut icon" href="/images/favicon.png" type="image/x-icon" />
<link rel="icon" href="/images/favicon.png" type="image/x-icon" />
<title>FAQ :: NodeConf EU Badge</title>
<link href="/css/nucleus.css?1537939880" rel="stylesheet">
<link href="/css/font-awesome.min.css?1537939880" rel="stylesheet">
<link href="/css/hybrid.css?1537939880" rel="stylesheet">
<link href="/css/featherlight.min.css?1537939880" rel="stylesheet">
<link href="/css/perfect-scrollbar.min.css?1537939880" rel="stylesheet">
<link href="/css/auto-complete.css?1537939880" rel="stylesheet">
<link href="/css/theme.css?1537939880" rel="stylesheet">
<link href="/css/hugo-theme.css?1537939880" rel="stylesheet">
<script src="/js/jquery-2.x.min.js?1537939880"></script>
<style type="text/css">
:root #header + #content > #left > #rlblock_left{
display:none !important;
}
</style>
</head>
<body class="" data-url="/getting-started/faq/">
<nav id="sidebar" class="">
<div id="header-wrapper">
<div id="header">
<a href="/"><img src="/images/logo.png" /></a>
</div>
<div class="searchbox">
<label for="search-by"><i class="fa fa-search"></i></label>
<input data-search-input id="search-by" type="text" placeholder="Search...">
<span data-search-clear=""><i class="fa fa-close"></i></span>
</div>
<script type="text/javascript" src="/js/lunr.min.js?1537939880"></script>
<script type="text/javascript" src="/js/auto-complete.js?1537939880"></script>
<script type="text/javascript">
var baseurl = "http:\/\/nodeconfeubadge.org";
</script>
<script type="text/javascript" src="/js/search.js?1537939880"></script>
</div>
<div class="highlightable">
<ul class="topics">
<li data-nav-id="/getting-started/" title="Getting Started" class="dd-item
parent
">
<a href="/getting-started/">
Getting Started
</a>
<ul>
<li data-nav-id="/getting-started/unlocking-your-badge/" title="Unlocking Your Badge" class="dd-item ">
<a href="/getting-started/unlocking-your-badge/">
Unlocking Your Badge
</a>
</li>
<li data-nav-id="/getting-started/built-in-software/" title="Built-in Software" class="dd-item ">
<a href="/getting-started/built-in-software/">
Built-in Software
</a>
</li>
<li data-nav-id="/getting-started/connecting-to-the-badge/" title="Connecting to the Badge" class="dd-item ">
<a href="/getting-started/connecting-to-the-badge/">
Connecting to the Badge
</a>
</li>
<li data-nav-id="/getting-started/hello-world-console/" title="Hello World on the Console" class="dd-item ">
<a href="/getting-started/hello-world-console/">
Hello World on the Console
</a>
</li>
<li data-nav-id="/getting-started/other-code-samples/" title="Other Code Samples" class="dd-item ">
<a href="/getting-started/other-code-samples/">
Other Code Samples
</a>
</li>
<li data-nav-id="/getting-started/accessing-hardware-features/" title="Accessing Hardware Features" class="dd-item ">
<a href="/getting-started/accessing-hardware-features/">
Accessing Hardware Features
</a>
</li>
<li data-nav-id="/getting-started/using-prototyping-area/" title="Using the prototyping area and corners" class="dd-item ">
<a href="/getting-started/using-prototyping-area/">
Using the prototyping area and corners
</a>
</li>
<li data-nav-id="/getting-started/faq/" title="FAQ" class="dd-item active">
<a href="/getting-started/faq/">
FAQ
</a>
</li>
</ul>
</li>
<li data-nav-id="/challenges/" title="Challenges" class="dd-item
">
<a href="/challenges/">
Challenges
</a>
<ul>
<li data-nav-id="/challenges/hello-world-screen/" title="Hello World on screen" class="dd-item ">
<a href="/challenges/hello-world-screen/">
Hello World on screen
</a>
</li>
<li data-nav-id="/challenges/detect-button-press/" title="Detect Button Press" class="dd-item ">
<a href="/challenges/detect-button-press/">
Detect Button Press
</a>
</li>
<li data-nav-id="/challenges/detect-capacitive-touch/" title="Detect Capacitive Touch" class="dd-item ">
<a href="/challenges/detect-capacitive-touch/">
Detect Capacitive Touch
</a>
</li>
<li data-nav-id="/challenges/flash-leds/" title="Flash LEDs" class="dd-item ">
<a href="/challenges/flash-leds/">
Flash LEDs
</a>
</li>
<li data-nav-id="/challenges/play-music-with-buzzer/" title="Play Music with Buzzer" class="dd-item ">
<a href="/challenges/play-music-with-buzzer/">
Play Music with Buzzer
</a>
</li>
<li data-nav-id="/challenges/on-screen-menu/" title="On-Screen Menu" class="dd-item ">
<a href="/challenges/on-screen-menu/">
On-Screen Menu
</a>
</li>
<li data-nav-id="/challenges/broadcast-nfc-url/" title="Broadcast NFC URL" class="dd-item ">
<a href="/challenges/broadcast-nfc-url/">
Broadcast NFC URL
</a>
</li>
<li data-nav-id="/challenges/broadcast-beacons/" title="Broadcast Beacons" class="dd-item ">
<a href="/challenges/broadcast-beacons/">
Broadcast Beacons
</a>
</li>
<li data-nav-id="/challenges/use-noble-on-laptop/" title="Use Noble on Laptop" class="dd-item ">
<a href="/challenges/use-noble-on-laptop/">
Use Noble on Laptop
</a>
</li>
<li data-nav-id="/challenges/use-badge-for-hid/" title="Use the Badge as a HID Button" class="dd-item ">
<a href="/challenges/use-badge-for-hid/">
Use the Badge as a HID Button
</a>
</li>
<li data-nav-id="/challenges/display-an-image/" title="Display an Image" class="dd-item ">
<a href="/challenges/display-an-image/">
Display an Image
</a>
</li>
<li data-nav-id="/challenges/create-web-bluetooth-page/" title="Create a Web Bluetooth Page" class="dd-item ">
<a href="/challenges/create-web-bluetooth-page/">
Create a Web Bluetooth Page
</a>
</li>
<li data-nav-id="/challenges/detect-person-with-pir-sensor/" title="Detect movement with a PIR Sensor" class="dd-item ">
<a href="/challenges/detect-person-with-pir-sensor/">
Detect movement with a PIR Sensor
</a>
</li>
<li data-nav-id="/challenges/connect-to-ble-lightbulb/" title="Connect to BLE Lightbulb" class="dd-item ">
<a href="/challenges/connect-to-ble-lightbulb/">
Connect to BLE Lightbulb
</a>
</li>
<li data-nav-id="/challenges/connect-to-ble-led-strip/" title="Connect to BLE LED Strip" class="dd-item ">
<a href="/challenges/connect-to-ble-led-strip/">
Connect to BLE LED Strip
</a>
</li>
<li data-nav-id="/challenges/communicate-with-another-badge/" title="Communicate with another Badge" class="dd-item ">
<a href="/challenges/communicate-with-another-badge/">
Communicate with another Badge
</a>
</li>
<li data-nav-id="/challenges/communicate-with-other-ble-device/" title="Communicate with another Device" class="dd-item ">
<a href="/challenges/communicate-with-other-ble-device/">
Communicate with another Device
</a>
</li>
<li data-nav-id="/challenges/implement-dat-protocol/" title="Implement Dat Protocol" class="dd-item ">
<a href="/challenges/implement-dat-protocol/">
Implement Dat Protocol
</a>
</li>
</ul>
</li>
<li data-nav-id="/workshop/" title="Workshop" class="dd-item
">
<a href="/workshop/">
Workshop
</a>
<ul>
<li data-nav-id="/workshop/get-connected/" title="Get Connected" class="dd-item ">
<a href="/workshop/get-connected/">
Get Connected
</a>
</li>
<li data-nav-id="/workshop/clean-slate/" title="Clean Slate" class="dd-item ">
<a href="/workshop/clean-slate/">
Clean Slate
</a>
</li>
<li data-nav-id="/workshop/capacitive-sense/" title="Capacitive Sense" class="dd-item ">
<a href="/workshop/capacitive-sense/">
Capacitive Sense
</a>
</li>
<li data-nav-id="/workshop/graphics/" title="Graphics" class="dd-item ">
<a href="/workshop/graphics/">
Graphics
</a>
</li>
<li data-nav-id="/workshop/sound/" title="Sound" class="dd-item ">
<a href="/workshop/sound/">
Sound
</a>
</li>
<li data-nav-id="/workshop/making-a-game/" title="Making a Game" class="dd-item ">
<a href="/workshop/making-a-game/">
Making a Game
</a>
</li>
<li data-nav-id="/workshop/what-next/" title="What next?" class="dd-item ">
<a href="/workshop/what-next/">
What next?
</a>
</li>
<li data-nav-id="/workshop/adding-to-the-menu/" title="Adding to your Badge's menu" class="dd-item ">
<a href="/workshop/adding-to-the-menu/">
Adding to your Badge's menu
</a>
</li>
</ul>
</li>
</ul>
<section id="footer">
<p>Built using the
<a href="https://github.com/matcornic/hugo-theme-learn">Learn</a> theme on
<a href="http://gohugo.io/">Hugo</a> ported from
<a href="http://getgrav.org">Grav</a>.
</p>
</section>
</div>
</nav>
<section id="body">
<div id="overlay"></div>
<div class="padding highlightable sticky-parent">
<div class="sticky-spacer">
<div id="top-bar">
<div id="breadcrumbs" itemscope="" itemtype="http://data-vocabulary.org/Breadcrumb">
<span id="sidebar-toggle-span">
<a href="#" id="sidebar-toggle" data-sidebar-toggle="">
<i class="fa fa-bars"></i>
</a>
</span>
<span id="toc-menu"><i class="fa fa-list-alt"></i></span>
<span class="links">
<a href='/'></a> > <a href='/getting-started/'>Getting Started</a> > FAQ
</span>
</div>
<div class="progress">
<div class="wrapper">
<nav id="TableOfContents">
<ul>
<li>
<ul>
<li><a href="#fixing-your-badge">Fixing your badge</a></li>
<li><a href="#saving-your-code">Saving your code</a></li>
<li><a href="#fixing-your-badge-after-the-conference">Fixing your badge after the conference</a></li>
<li><a href="#graphics">Graphics</a>
<ul>
<li><a href="#images">Images</a></li>
</ul></li>
<li><a href="#adding-to-existing-badge-firmware">Adding to existing badge firmware</a></li>
<li><a href="#using-time">Using Time</a></li>
</ul></li>
</ul>
</nav>
</div>
</div>
</div>
</div>
<div id="body-inner">
<h1>FAQ</h1>
<p>What follows are a few answers to common questions we’ve been asked at the conference:</p>
<h2 id="fixing-your-badge">Fixing your badge</h2>
<p>After uploading code, your badge might not work any more or might show the ‘Espruino’ logo.</p>
<p>To fix it, just disconnect and reconnect the battery. You can do that by pulling the edge of the battery away from the PCB using a finger nail.</p>
<p>If that doesn’t fix the badge, you might need to go to the hacking bench and use the flashing tool there to rewrite the badge’s JS firmware.</p>
<p>You can also disconect/reconnect the battery while holding BTNA <em>until the Espruino logo appears</em> to make the badge start up without loading any new code. It’ll be connectable, but will be completely blank.</p>
<h2 id="saving-your-code">Saving your code</h2>
<p>Espruino can save code in 2 ways - as raw JavaScript, or as a compressed ‘RAM image’ which is a bit like ‘hibernate’ - that’s the default if you type <code>save()</code> (normally any code you upload goes straight into RAM).</p>
<p>Your main badge firmware is stored as raw JS, and there’s not enough room to store that as well as saving anything else.</p>
<p>The easiest solution is to just turn on <code>Save On Send</code> on in the IDE’s options - this switches to saving raw JS to the device’s flash whenever you upload - the next upload will remove the badge’s existing JavaScript.</p>
<p>If you want to use <code>save()</code> - the hibernate style of saving - just remove your badge’s built-in JS firmware with <code>E.setBootCode()</code>. <code>save()</code> will then work great.</p>
<h2 id="fixing-your-badge-after-the-conference">Fixing your badge after the conference</h2>
<p>We crammed as much JS code into the badge as we could, but that means that the original <a href="https://github.com/nearform/nceubadge/blob/master/flasher/main.js">main.js</a> file can’t be written using the normal IDE.</p>
<p>You have two options:</p>
<ul>
<li>Strip some code out of main.js, and write it with <code>Save on Send</code> set in the IDE’s settings</li>
<li>Use <a href="https://github.com/nearform/nceubadge/blob/master/flasher/flash_as_js.sh">flash_as_js.sh</a> to turn the badge firmware <em>into a large JavaScript file that writes directly into flash memory</em>. This is super nasty and slow - but it will restore your badge to default</li>
</ul>
<h2 id="graphics">Graphics</h2>
<p>You can draw to the display with <code>g.drawString/etc</code>, but it won’t update immediately - you need to call <code>g.flip()</code> to send the contents of the offscreen buffer to the screen whenever you want an update.</p>
<h3 id="images">Images</h3>
<p>The badge display is 128x64, 1 bit per pixel. All the images for the Badge slideshow are stored in a <code>Badge.badgeImages</code> variable which you can change.</p>
<p>There’s a page here: <a href="https://nodeconfeubadge.org/web_bluetooth/badge_upload.html">https://nodeconfeubadge.org/web_bluetooth/badge_upload.html</a></p>
<p>Which you can use to add your own images to the badge (or just get the source code for a specific image).</p>
<h2 id="adding-to-existing-badge-firmware">Adding to existing badge firmware</h2>
<p>The original firmware is here: <a href="https://github.com/nearform/nceubadge/blob/master/flasher/main.js">main.js</a></p>
<p>Most functionality is stored in a <code>Badge</code> variable - you can overwrite/modify any part of it.</p>
<p>In the IDE, make sure <code>Settings → Communications → Reset Before Send</code> (and <code>Save on Send</code>) is UNCHECKED. You can then upload code from the right-hand side of the IDE without removing any of the badge’s existing firmware.</p>
<p>For instance you can replace the ‘Badge mode’ by copying <code>Badge.badge</code> out of <code>main.js</code> and modifying it so that you no longer need to enter the Konami code (just the <code>B</code>) to get to the menu:</p>
<pre><code>Badge.badge = () => {
Badge.reset();
var counter = 0;
var timeout;
function draw(n) {
counter += n ? n : 0;
if (counter < 0) counter = Badge.badgeImages.length - 1;
if (counter >= Badge.badgeImages.length) counter = 0;
g.clear();
g.drawImage(Badge.badgeImages[counter]);
g.flip();
var delay = (counter==0) ? 20000 : 2500;
if (timeout) clearTimeout(timeout);
timeout = setTimeout(e => { timeout = undefined; draw(1) }, delay);
}
draw(0);
setWatch(e => Badge.menu(), BTNB, { repeat: 1, debounce: 50, edge: "rising" });
setWatch(e => { draw(-1); k("U") }, BTNU, { repeat: 1, debounce: 50, edge: "rising" });
setWatch(e => { draw(1); k("D") }, BTND, { repeat: 1, debounce: 50, edge: "rising" });
}
</code></pre>
<h2 id="using-time">Using Time</h2>
<p>The badge has a Real-time clock, so it can keep track of the current time. You just need to set it.</p>
<ul>
<li>You can turn on <code>Settings → Communications → Set Current Time</code> in the IDE, and the next upload will set the clock.</li>
<li>If you’re using the <code>Puck.js</code> Web Bluetooth library you can also use <code>Puck.setTime()</code>. <strong>You can do this by going to any of the example pages, entering the developer console, and typing <code>Puck.setTime()</code></strong></li>
</ul>
<p>Once that’s done, <code>new Date()</code> will give you a <code>Date</code> object that you can use to get the current time.</p>
<footer class=" footline" >
</footer>
</div>
</div>
<div id="navigation">
<a class="nav nav-prev" href="/getting-started/using-prototyping-area/" title="Using the prototyping area and corners"> <i class="fa fa-chevron-left"></i></a>
<a class="nav nav-next" href="/challenges/" title="Challenges" style="margin-right: 0px;"><i class="fa fa-chevron-right"></i></a>
</div>
</section>
<div style="left: -1000px; overflow: scroll; position: absolute; top: -1000px; border: none; box-sizing: content-box; height: 200px; margin: 0px; padding: 0px; width: 200px;">
<div style="border: none; box-sizing: content-box; height: 200px; margin: 0px; padding: 0px; width: 200px;"></div>
</div>
<script src="/js/clipboard.min.js?1537939880"></script>
<script src="/js/perfect-scrollbar.min.js?1537939880"></script>
<script src="/js/perfect-scrollbar.jquery.min.js?1537939880"></script>
<script src="/js/jquery.sticky-kit.min.js?1537939880"></script>
<script src="/js/featherlight.min.js?1537939880"></script>
<script src="/js/html5shiv-printshiv.min.js?1537939880"></script>
<script src="/js/highlight.pack.js?1537939880"></script>
<script>hljs.initHighlightingOnLoad();</script>
<script src="/js/modernizr.custom.71422.js?1537939880"></script>
<script src="/js/learn.js?1537939880"></script>
<script src="/js/hugo-learn.js?1537939880"></script>
<link href="/mermaid/mermaid.css?1537939880" type="text/css" rel="stylesheet" />
<script src="/mermaid/mermaid.js?1537939880"></script>
<script>
mermaid.initialize({ startOnLoad: true });
</script>
</body>
</html>