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
3e7df4a6
Commit
3e7df4a6
authored
Sep 28, 2015
by
MagoKimbra
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update Nextion now use library
parent
b0bc6afa
Changes
41
Show whitespace changes
Inline
Side-by-side
Showing
41 changed files
with
1020 additions
and
2914 deletions
+1020
-2914
NexConfig.h
Arduino/libraries/Nextion/NexConfig.h
+0
-6
NexHardware.cpp
Arduino/libraries/Nextion/NexHardware.cpp
+23
-2
Nextion.h
Arduino/libraries/Nextion/Nextion.h
+2
-2
Configuration_Feature.h
MarlinKimbra/Configuration_Feature.h
+1
-0
MarlinKimbra.ino
MarlinKimbra/MarlinKimbra.ino
+3
-0
Marlin_main.cpp
MarlinKimbra/Marlin_main.cpp
+1
-0
NexButton.cpp
MarlinKimbra/NexButton.cpp
+0
-42
NexButton.h
MarlinKimbra/NexButton.h
+0
-66
NexConfig.h
MarlinKimbra/NexConfig.h
+0
-60
NexHardware.cpp
MarlinKimbra/NexHardware.cpp
+0
-267
NexHardware.h
MarlinKimbra/NexHardware.h
+0
-55
NexHotspot.cpp
MarlinKimbra/NexHotspot.cpp
+0
-22
NexHotspot.h
MarlinKimbra/NexHotspot.h
+0
-43
NexObject.cpp
MarlinKimbra/NexObject.cpp
+0
-58
NexObject.h
MarlinKimbra/NexObject.h
+0
-84
NexPage.cpp
MarlinKimbra/NexPage.cpp
+0
-38
NexPage.h
MarlinKimbra/NexPage.h
+0
-50
NexPicture.cpp
MarlinKimbra/NexPicture.cpp
+0
-45
NexPicture.h
MarlinKimbra/NexPicture.h
+0
-63
NexProgressBar.cpp
MarlinKimbra/NexProgressBar.cpp
+0
-45
NexProgressBar.h
MarlinKimbra/NexProgressBar.h
+0
-63
NexSlider.cpp
MarlinKimbra/NexSlider.cpp
+0
-71
NexSlider.h
MarlinKimbra/NexSlider.h
+0
-83
NexText.cpp
MarlinKimbra/NexText.cpp
+0
-55
NexText.h
MarlinKimbra/NexText.h
+0
-61
NexTimer.cpp
MarlinKimbra/NexTimer.cpp
+0
-86
NexTimer.h
MarlinKimbra/NexTimer.h
+0
-105
NexTouch.cpp
MarlinKimbra/NexTouch.cpp
+0
-95
NexTouch.h
MarlinKimbra/NexTouch.h
+0
-116
NexVar.cpp
MarlinKimbra/NexVar.cpp
+0
-64
NexVar.h
MarlinKimbra/NexVar.h
+0
-80
NexWaveform.cpp
MarlinKimbra/NexWaveform.cpp
+0
-36
NexWaveform.h
MarlinKimbra/NexWaveform.h
+0
-53
Nextion.h
MarlinKimbra/Nextion.h
+0
-39
cardreader.cpp
MarlinKimbra/cardreader.cpp
+1
-0
nextion_lcd.cpp
MarlinKimbra/nextion_lcd.cpp
+910
-0
nextion_lcd.h
MarlinKimbra/nextion_lcd.h
+55
-0
stepper.cpp
MarlinKimbra/stepper.cpp
+1
-0
temperature.cpp
MarlinKimbra/temperature.cpp
+1
-0
ultralcd.cpp
MarlinKimbra/ultralcd.cpp
+0
-906
ultralcd.h
MarlinKimbra/ultralcd.h
+22
-53
No files found.
Arduino/libraries/Nextion/NexConfig.h
View file @
3e7df4a6
...
...
@@ -20,12 +20,6 @@
* @{
*/
/**
* Nextion Baudrate - default 9600
* 2400 - 4800 - 9600 - 19200 - 38400 - 57600 - 115200
*/
#define NEXTION_BAUDRATE 9600
/**
* Define DEBUG_SERIAL_ENABLE to enable debug serial.
* Comment it to disable debug serial.
...
...
Arduino/libraries/Nextion/NexHardware.cpp
View file @
3e7df4a6
...
...
@@ -222,14 +222,35 @@ bool nexInit(void)
bool
ret1
=
false
;
bool
ret2
=
false
;
// Try default baudrate
dbSerialBegin
(
9600
);
nexSerial
.
begin
(
NEXTION_BAUDRATE
);
nexSerial
.
begin
(
9600
);
sendCommand
(
""
);
sendCommand
(
"bkcmd=1"
);
ret1
=
recvRetCommandFinished
();
sendCommand
(
"page 0"
);
ret2
=
recvRetCommandFinished
();
// If baudrate is 9600 set to 57600 and reconnect
if
(
ret1
&&
ret2
)
{
sendCommand
(
"baud=57600"
);
nexSerial
.
end
();
delay
(
1000
);
nexSerial
.
begin
(
57600
);
return
ret1
&&
ret2
;
// Else try to 57600 baudrate
}
else
{
nexSerial
.
end
();
delay
(
1000
);
nexSerial
.
begin
(
57600
);
sendCommand
(
""
);
sendCommand
(
"bkcmd=1"
);
ret1
=
recvRetCommandFinished
();
sendCommand
(
"page 0"
);
ret2
=
recvRetCommandFinished
();
return
ret1
&&
ret2
;
}
}
void
nexLoop
(
NexTouch
*
nex_listen_list
[])
...
...
Arduino/libraries/Nextion/Nextion.h
View file @
3e7df4a6
...
...
@@ -23,8 +23,8 @@
#include "NexHardware.h"
#include "NexButton.h"
//
#include "NexCrop.h"
//
#include "NexGauge.h"
#include "NexCrop.h"
#include "NexGauge.h"
#include "NexHotspot.h"
#include "NexPage.h"
#include "NexPicture.h"
...
...
MarlinKimbra/Configuration_Feature.h
View file @
3e7df4a6
...
...
@@ -1112,6 +1112,7 @@
// #define MINIPANEL
// Nextion HMI panel
// REMEMBER TO INSTALL Nextion library in your ARDUINO library folder. You can find it in Arduino\libraries\
//#define NEXTION
// I2C Panels
...
...
MarlinKimbra/MarlinKimbra.ino
View file @
3e7df4a6
...
...
@@ -48,6 +48,9 @@
#include <LiquidCrystal.h> // library for character LCD
#endif
#endif
#if ENABLED(NEXTION)
#include <Nextion.h>
#endif
#if HAS(DIGIPOTSS)
#include <SPI.h>
#endif
MarlinKimbra/Marlin_main.cpp
View file @
3e7df4a6
...
...
@@ -31,6 +31,7 @@
#include "Marlin_main.h"
#include "ultralcd.h"
#include "nextion_lcd.h"
#include "base.h"
#if ENABLED(AUTO_BED_LEVELING_FEATURE)
#include "vector_3.h"
...
...
MarlinKimbra/NexButton.cpp
deleted
100644 → 0
View file @
b0bc6afa
/**
* @file NexButton.cpp
*
* The implementation of class NexButton.
*
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
* @date 2015/8/13
* @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 "NexButton.h"
NexButton
::
NexButton
(
uint8_t
pid
,
uint8_t
cid
,
const
char
*
name
)
:
NexTouch
(
pid
,
cid
,
name
)
{
}
uint16_t
NexButton
::
getText
(
char
*
buffer
,
uint16_t
len
)
{
String
cmd
;
cmd
+=
"get "
;
cmd
+=
getObjName
();
cmd
+=
".txt"
;
sendCommand
(
cmd
.
c_str
());
return
recvRetString
(
buffer
,
len
);
}
bool
NexButton
::
setText
(
const
char
*
buffer
)
{
String
cmd
;
cmd
+=
getObjName
();
cmd
+=
".txt=
\"
"
;
cmd
+=
buffer
;
cmd
+=
"
\"
"
;
sendCommand
(
cmd
.
c_str
());
return
recvRetCommandFinished
();
}
MarlinKimbra/NexButton.h
deleted
100644 → 0
View file @
b0bc6afa
/**
* @file NexButton.h
*
* The definition of class NexButton.
*
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
* @date 2015/8/13
*
* @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 __NEXBUTTON_H__
#define __NEXBUTTON_H__
#include "NexTouch.h"
#include "NexHardware.h"
/**
* @addtogroup Component
* @{
*/
/**
* NexButton 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
NexButton
:
public
NexTouch
{
public
:
/* methods */
/**
* @copydoc NexObject::NexObject(uint8_t pid, uint8_t cid, const char *name);
*/
NexButton
(
uint8_t
pid
,
uint8_t
cid
,
const
char
*
name
);
/**
* Get text attribute of component.
*
* @param buffer - buffer storing text returned.
* @param len - length of buffer.
* @return The real length of text returned.
*/
uint16_t
getText
(
char
*
buffer
,
uint16_t
len
);
/**
* Set text attribute of component.
*
* @param buffer - text buffer terminated with '\0'.
* @return true if success, false for failure.
*/
bool
setText
(
const
char
*
buffer
);
};
/**
* @}
*/
#endif
/* #ifndef __NEXBUTTON_H__ */
MarlinKimbra/NexConfig.h
deleted
100644 → 0
View file @
b0bc6afa
/**
* @file NexConfig.h
*
* Options for user can be found here.
*
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
* @date 2015/8/13
* @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 __NEXCONFIG_H__
#define __NEXCONFIG_H__
/**
* @addtogroup Configuration
* @{
*/
/**
* Nextion Baudrate - default 9600
* 2400 - 4800 - 9600 - 19200 - 38400 - 57600 - 115200
*/
#define NEXTION_BAUDRATE 9600
/**
* Define DEBUG_SERIAL_ENABLE to enable debug serial.
* Comment it to disable debug serial.
*/
//#define DEBUG_SERIAL_ENABLE
/**
* Define dbSerial for the output of debug messages.
*/
#define dbSerial Serial
/**
* Define nexSerial for communicate with Nextion touch panel.
*/
#define nexSerial Serial1
#ifdef DEBUG_SERIAL_ENABLE
#define dbSerialPrint(a) dbSerial.print(a)
#define dbSerialPrintln(a) dbSerial.println(a)
#define dbSerialBegin(a) dbSerial.begin(a)
#else
#define dbSerialPrint(a) do{}while(0)
#define dbSerialPrintln(a) do{}while(0)
#define dbSerialBegin(a) do{}while(0)
#endif
/**
* @}
*/
#endif
/* #ifndef __NEXCONFIG_H__ */
MarlinKimbra/NexHardware.cpp
deleted
100644 → 0
View file @
b0bc6afa
/**
* @file NexHardware.cpp
*
* The implementation of base API for using Nextion.
*
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
* @date 2015/8/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 "NexHardware.h"
#define NEX_RET_CMD_FINISHED (0x01)
#define NEX_RET_EVENT_LAUNCHED (0x88)
#define NEX_RET_EVENT_UPGRADED (0x89)
#define NEX_RET_EVENT_TOUCH_HEAD (0x65)
#define NEX_RET_EVENT_POSITION_HEAD (0x67)
#define NEX_RET_EVENT_SLEEP_POSITION_HEAD (0x68)
#define NEX_RET_CURRENT_PAGE_ID_HEAD (0x66)
#define NEX_RET_STRING_HEAD (0x70)
#define NEX_RET_NUMBER_HEAD (0x71)
#define NEX_RET_INVALID_CMD (0x00)
#define NEX_RET_INVALID_COMPONENT_ID (0x02)
#define NEX_RET_INVALID_PAGE_ID (0x03)
#define NEX_RET_INVALID_PICTURE_ID (0x04)
#define NEX_RET_INVALID_FONT_ID (0x05)
#define NEX_RET_INVALID_BAUD (0x11)
#define NEX_RET_INVALID_VARIABLE (0x1A)
#define NEX_RET_INVALID_OPERATION (0x1B)
/*
* Receive uint32_t data.
*
* @param number - save uint32_t data.
* @param timeout - set timeout time.
*
* @retval true - success.
* @retval false - failed.
*
*/
bool
recvRetNumber
(
uint32_t
*
number
,
uint32_t
timeout
)
{
bool
ret
=
false
;
uint8_t
temp
[
8
]
=
{
0
};
if
(
!
number
)
{
goto
__return
;
}
nexSerial
.
setTimeout
(
timeout
);
if
(
sizeof
(
temp
)
!=
nexSerial
.
readBytes
((
char
*
)
temp
,
sizeof
(
temp
)))
{
goto
__return
;
}
if
(
temp
[
0
]
==
NEX_RET_NUMBER_HEAD
&&
temp
[
5
]
==
0xFF
&&
temp
[
6
]
==
0xFF
&&
temp
[
7
]
==
0xFF
)
{
*
number
=
(
temp
[
4
]
<<
24
)
|
(
temp
[
3
]
<<
16
)
|
(
temp
[
2
]
<<
8
)
|
(
temp
[
1
]);
ret
=
true
;
}
__return:
if
(
ret
)
{
dbSerialPrint
(
"recvRetNumber :"
);
dbSerialPrintln
(
*
number
);
}
else
{
dbSerialPrintln
(
"recvRetNumber err"
);
}
return
ret
;
}
/*
* Receive string data.
*
* @param buffer - save string data.
* @param len - string buffer length.
* @param timeout - set timeout time.
*
* @return the length of string buffer.
*
*/
uint16_t
recvRetString
(
char
*
buffer
,
uint16_t
len
,
uint32_t
timeout
)
{
uint16_t
ret
=
0
;
bool
str_start_flag
=
false
;
uint8_t
cnt_0xff
=
0
;
String
temp
=
String
(
""
);
uint8_t
c
=
0
;
long
start
;
if
(
!
buffer
||
len
==
0
)
{
goto
__return
;
}
start
=
millis
();
while
(
millis
()
-
start
<=
timeout
)
{
while
(
nexSerial
.
available
())
{
c
=
nexSerial
.
read
();
if
(
str_start_flag
)
{
if
(
0xFF
==
c
)
{
cnt_0xff
++
;
if
(
cnt_0xff
>=
3
)
{
break
;
}
}
else
{
temp
+=
(
char
)
c
;
}
}
else
if
(
NEX_RET_STRING_HEAD
==
c
)
{
str_start_flag
=
true
;
}
}
if
(
cnt_0xff
>=
3
)
{
break
;
}
}
ret
=
temp
.
length
();
ret
=
ret
>
len
?
len
:
ret
;
strncpy
(
buffer
,
temp
.
c_str
(),
ret
);
__return:
dbSerialPrint
(
"recvRetString["
);
dbSerialPrint
(
temp
.
length
());
dbSerialPrint
(
","
);
dbSerialPrint
(
temp
);
dbSerialPrintln
(
"]"
);
return
ret
;
}
/*
* Send command to Nextion.
*
* @param cmd - the string of command.
*/
void
sendCommand
(
const
char
*
cmd
)
{
while
(
nexSerial
.
available
())
{
nexSerial
.
read
();
}
nexSerial
.
print
(
cmd
);
nexSerial
.
write
(
0xFF
);
nexSerial
.
write
(
0xFF
);
nexSerial
.
write
(
0xFF
);
}
/*
* Command is executed successfully.
*
* @param timeout - set timeout time.
*
* @retval true - success.
* @retval false - failed.
*
*/
bool
recvRetCommandFinished
(
uint32_t
timeout
)
{
bool
ret
=
false
;
uint8_t
temp
[
4
]
=
{
0
};
nexSerial
.
setTimeout
(
timeout
);
if
(
sizeof
(
temp
)
!=
nexSerial
.
readBytes
((
char
*
)
temp
,
sizeof
(
temp
)))
{
ret
=
false
;
}
if
(
temp
[
0
]
==
NEX_RET_CMD_FINISHED
&&
temp
[
1
]
==
0xFF
&&
temp
[
2
]
==
0xFF
&&
temp
[
3
]
==
0xFF
)
{
ret
=
true
;
}
if
(
ret
)
{
dbSerialPrintln
(
"recvRetCommandFinished ok"
);
}
else
{
dbSerialPrintln
(
"recvRetCommandFinished err"
);
}
return
ret
;
}
bool
nexInit
(
void
)
{
bool
ret1
=
false
;
bool
ret2
=
false
;
dbSerialBegin
(
9600
);
nexSerial
.
begin
(
NEXTION_BAUDRATE
);
sendCommand
(
""
);
sendCommand
(
"bkcmd=1"
);
ret1
=
recvRetCommandFinished
();
sendCommand
(
"page 0"
);
ret2
=
recvRetCommandFinished
();
return
ret1
&&
ret2
;
}
void
nexLoop
(
NexTouch
*
nex_listen_list
[])
{
static
uint8_t
__buffer
[
10
];
uint16_t
i
;
uint8_t
c
;
while
(
nexSerial
.
available
()
>
0
)
{
delay
(
10
);
c
=
nexSerial
.
read
();
if
(
NEX_RET_EVENT_TOUCH_HEAD
==
c
)
{
if
(
nexSerial
.
available
()
>=
6
)
{
__buffer
[
0
]
=
c
;
for
(
i
=
1
;
i
<
7
;
i
++
)
{
__buffer
[
i
]
=
nexSerial
.
read
();
}
__buffer
[
i
]
=
0x00
;
if
(
0xFF
==
__buffer
[
4
]
&&
0xFF
==
__buffer
[
5
]
&&
0xFF
==
__buffer
[
6
])
{
NexTouch
::
iterate
(
nex_listen_list
,
__buffer
[
1
],
__buffer
[
2
],
(
int32_t
)
__buffer
[
3
]);
}
}
}
}
}
MarlinKimbra/NexHardware.h
deleted
100644 → 0
View file @
b0bc6afa
/**
* @file NexHardware.h
*
* The definition of base API for using Nextion.
*
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
* @date 2015/8/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 __NEXHARDWARE_H__
#define __NEXHARDWARE_H__
#include <Arduino.h>
#include "NexConfig.h"
#include "NexTouch.h"
/**
* @addtogroup CoreAPI
* @{
*/
/**
* Init Nextion.
*
* @return true if success, false for failure.
*/
bool
nexInit
(
void
);
/**
* Listen touch event and calling callbacks attached before.
*
* Supports push and pop at present.
*
* @param nex_listen_list - index to Nextion Components list.
* @return none.
*
* @warning This function must be called repeatedly to response touch events
* from Nextion touch panel. Actually, you should place it in your loop function.
*/
void
nexLoop
(
NexTouch
*
nex_listen_list
[]);
/**
* @}
*/
bool
recvRetNumber
(
uint32_t
*
number
,
uint32_t
timeout
=
100
);
uint16_t
recvRetString
(
char
*
buffer
,
uint16_t
len
,
uint32_t
timeout
=
100
);
void
sendCommand
(
const
char
*
cmd
);
bool
recvRetCommandFinished
(
uint32_t
timeout
=
100
);
#endif
/* #ifndef __NEXHARDWARE_H__ */
MarlinKimbra/NexHotspot.cpp
deleted
100644 → 0
View file @
b0bc6afa
/**
* @file NexHotspot.cpp
*
* The implementation of class NexHotspot.
*
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
* @date 2015/8/13
* @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 "NexHotspot.h"
NexHotspot
::
NexHotspot
(
uint8_t
pid
,
uint8_t
cid
,
const
char
*
name
)
:
NexTouch
(
pid
,
cid
,
name
)
{
}
MarlinKimbra/NexHotspot.h
deleted
100644 → 0
View file @
b0bc6afa
/**
* @file NexHotspot.h
*
* The definition of class NexHotspot.
*
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
* @date 2015/8/13
*
* @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 __NEXHOTSPOT_H__
#define __NEXHOTSPOT_H__
#include "NexTouch.h"
#include "NexHardware.h"
/**
* @addtogroup Component
* @{
*/
/**
* NexHotspot component.
*/
class
NexHotspot
:
public
NexTouch
{
public
:
/* methods */
/**
* @copydoc NexObject::NexObject(uint8_t pid, uint8_t cid, const char *name);
*/
NexHotspot
(
uint8_t
pid
,
uint8_t
cid
,
const
char
*
name
);
};
/**
* @}
*/
#endif
/* #ifndef __NEXHOTSPOT_H__ */
MarlinKimbra/NexObject.cpp
deleted
100644 → 0
View file @
b0bc6afa
/**
* @file NexObject.cpp
*
* The implementation of class NexObject.
*
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
* @date 2015/8/13
* @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 "NexObject.h"
NexObject
::
NexObject
(
uint8_t
pid
,
uint8_t
cid
,
const
char
*
name
)
{
this
->
__pid
=
pid
;
this
->
__cid
=
cid
;
this
->
__name
=
name
;
}
uint8_t
NexObject
::
getObjPid
(
void
)
{
return
__pid
;
}
uint8_t
NexObject
::
getObjCid
(
void
)
{
return
__cid
;
}
const
char
*
NexObject
::
getObjName
(
void
)
{
return
__name
;
}
void
NexObject
::
printObjInfo
(
void
)
{
dbSerialPrint
(
"["
);
dbSerialPrint
((
uint32_t
)
this
);
dbSerialPrint
(
":"
);
dbSerialPrint
(
__pid
);
dbSerialPrint
(
","
);
dbSerialPrint
(
__cid
);
dbSerialPrint
(
","
);
if
(
__name
)
{
dbSerialPrint
(
__name
);
}
else
{
dbSerialPrint
(
"(null)"
);
}
dbSerialPrintln
(
"]"
);
}
MarlinKimbra/NexObject.h
deleted
100644 → 0
View file @
b0bc6afa
/**
* @file NexObject.h
*
* The definition of class NexObject.
*
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
* @date 2015/8/13
*
* @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 __NEXOBJECT_H__
#define __NEXOBJECT_H__
#include <Arduino.h>
#include "NexConfig.h"
/**
* @addtogroup CoreAPI
* @{
*/
/**
* Root class of all Nextion components.
*
* Provides the essential attributes of a Nextion component and the methods accessing
* them. At least, Page ID(pid), Component ID(pid) and an unique name are needed for
* creating a component in Nexiton library.
*/
class
NexObject
{
public
:
/* methods */
/**
* Constructor.
*
* @param pid - page id.
* @param cid - component id.
* @param name - pointer to an unique name in range of all components.
*/
NexObject
(
uint8_t
pid
,
uint8_t
cid
,
const
char
*
name
);
/**
* Print current object'address, page id, component id and name.
*
* @warning this method does nothing, unless debug message enabled.
*/
void
printObjInfo
(
void
);
protected
:
/* methods */
/*
* Get page id.
*
* @return the id of page.
*/
uint8_t
getObjPid
(
void
);
/*
* Get component id.
*
* @return the id of component.
*/
uint8_t
getObjCid
(
void
);
/*
* Get component name.
*
* @return the name of component.
*/
const
char
*
getObjName
(
void
);
private
:
/* data */
uint8_t
__pid
;
/* Page ID */
uint8_t
__cid
;
/* Component ID */
const
char
*
__name
;
/* An unique name */
};
/**
* @}
*/
#endif
/* #ifndef __NEXOBJECT_H__ */
MarlinKimbra/NexPage.cpp
deleted
100644 → 0
View file @
b0bc6afa
/**
* @file NexPage.cpp
*
* The implementation of class NexPage.
*
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
* @date 2015/8/13
* @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 "NexPage.h"
NexPage
::
NexPage
(
uint8_t
pid
,
uint8_t
cid
,
const
char
*
name
)
:
NexTouch
(
pid
,
cid
,
name
)
{
}
bool
NexPage
::
show
(
void
)
{
uint8_t
buffer
[
4
]
=
{
0
};
const
char
*
name
=
getObjName
();
if
(
!
name
)
{
return
false
;
}
String
cmd
=
String
(
"page "
);
cmd
+=
name
;
sendCommand
(
cmd
.
c_str
());
return
recvRetCommandFinished
();
}
MarlinKimbra/NexPage.h
deleted
100644 → 0
View file @
b0bc6afa
/**
* @file NexPage.h
*
* The definition of class NexPage.
*
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
* @date 2015/8/13
*
* @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 __NEXPAGE_H__
#define __NEXPAGE_H__
#include "NexTouch.h"
#include "NexHardware.h"
/**
* @addtogroup Component
* @{
*/
/**
* A special component , which can contain other components such as NexButton,
* NexText and NexWaveform, etc.
*/
class
NexPage
:
public
NexTouch
{
public
:
/* methods */
/**
* @copydoc NexObject::NexObject(uint8_t pid, uint8_t cid, const char *name);
*/
NexPage
(
uint8_t
pid
,
uint8_t
cid
,
const
char
*
name
);
/**
* Show itself.
*
* @return true if success, false for faileure.
*/
bool
show
(
void
);
};
/**
* @}
*/
#endif
/* #ifndef __NEXPAGE_H__ */
MarlinKimbra/NexPicture.cpp
deleted
100644 → 0
View file @
b0bc6afa
/**
* @file NexPicture.cpp
*
* The implementation of class NexPicture.
*
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
* @date 2015/8/13
* @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 "NexPicture.h"
NexPicture
::
NexPicture
(
uint8_t
pid
,
uint8_t
cid
,
const
char
*
name
)
:
NexTouch
(
pid
,
cid
,
name
)
{
}
bool
NexPicture
::
getPic
(
uint32_t
*
number
)
{
String
cmd
=
String
(
"get "
);
cmd
+=
getObjName
();
cmd
+=
".pic"
;
sendCommand
(
cmd
.
c_str
());
return
recvRetNumber
(
number
);
}
bool
NexPicture
::
setPic
(
uint32_t
number
)
{
char
buf
[
10
]
=
{
0
};
String
cmd
;
utoa
(
number
,
buf
,
10
);
cmd
+=
getObjName
();
cmd
+=
".pic="
;
cmd
+=
buf
;
sendCommand
(
cmd
.
c_str
());
return
recvRetCommandFinished
();
}
MarlinKimbra/NexPicture.h
deleted
100644 → 0
View file @
b0bc6afa
/**
* @file NexPicture.h
*
* The definition of class NexPicture.
*
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
* @date 2015/8/13
*
* @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 __NEXPICTURE_H__
#define __NEXPICTURE_H__
#include "NexTouch.h"
#include "NexHardware.h"
/**
* @addtogroup Component
* @{
*/
/**
* NexPicture component.
*/
class
NexPicture
:
public
NexTouch
{
public
:
/* methods */
/**
* @copydoc NexObject::NexObject(uint8_t pid, uint8_t cid, const char *name);
*/
NexPicture
(
uint8_t
pid
,
uint8_t
cid
,
const
char
*
name
);
/**
* Get picture's number.
*
* @param number - an output parameter to save picture number.
*
* @retval true - success.
* @retval false - failed.
*/
bool
getPic
(
uint32_t
*
number
);
/**
* Set picture's number.
*
* @param number -the picture number.
*
* @retval true - success.
* @retval false - failed.
*/
bool
setPic
(
uint32_t
number
);
};
/**
* @}
*/
#endif
/* #ifndef __NEXPICTURE_H__ */
MarlinKimbra/NexProgressBar.cpp
deleted
100644 → 0
View file @
b0bc6afa
/**
* @file NexProgressBar.cpp
*
* The implementation of class NexProgressBar.
*
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
* @date 2015/8/13
* @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 "NexProgressBar.h"
NexProgressBar
::
NexProgressBar
(
uint8_t
pid
,
uint8_t
cid
,
const
char
*
name
)
:
NexObject
(
pid
,
cid
,
name
)
{
}
bool
NexProgressBar
::
getValue
(
uint32_t
*
number
)
{
String
cmd
=
String
(
"get "
);
cmd
+=
getObjName
();
cmd
+=
".val"
;
sendCommand
(
cmd
.
c_str
());
return
recvRetNumber
(
number
);
}
bool
NexProgressBar
::
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
();
}
MarlinKimbra/NexProgressBar.h
deleted
100644 → 0
View file @
b0bc6afa
/**
* @file NexProgressBar.h
*
* The definition of class NexProgressBar.
*
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
* @date 2015/8/13
*
* @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 __NEXPROGRESSBAR_H__
#define __NEXPROGRESSBAR_H__
#include "NexTouch.h"
#include "NexHardware.h"
/**
* @addtogroup Component
* @{
*/
/**
* NexProgressBar component.
*/
class
NexProgressBar
:
public
NexObject
{
public
:
/* methods */
/**
* @copydoc NexObject::NexObject(uint8_t pid, uint8_t cid, const char *name);
*/
NexProgressBar
(
uint8_t
pid
,
uint8_t
cid
,
const
char
*
name
);
/**
* Get the value of progress bar.
*
* @param number - an output parameter to save the value of porgress bar.
*
* @retval true - success.
* @retval false - failed.
*/
bool
getValue
(
uint32_t
*
number
);
/**
* Set the value of progress bar.
*
* @param number - the value of progress bar.
*
* @retval true - success.
* @retval false - failed.
*/
bool
setValue
(
uint32_t
number
);
};
/**
* @}
*/
#endif
/* #ifndef __NEXPROGRESSBAR_H__ */
MarlinKimbra/NexSlider.cpp
deleted
100644 → 0
View file @
b0bc6afa
/**
* @file NexSlider.cpp
*
* The implementation of class NexSlider.
*
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
* @date 2015/8/13
* @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 "NexSlider.h"
NexSlider
::
NexSlider
(
uint8_t
pid
,
uint8_t
cid
,
const
char
*
name
)
:
NexTouch
(
pid
,
cid
,
name
)
{
}
bool
NexSlider
::
getValue
(
uint32_t
*
number
)
{
String
cmd
=
String
(
"get "
);
cmd
+=
getObjName
();
cmd
+=
".val"
;
sendCommand
(
cmd
.
c_str
());
return
recvRetNumber
(
number
);
}
bool
NexSlider
::
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
();
}
bool
NexSlider
::
setMaxValue
(
uint32_t
number
)
{
char
buf
[
10
]
=
{
0
};
String
cmd
;
utoa
(
number
,
buf
,
10
);
cmd
+=
getObjName
();
cmd
+=
".maxval="
;
cmd
+=
buf
;
sendCommand
(
cmd
.
c_str
());
return
recvRetCommandFinished
();
}
bool
NexSlider
::
setHigValue
(
uint32_t
number
)
{
char
buf
[
10
]
=
{
0
};
String
cmd
;
utoa
(
number
,
buf
,
10
);
cmd
+=
getObjName
();
cmd
+=
".hig="
;
cmd
+=
buf
;
sendCommand
(
cmd
.
c_str
());
return
recvRetCommandFinished
();
}
MarlinKimbra/NexSlider.h
deleted
100644 → 0
View file @
b0bc6afa
/**
* @file NexSlider.h
*
* The definition of class NexSlider.
*
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
* @date 2015/8/13
*
* @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 __NEXSLIDER_H__
#define __NEXSLIDER_H__
#include "NexTouch.h"
#include "NexHardware.h"
/**
* @addtogroup Component
* @{
*/
/**
* NexSlider component.
*/
class
NexSlider
:
public
NexTouch
{
public
:
/* methods */
/**
* @copydoc NexObject::NexObject(uint8_t pid, uint8_t cid, const char *name);
*/
NexSlider
(
uint8_t
pid
,
uint8_t
cid
,
const
char
*
name
);
/**
* Get the value of slider.
*
* @param number - an output parameter to save the value of slider.
*
* @retval true - success.
* @retval false - failed.
*/
bool
getValue
(
uint32_t
*
number
);
/**
* Set the value of slider.
*
* @param number - the value of slider.
*
* @retval true - success.
* @retval false - failed.
*/
bool
setValue
(
uint32_t
number
);
/**
* Set the maxvalue of slider.
*
* @param number - the value of slider.
*
* @retval true - success.
* @retval false - failed.
*/
bool
setMaxValue
(
uint32_t
number
);
/**
* Set the hig of slider.
*
* @param number - the value of slider.
*
* @retval true - success.
* @retval false - failed.
*/
bool
setHigValue
(
uint32_t
number
);
};
/**
* @}
*/
#endif
/* #ifndef __NEXSLIDER_H__ */
MarlinKimbra/NexText.cpp
deleted
100644 → 0
View file @
b0bc6afa
/**
* @file NexText.cpp
*
* The implementation of class NexText.
*
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
* @date 2015/8/13
* @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 "NexText.h"
NexText
::
NexText
(
uint8_t
pid
,
uint8_t
cid
,
const
char
*
name
)
:
NexTouch
(
pid
,
cid
,
name
)
{
}
uint16_t
NexText
::
getText
(
char
*
buffer
,
uint16_t
len
)
{
String
cmd
;
cmd
+=
"get "
;
cmd
+=
getObjName
();
cmd
+=
".txt"
;
sendCommand
(
cmd
.
c_str
());
return
recvRetString
(
buffer
,
len
);
}
bool
NexText
::
setText
(
const
char
*
buffer
)
{
String
cmd
;
cmd
+=
getObjName
();
cmd
+=
".txt=
\"
"
;
cmd
+=
buffer
;
cmd
+=
"
\"
"
;
sendCommand
(
cmd
.
c_str
());
return
recvRetCommandFinished
();
}
bool
NexText
::
setColor
(
uint32_t
value
)
{
char
buf
[
10
]
=
{
0
};
String
cmd
;
utoa
(
value
,
buf
,
10
);
cmd
+=
getObjName
();
cmd
+=
".pco="
;
cmd
+=
buf
;
sendCommand
(
cmd
.
c_str
());
return
recvRetCommandFinished
();
}
MarlinKimbra/NexText.h
deleted
100644 → 0
View file @
b0bc6afa
/**
* @file NexText.h
*
* The definition of class NexText.
*
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
* @date 2015/8/13
*
* @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 __NEXTEXT_H__
#define __NEXTEXT_H__
#include "NexTouch.h"
#include "NexHardware.h"
/**
* @addtogroup Component
* @{
*/
/**
* NexText component.
*/
class
NexText
:
public
NexTouch
{
public
:
/* methods */
/**
* @copydoc NexObject::NexObject(uint8_t pid, uint8_t cid, const char *name);
*/
NexText
(
uint8_t
pid
,
uint8_t
cid
,
const
char
*
name
);
/**
* Get text attribute of component.
*
* @param buffer - buffer storing text returned.
* @param len - length of buffer.
* @return The real length of text returned.
*/
uint16_t
getText
(
char
*
buffer
,
uint16_t
len
);
/**
* Set text attribute of component.
*
* @param buffer - text buffer terminated with '\0'.
* @return true if success, false for failure.
*/
bool
setText
(
const
char
*
buffer
);
bool
setColor
(
uint32_t
value
);
};
/**
* @}
*/
#endif
/* #ifndef __NEXTEXT_H__ */
MarlinKimbra/NexTimer.cpp
deleted
100644 → 0
View file @
b0bc6afa
/**
* @file NexTimer.cpp
*
* The implementation of class NexTimer.
*
* @author huang xianming (email:<xianming.huang@itead.cc>)
* @date 2015/8/26
* @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 "NexTimer.h"
NexTimer
::
NexTimer
(
uint8_t
pid
,
uint8_t
cid
,
const
char
*
name
)
:
NexTouch
(
pid
,
cid
,
name
)
{
}
void
NexTimer
::
attachTimer
(
NexTouchEventCb
timer
,
void
*
ptr
)
{
NexTouch
::
attachPop
(
timer
,
ptr
);
}
void
NexTimer
::
detachTimer
(
void
)
{
NexTouch
::
detachPop
();
}
bool
NexTimer
::
getCycle
(
uint32_t
*
number
)
{
String
cmd
=
String
(
"get "
);
cmd
+=
getObjName
();
cmd
+=
".tim"
;
sendCommand
(
cmd
.
c_str
());
return
recvRetNumber
(
number
);
}
bool
NexTimer
::
setCycle
(
uint32_t
number
)
{
char
buf
[
10
]
=
{
0
};
String
cmd
;
if
(
number
<
50
)
{
number
=
50
;
}
utoa
(
number
,
buf
,
10
);
cmd
+=
getObjName
();
cmd
+=
".tim="
;
cmd
+=
buf
;
sendCommand
(
cmd
.
c_str
());
return
recvRetCommandFinished
();
}
bool
NexTimer
::
enable
(
void
)
{
char
buf
[
10
]
=
{
0
};
String
cmd
;
utoa
(
1
,
buf
,
10
);
cmd
+=
getObjName
();
cmd
+=
".en="
;
cmd
+=
buf
;
sendCommand
(
cmd
.
c_str
());
return
recvRetCommandFinished
();
}
bool
NexTimer
::
disable
(
void
)
{
char
buf
[
10
]
=
{
0
};
String
cmd
;
utoa
(
0
,
buf
,
10
);
cmd
+=
getObjName
();
cmd
+=
".en="
;
cmd
+=
buf
;
sendCommand
(
cmd
.
c_str
());
return
recvRetCommandFinished
();
}
MarlinKimbra/NexTimer.h
deleted
100644 → 0
View file @
b0bc6afa
/**
* @file NexTimer.h
*
* The definition of class NexTimer.
*
* @author huang xianming (email:<xianming.huang@itead.cc>)
* @date 2015/8/26
*
* @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 __NEXTIMER_H__
#define __NEXTIMER_H__
#include "NexTouch.h"
#include "NexHardware.h"
/**
* @addtogroup Component
* @{
*/
/**
* NexTimer component.
*
* Commonly, you want to do something after set timer cycle and enable it,and the cycle value
* must be greater than 50
*
*/
class
NexTimer
:
public
NexTouch
{
public
:
/* methods */
/**
* @copydoc NexObject::NexObject(uint8_t pid, uint8_t cid, const char *name);
*/
NexTimer
(
uint8_t
pid
,
uint8_t
cid
,
const
char
*
name
);
/**
* Attach an callback function of timer respond event.
*
* @param timer - callback called with ptr when a timer respond event occurs.
* @param ptr - parameter passed into push[default:NULL].
* @return none.
*
* @note If calling this method multiply, the last call is valid.
*/
void
attachTimer
(
NexTouchEventCb
timer
,
void
*
ptr
=
NULL
);
/**
* Detach an callback function.
*
* @return none.
*/
void
detachTimer
(
void
);
/**
* Get the value of timer cycle val.
*
* @param number - an output parameter to save the value of timer cycle.
*
* @retval true - success.
* @retval false - failed.
*/
bool
getCycle
(
uint32_t
*
number
);
/**
* Set the value of timer cycle val.
*
* @param number - the value of timer cycle.
*
* @retval true - success.
* @retval false - failed.
*
* @warning the cycle value must be greater than 50.
*/
bool
setCycle
(
uint32_t
number
);
/**
* contorl timer enable.
*
* @retval true - success.
* @retval false - failed.
*/
bool
enable
(
void
);
/**
* contorl timer disable.
*
* @retval true - success.
* @retval false - failed.
*/
bool
disable
(
void
);
};
/**
* @}
*/
#endif
/* #ifndef __NEXTIMER_H__ */
MarlinKimbra/NexTouch.cpp
deleted
100644 → 0
View file @
b0bc6afa
/**
* @file NexTouch.cpp
*
* The implementation of class NexTouch.
*
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
* @date 2015/8/13
* @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 "NexTouch.h"
NexTouch
::
NexTouch
(
uint8_t
pid
,
uint8_t
cid
,
const
char
*
name
)
:
NexObject
(
pid
,
cid
,
name
)
{
this
->
__cb_push
=
NULL
;
this
->
__cb_pop
=
NULL
;
this
->
__cbpop_ptr
=
NULL
;
this
->
__cbpush_ptr
=
NULL
;
}
void
NexTouch
::
attachPush
(
NexTouchEventCb
push
,
void
*
ptr
)
{
this
->
__cb_push
=
push
;
this
->
__cbpush_ptr
=
ptr
;
}
void
NexTouch
::
detachPush
(
void
)
{
this
->
__cb_push
=
NULL
;
this
->
__cbpush_ptr
=
NULL
;
}
void
NexTouch
::
attachPop
(
NexTouchEventCb
pop
,
void
*
ptr
)
{
this
->
__cb_pop
=
pop
;
this
->
__cbpop_ptr
=
ptr
;
}
void
NexTouch
::
detachPop
(
void
)
{
this
->
__cb_pop
=
NULL
;
this
->
__cbpop_ptr
=
NULL
;
}
void
NexTouch
::
push
(
void
)
{
if
(
__cb_push
)
{
__cb_push
(
__cbpush_ptr
);
}
}
void
NexTouch
::
pop
(
void
)
{
if
(
__cb_pop
)
{
__cb_pop
(
__cbpop_ptr
);
}
}
void
NexTouch
::
iterate
(
NexTouch
**
list
,
uint8_t
pid
,
uint8_t
cid
,
int32_t
event
)
{
NexTouch
*
e
=
NULL
;
uint16_t
i
=
0
;
if
(
NULL
==
list
)
{
return
;
}
for
(
i
=
0
;
(
e
=
list
[
i
])
!=
NULL
;
i
++
)
{
if
(
e
->
getObjPid
()
==
pid
&&
e
->
getObjCid
()
==
cid
)
{
e
->
printObjInfo
();
if
(
NEX_EVENT_PUSH
==
event
)
{
e
->
push
();
}
else
if
(
NEX_EVENT_POP
==
event
)
{
e
->
pop
();
}
break
;
}
}
}
MarlinKimbra/NexTouch.h
deleted
100644 → 0
View file @
b0bc6afa
/**
* @file NexTouch.h
*
* The definition of class NexTouch.
*
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
* @date 2015/8/13
*
* @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 __NEXTOUCH_H__
#define __NEXTOUCH_H__
#include <Arduino.h>
#include "NexConfig.h"
#include "NexObject.h"
/**
* @addtogroup TouchEvent
* @{
*/
/**
* Push touch event occuring when your finger or pen coming to Nextion touch pannel.
*/
#define NEX_EVENT_PUSH (0x01)
/**
* Pop touch event occuring when your finger or pen leaving from Nextion touch pannel.
*/
#define NEX_EVENT_POP (0x00)
/**
* Type of callback funciton when an touch event occurs.
*
* @param ptr - user pointer for any purpose. Commonly, it is a pointer to a object.
* @return none.
*/
typedef
void
(
*
NexTouchEventCb
)(
void
*
ptr
);
/**
* Father class of the components with touch events.
*
* Derives from NexObject and provides methods allowing user to attach
* (or detach) a callback function called when push(or pop) touch event occurs.
*/
class
NexTouch
:
public
NexObject
{
public
:
/* static methods */
static
void
iterate
(
NexTouch
**
list
,
uint8_t
pid
,
uint8_t
cid
,
int32_t
event
);
public
:
/* methods */
/**
* @copydoc NexObject::NexObject(uint8_t pid, uint8_t cid, const char *name);
*/
NexTouch
(
uint8_t
pid
,
uint8_t
cid
,
const
char
*
name
);
/**
* Attach an callback function of push touch event.
*
* @param push - callback called with ptr when a push touch event occurs.
* @param ptr - parameter passed into push[default:NULL].
* @return none.
*
* @note If calling this method multiply, the last call is valid.
*/
void
attachPush
(
NexTouchEventCb
push
,
void
*
ptr
=
NULL
);
/**
* Detach an callback function.
*
* @return none.
*/
void
detachPush
(
void
);
/**
* Attach an callback function of pop touch event.
*
* @param pop - callback called with ptr when a pop touch event occurs.
* @param ptr - parameter passed into pop[default:NULL].
* @return none.
*
* @note If calling this method multiply, the last call is valid.
*/
void
attachPop
(
NexTouchEventCb
pop
,
void
*
ptr
=
NULL
);
/**
* Detach an callback function.
*
* @return none.
*/
void
detachPop
(
void
);
private
:
/* methods */
void
push
(
void
);
void
pop
(
void
);
private
:
/* data */
NexTouchEventCb
__cb_push
;
void
*
__cbpush_ptr
;
NexTouchEventCb
__cb_pop
;
void
*
__cbpop_ptr
;
};
/**
* @}
*/
#endif
/* #ifndef __NEXTOUCH_H__ */
MarlinKimbra/NexVar.cpp
deleted
100644 → 0
View file @
b0bc6afa
/**
* @file NexVar.cpp
*
* The implementation of class NexVar.
*
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
* @date 2015/8/13
* @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 "NexVar.h"
NexVar
::
NexVar
(
uint8_t
pid
,
uint8_t
cid
,
const
char
*
name
)
:
NexTouch
(
pid
,
cid
,
name
)
{
}
uint16_t
NexVar
::
getText
(
char
*
buffer
,
uint16_t
len
)
{
String
cmd
;
cmd
+=
"get "
;
cmd
+=
getObjName
();
cmd
+=
".txt"
;
sendCommand
(
cmd
.
c_str
());
return
recvRetString
(
buffer
,
len
);
}
bool
NexVar
::
setText
(
const
char
*
buffer
)
{
String
cmd
;
cmd
+=
getObjName
();
cmd
+=
".txt=
\"
"
;
cmd
+=
buffer
;
cmd
+=
"
\"
"
;
sendCommand
(
cmd
.
c_str
());
return
recvRetCommandFinished
();
}
bool
NexVar
::
getValue
(
uint32_t
*
number
)
{
String
cmd
=
String
(
"get "
);
cmd
+=
getObjName
();
cmd
+=
".val"
;
sendCommand
(
cmd
.
c_str
());
return
recvRetNumber
(
number
);
}
bool
NexVar
::
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
();
}
MarlinKimbra/NexVar.h
deleted
100644 → 0
View file @
b0bc6afa
/**
* @file NexVar.h
*
* The definition of class NexVar.
*
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
* @date 2015/8/13
*
* @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 __NEXVAL_H__
#define __NEXVAL_H__
#include "NexTouch.h"
#include "NexHardware.h"
/**
* @addtogroup Component
* @{
*/
/**
* NexVar component.
*/
class
NexVar
:
public
NexTouch
{
public
:
/* methods */
/**
* @copydoc NexObject::NexObject(uint8_t pid, uint8_t cid, const char *name);
*/
NexVar
(
uint8_t
pid
,
uint8_t
cid
,
const
char
*
name
);
/**
* Get text attribute of component.
*
* @param buffer - buffer storing text returned.
* @param len - length of buffer.
* @return The real length of text returned.
*/
uint16_t
getText
(
char
*
buffer
,
uint16_t
len
);
/**
* Set text attribute of component.
*
* @param buffer - text buffer terminated with '\0'.
* @return true if success, false for failure.
*/
bool
setText
(
const
char
*
buffer
);
/**
* Get the value of slider.
*
* @param number - an output parameter to save the value of slider.
*
* @retval true - success.
* @retval false - failed.
*/
bool
getValue
(
uint32_t
*
number
);
/**
* Set the value of slider.
*
* @param number - the value of slider.
*
* @retval true - success.
* @retval false - failed.
*/
bool
setValue
(
uint32_t
number
);
};
/**
* @}
*/
#endif
/* #ifndef __NEXTEXT_H__ */
MarlinKimbra/NexWaveform.cpp
deleted
100644 → 0
View file @
b0bc6afa
/**
* @file NexWaveform.cpp
*
* The implementation of class NexWaveform.
*
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
* @date 2015/8/13
* @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 "NexWaveform.h"
NexWaveform
::
NexWaveform
(
uint8_t
pid
,
uint8_t
cid
,
const
char
*
name
)
:
NexObject
(
pid
,
cid
,
name
)
{
}
bool
NexWaveform
::
addValue
(
uint8_t
ch
,
uint8_t
number
)
{
char
buf
[
15
]
=
{
0
};
if
(
ch
>
3
)
{
return
false
;
}
sprintf
(
buf
,
"add %u,%u,%u"
,
getObjCid
(),
ch
,
number
);
sendCommand
(
buf
);
return
true
;
}
MarlinKimbra/NexWaveform.h
deleted
100644 → 0
View file @
b0bc6afa
/**
* @file NexWaveform.h
*
* The definition of class NexWaveform.
*
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
* @date 2015/8/13
*
* @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 __NEXWAVEFORM_H__
#define __NEXWAVEFORM_H__
#include "NexTouch.h"
#include "NexHardware.h"
/**
* @addtogroup Component
* @{
*/
/**
* NexWaveform component.
*/
class
NexWaveform
:
public
NexObject
{
public
:
/* methods */
/**
* @copydoc NexObject::NexObject(uint8_t pid, uint8_t cid, const char *name);
*/
NexWaveform
(
uint8_t
pid
,
uint8_t
cid
,
const
char
*
name
);
/**
* Add value to show.
*
* @param ch - channel of waveform(0-3).
* @param number - the value of waveform.
*
* @retval true - success.
* @retval false - failed.
*/
bool
addValue
(
uint8_t
ch
,
uint8_t
number
);
};
/**
* @}
*/
#endif
/* #ifndef __NEXWAVEFORM_H__ */
MarlinKimbra/Nextion.h
deleted
100644 → 0
View file @
b0bc6afa
/**
* @file Nextion.h
*
* The header file including all other header files provided by this library.
*
* Every example sketch should include this file.
*
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
* @date 2015/8/12
* @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 __NEXTION_H__
#define __NEXTION_H__
#include "Arduino.h"
#include "NexConfig.h"
#include "NexTouch.h"
#include "NexHardware.h"
#include "NexButton.h"
//#include "NexCrop.h"
//#include "NexGauge.h"
#include "NexHotspot.h"
#include "NexPage.h"
#include "NexPicture.h"
#include "NexProgressBar.h"
#include "NexSlider.h"
#include "NexText.h"
#include "NexWaveform.h"
#include "NexTimer.h"
#include "NexVar.h"
#endif
/* #ifndef __NEXTION_H__ */
MarlinKimbra/cardreader.cpp
View file @
3e7df4a6
...
...
@@ -11,6 +11,7 @@
#include "stepper.h"
#include "temperature.h"
#include "ultralcd.h"
#include "nextion_lcd.h"
#include "cardreader.h"
CardReader
::
CardReader
()
{
...
...
MarlinKimbra/nextion_lcd.cpp
0 → 100644
View file @
3e7df4a6
#include "base.h"
#if ENABLED(NEXTION)
#include "Marlin_main.h"
#include "cardreader.h"
#include "temperature.h"
#if ENABLED(AUTO_BED_LEVELING_FEATURE)
#include "vector_3.h"
#endif
#include "planner.h"
#include "stepper_indirection.h"
#include "stepper.h"
#include "configuration_store.h"
#include "nextion_lcd.h"
#include <Nextion.h>
const
float
MaxWave
=
0.2
;
bool
NextionON
=
false
;
bool
PageInfo
=
false
;
char
buffer
[
100
]
=
{
0
};
uint32_t
slidermaxval
=
20
;
char
lcd_status_message
[
30
]
=
WELCOME_MSG
;
// worst case is kana with up to 3*LCD_WIDTH+1
uint8_t
lcd_status_message_level
=
0
;
static
millis_t
next_lcd_update_ms
;
static
millis_t
return_to_status_ms
=
30000
;
// Page
NexPage
Pstart
=
NexPage
(
0
,
0
,
"start"
);
NexPage
Pinfo
=
NexPage
(
1
,
0
,
"info"
);
NexPage
Ptemp
=
NexPage
(
2
,
0
,
"temp"
);
NexPage
Pmenu
=
NexPage
(
3
,
0
,
"menu"
);
NexPage
Psdcard
=
NexPage
(
4
,
0
,
"sdcard"
);
NexPage
Psetup
=
NexPage
(
5
,
0
,
"setup"
);
// Text
NexText
Hotend0
=
NexText
(
1
,
1
,
"t0"
);
NexText
Hotend1
=
NexText
(
1
,
4
,
"t1"
);
NexText
Hotend2
=
NexText
(
1
,
5
,
"t2"
);
NexText
Hotend21
=
NexText
(
1
,
6
,
"h2"
);
NexText
LedStatus
=
NexText
(
1
,
7
,
"t4"
);
NexText
LedCoord
=
NexText
(
1
,
8
,
"t5"
);
NexText
set0
=
NexText
(
2
,
2
,
"set0"
);
NexText
set1
=
NexText
(
2
,
15
,
"set1"
);
NexText
sdrow0
=
NexText
(
4
,
3
,
"t0"
);
NexText
sdrow1
=
NexText
(
4
,
4
,
"t1"
);
NexText
sdrow2
=
NexText
(
4
,
5
,
"t2"
);
NexText
sdrow3
=
NexText
(
4
,
6
,
"t3"
);
NexText
sdrow4
=
NexText
(
4
,
7
,
"t4"
);
NexText
sdrow5
=
NexText
(
4
,
8
,
"t5"
);
NexText
sdfolder
=
NexText
(
4
,
23
,
"sdfolder"
);
// Picture
NexPicture
Menu
=
NexPicture
(
1
,
10
,
"p0"
);
NexPicture
MSD
=
NexPicture
(
1
,
11
,
"p1"
);
NexPicture
MSetup
=
NexPicture
(
1
,
12
,
"p2"
);
NexPicture
Hend0
=
NexPicture
(
1
,
13
,
"p3"
);
NexPicture
Hend1
=
NexPicture
(
1
,
14
,
"p4"
);
NexPicture
Hend2
=
NexPicture
(
1
,
15
,
"p5"
);
NexPicture
Fanpic
=
NexPicture
(
1
,
19
,
"p6"
);
NexPicture
Folder0
=
NexPicture
(
4
,
9
,
"p0"
);
NexPicture
Folder1
=
NexPicture
(
4
,
10
,
"p1"
);
NexPicture
Folder2
=
NexPicture
(
4
,
11
,
"p2"
);
NexPicture
Folder3
=
NexPicture
(
4
,
12
,
"p3"
);
NexPicture
Folder4
=
NexPicture
(
4
,
13
,
"p4"
);
NexPicture
Folder5
=
NexPicture
(
4
,
14
,
"p5"
);
NexPicture
Folderup
=
NexPicture
(
4
,
15
,
"p6"
);
NexPicture
Exit
=
NexPicture
(
4
,
16
,
"p7"
);
// Progress Bar
// Slider
NexSlider
sdlist
=
NexSlider
(
4
,
1
,
"h0"
);
// Wafeform
NexWaveform
Graph0
=
NexWaveform
(
1
,
9
,
"s0"
);
NexWaveform
Graph1
=
NexWaveform
(
1
,
24
,
"s1"
);
NexWaveform
Graph2
=
NexWaveform
(
1
,
25
,
"s2"
);
// Touch area
NexHotspot
hot0
=
NexHotspot
(
1
,
14
,
"hot0"
);
NexHotspot
hot1
=
NexHotspot
(
1
,
16
,
"hot1"
);
NexHotspot
hot2
=
NexHotspot
(
1
,
18
,
"hot2"
);
NexHotspot
m11
=
NexHotspot
(
2
,
14
,
"m11"
);
NexHotspot
tup
=
NexHotspot
(
2
,
16
,
"tup"
);
NexHotspot
tdown
=
NexHotspot
(
2
,
17
,
"tdown"
);
// Timer
NexTimer
startimer
=
NexTimer
(
0
,
1
,
"tm0"
);
NexTimer
fantimer
=
NexTimer
(
1
,
23
,
"tm0"
);
// Variable
NexVar
Hotend
=
NexVar
(
1
,
20
,
"he"
);
NexVar
Bed
=
NexVar
(
1
,
21
,
"bed"
);
NexVar
filename0
=
NexVar
(
4
,
19
,
"va0"
);
NexVar
filename1
=
NexVar
(
4
,
20
,
"va1"
);
NexVar
filename2
=
NexVar
(
4
,
21
,
"va2"
);
NexVar
filename3
=
NexVar
(
4
,
22
,
"va3"
);
NexVar
filename4
=
NexVar
(
4
,
23
,
"va4"
);
NexVar
filename5
=
NexVar
(
4
,
24
,
"va5"
);
NexTouch
*
nex_listen_list
[]
=
{
&
Pstart
,
&
Menu
,
&
MSD
,
&
MSetup
,
&
Fanpic
,
&
hot0
,
&
hot1
,
&
hot2
,
&
m11
,
&
tup
,
&
tdown
,
&
sdlist
,
&
sdrow0
,
&
sdrow1
,
&
sdrow2
,
&
sdrow3
,
&
sdrow4
,
&
sdrow5
,
&
Folderup
,
&
Exit
,
NULL
};
void
setpageInfo
()
{
Pinfo
.
show
();
PageInfo
=
true
;
#if HAS_TEMP_0
Hotend
.
setValue
(
1
);
#endif
#if HAS_TEMP_1
Hotend
.
setValue
(
2
);
#endif
#if HAS_TEMP_2
Hotend
.
setValue
(
3
);
#elif HAS_TEMP_BED
Hotend21
.
setText
(
"BED"
);
Bed
.
setValue
(
1
);
#endif
lcd_setstatus
(
lcd_status_message
);
}
#if ENABLED(SDSUPPORT)
void
printrowsd
(
uint8_t
row
,
const
bool
folder
,
const
char
*
filename
,
char
*
longFilename
)
{
const
char
*
cmd
;
if
(
longFilename
[
0
])
cmd
=
longFilename
;
else
cmd
=
filename
;
switch
(
row
)
{
case
0
:
{
if
(
folder
)
{
Folder0
.
setPic
(
18
);
sdrow0
.
attachPop
(
sdfolderPopCallback
,
&
sdrow0
);
}
else
if
(
cmd
==
""
)
{
Folder0
.
setPic
(
17
);
sdrow0
.
detachPop
();
}
else
{
Folder0
.
setPic
(
17
);
sdrow0
.
attachPop
(
sdfilePopCallback
,
&
sdrow0
);
}
sdrow0
.
setText
(
cmd
);
filename0
.
setText
(
filename
);
}
case
1
:
{
if
(
folder
)
{
Folder1
.
setPic
(
18
);
sdrow1
.
attachPop
(
sdfolderPopCallback
,
&
sdrow1
);
}
else
if
(
cmd
==
""
)
{
Folder1
.
setPic
(
17
);
sdrow1
.
detachPop
();
}
else
{
Folder1
.
setPic
(
17
);
sdrow1
.
attachPop
(
sdfilePopCallback
,
&
sdrow1
);
}
sdrow1
.
setText
(
cmd
);
filename1
.
setText
(
filename
);
}
case
2
:
{
if
(
folder
)
{
Folder2
.
setPic
(
18
);
sdrow2
.
attachPop
(
sdfolderPopCallback
,
&
sdrow2
);
}
else
if
(
cmd
==
""
)
{
Folder2
.
setPic
(
17
);
sdrow2
.
detachPop
();
}
else
{
Folder2
.
setPic
(
17
);
sdrow2
.
attachPop
(
sdfilePopCallback
,
&
sdrow2
);
}
sdrow2
.
setText
(
cmd
);
filename2
.
setText
(
filename
);
}
case
3
:
{
if
(
folder
)
{
Folder3
.
setPic
(
18
);
sdrow3
.
attachPop
(
sdfolderPopCallback
,
&
sdrow3
);
}
else
if
(
cmd
==
""
)
{
Folder3
.
setPic
(
17
);
sdrow3
.
detachPop
();
}
else
{
Folder3
.
setPic
(
17
);
sdrow3
.
attachPop
(
sdfilePopCallback
,
&
sdrow3
);
}
sdrow3
.
setText
(
cmd
);
filename3
.
setText
(
filename
);
}
case
4
:
{
if
(
folder
)
{
Folder4
.
setPic
(
18
);
sdrow4
.
attachPop
(
sdfolderPopCallback
,
&
sdrow4
);
}
else
if
(
cmd
==
""
)
{
Folder4
.
setPic
(
17
);
sdrow4
.
detachPop
();
}
else
{
Folder4
.
setPic
(
17
);
sdrow4
.
attachPop
(
sdfilePopCallback
,
&
sdrow4
);
}
sdrow4
.
setText
(
cmd
);
filename4
.
setText
(
filename
);
}
case
5
:
{
if
(
folder
)
{
Folder5
.
setPic
(
18
);
sdrow5
.
attachPop
(
sdfolderPopCallback
,
&
sdrow5
);
}
else
if
(
cmd
==
""
)
{
Folder5
.
setPic
(
17
);
sdrow5
.
detachPop
();
}
else
{
Folder5
.
setPic
(
17
);
sdrow5
.
attachPop
(
sdfilePopCallback
,
&
sdrow5
);
}
sdrow5
.
setText
(
cmd
);
filename5
.
setText
(
filename
);
}
}
}
static
void
setrowsdcard
(
uint32_t
number
=
0
)
{
uint16_t
fileCnt
=
card
.
getnrfilenames
();
uint32_t
i
=
0
;
card
.
getWorkDirName
();
if
(
card
.
filename
[
0
]
!=
'/'
)
{
Folderup
.
setPic
(
20
);
Folderup
.
attachPop
(
sdfolderUpPopCallback
);
sdfolder
.
setText
(
card
.
filename
);
}
else
{
Folderup
.
detachPop
();
Folderup
.
setPic
(
19
);
sdfolder
.
setText
(
""
);
}
for
(
uint8_t
row
=
0
;
row
<
6
;
row
++
)
{
i
=
row
+
number
;
if
(
i
<
fileCnt
)
{
card
.
getfilename
(
i
);
printrowsd
(
row
,
card
.
filenameIsDir
,
card
.
filename
,
card
.
longFilename
);
}
else
{
printrowsd
(
row
,
false
,
""
,
""
);
}
}
sendCommand
(
"ref 0"
);
}
static
void
setpagesdcard
()
{
PageInfo
=
false
;
Psdcard
.
show
();
uint16_t
fileCnt
=
card
.
getnrfilenames
();
if
(
fileCnt
<=
6
)
slidermaxval
=
0
;
else
slidermaxval
=
fileCnt
-
6
;
uint16_t
hig
=
210
-
slidermaxval
*
10
;
if
(
hig
<
10
)
hig
=
10
;
sdlist
.
setHigValue
(
hig
);
sdlist
.
setMaxValue
(
slidermaxval
);
sdlist
.
setValue
(
slidermaxval
);
sendCommand
(
"ref 0"
);
setrowsdcard
();
}
void
sdlistPopCallback
(
void
*
ptr
)
{
uint32_t
number
=
0
;
sdlist
.
getValue
(
&
number
);
number
=
slidermaxval
-
number
;
setrowsdcard
(
number
);
}
static
void
menu_action_sdfile
(
const
char
*
filename
)
{
char
cmd
[
30
];
char
*
c
;
sprintf_P
(
cmd
,
PSTR
(
"M23 %s"
),
filename
);
for
(
c
=
&
cmd
[
4
];
*
c
;
c
++
)
*
c
=
tolower
(
*
c
);
enqueuecommand
(
cmd
);
enqueuecommands_P
(
PSTR
(
"M24"
));
setpageInfo
();
}
static
void
menu_action_sddirectory
(
const
char
*
filename
)
{
card
.
chdir
(
filename
);
setpagesdcard
();
}
void
sdfilePopCallback
(
void
*
ptr
)
{
memset
(
buffer
,
0
,
sizeof
(
buffer
));
if
(
ptr
==
&
sdrow0
)
filename0
.
getText
(
buffer
,
sizeof
(
buffer
));
else
if
(
ptr
==
&
sdrow1
)
filename1
.
getText
(
buffer
,
sizeof
(
buffer
));
else
if
(
ptr
==
&
sdrow2
)
filename2
.
getText
(
buffer
,
sizeof
(
buffer
));
else
if
(
ptr
==
&
sdrow3
)
filename3
.
getText
(
buffer
,
sizeof
(
buffer
));
else
if
(
ptr
==
&
sdrow4
)
filename4
.
getText
(
buffer
,
sizeof
(
buffer
));
else
if
(
ptr
==
&
sdrow5
)
filename5
.
getText
(
buffer
,
sizeof
(
buffer
));
menu_action_sdfile
(
buffer
);
}
void
sdfolderPopCallback
(
void
*
ptr
)
{
memset
(
buffer
,
0
,
sizeof
(
buffer
));
if
(
ptr
==
&
sdrow0
)
filename0
.
getText
(
buffer
,
sizeof
(
buffer
));
else
if
(
ptr
==
&
sdrow1
)
filename1
.
getText
(
buffer
,
sizeof
(
buffer
));
else
if
(
ptr
==
&
sdrow2
)
filename2
.
getText
(
buffer
,
sizeof
(
buffer
));
else
if
(
ptr
==
&
sdrow3
)
filename3
.
getText
(
buffer
,
sizeof
(
buffer
));
else
if
(
ptr
==
&
sdrow4
)
filename4
.
getText
(
buffer
,
sizeof
(
buffer
));
else
if
(
ptr
==
&
sdrow5
)
filename5
.
getText
(
buffer
,
sizeof
(
buffer
));
menu_action_sddirectory
(
buffer
);
}
void
sdfolderUpPopCallback
(
void
*
ptr
)
{
card
.
updir
();
setpagesdcard
();
}
void
ExitPopCallback
(
void
*
ptr
)
{
setpageInfo
();
}
#endif
void
PstartPopCallback
(
void
*
ptr
)
{
setpageInfo
();
}
void
hotPopCallback
(
void
*
ptr
)
{
Ptemp
.
show
();
PageInfo
=
false
;
memset
(
buffer
,
0
,
sizeof
(
buffer
));
if
(
ptr
==
&
hot0
)
{
if
(
degTargetHotend
(
0
)
!=
0
)
{
itoa
(
degTargetHotend
(
0
),
buffer
,
10
);
}
set1
.
setText
(
"M104 T0 S"
);
}
if
(
ptr
==
&
hot1
)
{
if
(
degTargetHotend
(
1
)
!=
0
)
{
itoa
(
degTargetHotend
(
1
),
buffer
,
10
);
}
set1
.
setText
(
"M104 T1 S"
);
}
#if HAS_TEMP_2
if
(
ptr
==
&
hot2
)
{
if
(
degTargetHotend
(
2
)
!=
0
)
{
itoa
(
degTargetHotend
(
2
),
buffer
,
10
);
}
set1
.
setText
(
"M104 T2 S"
);
}
#elif HAS_TEMP_BED
if
(
ptr
==
&
hot2
)
{
if
(
degTargetBed
()
!=
0
)
{
itoa
(
degTargetBed
(),
buffer
,
10
);
}
set1
.
setText
(
"M140 S"
);
}
#endif
set0
.
setText
(
buffer
);
}
void
settempPopCallback
(
void
*
ptr
)
{
uint16_t
number
;
memset
(
buffer
,
0
,
sizeof
(
buffer
));
set0
.
getText
(
buffer
,
sizeof
(
buffer
));
number
=
atoi
(
buffer
);
if
(
ptr
==
&
tup
)
number
+=
1
;
if
(
ptr
==
&
tdown
)
number
-=
1
;
memset
(
buffer
,
0
,
sizeof
(
buffer
));
itoa
(
number
,
buffer
,
10
);
set0
.
setText
(
buffer
);
}
void
sethotPopCallback
(
void
*
ptr
)
{
memset
(
buffer
,
0
,
sizeof
(
buffer
));
set1
.
getText
(
buffer
,
sizeof
(
buffer
));
enqueuecommands_P
(
buffer
);
setpageInfo
();
}
void
setpagePopCallback
(
void
*
ptr
)
{
if
(
ptr
==
&
Menu
)
Pmenu
.
show
();
if
(
ptr
==
&
MSetup
)
Psetup
.
show
();
#if ENABLED(SDSUPPORT)
if
(
ptr
==
&
MSD
)
setpagesdcard
();
#endif
}
void
setfanPopCallback
(
void
*
ptr
)
{
if
(
fanSpeed
)
fanSpeed
=
0
;
else
fanSpeed
=
255
;
}
void
lcd_init
()
{
delay
(
1000
);
NextionON
=
nexInit
();
if
(
!
NextionON
)
{
ECHO_LM
(
DB
,
"Nextion LCD not connected!"
);
}
else
{
ECHO_LM
(
DB
,
"Nextion LCD connected!"
);
Pstart
.
attachPop
(
PstartPopCallback
);
#if ENABLED(SDSUPPORT)
MSD
.
attachPop
(
setpagePopCallback
,
&
MSD
);
sdlist
.
attachPop
(
sdlistPopCallback
);
Exit
.
attachPop
(
ExitPopCallback
);
#endif
#if HAS_TEMP_0
hot0
.
attachPop
(
hotPopCallback
,
&
hot0
);
#endif
#if HAS_TEMP_1
hot1
.
attachPop
(
hotPopCallback
,
&
hot1
);
#endif
#if HAS_TEMP_2 || HAS_TEMP_BED
hot2
.
attachPop
(
hotPopCallback
,
&
hot2
);
#endif
Menu
.
attachPop
(
setpagePopCallback
,
&
Menu
);
MSetup
.
attachPop
(
setpagePopCallback
,
&
Menu
);
Fanpic
.
attachPop
(
setfanPopCallback
,
&
Fanpic
);
m11
.
attachPop
(
sethotPopCallback
,
&
m11
);
tup
.
attachPop
(
settempPopCallback
,
&
tup
);
tdown
.
attachPop
(
settempPopCallback
,
&
tdown
);
startimer
.
enable
();
}
}
static
void
temptoLCD
(
int
h
,
int
T1
,
int
T2
)
{
char
valuetemp
[
25
]
=
{
0
};
memset
(
buffer
,
0
,
sizeof
(
buffer
));
itoa
(
T1
,
valuetemp
,
10
);
strcat
(
buffer
,
valuetemp
);
strcat
(
buffer
,
"/"
);
itoa
(
T2
,
valuetemp
,
10
);
strcat
(
buffer
,
valuetemp
);
uint32_t
color
=
1023
;
uint32_t
prc
=
(
T1
/
(
T2
+
0.1
))
*
100
;
if
(
prc
>=
50
&&
prc
<
75
)
color
=
65519
;
else
if
(
prc
>=
75
&&
prc
<
95
)
color
=
64487
;
else
if
(
prc
>=
95
&&
prc
<
100
)
color
=
63488
;
switch
(
h
)
{
case
0
:
{
Hotend0
.
setText
(
buffer
);
Hotend0
.
setColor
(
color
);
Graph0
.
addValue
(
0
,
(
int
)(
T1
*
MaxWave
));
Graph0
.
addValue
(
1
,
(
int
)(
T2
*
MaxWave
));
break
;
}
case
1
:
{
Hotend1
.
setText
(
buffer
);
Hotend1
.
setColor
(
color
);
Graph1
.
addValue
(
0
,
(
int
)(
T1
*
MaxWave
));
Graph1
.
addValue
(
1
,
(
int
)(
T2
*
MaxWave
));
break
;
}
case
2
:
{
Hotend2
.
setText
(
buffer
);
Hotend2
.
setColor
(
color
);
Graph2
.
addValue
(
0
,
(
int
)(
T1
*
MaxWave
));
Graph2
.
addValue
(
1
,
(
int
)(
T2
*
MaxWave
));
break
;
}
}
}
static
void
coordtoLCD
()
{
char
*
valuetemp
;
memset
(
buffer
,
0
,
sizeof
(
buffer
));
strcat
(
buffer
,
"X"
);
if
(
axis_known_position
[
X_AXIS
])
{
#if MECH(DELTA)
valuetemp
=
ftostr30
(
current_position
[
X_AXIS
]);
#else
valuetemp
=
ftostr3
(
current_position
[
X_AXIS
]);
#endif
strcat
(
buffer
,
valuetemp
);
}
else
strcat
(
buffer
,
"---"
);
strcat
(
buffer
,
" Y"
);
if
(
axis_known_position
[
Y_AXIS
])
{
#if MECH(DELTA)
valuetemp
=
ftostr30
(
current_position
[
Y_AXIS
]);
#else
valuetemp
=
ftostr3
(
current_position
[
Y_AXIS
]);
#endif
strcat
(
buffer
,
valuetemp
);
}
else
strcat
(
buffer
,
"---"
);
strcat
(
buffer
,
" Z"
);
if
(
axis_known_position
[
Z_AXIS
])
{
valuetemp
=
ftostr32sp
(
current_position
[
Z_AXIS
]
+
0.00001
);
strcat
(
buffer
,
valuetemp
);
}
else
strcat
(
buffer
,
"---"
);
LedCoord
.
setText
(
buffer
);
}
void
lcd_update
()
{
if
(
!
NextionON
)
return
;
nexLoop
(
nex_listen_list
);
millis_t
ms
=
millis
();
if
(
ms
>
next_lcd_update_ms
&&
PageInfo
)
{
if
(
fanSpeed
>
0
)
fantimer
.
enable
();
else
fantimer
.
disable
();
#if HAS_TEMP_0
temptoLCD
(
0
,
degHotend
(
0
),
degTargetHotend
(
0
));
#endif
#if HAS_TEMP_1
temptoLCD
(
1
,
degHotend
(
1
),
degTargetHotend
(
1
));
#endif
#if HAS_TEMP_2
temptoLCD
(
2
,
degHotend
(
2
),
degTargetHotend
(
2
));
#elif HAS_TEMP_BED
temptoLCD
(
2
,
degBed
(),
degTargetBed
());
#endif
coordtoLCD
();
#if ENABLED(SDSUPPORT)
if
(
card
.
cardOK
)
MSD
.
setPic
(
7
);
else
MSD
.
setPic
(
6
);
#endif
next_lcd_update_ms
=
ms
+
LCD_UPDATE_INTERVAL
;
return_to_status_ms
=
ms
+
30000
;
}
else
if
(
ms
>
return_to_status_ms
&&
!
PageInfo
)
{
setpageInfo
();
}
}
void
lcd_setstatus
(
const
char
*
message
,
bool
persist
)
{
if
(
lcd_status_message_level
>
0
||
!
NextionON
)
return
;
strncpy
(
lcd_status_message
,
message
,
30
);
LedStatus
.
setText
(
lcd_status_message
);
}
void
lcd_setstatuspgm
(
const
char
*
message
,
uint8_t
level
)
{
if
(
level
>=
lcd_status_message_level
&&
NextionON
)
{
strncpy_P
(
lcd_status_message
,
message
,
30
);
lcd_status_message_level
=
level
;
LedStatus
.
setText
(
lcd_status_message
);
}
}
void
lcd_setalertstatuspgm
(
const
char
*
message
)
{
lcd_setstatuspgm
(
message
,
1
);
}
void
lcd_reset_alert_level
()
{
lcd_status_message_level
=
0
;
}
/*********************************/
/** Number to string conversion **/
/*********************************/
char
conv
[
8
];
// Convert float to string with +123.4 format
char
*
ftostr3
(
const
float
&
x
)
{
return
itostr3
((
int
)
x
);
}
// Convert int to string with 12 format
char
*
itostr2
(
const
uint8_t
&
x
)
{
//sprintf(conv,"%5.1f",x);
int
xx
=
x
;
conv
[
0
]
=
(
xx
/
10
)
%
10
+
'0'
;
conv
[
1
]
=
xx
%
10
+
'0'
;
conv
[
2
]
=
0
;
return
conv
;
}
// Convert float to string with +123.4 format
char
*
ftostr31
(
const
float
&
x
)
{
int
xx
=
abs
(
x
*
10
);
conv
[
0
]
=
(
x
>=
0
)
?
'+'
:
'-'
;
conv
[
1
]
=
(
xx
/
1000
)
%
10
+
'0'
;
conv
[
2
]
=
(
xx
/
100
)
%
10
+
'0'
;
conv
[
3
]
=
(
xx
/
10
)
%
10
+
'0'
;
conv
[
4
]
=
'.'
;
conv
[
5
]
=
xx
%
10
+
'0'
;
conv
[
6
]
=
0
;
return
conv
;
}
// Convert float to string with 123.4 format, dropping sign
char
*
ftostr31ns
(
const
float
&
x
)
{
int
xx
=
abs
(
x
*
10
);
conv
[
0
]
=
(
xx
/
1000
)
%
10
+
'0'
;
conv
[
1
]
=
(
xx
/
100
)
%
10
+
'0'
;
conv
[
2
]
=
(
xx
/
10
)
%
10
+
'0'
;
conv
[
3
]
=
'.'
;
conv
[
4
]
=
xx
%
10
+
'0'
;
conv
[
5
]
=
0
;
return
conv
;
}
// Convert float to string with 123.4 format
char
*
ftostr32
(
const
float
&
x
)
{
long
xx
=
abs
(
x
*
100
);
conv
[
0
]
=
x
>=
0
?
(
xx
/
10000
)
%
10
+
'0'
:
'-'
;
conv
[
1
]
=
(
xx
/
1000
)
%
10
+
'0'
;
conv
[
2
]
=
(
xx
/
100
)
%
10
+
'0'
;
conv
[
3
]
=
'.'
;
conv
[
4
]
=
(
xx
/
10
)
%
10
+
'0'
;
conv
[
5
]
=
xx
%
10
+
'0'
;
conv
[
6
]
=
0
;
return
conv
;
}
// Convert float to string with 1.234 format
char
*
ftostr43
(
const
float
&
x
)
{
long
xx
=
x
*
1000
;
if
(
xx
>=
0
)
{
conv
[
0
]
=
(
xx
/
1000
)
%
10
+
'0'
;
}
else
{
conv
[
0
]
=
'-'
;
}
xx
=
abs
(
xx
);
conv
[
1
]
=
'.'
;
conv
[
2
]
=
(
xx
/
100
)
%
10
+
'0'
;
conv
[
3
]
=
(
xx
/
10
)
%
10
+
'0'
;
conv
[
4
]
=
(
xx
)
%
10
+
'0'
;
conv
[
5
]
=
0
;
return
conv
;
}
// Convert float to string with 1.23 format
char
*
ftostr12ns
(
const
float
&
x
)
{
long
xx
=
x
*
100
;
xx
=
abs
(
xx
);
conv
[
0
]
=
(
xx
/
100
)
%
10
+
'0'
;
conv
[
1
]
=
'.'
;
conv
[
2
]
=
(
xx
/
10
)
%
10
+
'0'
;
conv
[
3
]
=
(
xx
)
%
10
+
'0'
;
conv
[
4
]
=
0
;
return
conv
;
}
// Convert float to space-padded string with -_23.4_ format
char
*
ftostr32sp
(
const
float
&
x
)
{
long
xx
=
abs
(
x
*
100
);
uint8_t
dig
;
if
(
x
<
0
)
{
// negative val = -_0
conv
[
0
]
=
'-'
;
dig
=
(
xx
/
1000
)
%
10
;
conv
[
1
]
=
dig
?
'0'
+
dig
:
' '
;
}
else
{
// positive val = __0
dig
=
(
xx
/
10000
)
%
10
;
if
(
dig
)
{
conv
[
0
]
=
'0'
+
dig
;
conv
[
1
]
=
'0'
+
(
xx
/
1000
)
%
10
;
}
else
{
conv
[
0
]
=
' '
;
dig
=
(
xx
/
1000
)
%
10
;
conv
[
1
]
=
dig
?
'0'
+
dig
:
' '
;
}
}
conv
[
2
]
=
'0'
+
(
xx
/
100
)
%
10
;
// lsd always
dig
=
xx
%
10
;
if
(
dig
)
{
// 2 decimal places
conv
[
5
]
=
'0'
+
dig
;
conv
[
4
]
=
'0'
+
(
xx
/
10
)
%
10
;
conv
[
3
]
=
'.'
;
}
else
{
// 1 or 0 decimal place
dig
=
(
xx
/
10
)
%
10
;
if
(
dig
)
{
conv
[
4
]
=
'0'
+
dig
;
conv
[
3
]
=
'.'
;
}
else
{
conv
[
3
]
=
conv
[
4
]
=
' '
;
}
conv
[
5
]
=
' '
;
}
conv
[
6
]
=
'\0'
;
return
conv
;
}
// Convert int to lj string with +123.0 format
char
*
itostr31
(
const
int
&
x
)
{
conv
[
0
]
=
x
>=
0
?
'+'
:
'-'
;
int
xx
=
abs
(
x
);
conv
[
1
]
=
(
xx
/
100
)
%
10
+
'0'
;
conv
[
2
]
=
(
xx
/
10
)
%
10
+
'0'
;
conv
[
3
]
=
xx
%
10
+
'0'
;
conv
[
4
]
=
'.'
;
conv
[
5
]
=
'0'
;
conv
[
6
]
=
0
;
return
conv
;
}
// Convert int to rj string with 123 or -12 format
char
*
itostr3
(
const
int
&
x
)
{
int
xx
=
x
;
if
(
xx
<
0
)
{
conv
[
0
]
=
'-'
;
xx
=
-
xx
;
}
else
conv
[
0
]
=
xx
>=
100
?
(
xx
/
100
)
%
10
+
'0'
:
' '
;
conv
[
1
]
=
xx
>=
10
?
(
xx
/
10
)
%
10
+
'0'
:
' '
;
conv
[
2
]
=
xx
%
10
+
'0'
;
conv
[
3
]
=
0
;
return
conv
;
}
// Convert int to lj string with 123 format
char
*
itostr3left
(
const
int
&
xx
)
{
if
(
xx
>=
100
)
{
conv
[
0
]
=
(
xx
/
100
)
%
10
+
'0'
;
conv
[
1
]
=
(
xx
/
10
)
%
10
+
'0'
;
conv
[
2
]
=
xx
%
10
+
'0'
;
conv
[
3
]
=
0
;
}
else
if
(
xx
>=
10
)
{
conv
[
0
]
=
(
xx
/
10
)
%
10
+
'0'
;
conv
[
1
]
=
xx
%
10
+
'0'
;
conv
[
2
]
=
0
;
}
else
{
conv
[
0
]
=
xx
%
10
+
'0'
;
conv
[
1
]
=
0
;
}
return
conv
;
}
// Convert int to rj string with 1234 format
char
*
itostr4
(
const
int
&
xx
)
{
conv
[
0
]
=
xx
>=
1000
?
(
xx
/
1000
)
%
10
+
'0'
:
' '
;
conv
[
1
]
=
xx
>=
100
?
(
xx
/
100
)
%
10
+
'0'
:
' '
;
conv
[
2
]
=
xx
>=
10
?
(
xx
/
10
)
%
10
+
'0'
:
' '
;
conv
[
3
]
=
xx
%
10
+
'0'
;
conv
[
4
]
=
0
;
return
conv
;
}
char
*
ltostr7
(
const
long
&
xx
)
{
if
(
xx
>=
1000000
)
conv
[
0
]
=
(
xx
/
1000000
)
%
10
+
'0'
;
else
conv
[
0
]
=
' '
;
if
(
xx
>=
100000
)
conv
[
1
]
=
(
xx
/
100000
)
%
10
+
'0'
;
else
conv
[
1
]
=
' '
;
if
(
xx
>=
10000
)
conv
[
2
]
=
(
xx
/
10000
)
%
10
+
'0'
;
else
conv
[
2
]
=
' '
;
if
(
xx
>=
1000
)
conv
[
3
]
=
(
xx
/
1000
)
%
10
+
'0'
;
else
conv
[
3
]
=
' '
;
if
(
xx
>=
100
)
conv
[
4
]
=
(
xx
/
100
)
%
10
+
'0'
;
else
conv
[
4
]
=
' '
;
if
(
xx
>=
10
)
conv
[
5
]
=
(
xx
/
10
)
%
10
+
'0'
;
else
conv
[
5
]
=
' '
;
conv
[
6
]
=
(
xx
)
%
10
+
'0'
;
conv
[
7
]
=
0
;
return
conv
;
}
// convert float to string with +123 format
char
*
ftostr30
(
const
float
&
x
)
{
int
xx
=
x
;
conv
[
0
]
=
(
xx
>=
0
)
?
'+'
:
'-'
;
xx
=
abs
(
xx
);
conv
[
1
]
=
(
xx
/
100
)
%
10
+
'0'
;
conv
[
2
]
=
(
xx
/
10
)
%
10
+
'0'
;
conv
[
3
]
=
(
xx
)
%
10
+
'0'
;
conv
[
4
]
=
0
;
return
conv
;
}
// Convert float to rj string with 12345 format
char
*
ftostr5
(
const
float
&
x
)
{
long
xx
=
abs
(
x
);
conv
[
0
]
=
xx
>=
10000
?
(
xx
/
10000
)
%
10
+
'0'
:
' '
;
conv
[
1
]
=
xx
>=
1000
?
(
xx
/
1000
)
%
10
+
'0'
:
' '
;
conv
[
2
]
=
xx
>=
100
?
(
xx
/
100
)
%
10
+
'0'
:
' '
;
conv
[
3
]
=
xx
>=
10
?
(
xx
/
10
)
%
10
+
'0'
:
' '
;
conv
[
4
]
=
xx
%
10
+
'0'
;
conv
[
5
]
=
0
;
return
conv
;
}
// Convert float to string with +1234.5 format
char
*
ftostr51
(
const
float
&
x
)
{
long
xx
=
abs
(
x
*
10
);
conv
[
0
]
=
(
x
>=
0
)
?
'+'
:
'-'
;
conv
[
1
]
=
(
xx
/
10000
)
%
10
+
'0'
;
conv
[
2
]
=
(
xx
/
1000
)
%
10
+
'0'
;
conv
[
3
]
=
(
xx
/
100
)
%
10
+
'0'
;
conv
[
4
]
=
(
xx
/
10
)
%
10
+
'0'
;
conv
[
5
]
=
'.'
;
conv
[
6
]
=
xx
%
10
+
'0'
;
conv
[
7
]
=
0
;
return
conv
;
}
// Convert float to string with +123.45 format
char
*
ftostr52
(
const
float
&
x
)
{
conv
[
0
]
=
(
x
>=
0
)
?
'+'
:
'-'
;
long
xx
=
abs
(
x
*
100
);
conv
[
1
]
=
(
xx
/
10000
)
%
10
+
'0'
;
conv
[
2
]
=
(
xx
/
1000
)
%
10
+
'0'
;
conv
[
3
]
=
(
xx
/
100
)
%
10
+
'0'
;
conv
[
4
]
=
'.'
;
conv
[
5
]
=
(
xx
/
10
)
%
10
+
'0'
;
conv
[
6
]
=
xx
%
10
+
'0'
;
conv
[
7
]
=
0
;
return
conv
;
}
#endif
MarlinKimbra/nextion_lcd.h
0 → 100644
View file @
3e7df4a6
#ifndef NEXTIONLCD_H
#define NEXTIONLCD_H
#if ENABLED(NEXTION)
#define LCD_UPDATE_INTERVAL 100
void
PstartPopCallback
(
void
*
ptr
);
void
setpagePopCallback
(
void
*
ptr
);
void
hotPopCallback
(
void
*
ptr
);
void
sethotPopCallback
(
void
*
ptr
);
void
settempPopCallback
(
void
*
ptr
);
void
setfanPopCallback
(
void
*
ptr
);
void
lcd_update
();
void
lcd_init
();
void
lcd_setstatus
(
const
char
*
message
,
const
bool
persist
=
false
);
void
lcd_setstatuspgm
(
const
char
*
message
,
const
uint8_t
level
=
0
);
void
lcd_setalertstatuspgm
(
const
char
*
message
);
void
lcd_reset_alert_level
();
#if ENABLED(SDSUPPORT)
void
sdlistPopCallback
(
void
*
ptr
);
void
sdfilePopCallback
(
void
*
ptr
);
void
sdfolderPopCallback
(
void
*
ptr
);
void
sdfolderUpPopCallback
(
void
*
ptr
);
void
ExitUpPopCallback
(
void
*
ptr
);
#endif
FORCE_INLINE
bool
lcd_hasstatus
()
{
return
false
;
}
FORCE_INLINE
void
lcd_buttons_update
()
{}
FORCE_INLINE
bool
lcd_detected
(
void
)
{
return
true
;
}
#define LCD_MESSAGEPGM(x) lcd_setstatuspgm(PSTR(x))
#define LCD_ALERTMESSAGEPGM(x) lcd_setalertstatuspgm(PSTR(x))
char
*
itostr2
(
const
uint8_t
&
x
);
char
*
itostr31
(
const
int
&
xx
);
char
*
itostr3
(
const
int
&
xx
);
char
*
itostr3left
(
const
int
&
xx
);
char
*
itostr4
(
const
int
&
xx
);
char
*
ltostr7
(
const
long
&
xx
);
char
*
ftostr3
(
const
float
&
x
);
char
*
ftostr30
(
const
float
&
x
);
char
*
ftostr31ns
(
const
float
&
x
);
// float to string without sign character
char
*
ftostr31
(
const
float
&
x
);
char
*
ftostr32
(
const
float
&
x
);
char
*
ftostr43
(
const
float
&
x
);
char
*
ftostr12ns
(
const
float
&
x
);
char
*
ftostr32sp
(
const
float
&
x
);
// remove zero-padding from ftostr32
char
*
ftostr5
(
const
float
&
x
);
char
*
ftostr51
(
const
float
&
x
);
char
*
ftostr52
(
const
float
&
x
);
#endif
#endif // NEXTIONLCD_H
\ No newline at end of file
MarlinKimbra/stepper.cpp
View file @
3e7df4a6
...
...
@@ -36,6 +36,7 @@
#include "stepper.h"
#include "temperature.h"
#include "ultralcd.h"
#include "nextion_lcd.h"
#include "language.h"
#if ENABLED(SDSUPPORT)
#include "cardreader.h"
...
...
MarlinKimbra/temperature.cpp
View file @
3e7df4a6
...
...
@@ -24,6 +24,7 @@
#include "vector_3.h"
#endif
#include "ultralcd.h"
#include "nextion_lcd.h"
#include "planner.h"
#include "stepper_indirection.h"
#if MB(ALLIGATOR)
...
...
MarlinKimbra/ultralcd.cpp
View file @
3e7df4a6
#include "base.h"
#if ENABLED(ULTRA_LCD)
...
...
@@ -2375,911 +2374,6 @@ char *ftostr52(const float &x) {
}
#endif
#elif ENABLED(NEXTION)
#include "Marlin_main.h"
#include "cardreader.h"
#include "temperature.h"
#if ENABLED(AUTO_BED_LEVELING_FEATURE)
#include "vector_3.h"
#endif
#include "planner.h"
#include "stepper_indirection.h"
#include "stepper.h"
#include "configuration_store.h"
#include "ultralcd.h"
#include "Nextion.h"
const
float
MaxWave
=
0.2
;
bool
NextionON
=
false
;
bool
PageInfo
=
false
;
char
buffer
[
100
]
=
{
0
};
uint32_t
slidermaxval
=
20
;
char
lcd_status_message
[
30
]
=
WELCOME_MSG
;
// worst case is kana with up to 3*LCD_WIDTH+1
uint8_t
lcd_status_message_level
=
0
;
// Page
NexPage
page0
=
NexPage
(
0
,
0
,
"start"
);
NexPage
page1
=
NexPage
(
1
,
0
,
"info"
);
NexPage
page2
=
NexPage
(
2
,
0
,
"settemp"
);
NexPage
page3
=
NexPage
(
3
,
0
,
"menu"
);
NexPage
page4
=
NexPage
(
4
,
0
,
"sdcard"
);
NexPage
page5
=
NexPage
(
5
,
0
,
"setup"
);
// Text
NexText
Hotend0
=
NexText
(
1
,
1
,
"t0"
);
NexText
Hotend1
=
NexText
(
1
,
4
,
"t1"
);
NexText
Hotend2
=
NexText
(
1
,
5
,
"t2"
);
NexText
Hotend21
=
NexText
(
1
,
6
,
"h2"
);
NexText
LedStatus
=
NexText
(
1
,
7
,
"t4"
);
NexText
LedCoord
=
NexText
(
1
,
8
,
"t5"
);
NexText
set0
=
NexText
(
2
,
2
,
"set0"
);
NexText
set1
=
NexText
(
2
,
15
,
"set1"
);
NexText
sdrow0
=
NexText
(
4
,
3
,
"t0"
);
NexText
sdrow1
=
NexText
(
4
,
4
,
"t1"
);
NexText
sdrow2
=
NexText
(
4
,
5
,
"t2"
);
NexText
sdrow3
=
NexText
(
4
,
6
,
"t3"
);
NexText
sdrow4
=
NexText
(
4
,
7
,
"t4"
);
NexText
sdrow5
=
NexText
(
4
,
8
,
"t5"
);
NexText
sdfolder
=
NexText
(
4
,
23
,
"sdfolder"
);
// Picture
NexPicture
Menu
=
NexPicture
(
1
,
10
,
"p0"
);
NexPicture
MSD
=
NexPicture
(
1
,
11
,
"p1"
);
NexPicture
MSetup
=
NexPicture
(
1
,
12
,
"p2"
);
NexPicture
Hend0
=
NexPicture
(
1
,
13
,
"p3"
);
NexPicture
Hend1
=
NexPicture
(
1
,
14
,
"p4"
);
NexPicture
Hend2
=
NexPicture
(
1
,
15
,
"p5"
);
NexPicture
Fanpic
=
NexPicture
(
1
,
19
,
"p6"
);
NexPicture
Folder0
=
NexPicture
(
4
,
9
,
"p0"
);
NexPicture
Folder1
=
NexPicture
(
4
,
10
,
"p1"
);
NexPicture
Folder2
=
NexPicture
(
4
,
11
,
"p2"
);
NexPicture
Folder3
=
NexPicture
(
4
,
12
,
"p3"
);
NexPicture
Folder4
=
NexPicture
(
4
,
13
,
"p4"
);
NexPicture
Folder5
=
NexPicture
(
4
,
14
,
"p5"
);
NexPicture
Folderup
=
NexPicture
(
4
,
15
,
"p6"
);
NexPicture
Exit
=
NexPicture
(
4
,
16
,
"p7"
);
// Progress Bar
// Slider
NexSlider
sdlist
=
NexSlider
(
4
,
1
,
"h0"
);
// Wafeform
NexWaveform
Graph0
=
NexWaveform
(
1
,
9
,
"s0"
);
NexWaveform
Graph1
=
NexWaveform
(
1
,
24
,
"s1"
);
NexWaveform
Graph2
=
NexWaveform
(
1
,
25
,
"s2"
);
// Touch area
NexHotspot
hot0
=
NexHotspot
(
1
,
14
,
"hot0"
);
NexHotspot
hot1
=
NexHotspot
(
1
,
16
,
"hot1"
);
NexHotspot
hot2
=
NexHotspot
(
1
,
18
,
"hot2"
);
NexHotspot
m11
=
NexHotspot
(
2
,
14
,
"m11"
);
NexHotspot
tup
=
NexHotspot
(
2
,
16
,
"tup"
);
NexHotspot
tdown
=
NexHotspot
(
2
,
17
,
"tdown"
);
// Timer
NexTimer
startimer
=
NexTimer
(
0
,
1
,
"tm0"
);
NexTimer
fantimer
=
NexTimer
(
1
,
23
,
"tm0"
);
// Variable
NexVar
Hotend
=
NexVar
(
1
,
20
,
"he"
);
NexVar
Bed
=
NexVar
(
1
,
21
,
"bed"
);
NexVar
filename0
=
NexVar
(
4
,
19
,
"va0"
);
NexVar
filename1
=
NexVar
(
4
,
20
,
"va1"
);
NexVar
filename2
=
NexVar
(
4
,
21
,
"va2"
);
NexVar
filename3
=
NexVar
(
4
,
22
,
"va3"
);
NexVar
filename4
=
NexVar
(
4
,
23
,
"va4"
);
NexVar
filename5
=
NexVar
(
4
,
24
,
"va5"
);
NexTouch
*
nex_listen_list
[]
=
{
&
page0
,
&
Menu
,
&
MSD
,
&
MSetup
,
&
Fanpic
,
&
hot0
,
&
hot1
,
&
hot2
,
&
m11
,
&
tup
,
&
tdown
,
&
sdlist
,
&
sdrow0
,
&
sdrow1
,
&
sdrow2
,
&
sdrow3
,
&
sdrow4
,
&
sdrow5
,
&
Folderup
,
&
Exit
,
NULL
};
void
setpageInfo
()
{
page1
.
show
();
PageInfo
=
true
;
#if HAS_TEMP_0
Hotend
.
setValue
(
1
);
#endif
#if HAS_TEMP_1
Hotend
.
setValue
(
2
);
#endif
#if HAS_TEMP_2
Hotend
.
setValue
(
3
);
#elif HAS_TEMP_BED
Hotend21
.
setText
(
"BED"
);
Bed
.
setValue
(
1
);
#endif
lcd_setstatus
(
lcd_status_message
);
}
#if ENABLED(SDSUPPORT)
void
printrowsd
(
uint8_t
row
,
const
bool
folder
,
const
char
*
filename
,
char
*
longFilename
)
{
const
char
*
cmd
;
if
(
longFilename
[
0
])
cmd
=
longFilename
;
else
cmd
=
filename
;
switch
(
row
)
{
case
0
:
{
if
(
folder
)
{
Folder0
.
setPic
(
18
);
sdrow0
.
attachPop
(
sdfolderPopCallback
,
&
sdrow0
);
}
else
if
(
cmd
==
""
)
{
Folder0
.
setPic
(
17
);
sdrow0
.
detachPop
();
}
else
{
Folder0
.
setPic
(
17
);
sdrow0
.
attachPop
(
sdfilePopCallback
,
&
sdrow0
);
}
sdrow0
.
setText
(
cmd
);
filename0
.
setText
(
filename
);
}
case
1
:
{
if
(
folder
)
{
Folder1
.
setPic
(
18
);
sdrow1
.
attachPop
(
sdfolderPopCallback
,
&
sdrow1
);
}
else
if
(
cmd
==
""
)
{
Folder1
.
setPic
(
17
);
sdrow1
.
detachPop
();
}
else
{
Folder1
.
setPic
(
17
);
sdrow1
.
attachPop
(
sdfilePopCallback
,
&
sdrow1
);
}
sdrow1
.
setText
(
cmd
);
filename1
.
setText
(
filename
);
}
case
2
:
{
if
(
folder
)
{
Folder2
.
setPic
(
18
);
sdrow2
.
attachPop
(
sdfolderPopCallback
,
&
sdrow2
);
}
else
if
(
cmd
==
""
)
{
Folder2
.
setPic
(
17
);
sdrow2
.
detachPop
();
}
else
{
Folder2
.
setPic
(
17
);
sdrow2
.
attachPop
(
sdfilePopCallback
,
&
sdrow2
);
}
sdrow2
.
setText
(
cmd
);
filename2
.
setText
(
filename
);
}
case
3
:
{
if
(
folder
)
{
Folder3
.
setPic
(
18
);
sdrow3
.
attachPop
(
sdfolderPopCallback
,
&
sdrow3
);
}
else
if
(
cmd
==
""
)
{
Folder3
.
setPic
(
17
);
sdrow3
.
detachPop
();
}
else
{
Folder3
.
setPic
(
17
);
sdrow3
.
attachPop
(
sdfilePopCallback
,
&
sdrow3
);
}
sdrow3
.
setText
(
cmd
);
filename3
.
setText
(
filename
);
}
case
4
:
{
if
(
folder
)
{
Folder4
.
setPic
(
18
);
sdrow4
.
attachPop
(
sdfolderPopCallback
,
&
sdrow4
);
}
else
if
(
cmd
==
""
)
{
Folder4
.
setPic
(
17
);
sdrow4
.
detachPop
();
}
else
{
Folder4
.
setPic
(
17
);
sdrow4
.
attachPop
(
sdfilePopCallback
,
&
sdrow4
);
}
sdrow4
.
setText
(
cmd
);
filename4
.
setText
(
filename
);
}
case
5
:
{
if
(
folder
)
{
Folder5
.
setPic
(
18
);
sdrow5
.
attachPop
(
sdfolderPopCallback
,
&
sdrow5
);
}
else
if
(
cmd
==
""
)
{
Folder5
.
setPic
(
17
);
sdrow5
.
detachPop
();
}
else
{
Folder5
.
setPic
(
17
);
sdrow5
.
attachPop
(
sdfilePopCallback
,
&
sdrow5
);
}
sdrow5
.
setText
(
cmd
);
filename5
.
setText
(
filename
);
}
}
}
static
void
setrowsdcard
(
uint32_t
number
=
0
)
{
uint16_t
fileCnt
=
card
.
getnrfilenames
();
uint32_t
i
=
0
;
card
.
getWorkDirName
();
if
(
card
.
filename
[
0
]
!=
'/'
)
{
Folderup
.
setPic
(
20
);
Folderup
.
attachPop
(
sdfolderUpPopCallback
);
sdfolder
.
setText
(
card
.
filename
);
}
else
{
Folderup
.
detachPop
();
Folderup
.
setPic
(
19
);
sdfolder
.
setText
(
""
);
}
for
(
uint8_t
row
=
0
;
row
<
6
;
row
++
)
{
i
=
row
+
number
;
if
(
i
<
fileCnt
)
{
card
.
getfilename
(
i
);
printrowsd
(
row
,
card
.
filenameIsDir
,
card
.
filename
,
card
.
longFilename
);
}
else
{
printrowsd
(
row
,
false
,
""
,
""
);
}
}
sendCommand
(
"ref 0"
);
}
static
void
setpagesdcard
()
{
PageInfo
=
false
;
page4
.
show
();
uint16_t
fileCnt
=
card
.
getnrfilenames
();
if
(
fileCnt
<=
6
)
slidermaxval
=
0
;
else
slidermaxval
=
fileCnt
-
6
;
uint16_t
hig
=
210
-
slidermaxval
*
10
;
if
(
hig
<
10
)
hig
=
10
;
sdlist
.
setHigValue
(
hig
);
sdlist
.
setMaxValue
(
slidermaxval
);
sdlist
.
setValue
(
slidermaxval
);
sendCommand
(
"ref 0"
);
setrowsdcard
();
}
void
sdlistPopCallback
(
void
*
ptr
)
{
uint32_t
number
=
0
;
sdlist
.
getValue
(
&
number
);
number
=
slidermaxval
-
number
;
setrowsdcard
(
number
);
}
static
void
menu_action_sdfile
(
const
char
*
filename
)
{
char
cmd
[
30
];
char
*
c
;
sprintf_P
(
cmd
,
PSTR
(
"M23 %s"
),
filename
);
for
(
c
=
&
cmd
[
4
];
*
c
;
c
++
)
*
c
=
tolower
(
*
c
);
enqueuecommand
(
cmd
);
enqueuecommands_P
(
PSTR
(
"M24"
));
setpageInfo
();
}
static
void
menu_action_sddirectory
(
const
char
*
filename
)
{
card
.
chdir
(
filename
);
setpagesdcard
();
}
void
sdfilePopCallback
(
void
*
ptr
)
{
memset
(
buffer
,
0
,
sizeof
(
buffer
));
if
(
ptr
==
&
sdrow0
)
filename0
.
getText
(
buffer
,
sizeof
(
buffer
));
else
if
(
ptr
==
&
sdrow1
)
filename1
.
getText
(
buffer
,
sizeof
(
buffer
));
else
if
(
ptr
==
&
sdrow2
)
filename2
.
getText
(
buffer
,
sizeof
(
buffer
));
else
if
(
ptr
==
&
sdrow3
)
filename3
.
getText
(
buffer
,
sizeof
(
buffer
));
else
if
(
ptr
==
&
sdrow4
)
filename4
.
getText
(
buffer
,
sizeof
(
buffer
));
else
if
(
ptr
==
&
sdrow5
)
filename5
.
getText
(
buffer
,
sizeof
(
buffer
));
menu_action_sdfile
(
buffer
);
}
void
sdfolderPopCallback
(
void
*
ptr
)
{
memset
(
buffer
,
0
,
sizeof
(
buffer
));
if
(
ptr
==
&
sdrow0
)
filename0
.
getText
(
buffer
,
sizeof
(
buffer
));
else
if
(
ptr
==
&
sdrow1
)
filename1
.
getText
(
buffer
,
sizeof
(
buffer
));
else
if
(
ptr
==
&
sdrow2
)
filename2
.
getText
(
buffer
,
sizeof
(
buffer
));
else
if
(
ptr
==
&
sdrow3
)
filename3
.
getText
(
buffer
,
sizeof
(
buffer
));
else
if
(
ptr
==
&
sdrow4
)
filename4
.
getText
(
buffer
,
sizeof
(
buffer
));
else
if
(
ptr
==
&
sdrow5
)
filename5
.
getText
(
buffer
,
sizeof
(
buffer
));
menu_action_sddirectory
(
buffer
);
}
void
sdfolderUpPopCallback
(
void
*
ptr
)
{
card
.
updir
();
setpagesdcard
();
}
void
ExitPopCallback
(
void
*
ptr
)
{
setpageInfo
();
}
#endif
void
page0PopCallback
(
void
*
ptr
)
{
setpageInfo
();
}
void
hotPopCallback
(
void
*
ptr
)
{
page2
.
show
();
PageInfo
=
false
;
memset
(
buffer
,
0
,
sizeof
(
buffer
));
if
(
ptr
==
&
hot0
)
{
if
(
degTargetHotend
(
0
)
!=
0
)
{
itoa
(
degTargetHotend
(
0
),
buffer
,
10
);
}
set1
.
setText
(
"M104 T0 S"
);
}
if
(
ptr
==
&
hot1
)
{
if
(
degTargetHotend
(
1
)
!=
0
)
{
itoa
(
degTargetHotend
(
1
),
buffer
,
10
);
}
set1
.
setText
(
"M104 T1 S"
);
}
#if HAS_TEMP_2
if
(
ptr
==
&
hot2
)
{
if
(
degTargetHotend
(
2
)
!=
0
)
{
itoa
(
degTargetHotend
(
2
),
buffer
,
10
);
}
set1
.
setText
(
"M104 T2 S"
);
}
#elif HAS_TEMP_BED
if
(
ptr
==
&
hot2
)
{
if
(
degTargetBed
()
!=
0
)
{
itoa
(
degTargetBed
(),
buffer
,
10
);
}
set1
.
setText
(
"M140 S"
);
}
#endif
set0
.
setText
(
buffer
);
}
void
settempPopCallback
(
void
*
ptr
)
{
uint16_t
number
;
memset
(
buffer
,
0
,
sizeof
(
buffer
));
set0
.
getText
(
buffer
,
sizeof
(
buffer
));
number
=
atoi
(
buffer
);
if
(
ptr
==
&
tup
)
number
+=
1
;
if
(
ptr
==
&
tdown
)
number
-=
1
;
memset
(
buffer
,
0
,
sizeof
(
buffer
));
itoa
(
number
,
buffer
,
10
);
set0
.
setText
(
buffer
);
}
void
sethotPopCallback
(
void
*
ptr
)
{
memset
(
buffer
,
0
,
sizeof
(
buffer
));
set1
.
getText
(
buffer
,
sizeof
(
buffer
));
enqueuecommands_P
(
buffer
);
setpageInfo
();
}
void
setpagePopCallback
(
void
*
ptr
)
{
if
(
ptr
==
&
Menu
)
sendCommand
(
"page menu"
);
if
(
ptr
==
&
MSetup
)
sendCommand
(
"page setup"
);
#if ENABLED(SDSUPPORT)
if
(
ptr
==
&
MSD
)
setpagesdcard
();
#endif
}
void
setfanPopCallback
(
void
*
ptr
)
{
if
(
fanSpeed
)
fanSpeed
=
0
;
else
fanSpeed
=
255
;
}
millis_t
next_lcd_update_ms
;
void
lcd_init
()
{
NextionON
=
nexInit
();
if
(
!
NextionON
)
{
ECHO_LM
(
DB
,
"Nextion LCD not connected!"
);
}
else
{
ECHO_LM
(
DB
,
"Nextion LCD connected!"
);
page0
.
attachPop
(
page0PopCallback
);
#if ENABLED(SDSUPPORT)
MSD
.
attachPop
(
setpagePopCallback
,
&
MSD
);
sdlist
.
attachPop
(
sdlistPopCallback
);
Exit
.
attachPop
(
ExitPopCallback
);
#endif
#if HAS_TEMP_0
hot0
.
attachPop
(
hotPopCallback
,
&
hot0
);
#endif
#if HAS_TEMP_1
hot1
.
attachPop
(
hotPopCallback
,
&
hot1
);
#endif
#if HAS_TEMP_2 || HAS_TEMP_BED
hot2
.
attachPop
(
hotPopCallback
,
&
hot2
);
#endif
Menu
.
attachPop
(
setpagePopCallback
,
&
Menu
);
MSetup
.
attachPop
(
setpagePopCallback
,
&
Menu
);
Fanpic
.
attachPop
(
setfanPopCallback
,
&
Fanpic
);
m11
.
attachPop
(
sethotPopCallback
,
&
m11
);
tup
.
attachPop
(
settempPopCallback
,
&
tup
);
tdown
.
attachPop
(
settempPopCallback
,
&
tdown
);
startimer
.
enable
();
}
}
static
void
temptoLCD
(
int
h
,
int
T1
,
int
T2
)
{
char
valuetemp
[
25
]
=
{
0
};
memset
(
buffer
,
0
,
sizeof
(
buffer
));
itoa
(
T1
,
valuetemp
,
10
);
strcat
(
buffer
,
valuetemp
);
strcat
(
buffer
,
"/"
);
itoa
(
T2
,
valuetemp
,
10
);
strcat
(
buffer
,
valuetemp
);
uint32_t
color
=
1023
;
uint32_t
prc
=
(
T1
/
(
T2
+
0.1
))
*
100
;
if
(
prc
>=
50
&&
prc
<
75
)
color
=
65519
;
else
if
(
prc
>=
75
&&
prc
<
95
)
color
=
64487
;
else
if
(
prc
>=
95
&&
prc
<
100
)
color
=
63488
;
switch
(
h
)
{
case
0
:
{
Hotend0
.
setText
(
buffer
);
Hotend0
.
setColor
(
color
);
Graph0
.
addValue
(
0
,
(
int
)(
T1
*
MaxWave
));
Graph0
.
addValue
(
1
,
(
int
)(
T2
*
MaxWave
));
break
;
}
case
1
:
{
Hotend1
.
setText
(
buffer
);
Hotend1
.
setColor
(
color
);
Graph1
.
addValue
(
0
,
(
int
)(
T1
*
MaxWave
));
Graph1
.
addValue
(
1
,
(
int
)(
T2
*
MaxWave
));
break
;
}
case
2
:
{
Hotend2
.
setText
(
buffer
);
Hotend2
.
setColor
(
color
);
Graph2
.
addValue
(
0
,
(
int
)(
T1
*
MaxWave
));
Graph2
.
addValue
(
1
,
(
int
)(
T2
*
MaxWave
));
break
;
}
}
}
static
void
coordtoLCD
()
{
char
*
valuetemp
;
memset
(
buffer
,
0
,
sizeof
(
buffer
));
strcat
(
buffer
,
"X"
);
if
(
axis_known_position
[
X_AXIS
])
{
#if MECH(DELTA)
valuetemp
=
ftostr30
(
current_position
[
X_AXIS
]);
#else
valuetemp
=
ftostr3
(
current_position
[
X_AXIS
]);
#endif
strcat
(
buffer
,
valuetemp
);
}
else
strcat
(
buffer
,
"---"
);
strcat
(
buffer
,
" Y"
);
if
(
axis_known_position
[
Y_AXIS
])
{
#if MECH(DELTA)
valuetemp
=
ftostr30
(
current_position
[
Y_AXIS
]);
#else
valuetemp
=
ftostr3
(
current_position
[
Y_AXIS
]);
#endif
strcat
(
buffer
,
valuetemp
);
}
else
strcat
(
buffer
,
"---"
);
strcat
(
buffer
,
" Z"
);
if
(
axis_known_position
[
Z_AXIS
])
{
valuetemp
=
ftostr32sp
(
current_position
[
Z_AXIS
]
+
0.00001
);
strcat
(
buffer
,
valuetemp
);
}
else
strcat
(
buffer
,
"---"
);
LedCoord
.
setText
(
buffer
);
}
void
lcd_update
()
{
if
(
!
NextionON
)
return
;
nexLoop
(
nex_listen_list
);
millis_t
ms
=
millis
();
if
(
ms
>
next_lcd_update_ms
&&
PageInfo
)
{
if
(
fanSpeed
>
0
)
fantimer
.
enable
();
else
fantimer
.
disable
();
#if HAS_TEMP_0
temptoLCD
(
0
,
degHotend
(
0
),
degTargetHotend
(
0
));
#endif
#if HAS_TEMP_1
temptoLCD
(
1
,
degHotend
(
1
),
degTargetHotend
(
1
));
#endif
#if HAS_TEMP_2
temptoLCD
(
2
,
degHotend
(
2
),
degTargetHotend
(
2
));
#elif HAS_TEMP_BED
temptoLCD
(
2
,
degBed
(),
degTargetBed
());
#endif
coordtoLCD
();
#if ENABLED(SDSUPPORT)
if
(
card
.
cardOK
)
MSD
.
setPic
(
7
);
else
MSD
.
setPic
(
6
);
#endif
next_lcd_update_ms
=
ms
+
LCD_UPDATE_INTERVAL
;
}
}
void
lcd_setstatus
(
const
char
*
message
,
bool
persist
)
{
if
(
lcd_status_message_level
>
0
||
!
NextionON
)
return
;
strncpy
(
lcd_status_message
,
message
,
30
);
LedStatus
.
setText
(
lcd_status_message
);
}
void
lcd_setstatuspgm
(
const
char
*
message
,
uint8_t
level
)
{
if
(
level
>=
lcd_status_message_level
&&
NextionON
)
{
strncpy_P
(
lcd_status_message
,
message
,
30
);
lcd_status_message_level
=
level
;
LedStatus
.
setText
(
lcd_status_message
);
}
}
void
lcd_setalertstatuspgm
(
const
char
*
message
)
{
lcd_setstatuspgm
(
message
,
1
);
}
void
lcd_reset_alert_level
()
{
lcd_status_message_level
=
0
;
}
/*********************************/
/** Number to string conversion **/
/*********************************/
char
conv
[
8
];
// Convert float to string with +123.4 format
char
*
ftostr3
(
const
float
&
x
)
{
return
itostr3
((
int
)
x
);
}
// Convert int to string with 12 format
char
*
itostr2
(
const
uint8_t
&
x
)
{
//sprintf(conv,"%5.1f",x);
int
xx
=
x
;
conv
[
0
]
=
(
xx
/
10
)
%
10
+
'0'
;
conv
[
1
]
=
xx
%
10
+
'0'
;
conv
[
2
]
=
0
;
return
conv
;
}
// Convert float to string with +123.4 format
char
*
ftostr31
(
const
float
&
x
)
{
int
xx
=
abs
(
x
*
10
);
conv
[
0
]
=
(
x
>=
0
)
?
'+'
:
'-'
;
conv
[
1
]
=
(
xx
/
1000
)
%
10
+
'0'
;
conv
[
2
]
=
(
xx
/
100
)
%
10
+
'0'
;
conv
[
3
]
=
(
xx
/
10
)
%
10
+
'0'
;
conv
[
4
]
=
'.'
;
conv
[
5
]
=
xx
%
10
+
'0'
;
conv
[
6
]
=
0
;
return
conv
;
}
// Convert float to string with 123.4 format, dropping sign
char
*
ftostr31ns
(
const
float
&
x
)
{
int
xx
=
abs
(
x
*
10
);
conv
[
0
]
=
(
xx
/
1000
)
%
10
+
'0'
;
conv
[
1
]
=
(
xx
/
100
)
%
10
+
'0'
;
conv
[
2
]
=
(
xx
/
10
)
%
10
+
'0'
;
conv
[
3
]
=
'.'
;
conv
[
4
]
=
xx
%
10
+
'0'
;
conv
[
5
]
=
0
;
return
conv
;
}
// Convert float to string with 123.4 format
char
*
ftostr32
(
const
float
&
x
)
{
long
xx
=
abs
(
x
*
100
);
conv
[
0
]
=
x
>=
0
?
(
xx
/
10000
)
%
10
+
'0'
:
'-'
;
conv
[
1
]
=
(
xx
/
1000
)
%
10
+
'0'
;
conv
[
2
]
=
(
xx
/
100
)
%
10
+
'0'
;
conv
[
3
]
=
'.'
;
conv
[
4
]
=
(
xx
/
10
)
%
10
+
'0'
;
conv
[
5
]
=
xx
%
10
+
'0'
;
conv
[
6
]
=
0
;
return
conv
;
}
// Convert float to string with 1.234 format
char
*
ftostr43
(
const
float
&
x
)
{
long
xx
=
x
*
1000
;
if
(
xx
>=
0
)
{
conv
[
0
]
=
(
xx
/
1000
)
%
10
+
'0'
;
}
else
{
conv
[
0
]
=
'-'
;
}
xx
=
abs
(
xx
);
conv
[
1
]
=
'.'
;
conv
[
2
]
=
(
xx
/
100
)
%
10
+
'0'
;
conv
[
3
]
=
(
xx
/
10
)
%
10
+
'0'
;
conv
[
4
]
=
(
xx
)
%
10
+
'0'
;
conv
[
5
]
=
0
;
return
conv
;
}
// Convert float to string with 1.23 format
char
*
ftostr12ns
(
const
float
&
x
)
{
long
xx
=
x
*
100
;
xx
=
abs
(
xx
);
conv
[
0
]
=
(
xx
/
100
)
%
10
+
'0'
;
conv
[
1
]
=
'.'
;
conv
[
2
]
=
(
xx
/
10
)
%
10
+
'0'
;
conv
[
3
]
=
(
xx
)
%
10
+
'0'
;
conv
[
4
]
=
0
;
return
conv
;
}
// Convert float to space-padded string with -_23.4_ format
char
*
ftostr32sp
(
const
float
&
x
)
{
long
xx
=
abs
(
x
*
100
);
uint8_t
dig
;
if
(
x
<
0
)
{
// negative val = -_0
conv
[
0
]
=
'-'
;
dig
=
(
xx
/
1000
)
%
10
;
conv
[
1
]
=
dig
?
'0'
+
dig
:
' '
;
}
else
{
// positive val = __0
dig
=
(
xx
/
10000
)
%
10
;
if
(
dig
)
{
conv
[
0
]
=
'0'
+
dig
;
conv
[
1
]
=
'0'
+
(
xx
/
1000
)
%
10
;
}
else
{
conv
[
0
]
=
' '
;
dig
=
(
xx
/
1000
)
%
10
;
conv
[
1
]
=
dig
?
'0'
+
dig
:
' '
;
}
}
conv
[
2
]
=
'0'
+
(
xx
/
100
)
%
10
;
// lsd always
dig
=
xx
%
10
;
if
(
dig
)
{
// 2 decimal places
conv
[
5
]
=
'0'
+
dig
;
conv
[
4
]
=
'0'
+
(
xx
/
10
)
%
10
;
conv
[
3
]
=
'.'
;
}
else
{
// 1 or 0 decimal place
dig
=
(
xx
/
10
)
%
10
;
if
(
dig
)
{
conv
[
4
]
=
'0'
+
dig
;
conv
[
3
]
=
'.'
;
}
else
{
conv
[
3
]
=
conv
[
4
]
=
' '
;
}
conv
[
5
]
=
' '
;
}
conv
[
6
]
=
'\0'
;
return
conv
;
}
// Convert int to lj string with +123.0 format
char
*
itostr31
(
const
int
&
x
)
{
conv
[
0
]
=
x
>=
0
?
'+'
:
'-'
;
int
xx
=
abs
(
x
);
conv
[
1
]
=
(
xx
/
100
)
%
10
+
'0'
;
conv
[
2
]
=
(
xx
/
10
)
%
10
+
'0'
;
conv
[
3
]
=
xx
%
10
+
'0'
;
conv
[
4
]
=
'.'
;
conv
[
5
]
=
'0'
;
conv
[
6
]
=
0
;
return
conv
;
}
// Convert int to rj string with 123 or -12 format
char
*
itostr3
(
const
int
&
x
)
{
int
xx
=
x
;
if
(
xx
<
0
)
{
conv
[
0
]
=
'-'
;
xx
=
-
xx
;
}
else
conv
[
0
]
=
xx
>=
100
?
(
xx
/
100
)
%
10
+
'0'
:
' '
;
conv
[
1
]
=
xx
>=
10
?
(
xx
/
10
)
%
10
+
'0'
:
' '
;
conv
[
2
]
=
xx
%
10
+
'0'
;
conv
[
3
]
=
0
;
return
conv
;
}
// Convert int to lj string with 123 format
char
*
itostr3left
(
const
int
&
xx
)
{
if
(
xx
>=
100
)
{
conv
[
0
]
=
(
xx
/
100
)
%
10
+
'0'
;
conv
[
1
]
=
(
xx
/
10
)
%
10
+
'0'
;
conv
[
2
]
=
xx
%
10
+
'0'
;
conv
[
3
]
=
0
;
}
else
if
(
xx
>=
10
)
{
conv
[
0
]
=
(
xx
/
10
)
%
10
+
'0'
;
conv
[
1
]
=
xx
%
10
+
'0'
;
conv
[
2
]
=
0
;
}
else
{
conv
[
0
]
=
xx
%
10
+
'0'
;
conv
[
1
]
=
0
;
}
return
conv
;
}
// Convert int to rj string with 1234 format
char
*
itostr4
(
const
int
&
xx
)
{
conv
[
0
]
=
xx
>=
1000
?
(
xx
/
1000
)
%
10
+
'0'
:
' '
;
conv
[
1
]
=
xx
>=
100
?
(
xx
/
100
)
%
10
+
'0'
:
' '
;
conv
[
2
]
=
xx
>=
10
?
(
xx
/
10
)
%
10
+
'0'
:
' '
;
conv
[
3
]
=
xx
%
10
+
'0'
;
conv
[
4
]
=
0
;
return
conv
;
}
char
*
ltostr7
(
const
long
&
xx
)
{
if
(
xx
>=
1000000
)
conv
[
0
]
=
(
xx
/
1000000
)
%
10
+
'0'
;
else
conv
[
0
]
=
' '
;
if
(
xx
>=
100000
)
conv
[
1
]
=
(
xx
/
100000
)
%
10
+
'0'
;
else
conv
[
1
]
=
' '
;
if
(
xx
>=
10000
)
conv
[
2
]
=
(
xx
/
10000
)
%
10
+
'0'
;
else
conv
[
2
]
=
' '
;
if
(
xx
>=
1000
)
conv
[
3
]
=
(
xx
/
1000
)
%
10
+
'0'
;
else
conv
[
3
]
=
' '
;
if
(
xx
>=
100
)
conv
[
4
]
=
(
xx
/
100
)
%
10
+
'0'
;
else
conv
[
4
]
=
' '
;
if
(
xx
>=
10
)
conv
[
5
]
=
(
xx
/
10
)
%
10
+
'0'
;
else
conv
[
5
]
=
' '
;
conv
[
6
]
=
(
xx
)
%
10
+
'0'
;
conv
[
7
]
=
0
;
return
conv
;
}
// convert float to string with +123 format
char
*
ftostr30
(
const
float
&
x
)
{
int
xx
=
x
;
conv
[
0
]
=
(
xx
>=
0
)
?
'+'
:
'-'
;
xx
=
abs
(
xx
);
conv
[
1
]
=
(
xx
/
100
)
%
10
+
'0'
;
conv
[
2
]
=
(
xx
/
10
)
%
10
+
'0'
;
conv
[
3
]
=
(
xx
)
%
10
+
'0'
;
conv
[
4
]
=
0
;
return
conv
;
}
// Convert float to rj string with 12345 format
char
*
ftostr5
(
const
float
&
x
)
{
long
xx
=
abs
(
x
);
conv
[
0
]
=
xx
>=
10000
?
(
xx
/
10000
)
%
10
+
'0'
:
' '
;
conv
[
1
]
=
xx
>=
1000
?
(
xx
/
1000
)
%
10
+
'0'
:
' '
;
conv
[
2
]
=
xx
>=
100
?
(
xx
/
100
)
%
10
+
'0'
:
' '
;
conv
[
3
]
=
xx
>=
10
?
(
xx
/
10
)
%
10
+
'0'
:
' '
;
conv
[
4
]
=
xx
%
10
+
'0'
;
conv
[
5
]
=
0
;
return
conv
;
}
// Convert float to string with +1234.5 format
char
*
ftostr51
(
const
float
&
x
)
{
long
xx
=
abs
(
x
*
10
);
conv
[
0
]
=
(
x
>=
0
)
?
'+'
:
'-'
;
conv
[
1
]
=
(
xx
/
10000
)
%
10
+
'0'
;
conv
[
2
]
=
(
xx
/
1000
)
%
10
+
'0'
;
conv
[
3
]
=
(
xx
/
100
)
%
10
+
'0'
;
conv
[
4
]
=
(
xx
/
10
)
%
10
+
'0'
;
conv
[
5
]
=
'.'
;
conv
[
6
]
=
xx
%
10
+
'0'
;
conv
[
7
]
=
0
;
return
conv
;
}
// Convert float to string with +123.45 format
char
*
ftostr52
(
const
float
&
x
)
{
conv
[
0
]
=
(
x
>=
0
)
?
'+'
:
'-'
;
long
xx
=
abs
(
x
*
100
);
conv
[
1
]
=
(
xx
/
10000
)
%
10
+
'0'
;
conv
[
2
]
=
(
xx
/
1000
)
%
10
+
'0'
;
conv
[
3
]
=
(
xx
/
100
)
%
10
+
'0'
;
conv
[
4
]
=
'.'
;
conv
[
5
]
=
(
xx
/
10
)
%
10
+
'0'
;
conv
[
6
]
=
xx
%
10
+
'0'
;
conv
[
7
]
=
0
;
return
conv
;
}
#endif //ULTRA_LCD
#if ENABLED(SDSUPPORT) && ENABLED(SD_SETTINGS)
...
...
MarlinKimbra/ultralcd.h
View file @
3e7df4a6
...
...
@@ -109,39 +109,28 @@
#define LCD_CLICKED ((buttons&B_MI)||(buttons&B_ST))
#endif//NEWPANEL
#elif ENABLED(NEXTION)
char
*
itostr2
(
const
uint8_t
&
x
);
char
*
itostr31
(
const
int
&
xx
);
char
*
itostr3
(
const
int
&
xx
);
char
*
itostr3left
(
const
int
&
xx
);
char
*
itostr4
(
const
int
&
xx
);
char
*
ltostr7
(
const
long
&
xx
);
char
*
ftostr3
(
const
float
&
x
);
char
*
ftostr30
(
const
float
&
x
);
char
*
ftostr31ns
(
const
float
&
x
);
// float to string without sign character
char
*
ftostr31
(
const
float
&
x
);
char
*
ftostr32
(
const
float
&
x
);
char
*
ftostr43
(
const
float
&
x
);
char
*
ftostr12ns
(
const
float
&
x
);
char
*
ftostr32sp
(
const
float
&
x
);
// remove zero-padding from ftostr32
char
*
ftostr5
(
const
float
&
x
);
char
*
ftostr51
(
const
float
&
x
);
char
*
ftostr52
(
const
float
&
x
);
#elif DISABLED(NEXTION)
#define LCD_UPDATE_INTERVAL 100
void
page0PopCallback
(
void
*
ptr
);
void
setpagePopCallback
(
void
*
ptr
);
void
hotPopCallback
(
void
*
ptr
);
void
sethotPopCallback
(
void
*
ptr
);
void
settempPopCallback
(
void
*
ptr
);
void
setfanPopCallback
(
void
*
ptr
);
void
lcd_update
();
void
lcd_init
();
void
lcd_setstatus
(
const
char
*
message
,
const
bool
persist
=
false
);
void
lcd_setstatuspgm
(
const
char
*
message
,
const
uint8_t
level
=
0
);
void
lcd_setalertstatuspgm
(
const
char
*
message
);
void
lcd_reset_alert_level
();
#if ENABLED(SDSUPPORT)
void
sdlistPopCallback
(
void
*
ptr
);
void
sdfilePopCallback
(
void
*
ptr
);
void
sdfolderPopCallback
(
void
*
ptr
);
void
sdfolderUpPopCallback
(
void
*
ptr
);
void
ExitUpPopCallback
(
void
*
ptr
);
#endif
FORCE_INLINE
bool
lcd_hasstatus
()
{
return
false
;
}
FORCE_INLINE
void
lcd_buttons_update
()
{}
FORCE_INLINE
bool
lcd_detected
(
void
)
{
return
true
;
}
#define LCD_MESSAGEPGM(x) lcd_setstatuspgm(PSTR(x))
#define LCD_ALERTMESSAGEPGM(x) lcd_setalertstatuspgm(PSTR(x))
#else //no LCD
FORCE_INLINE
void
lcd_update
()
{}
FORCE_INLINE
void
lcd_init
()
{}
FORCE_INLINE
bool
lcd_hasstatus
()
{
return
false
;
}
...
...
@@ -161,24 +150,4 @@
extern
void
unset_sd_dot
();
#endif
char
*
itostr2
(
const
uint8_t
&
x
);
char
*
itostr31
(
const
int
&
xx
);
char
*
itostr3
(
const
int
&
xx
);
char
*
itostr3left
(
const
int
&
xx
);
char
*
itostr4
(
const
int
&
xx
);
char
*
ltostr7
(
const
long
&
xx
);
char
*
ftostr3
(
const
float
&
x
);
char
*
ftostr30
(
const
float
&
x
);
char
*
ftostr31ns
(
const
float
&
x
);
// float to string without sign character
char
*
ftostr31
(
const
float
&
x
);
char
*
ftostr32
(
const
float
&
x
);
char
*
ftostr43
(
const
float
&
x
);
char
*
ftostr12ns
(
const
float
&
x
);
char
*
ftostr32sp
(
const
float
&
x
);
// remove zero-padding from ftostr32
char
*
ftostr5
(
const
float
&
x
);
char
*
ftostr51
(
const
float
&
x
);
char
*
ftostr52
(
const
float
&
x
);
#endif //ULTRALCD_H
#endif // ULTRALCD_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