Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Append text fonction for NexText object #93

Open
wants to merge 36 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
6324145
Enhanced and corrected Nextion library version for Arduino/Esp8266/No…
jyberg Feb 25, 2019
3ac82dc
Update readme.md
jyberg Feb 26, 2019
8f87689
Update readme.md
jyberg Feb 26, 2019
2f51c75
Update readme.md
jyberg Feb 26, 2019
a631087
Update readme.md
jyberg Feb 26, 2019
0b705cb
Update readme.md
jyberg Feb 26, 2019
7a5b54c
Small changes in examples
jyberg Feb 27, 2019
4b04013
Update NexConfig.h
jyberg Feb 28, 2019
5cc5a35
Update readme.md
jyberg Feb 28, 2019
e1f4e24
Waveform corrections & NexObject enhancement
jyberg Mar 4, 2019
4bdb617
Update readme.md
jyberg Mar 4, 2019
464dc9e
updates/correction to the Waveform component, nextInit baud rate support
jyberg Mar 16, 2019
c9795cc
Update readme.md
jyberg Mar 16, 2019
bc36c85
Update readme.md
jyberg Mar 19, 2019
a73e625
#include <functional> corrected (moded from cpp file to .h file)
jyberg Mar 19, 2019
a9ebfec
Merge branch 'master' of https://github.com/jyberg/ITEADLIB_Arduino_N…
jyberg Mar 19, 2019
9d7fc16
C++ STD library usage changed optional
jyberg Mar 20, 2019
cadeec9
Update readme.md
jyberg Mar 20, 2019
83bd597
communication stability bug corrections
jyberg Jun 12, 2019
bcf75c6
Merge branch 'master' of https://github.com/jyberg/ITEADLIB_Arduino_N…
jyberg Jun 12, 2019
285cea4
Update readme.md
jyberg Jun 12, 2019
4411135
Update readme.md
jyberg Aug 5, 2019
c34cf4e
updated to latest nextion return/error code documentation
jyberg Aug 14, 2019
922eb41
Update readme.md
jyberg Dec 18, 2019
1d8768f
Issue #2 corrected, readBytes re-implemented
jyberg Jan 18, 2020
902bc46
SoftwareSerial include in NexUpload.cpp #7
jyberg Jan 25, 2020
1f670a7
version updated
jyberg Jan 25, 2020
deb21b2
getValue and getText doesn't work #9 corrected
jyberg Apr 5, 2020
8e73e5a
Update readme.md
jyberg Apr 5, 2020
eefd5ac
Update readme.md
jyberg Apr 5, 2020
abfa323
ReadBytes function corrected
jyberg Apr 12, 2020
34f816d
Update version.txt
jyberg May 3, 2020
39a1924
Update release_notes.md
jyberg May 3, 2020
3e7ed4e
Update release_notes.md
jyberg May 3, 2020
2e38482
some git problems let's re-try
jyberg May 3, 2020
95aba3c
add appendText fuction to NexText object
VincentFrangi May 12, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 51 additions & 38 deletions NexButton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
*
* @author Wu Pengfei (email:<[email protected]>)
* @date 2015/8/13
* @author Jyrki Berg 2/17/2019 (https://github.com/jyberg)
*
* @copyright
* Copyright (C) 2014-2015 ITEAD Intelligent Systems Co., Ltd. \n
* This program is free software; you can redistribute it and/or
Expand All @@ -15,16 +17,27 @@

#include "NexButton.h"

NexButton::NexButton(uint8_t pid, uint8_t cid, const char *name)
:NexTouch(pid, cid, name)
NexButton::NexButton(uint8_t pid, uint8_t cid, const char *name, const NexObject* page)
:NexTouch(pid, cid, name, page)
{
}

uint16_t NexButton::getText(char *buffer, uint16_t len)
bool NexButton::getText(String &str)
{
String cmd;
cmd += "get ";
cmd += getObjName();
getObjGlobalPageName(cmd);
cmd += ".txt";
sendCommand(cmd.c_str());
return recvRetString(str);
}


bool NexButton::getText(char *buffer, uint16_t &len)
{
String cmd;
cmd += "get ";
getObjGlobalPageName(cmd);
cmd += ".txt";
sendCommand(cmd.c_str());
return recvRetString(buffer,len);
Expand All @@ -33,7 +46,7 @@ uint16_t NexButton::getText(char *buffer, uint16_t len)
bool NexButton::setText(const char *buffer)
{
String cmd;
cmd += getObjName();
getObjGlobalPageName(cmd);
cmd += ".txt=\"";
cmd += buffer;
cmd += "\"";
Expand All @@ -46,7 +59,7 @@ uint32_t NexButton::Get_background_color_bco(uint32_t *number)
{
String cmd;
cmd += "get ";
cmd += getObjName();
getObjGlobalPageName(cmd);
cmd += ".bco";
sendCommand(cmd.c_str());
return recvRetNumber(number);
Expand All @@ -58,14 +71,14 @@ bool NexButton::Set_background_color_bco(uint32_t number)
String cmd;

utoa(number, buf, 10);
cmd += getObjName();
getObjGlobalPageName(cmd);
cmd += ".bco=";
cmd += buf;
sendCommand(cmd.c_str());

cmd="";
cmd += "ref ";
cmd += getObjName();
getObjGlobalPageName(cmd);
sendCommand(cmd.c_str());
return recvRetCommandFinished();
}
Expand All @@ -74,7 +87,7 @@ uint32_t NexButton::Get_press_background_color_bco2(uint32_t *number)
{
String cmd;
cmd += "get ";
cmd += getObjName();
getObjGlobalPageName(cmd);
cmd += ".bco2";
sendCommand(cmd.c_str());
return recvRetNumber(number);
Expand All @@ -86,14 +99,14 @@ bool NexButton::Set_press_background_color_bco2(uint32_t number)
String cmd;

utoa(number, buf, 10);
cmd += getObjName();
getObjGlobalPageName(cmd);
cmd += ".bco2=";
cmd += buf;
sendCommand(cmd.c_str());

cmd="";
cmd += "ref ";
cmd += getObjName();
getObjGlobalPageName(cmd);
sendCommand(cmd.c_str());
return recvRetCommandFinished();
}
Expand All @@ -102,7 +115,7 @@ uint32_t NexButton::Get_font_color_pco(uint32_t *number)
{
String cmd;
cmd += "get ";
cmd += getObjName();
getObjGlobalPageName(cmd);
cmd += ".pco";
sendCommand(cmd.c_str());
return recvRetNumber(number);
Expand All @@ -114,14 +127,14 @@ bool NexButton::Set_font_color_pco(uint32_t number)
String cmd;

utoa(number, buf, 10);
cmd += getObjName();
getObjGlobalPageName(cmd);
cmd += ".pco=";
cmd += buf;
sendCommand(cmd.c_str());

cmd = "";
cmd += "ref ";
cmd += getObjName();
getObjGlobalPageName(cmd);
sendCommand(cmd.c_str());
return recvRetCommandFinished();
}
Expand All @@ -130,7 +143,7 @@ uint32_t NexButton::Get_press_font_color_pco2(uint32_t *number)
{
String cmd;
cmd += "get ";
cmd += getObjName();
getObjGlobalPageName(cmd);
cmd += ".pco2";
sendCommand(cmd.c_str());
return recvRetNumber(number);
Expand All @@ -142,14 +155,14 @@ bool NexButton::Set_press_font_color_pco2(uint32_t number)
String cmd;

utoa(number, buf, 10);
cmd += getObjName();
getObjGlobalPageName(cmd);
cmd += ".pco2=";
cmd += buf;
sendCommand(cmd.c_str());

cmd = "";
cmd += "ref ";
cmd += getObjName();
getObjGlobalPageName(cmd);
sendCommand(cmd.c_str());
return recvRetCommandFinished();
}
Expand All @@ -158,7 +171,7 @@ uint32_t NexButton::Get_place_xcen(uint32_t *number)
{
String cmd;
cmd += "get ";
cmd += getObjName();
getObjGlobalPageName(cmd);
cmd += ".xcen";
sendCommand(cmd.c_str());
return recvRetNumber(number);
Expand All @@ -170,14 +183,14 @@ bool NexButton::Set_place_xcen(uint32_t number)
String cmd;

utoa(number, buf, 10);
cmd += getObjName();
getObjGlobalPageName(cmd);
cmd += ".xcen=";
cmd += buf;
sendCommand(cmd.c_str());

cmd = "";
cmd += "ref ";
cmd += getObjName();
getObjGlobalPageName(cmd);
sendCommand(cmd.c_str());
return recvRetCommandFinished();
}
Expand All @@ -186,7 +199,7 @@ uint32_t NexButton::Get_place_ycen(uint32_t *number)
{
String cmd;
cmd += "get ";
cmd += getObjName();
getObjGlobalPageName(cmd);
cmd += ".ycen";
sendCommand(cmd.c_str());
return recvRetNumber(number);
Expand All @@ -198,14 +211,14 @@ bool NexButton::Set_place_ycen(uint32_t number)
String cmd;

utoa(number, buf, 10);
cmd += getObjName();
getObjGlobalPageName(cmd);
cmd += ".ycen=";
cmd += buf;
sendCommand(cmd.c_str());

cmd = "";
cmd += "ref ";
cmd += getObjName();
getObjGlobalPageName(cmd);
sendCommand(cmd.c_str());
return recvRetCommandFinished();
}
Expand All @@ -214,7 +227,7 @@ uint32_t NexButton::getFont(uint32_t *number)
{
String cmd;
cmd += "get ";
cmd += getObjName();
getObjGlobalPageName(cmd);
cmd += ".font";
sendCommand(cmd.c_str());
return recvRetNumber(number);
Expand All @@ -226,14 +239,14 @@ bool NexButton::setFont(uint32_t number)
String cmd;

utoa(number, buf, 10);
cmd += getObjName();
getObjGlobalPageName(cmd);
cmd += ".font=";
cmd += buf;
sendCommand(cmd.c_str());

cmd = "";
cmd += "ref ";
cmd += getObjName();
getObjGlobalPageName(cmd);
sendCommand(cmd.c_str());
return recvRetCommandFinished();
}
Expand All @@ -242,7 +255,7 @@ uint32_t NexButton::Get_background_cropi_picc(uint32_t *number)
{
String cmd;
cmd += "get ";
cmd += getObjName();
getObjGlobalPageName(cmd);
cmd += ".picc";
sendCommand(cmd.c_str());
return recvRetNumber(number);
Expand All @@ -254,14 +267,14 @@ bool NexButton::Set_background_crop_picc(uint32_t number)
String cmd;

utoa(number, buf, 10);
cmd += getObjName();
getObjGlobalPageName(cmd);
cmd += ".picc=";
cmd += buf;
sendCommand(cmd.c_str());

cmd = "";
cmd += "ref ";
cmd += getObjName();
getObjGlobalPageName(cmd);
sendCommand(cmd.c_str());
return recvRetCommandFinished();
}
Expand All @@ -270,7 +283,7 @@ uint32_t NexButton::Get_press_background_crop_picc2(uint32_t *number)
{
String cmd;
cmd += "get ";
cmd += getObjName();
getObjGlobalPageName(cmd);
cmd += ".picc2";
sendCommand(cmd.c_str());
return recvRetNumber(number);
Expand All @@ -282,14 +295,14 @@ bool NexButton::Set_press_background_crop_picc2(uint32_t number)
String cmd;

utoa(number, buf, 10);
cmd += getObjName();
getObjGlobalPageName(cmd);
cmd += ".picc2=";
cmd += buf;
sendCommand(cmd.c_str());

cmd = "";
cmd += "ref ";
cmd += getObjName();
getObjGlobalPageName(cmd);
sendCommand(cmd.c_str());
return recvRetCommandFinished();
}
Expand All @@ -298,7 +311,7 @@ uint32_t NexButton::Get_background_image_pic(uint32_t *number)
{
String cmd;
cmd += "get ";
cmd += getObjName();
getObjGlobalPageName(cmd);
cmd += ".pic";
sendCommand(cmd.c_str());
return recvRetNumber(number);
Expand All @@ -310,14 +323,14 @@ bool NexButton::Set_background_image_pic(uint32_t number)
String cmd;

utoa(number, buf, 10);
cmd += getObjName();
getObjGlobalPageName(cmd);
cmd += ".pic=";
cmd += buf;
sendCommand(cmd.c_str());

cmd = "";
cmd += "ref ";
cmd += getObjName();
getObjGlobalPageName(cmd);
sendCommand(cmd.c_str());
return recvRetCommandFinished();
}
Expand All @@ -326,7 +339,7 @@ uint32_t NexButton::Get_press_background_image_pic2(uint32_t *number)
{
String cmd;
cmd += "get ";
cmd += getObjName();
getObjGlobalPageName(cmd);
cmd += ".pic2";
sendCommand(cmd.c_str());
return recvRetNumber(number);
Expand All @@ -338,14 +351,14 @@ bool NexButton::Set_press_background_image_pic2(uint32_t number)
String cmd;

utoa(number, buf, 10);
cmd += getObjName();
getObjGlobalPageName(cmd);
cmd += ".pic2=";
cmd += buf;
sendCommand(cmd.c_str());

cmd = "";
cmd += "ref ";
cmd += getObjName();
getObjGlobalPageName(cmd);
sendCommand(cmd.c_str());
return recvRetCommandFinished();
}
25 changes: 20 additions & 5 deletions NexButton.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*
* @author Wu Pengfei (email:<[email protected]>)
* @date 2015/8/13
* @author Jyrki Berg 2/17/2019 (https://github.com/jyberg)
*
* @copyright
* Copyright (C) 2014-2015 ITEAD Intelligent Systems Co., Ltd. \n
Expand Down Expand Up @@ -37,18 +38,32 @@ class NexButton: public NexTouch
public: /* methods */

/**
* @copydoc NexObject::NexObject(uint8_t pid, uint8_t cid, const char *name);
* @copydoc NexObject::NexObject(uint8_t pid, uint8_t cid, const char *name, const NexObject* page=nullptr);
*/
NexButton(uint8_t pid, uint8_t cid, const char *name);
NexButton(uint8_t pid, uint8_t cid, const char *name, const NexObject* page=nullptr);

/*
* Get text attribute of component.
*
* @param str - String storing text returned.
*
* @retval true - success.
* @retval false - failed.
*
*/
bool getText(String &str);

/**
* Get text attribute of component.
*
* @param buffer - buffer storing text returned.
* @param len - length of buffer.
* @return The real length of text returned.
* @param len - in buffer len / out saved string len excluding null char.
*
* @retval true - success.
* @retval false - failed.
*/
uint16_t getText(char *buffer, uint16_t len);
bool getText(char *buffer, uint16_t &len);


/**
* Set text attribute of component.
Expand Down
Loading