Commit 2a9ed7d7 authored by w@hxdl.org's avatar w@hxdl.org

final

parents
File added
src @ b824e615
Subproject commit b824e615d9f7918fdd370c1dae4ffcfd0923940e
# Ignore build generated files
build
argv = ['/Users/core/pebble-dev/PebbleSDK-2.7/Pebble/waf', 'configure', 'build']
environ = {'TERM_SESSION_ID': 'AB476A37-E64A-4FC0-80C1-4A2523703387', 'XPC_SERVICE_NAME': '0', 'PYTHONPATH': '/Users/core/pebble-dev/PebbleSDK-current/bin/../.env/lib/python2.7/site-packages', 'VERSIONER_PYTHON_PREFER_32_BIT': 'no', 'LC_CTYPE': 'UTF-8', 'TERM_PROGRAM_VERSION': '343', 'SSH_AUTH_SOCK': '/private/tmp/com.apple.launchd.Ejr6lvrDJj/Listeners', 'SHELL': '/bin/bash', 'LOGNAME': 'core', 'USER': 'core', 'HOME': '/Users/core', 'PATH': '/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/core/pebble-dev/PebbleSDK-current/bin:/Users/core/pebble-dev/PebbleSDK-2.7/arm-cs-tools/bin', 'DISPLAY': '/private/tmp/com.apple.launchd.RERTjBbyIj/org.macosforge.xquartz:0', 'TMPDIR': '/var/folders/43/2czww94s27g6kzxhbn62ty9w0000gn/T/', 'TERM_PROGRAM': 'Apple_Terminal', 'TERM': 'xterm-256color', 'Apple_PubSub_Socket_Render': '/private/tmp/com.apple.launchd.sJ2RZIzYEd/Render', 'VERSIONER_PYTHON_VERSION': '2.7', 'SHLVL': '2', 'SECURITYSESSIONID': '186a5', 'XPC_FLAGS': '0x0', '__CF_USER_TEXT_ENCODING': '0x1F5:0x0:0x0', 'PWD': '/Users/core/Development/Projects/HackShanghai/test', '_': '/Users/core/pebble-dev/PebbleSDK-2.7/Pebble/waf'}
files = ['/Users/core/Development/Projects/HackShanghai/test/wscript']
hash = 7538170971265686294
options = {'files': '', 'jobs': 4, 'verbose': 0, 'nocache': False, 'progress_bar': 0, 'timestamp': None, 'distcheck_args': None, 'top': '', 'destdir': '', 'keep': 0, 'zones': '', 'debug': False, 'prefix': '/usr/local/', 'download': False, 'force': False, 'targets': '', 'out': ''}
out_dir = '/Users/core/Development/Projects/HackShanghai/test/build'
run_dir = '/Users/core/Development/Projects/HackShanghai/test'
top_dir = '/Users/core/Development/Projects/HackShanghai/test'
# This file is NOT licensed under the GPLv3, which is the license for the rest
# of YouCompleteMe.
#
# Here's the license text for this file:
#
# This is free and unencumbered software released into the public domain.
#
# Anyone is free to copy, modify, publish, use, compile, sell, or
# distribute this software, either in source code form or as a compiled
# binary, for any purpose, commercial or non-commercial, and by any
# means.
#
# In jurisdictions that recognize copyright laws, the author or authors
# of this software dedicate any and all copyright interest in the
# software to the public domain. We make this dedication for the benefit
# of the public at large and to the detriment of our heirs and
# successors. We intend this dedication to be an overt act of
# relinquishment in perpetuity of all present and future rights to this
# software under copyright law.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
#
# For more information, please refer to <http://unlicense.org/>
import os
import ycm_core
# These are the compilation flags that will be used in case there's no
# compilation database set (by default, one is not set).
# CHANGE THIS LIST OF FLAGS. YES, THIS IS THE DROID YOU HAVE BEEN LOOKING FOR.
flags = [
'-Wall',
'-Wextra',
'-Werror',
'-Wc++98-compat',
'-Wno-long-long',
'-Wno-variadic-macros',
'-fexceptions',
'-DNDEBUG',
# You 100% do NOT need -DUSE_CLANG_COMPLETER in your flags; only the YCM
# source code needs it.
'-DUSE_CLANG_COMPLETER',
# THIS IS IMPORTANT! Without a "-std=<something>" flag, clang won't know which
# language to use when compiling headers. So it will guess. Badly. So C++
# headers will be compiled as C headers. You don't want that so ALWAYS specify
# a "-std=<something>".
# For a C project, you would set this to something like 'c99' instead of
# 'c++11'.
'-std=c++11',
# ...and the same thing goes for the magic -x option which specifies the
# language that the files to be compiled are written in. This is mostly
# relevant for c++ headers.
# For a C project, you would set this to 'c' instead of 'c++'.
'-x',
'c++',
'-isystem',
# This path will only work on OS X, but extra paths that don't exist are not
# harmful
'/System/Library/Frameworks/Python.framework/Headers',
'-I',
'.',
'-I',
'/Users/core/pebble-dev/PebbleSDK-current/Pebble/include',
'-isystem',
'/usr/include',
'-isystem',
'/usr/local/include',
'-isystem',
'/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1',
'-isystem',
'/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include',
]
# Set this to the absolute path to the folder (NOT the file!) containing the
# compile_commands.json file to use that instead of 'flags'. See here for
# more details: http://clang.llvm.org/docs/JSONCompilationDatabase.html
#
# You can get CMake to generate this file for you by adding:
# set( CMAKE_EXPORT_COMPILE_COMMANDS 1 )
# to your CMakeLists.txt file.
#
# Most projects will NOT need to set this to anything; you can just change the
# 'flags' list of compilation flags. Notice that YCM itself uses that approach.
compilation_database_folder = ''
if os.path.exists( compilation_database_folder ):
database = ycm_core.CompilationDatabase( compilation_database_folder )
else:
database = None
SOURCE_EXTENSIONS = [ '.cpp', '.cxx', '.cc', '.c', '.m', '.mm' ]
def DirectoryOfThisScript():
return os.path.dirname( os.path.abspath( __file__ ) )
def MakeRelativePathsInFlagsAbsolute( flags, working_directory ):
if not working_directory:
return list( flags )
new_flags = []
make_next_absolute = False
path_flags = [ '-isystem', '-I', '-iquote', '--sysroot=' ]
for flag in flags:
new_flag = flag
if make_next_absolute:
make_next_absolute = False
if not flag.startswith( '/' ):
new_flag = os.path.join( working_directory, flag )
for path_flag in path_flags:
if flag == path_flag:
make_next_absolute = True
break
if flag.startswith( path_flag ):
path = flag[ len( path_flag ): ]
new_flag = path_flag + os.path.join( working_directory, path )
break
if new_flag:
new_flags.append( new_flag )
return new_flags
def IsHeaderFile( filename ):
extension = os.path.splitext( filename )[ 1 ]
return extension in [ '.h', '.hxx', '.hpp', '.hh' ]
def GetCompilationInfoForFile( filename ):
# The compilation_commands.json file generated by CMake does not have entries
# for header files. So we do our best by asking the db for flags for a
# corresponding source file, if any. If one exists, the flags for that file
# should be good enough.
if IsHeaderFile( filename ):
basename = os.path.splitext( filename )[ 0 ]
for extension in SOURCE_EXTENSIONS:
replacement_file = basename + extension
if os.path.exists( replacement_file ):
compilation_info = database.GetCompilationInfoForFile(
replacement_file )
if compilation_info.compiler_flags_:
return compilation_info
return None
return database.GetCompilationInfoForFile( filename )
def FlagsForFile( filename, **kwargs ):
if database:
# Bear in mind that compilation_info.compiler_flags_ does NOT return a
# python list, but a "list-like" StringVec object
compilation_info = GetCompilationInfoForFile( filename )
if not compilation_info:
return None
final_flags = MakeRelativePathsInFlagsAbsolute(
compilation_info.compiler_flags_,
compilation_info.compiler_working_dir_ )
# NOTE: This is just for YouCompleteMe; it's highly likely that your project
# does NOT need to remove the stdlib flag. DO NOT USE THIS IN YOUR
# ycm_extra_conf IF YOU'RE NOT 100% SURE YOU NEED IT.
try:
final_flags.remove( '-stdlib=libc++' )
except ValueError:
pass
else:
relative_to = DirectoryOfThisScript()
final_flags = MakeRelativePathsInFlagsAbsolute( flags, relative_to )
return {
'flags': final_flags,
'do_cache': True
}
{
"uuid": "d66eb88f-7bd7-427d-a78f-ddc548396a77",
"shortName": "test",
"longName": "test",
"companyName": "MakeAwesomeHappen",
"versionCode": 1,
"versionLabel": "1.0",
"watchapp": {
"watchface": false
},
"appKeys": {
"dummy": 0
},
"resources": {
"media": []
}
}
#define ACTION 0
#define RESULT 1
#define ORDER_CONTENT 2
#define ORDER_AMOUNT 3
#define ORDER_DATE 4
#define ORDER_SHOP_NAME 5
#define ORDER_ID 6
//ACTION
#define ACTION_SHOW_ORDER 20
#define ACTION_SHOW_SUGGEST 21
#define ACTION_SHOW_ALARM 22
#define ACTION_ACCEPT 23
#define ACTION_REFRESH_SUGGEST 24
#define ACTION_COMPLETE_ORDER 25
#define ACTION_ACTIVATE_APP 26
#define ACTION_EXIT 99
#include <pebble.h>
static Window *window;
char shopNameBuf[20];
char contentBuf[50];
char countdownBuf[15];
char amountBuf[20];
char confirmBuf[10];
char IDBuf[17];
static TextLayer *contentLayer, *shopNameLayer, *countdownLayer, *amountLayer, *confirmLayer;
time_t timerTime;
typedef enum {List, Order} ScreenType;
ScreenType currentScreenType;
static void select_click_handler(ClickRecognizerRef recognizer, void *context) {
DictionaryIterator *iter;
app_message_outbox_begin(&iter);
if(currentScreenType == Order) {
dict_write_int8(iter, ACTION, ACTION_COMPLETE_ORDER);
window_stack_pop_all(true);
} else if(currentScreenType == List) {
dict_write_int8(iter, ACTION, ACTION_ACCEPT);
dict_write_cstring(iter, ORDER_ID, IDBuf);
} else {
APP_LOG(APP_LOG_LEVEL_ERROR, "invalid screen type");
}
app_message_outbox_send();
}
static void up_click_handler(ClickRecognizerRef recognizer, void *context) {
DictionaryIterator *iter;
app_message_outbox_begin(&iter);
dict_write_int8(iter, 0, ACTION_ACTIVATE_APP);
app_message_outbox_send();
}
static void down_click_handler(ClickRecognizerRef recognizer, void *context) {
if(currentScreenType == List) {
DictionaryIterator *iter;
app_message_outbox_begin(&iter);
dict_write_int8(iter, 0, ACTION_REFRESH_SUGGEST);
app_message_outbox_send();
}
}
static void click_config_provider(void *pContext) {
window_single_click_subscribe(BUTTON_ID_SELECT, select_click_handler);
window_single_click_subscribe(BUTTON_ID_UP, up_click_handler);
window_single_click_subscribe(BUTTON_ID_DOWN, down_click_handler);
}
static void window_load(Window *pWindow) {
const short lineHeight = 20;
Layer *window_layer = window_get_root_layer(pWindow);
GRect window_bounds = layer_get_bounds(window_layer);
countdownLayer = text_layer_create(GRect(0, 0, window_bounds.size.w, lineHeight));
text_layer_set_background_color(countdownLayer, GColorBlack);
text_layer_set_text_color(countdownLayer, GColorWhite);
//text_layer_set_overflow_mode(contentLayer, GTextOverflowModeWordWrap);
text_layer_set_text_alignment(countdownLayer, GTextAlignmentCenter);
layer_add_child(window_layer, text_layer_get_layer(countdownLayer));
shopNameLayer = text_layer_create(GRect(0, lineHeight, window_bounds.size.w, lineHeight));
text_layer_set_background_color(shopNameLayer, GColorClear);
text_layer_set_text_color(shopNameLayer, GColorBlack);
//text_layer_set_overflow_mode(contentLayer, GTextOverflowModeWordWrap);
text_layer_set_text_alignment(shopNameLayer, GTextAlignmentLeft);
layer_add_child(window_layer, text_layer_get_layer(shopNameLayer));
contentLayer = text_layer_create(GRect(0, 2 * lineHeight, window_bounds.size.w, window_bounds.size.h - 3 * lineHeight));
text_layer_set_text_alignment(contentLayer, GTextAlignmentLeft);
text_layer_set_overflow_mode(contentLayer, GTextOverflowModeWordWrap);
layer_add_child(window_layer, text_layer_get_layer(contentLayer));
text_layer_set_text(contentLayer, "I am hangry.\nI'm waiting for connection");
amountLayer = text_layer_create(GRect(0, window_bounds.size.h - lineHeight, window_bounds.size.w, lineHeight));
text_layer_set_background_color(amountLayer, GColorBlack);
text_layer_set_text_color(amountLayer, GColorWhite);
text_layer_set_text_alignment(amountLayer, GTextAlignmentLeft);
layer_add_child(window_layer, text_layer_get_layer(amountLayer));
confirmLayer = text_layer_create(GRect(0, window_bounds.size.h - lineHeight, window_bounds.size.w, lineHeight));
text_layer_set_text_alignment(confirmLayer, GTextAlignmentRight);
text_layer_set_background_color(confirmLayer, GColorClear);
text_layer_set_text_color(confirmLayer, GColorWhite);
layer_add_child(window_layer, text_layer_get_layer(confirmLayer));
}
static void window_unload(Window *pWindow) {
text_layer_destroy(countdownLayer);
text_layer_destroy(shopNameLayer);
text_layer_destroy(contentLayer);
text_layer_destroy(amountLayer);
}
void UpdateTimerCallback(struct tm *tick, TimeUnits units_changed) {
time_t diffTime;
time_t nowTime;
time(&nowTime);
diffTime = timerTime - nowTime;
snprintf(countdownBuf, sizeof(countdownBuf), "%ld:%ld", diffTime / 60, labs(diffTime % 60));
text_layer_set_text(countdownLayer, countdownBuf);
//APP_LOG(APP_LOG_LEVEL_INFO, "%ld", diffTime);
//APP_LOG(APP_LOG_LEVEL_INFO, "%ld", timerTime);
}
void initCurrentTimer() {
// strptime(countdownBuf, "%Y-%m-%d %T", &curr_Tm);
// struct tm tmTime;
// sscanf(countdownBuf, "%d-%d-%d %d:%d:%d", &tmTime.tm_year, &tmTime.tm_mon, &tmTime.tm_mday, &tmTime.tm_hour, &tmTime.tm_min, &tmTime.tm_sec);
// timerTime = mktime(&tmTime);
timerTime = atoi(countdownBuf) + 8 * 3600;
tick_timer_service_subscribe(SECOND_UNIT, UpdateTimerCallback);
}
static void inbox_received_callback(DictionaryIterator *iterator, void *context) {
Tuple *t = dict_find(iterator, ACTION);
switch(t->value->uint8) {
Tuple *tContent, *tAmount, *tDate, *tShopName, *tID;
case ACTION_SHOW_SUGGEST:
currentScreenType = List;
tContent = dict_find(iterator, ORDER_CONTENT);
tAmount = dict_find(iterator, ORDER_AMOUNT);
//tDate = dict_find(iterator, ORDER_DATE);
tShopName = dict_find(iterator, ORDER_SHOP_NAME);
tID = dict_find(iterator, ORDER_ID);
//snprintf(countdownBuf, sizeof(countdownBuf), "%s", tDate->value->cstring);
snprintf(shopNameBuf, sizeof(shopNameBuf), "%s", tShopName->value->cstring);
snprintf(contentBuf, sizeof(contentBuf), " *%s", tContent->value->cstring);
snprintf(amountBuf, sizeof(amountBuf), "Total: %s", tAmount->value->cstring);
snprintf(confirmBuf, sizeof(confirmBuf), "OK?");
snprintf(IDBuf, sizeof(IDBuf), tID->value->cstring);
//text_layer_set_text(countdownLayer, countdownBuf);
text_layer_set_text(shopNameLayer, shopNameBuf);
text_layer_set_text(contentLayer, contentBuf);
text_layer_set_text(amountLayer, amountBuf);
text_layer_set_text(confirmLayer, confirmBuf);
break;
case ACTION_SHOW_ORDER:
currentScreenType = Order;
tContent = dict_find(iterator, ORDER_CONTENT);
tAmount = dict_find(iterator, ORDER_AMOUNT);
tDate = dict_find(iterator, ORDER_DATE);
tShopName = dict_find(iterator, ORDER_SHOP_NAME);
snprintf(countdownBuf, sizeof(countdownBuf), "%s", tDate->value->cstring);
snprintf(shopNameBuf, sizeof(shopNameBuf), "%s", tShopName->value->cstring);
snprintf(contentBuf, sizeof(contentBuf), " *%s", tContent->value->cstring);
snprintf(amountBuf, sizeof(amountBuf), "Total: %s", tAmount->value->cstring);
snprintf(confirmBuf, sizeof(confirmBuf), "DONE");
//text_layer_set_text(countdownLayer, countdownBuf);
text_layer_set_text(shopNameLayer, shopNameBuf);
text_layer_set_text(contentLayer, contentBuf);
text_layer_set_text(amountLayer, amountBuf);
text_layer_set_text(confirmLayer, confirmBuf);
initCurrentTimer();
// snprintf(infoBuffer, sizeof(infoBuffer), "%s\n%s\n%s\n%s",
// tShopName->value->cstring,
// tAmount->value->cstring,
// tDate->value->cstring,
// tContent->value->cstring);
//APP_LOG(APP_LOG_LEVEL_INFO, displayBuffer);
//text_layer_set_text(orderLayer, displayBuffer);
break;
case ACTION_SHOW_ALARM:
vibes_double_pulse();
break;
case ACTION_EXIT:
window_stack_pop_all(true);
break;
default:
break;
}
}
static void inbox_dropped_callback(AppMessageResult reason, void *context) {
APP_LOG(APP_LOG_LEVEL_ERROR, "Message dropped!");
}
static void outbox_failed_callback(DictionaryIterator *iterator, AppMessageResult reason, void *context) {
APP_LOG(APP_LOG_LEVEL_ERROR, "Outbox send failed!");
}
static void outbox_sent_callback(DictionaryIterator *iterator, void *context) {
APP_LOG(APP_LOG_LEVEL_INFO, "Outbox send success!");
}
static void send_init_startup_data() {
DictionaryIterator *iter;
app_message_outbox_begin(&iter);
if(iter == NULL) {
APP_LOG(APP_LOG_LEVEL_ERROR, "Can't open outbox iterator");
return;
}
//dict_write_begin(iter, buffer, sizeof(buffer));
dict_write_int8(iter, 0, 100);
//dict_write_end(iter);
if(app_message_outbox_send() == APP_MSG_BUSY) {
APP_LOG(APP_LOG_LEVEL_DEBUG, "outbox busy");
} else {
APP_LOG(APP_LOG_LEVEL_DEBUG, "outbox sent");
}
}
static void init(void) {
window = window_create();
window_set_click_config_provider(window, click_config_provider);
window_set_window_handlers(window, (WindowHandlers) {
.load = window_load,
.unload = window_unload,
});
const bool animated = true;
window_set_fullscreen(window, true);
window_stack_push(window, animated);
app_message_register_inbox_received(inbox_received_callback);
app_message_register_inbox_dropped(inbox_dropped_callback);
app_message_register_outbox_sent(outbox_sent_callback);
app_message_register_outbox_failed(outbox_failed_callback);
app_message_open(app_message_inbox_size_maximum(), app_message_outbox_size_maximum());
send_init_startup_data();
}
static void deinit(void) {
window_destroy(window);
}
int main(void) {
init();
APP_LOG(APP_LOG_LEVEL_DEBUG, "Done initializing, pushed window: %p", window);
app_event_loop();
deinit();
}
#
# This file is the default set of rules to compile a Pebble project.
#
# Feel free to customize this to your needs.
#
import os.path
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')
if os.path.exists('worker_src'):
ctx.pbl_worker(source=ctx.path.ant_glob('worker_src/**/*.c'),
target='pebble-worker.elf')
ctx.pbl_bundle(elf='pebble-app.elf',
worker_elf='pebble-worker.elf',
js=ctx.path.ant_glob('src/js/**/*.js'))
else:
ctx.pbl_bundle(elf='pebble-app.elf',
js=ctx.path.ant_glob('src/js/**/*.js'))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment