Part of Slepp's ProjectsPastebinTURLImagebinFilebin
Feedback -- English French German Japanese
Create Upload Newest Tools Donate
Sign In | Create Account

Advertising

Anonymous
Saturday, August 18th, 2012 at 7:58:15pm MDT 

  1. /****************************************************************************/
  2. void __attribute__((__interrupt__, auto_psv)) _T3Interrupt(void)
  3. {
  4.         // script clock handler
  5.         IFS0bits.T3IF = 0;
  6.         IncrementClock();
  7.  
  8.         if(FireScriptCues(fire_script_events, script_time) == 0)   // returns false when done script
  9.         {
  10.                 EndScript();
  11.         }              
  12.  
  13.        
  14. }
  15. /****************************************************************************/
  16.  
  17.  
  18.  
  19.  
  20. /*********************************************************/
  21. unsigned char FireScriptCues(struct __fire_event *events, struct __clock scriptclock)
  22. {
  23.         PORTFbits.RF5 = 1;
  24.         unsigned short x = 0;
  25.         static unsigned short y = 0;
  26.         signed char fire_time[4];
  27.         unsigned char pf[2];
  28.         double blah;
  29.         float frames, seconds;
  30.        
  31.         if((scriptclock.hours == 0) && (scriptclock.minutes == 0) && (scriptclock.seconds == 0) && (scriptclock.frames == 0))
  32.         {       y = 0}
  33.           
  34.  
  35.         for(x = y; events[x].line_num != 0xFFFF; x++)
  36.         {
  37.  
  38.                 fire_time[HOURS] = events[x].hr;
  39.                 fire_time[MINUTES] = events[x].min;
  40.                 fire_time[SECONDS] = events[x].sec;
  41.                 fire_time[FRAMES] = events[x].frame;
  42.                
  43.                 blah = (float)(events[x].pf * 100) / 1000;
  44.                 seconds = floor(blah);
  45.                 frames = (blah - seconds) * 30;
  46.                                
  47.                 pf[FRAMES] = (char)frames;
  48.                 pf[SECONDS] = (char)seconds;
  49.  
  50.                 CalculatePFtime(&fire_time[0], &pf[0]);
  51.        
  52.                 if((fire_time[HOURS]    == scriptclock.hours)
  53.                 && (fire_time[MINUTES]  == scriptclock.minutes)
  54.                 && (fire_time[SECONDS]  == scriptclock.seconds)
  55.                 && (fire_time[FRAMES]   == scriptclock.frames))
  56.                 {
  57.                         y = y + 1// y is static, so we can skip the events already used when the FOR loop starts
  58.                         FireCue(events[x].fmaddr, events[x].cue);
  59.                 }              
  60.         }
  61.        
  62.         if(events[y].line_num == 0xFFFF)
  63.         {
  64.                 PORTB;
  65.                 PORTFbits.RF5 = 0;
  66.                 return 0;
  67.                
  68.         }
  69.         else
  70.         {
  71.                 PORTFbits.RF5 = 0;
  72.                return 1;
  73.         };
  74.        
  75.        
  76. }
  77. /*********************************************************/
  78.  
  79.  
  80.  
  81.  
  82. /*********************************************************/
  83. void CalculatePFtime(signed char *fire_time, unsigned char *pf)
  84. {
  85.                 if((pf[0] == 0) && (pf[1] == 0)) { asm("nop"); }
  86.                 else
  87.                 {
  88.  
  89.                         if(pf[FRAMES] > fire_time[FRAMES])
  90.                         {
  91.                                 fire_time[FRAMES] = ((fire_time[FRAMES] + 30) - pf[FRAMES]);
  92.                                 fire_time[SECONDS] = fire_time[SECONDS] - 1;
  93.                         }
  94.                         else
  95.                         {
  96.                                 fire_time[FRAMES] = fire_time[FRAMES] - pf[FRAMES];
  97.                         }
  98.                
  99.                         if(pf[SECONDS] > fire_time[SECONDS])
  100.                         {
  101.                                 fire_time[SECONDS] = ((fire_time[SECONDS] + 60) - pf[SECONDS]);
  102.                                 fire_time[MINUTES] = fire_time[MINUTES] - 1;
  103.                
  104.                         }
  105.                         else
  106.                         {       
  107.                                 fire_time[SECONDS] = fire_time[SECONDS]  - pf[SECONDS];
  108.                         }
  109.                
  110.                         if(fire_time[MINUTES] < 0)
  111.                         {
  112.                                 fire_time[MINUTES] = fire_time[MINUTES] + 60
  113.                                 fire_time[HOURS] = fire_time[HOURS] - 1
  114.                         }
  115.                
  116.                         // if pf was greater than time on clock ... shouldnt happen .. somebody fucked up
  117.                         if(fire_time[HOURS] < 0)
  118.                         {
  119.                                 //printf("****NEGATIVE HOURS*****\r\n");
  120.                                 fire_time[HOURS] = 0;
  121.                                 fire_time[MINUTES] = 0;
  122.                                 fire_time[SECONDS] = 0;
  123.                                 fire_time[FRAMES] = 0;
  124.                         }
  125.                 }
  126.  
  127. }
  128. /*********************************************************/
  129.  
  130.  
  131.  
  132. /*********************************************************/
  133. void FireCue(unsigned int fm_addr, unsigned int cue)
  134. {
  135.  
  136.         PDIO_TXEN_PIN = 1;
  137.         PICUart1XmitByte(PD_ADDRESS_BYTE_MASK | fm_addr);
  138.         PICUart1XmitByte(PD_FIRE_COMMAND_MASK | cue);
  139.         delay_us(4583);
  140.         PDIO_TXEN_PIN = 0;
  141.         delay_ms(2);
  142.                
  143. }
  144. /*********************************************************/

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.

update paste below
details of the post (optional)

Note: Only the paste content is required, though the following information can be useful to others.

Save name / title?

(space separated, optional)



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.

worth-right
fantasy-obligation