This is a patch to the 'grand' branch of CHDK, as of 2007-08-13 22:48:11 -0700 (Mon, 13 Aug 2007) (according to 'svn info'.) It adds a 'get_day_seconds' command to uBasic. Call it as 'get_day_seconds x' to put the number of seconds elapsed since midnight into the x variable. The patch is available at http://bostoncoop.net/~mike/CHDK_get_day_seconds.patch ... or copy the lines starting with 'Index' below into a new file and use that. Enjoy - Mike McCabe E-mail: nickname-for-michael at-sign mcca dot be Index: include/platform.h =================================================================== --- include/platform.h (revision 200) +++ include/platform.h (working copy) @@ -146,6 +146,8 @@ int shooting_get_real_av(); +int shooting_get_day_seconds(); + extern int circle_of_confusion; extern const int zoom_points; Index: platform/generic/shooting.c =================================================================== --- platform/generic/shooting.c (revision 200) +++ platform/generic/shooting.c (working copy) @@ -3,6 +3,7 @@ #include "core.h" #include "keyboard.h" #include "math.h" +#include #define SS_SIZE (sizeof(shutter_speeds_table)/sizeof(shutter_speeds_table[0])) #define SSID_MIN (shutter_speeds_table[0].id) @@ -102,6 +103,15 @@ shooting_set_av(cv+v); } +int shooting_get_day_seconds() +{ + unsigned long t; + struct tm *ttm; + t = time(NULL); + ttm = localtime(&t); + return ttm->tm_hour * 3600 + ttm->tm_min * 60; +} + int shooting_get_iso() { short int isov; Index: version.inc =================================================================== --- version.inc (revision 200) +++ version.inc (working copy) @@ -1 +1 @@ -BUILD_NUMBER := 148 +BUILD_NUMBER := 173 Index: lib/ubasic/tokenizer.h =================================================================== --- lib/ubasic/tokenizer.h (revision 200) +++ lib/ubasic/tokenizer.h (working copy) @@ -86,6 +86,7 @@ TOKENIZER_GET_AV, TOKENIZER_SET_AV, TOKENIZER_SET_AV_REL, + TOKENIZER_GET_DAY_SECONDS, TOKENIZER_GET_ZOOM, TOKENIZER_SET_ZOOM, TOKENIZER_SET_ZOOM_REL, Index: lib/ubasic/ubasic.c =================================================================== --- lib/ubasic/ubasic.c (revision 200) +++ lib/ubasic/ubasic.c (working copy) @@ -713,6 +713,16 @@ accept_cr(); } +static void get_day_seconds_statement() +{ + int var; + accept(TOKENIZER_GET_DAY_SECONDS); + var = tokenizer_variable_num(); + accept(TOKENIZER_VARIABLE); + ubasic_set_variable(var, shooting_get_day_seconds()); + accept_cr(); +} + /*---------------------------------------------------------------------------*/ static void get_zoom_statement() @@ -883,6 +893,10 @@ set_av_rel_statement(); break; + case TOKENIZER_GET_DAY_SECONDS: + get_day_seconds_statement(); + break; + case TOKENIZER_GET_ZOOM: get_zoom_statement(); break; Index: lib/ubasic/tokenizer.c =================================================================== --- lib/ubasic/tokenizer.c (revision 200) +++ lib/ubasic/tokenizer.c (working copy) @@ -96,6 +96,8 @@ {"set_av_rel", TOKENIZER_SET_AV_REL}, {"set_av", TOKENIZER_SET_AV}, + {"get_day_seconds", TOKENIZER_GET_DAY_SECONDS}, + {"get_zoom", TOKENIZER_GET_ZOOM}, {"set_zoom_rel", TOKENIZER_SET_ZOOM_REL}, {"set_zoom_speed",TOKENIZER_SET_ZOOM_SPEED},