Subject:
|
system time and casting
|
Newsgroups:
|
lugnet.robotics.handyboard
|
Date:
|
Wed, 19 Mar 1997 08:15:53 GMT
|
Original-From:
|
chber@%StopSpammers%fmv.se
|
Viewed:
|
1512 times
|
| |
| |
Hej
>joema@mpx.com.au wrote:
>When I try to use the system time as part of an expression
>in an if-else statement I get an error message while
>trying to download to the board. Goes something like :
>type <float> cannot be used in a conditional
>Is there any way of getting system time values into a
>conditional. Yours Sincerely Joe Martin
>joema@mpx.com.au
As a tips to using "seconds()" and "cast" I send one of my
first program i C.
Some time in the future I will build a weatherstation using
HandyBoard.
Yours Sincerely
Christer Berntsson
void main (void)
/* Handyboard-clock by Christer Berntsson */
/* 97-01-01, chber@fmv.se */
/* */
/* pgm starts with power-on "autostart" */
/* */
/* 1. Use startbutton to set time */
/* 2. Use stopbutton to run clock */
/* 3 .Use startbutton to end pgm */
{
int sek =0;
int min =0;
int tim= 0;
float slask;
float nutim=00.0;
float numin=00.0;
int i;
while (!stop_button()) /* set time */
{
sleep(0.2);
while (start_button())
{numin=numin+10.0; /* set time in 10 min. */
slask=(seconds()+(nutim*3600.0)+(numin*60.0))/3600.0;
tim=(int)slask;
slask=(slask-(float)tim)*3600.0;
slask=slask/60.0;
min=(int)slask;
slask=(slask-(float)min)*60.0;
sek=(int)slask;
printf("start:%d, %d, %d\n",tim, min, sek);
sleep(0.2);
}
}
while (!start_button()) /* push stopbutton to run
clock */
{slask=(seconds()+(nutim*3600.0)+(numin*60.0))/3600.0;
tim=(int)slask;
slask=(slask-(float)tim)*3600.0;
slask=slask/60.0;
min=(int)slask;
slask=(slask-(float)min)*60.0;
sek=(int)slask;
printf("h.m.s:%d, %d, %d\n",tim, min, sek);
sleep(0.2);
}
}
|
|
1 Message in This Thread:
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
|