initial commit
This commit is contained in:
43
colortest-290905/jshintrc
Normal file
43
colortest-290905/jshintrc
Normal 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"
|
||||
}
|
||||
24
colortest-290905/package.json
Normal file
24
colortest-290905/package.json
Normal file
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"author": "lastfuture@lastfuture.de",
|
||||
"dependencies": {},
|
||||
"keywords": [],
|
||||
"name": "colortest",
|
||||
"pebble": {
|
||||
"displayName": "colortest",
|
||||
"enableMultiJS": false,
|
||||
"messageKeys": [],
|
||||
"projectType": "native",
|
||||
"resources": {
|
||||
"media": []
|
||||
},
|
||||
"sdkVersion": "3",
|
||||
"targetPlatforms": [
|
||||
"chalk"
|
||||
],
|
||||
"uuid": "30630c34-d469-4d4d-a709-4e9d48e0c43e",
|
||||
"watchapp": {
|
||||
"watchface": false
|
||||
}
|
||||
},
|
||||
"version": "1.0.0"
|
||||
}
|
||||
128
colortest-290905/src/c/main.c
Normal file
128
colortest-290905/src/c/main.c
Normal file
@@ -0,0 +1,128 @@
|
||||
#include <pebble.h>
|
||||
|
||||
static Window *s_window;
|
||||
static Layer *s_canvas;
|
||||
|
||||
static int s_hours, s_minutes;
|
||||
|
||||
/*uint8_t sortedcolors[64] = {
|
||||
0, 1, 2, 16, 3, 17, 18, 4, 32, 19, 5, 33, 6, 34, 20, 48,
|
||||
7, 35, 21, 49, 22, 50, 8, 36, 23, 51, 9, 37, 10, 38, 24, 52,
|
||||
11, 39, 25, 53, 26, 54, 12, 40, 27, 55, 13, 41, 14, 42, 28, 56,
|
||||
15, 43, 29, 57, 30, 58, 44, 31, 59, 45, 46, 60, 47, 61, 62, 63
|
||||
};*/
|
||||
|
||||
uint8_t sortedcolors[64] = {0,1,16,2,17,18,3,4,5,19,20,32,6,21,33,22,34,7,23,35,36,37,38,39,48,49,50,51,52,8,9,53,24,10,25,54,26,11,55,27,40,41,42,43,56,57,58,59,12,13,28,14,29,30,15,31,44,45,46,47,60,61,62,63};
|
||||
|
||||
int compare( const void* a, const void* b)
|
||||
{
|
||||
uint32_t int_a = * ( (uint32_t*) a );
|
||||
uint32_t int_b = * ( (uint32_t*) b );
|
||||
|
||||
if ( int_a == int_b ) return 0;
|
||||
else if ( int_a < int_b ) return -1;
|
||||
else return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
static uint16_t int_sqrt(uint16_t value)
|
||||
{
|
||||
uint16_t answer = value;
|
||||
uint16_t answer_sqr = value*value;
|
||||
while(answer_sqr>value)
|
||||
{
|
||||
answer = (answer + value/answer)/2;
|
||||
answer_sqr = answer * answer;
|
||||
}
|
||||
return answer;
|
||||
}
|
||||
*/
|
||||
|
||||
static void layer_update_proc(Layer *layer, GContext *ctx) {
|
||||
GRect bounds = layer_get_bounds(layer);
|
||||
|
||||
GRect righthalf = GRect(bounds.size.w/2, bounds.origin.y, bounds.size.w/2, bounds.size.h);
|
||||
graphics_context_set_fill_color(ctx, GColorBlack);
|
||||
graphics_fill_rect(ctx, righthalf, 0, GCornerNone);
|
||||
|
||||
/*
|
||||
uint32_t brightnesstable[64];
|
||||
uint32_t brightnesstable2[64];
|
||||
for(uint8_t i=0; i<64; i++) {
|
||||
GColor8 color = (GColor8) { .argb = i+0b11000000 };
|
||||
uint32_t brightness = color.r*475251000 + color.g*774330000 + color.b*181260000;
|
||||
brightnesstable[i] = brightness;
|
||||
brightnesstable2[i] = brightness;
|
||||
}
|
||||
|
||||
uint8_t sortedcolors[64];
|
||||
qsort(brightnesstable, 64, sizeof(uint32_t), compare);
|
||||
for(uint8_t i=0; i<64; i++) {
|
||||
for(uint8_t j=0; j<64; j++) {
|
||||
if (brightnesstable[i] == brightnesstable2[j]) {
|
||||
APP_LOG(APP_LOG_LEVEL_INFO, "%d", j);
|
||||
sortedcolors[i] = j;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
for(uint8_t i=0; i<64; i++) {
|
||||
uint8_t argb = sortedcolors[i]+0b11000000;
|
||||
//APP_LOG(APP_LOG_LEVEL_INFO, "Color %i", argb);
|
||||
GRect colorstripe = GRect(26+bounds.origin.x+(i*2), bounds.origin.y, 2, bounds.size.h);
|
||||
graphics_context_set_fill_color(ctx, (GColor8) { .argb = argb });
|
||||
graphics_fill_rect(ctx, colorstripe, 0, GCornerNone);
|
||||
}
|
||||
}
|
||||
|
||||
static void window_load(Window *window) {
|
||||
Layer *window_layer = window_get_root_layer(window);
|
||||
GRect bounds = layer_get_bounds(window_layer);
|
||||
|
||||
s_canvas = layer_create(bounds);
|
||||
layer_set_update_proc(s_canvas, layer_update_proc);
|
||||
layer_add_child(window_layer, s_canvas);
|
||||
}
|
||||
|
||||
static void window_unload(Window *window) {
|
||||
layer_destroy(s_canvas);
|
||||
window_destroy(s_window);
|
||||
}
|
||||
|
||||
void main_window_push() {
|
||||
s_window = window_create();
|
||||
window_set_background_color(s_window, GColorWhite);
|
||||
window_set_window_handlers(s_window, (WindowHandlers) {
|
||||
.load = window_load,
|
||||
.unload = window_unload,
|
||||
});
|
||||
window_stack_push(s_window, true);
|
||||
}
|
||||
|
||||
void main_window_update(int hours, int minutes) {
|
||||
s_hours = hours;
|
||||
s_minutes = minutes;
|
||||
layer_mark_dirty(s_canvas);
|
||||
}
|
||||
|
||||
static void tick_handler(struct tm *time_now, TimeUnits changed) {
|
||||
main_window_update(time_now->tm_hour, time_now->tm_min);
|
||||
}
|
||||
|
||||
static void init() {
|
||||
main_window_push();
|
||||
|
||||
tick_timer_service_subscribe(MINUTE_UNIT, tick_handler);
|
||||
}
|
||||
|
||||
static void deinit() {
|
||||
tick_timer_service_unsubscribe();
|
||||
}
|
||||
|
||||
int main() {
|
||||
init();
|
||||
app_event_loop();
|
||||
deinit();
|
||||
}
|
||||
62
colortest-290905/wscript
Normal file
62
colortest-290905/wscript
Normal 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 [])
|
||||
|
||||
Reference in New Issue
Block a user