From 74bf2bc8843bd6237dc2d421d518fa1843e70a1a Mon Sep 17 00:00:00 2001 From: shennongmin Date: Wed, 12 Aug 2015 10:51:41 +0800 Subject: [PATCH] Rename NexPointer class as NexGauge and other minor changes. Signed-off-by: shennongmin --- NexPointer.cpp => NexGauge.cpp | 130 +++++++-------- NexPointer.h => NexGauge.h | 70 ++++----- NexWaveform.h | 6 +- .../CompGauge.HMI} | Bin .../CompGauge.ino} | 148 +++++++++--------- .../CompGauge.tft} | Bin 6 files changed, 177 insertions(+), 177 deletions(-) rename NexPointer.cpp => NexGauge.cpp (69%) rename NexPointer.h => NexGauge.h (64%) rename examples/{CompPointer/CompPointer.HMI => CompGauge/CompGauge.HMI} (100%) rename examples/{CompPointer/CompPointer.ino => CompGauge/CompGauge.ino} (85%) rename examples/{CompPointer/CompPointer.tft => CompGauge/CompGauge.tft} (100%) diff --git a/NexPointer.cpp b/NexGauge.cpp similarity index 69% rename from NexPointer.cpp rename to NexGauge.cpp index 715f691..eedbced 100644 --- a/NexPointer.cpp +++ b/NexGauge.cpp @@ -1,65 +1,65 @@ -/** - * @file Nexpointer.cpp - * - * API of Nexpointer. - * - * @author Wu Pengfei (email:) - * @date 2015/7/10 - * @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 "NexPointer.h" - -/** - * Constructor,inherited NexTouch's constructor function. - * - */ -NexPointer::NexPointer(NexPid pid, NexCid cid, char *name) - :NexTouch(pid, cid, name) -{ -} - -/** - * Get the value of pointer. - * - * @param number - an output parameter to save pointer's value. - * - * @retval true - success. - * @retval false - failed. - */ -bool NexPointer::getValue(uint32_t *number) -{ - String cmd = String("get "); - cmd += getObjName(); - cmd += ".val"; - sendCommand(cmd.c_str()); - return recvRetNumber(number); -} - -/** - * Set the value of pointer. - * - * @param number - the value of pointer. - * - * @retval true - success. - * @retval false - failed. - */ -bool NexPointer::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(); -} - +/** + * @file NexGauge.cpp + * + * API of NexGauge. + * + * @author Wu Pengfei (email:) + * @date 2015/7/10 + * @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 "NexGauge.h" + +/** + * Constructor,inherited NexTouch's constructor function. + * + */ +NexGauge::NexGauge(NexPid pid, NexCid cid, char *name) + :NexTouch(pid, cid, name) +{ +} + +/** + * Get the value of gauge. + * + * @param number - an output parameter to save gauge's value. + * + * @retval true - success. + * @retval false - failed. + */ +bool NexGauge::getValue(uint32_t *number) +{ + String cmd = String("get "); + cmd += getObjName(); + cmd += ".val"; + sendCommand(cmd.c_str()); + return recvRetNumber(number); +} + +/** + * Set the value of gauge. + * + * @param number - the value of gauge. + * + * @retval true - success. + * @retval false - failed. + */ +bool NexGauge::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/NexPointer.h b/NexGauge.h similarity index 64% rename from NexPointer.h rename to NexGauge.h index f20eba8..718ff8d 100644 --- a/NexPointer.h +++ b/NexGauge.h @@ -1,35 +1,35 @@ -/** - * @file NexPointer.h - * - * API of NexPointer. - * - * @author Wu Pengfei (email:) - * @date 2015/7/10 - * @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 __NEXPOINTER_H__ -#define __NEXPOINTER_H__ -#ifdef __cplusplus -#include "NexTouch.h" - -/** - * NexPointer,subclass of NexTouch,provides simple methods to control pointer component. - * - */ -class NexPointer: public NexTouch -{ -public: /* methods */ - NexPointer(NexPid pid, NexCid cid, char *name); - - bool getValue(uint32_t *number); - bool setValue(uint32_t number); -}; - -#endif /* #ifdef __cplusplus */ -#endif /* #ifndef __NEXPOINTER_H__ */ +/** + * @file NexGauge.h + * + * API of NexGauge. + * + * @author Wu Pengfei (email:) + * @date 2015/7/10 + * @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 __NEXGAUGE_H__ +#define __NEXGAUGE_H__ +#ifdef __cplusplus +#include "NexTouch.h" + +/** + * NexGauge,subclass of NexTouch,provides simple methods to control gauge component. + * + */ +class NexGauge: public NexTouch +{ +public: /* methods */ + NexGauge(NexPid pid, NexCid cid, char *name); + + bool getValue(uint32_t *number); + bool setValue(uint32_t number); +}; + +#endif /* #ifdef __cplusplus */ +#endif /* #ifndef __NEXGAUGE_H__ */ diff --git a/NexWaveform.h b/NexWaveform.h index 61ad9f9..7d3a87b 100644 --- a/NexWaveform.h +++ b/NexWaveform.h @@ -13,8 +13,8 @@ * the License, or (at your option) any later version. */ -#ifndef __NEXPOINTER_H__ -#define __NEXPOINTER_H__ +#ifndef __NEXWAVEFORM_H__ +#define __NEXWAVEFORM_H__ #ifdef __cplusplus #include "NexTouch.h" @@ -30,4 +30,4 @@ public: /* methods */ }; #endif /* #ifdef __cplusplus */ -#endif /* #ifndef __NEXPOINTER_H__ */ +#endif /* #ifndef __NEXWAVEFORM_H__ */ diff --git a/examples/CompPointer/CompPointer.HMI b/examples/CompGauge/CompGauge.HMI similarity index 100% rename from examples/CompPointer/CompPointer.HMI rename to examples/CompGauge/CompGauge.HMI diff --git a/examples/CompPointer/CompPointer.ino b/examples/CompGauge/CompGauge.ino similarity index 85% rename from examples/CompPointer/CompPointer.ino rename to examples/CompGauge/CompGauge.ino index e68e827..efe6798 100644 --- a/examples/CompPointer/CompPointer.ino +++ b/examples/CompGauge/CompGauge.ino @@ -1,74 +1,74 @@ -/** - * @example CompPointer.ino - * - * @par Show how to use API of class NexPointer. - * - * @author Wu Pengfei (email:) - * @date 2015/7/10 - * @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 "NexPointer.h" -#include "NexButton.h" - -NexPointer pointer = NexPointer(0, 1, "pointer"); -NexButton btn_up = NexButton(0, 2, "btn_up"); -NexButton btn_down = NexButton(0, 3, "btn_down"); - -NexTouch *nex_listen_list[] = -{ - &btn_up, - &btn_down, - NULL -}; - -void buttonUpPopCallback(void *ptr) -{ - uint32_t number = 0; - dbSerialPrintln("buttonUpPopCallback"); - - pointer.getValue(&number); - - number += 5; - if (number >= 360) - { - number = 0; - } - - pointer.setValue(number); -} -void buttonDownPopCallback(void *ptr) -{ - uint32_t number = 0; - dbSerialPrintln("buttonDownPopCallback"); - - pointer.getValue(&number); - - if (number >= 5) - { - number -= 5; - } - - pointer.setValue(number); -} - - - -void setup(void) -{ - nexInit(); - btn_up.attachPop(buttonUpPopCallback); - btn_down.attachPop(buttonDownPopCallback); - dbSerialPrintln("setup done"); -} - -void loop(void) -{ - nexLoop(nex_listen_list); -} - +/** + * @example CompGauge.ino + * + * @par Show how to use API of class NexGauge. + * + * @author Wu Pengfei (email:) + * @date 2015/7/10 + * @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 "NexGauge.h" +#include "NexButton.h" + +NexGauge pointer = NexGauge(0, 1, "pointer"); +NexButton btn_up = NexButton(0, 2, "btn_up"); +NexButton btn_down = NexButton(0, 3, "btn_down"); + +NexTouch *nex_listen_list[] = +{ + &btn_up, + &btn_down, + NULL +}; + +void buttonUpPopCallback(void *ptr) +{ + uint32_t number = 0; + dbSerialPrintln("buttonUpPopCallback"); + + pointer.getValue(&number); + + number += 5; + if (number >= 360) + { + number = 0; + } + + pointer.setValue(number); +} +void buttonDownPopCallback(void *ptr) +{ + uint32_t number = 0; + dbSerialPrintln("buttonDownPopCallback"); + + pointer.getValue(&number); + + if (number >= 5) + { + number -= 5; + } + + pointer.setValue(number); +} + + + +void setup(void) +{ + nexInit(); + btn_up.attachPop(buttonUpPopCallback); + btn_down.attachPop(buttonDownPopCallback); + dbSerialPrintln("setup done"); +} + +void loop(void) +{ + nexLoop(nex_listen_list); +} + diff --git a/examples/CompPointer/CompPointer.tft b/examples/CompGauge/CompGauge.tft similarity index 100% rename from examples/CompPointer/CompPointer.tft rename to examples/CompGauge/CompGauge.tft