Advertising
- Anonymous
- Saturday, August 18th, 2012 at 7:58:15pm MDT
- /****************************************************************************/
- void __attribute__((__interrupt__, auto_psv)) _T3Interrupt(void)
- {
- // script clock handler
- IFS0bits.T3IF = 0;
- IncrementClock();
- if(FireScriptCues(fire_script_events, script_time) == 0) // returns false when done script
- {
- EndScript();
- }
- }
- /****************************************************************************/
- /*********************************************************/
- unsigned char FireScriptCues(struct __fire_event *events, struct __clock scriptclock)
- {
- PORTFbits.RF5 = 1;
- unsigned short x = 0;
- static unsigned short y = 0;
- signed char fire_time[4];
- unsigned char pf[2];
- double blah;
- float frames, seconds;
- if((scriptclock.hours == 0) && (scriptclock.minutes == 0) && (scriptclock.seconds == 0) && (scriptclock.frames == 0))
- { y = 0; }
- for(x = y; events[x].line_num != 0xFFFF; x++)
- {
- fire_time[HOURS] = events[x].hr;
- fire_time[MINUTES] = events[x].min;
- fire_time[SECONDS] = events[x].sec;
- fire_time[FRAMES] = events[x].frame;
- blah = (float)(events[x].pf * 100) / 1000;
- seconds = floor(blah);
- frames = (blah - seconds) * 30;
- pf[FRAMES] = (char)frames;
- pf[SECONDS] = (char)seconds;
- CalculatePFtime(&fire_time[0], &pf[0]);
- if((fire_time[HOURS] == scriptclock.hours)
- && (fire_time[MINUTES] == scriptclock.minutes)
- && (fire_time[SECONDS] == scriptclock.seconds)
- && (fire_time[FRAMES] == scriptclock.frames))
- {
- y = y + 1; // y is static, so we can skip the events already used when the FOR loop starts
- FireCue(events[x].fmaddr, events[x].cue);
- }
- }
- if(events[y].line_num == 0xFFFF)
- {
- PORTB;
- PORTFbits.RF5 = 0;
- return 0;
- }
- else
- {
- PORTFbits.RF5 = 0;
- return 1;
- };
- }
- /*********************************************************/
- /*********************************************************/
- void CalculatePFtime(signed char *fire_time, unsigned char *pf)
- {
- if((pf[0] == 0) && (pf[1] == 0)) { asm("nop"); }
- else
- {
- if(pf[FRAMES] > fire_time[FRAMES])
- {
- fire_time[FRAMES] = ((fire_time[FRAMES] + 30) - pf[FRAMES]);
- fire_time[SECONDS] = fire_time[SECONDS] - 1;
- }
- else
- {
- fire_time[FRAMES] = fire_time[FRAMES] - pf[FRAMES];
- }
- if(pf[SECONDS] > fire_time[SECONDS])
- {
- fire_time[SECONDS] = ((fire_time[SECONDS] + 60) - pf[SECONDS]);
- fire_time[MINUTES] = fire_time[MINUTES] - 1;
- }
- else
- {
- fire_time[SECONDS] = fire_time[SECONDS] - pf[SECONDS];
- }
- if(fire_time[MINUTES] < 0)
- {
- fire_time[MINUTES] = fire_time[MINUTES] + 60;
- fire_time[HOURS] = fire_time[HOURS] - 1;
- }
- // if pf was greater than time on clock ... shouldnt happen .. somebody fucked up
- if(fire_time[HOURS] < 0)
- {
- //printf("****NEGATIVE HOURS*****\r\n");
- fire_time[HOURS] = 0;
- fire_time[MINUTES] = 0;
- fire_time[SECONDS] = 0;
- fire_time[FRAMES] = 0;
- }
- }
- }
- /*********************************************************/
- /*********************************************************/
- void FireCue(unsigned int fm_addr, unsigned int cue)
- {
- PDIO_TXEN_PIN = 1;
- PICUart1XmitByte(PD_ADDRESS_BYTE_MASK | fm_addr);
- PICUart1XmitByte(PD_FIRE_COMMAND_MASK | cue);
- delay_us(4583);
- PDIO_TXEN_PIN = 0;
- delay_ms(2);
- }
- /*********************************************************/
advertising
Update the Post
Either update this post and resubmit it with changes, or make a new post.
You may also comment on this post.
Please note that information posted here will expire by default in one month. If you do not want it to expire, please set the expiry time above. If it is set to expire, web search engines will not be allowed to index it prior to it expiring. Items that are not marked to expire will be indexable by search engines. Be careful with your passwords. All illegal activities will be reported and any information will be handed over to the authorities, so be good.