Difference between revisions of "Projects:Badge/Splash"

From SHA2017 Wiki
Jump to: navigation, search
(NVS settings)
(NVS settings)
Line 81: Line 81:
 
10 times)
 
10 times)
 
|-
 
|-
| Example || Example || uint16 || Example
+
| badge || mpr121.base.0 || uint16 || Touch baseline for the A button
 
|-
 
|-
| Example || Example || uint16 || Example
+
| badge || mpr121.base.1 || uint16 || Touch baseline for the B button
 
|-
 
|-
| Example || Example || uint16 || Example
+
| badge || mpr121.base.2 || uint16 || Touch baseline for the START button
 
|-
 
|-
| Example || Example || uint16 || Example
+
| badge || mpr121.base.3 || uint16 || Touch baseline for the SELECT button
 +
|-
 +
| badge || mpr121.base.4 || uint16 || Touch baseline for the DOWN button
 +
|-
 +
| badge || mpr121.base.5 || uint16 || Touch baseline for the RIGHT button
 +
|-
 +
| badge || mpr121.base.6 || uint16 || Touch baseline for the UP button
 +
|-
 +
| badge || mpr121.base.7 || uint16 || Touch baseline for the LEFT button
 
|}
 
|}

Revision as of 11:03, 18 July 2017

Badge splash screen service API

Introduction to splash screen services

What is a service?

A service is a small program bundled with an app which allows apps to execute background tasks while the badge shows the splash / home screen.

How can I create a service?

A service is a small program included with an app as a separate Python file, from which a couple of functions are executed. The file should be called “service.py” and it should be bundled with your app files.

What does a service script look like?

Each service script contains three functions: setup, loop and draw. Each of this functions is called by the splash application at different moments. In the next chapter of this document each of these three functions will be discussed in detail.

API

Your service has to contain each of the following three functions, even if no action is to be performed at all.

void setup ( void )

The setup function is called directly after wakeup and is to be used to initialize the service.

prevent_sleep loop ( counter )

The loop function is called by a timer ran a configurable amount of times before the badge starts sleeping again. Sleep can be prevented by returning True. Normal operation requires this function to return False.

The counter value represents the amount of times the loop function will be ran before the badge starts sleeping. The lowest value your service will see is 1, when the counter is at 1 the current execution will be the last one before sleep kicks in.

height draw ( x , y )

This function is called just before the screen is updated and allows your service to add information or widgets to the homescreen. The x and y coordinates provided to you are the location of the bottom-left corner of the location designated to your service. Currently x is always set to 0 and you may use the full width of the screen. The return value should be set to the amount of pixels used by your information string or widget. The next widget will be drawn upwards from coordinate (x+height, 0).

Should you decide not to use the location appointed to you then please return 0. Also note that conflicts between multiple services can occur if you place your content at an arbitrary place on the screen. Because of this I suggest you to never do that. Unless of course the purpose of your app is overriding existing elements like the nickname.

NVS settings

Namespace Key Type Info
badge wifi.ssid string WiFi access point to connect to
badge wifi.password string WiFi password (optional)
owner name string Your (nick) name
splash header.invert uint8 0: normal operation, 1: inverted

Controls the way the header is drawn (default: 0)

splash header.hws uint8 0: normal operation, 1: hide header while sleeping

(default: 0)

splash header.hbws uint8 0: normal operation, 1: hide battery indicator while sleeping

(default: 0)

splash sleep.duration uint16 30000 up to 120000 (default: 60000)

Amount of time the badge deep-sleeps between updates

splash battery.volt.min uint16 Voltage of battery when completely empty in mV (default: 3800)
splash battery.volt.max uint16 Voltage of battery when completely full (n mV (default: 4300)
splash battery.percent.empty uint8 Battery percentage below which the badge will become unusable

(default: 1)

splash ntp.timeout uint8 Amount of connection tries before NTP fails

(default: 40)

splash bpp.count uint8 Amount of wake-up or reboot cycles before BPP triggers

(default: 5)

splash timer.interval uint16 Interval between timer executions (default: 500ms)
splash timer.amount uint8 Amount of times the timer loops before sleep is invoked (default:

10 times)

badge mpr121.base.0 uint16 Touch baseline for the A button
badge mpr121.base.1 uint16 Touch baseline for the B button
badge mpr121.base.2 uint16 Touch baseline for the START button
badge mpr121.base.3 uint16 Touch baseline for the SELECT button
badge mpr121.base.4 uint16 Touch baseline for the DOWN button
badge mpr121.base.5 uint16 Touch baseline for the RIGHT button
badge mpr121.base.6 uint16 Touch baseline for the UP button
badge mpr121.base.7 uint16 Touch baseline for the LEFT button