1
0

initial commit

This commit is contained in:
2023-04-04 20:48:51 +02:00
commit 3cf894b67f
21 changed files with 1002 additions and 0 deletions

43
pdctest-281063/jshintrc Normal file
View File

@@ -0,0 +1,43 @@
/*
* Example jshint configuration file for Pebble development.
*
* Check out the full documentation at http://www.jshint.com/docs/options/
*/
{
// Declares the existence of the globals available in PebbleKit JS.
"globals": {"localStorage": true, "Int16Array": true, "Uint32Array": true, "setTimeout": true, "Uint8ClampedArray": true, "navigator": true, "setInterval": true, "WebSocket": true, "Int32Array": true, "Uint8Array": true, "Float64Array": true, "Int8Array": true, "XMLHttpRequest": true, "Uint16Array": true, "Float32Array": true, "console": true, "Pebble": true},
// Do not mess with standard JavaScript objects (Array, Date, etc)
"freeze": true,
// Do not use eval! Keep this warning turned on (ie: false)
"evil": false,
/*
* The options below are more style/developer dependent.
* Customize to your liking.
*/
// All variables should be in camelcase - too specific for CloudPebble builds to fail
// "camelcase": true,
// Do not allow blocks without { } - too specific for CloudPebble builds to fail.
// "curly": true,
// Prohibits the use of immediate function invocations without wrapping them in parentheses
"immed": true,
// Don't enforce indentation, because it's not worth failing builds over
// (especially given our somewhat lacklustre support for it)
"indent": false,
// Do not use a variable before it's defined
"latedef": "nofunc",
// Spot undefined variables
"undef": "true",
// Spot unused variables
"unused": "true"
}

View File

@@ -0,0 +1,52 @@
{
"author": "lastfuture@lastfuture.de",
"dependencies": {},
"keywords": [],
"name": "pdctest",
"pebble": {
"displayName": "pdctest",
"enableMultiJS": false,
"messageKeys": [],
"projectType": "native",
"resources": {
"media": [
{
"file": "data/moonshape4.pdc",
"name": "MOONSHAPE4",
"targetPlatforms": null,
"type": "raw"
},
{
"file": "data/moonshape3.pdc",
"name": "MOONSHAPE3",
"targetPlatforms": null,
"type": "raw"
},
{
"file": "data/moonshape2.pdc",
"name": "MOONSHAPE2",
"targetPlatforms": null,
"type": "raw"
},
{
"file": "data/moonshape.pdc",
"name": "MOONSHAPE",
"targetPlatforms": null,
"type": "raw"
},
{
"file": "data/image.pdc",
"name": "IMAGE",
"targetPlatforms": null,
"type": "raw"
}
]
},
"sdkVersion": "3",
"uuid": "2d00df02-2c1f-4217-b033-ba2b2024fdae",
"watchapp": {
"watchface": false
}
},
"version": "1.0.0"
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,74 @@
/**
* main.c - Sets up a Window and Layer that draws the GDrawCommandImage
* in its LayerUpdateProc.
*/
#include <pebble.h>
static Window *s_main_window;
static Layer *s_canvas_layer;
static GDrawCommandImage *s_command_image;
static void update_proc(Layer *layer, GContext *ctx) {
// Place image in the center of the Window
GSize img_size = gdraw_command_image_get_bounds_size(s_command_image);
GRect bounds = layer_get_bounds(layer);
const GEdgeInsets frame_insets = {
.top = (bounds.size.h - img_size.h) / 2,
.left = (bounds.size.w - img_size.w) / 2
};
// If the image was loaded successfully...
if (s_command_image) {
// Draw it
gdraw_command_image_draw(ctx, s_command_image, grect_inset(bounds, frame_insets).origin);
}
}
static void window_load(Window *window) {
Layer *window_layer = window_get_root_layer(window);
GRect bounds = layer_get_bounds(window_layer);
// Load the image and check it was succcessful
s_command_image = gdraw_command_image_create_with_resource(RESOURCE_ID_MOONSHAPE4);
if (!s_command_image) {
APP_LOG(APP_LOG_LEVEL_ERROR, "Image is NULL!");
}
// Create canvas Layer and set up the update procedure
s_canvas_layer = layer_create(bounds);
layer_set_update_proc(s_canvas_layer, update_proc);
layer_add_child(window_layer, s_canvas_layer);
}
static void window_unload(Window *window) {
// Destroy canvas Layer
layer_destroy(s_canvas_layer);
// Destroy the image
gdraw_command_image_destroy(s_command_image);
}
static void init() {
// Set up main Window
s_main_window = window_create();
window_set_background_color(s_main_window, GColorFromHEX(0xbbbbbb));
window_set_window_handlers(s_main_window, (WindowHandlers) {
.load = window_load,
.unload = window_unload,
});
window_stack_push(s_main_window, true);
}
static void deinit() {
// Destroy main Window
window_destroy(s_main_window);
}
int main() {
init();
app_event_loop();
deinit();
}

62
pdctest-281063/wscript Normal file
View File

@@ -0,0 +1,62 @@
#
# This file is the default set of rules to compile a Pebble project.
#
# Feel free to customize this to your needs.
#
import os.path
try:
from sh import CommandNotFound, jshint, cat, ErrorReturnCode_2
hint = jshint
except (ImportError, CommandNotFound):
hint = None
top = '.'
out = 'build'
def options(ctx):
ctx.load('pebble_sdk')
def configure(ctx):
ctx.load('pebble_sdk')
def build(ctx):
if False and hint is not None:
try:
hint([node.abspath() for node in ctx.path.ant_glob("src/**/*.js")], _tty_out=False) # no tty because there are none in the cloudpebble sandbox.
except ErrorReturnCode_2 as e:
ctx.fatal("\nJavaScript linting failed (you can disable this in Project Settings):\n" + e.stdout)
# Concatenate all our JS files (but not recursively), and only if any JS exists in the first place.
ctx.path.make_node('src/js/').mkdir()
js_paths = ctx.path.ant_glob(['src/*.js', 'src/**/*.js'])
if js_paths:
ctx(rule='cat ${SRC} > ${TGT}', source=js_paths, target='pebble-js-app.js')
has_js = True
else:
has_js = False
ctx.load('pebble_sdk')
build_worker = os.path.exists('worker_src')
binaries = []
for p in ctx.env.TARGET_PLATFORMS:
ctx.set_env(ctx.all_envs[p])
ctx.set_group(ctx.env.PLATFORM_NAME)
app_elf='{}/pebble-app.elf'.format(p)
ctx.pbl_program(source=ctx.path.ant_glob('src/c/**/*.c'),
target=app_elf)
if build_worker:
worker_elf='{}/pebble-worker.elf'.format(p)
binaries.append({'platform': p, 'app_elf': app_elf, 'worker_elf': worker_elf})
ctx.pbl_worker(source=ctx.path.ant_glob('worker_src/c/**/*.c'),
target=worker_elf)
else:
binaries.append({'platform': p, 'app_elf': app_elf})
ctx.set_group('bundle')
ctx.pbl_bundle(binaries=binaries, js='pebble-js-app.js' if has_js else [])