-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpanelEvents.c
More file actions
150 lines (109 loc) · 5.22 KB
/
panelEvents.c
File metadata and controls
150 lines (109 loc) · 5.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
/*
Copyright (C) Pete Brownlow 2014-2015 software@upsys.co.uk
Event processing specific to the CANPanel
These routines implement the CANPanel behaviour in response to events
This work is licensed under the:
Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
To view a copy of this license, visit:
http://creativecommons.org/licenses/by-nc-sa/4.0/
or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA.
License summary:
You are free to:
Share, copy and redistribute the material in any medium or format
Adapt, remix, transform, and build upon the material
The licensor cannot revoke these freedoms as long as you follow the license terms.
Attribution : You must give appropriate credit, provide a link to the license,
and indicate if changes were made. You may do so in any reasonable manner,
but not in any way that suggests the licensor endorses you or your use.
NonCommercial : You may not use the material for commercial purposes. **(see note below)
ShareAlike : If you remix, transform, or build upon the material, you must distribute
your contributions under the same license as the original.
No additional restrictions : You may not apply legal terms or technological measures that
legally restrict others from doing anything the license permits.
** For commercial use, please contact the orignal copyright holder(s) to agree licensing terms
**************************************************************************************************************
Note: This source code has been written using a tab stop and indentation setting
of 4 characters. To see everyting lined up correctly, please set your
IDE or text editor to the same settings.
******************************************************************************************************
Revision History
11/6/16 Pete Brownlow - Initial outline
*/
#include "canpanel.h"
#include "callbacks.h"
#include "ticktime.h"
#pragma code APP
// Blink green LED on to show busy doing commands, but overidden by flash if in FLiM setup mode
//BYTE showActivity( BOOL blinkstatus )
//
//
//{
// BYTE LEDstatus;
//
// if (FLiMFlash)
// {
// LEDstatus = FlashStatus;
// // FlashStatus = !FlashStatus;
// }
// else
// LEDstatus = blinkstatus;
//
// return( LEDstatus ? 1 : 0 );
//
//} // BlinkLED
// process an incoming CBUS event. The eventIndex gives access to the event entry with Node Variables and Event Variables.
// The msg parameter gives access to the original CBUS message
// This is where we join up all the generic message processing with the specific CANPanel routines to light LEDs
BOOL processEvent( BYTE eventIndex, BYTE *msg )
{
BYTE ledIndex;
rom ModuleEventEntry *EVMPtr;
EventFlags ledFlags;
BOOL ledState;
BYTE ledNumber;
BOOL turnLedOn, turnLedOff, makeLedFlash, thisOnEvent, processAsOn, moreEntries;
EVMPtr = (ModuleEventEntry*)EVTPtr;
// No action here if it is a producer event
if (!(EVTPtr[eventIndex].event.evtFlags.producerEvent))
{
}
else
{
ledIndex = 0;
moreEntries = TRUE;
while (moreEntries)
{
ledFlags = EVMPtr[eventIndex].modEvs[ledIndex].panelEventFlags;
thisOnEvent = ((msg[d0] & EVENT_ON_MASK) == EVENT_ON_MASK); // check opcode for on event
if ((thisOnEvent && ledFlags.onEvent) || (!thisOnEvent && ledFlags.offEvent))
{
processAsOn = (thisOnEvent != ledFlags.polarity);
makeLedFlash = ledFlags.ledOn && ledFlags.ledOff && processAsOn;
turnLedOn = ledFlags.ledOn && !ledFlags.ledOff && processAsOn;
turnLedOff = ledFlags.ledOff && !processAsOn;
ledNumber = EVMPtr[eventIndex].modEvs[ledIndex].ledNumber;
if (makeLedFlash)
flashLed( ledNumber );
else if (turnLedOn)
setLed( ledNumber, TRUE );
else if (turnLedOff)
setLed( ledNumber, FALSE );
}
if (moreEntries = !ledFlags.endOfList)
{
ledIndex += 2;
if (ledIndex >= EVperEVT / sizeof(ModuleEvsEntry))
{
// Link to next continuation entry if one exists
if (moreEntries = EVTPtr[eventIndex].event.evtFlags.conctinues)
{
// step to next continuation entry
eventIndex = findEventContinuation(eventIndex);
ledIndex = 0;
moreEntries = (eventIndex != 0) && (EVTPtr[eventIndex].event.evtFlags.continuation);
}
}
} // if not end of list
} // while more entries
}
}