overlay technique | pebble developer retreat 2014
DESCRIPTION
You can find the video presentation here: http://youtu.be/VhVjCnF-Y0M Ron Ravid and Grégoire Sage cover the Overlay technique and how to load parts of code from resources. Day 2 - Video 4TRANSCRIPT
Overlays Tec hniqueRon & Grégoire
Overlays technique 2
What's an overlay ?
http://www.wikiwand.com/en/Overlay
In a general computing sense, overlaying means "replacement of a block of stored instructions or data with another."
Overlaying is a programming method that allows programs to be larger than the computer's main memory.
Overlays technique 3
Overlay ma pping
Overlays technique 4
Our Build Proc es s1.Generate an initial LD script2.First build of the app3.Calculate the size of the overlay sections4.Generate final LD script5.Second build of the app6.Extract overlays sections from the elf to
external resource file7.Trim elf file to remove overlays section8.Very final build
Overlays technique 5
Generate the initia l L D s c ript
1 / 8
Overlay configurationSelecting files (from sources or libraries) for every overlay section
Overlays technique 6
Generate the initia l L D s c ript
1 / 8
Generated LD script
Overlays technique 7
F irs t build of the a pp
pebble build
The overlays sections are mapped at a default hard-coded position
2 / 8
Overlays technique 8
C a lc ulate the overlay s ec tion s izearm-none-ea bi-reade lf -S build/pebble-app.elf
Maximum overlay section size = 0x1D00
3 / 8
Overlays technique 9
Generate fina l L D s c ript
Maximum overlay section sizeSize of main app
= 0x1D00 + 0x2600
4 / 8
Overlays technique 10
Generate fina l L D s c ript
Overlay Table
4 / 8
Overlays technique 11
S ec ond build of the a pp
pebble build
Every section will be mapped in its correct position thanks to the final LD script
5 / 8
Overlays technique 12
E xtrac t overlays from e lf
Extract the compiled code in the overlay sections to one unique resource binary file.
6 / 8
Overlays technique 13
T hird and fina l build of the a pp
pebble build
Pack the previously generated binary resource in the app
7 / 8
Overlays technique 14
Trim the e lf file
Remove the extracted overlay compiled code from the elf file to reduce its size (optional)
8 / 8
Overlays technique 15
T he a pp is ready !
Overlays technique 16
How to load an overlay ?
Overlays technique 17
How to load an overlay ?
Overlays technique 18
Pos s ible a pplic ations
If your app can be divided in independant parts,more parts can be added.
Example:Heap Usage for App <Pebblets>: Total Size <3632B> Used <2928B> Still allocated <40B>
Only 700 bytes remaining...
Any application that not all of its parts are active simultaneously
Overlays technique 19
Adjus ting c ode for overlay● Change any string array from form of c ons t c har* days [] to
c ons t c har days [][12] (one-two bytes bigger than length of your longest string.)
● If you use GPath, move your GPath data to external file with setup function
● menu_layer_set_callbacks. Instead of defining 'MenuLayerCallbacks menu_callbacks' and giving it to that function as parameter, put it directly inside the 3rd parameter of menu_layer_set_callbacks like: (MenuL ayerC a llbac ks ){ .get_num_row s = get_num_row s , .draw _row = draw _row, .s e lec t_c lic k = s e lec t_c lic k });
● vibes_enqueue_custom_pattern. Move your custom pattern to external non-overlay file.
Overlays technique 20
C ha llenges
● Overlay slot● Debugging information
Overlays technique 21
Try it
Some apps in the appstore :
- F ina lly (12 watchfaces in one)- PPOS Demo (concept for a point of sale demo) with source code, & detailed readme- Pebble Demos (all the SDK demos + compass in one app) with source code* check the links to source code on GitHub