mirror of
https://github.com/google/pebble.git
synced 2025-07-03 22:06:19 +00:00
Import of the watch repository from Pebble
This commit is contained in:
commit
3b92768480
10334 changed files with 2564465 additions and 0 deletions
17
src/apps/app_heap_demo/appinfo.json
Normal file
17
src/apps/app_heap_demo/appinfo.json
Normal file
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"uuid": "5900750a-b7e4-439c-890d-a7b2d2d29fc2",
|
||||
"shortName": "AppHeap Demo",
|
||||
"longName": "AppHeap Demo",
|
||||
"companyName": "Pebble Technology",
|
||||
"versionCode": 1,
|
||||
"versionLabel": "1.0",
|
||||
"watchapp": {
|
||||
"watchface": false
|
||||
},
|
||||
"appKeys": {
|
||||
"dummy": 0
|
||||
},
|
||||
"resources": {
|
||||
"media": []
|
||||
}
|
||||
}
|
67
src/apps/app_heap_demo/src/app_heap_demo.c
Normal file
67
src/apps/app_heap_demo/src/app_heap_demo.c
Normal file
|
@ -0,0 +1,67 @@
|
|||
/*
|
||||
* Copyright 2024 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <pebble.h>
|
||||
|
||||
#define ALLOC_SIZE 2048
|
||||
|
||||
static Window *window;
|
||||
static TextLayer *text_heap_info;
|
||||
|
||||
static unsigned s_alloc_total = 0;
|
||||
static char s_text_buf[80];
|
||||
|
||||
static void select_click_handler(ClickRecognizerRef recognizer, void *context) {
|
||||
char *buf = malloc(ALLOC_SIZE);
|
||||
if (buf == NULL) {
|
||||
snprintf(s_text_buf, 80, "Heap full at %dB", s_alloc_total);
|
||||
text_layer_set_text(text_heap_info, s_text_buf);
|
||||
return;
|
||||
}
|
||||
s_alloc_total += ALLOC_SIZE;
|
||||
snprintf(s_text_buf, 80, "%dB allocated", s_alloc_total);
|
||||
text_layer_set_text(text_heap_info, s_text_buf);
|
||||
}
|
||||
|
||||
static void config_provider(void *context) {
|
||||
window_single_click_subscribe(BUTTON_ID_SELECT, select_click_handler);
|
||||
}
|
||||
|
||||
static void init() {
|
||||
window = window_create();
|
||||
window_set_click_config_provider(window, config_provider);
|
||||
window_stack_push(window, true /* Animated */);
|
||||
Layer *window_layer = window_get_root_layer(window);
|
||||
|
||||
text_heap_info = text_layer_create(layer_get_frame(window_layer));
|
||||
text_layer_set_text_color(text_heap_info, GColorWhite);
|
||||
text_layer_set_background_color(text_heap_info, GColorBlack);
|
||||
text_layer_set_font(text_heap_info, fonts_get_system_font(FONT_KEY_GOTHIC_28_BOLD));
|
||||
|
||||
snprintf(s_text_buf, 80, "Press [SELECT] to allocate %dB", ALLOC_SIZE);
|
||||
text_layer_set_text(text_heap_info, s_text_buf);
|
||||
layer_add_child(window_layer, text_layer_get_layer(text_heap_info));
|
||||
}
|
||||
|
||||
static void deinit(void) {
|
||||
// Don't free anything
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
init();
|
||||
app_event_loop();
|
||||
deinit();
|
||||
}
|
25
src/apps/app_heap_demo/wscript
Normal file
25
src/apps/app_heap_demo/wscript
Normal file
|
@ -0,0 +1,25 @@
|
|||
|
||||
#
|
||||
# This file is the default set of rules to compile a Pebble project.
|
||||
#
|
||||
# Feel free to customize this to your needs.
|
||||
#
|
||||
|
||||
top = '.'
|
||||
out = 'build'
|
||||
|
||||
def options(ctx):
|
||||
ctx.load('pebble_sdk')
|
||||
|
||||
def configure(ctx):
|
||||
ctx.load('pebble_sdk')
|
||||
|
||||
def build(ctx):
|
||||
ctx.load('pebble_sdk')
|
||||
|
||||
ctx.pbl_program(source=ctx.path.ant_glob('src/**/*.c'),
|
||||
target='pebble-app.elf')
|
||||
|
||||
ctx.pbl_bundle(elf='pebble-app.elf',
|
||||
js=ctx.path.ant_glob('js/**/*.js'))
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue