mirror of
https://github.com/pebble-dev/clay.git
synced 2026-09-05 16:47:37 -04:00
[WIP] - Basic SimpleAppMessage integration for ints.
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
# Ignore build generated files
|
||||
build/
|
||||
dist/
|
||||
dist.zip
|
||||
|
||||
# Ignore waf lock file
|
||||
.lock-waf*
|
||||
|
||||
# Ignore installed node modules
|
||||
node_modules/
|
||||
@@ -0,0 +1,30 @@
|
||||
cmake_minimum_required (VERSION 3.2)
|
||||
project (test-project)
|
||||
|
||||
set(CMAKE_C_FLAGS "-std=c11 -mthumb -ffunction-sections -g -fno-diagnostics-show-caret -D_REENT_SMALL=1 -Wall -Wextra -Werror -Wpointer-arith -Wno-unused-parameter -Wno-missing-field-initializers -Wno-error=unused-function -Wno-error=unused-variable -Wno-error=unused-parameter -Wno-error=unused-but-set-variable -Wno-packed-bitfield-compat -mcpu=cortex-m3 -Os -Werror=return-type")
|
||||
|
||||
file(GLOB_RECURSE src "src/*")
|
||||
file(GLOB_RECURSE build "build/basalt/*.c")
|
||||
|
||||
set(SOURCES
|
||||
${src}
|
||||
${build}
|
||||
)
|
||||
|
||||
set(INCLUDES
|
||||
~/Library/Application\ Support/Pebble\ SDK/SDKs/current/sdk-core/pebble/basalt/include
|
||||
./node_modules/pebble-events/dist/include
|
||||
./node_modules/@keegan-stoneware/simple-dict/dist/include
|
||||
./node_modules/pebble-clay/dist/include
|
||||
./build/include
|
||||
./build
|
||||
./include
|
||||
)
|
||||
|
||||
add_definitions(-DPEBBLE)
|
||||
add_definitions(-DPBL_COLOR)
|
||||
|
||||
include_directories(${INCLUDES})
|
||||
|
||||
add_executable(app ${SOURCES})
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
{
|
||||
"name": "clay-test",
|
||||
"author": "MakeAwesomeHappen",
|
||||
"version": "1.0.0",
|
||||
"keywords": [
|
||||
"pebble-app"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "./scripts/build.sh"
|
||||
},
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"pebble-clay": "../"
|
||||
},
|
||||
"pebble": {
|
||||
"displayName": "clay-test",
|
||||
"uuid": "3fff53d2-1b59-48d7-8187-0c2f3674c32d",
|
||||
"sdkVersion": "3",
|
||||
"enableMultiJS": true,
|
||||
"targetPlatforms": [
|
||||
"aplite",
|
||||
"basalt",
|
||||
"chalk",
|
||||
"diorite"
|
||||
],
|
||||
"watchapp": {
|
||||
"watchface": false
|
||||
},
|
||||
"messageKeys": [],
|
||||
"resources": {
|
||||
"media": []
|
||||
}
|
||||
}
|
||||
}
|
||||
Executable
+9
@@ -0,0 +1,9 @@
|
||||
#!/bin/bash
|
||||
|
||||
test_app_folder_name="clay-test"
|
||||
if [ "$(basename $(pwd))" != "$test_app_folder_name" ]; then
|
||||
echo "Must be executed from $test_app_folder_name folder"
|
||||
exit
|
||||
fi
|
||||
|
||||
pebble clean && cd .. && npm run pebble-build || { cd $test_app_folder_name && exit; } && cd $test_app_folder_name && pebble build
|
||||
@@ -0,0 +1,69 @@
|
||||
#include <inttypes.h>
|
||||
#include <pebble.h>
|
||||
#include <pebble-clay/clay.h>
|
||||
|
||||
#define CLAY_INBOX_SIZE (64)
|
||||
|
||||
static Window *s_window;
|
||||
static int s_background_color;
|
||||
|
||||
static void draw_background(Layer *layer, GContext *ctx) {
|
||||
graphics_context_set_fill_color(ctx, GColorFromHEX(s_background_color));
|
||||
graphics_fill_rect(ctx, layer_get_bounds(layer), 0, GCornerNone);
|
||||
}
|
||||
|
||||
static void prv_update_layer(Layer *layer, GContext *ctx) {
|
||||
draw_background(layer, ctx);
|
||||
}
|
||||
|
||||
|
||||
static void prv_window_unload(Window *window) {
|
||||
window_destroy(window);
|
||||
}
|
||||
|
||||
static void prv_window_load(Window *window) {
|
||||
layer_set_update_proc(window_get_root_layer(s_window), prv_update_layer);
|
||||
}
|
||||
|
||||
static void prv_clay_updated_handler(void *context) {
|
||||
int value_int;
|
||||
if (clay_get_int("test_int", &value_int)) {
|
||||
s_background_color = value_int;
|
||||
}
|
||||
|
||||
layer_mark_dirty(window_get_root_layer(s_window));
|
||||
}
|
||||
|
||||
static void prv_init(void) {
|
||||
|
||||
const ClayCallbacks clay_callbacks = (ClayCallbacks) {
|
||||
.settings_updated = prv_clay_updated_handler,
|
||||
};
|
||||
clay_register_callbacks(&clay_callbacks, NULL);
|
||||
|
||||
clay_init(CLAY_INBOX_SIZE);
|
||||
|
||||
s_window = window_create();
|
||||
window_set_window_handlers(s_window, (WindowHandlers) {
|
||||
.load = prv_window_load,
|
||||
.unload = prv_window_unload,
|
||||
});
|
||||
|
||||
window_stack_push(s_window, true);
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
prv_init();
|
||||
app_event_loop();
|
||||
}
|
||||
|
||||
|
||||
|
||||
//int s_background_color = 0xffffff;
|
||||
//#define TEXT_SIZE 20;
|
||||
//char s_text [TEXT_SIZE];
|
||||
//
|
||||
//void clay_update_handler(void *ctx) {
|
||||
// clay_get_int("background_color", &s_background_color);
|
||||
// clay_get_string("background_color", &s_text, TEXT_SIZE - 1);
|
||||
//}
|
||||
@@ -0,0 +1,19 @@
|
||||
'use strict';
|
||||
var Clay = require('pebble-clay');
|
||||
var clay = new Clay({
|
||||
config: [
|
||||
{
|
||||
label: 'test',
|
||||
type: 'color',
|
||||
messageKey: 'test_int'
|
||||
},
|
||||
{
|
||||
type: 'submit',
|
||||
defaultValue: 'submit'
|
||||
}
|
||||
],
|
||||
closedCallback: function(response) {
|
||||
console.log('closedcallback: arguments' + JSON.stringify(arguments));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
#
|
||||
# This file is the default set of rules to compile a Pebble application.
|
||||
#
|
||||
# Feel free to customize this to your needs.
|
||||
#
|
||||
import os.path
|
||||
import shutil
|
||||
import waflib
|
||||
|
||||
top = '.'
|
||||
out = 'build'
|
||||
|
||||
|
||||
def options(ctx):
|
||||
ctx.load('pebble_sdk')
|
||||
|
||||
|
||||
def distclean(ctx):
|
||||
node_modules_dir = ctx.path.find_node('node_modules')
|
||||
if node_modules_dir:
|
||||
shutil.rmtree(node_modules_dir.abspath())
|
||||
waflib.Scripting.distclean(ctx)
|
||||
|
||||
|
||||
def configure(ctx):
|
||||
"""
|
||||
This method is used to configure your build. ctx.load(`pebble_sdk`) automatically configures
|
||||
a build for each valid platform in `targetPlatforms`. Platform-specific configuration: add your
|
||||
change after calling ctx.load('pebble_sdk') and make sure to set the correct environment first.
|
||||
Universal configuration: add your change prior to calling ctx.load('pebble_sdk').
|
||||
"""
|
||||
ctx.load('pebble_sdk')
|
||||
|
||||
|
||||
def build(ctx):
|
||||
ctx.load('pebble_sdk')
|
||||
|
||||
build_worker = os.path.exists('worker_src')
|
||||
binaries = []
|
||||
|
||||
cached_env = ctx.env
|
||||
for platform in ctx.env.TARGET_PLATFORMS:
|
||||
ctx.env = ctx.all_envs[platform]
|
||||
ctx.set_group(ctx.env.PLATFORM_NAME)
|
||||
app_elf = '{}/pebble-app.elf'.format(ctx.env.BUILD_DIR)
|
||||
ctx.pbl_program(source=ctx.path.ant_glob('src/**/*.c'), target=app_elf)
|
||||
|
||||
if build_worker:
|
||||
worker_elf = '{}/pebble-worker.elf'.format(ctx.env.BUILD_DIR)
|
||||
binaries.append({'platform': platform, 'app_elf': app_elf, 'worker_elf': worker_elf})
|
||||
ctx.pbl_worker(source=ctx.path.ant_glob('worker_src/**/*.c'), target=worker_elf)
|
||||
else:
|
||||
binaries.append({'platform': platform, 'app_elf': app_elf})
|
||||
ctx.env = cached_env
|
||||
|
||||
ctx.set_group('bundle')
|
||||
ctx.pbl_bundle(binaries=binaries,
|
||||
js=ctx.path.ant_glob(['src/js/**/*.js', 'src/js/**/*.json']),
|
||||
js_entry_file='src/js/app.js')
|
||||
Reference in New Issue
Block a user