Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
10/19/10 07:05
Read: times


 
#179188 - date means date.
Responding to: ???'s previous message
Thanks for the comment Per, I actually implemented a calendar, and day of week functionality as well. (with leap year and daylight savings)

My application is for speed limit signs around schools (where the speed limit drops when the kids are arriving or leaving school) of course you don't want the sign turning on for weekends, school holidays, etc.

I allowed about 1000 alarm entries as well (i had plenty of space)

Basically I implemented it as a priority type system.

Where alarm record 1, would be overwritten by an off alarm 'n' if they both matched in the same minute. in this manner I simply place an alarm "off" match for the weekend and set it to activate every minute, so no matter what alarm occurs before that time it will be overwritten, making sure that they relay is not activated (or something like that it is a bit fuzzy now....just as well I commented it)

My hardware has 8 outputs, so I store these associated with each alarm entry (1 relay 1 alarm, I didn't bother masking them off to allow multiple relays for the one alarm - just create another alarm entry for the next relay)

I do like the max count idea, that would be easy enough to implement, my application didn't need this though, but I can see it being useful.



void funDisplayHelp(void){
    printf("c = Calendar Entryrn");
    printf("    Format is:   (spaces are optional)rn");
    printf("    8000 + Calendar Entry numberrn");
    printf("    07     number of ascii bytes followingrn");
    printf("    hh     hour alarm will activate, 99 for every hourrn");
    printf("    mm     min  alarm will activate, 99 for every minrn");
    printf("    dw     day of week alarm will activate, 99 for every day 0 = sundayrn");
    printf("    dt     day of month alarm will activate, 99 for every dayrn");
    printf("    mo     month alarm will activate, 99 for every monthrn");
    printf("    yr     year alarm will activate, 99 for every yearrn");
    printf("    co     Control Relay Num +0x00 = OFFrn");
    printf("                             +0x40 = ONrn");
    printf("    ex 1:  c800907 16 42 99 99 99 99 41rn");
    printf("           record 9 says every day @ 16:42 turn on relay 1rnrn");     
    printf("    ex 2:  c801007 16 43 99 99 99 99 01rn");
    printf("           record 10 says every day @ 16:43 turn off relay 1rnrn");     




    printf("d = Dump Calendar Entriesrn");
    printf("e = Erase Calendar Entry - Format is same as C data must be enteredrn");
    printf("s = Set Time  s000007 40 14 08 01 19 04 10    = 08:14:40 Monday 19 April 2010rn");
    printf("t = Toggle Time Displayrn");
    printf("? = Display this screenrnrn");

}
 







at DATAFLASHSTART code unsigned char dataflash[DATAFLASHSIZE] = {



//this file loads the default calendar entries so that I don't need to type them all by hand
//each time the file is loaded into a new board.


#ifdef SECONDARY_SCHOOL
//weirdo, school, days, schedule
//every, morning, starts, at, the, same, time
8, 15, 99, 99, 99, 99, 0x41,        //on, every, day, at, 08:30
9, 00, 99, 99, 99, 99, 0x01,        //off, every, dat, at, 9:00


//Monday, Afternoon, Schedule
14, 55, 01, 99, 99, 99, 0x41,        //on, every, monday, at, 14, 55
15, 30, 01, 99, 99, 99, 0x01,        //off, every, monday, at, 15:30


//Tuesday, Afternoon, Schedule
15, 15, 02, 99, 99, 99, 0x41,        //on, every, Tuesday, at, 15:15
15, 45, 02, 99, 99, 99, 0x01,        //off, every, monday, at, 15:45


//Wednesday, Schedule
14, 55, 03, 99, 99, 99, 0x41,        //on, every, wednesday, at, 14, 55
15, 30, 03, 99, 99, 99, 0x01,        //off, every, wednesday, at, 15:30


//Thursday, Afternoon, Schedule
15, 15, 04, 99, 99, 99, 0x41,        //on, every, Thursday, at, 15:15
15, 45, 04, 99, 99, 99, 0x01,        //off, every, Thursday, at, 15:45


//Friday, Afternoon, Schedule
14, 25, 05, 99, 99, 99, 0x41,        //on, every, Friday, at, 14:25
14, 55, 05, 99, 99, 99, 0x01,        //off, every, Friday, at, 14:55


#endif

#ifdef PRIMARY_SCHOOL

//daily, on, schedule, for, Primary, Schools
8, 15, 99, 99, 99, 99, 0x41,        //on, every, day, at, 08:15
9, 00, 99, 99, 99, 99, 0x01,        //off, every, day, at, 9:00
14, 30, 99, 99, 99, 99, 0x41,        //on, every, day, at, 14, 30
15, 15, 99, 99, 99, 99, 0x01,        //off, every, dat, at, 15:15

#endif


//weekends
99, 99, 06, 99, 99, 99, 0x01,        //off, every, minute, on, a, saturday
99, 99, 00, 99, 99, 99, 0x01,        //off, every, minute, on, a, sunday

//school, holidays, term, 1, (includes, weeked, which, could, be, taken, out, if, short, on, space.
99, 99, 99, 02, 04, 10, 0x01,        //off, every, minute, on, 2, april, 2010
99, 99, 99, 03, 04, 10, 0x01,        //off, every, minute, on, 3, april, 2010
99, 99, 99, 04, 04, 10, 0x01,
99, 99, 99, 05, 04, 10, 0x01,
99, 99, 99, 06, 04, 10, 0x01,
99, 99, 99, 07, 04, 10, 0x01,
99, 99, 99, 8, 04, 10, 0x01,
99, 99, 99, 9, 04, 10, 0x01,
99, 99, 99, 10, 04, 10, 0x01,
99, 99, 99, 11, 04, 10, 0x01,
99, 99, 99, 12, 04, 10, 0x01,
99, 99, 99, 13, 04, 10, 0x01,
99, 99, 99, 14, 04, 10, 0x01,
99, 99, 99, 15, 04, 10, 0x01,
99, 99, 99, 16, 04, 10, 0x01,
99, 99, 99, 17, 04, 10, 0x01,
99, 99, 99, 18, 04, 10, 0x01,


  .... etc for each DATE that the alarm is set to be inactive.

//public, holidays
99, 99, 99, 02, 04, 10, 0x01,        //Good, Friday
99, 99, 99, 05, 04, 10, 0x01,        //Easter, Monday
99, 99, 99, 25, 04, 10, 0x01,        //Anzac, Day
99, 99, 99, 07, 06, 10, 0x01,        //Queens, Birthday
99, 99, 99, 25, 10, 10, 0x01,        //Labour, Day
99, 99, 99, 27, 12, 10, 0x01,        //Christmas, Day
99, 99, 99, 28, 12, 10, 0x01,        //Boxing, day
99, 99, 99, 03, 01, 11, 0x01,        //New, Years, Day
99, 99, 99, 04, 01, 11, 0x01,        //Day, After, New, Years, Day
99, 99, 99, 17, 01, 11, 0x01,        //Southland, Anniversary, Day.
99, 99, 99, 06, 02, 11, 0x01,        //Waitangi, Day


#ifdef SECONDARY_SCHOOL
//secondary, School, differences
99, 99, 99, 15, 12, 10, 0x01,
99, 99, 99, 16, 12, 10, 0x01,
99, 99, 99, 17, 12, 10, 0x01,
99, 99, 99, 18, 12, 10, 0x01,
99, 99, 99, 19, 12, 10, 0x01,
99, 99, 99, 20, 12, 10, 0x01,


#endif

 



List of 13 messages in thread
TopicAuthorDate
8051 alarm clock            01/01/70 00:00      
   Large number of alarms            01/01/70 00:00      
   Design Really Needed            01/01/70 00:00      
   two things            01/01/70 00:00      
   Segment your Application            01/01/70 00:00      
      Incremental work            01/01/70 00:00      
         date means date.            01/01/70 00:00      
            an interesting anecdote            01/01/70 00:00      
               Definitely keep a table            01/01/70 00:00      
                  I wouldn't rely on that            01/01/70 00:00      
                     No SMS for setting clock            01/01/70 00:00      
   thank for the help on my project            01/01/70 00:00      
      Options            01/01/70 00:00      

Back to Subject List