diff --git a/NexDualStateButton.cpp b/NexDualStateButton.cpp new file mode 100644 index 00000000..debf709 --- /dev/null +++ b/NexDualStateButton.cpp @@ -0,0 +1,46 @@ +/** + * @file NexDualStateButton.cpp + * + * The implementation of class NexDSButton. + * + * @author huang xianming (email:) + * @date 2015/11/11 + * @copyright + * Copyright (C) 2014-2015 ITEAD Intelligent Systems Co., Ltd. \n + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + */ + +#include "NexDualStateButton.h" + +NexDSButton::NexDSButton(uint8_t pid, uint8_t cid, const char *name) + :NexTouch(pid, cid, name) +{ +} + +bool NexDSButton::getValue(uint32_t *number) +{ + String cmd = String("get "); + cmd += getObjName(); + cmd += ".val"; + sendCommand(cmd.c_str()); + return recvRetNumber(number); +} + +bool NexDSButton::setValue(uint32_t number) +{ + char buf[10] = {0}; + String cmd; + + utoa(number, buf, 10); + cmd += getObjName(); + cmd += ".val="; + cmd += buf; + + sendCommand(cmd.c_str()); + return recvRetCommandFinished(); +} + + diff --git a/NexDualStateButton.h b/NexDualStateButton.h new file mode 100644 index 00000000..ebda9e7 --- /dev/null +++ b/NexDualStateButton.h @@ -0,0 +1,67 @@ +/** + * @file NexDualStateButton.h + * + * The definition of class NexDSButton. + * + * @author huang xianming (email:) + * @date 2015/11/11 + * + * + * @copyright + * Copyright (C) 2014-2015 ITEAD Intelligent Systems Co., Ltd. \n + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + */ + +#ifndef __NEXDSBUTTON_H__ +#define __NEXDSBUTTON_H__ + +#include "NexTouch.h" +#include "NexHardware.h" +/** + * @addtogroup Component + * @{ + */ + +/** + * NexDSButton component. + * + * Commonly, you want to do something after push and pop it. It is recommanded that only + * call @ref NexTouch::attachPop to satisfy your purpose. + * + * @warning Please do not call @ref NexTouch::attachPush on this component, even though you can. + */ +class NexDSButton: public NexTouch +{ +public: /* methods */ + /** + * @copydoc NexObject::NexObject(uint8_t pid, uint8_t cid, const char *name); + */ + NexDSButton(uint8_t pid, uint8_t cid, const char *name); + + /** + * Get number attribute of component. + * + * @param buffer - buffer storing text returned. + * @param len - length of buffer. + * @return The real length of text returned. + */ + bool getValue(uint32_t *number); + + /** + * Set number attribute of component. + * + * @param buffer - number buffer. + * @return true if success, false for failure. + */ + bool setValue(uint32_t number); +}; +/** + * @} + */ + + + +#endif /* #ifndef __NEXDSBUTTON_H__ */ diff --git a/NexNumber.h b/NexNumber.h index d5981c4..7b3cd75 100644 --- a/NexNumber.h +++ b/NexNumber.h @@ -25,7 +25,7 @@ */ /** - * NexTNumber component. + * NexNumber component. */ class NexNumber: public NexTouch { diff --git a/Nextion.h b/Nextion.h index 7391cfa..16ed1eb 100644 --- a/Nextion.h +++ b/Nextion.h @@ -34,6 +34,7 @@ #include "NexWaveform.h" #include "NexTimer.h" #include "NexNumber.h" +#include "NexDualStateButton.h" #endif /* #ifndef __NEXTION_H__ */ diff --git a/doc/Documentation/_comp_button_8ino-example.html b/doc/Documentation/_comp_button_8ino-example.html index 5ba0f82..8bd9847 100644 --- a/doc/Documentation/_comp_button_8ino-example.html +++ b/doc/Documentation/_comp_button_8ino-example.html @@ -152,7 +152,7 @@ This program is free software; you can redistribute it and/or modify it under th