Skip to content

Commit

Permalink
updated headers for public beta
Browse files Browse the repository at this point in the history
  • Loading branch information
fuzzie360 committed Nov 7, 2013
1 parent a945a69 commit 7295cdc
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 34 deletions.
8 changes: 8 additions & 0 deletions .lock-waf_darwin_build
@@ -0,0 +1,8 @@
argv = ['/Users/fuzzie/pebble-dev/PebbleSDK-2.0-BETA1-rc4/Pebble/waf', 'configure', 'build']
environ = {'rvm_version': '1.21.6 (stable)', 'VERSIONER_PYTHON_PREFER_32_BIT': 'no', 'rvm_path': '/Users/fuzzie/.rvm', 'TMPDIR': '/var/folders/7f/8qn1tq4j7rb2mm_wzb_l8k900000gn/T/', 'RUBY_VERSION': 'ruby-2.0.0-p247', 'LOGNAME': 'fuzzie', 'USER': 'fuzzie', 'PATH': '/Users/fuzzie/pebble-dev/PebbleSDK-2.0-BETA1-rc4/arm-cs-tools/bin:/Users/fuzzie/.rvm/gems/ruby-2.0.0-p247/bin:/Users/fuzzie/.rvm/gems/ruby-2.0.0-p247@global/bin:/Users/fuzzie/.rvm/rubies/ruby-2.0.0-p247/bin:/Users/fuzzie/.rvm/bin:/Users/fuzzie/bin:/usr/local/opt/coreutils/libexec/gnubin:/usr/local/share/npm/bin/:/usr/local/bin:/usr/local/sbin:/Users/fuzzie/pebble-dev/PebbleSDK-2.0-BETA1-rc4/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/Applications/Server.app/Contents/ServerRoot/usr/bin:/Applications/Server.app/Contents/ServerRoot/usr/sbin:/usr/texbin', 'HOME': '/Users/fuzzie', 'DISPLAY': '/tmp/launch-gVyrFg/org.macosforge.xquartz:0', 'TERM_PROGRAM': 'iTerm.app', 'TERM': 'xterm-256color', 'SHELL': '/usr/local/bin/bash', 'VERSIONER_PYTHON_VERSION': '2.7', 'SHLVL': '2', 'COM_GOOGLE_CHROME_FRAMEWORK_SERVICE_PROCESS/USERS/FUZZIE/LIBRARY/APPLICATION_SUPPORT/GOOGLE/CHROME_SOCKET': '/tmp/launch-7o1NY1/ServiceProcessSocket', 'ITERM_SESSION_ID': 'w0t0p0', 'EDITOR': '/usr/local/bin/vim', 'GEM_PATH': '/Users/fuzzie/.rvm/gems/ruby-2.0.0-p247:/Users/fuzzie/.rvm/gems/ruby-2.0.0-p247@global', 'rvm_bin_path': '/Users/fuzzie/.rvm/bin', 'rvm_prefix': '/Users/fuzzie', 'SSH_AUTH_SOCK': '/tmp/launch-VyrkKE/Listeners', 'IRBRC': '/Users/fuzzie/.rvm/rubies/ruby-2.0.0-p247/.irbrc', 'LC_CTYPE': 'UTF-8', 'MY_RUBY_HOME': '/Users/fuzzie/.rvm/rubies/ruby-2.0.0-p247', 'VISUAL': '/usr/local/bin/mate -w', 'Apple_PubSub_Socket_Render': '/tmp/launch-TyOMcB/Render', 'ITERM_PROFILE': 'Default', '_': '/Users/fuzzie/pebble-dev/PebbleSDK-2.0-BETA1-rc4/Pebble/waf', 'PAGER': '/usr/local/bin/vimpager', 'HOMEBREW_GITHUB_API_TOKEN': 'fd72f7b225157765876f5effba992ab1c37c5eec', 'CLICOLOR': '1', '__CF_USER_TEXT_ENCODING': '0x1F5:0:0', 'PWD': '/Users/fuzzie/Documents/PebbleProjects/pebble-noms', '__CHECKFIX1436934': '1', 'GEM_HOME': '/Users/fuzzie/.rvm/gems/ruby-2.0.0-p247'}
files = ['/Users/fuzzie/Documents/PebbleProjects/pebble-noms/wscript']
hash = 4672844372416070989
options = {'files': '', 'jobs': 8, '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/fuzzie/Documents/PebbleProjects/pebble-noms/build'
run_dir = '/Users/fuzzie/Documents/PebbleProjects/pebble-noms'
top_dir = '/Users/fuzzie/Documents/PebbleProjects/pebble-noms'
90 changes: 59 additions & 31 deletions src/noms.c
Expand Up @@ -17,8 +17,8 @@
//
// You may contact the author at fazli@sapuan.org
//
#include <pebble_os.h>
#include <pebble_app.h>
#include <pebble.h>
#include <pebble_app_info.h>
#include <pebble_fonts.h>

static Window *window;
Expand All @@ -35,10 +35,10 @@ static GBitmap *face;
static GBitmap *mouth;
static GBitmap *jaw;

static PropertyAnimation *mouth_animation_beg;
static PropertyAnimation *mouth_animation_end;
static PropertyAnimation *jaw_animation_beg;
static PropertyAnimation *jaw_animation_end;
static PropertyAnimation *mouth_animation_beg = NULL;
static PropertyAnimation *mouth_animation_end = NULL;
static PropertyAnimation *jaw_animation_beg = NULL;
static PropertyAnimation *jaw_animation_end = NULL;

static GRect mouth_from_rect;
static GRect mouth_to_rect;
Expand All @@ -48,6 +48,19 @@ static GRect jaw_to_rect;
static char time_text[] = "00:00";
static char time_text_buffer[] = "00:00";

void destroy_property_animation(PropertyAnimation **prop_animation) {
if (*prop_animation == NULL) {
return;
}

if (animation_is_scheduled((Animation*) *prop_animation)) {
animation_unschedule((Animation*) *prop_animation);
}

property_animation_destroy(*prop_animation);
*prop_animation = NULL;
}

void animation_started(Animation *animation, void *data) {
(void)animation;
(void)data;
Expand All @@ -56,26 +69,32 @@ void animation_started(Animation *animation, void *data) {
void animation_stopped(Animation *animation, void *data) {
(void)animation;
(void)data;

memcpy(time_text, time_text_buffer, strlen(time_text)+1);
text_layer_set_text(text_time_layer, time_text);


destroy_property_animation(&mouth_animation_end);
destroy_property_animation(&jaw_animation_end);

mouth_animation_end = property_animation_create_layer_frame(bitmap_layer_get_layer(mouth_layer), &mouth_to_rect, &mouth_from_rect);
jaw_animation_end = property_animation_create_layer_frame(bitmap_layer_get_layer(jaw_layer), &jaw_to_rect, &jaw_from_rect);

animation_schedule((Animation*) mouth_animation_end);
animation_schedule((Animation*) jaw_animation_end);
}

void handle_minute_tick(struct tm *tick_time, TimeUnits units_changed) {
destroy_property_animation(&mouth_animation_beg);
destroy_property_animation(&jaw_animation_beg);

mouth_animation_beg = property_animation_create_layer_frame(bitmap_layer_get_layer(mouth_layer), &mouth_from_rect, &mouth_to_rect);
jaw_animation_beg = property_animation_create_layer_frame(bitmap_layer_get_layer(jaw_layer), &jaw_from_rect, &jaw_to_rect);

animation_set_handlers((Animation*) mouth_animation_beg, (AnimationHandlers) {
.started = (AnimationStartedHandler) animation_started,
.stopped = (AnimationStoppedHandler) animation_stopped
}, 0);

// section based on Simplicity by Pebble Team begins
char *time_format;

Expand All @@ -91,51 +110,61 @@ void handle_minute_tick(struct tm *tick_time, TimeUnits units_changed) {
memmove(time_text_buffer, &time_text_buffer[1], sizeof(time_text_buffer) - 1);
}
// section ends

animation_schedule((Animation*) mouth_animation_beg);
animation_schedule((Animation*) jaw_animation_beg);
}

static void window_load(Window *window) {
Layer *root_layer = window_get_root_layer(window);

face = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_FACE);
mouth = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_MOUTH);
jaw = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_JAW);

time_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_BIG_NOODLE_TITLING_55));

background_layer = bitmap_layer_create(layer_get_frame(root_layer));
bitmap_layer_set_bitmap(background_layer, face);
layer_add_child(root_layer, bitmap_layer_get_layer(background_layer));
mouth_from_rect = GRect(17, 45, 110, 107);
mouth_to_rect = GRect(17, 88, 110, 107);
jaw_from_rect = GRect(17, 142, 110, 107);
jaw_to_rect = GRect(17, 97, 110, 107);

mouth_from_rect = GRect(17, 45, 110, 107);
mouth_to_rect = GRect(17, 88, 110, 107);
jaw_from_rect = GRect(17, 142, 110, 107);
jaw_to_rect = GRect(17, 97, 110, 107);

mouth_layer = bitmap_layer_create(mouth_from_rect);
bitmap_layer_set_bitmap(mouth_layer, mouth);
layer_add_child(root_layer, bitmap_layer_get_layer(mouth_layer));
text_time_layer = text_layer_create(GRect(0, 19, 110, 107)); 107));

text_time_layer = text_layer_create(GRect(0, 19, 110, 107));
text_layer_set_text_color(text_time_layer, GColorWhite);
text_layer_set_background_color(text_time_layer, GColorClear);
text_layer_set_text_alignment(text_time_layer, GTextAlignmentCenter);
text_layer_set_font(text_time_layer, time_font);
layer_add_child(bitmap_layer_get_layer(mouth_layer), text_layer_get_layer(text_time_layer));

jaw_layer = bitmap_layer_create(jaw_from_rect);
bitmap_layer_set_bitmap(jaw_layer, jaw);
layer_add_child(root_layer, bitmap_layer_get_layer(jaw_layer));
}

static void window_unload(Window *window) {
gbitmap_destroy(face);
gbitmap_destroy(mouth);
gbitmap_destroy(jaw);

destroy_property_animation(&mouth_animation_beg);
destroy_property_animation(&jaw_animation_beg);
destroy_property_animation(&mouth_animation_end);
destroy_property_animation(&jaw_animation_end);

bitmap_layer_destroy(jaw_layer);
text_layer_destroy(text_time_layer);
bitmap_layer_destroy(mouth_layer);
bitmap_layer_destroy(background_layer);

fonts_unload_custom_font(time_font);

gbitmap_destroy(jaw);
gbitmap_destroy(mouth);
gbitmap_destroy(face);
}

static void init(void) {
Expand All @@ -150,14 +179,13 @@ static void init(void) {
}

static void deinit(void) {
tick_timer_service_unsubscribe();
window_stack_remove(window, false);
window_destroy(window);
}

int main(void) {
init();

APP_LOG(APP_LOG_LEVEL_DEBUG, "Done initializing, pushed window: %p", window);

app_event_loop();
deinit();
}
12 changes: 9 additions & 3 deletions wscript
Expand Up @@ -9,10 +9,16 @@ top = '.'
out = 'build'

def options(ctx):
ctx.load('pebble_sdk')
ctx.load('pebble_sdk')

def configure(ctx):
ctx.load('pebble_sdk')
ctx.load('pebble_sdk')

def build(ctx):
ctx.load('pebble_sdk')
ctx.load('pebble_sdk')

ctx.pbl_program(source=ctx.path.ant_glob('src/**/*.c'),
target='pebble-app.elf')

ctx.pbl_bundle(elf='pebble-app.elf',
js=ctx.path.ant_glob('src/js/**/*.js'))

0 comments on commit 7295cdc

Please sign in to comment.