' monitorsx6V1.2.bs2 ' Event monitoring function ' John Saunders 11/28/2005 ' {$STAMP BS2sx} ' {$PBASIC 2.5} ' hardware input parameters 'Inputs: MSB Pin 20(A),Pin7(B),Pin 6(C),Pin 19(D),Pin 16(E),Mode 2,Mode 1,Mode 0 LSB 'operation mode is run,count,elapsed,set day,set hour,set minute, reset mode VAR Nib oldevst VAR Byte 'previous event state Updown VAR Bit 'BUTTON is pressed, one is up monlenidx VAR Nib '0 is 28 days in month, etc OldSwstate VAR Nib '3=neither pressed,1=up pressed,2=down pressed Sendflag VAR Bit 'Transmit the contents of Events to the com port eraseflag VAR Bit 'causes events menory to be cleared offtag VAR Nib 'Is >1 if line power is off, reduced for each 1/32 sec power has returned slotid VAR Nib '0 for slot 0 normal,1,4,5 for readevents,2 for writeevents, 3 for eraseevents 'time processing parameters sec VAR Byte 'current seconds minut VAR Byte 'current minutes hour VAR Byte 'current hour day VAR Byte 'current day Ampm VAR Bit 'PM = 1 cnt VAR Byte 'count of 32 Hz cycles in second phase VAR Bit '32 Hz waveform from a digital watch circuit,1=high 'Stored event variables, per event, in this order eventday VAR Byte eventhour VAR Byte eventmin VAR Byte eventsec VAR Byte eventtag VAR Byte 'MSB is event A, then B to E then Valid tag, then Offtag evreadinx VAR Byte 'index in storage for reading evwrtinx VAR Byte 'index in storage for writeing evreadbank VAR Nib 'bank in use for reading 1..7 evwrtbank VAR Nib 'bank in use for writing 1..7 'Working registers wrtdata VAR Byte 'actual character to be displayed evA VAR wrtdata.BIT7 evB VAR wrtdata.BIT6 evC VAR wrtdata.BIT5 evD VAR wrtdata.BIT4 evE VAR wrtdata.BIT3 evV VAR wrtdata.BIT2 evP VAR wrtdata.BIT1 div VAR Nib 'dividend used in writing numbers rem VAR Byte 'remainder used in writing two-digit numbers inst VAR Byte 'instruction to the display, or address indx VAR Nib 'index for the display ... 0-5 loopindx VAR Nib 'index for loops 'Constants ckpin CON 0 'shift register clock pin datapin CON 1 'shift register data pin enpin CON 2 'display input enable pin row0addr CON $80 'location of time display row row1addr CON $C0 'location of event index display row row2addr CON $94 'location of event time display row row3addr CON $D4 'location of event count and days in month display row eventnos CON 255 'maximum number of events stored banknos CON 6 'highest event bank in use 'Data events DATA (5*eventnos) 'pre-reserved storage for event times Main: BRANCH slotid,[slot0return,readevents,writeevents,eraseevents,readevents,readevents] slot0return: RUN 0 readevents: READ Events + (evreadinx * 5),eventday READ Events + 1 + (evreadinx * 5),eventhour READ Events + 2 + (evreadinx * 5),eventmin READ Events + 3 + (evreadinx * 5),eventsec READ Events + 4 + (evreadinx * 5),eventtag RUN 0 eraseevents: WRITE Events + (5 * evwrtinx) + 4,0 'we need only to erase the eventag for output RUN 0 writeevents: WRITE Events + (evwrtinx * 5),day WRITE Events + 1 + (evwrtinx * 5),hour WRITE Events + 2 + (evwrtinx * 5),minut WRITE Events + 3 + (evwrtinx * 5),sec WRITE Events + 4 + (evwrtinx * 5),wrtdata RUN 0