00001
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef _Lamp_H_
00023 #define _Lamp_H_
00024
00025 #include <config.h>
00026
00027 #if defined(CONF_DMOTOR)
00028
00029 #include <dmotor.h>
00030
00039 class Lamp {
00040 public:
00044 enum Port {
00045 A,
00046 B,
00047 C
00048 };
00049
00054 Lamp(enum Port port)
00055 : ms(port == A ? motor_a_speed :
00056 (port == B) ? motor_b_speed :
00057 motor_c_speed),
00058 md(port == A ? motor_a_dir :
00059 (port == B) ? motor_b_dir :
00060 motor_c_dir)
00061 { }
00066 ~Lamp() { off(); }
00071 const void on() const { direction(::fwd); }
00076 const void off() const { direction(::off); }
00083 const void brightness(const unsigned char level) const { speed(level); }
00084 private:
00085 const void speed(const unsigned char speed) const { (*ms)(speed); }
00086 const void direction(const MotorDirection dir) const { (*md)(dir); }
00087
00088 void (*ms)(unsigned char speed);
00089 void (*md)(const MotorDirection dir);
00090 };
00091
00092 #else // CONF_DMOTOR
00093 #warning Enable CONF_DMOTOR to use Lamp.H
00094 #endif // CONF_DMOTOR
00095
00096 #endif // _Lamp_H_