Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
MarlinKimbra
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
machinery
MarlinKimbra
Commits
7068e281
Commit
7068e281
authored
Nov 11, 2015
by
MagoKimbra
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update Nextion library
parent
e7267fe5
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
234 additions
and
1 deletion
+234
-1
NexHardware.cpp
Arduino/libraries/Nextion/NexHardware.cpp
+125
-1
NexHardware.h
Arduino/libraries/Nextion/NexHardware.h
+5
-0
NexNumber.cpp
Arduino/libraries/Nextion/NexNumber.cpp
+43
-0
NexNumber.h
Arduino/libraries/Nextion/NexNumber.h
+60
-0
Nextion.h
Arduino/libraries/Nextion/Nextion.h
+1
-0
No files found.
Arduino/libraries/Nextion/NexHardware.cpp
View file @
7068e281
...
...
@@ -23,6 +23,7 @@
#define NEX_RET_CURRENT_PAGE_ID_HEAD (0x66)
#define NEX_RET_STRING_HEAD (0x70)
#define NEX_RET_NUMBER_HEAD (0x71)
#define NEX_RET_VALUE_HEAD (0x72)
#define NEX_RET_INVALID_CMD (0x00)
#define NEX_RET_INVALID_COMPONENT_ID (0x02)
#define NEX_RET_INVALID_PAGE_ID (0x03)
...
...
@@ -255,7 +256,7 @@ bool nexInit(void)
void
nexLoop
(
NexTouch
*
nex_listen_list
[])
{
static
uint8_t
__buffer
[
1
0
];
static
uint8_t
__buffer
[
2
0
];
uint16_t
i
;
uint8_t
c
;
...
...
@@ -286,3 +287,126 @@ void nexLoop(NexTouch *nex_listen_list[])
}
}
/**
* Return current page id.
*
* @param pageId - output parameter,to save page id.
*
* @retval true - success.
* @retval false - failed.
*/
bool
sendCurrentPageId
(
uint8_t
*
pageId
)
{
bool
ret
=
false
;
uint8_t
temp
[
5
]
=
{
0
};
if
(
!
pageId
)
{
goto
__return
;
}
sendCommand
(
"sendme"
);
delay
(
50
);
nexSerial
.
setTimeout
(
100
);
if
(
sizeof
(
temp
)
!=
nexSerial
.
readBytes
((
char
*
)
temp
,
sizeof
(
temp
)))
{
goto
__return
;
}
if
(
temp
[
0
]
==
NEX_RET_CURRENT_PAGE_ID_HEAD
&&
temp
[
2
]
==
0xFF
&&
temp
[
3
]
==
0xFF
&&
temp
[
4
]
==
0xFF
)
{
*
pageId
=
temp
[
1
];
ret
=
true
;
}
__return:
if
(
ret
)
{
dbSerialPrint
(
"recvPageId :"
);
dbSerialPrintln
(
*
pageId
);
}
else
{
dbSerialPrintln
(
"recvPageId err"
);
}
return
ret
;
}
/**
* Set current backlight brightness value.
*
* @param dimValue - current backlight brightness value.
*
* @retval true - success.
* @retval false - failed.
*/
bool
setCurrentBrightness
(
uint8_t
dimValue
)
{
bool
ret
=
false
;
char
buf
[
10
]
=
{
0
};
String
cmd
;
utoa
(
dimValue
,
buf
,
10
);
cmd
+=
"dim="
;
cmd
+=
buf
;
sendCommand
(
cmd
.
c_str
());
delay
(
10
);
if
(
recvRetCommandFinished
())
{
dbSerialPrint
(
"setCurrentBrightness[ "
);
dbSerialPrint
(
dimValue
);
dbSerialPrintln
(
"]ok "
);
ret
=
true
;
}
else
{
dbSerialPrintln
(
"setCurrentBrightness err "
);
}
return
ret
;
}
/**
* Set default baudrate.
*
* @param defaultBaudrate - default baudrate,it supports 2400,4800,9600,19200,38400,57600,115200.
*
* @retval true - success.
* @retval false - failed.
*/
bool
setDefaultBaudrate
(
uint32_t
defaultBaudrate
)
{
bool
ret
=
false
;
char
buf
[
10
]
=
{
0
};
String
cmd
;
utoa
(
defaultBaudrate
,
buf
,
10
);
cmd
+=
"bauds="
;
cmd
+=
buf
;
sendCommand
(
cmd
.
c_str
());
delay
(
10
);
if
(
recvRetCommandFinished
())
{
dbSerialPrintln
(
"setDefaultBaudrate ok "
);
ret
=
true
;
}
else
{
dbSerialPrintln
(
"setDefaultBaudrate err "
);
}
return
ret
;
}
void
sendRefreshAll
(
void
)
{
sendCommand
(
"ref 0"
);
}
\ No newline at end of file
Arduino/libraries/Nextion/NexHardware.h
View file @
7068e281
...
...
@@ -52,4 +52,9 @@ uint16_t recvRetString(char *buffer, uint16_t len, uint32_t timeout = 100);
void
sendCommand
(
const
char
*
cmd
);
bool
recvRetCommandFinished
(
uint32_t
timeout
=
100
);
bool
sendCurrentPageId
(
uint8_t
*
pageId
);
bool
setCurrentBrightness
(
uint8_t
dimValue
);
bool
setDefaultBaudrate
(
uint32_t
baudrate
);
void
sendRefreshAll
(
void
);
#endif
/* #ifndef __NEXHARDWARE_H__ */
Arduino/libraries/Nextion/NexNumber.cpp
0 → 100644
View file @
7068e281
/**
* @file NexNumber.cpp
*
* The implementation of class NexNumber.
*
* @author huang xianming (email:<xianming.huang@itead.cc>)
* @date 2015/8/13
* @copyright
* Copyright (C) 2014-2015 ITEAD Intelligent Systems Co., Ltd.
* 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 "NexNumber.h"
NexNumber
::
NexNumber
(
uint8_t
pid
,
uint8_t
cid
,
const
char
*
name
)
:
NexTouch
(
pid
,
cid
,
name
)
{
}
bool
NexNumber
::
getValue
(
uint32_t
*
number
)
{
String
cmd
=
String
(
"get "
);
cmd
+=
getObjName
();
cmd
+=
".val"
;
sendCommand
(
cmd
.
c_str
());
return
recvRetNumber
(
number
);
}
bool
NexNumber
::
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
();
}
Arduino/libraries/Nextion/NexNumber.h
0 → 100644
View file @
7068e281
/**
* @file NexNumber.h
*
* The definition of class NexNumber.
*
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
* @date 2015/8/13
*
* @copyright
* Copyright (C) 2014-2015 ITEAD Intelligent Systems Co., Ltd.
* 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 __NEXNUMBER_H__
#define __NEXNUMBER_H__
#include "NexTouch.h"
#include "NexHardware.h"
/**
* @addtogroup Component
* @{
*/
/**
* NexTNumber component.
*/
class
NexNumber
:
public
NexTouch
{
public
:
/* methods */
/**
* @copydoc NexObject::NexObject(uint8_t pid, uint8_t cid, const char *name);
*/
NexNumber
(
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 __NEXNUMBER_H__ */
Arduino/libraries/Nextion/Nextion.h
View file @
7068e281
...
...
@@ -33,6 +33,7 @@
#include "NexText.h"
#include "NexWaveform.h"
#include "NexTimer.h"
#include "NexNumber.h"
#include "NexVar.h"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment