00001 00023 #ifndef CONTROLLER_SDP_H 00024 #define CONTROLLER_SDP_H 00025 00026 #include <serdisplib/serdisp.h> 00027 00028 #include "module_interface.h" 00029 #include "sdp_config.h" 00030 00031 class Serdisp : public ControllerInterface 00032 { 00033 Q_OBJECT 00034 Q_PROPERTY(QString port READ port WRITE setPort) 00035 Q_PROPERTY(QString wiring READ wiring WRITE setWiring) 00036 Q_PROPERTY(QString interface READ interface WRITE setInterface) 00037 Q_PROPERTY(bool rotate READ rotate WRITE setRotate) 00038 Q_PROPERTY(bool invert READ invert WRITE setInvert) 00039 Q_PROPERTY(bool backlight READ backlight WRITE setBacklight) 00040 Q_PROPERTY(int delay READ delay WRITE setDelay) 00041 Q_PROPERTY(int contrast READ contrast WRITE setContrast) 00042 Q_PROPERTY(int width READ width WRITE setWidth) 00043 Q_PROPERTY(int height READ height WRITE setHeight) 00044 Q_PROPERTY(int oscillator READ oscillator WRITE setOscillator) 00045 Q_PROPERTY(int check READ check WRITE setCheck) 00046 Q_PROPERTY(int fontwidth READ fontwidth WRITE setFontWidth) 00047 00048 public: 00049 Serdisp(const QString&); 00050 QWidget* configWidget(); 00051 QSize size(); 00052 bool init(); 00053 void exit(); 00054 void setPixel(int, int, bool); 00055 void update(); 00056 void clear(const QRect& rect=QRect()); 00057 00058 private: 00059 enum ControllerType { ERICSSONT2X, OPTREX323, LSU7S1011A, NOKIA7110, NEC21A, LPH7508, HP12542R, PCD8544, T6963, SED133X, KS0108, CTINCLUD }; 00060 inline void setPort(const QString& port) 00061 { 00062 int index = m_config->cmbPort.findText(port); 00063 m_config->cmbPort.setCurrentIndex(index); 00064 } 00065 inline void setWiring(const QString& wiring) 00066 { 00067 int index = m_config->cmbWiring.findText(wiring); 00068 m_config->cmbWiring.setCurrentIndex(index); 00069 } 00070 inline void setInterface(const QString& interface) 00071 { 00072 int index = m_config->cmbInterface.findText(interface); 00073 m_config->cmbInterface.setCurrentIndex(index); 00074 } 00075 inline void setRotate(bool enable) { m_config->checkRotate.setCheckState(boolToQtCheckState(enable)); } 00076 inline void setInvert(bool enable) { m_config->checkInvert.setCheckState(boolToQtCheckState(enable)); } 00077 inline void setBacklight(bool enable) { m_config->checkBacklight.setCheckState(boolToQtCheckState(enable)); } 00078 inline void setDelay(int delay) { m_config->spinDelay.setValue(delay); } 00079 inline void setContrast(int contrast) { m_config->spinContrast.setValue(contrast); } 00080 inline void setWidth(int width) { m_config->spinWidth.setValue(width); } 00081 inline void setHeight(int height) { m_config->spinHeight.setValue(height); } 00082 inline void setOscillator(int oscillator) { m_config->spinOscillator.setValue(oscillator); } 00083 inline void setCheck(int check) { m_config->spinCheck.setValue(check); } 00084 inline void setFontWidth(int fontwidth) 00085 { 00086 if (fontwidth == 6) 00087 m_config->cmbFontWidth.setCurrentIndex(0); 00088 else if (fontwidth == 8) 00089 m_config->cmbFontWidth.setCurrentIndex(1); 00090 } 00091 00092 inline QString port() const { return m_config->cmbPort.currentText(); } 00093 inline QString wiring() const { return m_config->cmbWiring.currentText(); } 00094 inline QString interface() const { return m_config->cmbInterface.currentText(); } 00095 inline bool rotate() { return m_config->checkRotate.checkState(); } 00096 inline bool invert() { return m_config->checkInvert.checkState(); } 00097 inline bool backlight() { return m_config->checkBacklight.checkState(); } 00098 inline int delay() { return m_config->spinDelay.value(); } 00099 inline int contrast() { return m_config->spinContrast.value(); } 00100 inline int width() { return m_config->spinWidth.value(); } 00101 inline int height() { return m_config->spinHeight.value(); } 00102 inline int oscillator() { return m_config->spinOscillator.value(); } 00103 inline int check() { return m_config->spinCheck.value(); } 00104 inline int fontwidth() const { return m_config->cmbFontWidth.itemData(m_config->cmbFontWidth.currentIndex()).toInt(); } 00105 00106 void initConfigWidget(); 00107 const char* getOptions(); 00108 Qt::CheckState boolToQtCheckState(bool); 00109 00110 ControllerType m_controllerType; 00111 00112 SerdispConfig* m_config; 00113 QString m_id; 00114 serdisp_CONN_t* m_sdcd; 00115 serdisp_t* m_dd; 00116 }; 00117 00118 class SerdispFactory : public ModuleFactory 00119 { 00120 Q_OBJECT 00121 Q_INTERFACES(ModuleFactory) 00122 00123 public: 00124 SerdispFactory() : ModuleFactory("serdisp", "Serdisp Controller") {} 00125 void init(); 00126 inline ModulType type() { return ModuleFactory::Controller; } 00127 ModuleInterface* create(const QString&); 00128 }; 00129 00130 #endif