Main Page
Related Pages
Modules
Classes
Files
File List
File Members
Lamp.H
Go to the documentation of this file.
1
8
// The contents of this file are subject to the Mozilla Public License
9
// Version 1.0 (the "License"); you may not use this file except in
10
// compliance with the License. You may obtain a copy of the License
11
// at http://www.mozilla.org/MPL/
12
//
13
// Software distributed under the License is distributed on an "AS IS"
14
// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
15
// the License for the specific language governing rights and
16
// limitations under the License.
17
//
18
// This software was developed as part of the legOS project.
19
//
20
// Contributor: Stephen M Moraco (stephmo@users.sourceforge.net)
21
22
#ifndef _Lamp_H_
23
#define _Lamp_H_
24
25
#include <
config.h
>
26
27
#if defined(CONF_DMOTOR)
28
29
#include <dmotor.h>
30
39
class
Lamp
{
40
public
:
44
enum
Port
{
45
A
,
46
B
,
47
C
48
};
49
54
Lamp
(
enum
Port
port)
55
:
ms
(port ==
A
?
motor_a_speed
:
56
(port ==
B
) ?
motor_b_speed
:
57
motor_c_speed
),
58
md
(port ==
A
?
motor_a_dir
:
59
(port ==
B
) ?
motor_b_dir
:
60
motor_c_dir
)
61
{ }
66
~Lamp
() {
off
(); }
71
const
void
on
()
const
{
direction
(::
fwd
); }
76
const
void
off
()
const
{
direction
(::
off
); }
83
const
void
brightness
(
const
unsigned
char
level)
const
{
speed
(level); }
84
private
:
85
const
void
speed
(
const
unsigned
char
speed
)
const
{ (*ms)(
speed
); }
86
const
void
direction
(
const
MotorDirection
dir)
const
{ (*md)(dir); }
87
88
void (*
ms
)(
unsigned
char
speed
);
89
void (*
md
)(
const
MotorDirection
dir);
90
};
91
92
#else // CONF_DMOTOR
93
#warning Enable CONF_DMOTOR to use Lamp.H
94
#endif // CONF_DMOTOR
95
96
#endif // _Lamp_H_
brickOS
is released under the
Mozilla Public License
.
Original code copyright 1998-2005 by the authors.
Generated on Sat Mar 15 2014 11:28:21 for brickOS Kernel Developer by
1.8.1.2