diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..31aa732 --- /dev/null +++ b/.clang-format @@ -0,0 +1,7 @@ +--- +BasedOnStyle: LLVM +TabWidth: 4 +IndentWidth: 4 +UseTab: ForIndentation +ColumnLimit: 0 +... diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ec2184a --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +/build +/.clangd +/.lock-waf* +/package-lock.json diff --git a/appinfo.json b/appinfo.json deleted file mode 100644 index 01d7a74..0000000 --- a/appinfo.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "resources": { - "media": [ - { - "type": "png-trans", - "file": "images/action_icon_minus.png", - "name": "MINUS" - }, - { - "type": "png-trans", - "file": "images/action_icon_plus.png", - "name": "PLUS" - }, - { - "type": "png-trans", - "file": "images/reset.png", - "name": "RESET" - }, - { - "type": "png", - "file": "images/icon.png", - "name": "ICON", - "menuIcon": true - } - ] - }, - "versionCode": 1, - "shortName": "counter", - "capabilities": [ - "" - ], - "versionLabel": "1.0", - "longName": "Counter is a multipurpose counting app with applications ranging from lap tracking to card counting.", - "uuid": "36bab645-70c5-472b-b99f-afc9f8656c70", - "appKeys": {}, - "companyName": "matthewbauer", - "watchapp": { - "watchface": false - } -} diff --git a/clangd.zsh b/clangd.zsh new file mode 100755 index 0000000..10a19d6 --- /dev/null +++ b/clangd.zsh @@ -0,0 +1,20 @@ +#!/usr/bin/env zsh +echo "CompileFlags: + Add: + [ + -DPBL_DISPLAY_WIDTH=200, + -DPBL_DISPLAY_HEIGHT=228, + -xc, + -nostdinc, + -DPBL_COLOR, + -DPBL_RECT, + -I${HOME}/.pebble-sdk/SDKs/current/sdk-core/pebble/emery/include, + -include$(pwd)/build/include/message_keys.auto.h, + -I$(pwd)/build/emery, + -include${HOME}/.pebble-sdk/SDKs/current/toolchain/arm-none-eabi/arm-none-eabi/include/stdint.h, + -include${HOME}/.pebble-sdk/SDKs/current/toolchain/arm-none-eabi/arm-none-eabi/include/stdlib.h, + -include${HOME}/.pebble-sdk/SDKs/current/toolchain/arm-none-eabi/arm-none-eabi/include/time.h, + -include${HOME}/.pebble-sdk/SDKs/current/toolchain/arm-none-eabi/arm-none-eabi/include/string.h, + -include${HOME}/.pebble-sdk/SDKs/current/toolchain/arm-none-eabi/lib/gcc/arm-none-eabi/14.2.1/include/stddef.h, + -include${HOME}/.pebble-sdk/SDKs/current/toolchain/arm-none-eabi/lib/gcc/arm-none-eabi/14.2.1/include/stdbool.h, + ]" > ./.clangd diff --git a/package.json b/package.json new file mode 100644 index 0000000..dbb0e5d --- /dev/null +++ b/package.json @@ -0,0 +1,62 @@ +{ + "name": "recounter", + "author": "RandyTheSilly", + "version": "1.0.0", + "keywords": [ + "counter", + "touch", + "simple" + ], + "private": true, + "dependencies": {}, + "pebble": { + "displayName": "REcounter", + "uuid": "36bab645-70c5-472b-b99f-afc9f8656c71", + "sdkVersion": "3", + "enableMultiJS": false, + "targetPlatforms": [ + "aplite", + "basalt", + "diorite", + "flint", + "emery" + ], + "watchapp": { + "watchface": false + }, + "messageKeys": [], + "resources": { + "media": [ + { + "file": "action_icon_minus.png", + "memoryFormat": "Smallest", + "name": "MINUS", + "spaceOptimization": "storage", + "type": "bitmap" + }, + { + "file": "action_icon_plus.png", + "memoryFormat": "Smallest", + "name": "PLUS", + "spaceOptimization": "storage", + "type": "bitmap" + }, + { + "file": "reset.png", + "memoryFormat": "Smallest", + "name": "RESET", + "spaceOptimization": "storage", + "type": "bitmap" + }, + { + "file": "icon.png", + "memoryFormat": "Smallest", + "name": "ICON", + "spaceOptimization": "storage", + "type": "bitmap", + "menuIcon": true + } + ] + } + } +} diff --git a/resources/images/action_icon_minus.png b/resources/action_icon_minus.png similarity index 100% rename from resources/images/action_icon_minus.png rename to resources/action_icon_minus.png diff --git a/resources/images/action_icon_plus.png b/resources/action_icon_plus.png similarity index 100% rename from resources/images/action_icon_plus.png rename to resources/action_icon_plus.png diff --git a/resources/images/icon.png b/resources/icon.png similarity index 100% rename from resources/images/icon.png rename to resources/icon.png diff --git a/resources/images/reset.png b/resources/reset.png similarity index 100% rename from resources/images/reset.png rename to resources/reset.png diff --git a/src/main.c b/src/c/main.c similarity index 87% rename from src/main.c rename to src/c/main.c index b3019ab..ffed98f 100644 --- a/src/main.c +++ b/src/c/main.c @@ -3,7 +3,7 @@ #define COUNT_PKEY 1 #define COUNT_DEFAULT 0 #define REPEAT_INTERVAL 50 - + Window *window; TextLayer *text_layer; @@ -49,9 +49,9 @@ void up_click_handler(ClickRecognizerRef recognizer, void *context) { } void click_config_provider(void *context) { - window_single_repeating_click_subscribe(BUTTON_ID_SELECT, REPEAT_INTERVAL, (ClickHandler) select_click_handler); - window_single_repeating_click_subscribe(BUTTON_ID_UP, REPEAT_INTERVAL, (ClickHandler) up_click_handler); - window_single_repeating_click_subscribe(BUTTON_ID_DOWN, REPEAT_INTERVAL, (ClickHandler) down_click_handler); + window_single_repeating_click_subscribe(BUTTON_ID_SELECT, REPEAT_INTERVAL, (ClickHandler)select_click_handler); + window_single_repeating_click_subscribe(BUTTON_ID_UP, REPEAT_INTERVAL, (ClickHandler)up_click_handler); + window_single_repeating_click_subscribe(BUTTON_ID_DOWN, REPEAT_INTERVAL, (ClickHandler)down_click_handler); } void window_load(Window *window) { @@ -81,16 +81,16 @@ void window_unload(Window *window) { } void init() { - action_icon_plus = gbitmap_create_with_resource(RESOURCE_ID_PLUS_WHITE); - action_icon_minus = gbitmap_create_with_resource(RESOURCE_ID_MINUS_WHITE); - action_icon_reset = gbitmap_create_with_resource(RESOURCE_ID_RESET_WHITE); + action_icon_plus = gbitmap_create_with_resource(RESOURCE_ID_PLUS); + action_icon_minus = gbitmap_create_with_resource(RESOURCE_ID_MINUS); + action_icon_reset = gbitmap_create_with_resource(RESOURCE_ID_RESET); window = window_create(); - window_set_window_handlers(window, (WindowHandlers) { - .load = window_load, - .unload = window_unload, - }); + window_set_window_handlers(window, (WindowHandlers){ + .load = window_load, + .unload = window_unload, + }); count = persist_exists(COUNT_PKEY) ? persist_read_int(COUNT_PKEY) : COUNT_DEFAULT; diff --git a/wscript b/wscript index 15d208f..5238bc8 100644 --- a/wscript +++ b/wscript @@ -1,46 +1,54 @@ - # -# This file is the default set of rules to compile a Pebble project. +# This file is the default set of rules to compile a Pebble application. # # Feel free to customize this to your needs. # - -try: - from sh import CommandNotFound, jshint, cat, ErrorReturnCode_2 - hint = jshint -except (ImportError, CommandNotFound): - hint = None +import os.path top = '.' out = 'build' + def options(ctx): ctx.load('pebble_sdk') + 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') - global hint - if hint is not None: - hint = hint.bake(['--config', 'pebble-jshintrc']) + 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 = [node.abspath() for node in ctx.path.ant_glob("src/*.js")] - if js_paths: - ctx.exec_command(['cat'] + js_paths, stdout=open('src/js/pebble-js-app.js', 'a')) - ctx.load('pebble_sdk') - ctx.pbl_program(source=ctx.path.ant_glob('src/**/*.c'), - target='pebble-app.elf') + build_worker = os.path.exists('worker_src') + binaries = [] - ctx.pbl_bundle(elf='pebble-app.elf', - js=ctx.path.ant_glob('src/js/**/*.js')) + 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_build(source=ctx.path.ant_glob('src/c/**/*.c'), target=app_elf, bin_type='app') + 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_build(source=ctx.path.ant_glob('worker_src/c/**/*.c'), + target=worker_elf, + bin_type='worker') + 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/pkjs/**/*.js', + 'src/pkjs/**/*.json', + 'src/common/**/*.js']), + js_entry_file='src/pkjs/index.js')