It is currently Wed Jul 06, 2011 6:44 pm

All times are UTC - 8 hours




 Page 1 of 1 [ 6 posts ] 
Author Message
 Post subject: Simple Watch
PostPosted: Fri Mar 04, 2011 6:51 pm 

Joined: Mon Feb 28, 2011 8:03 am
Posts: 7
My first attemp at an app (sorry about poor coding ahead of time, I am ultra novice) .. Just wanted a simple display ... one click on and one click off font is kremlin.ttf

http://www.jyito.com/firstapp/firstapp.zip





link has resource/include/src folders


#include <pulse_os.h>
#include <pulse_types.h>
#include <app_resources.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>


uint8_t current_min;
uint8_t current_hour;

struct pulse_time_tm current_time;

struct PWTextBox clock_text_box;
struct PWidgetTextDynamic clock_text_widget;

int onoff = 1;

enum PWTextStyle clock_text_style = (PWTS_WRAP | PWTS_TRUNCATE | PWTS_CENTER);

// Text buffers to store text to be rendered
char clock_text_buffer[16];

void print_time_into_text_buffer()
{   
    pulse_get_time_date(¤t_time);
   sprintf(clock_text_buffer, "%02d%02d", current_time.tm_hour,current_time.tm_min);
}

void update_time()
{
   if(onoff != 0)
   {

     pulse_blank_canvas();
     print_time_into_text_buffer();

     pulse_render_text(&clock_text_box, &clock_text_widget);

     // Register a timer to update the time on the minute mark
     pulse_register_timer(60000 - current_time.tm_sec * 1000, &update_time, 0);

   }

}

void main_app_init() {
   pulse_blank_canvas();
   
    clock_text_box.top = 0;
    clock_text_box.bottom = 126;
    clock_text_box.left = 0;
    clock_text_box.right = SCREEN_WIDTH;
    pulse_init_dynamic_text_widget(&clock_text_widget, clock_text_buffer,FONT_KREMLIN, COLOR_RED24, clock_text_style);
    update_time();
}

void handle_button_causing_wakeup() {
}

void main_app_handle_button_down() {
}

void main_app_handle_button_up() {

   if(onoff == 1) {
      pulse_blank_canvas();
      onoff = 0;
   } else {
      onoff = 1;
      update_time();
   }

}

void main_app_loop() {
}

void main_app_handle_doz() {
}

void main_app_handle_hardware_update(enum PulseHardwareEvent event) {
}



Offline
 Profile  
 
 Post subject: Re: Simple Watch
PostPosted: Fri Mar 04, 2011 10:24 pm 
User avatar

Joined: Mon Feb 14, 2011 7:07 pm
Posts: 172
Looks very cool! It reminds me of one of my favourite watches: the Nixon Newton Digital: http://www.google.com/products/catalog? ... DUQ8gIwAg#



_________________
---

Lead designer of inPulse
Offline
 Profile  
 
 Post subject: Re: Simple Watch
PostPosted: Sat Mar 05, 2011 11:48 am 

Joined: Mon Feb 28, 2011 8:03 am
Posts: 7
Thanks!

// Any coding tips, critiques etc.. would be appreciated


Offline
 Profile  
 
 Post subject: Re: Simple Watch
PostPosted: Tue Mar 15, 2011 10:32 am 

Joined: Mon Feb 28, 2011 8:03 am
Posts: 7
modified the code a bit.... watch stays alive about 3 days with normal usage.... working on adding chrono, timer and notification functionality


Offline
 Profile  
 
 Post subject: Re: Simple Watch
PostPosted: Tue Mar 15, 2011 10:38 am 
User avatar

Joined: Mon Feb 14, 2011 7:07 pm
Posts: 172
That's awesome, did you post the updated code in your first post?



_________________
---

Lead designer of inPulse
Offline
 Profile  
 
 Post subject: Re: Simple Watch
PostPosted: Wed Mar 16, 2011 7:20 pm 

Joined: Mon Feb 28, 2011 8:03 am
Posts: 7
Will upload updated code soon, next week sometime... work is keeping me pretty busy.


Offline
 Profile  
 
Display posts from previous:  Sort by  
 Page 1 of 1 [ 6 posts ] 

All times are UTC - 8 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: