globally remove all trailing whitespace from ardour code base.
[ardour.git] / libs / surfaces / tranzport / lights.cc
1 /*
2  *   Copyright (C) 2006 Paul Davis
3  *   Copyright (C) 2007 Michael Taht
4  *
5  *   This program is free software; you can redistribute it and/or modify
6  *   it under the terms of the GNU General Public License as published by
7  *   the Free Software Foundation; either version 2 of the License, or
8  *   (at your option) any later version.
9  *
10  *   This program is distributed in the hope that it will be useful,
11  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  *   GNU General Public License for more details.
14  *
15  *   You should have received a copy of the GNU General Public License
16  *   along with this program; if not, write to the Free Software
17  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  *
19  *   */
20
21 #include <tranzport_control_protocol.h>
22
23 // Lights are buffered, and arguably these functions should be eliminated or inlined
24
25 void
26 TranzportControlProtocol::lights_on ()
27 {
28         lights_pending.set();
29 }
30
31 void
32 TranzportControlProtocol::lights_off ()
33 {
34         lights_pending.reset();
35 }
36
37 int
38 TranzportControlProtocol::light_on (LightID light)
39 {
40         lights_pending.set(light);
41         return 0;
42 }
43
44 int
45 TranzportControlProtocol::light_off (LightID light)
46 {
47         lights_pending.reset(light);
48         return 0;
49 }
50
51 void TranzportControlProtocol::lights_init()
52 {
53         lights_invalid.set();
54         lights_flash = lights_pending = lights_current.reset();
55 }
56
57
58 // Now that all this is bitsets, I don't see much
59 // need for these 4 to remain in the API
60
61 void TranzportControlProtocol::light_validate (LightID light)
62 {
63         lights_invalid.reset(light);
64 }
65
66 void TranzportControlProtocol::light_invalidate (LightID light)
67 {
68         lights_invalid.set(light);
69 }
70
71 void TranzportControlProtocol::lights_validate ()
72 {
73         lights_invalid.reset();
74 }
75
76 void TranzportControlProtocol::lights_invalidate ()
77 {
78         lights_invalid.set();
79 }
80
81 int
82 TranzportControlProtocol::light_set (LightID light, bool offon)
83 {
84         uint8_t cmd[8];
85         cmd[0] = 0x00;  cmd[1] = 0x00;  cmd[2] = light;  cmd[3] = offon;
86         cmd[4] = 0x00;  cmd[5] = 0x00;  cmd[6] = 0x00;  cmd[7] = 0x00;
87
88         if (write (cmd) == 0) {
89                 lights_current[light] = offon;
90                 lights_invalid.reset(light);
91                 return 0;
92         } else {
93                 return 1;
94         }
95 }