Commit e92e02e0 authored by Simone Primarosa's avatar Simone Primarosa

Merge pull request #1 from MagoKimbra/master

Update 4.1.4 dev
parents 1bee3854 b5c2d02a
......@@ -18,7 +18,7 @@ If jumping the arduino Vcc do RAMPS 5V rail, take care to not use a power hungry
Instructions for Both Options
-----------------------------
Uncomment the "ENABLE_AUTO_BED_LEVELING" define (commented by default)
Uncomment the "AUTO_BED_LEVELING_FEATURE" define (commented by default)
The following options define the probing positions. These are good starting values.
I recommend to keep a better clearance from borders in the first run and then make the probes as close as possible to borders:
......@@ -52,9 +52,14 @@ In order to get the servo working, you need to enable:
* \#define NUM_SERVOS 1 // Servo index starts with 0 for M280 command
* \#define SERVO_ENDSTOPS {-1, -1, 0} // Servo index for X, Y, Z. Disable with -1
* \// Define nr servo for endstop -1 not define. Servo index start 0
* \#define X_ENDSTOP_SERVO_NR -1
* \#define Y_ENDSTOP_SERVO_NR -1
* \#define Z_ENDSTOP_SERVO_NR 0
* \#define SERVO_ENDSTOP_ANGLES {0,0, 0,0, 165,60} // X,Y,Z Axis Extend and Retract angles
* \#define X_ENDSTOP_SERVO_ANGLES {0,0} // X Axis Extend and Retract angles
* \#define Y_ENDSTOP_SERVO_ANGLES {0,0} // Y Axis Extend and Retract angles
* \#define Z_ENDSTOP_SERVO_ANGLES {90,0} // Z Axis Extend and Retract angles
The first define tells firmware how many servos you have.
The second tells what axis this servo will be attached to. In the example above, we have a servo in Z axis.
......
......@@ -12,8 +12,7 @@
* G28 - X0 Y0 Z0 Home all Axis. G28 M for bed manual setting with LCD.
* G29 - Detailed Z-Probe, probes the bed at 3 points or grid. You must be at the home position for this to work correctly.
G29 Fyyy Lxxx Rxxx Byyy for customer grid.
* G30 - Single Z Probe, probes bed at current XY location.
Bed Probe and Delta geometry Autocalibration G30 A
* G30 - Single Z Probe, probes bed at current XY location. Bed Probe and Delta geometry Autocalibration G30 A
* G31 - Dock Z Probe sled (if enabled)
* G32 - Undock Z Probe sled (if enabled)
* G60 - Save current position coordinates (all axes, for active extruder). S<SLOT> - specifies memory slot # (0-based) to save into (default 0).
......@@ -60,7 +59,7 @@
* M109 - S[xxx] Wait for extruder current temp to reach target temp. Waits only when heating - R[xxx] Wait for extruder current temp to reach target temp. Waits when heating and cooling
* M111 - Debug Dryrun Repetier
* M112 - Emergency stop
* M114 - Output current position to serial port, (V)erbose for user
* M114 - Output current position to serial port, (V)erbose for user
* M115 - Capabilities string
* M117 - display message
* M119 - Output Endstop status to serial port
......@@ -100,8 +99,8 @@
* M405 - Turn on Filament Sensor extrusion control. Optional D[delay in cm] to set delay in centimeters between sensor and extruder
* M406 - Turn off Filament Sensor extrusion control
* M407 - Displays measured filament diameter
* M410 - Quickstop. Abort all the planned moves
* M428 - Set the home_offset logically based on the current_position
* M410 - Quickstop. Abort all the planned moves
* M428 - Set the home_offset logically based on the current_position
* M500 - stores paramters in EEPROM
* M501 - reads parameters from EEPROM (if you need reset them after you changed them temporarily).
* M502 - reverts to the default "factory settings". You still need to store them in EEPROM afterwards if you want to.
......
### Version 4.1.4
* Add support for Piggy Alligator board
* Add Debug_info. Repetier button info for enabled or disabled, or M111 S2 for enabled and M111 S0 for disabled.
* Improved Topography Auto Bed Level.
* Add Dryrun ABL and verbose width command G29 D or G29 V(0-4).
* Improve Autoconfiguration for Delta printer.
* Add support (test only) for NEXTION HMI LCD.
* Improved firmare test dialog.
* Bugfix for SDCONFIG routine. Now the configuration file will be readed and created only on the root of the SD.
* Improved "Thermal Runaway Protection" now the system will be halted also if the thermistor is missing before the temperature is reached as suggested in Issue #35.
......
......@@ -3,6 +3,7 @@
#include "boards.h"
#include "macros.h"
#include "Default_Version.h"
//===========================================================================
//============================= Getting Started =============================
......@@ -28,11 +29,10 @@
// User-specified version info of this build to display in [Pronterface, etc] terminal window during
// startup. Implementation of an idea by Prof Braino to inform user that any changes made to this
// build by the user have been successfully uploaded into firmware.
#define BUILD_VERSION "4.1.4 dev"
#define STRING_DISTRIBUTION_DATE __DATE__ " " __TIME__ // build date and time
#define STRING_CONFIG_H_AUTHOR "(none, default config)" // Who made the changes.
#define STRING_SPLASH_LINE1 "v" BUILD_VERSION // will be shown during bootup in line 1
#define STRING_SPLASH_LINE2 STRING_DISTRIBUTION_DATE // will be shown during bootup in line 2
#define SHOW_BOOTSCREEN
#define STRING_SPLASH_LINE1 "v" SHORT_BUILD_VERSION // will be shown during bootup in line 1
//#define STRING_SPLASH_LINE2 STRING_DISTRIBUTION_DATE // will be shown during bootup in line 2
// SERIAL_PORT selects which serial port should be used for communication with the host.
// This allows the connection of wireless adapters (for instance) to non-default port pins.
......@@ -43,8 +43,8 @@
// 2400,9600,19200,38400,57600,115200,250000
#define BAUDRATE 115200
// This enables the serial port associated to the Bluetooth interface on AT90USB devices
//#define BTENABLED
// Enable the Bluetooth serial interface on AT90USB devices
//#define BLUETOOTH
// Define this to set a unique identifier for this printer, (Used by some programs to differentiate between machines)
// You can use an online service to generate a random UUID. (eg http://www.uuidgenerator.net/version4)
......@@ -425,7 +425,6 @@
/**
* Nextion HMI panel
*/
//
//#define NEXTION
// option for invert rotary switch
......
......@@ -14,9 +14,11 @@
//#define ENDSTOPPULLUP_XMIN
//#define ENDSTOPPULLUP_YMIN
//#define ENDSTOPPULLUP_ZMIN
//#define ENDSTOPPULLUP_Z2MIN
//#define ENDSTOPPULLUP_XMAX
//#define ENDSTOPPULLUP_YMAX
//#define ENDSTOPPULLUP_ZMAX
//#define ENDSTOPPULLUP_Z2MAX
//#define ENDSTOPPULLUP_ZPROBE
//#define ENDSTOPPULLUP_EMIN
#endif
......@@ -26,12 +28,12 @@
#define Y_MIN_ENDSTOP_LOGIC false // set to true to invert the logic of the endstop.
#define Z_MIN_ENDSTOP_LOGIC false // set to true to invert the logic of the endstop.
#define Z2_MIN_ENDSTOP_LOGIC false // set to true to invert the logic of the endstop.
#define E_MIN_ENDSTOP_LOGIC false // set to true to invert the logic of the endstop.
#define X_MAX_ENDSTOP_LOGIC false // set to true to invert the logic of the endstop.
#define Y_MAX_ENDSTOP_LOGIC false // set to true to invert the logic of the endstop.
#define Z_MAX_ENDSTOP_LOGIC false // set to true to invert the logic of the endstop.
#define Z2_MAX_ENDSTOP_LOGIC false // set to true to invert the logic of the endstop.
#define Z_PROBE_ENDSTOP_LOGIC false // set to true to invert the logic of the endstop.
#define E_MIN_ENDSTOP_LOGIC false // set to true to invert the logic of the endstop.
// ENDSTOP SETTINGS:
// Sets direction of endstop when homing; 1=MAX, -1=MIN
......@@ -90,15 +92,15 @@
//If you have enabled the Auto Bed Levelling and are using the same Z Probe for Z Homing,
//it is highly recommended you let this Z_SAFE_HOMING enabled!!!
//#define Z_SAFE_HOMING
#ifdef Z_SAFE_HOMING
#if ENABLED(Z_SAFE_HOMING)
#define Z_SAFE_HOMING_X_POINT ((X_MIN_POS + X_MAX_POS) / 2) // X point for Z homing when homing all axis (G28)
#define Z_SAFE_HOMING_Y_POINT ((Y_MIN_POS + Y_MAX_POS) / 2) // Y point for Z homing when homing all axis (G28)
#endif
//#define ENABLE_AUTO_BED_LEVELING // Delete the comment to enable (ABL)
//#define Z_PROBE_REPEATABILITY_TEST // Delete the comment to enable
//#define AUTO_BED_LEVELING_FEATURE // Delete the comment to enable (remove // at the start of the line)
//#define Z_PROBE_REPEATABILITY_TEST // If not commented out, Z-Probe Repeatability test will be included if Auto Bed Leveling is Enabled.
#ifdef ENABLE_AUTO_BED_LEVELING
#if ENABLED(AUTO_BED_LEVELING_FEATURE)
// There are 2 different ways to specify probing locations
//
......@@ -115,7 +117,7 @@
// Note: this feature generates 10KB extra code size
#define AUTO_BED_LEVELING_GRID
#ifdef AUTO_BED_LEVELING_GRID
#if ENABLED(AUTO_BED_LEVELING_GRID)
#define MIN_PROBE_EDGE 10 // The probe square sides can be no smaller than this
......@@ -162,7 +164,7 @@
//#define Z_PROBE_ENDSTOP
#endif // ENABLE_AUTO_BED_LEVELING
#endif // AUTO_BED_LEVELING_FEATURE
// The position of the homing switches
......@@ -197,15 +199,3 @@
#define DEFAULT_XYJERK 10.0 // (mm/sec)
#define DEFAULT_ZJERK 0.4 // (mm/sec)
#define DEFAULT_EJERK {5.0,5.0,5.0,5.0} // E0... (mm/sec) per extruder, max initial speed for retract moves
//===========================================================================
//=============================Additional Features===========================
//===========================================================================
// Custom M code points
//#define CUSTOM_M_CODES
#ifdef CUSTOM_M_CODES
#define CUSTOM_M_CODE_SET_Z_PROBE_OFFSET 851
#define Z_PROBE_OFFSET_RANGE_MIN -20
#define Z_PROBE_OFFSET_RANGE_MAX 20
#endif
......@@ -6,6 +6,21 @@
//=============================Mechanical Settings===========================
//===========================================================================
/***********************************************************************
************************ CORE X (YZ) MOLTIPLICATOR ********************
***********************************************************************
* This define the moltiplicator axis from X to Y or Z in COREXY or
* COREXZ.
* Example:
* COREXY set COREX_XZ_FACTOR 1
* The result is:
* X = dX + COREX_YZ_FACTOR * dY = dX + 1 * dY = dX + dY
* Y = dX - COREX_YZ_FACTOR * dY = dX - 1 * dY = dX - dY
* Z = dZ
*/
#define COREX_YZ_FACTOR 1
// coarse Endstop Settings
#define ENDSTOPPULLUPS // Comment this out (using // at the start of the line) to disable the endstop pullup resistors
......@@ -14,9 +29,11 @@
//#define ENDSTOPPULLUP_XMIN
//#define ENDSTOPPULLUP_YMIN
//#define ENDSTOPPULLUP_ZMIN
//#define ENDSTOPPULLUP_Z2MIN
//#define ENDSTOPPULLUP_XMAX
//#define ENDSTOPPULLUP_YMAX
//#define ENDSTOPPULLUP_ZMAX
//#define ENDSTOPPULLUP_Z2MAX
//#define ENDSTOPPULLUP_ZPROBE
//#define ENDSTOPPULLUP_EMIN
#endif
......@@ -26,12 +43,12 @@
#define Y_MIN_ENDSTOP_LOGIC false // set to true to invert the logic of the endstop.
#define Z_MIN_ENDSTOP_LOGIC false // set to true to invert the logic of the endstop.
#define Z2_MIN_ENDSTOP_LOGIC false // set to true to invert the logic of the endstop.
#define E_MIN_ENDSTOP_LOGIC false // set to true to invert the logic of the endstop.
#define X_MAX_ENDSTOP_LOGIC false // set to true to invert the logic of the endstop.
#define Y_MAX_ENDSTOP_LOGIC false // set to true to invert the logic of the endstop.
#define Z_MAX_ENDSTOP_LOGIC false // set to true to invert the logic of the endstop.
#define Z2_MAX_ENDSTOP_LOGIC false // set to true to invert the logic of the endstop.
#define Z_PROBE_ENDSTOP_LOGIC false // set to true to invert the logic of the endstop.
#define E_MIN_ENDSTOP_LOGIC false // set to true to invert the logic of the endstop.
// ENDSTOP SETTINGS:
// Sets direction of endstop when homing; 1=MAX, -1=MIN
......@@ -95,10 +112,10 @@
#define Z_SAFE_HOMING_Y_POINT ((Y_MIN_POS + Y_MAX_POS) / 2) // Y point for Z homing when homing all axis (G28)
#endif
//#define ENABLE_AUTO_BED_LEVELING // Delete the comment to enable (ABL)
//#define Z_PROBE_REPEATABILITY_TEST // Delete the comment to enable
//#define AUTO_BED_LEVELING_FEATURE // Delete the comment to enable (remove // at the start of the line)
//#define Z_PROBE_REPEATABILITY_TEST // If not commented out, Z-Probe Repeatability test will be included if Auto Bed Leveling is Enabled.
#ifdef ENABLE_AUTO_BED_LEVELING
#if ENABLED(AUTO_BED_LEVELING_FEATURE)
// There are 2 different ways to specify probing locations
//
......@@ -115,7 +132,7 @@
// Note: this feature generates 10KB extra code size
#define AUTO_BED_LEVELING_GRID
#ifdef AUTO_BED_LEVELING_GRID
#if ENABLED(AUTO_BED_LEVELING_GRID)
#define MIN_PROBE_EDGE 10 // The probe square sides can be no smaller than this
......@@ -162,7 +179,7 @@
//#define Z_PROBE_ENDSTOP
#endif // ENABLE_AUTO_BED_LEVELING
#endif // AUTO_BED_LEVELING_FEATURE
// The position of the homing switches
......@@ -197,15 +214,3 @@
#define DEFAULT_XYJERK 10.0 // (mm/sec)
#define DEFAULT_ZJERK 0.4 // (mm/sec)
#define DEFAULT_EJERK {5.0,5.0,5.0,5.0} // E0... (mm/sec) per extruder, max initial speed for retract moves
//===========================================================================
//=============================Additional Features===========================
//===========================================================================
// Custom M code points
//#define CUSTOM_M_CODES
#ifdef CUSTOM_M_CODES
#define CUSTOM_M_CODE_SET_Z_PROBE_OFFSET 851
#define Z_PROBE_OFFSET_RANGE_MIN -20
#define Z_PROBE_OFFSET_RANGE_MAX 20
#endif
......@@ -19,8 +19,8 @@
#define SCARA_offset_y -56 //mm
#define SCARA_RAD2DEG 57.2957795 // to convert RAD to degrees
#define THETA_HOMING_OFFSET 0 //calculatated from Calibration Guide and command M360 / M114 see picture in http://reprap.harleystudio.co.za/?page_id=1073
#define PSI_HOMING_OFFSET 0 // calculatated from Calibration Guide and command M364 / M114 see picture in http://reprap.harleystudio.co.za/?page_id=1073
#define THETA_HOMING_OFFSET 0 //calculatated from Calibration Guide and command M360 / M114 see picture in http://reprap.harleystudio.co.za/?page_id=1073
#define PSI_HOMING_OFFSET 0 // calculatated from Calibration Guide and command M364 / M114 see picture in http://reprap.harleystudio.co.za/?page_id=1073
//some helper variables to make kinematics faster
#define L1_2 sq(Linkage_1) // do not change
......@@ -118,10 +118,10 @@
#define Z_SAFE_HOMING_Y_POINT ((Y_MIN_POS + Y_MAX_POS) / 2) // Y point for Z homing when homing all axis (G28)
#endif
//#define ENABLE_AUTO_BED_LEVELING // Delete the comment to enable (ABL)
//#define Z_PROBE_REPEATABILITY_TEST // Delete the comment to enable
//#define AUTO_BED_LEVELING_FEATURE // Delete the comment to enable (remove // at the start of the line)
//#define Z_PROBE_REPEATABILITY_TEST // If not commented out, Z-Probe Repeatability test will be included if Auto Bed Leveling is Enabled.
#ifdef ENABLE_AUTO_BED_LEVELING
#if ENABLED(AUTO_BED_LEVELING_FEATURE)
// There are 2 different ways to specify probing locations
//
......@@ -138,7 +138,7 @@
// Note: this feature generates 10KB extra code size
#define AUTO_BED_LEVELING_GRID
#ifdef AUTO_BED_LEVELING_GRID
#if ENABLED(AUTO_BED_LEVELING_GRID)
#define MIN_PROBE_EDGE 10 // The probe square sides can be no smaller than this
......@@ -185,7 +185,7 @@
//#define Z_PROBE_ENDSTOP
#endif // ENABLE_AUTO_BED_LEVELING
#endif // AUTO_BED_LEVELING_FEATURE
// The position of the homing switches
......@@ -221,15 +221,3 @@
#define DEFAULT_XYJERK 5 // (mm/sec)
#define DEFAULT_ZJERK 0.4 // (mm/sec)
#define DEFAULT_EJERK {3.0,3.0,3.0,3.0} // (mm/sec)
//===========================================================================
//=============================Additional Features===========================
//===========================================================================
// Custom M code points
//#define CUSTOM_M_CODES
#ifdef CUSTOM_M_CODES
#define CUSTOM_M_CODE_SET_Z_PROBE_OFFSET 851
#define Z_PROBE_OFFSET_RANGE_MIN -20
#define Z_PROBE_OFFSET_RANGE_MAX 20
#endif
......@@ -70,7 +70,7 @@
* some filament is retracted. The filament retracted is re-added before the next extrusion
* or when the target temperature is less than IDLE_OOZING_MINTEMP and the actual temperature
* is greater than IDLE_OOZING_MINTEMP.
* PS: Always remember to set your extruder target temperature to 0°C before shoudown the printer if you enable this feature.
* PS: Always remember to set your extruder target temperature to 0°C before shoudown the printer if you enable this feature.
*/
//#define IDLE_OOZING_PREVENT
#define IDLE_OOZING_MINTEMP EXTRUDE_MINTEMP + 5
......@@ -143,7 +143,7 @@
#if ENABLED(Z_DUAL_STEPPER_DRIVERS)
// Z_DUAL_ENDSTOPS is a feature to enable the use of 2 endstops for both Z steppers - Let's call them Z stepper and Z2 stepper.
// Z DUAL ENDSTOPS is a feature to enable the use of 2 endstops for both Z steppers - Let's call them Z stepper and Z2 stepper.
// That way the machine is capable to align the bed during home, since both Z steppers are homed.
// There is also an implementation of M666 (software endstops adjustment) to this feature.
// After Z homing, this adjustment is applied to just one of the steppers in order to align the bed.
......@@ -152,17 +152,7 @@
// Play a little bit with small adjustments (0.5mm) and check the behaviour.
// The M119 (endstops report) will start reporting the Z2 Endstop as well.
#define Z2_STEP_PIN E2_STEP_PIN // Stepper to be used to Z2 axis.
#define Z2_DIR_PIN E2_DIR_PIN
#define Z2_ENABLE_PIN E2_ENABLE_PIN
// #define Z_DUAL_ENDSTOPS
#if ENABLED(Z_DUAL_ENDSTOPS)
#define Z2_MAX_PIN 36 //Endstop used for Z2 axis. In this case I'm using XMAX in a Rumba Board (pin 36)
const bool Z2_MAX_ENDSTOP_INVERTING = false;
#define DISABLE_XMAX_ENDSTOP //Better to disable the XMAX to avoid conflict. Just rename "XMAX_ENDSTOP" by the endstop you are using for Z2 axis.
#endif
//#define Z_DUAL_ENDSTOPS
#endif // Z_DUAL_STEPPER_DRIVERS
......@@ -269,7 +259,7 @@
#define MICROSTEP_MODES {16, 16, 16, 16} // X Y Z E - [1,2,4,8,16,32]
// Motor Current setting (Only functional on ALLIGATOR BOARD)
#define MOTOR_CURRENT {1, 1, 1, 1} // X Y Z E - Values 0 - 2.5 A
#define MOTOR_CURRENT {1, 1, 1, 1, 1, 1, 1} // X Y Z E0 E1 E2 E3 - Values 0 - 2.5 A
// Motor Current setting (Only functional when motor driver current ref pins are connected to a digital trimpot on supported boards)
#define DIGIPOT_MOTOR_CURRENT {135,135,135,135,135} // Values 0-255 (RAMBO 135 = ~0.75A, 185 = ~1A)
......
/*
* This file is a placeholder for a file which could be distributed in an archive
* It takes the place of an automatically created "_Version.h" which is generated during the build process
*/
// #error "You must specify the following parameters related to your distribution"
#if true
#define SHORT_BUILD_VERSION "4.1.4 dev"
#define STRING_DISTRIBUTION_DATE __DATE__ " " __TIME__ // build date and time
// It might also be appropriate to define a location where additional information can be found
#define SOURCE_CODE_URL "https://github.com/MagoKimbra/MarlinKimbra"
#endif
\ No newline at end of file
......@@ -281,12 +281,12 @@ void MarlinSerial::printFloat(double number, uint8_t digits) {
// Preinstantiate Objects //////////////////////////////////////////////////////
MarlinSerial MSerial;
MarlinSerial customizedSerial;
#endif // whole file
#endif // !USBCON
// For AT90USB targets use the UART for BT interfacing
#if defined(USBCON) && ENABLED(BTENABLED)
HardwareSerial bt;
#if defined(USBCON) && ENABLED(BLUETOOTH)
HardwareSerial bluetoothSerial;
#endif
......@@ -30,8 +30,8 @@
// The presence of the UBRRH register is used to detect a UART.
#define UART_PRESENT(port) ((port == 0 && (defined(UBRRH) || defined(UBRR0H))) || \
(port == 1 && defined(UBRR1H)) || (port == 2 && defined(UBRR2H)) || \
(port == 3 && defined(UBRR3H)))
(port == 3 && defined(UBRR3H)))
// These are macros to build serial port register names for the selected SERIAL_PORT (C preprocessor
// requires two levels of indirection to expand macro values properly)
#define SERIAL_REGNAME(registerbase,number,suffix) SERIAL_REGNAME_INTERNAL(registerbase,number,suffix)
......@@ -149,12 +149,12 @@ class MarlinSerial { //: public Stream
void println(void);
};
extern MarlinSerial MSerial;
extern MarlinSerial customizedSerial;
#endif // !USBCON
// Use the UART for BT in AT90USB configurations
#if defined(USBCON) && ENABLED(BTENABLED)
extern HardwareSerial bt;
// Use the UART for Bluetooth in AT90USB configurations
#if defined(USBCON) && ENABLED(BLUETOOTH)
extern HardwareSerial bluetoothSerial;
#endif
#endif
This diff is collapsed.
/**
* @file NexButton.cpp
*
* API of NexButton.
* The implementation of class NexButton.
*
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
* @date 2015/7/10
* @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
......@@ -15,23 +15,11 @@
#include "NexButton.h"
/**
* Constructor,inherited NexTouch's constructor function.
*
*/
NexButton::NexButton(NexPid pid, NexCid cid, char *name, NexTouchEventCb pop, void *pop_ptr)
:NexTouch(pid, cid, name, pop, pop_ptr)
NexButton::NexButton(uint8_t pid, uint8_t cid, const char *name)
:NexTouch(pid, cid, name)
{
}
/**
* Get text value from button component.
*
* @param buffer - text buffer.
* @param len - text buffer length.
*
* @return the text buffer length
*/
uint16_t NexButton::getText(char *buffer, uint16_t len)
{
String cmd;
......@@ -42,14 +30,6 @@ uint16_t NexButton::getText(char *buffer, uint16_t len)
return recvRetString(buffer,len);
}
/**
* Set text value of button component.
*
* @param buffer - text buffer.
*
* @retval true - success.
* @retval false - failed.
*/
bool NexButton::setText(const char *buffer)
{
String cmd;
......@@ -60,25 +40,3 @@ bool NexButton::setText(const char *buffer)
sendCommand(cmd.c_str());
return recvRetCommandFinished();
}
/**
* Register button pop callback function.
*
* @param pop - the pointer to button pop callback function.
* @param ptr - the parameter to be transmitted to button pop callback function.
*/
void NexButton::attachPop(NexTouchEventCb pop, void *ptr)
{
NexTouch::attachPop(pop, ptr);
}
/**
* Unload button pop callback function.
*
*/
void NexButton::detachPop(void)
{
NexTouch::detachPop();
}
/**
* @file NexButton.h
*
* API of NexButton.
* The definition of class NexButton.
*
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
* @date 2015/8/13
*
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
* @date 2015/7/10
* @copyright
* Copyright (C) 2014-2015 ITEAD Intelligent Systems Co., Ltd. \n
* This program is free software; you can redistribute it and/or
......@@ -15,24 +16,51 @@
#ifndef __NEXBUTTON_H__
#define __NEXBUTTON_H__
#ifdef __cplusplus
#include "NexTouch.h"
#include "NexHardware.h"
/**
* @addtogroup Component
* @{
*/
/**
* NexButton,subclass of NexTouch,provides simple methods to control button 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 */
NexButton(NexPid pid, NexCid cid, char *name, NexTouchEventCb pop = NULL, void *pop_ptr = NULL);
void attachPop(NexTouchEventCb pop, void *ptr = NULL);
void detachPop(void);
uint16_t getText(char *buffer, uint16_t len);
bool setText(const char *buffer);
/**
* @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 /* #ifdef __cplusplus */
#endif /* #ifndef __NEXBUTTON_H__ */
/**
* @file NexSerialConfig.h
* @file NexConfig.h
*
* Serial configure.
* Options for user can be found here.
*
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
* @date 2015/7/10
* @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
......@@ -12,31 +12,49 @@
* 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__
#ifndef __NexSerialConfig_H__
#define __NexSerialConfig_H__
/**
* @addtogroup Configuration
* @{
*/
// Nextion Baudrate - default 9600
// 2400 - 4800 - 9600 - 19200 - 38400 - 57600 - 115200
/**
* Nextion Baudrate - default 9600
* 2400 - 4800 - 9600 - 19200 - 38400 - 57600 - 115200
*/
#define NEXTION_BAUDRATE 9600
/*enable debug serial*/
/**
* Define DEBUG_SERIAL_ENABLE to enable debug serial.
* Comment it to disable debug serial.
*/
//#define DEBUG_SERIAL_ENABLE
/*define serial for debug*/
/**
* 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)
#define dbSerialPrintln(a)
#define dbSerialBegin(a)
#define dbSerialPrint(a) do{}while(0)
#define dbSerialPrintln(a) do{}while(0)
#define dbSerialBegin(a) do{}while(0)
#endif
/*define serial for communicate with Nextion screen*/
#define nexSerial Serial1
/**
* @}
*/
#endif
#endif /* #ifndef __NEXCONFIG_H__ */
/**
* @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]);
}
}
}
}
}
/**
* @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__ */
/**
* @file NexHotspot.cpp
*
* API of NexHotspot.
* The implementation of class NexHotspot.
*
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
* @date 2015/7/10
* @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
......@@ -15,53 +15,8 @@
#include "NexHotspot.h"
/**
* Constructor,inherited NexTouch's constructor function.
*
*/
NexHotspot::NexHotspot(NexPid pid, NexCid cid, char *name,
NexTouchEventCb pop, void *pop_ptr,
NexTouchEventCb push, void *push_ptr)
:NexTouch(pid, cid, name, pop, pop_ptr, push, push_ptr)
{
}
/**
* Register hotspot push callback function.
*
* @param push - the pointer to hotspot push callback function.
* @param ptr - the parameter to be transmitted to hotspot push callback function.
*/
void NexHotspot::attachPush(NexTouchEventCb push, void *ptr)
{
NexTouch::attachPush(push, ptr);
}
/**
* Unload hotsopt push callback function.
*
*/
void NexHotspot::detachPush(void)
NexHotspot::NexHotspot(uint8_t pid, uint8_t cid, const char *name)
:NexTouch(pid, cid, name)
{
NexTouch::detachPush();
}
/**
* Register hotspot pop callback function.
*
* @param pop - the pointer to hotspot pot callback function.
* @param ptr - the parameter to be transmitted to hotspot pop callback function.
*/
void NexHotspot::attachPop(NexTouchEventCb pop, void *ptr)
{
NexTouch::attachPop(pop, ptr);
}
/**
* Unload hotsopt pop callback function.
*
*/
void NexHotspot::detachPop(void)
{
NexTouch::detachPop();
}
/**
* @file NexHotspot.h
*
* API of NexHotspot.
* The definition of class NexHotspot.
*
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
* @date 2015/8/13
*
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
* @date 2015/7/10
* @copyright
* Copyright (C) 2014-2015 ITEAD Intelligent Systems Co., Ltd. \n
* This program is free software; you can redistribute it and/or
......@@ -15,26 +16,28 @@
#ifndef __NEXHOTSPOT_H__
#define __NEXHOTSPOT_H__
#ifdef __cplusplus
#include "NexTouch.h"
#include "NexHardware.h"
/**
* @addtogroup Component
* @{
*/
/**
* NexHotspot,subclass of NexTouch,provides simple methods to control hotspot component.
*
* NexHotspot component.
*/
class NexHotspot: public NexTouch
{
public: /* methods */
NexHotspot(NexPid pid, NexCid cid, char *name,
NexTouchEventCb pop = NULL, void *pop_ptr = NULL,
NexTouchEventCb push = NULL, void *push_ptr = NULL);
void attachPush(NexTouchEventCb push, void *ptr = NULL);
void detachPush(void);
void attachPop(NexTouchEventCb pop, void *ptr = NULL);
void detachPop(void);
/**
* @copydoc NexObject::NexObject(uint8_t pid, uint8_t cid, const char *name);
*/
NexHotspot(uint8_t pid, uint8_t cid, const char *name);
};
/**
* @}
*/
#endif /* #ifdef __cplusplus */
#endif /* #ifndef __NEXHOTSPOT_H__ */
/**
* @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("]");
}
/**
* @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__ */
/**
* @file NexPage.cpp
*
* API of NexPage.
* The implementation of class NexPage.
*
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
* @date 2015/7/10
* @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
......@@ -15,21 +15,11 @@
#include "NexPage.h"
/**
* Constructor,inherited NexTouch's constructor function.
*
*/
NexPage::NexPage(NexPid pid, NexCid cid, char *name, NexTouchEventCb pop, void *pop_ptr)
:NexTouch(pid, cid, name, pop, pop_ptr)
NexPage::NexPage(uint8_t pid, uint8_t cid, const char *name)
:NexTouch(pid, cid, name)
{
}
/**
* Change page.
*
* @retval true - success.
* @retval false - failed.
*/
bool NexPage::show(void)
{
uint8_t buffer[4] = {0};
......@@ -46,22 +36,3 @@ bool NexPage::show(void)
return recvRetCommandFinished();
}
/**
* Register page pop callback function.
*
* @param pop - the pointer to page pop callback function.
* @param ptr - the parameter to be transmitted to page pop callback function.
*/
void NexPage::attachPop(NexTouchEventCb pop, void *ptr)
{
NexTouch::attachPop(pop, ptr);
}
/**
* Unload page pop callback function.
*
*/
void NexPage::detachPop(void)
{
NexTouch::detachPop();
}
/**
* @file NexPage.h
*
* API of NexPage.
* The definition of class NexPage.
*
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
* @date 2015/8/13
*
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
* @date 2015/7/10
* @copyright
* Copyright (C) 2014-2015 ITEAD Intelligent Systems Co., Ltd. \n
* This program is free software; you can redistribute it and/or
......@@ -15,23 +16,35 @@
#ifndef __NEXPAGE_H__
#define __NEXPAGE_H__
#ifdef __cplusplus
#include "NexTouch.h"
#include "NexHardware.h"
/**
* @addtogroup Component
* @{
*/
/**
* NexPage,subclass of NexTouch,provides simple methods to control page component.
*
* A special component , which can contain other components such as NexButton,
* NexText and NexWaveform, etc.
*/
class NexPage: public NexTouch
{
public: /* methods */
NexPage(NexPid pid, NexCid cid, char *name, NexTouchEventCb pop = NULL, void *pop_ptr = NULL);
/**
* @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);
void attachPop(NexTouchEventCb pop, void *ptr = NULL);
void detachPop(void);
};
/**
* @}
*/
#endif /* #ifdef __cplusplus */
#endif /* #ifndef __NEXPAGE_H__ */
/**
* @file NexPicture.cpp
*
* API of NexPicture.
* The implementation of class NexPicture.
*
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
* @date 2015/7/10
* @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
......@@ -15,23 +15,11 @@
#include "NexPicture.h"
/**
* Constructor,inherited NexTouch's constructor function.
*
*/
NexPicture::NexPicture(NexPid pid, NexCid cid, char *name, NexTouchEventCb pop, void *pop_ptr)
:NexTouch(pid, cid, name, pop, pop_ptr)
NexPicture::NexPicture(uint8_t pid, uint8_t cid, const char *name)
:NexTouch(pid, cid, name)
{
}
/**
* Get picture's number.
*
* @param number - an output parameter to save picture number.
*
* @retval true - success.
* @retval false - failed.
*/
bool NexPicture::getPic(uint32_t *number)
{
String cmd = String("get ");
......@@ -41,14 +29,6 @@ bool NexPicture::getPic(uint32_t *number)
return recvRetNumber(number);
}
/**
* Set picture's number.
*
* @param number -the picture number.
*
* @retval true - success.
* @retval false - failed.
*/
bool NexPicture::setPic(uint32_t number)
{
char buf[10] = {0};
......@@ -62,24 +42,4 @@ bool NexPicture::setPic(uint32_t number)
sendCommand(cmd.c_str());
return recvRetCommandFinished();
}
/**
* Register picture pop callback function.
*
* @param pop - the pointer to picture pop callback function.
* @param ptr - the parameter to be transmitted to picture pop callback function.
*/
void NexPicture::attachPop(NexTouchEventCb pop, void *ptr)
{
NexTouch::attachPop(pop, ptr);
}
/**
* Unload picture pop callback function.
*
*/
void NexPicture::detachPop(void)
{
NexTouch::detachPop();
}
/**
* @file NexPicture.h
*
* API of NexPicture.
* The definition of class NexPicture.
*
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
* @date 2015/8/13
*
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
* @date 2015/7/10
* @copyright
* Copyright (C) 2014-2015 ITEAD Intelligent Systems Co., Ltd. \n
* This program is free software; you can redistribute it and/or
......@@ -15,24 +16,48 @@
#ifndef __NEXPICTURE_H__
#define __NEXPICTURE_H__
#ifdef __cplusplus
#include "NexTouch.h"
#include "NexHardware.h"
/**
* @addtogroup Component
* @{
*/
/**
* NexPicture,subclass of NexTouch,provides simple methods to control picture component.
*
* NexPicture component.
*/
class NexPicture: public NexTouch
{
public: /* methods */
NexPicture(NexPid pid, NexCid cid, char *name, NexTouchEventCb pop = NULL, void *pop_ptr = NULL);
/**
* @copydoc NexObject::NexObject(uint8_t pid, uint8_t cid, const char *name);
*/
NexPicture(uint8_t pid, uint8_t cid, const char *name);
void attachPop(NexTouchEventCb pop, void *ptr = NULL);
void detachPop(void);
/**
* 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 /* #ifdef __cplusplus */
/**
* @}
*/
#endif /* #ifndef __NEXPICTURE_H__ */
#include "NexPointer.h"
/**
* Constructor,inherited NexTouch's constructor function.
*
*/
NexPointer::NexPointer(NexPid pid, NexCid cid, char *name)
:NexTouch(pid, cid, name)
{
}
/**
* Get the value of pointer.
*
* @param number - an output parameter to save pointer's value.
*
* @retval true - success.
* @retval false - failed.
*/
bool NexPointer::getValue(uint32_t *number)
{
String cmd = String("get ");
cmd += getObjName();
cmd += ".val";
sendCommand(cmd.c_str());
return recvRetNumber(number);
}
/**
* Set the value of pointer.
*
* @param number - the value of pointer.
*
* @retval true - success.
* @retval false - failed.
*/
bool NexPointer::setValue(uint32_t number)
{
char buf[10] = {0};
String cmd;
utoa(number, buf, 10);
cmd += getObjName();
cmd += ".val=";
cmd += buf;
sendCommand(cmd.c_str());
return recvRetCommandFinished();
}
#ifndef __NEXPOINTER_H__
#define __NEXPOINTER_H__
#ifdef __cplusplus
#include "NexTouch.h"
/**
* NexPointer,subclass of NexTouch,provides simple methods to control pointer component.
*
*/
class NexPointer: public NexTouch
{
public: /* methods */
NexPointer(NexPid pid, NexCid cid, char *name);
bool getValue(uint32_t *number);
bool setValue(uint32_t number);
};
#endif /* #ifdef __cplusplus */
#endif /* #ifndef __NEXPOINTER_H__ */
/**
* @file NexProgressBar.cpp
*
* API of NexProgressBar.
* The implementation of class NexProgressBar.
*
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
* @date 2015/7/10
* @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
......@@ -15,23 +15,11 @@
#include "NexProgressBar.h"
/**
* Constructor,inherited NexTouch's constructor function.
*
*/
NexProgressBar::NexProgressBar(NexPid pid, NexCid cid, char *name)
:NexTouch(pid, cid, name)
NexProgressBar::NexProgressBar(uint8_t pid, uint8_t cid, const char *name)
:NexObject(pid, cid, 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 NexProgressBar::getValue(uint32_t *number)
{
String cmd = String("get ");
......@@ -41,14 +29,6 @@ bool NexProgressBar::getValue(uint32_t *number)
return recvRetNumber(number);
}
/**
* Set the value of progress bar.
*
* @param number - the value of progress bar.
*
* @retval true - success.
* @retval false - failed.
*/
bool NexProgressBar::setValue(uint32_t number)
{
char buf[10] = {0};
......
/**
* @file NexProgressBar.h
*
* API of NexProgressBar.
* The definition of class NexProgressBar.
*
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
* @date 2015/8/13
*
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
* @date 2015/7/10
* @copyright
* Copyright (C) 2014-2015 ITEAD Intelligent Systems Co., Ltd. \n
* This program is free software; you can redistribute it and/or
......@@ -15,21 +16,48 @@
#ifndef __NEXPROGRESSBAR_H__
#define __NEXPROGRESSBAR_H__
#ifdef __cplusplus
#include "NexTouch.h"
#include "NexHardware.h"
/**
* @addtogroup Component
* @{
*/
/**
* NexProgressBar,subclass of NexTouch,provides simple methods to control progress bar component.
*
* NexProgressBar component.
*/
class NexProgressBar: public NexTouch
class NexProgressBar: public NexObject
{
public: /* methods */
NexProgressBar(NexPid pid, NexCid cid, char *name);
/**
* @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 /* #ifdef __cplusplus */
/**
* @}
*/
#endif /* #ifndef __NEXPROGRESSBAR_H__ */
/**
* @file NexSlice.cpp
* @file NexSlider.cpp
*
* API of NexSlice.
* The implementation of class NexSlider.
*
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
* @date 2015/7/10
* @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
......@@ -12,74 +12,33 @@
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*/
#include "NexSlider.h"
#include "NexSlice.h"
/**
* Constructor,inherited NexTouch's constructor function.
*
*/
NexSlice::NexSlice(NexPid pid, NexCid cid, char *name, NexTouchEventCb pop, void *pop_ptr)
:NexTouch(pid, cid, name, pop, pop_ptr)
NexSlider::NexSlider(uint8_t pid, uint8_t cid, const char *name)
:NexTouch(pid, cid, name)
{
}
/*
* Get the number of picture.
*
* @param number - an output parameter to save the number of picture.
*
* @retval true - success.
* @retval false - failed.
*/
bool NexSlice::getPic(uint32_t *number)
bool NexSlider::getValue(uint32_t *number)
{
String cmd = String("get ");
cmd += getObjName();
cmd += ".picc";
cmd += ".val";
sendCommand(cmd.c_str());
return recvRetNumber(number);
}
/*
* Set the number of picture.
*
* @param number - the number of picture.
*
* @retval true - success.
* @retval false - failed.
*/
bool NexSlice::setPic(uint32_t number)
bool NexSlider::setValue(uint32_t number)
{
char buf[10] = {0};
String cmd;
utoa(number, buf, 10);
cmd += getObjName();
cmd += ".picc=";
cmd += ".val=";
cmd += buf;
sendCommand(cmd.c_str());
return recvRetCommandFinished();
}
/**
* Register slice pop callback function.
*
* @param pop - the pointer to slice pop callback function.
* @param ptr - the parameter to be transmitted to slice pop callback function.
*/
void NexSlice::attachPop(NexTouchEventCb pop, void *ptr)
{
NexTouch::attachPop(pop, ptr);
}
/**
* Unload slice pop callback function.
*
*/
void NexSlice::detachPop(void)
{
NexTouch::detachPop();
}
/**
* @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);
};
/**
* @}
*/
#endif /* #ifndef __NEXSLIDER_H__ */
/**
* @file NexText.cpp
*
* API of NexText.
* The implementation of class NexText.
*
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
* @date 2015/7/10
* @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
......@@ -12,26 +12,13 @@
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*/
#include "NexText.h"
/**
* Constructor,inherited NexTouch's constructor function.
*
*/
NexText::NexText(NexPid pid, NexCid cid, char *name, NexTouchEventCb pop, void *pop_ptr)
:NexTouch(pid, cid, name, pop, pop_ptr)
NexText::NexText(uint8_t pid, uint8_t cid, const char *name)
:NexTouch(pid, cid, name)
{
}
/**
* Get the value of text.
*
* @param buffer - text value buffer.
* @param len - the length of text value buffer.
*
* @return the length of text value buffer.
*/
uint16_t NexText::getText(char *buffer, uint16_t len)
{
String cmd;
......@@ -42,14 +29,6 @@ uint16_t NexText::getText(char *buffer, uint16_t len)
return recvRetString(buffer,len);
}
/**
* Set the value of text.
*
* @param buffer - text value buffer.
*
* @retval true - success.
* @retval false - failed.
*/
bool NexText::setText(const char *buffer)
{
String cmd;
......@@ -61,14 +40,6 @@ bool NexText::setText(const char *buffer)
return recvRetCommandFinished();
}
/**
* Set the value of color.
*
* @param value - color value.
*
* @retval true - success.
* @retval false - failed.
*/
bool NexText::setColor(uint32_t value)
{
char buf[10] = {0};
......@@ -82,24 +53,3 @@ bool NexText::setColor(uint32_t value)
sendCommand(cmd.c_str());
return recvRetCommandFinished();
}
/**
* Register text pop callback function.
*
* @param pop - the pointer to text pop callback function.
* @param ptr - the parameter to be transmitted to text pop callback function.
*/
void NexText::attachPop(NexTouchEventCb pop, void *ptr)
{
NexTouch::attachPop(pop, ptr);
}
/**
* Unload text pop callback function.
*
*/
void NexText::detachPop(void)
{
NexTouch::detachPop();
}
/**
* @file NexText.h
*
* API of NexText.
* The definition of class NexText.
*
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
* @date 2015/8/13
*
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
* @date 2015/7/10
* @copyright
* Copyright (C) 2014-2015 ITEAD Intelligent Systems Co., Ltd. \n
* This program is free software; you can redistribute it and/or
......@@ -15,25 +16,46 @@
#ifndef __NEXTEXT_H__
#define __NEXTEXT_H__
#ifdef __cplusplus
#include "NexTouch.h"
#include "NexHardware.h"
/**
* @addtogroup Component
* @{
*/
/**
* NexText,subclass of NexTouch,provides simple methods to control text component.
*
* NexText component.
*/
class NexText: public NexTouch
{
public: /* methods */
NexText(NexPid pid, NexCid cid, char *name, NexTouchEventCb pop = NULL, void *pop_ptr = NULL);
/**
* @copydoc NexObject::NexObject(uint8_t pid, uint8_t cid, const char *name);
*/
NexText(uint8_t pid, uint8_t cid, const char *name);
void attachPop(NexTouchEventCb pop, void *ptr = NULL);
void detachPop(void);
/**
* 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 /* #ifdef __cplusplus */
/**
* @}
*/
#endif /* #ifndef __NEXTEXT_H__ */
This diff is collapsed.
/**
* @file NexTouch.h
*
* API of Nextion.
* The definition of class NexTouch.
*
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
* @date 2015/8/13
*
* @author Wu Pengfei (email:<pengfei.wu@itead.cc>)
* @date 2015/7/10
* @copyright
* Copyright (C) 2014-2015 ITEAD Intelligent Systems Co., Ltd. \n
* This program is free software; you can redistribute it and/or
......@@ -15,107 +16,101 @@
#ifndef __NEXTOUCH_H__
#define __NEXTOUCH_H__
#ifdef __cplusplus
#include <Arduino.h>
#include "NexSerialConfig.h"
typedef uint8_t NexPid;
typedef uint8_t NexCid;
#include <Arduino.h>
#include "NexConfig.h"
#include "NexObject.h"
typedef enum {
NEX_EVENT_POP = 0x00,
NEX_EVENT_PUSH = 0x01,
NEX_EVENT_NULL
} NexEventType;
/**
* @addtogroup TouchEvent
* @{
*/
/*The first byte of Nextoin's return value*/
#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)
/**
* 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);
/**
* Root Class of Nextion Components.
* 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
class NexTouch: public NexObject
{
public: /* static methods */
static uint8_t mainEventLoop(NexTouch **list);
static void sendCommand(const char *cmd);
static bool recvRetCommandFinished(uint32_t timeout = 100);
static uint16_t recvRetString(char *buffer, uint16_t len, uint32_t timeout = 500);
static bool recvRetNumber(uint32_t *number, uint32_t timeout = 500);
public: /* static methods */
static void iterate(NexTouch **list, uint8_t pid, uint8_t cid, int32_t event);
public: /* methods */
NexTouch(NexPid pid, NexCid cid, char *name,
NexTouchEventCb pop = NULL, void *pop_ptr = NULL,
NexTouchEventCb push = NULL, void *push_ptr = NULL);
NexPid getPid(void);
NexCid getCid(void);
const char *getObjName(void);
void print(void);
protected: /* static methods */
static bool setBrightness(uint32_t brightness);
static bool getBrightness(uint32_t *brightness);
/**
* @copydoc NexObject::NexObject(uint8_t pid, uint8_t cid, const char *name);
*/
NexTouch(uint8_t pid, uint8_t cid, const char *name);
protected: /* methods */
/**
* 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);
void detachPop(void);
private: /* static methods */
static void iterate(NexTouch **list, NexPid pid, NexCid cid, NexEventType event);
/**
* Detach an callback function.
*
* @return none.
*/
void detachPop(void);
private: /* methods */
void push(void);
void pop(void);
private: /* static data */
static uint8_t __buffer[256];
private: /* data */
NexPid pid; /* Page ID */
NexCid cid; /* Component ID */
char *name; /* An unique name */
NexTouchEventCb cbPush;
NexTouchEventCb __cb_push;
void *__cbpush_ptr;
NexTouchEventCb cbPop;
NexTouchEventCb __cb_pop;
void *__cbpop_ptr;
};
bool nexInit(void);
bool nexLoop(NexTouch **nexListenList);
bool sendCurrentPageId(uint8_t* pageId);
bool touchCalibration(void);
bool disableTouchFocus(void);
bool pauseSerialCommand(void);
bool recoverySerialCommand(void);
bool clearSerialSurplusCommand(void);
bool setCurrentBrightness(uint8_t dimValue);
bool setDefaultBrightness(uint8_t dimDefaultValue);
bool sleepMode(uint8_t mode);
bool setCurrentBaudrate(uint32_t baudrate);
bool setDefaultBaudrate(uint32_t baudrate);
/**
* @}
*/
#endif /* #ifdef __cplusplus */
#endif /* #ifndef __NEXTOUCH_H__ */
/**
* @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;
}
/**
* @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__ */
/**
* @file NexSlice.h
* @file Nextion.h
*
* API of NexSlice.
* 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/7/10
* @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
......@@ -12,27 +14,23 @@
* 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__
#ifndef __NEXSLICE_H__
#define __NEXSLICE_H__
#ifdef __cplusplus
#include "Arduino.h"
#include "NexConfig.h"
#include "NexTouch.h"
#include "NexHardware.h"
/**
* NexSlice,subclass of NexTouch,provides simple methods to control slice component.
*
*/
class NexSlice: public NexTouch
{
public: /* methods */
NexSlice(NexPid pid, NexCid cid, char *name, NexTouchEventCb pop = NULL, void *pop_ptr = NULL);
void attachPop(NexTouchEventCb pop, void *ptr = NULL);
void detachPop(void);
bool getPic(uint32_t *number);
bool setPic(uint32_t number);
};
#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"
#endif /* #ifdef __cplusplus */
#endif /* #ifndef __NEXSLICE_H__ */
#endif /* #ifndef __NEXTION_H__ */
......@@ -316,8 +316,8 @@ void CardReader::openFile(char* name, bool read, bool replace_current/*=true*/,
subdirname[dirname_end - dirname_start] = 0;
ECHO_EV(subdirname);
if (!myDir.open(curDir, subdirname, O_READ)) {
ECHO_MV(MSG_SD_OPEN_FILE_FAIL, subdirname);
ECHO_C('.');
ECHO_SMV(ER, MSG_SD_OPEN_FILE_FAIL, subdirname);
ECHO_EM(".");
return;
}
else {
......@@ -357,12 +357,12 @@ void CardReader::openFile(char* name, bool read, bool replace_current/*=true*/,
}
else { //write
if (!file.open(curDir, fname, O_CREAT | O_APPEND | O_WRITE | O_TRUNC)) {
ECHO_MV(MSG_SD_OPEN_FILE_FAIL, fname);
ECHO_PGM(".\n");
ECHO_SMV(ER, MSG_SD_OPEN_FILE_FAIL, fname);
ECHO_EM(".");
}
else {
saving = true;
ECHO_EMV(MSG_SD_WRITE_TO_FILE, name);
ECHO_LMV(DB, MSG_SD_WRITE_TO_FILE, name);
if(lcd_status) lcd_setstatus(fname);
}
}
......@@ -389,8 +389,8 @@ void CardReader::removeFile(char* name) {
subdirname[dirname_end - dirname_start] = 0;
ECHO_EV(subdirname);
if (!myDir.open(curDir, subdirname, O_READ)) {
ECHO_MV(MSG_SD_OPEN_FILE_FAIL, subdirname);
ECHO_C('.');
ECHO_SMV(DB, MSG_SD_OPEN_FILE_FAIL, subdirname);
ECHO_EM(".");
return;
}
......@@ -509,7 +509,7 @@ void CardReader::parseKeyLine(char *key, char *value, int &len_k, int &len_v) {
int ln_buf = 0;
char ln_char;
bool ln_space = false, ln_ignore = false, key_found = false;
while(!eof()) { //READ KEY
while(!eof()) { //READ KEY
ln_char = (char)get();
if(ln_char == '\n') {
ln_buf = 0;
......@@ -542,7 +542,7 @@ void CardReader::parseKeyLine(char *key, char *value, int &len_k, int &len_v) {
}
ln_buf = 0;
ln_ignore = false;
while(!eof()) { //READ VALUE
while(!eof()) { //READ VALUE
ln_char = (char)get();
if(ln_char == '\n') {
value[ln_buf] = '\0';
......
......@@ -25,17 +25,17 @@
#include "WString.h"
#ifdef AT90USB
#ifdef BTENABLED
#define MYSERIAL bt
#ifdef USBCON
#if ENABLED(BLUETOOTH)
#define MYSERIAL bluetoothSerial
#else
#define MYSERIAL Serial
#endif // BTENABLED
#endif // BLUETOOTH
#else
#ifdef __SAM3X8E__
#define MYSERIAL Serial
#else
#define MYSERIAL MSerial
#define MYSERIAL customizedSerial
#endif
#endif
......
......@@ -223,14 +223,6 @@
#undef HAS_LCD_CONTRAST
#endif
#endif
/**
* SPLASH_SCREEN_DURATION for no DOGLCD display
*/
#if DISABLED(DOGLCD)
#undef SPLASH_SCREEN_DURATION
#define SPLASH_SCREEN_DURATION 500
#endif
#else // CONFIGURATION_LCD
#define CONDITIONALS_H
......@@ -265,14 +257,16 @@
* ENDSTOPPULLUPS
*/
#if ENABLED(ENDSTOPPULLUPS)
#define ENDSTOPPULLUP_XMAX
#define ENDSTOPPULLUP_YMAX
#define ENDSTOPPULLUP_ZMAX
#define ENDSTOPPULLUP_XMIN
#define ENDSTOPPULLUP_YMIN
#define ENDSTOPPULLUP_ZMIN
#define ENDSTOPPULLUP_EMIN
#define ENDSTOPPULLUP_Z2MIN
#define ENDSTOPPULLUP_XMAX
#define ENDSTOPPULLUP_YMAX
#define ENDSTOPPULLUP_ZMAX
#define ENDSTOPPULLUP_Z2MAX
#define ENDSTOPPULLUP_ZPROBE
#define ENDSTOPPULLUP_EMIN
#endif
/**
......@@ -366,7 +360,7 @@
/**
* Auto Bed Leveling
*/
#if ENABLED(ENABLE_AUTO_BED_LEVELING)
#if ENABLED(AUTO_BED_LEVELING_FEATURE)
// Boundaries for probing based on set limits
#define MIN_PROBE_X (max(X_MIN_POS, X_MIN_POS + X_PROBE_OFFSET_FROM_EXTRUDER))
#define MAX_PROBE_X (min(X_MAX_POS, X_MAX_POS + X_PROBE_OFFSET_FROM_EXTRUDER))
......
......@@ -455,16 +455,16 @@ void Config_ResetDefault() {
else
max_e_jerk[i] = tmp5[max_i - 1];
#if HOTENDS > 1
max_i = sizeof(tmp9) / sizeof(*tmp9);
if(i < max_i)
hotend_offset[X_AXIS][i] = tmp9[i];
else
hotend_offset[X_AXIS][i] = 0;
max_i = sizeof(tmp10) / sizeof(*tmp10);
if(i < max_i)
hotend_offset[Y_AXIS][i] = tmp10[i];
else
hotend_offset[Y_AXIS][i] = 0;
max_i = sizeof(tmp9) / sizeof(*tmp9);
if(i < max_i)
hotend_offset[X_AXIS][i] = tmp9[i];
else
hotend_offset[X_AXIS][i] = 0;
max_i = sizeof(tmp10) / sizeof(*tmp10);
if(i < max_i)
hotend_offset[Y_AXIS][i] = tmp10[i];
else
hotend_offset[Y_AXIS][i] = 0;
#endif // HOTENDS > 1
}
}
......@@ -488,7 +488,7 @@ void Config_ResetDefault() {
max_z_jerk = DEFAULT_ZJERK;
home_offset[X_AXIS] = home_offset[Y_AXIS] = home_offset[Z_AXIS] = 0;
#if ENABLED(ENABLE_AUTO_BED_LEVELING)
#if ENABLED(AUTO_BED_LEVELING_FEATURE)
zprobe_zoffset = Z_PROBE_OFFSET_FROM_EXTRUDER;
#elif !defined(DELTA)
zprobe_zoffset = 0;
......@@ -718,7 +718,7 @@ void Config_ResetDefault() {
ECHO_LM(DB, "Z2 Endstop adjustement (mm):");
}
ECHO_LMV(DB, " M666 Z", z_endstop_adj );
#elif ENABLED(ENABLE_AUTO_BED_LEVELING)
#elif ENABLED(AUTO_BED_LEVELING_FEATURE)
if (!forReplay) {
ECHO_LM(DB, "Z Probe offset (mm)");
}
......
......@@ -30,7 +30,7 @@ void ConfigSD_ResetDefault();
"TME",
};
enum cfgSD_ENUM { //This need to be in the same order as cfgSD_KEY
enum cfgSD_ENUM { //This need to be in the same order as cfgSD_KEY
#if HAS_POWER_CONSUMPTION_SENSOR
SD_CFG_PWR,
#endif
......
This diff is collapsed.
......@@ -115,10 +115,8 @@
// LCD selection
#if ENABLED(U8GLIB_ST7920)
//U8GLIB_ST7920_128X64_RRD u8g(0,0,0);
//U8GLIB_ST7920_128X64_RRD u8g(0);
U8GLIB_ST7920_128X64_1X u8g(LCD_PINS_D4, LCD_PINS_ENABLE, LCD_PINS_RS);
#elif defined(U8GLIB_SSD1306)
U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_DEV_0|U8G_I2C_OPT_NO_ACK|U8G_I2C_OPT_FAST);
U8GLIB_ST7920_128X64_RRD u8g(0);
//U8GLIB_ST7920_128X64_1X u8g(LCD_PINS_D4, LCD_PINS_ENABLE, LCD_PINS_RS);
#elif ENABLED(MAKRPANEL)
// The MaKrPanel display, ST7565 controller as well
U8GLIB_NHD_C12864 u8g(DOGLCD_CS, DOGLCD_A0);
......@@ -128,10 +126,10 @@
#elif ENABLED(U8GLIB_LM6059_AF)
// Based on the Adafruit ST7565 (http://www.adafruit.com/products/250)
U8GLIB_LM6059 u8g(DOGLCD_CS, DOGLCD_A0);
#elif defined U8GLIB_SSD1306
#elif ENABLED(U8GLIB_SSD1306)
// Generic support for SSD1306 OLED I2C LCDs
U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NONE);
#elif defined(MINIPANEL)
#elif ENABLED(MINIPANEL)
// The MINIPanel display
U8GLIB_MINI12864 u8g(DOGLCD_CS, DOGLCD_A0);
#else
......@@ -193,7 +191,9 @@ char lcd_printPGM(const char* str) {
return n;
}
static bool show_splashscreen = true;
#if ENABLED(SHOW_BOOTSCREEN)
static bool show_bootscreen = true;
#endif
/* Warning: This function is called from interrupt context */
static void lcd_implementation_init() {
......@@ -207,7 +207,7 @@ static void lcd_implementation_init() {
pinMode(LCD_PIN_RESET, OUTPUT);
digitalWrite(LCD_PIN_RESET, HIGH);
#endif
#ifndef MINIPANEL//setContrast not working for Mini Panel
#if DISABLED(MINIPANEL) // setContrast not working for Mini Panel
u8g.setContrast(lcd_contrast);
#endif
// FIXME: remove this workaround
......@@ -223,31 +223,36 @@ static void lcd_implementation_init() {
u8g.setRot270(); // Rotate screen by 270°
#endif
// Show splashscreen
int offx = (u8g.getWidth() - START_BMPWIDTH) / 2;
#if ENABLED(START_BMPHIGH)
int offy = 0;
#else
int offy = DOG_CHAR_HEIGHT;
#endif
#if ENABLED(SHOW_BOOTSCREEN)
int offx = (u8g.getWidth() - START_BMPWIDTH) / 2;
#if ENABLED(START_BMPHIGH)
int offy = 0;
#else
int offy = DOG_CHAR_HEIGHT;
#endif
int txt1X = (u8g.getWidth() - (sizeof(STRING_SPLASH_LINE1) - 1)*DOG_CHAR_WIDTH) / 2;
int txt1X = (u8g.getWidth() - (sizeof(STRING_SPLASH_LINE1) - 1)*DOG_CHAR_WIDTH) / 2;
u8g.firstPage();
do {
if (show_bootscreen) {
u8g.drawBitmapP(offx, offy, START_BMPBYTEWIDTH, START_BMPHEIGHT, start_bmp);
lcd_setFont(FONT_MENU);
#ifndef STRING_SPLASH_LINE2
u8g.drawStr(txt1X, u8g.getHeight() - DOG_CHAR_HEIGHT, STRING_SPLASH_LINE1);
#else
int txt2X = (u8g.getWidth() - (sizeof(STRING_SPLASH_LINE2) - 1)*DOG_CHAR_WIDTH) / 2;
u8g.drawStr(txt1X, u8g.getHeight() - DOG_CHAR_HEIGHT*3/2, STRING_SPLASH_LINE1);
u8g.drawStr(txt2X, u8g.getHeight() - DOG_CHAR_HEIGHT*1/2, STRING_SPLASH_LINE2);
#endif
}
} while (u8g.nextPage());
u8g.firstPage();
do {
if (show_splashscreen) {
u8g.drawBitmapP(offx, offy, START_BMPBYTEWIDTH, START_BMPHEIGHT, start_bmp);
lcd_setFont(FONT_MENU);
#ifndef STRING_SPLASH_LINE2
u8g.drawStr(txt1X, u8g.getHeight() - DOG_CHAR_HEIGHT, STRING_SPLASH_LINE1);
#else
int txt2X = (u8g.getWidth() - (sizeof(STRING_SPLASH_LINE2) - 1)*DOG_CHAR_WIDTH) / 2;
u8g.drawStr(txt1X, u8g.getHeight() - DOG_CHAR_HEIGHT*3/2, STRING_SPLASH_LINE1);
u8g.drawStr(txt2X, u8g.getHeight() - DOG_CHAR_HEIGHT*1/2, STRING_SPLASH_LINE2);
#endif
if (show_bootscreen) {
delay(SPLASH_SCREEN_DURATION);
show_bootscreen = false;
}
} while (u8g.nextPage());
show_splashscreen = false;
#endif
}
static void lcd_implementation_clear() { } // Automatically cleared by Picture Loop
......
This diff is collapsed.
......@@ -29,6 +29,8 @@
#define LANGUAGE_CHOICE 7 // Pick your language from the list above
#endif
#include "Default_Version.h"
#define PROTOCOL_VERSION "1.0"
#if MB(ULTIMAKER)|| MB(ULTIMAKER_OLD)|| MB(ULTIMAIN_2)
......@@ -51,11 +53,6 @@
#define MACHINE_NAME "3D Printer"
#endif
#ifdef CUSTOM_MENDEL_NAME
#error CUSTOM_MENDEL_NAME deprecated - use CUSTOM_MACHINE_NAME
#define CUSTOM_MACHINE_NAME CUSTOM_MENDEL_NAME
#endif
#ifdef CUSTOM_MACHINE_NAME
#undef MACHINE_NAME
#define MACHINE_NAME CUSTOM_MACHINE_NAME
......@@ -109,11 +106,10 @@
#define MSG_INVALID_EXTRUDER "Invalid extruder"
#define MSG_INVALID_SOLENOID "Invalid solenoid"
#define MSG_ERR_NO_THERMISTORS "No thermistors - no temperature"
#define MSG_M115_REPORT "FIRMWARE_NAME:MarlinKimbra " BUILD_VERSION " SOURCE_CODE_URL:" SOURCE_CODE_URL " PROTOCOL_VERSION:" PROTOCOL_VERSION " MACHINE_TYPE:" MACHINE_NAME " EXTRUDER_COUNT:" STRINGIFY(EXTRUDERS) " UUID:" MACHINE_UUID "\n"
#define MSG_M115_REPORT "FIRMWARE_NAME:MarlinKimbra " SHORT_BUILD_VERSION " SOURCE_CODE_URL:" SOURCE_CODE_URL " PROTOCOL_VERSION:" PROTOCOL_VERSION " MACHINE_TYPE:" MACHINE_NAME " EXTRUDER_COUNT:" STRINGIFY(EXTRUDERS) " UUID:" MACHINE_UUID "\n"
#define MSG_COUNT_X " Count X: "
#define MSG_ERR_KILLED "Printer halted. kill() called!"
#define MSG_ERR_STOPPED "Printer stopped due to errors. Fix the error and use M999 to restart. (Temperature is reset. Set it after restarting)"
#define MSG_RESEND "Resend: "
#define MSG_UNKNOWN_COMMAND "Unknown command: \""
#define MSG_ACTIVE_DRIVER "Active Driver: "
#define MSG_ACTIVE_EXTRUDER "Active Extruder: "
......
This diff is collapsed.
......@@ -74,14 +74,14 @@ float mintravelfeedrate;
unsigned long axis_steps_per_sqr_second[3 + EXTRUDERS];
uint8_t last_extruder;
#if ENABLED(ENABLE_AUTO_BED_LEVELING)
#if ENABLED(AUTO_BED_LEVELING_FEATURE)
// Transform required to compensate for bed level
matrix_3x3 plan_bed_level_matrix = {
1.0, 0.0, 0.0,
0.0, 1.0, 0.0,
0.0, 0.0, 1.0
};
#endif // ENABLE_AUTO_BED_LEVELING
#endif // AUTO_BED_LEVELING_FEATURE
#if ENABLED(AUTOTEMP)
float autotemp_max = 250;
......@@ -480,11 +480,11 @@ float junction_deviation = 0.1;
// Add a new linear movement to the buffer. steps[X_AXIS], _y and _z is the absolute position in
// mm. Microseconds specify how many microseconds the move should take to perform. To aid acceleration
// calculation the caller must also provide the physical length of the line in millimeters.
#if ENABLED(ENABLE_AUTO_BED_LEVELING)
#if ENABLED(AUTO_BED_LEVELING_FEATURE)
void plan_buffer_line(float x, float y, float z, const float &e, float feed_rate, const uint8_t &extruder, const uint8_t &driver)
#else
void plan_buffer_line(const float &x, const float &y, const float &z, const float &e, float feed_rate, const uint8_t &extruder, const uint8_t &driver)
#endif // ENABLE_AUTO_BED_LEVELING
#endif // AUTO_BED_LEVELING_FEATURE
{
// Calculate the buffer head after we push this byte
int next_buffer_head = next_block_index(block_buffer_head);
......@@ -493,7 +493,7 @@ float junction_deviation = 0.1;
// Rest here until there is room in the buffer.
while (block_buffer_tail == next_buffer_head) idle();
#if ENABLED(ENABLE_AUTO_BED_LEVELING)
#if ENABLED(AUTO_BED_LEVELING_FEATURE)
apply_rotation_xyz(plan_bed_level_matrix, x, y, z);
#endif
......@@ -521,6 +521,13 @@ float junction_deviation = 0.1;
dy = target[Y_AXIS] - position[Y_AXIS],
dz = target[Z_AXIS] - position[Z_AXIS],
de = target[E_AXIS] - position[E_AXIS];
#if ENABLED(COREXY)
float da = dx + COREX_YZ_FACTOR * dy;
float db = dx - COREX_YZ_FACTOR * dy;
#elif ENABLED(COREXZ)
float da = dx + COREX_YZ_FACTOR * dz;
float dc = dx - COREX_YZ_FACTOR * dz;
#endif
#if ENABLED(PREVENT_DANGEROUS_EXTRUDE)
if (de) {
......@@ -562,14 +569,14 @@ float junction_deviation = 0.1;
#if ENABLED(COREXY)
// corexy planning
// these equations follow the form of the dA and dB equations on http://www.corexy.com/theory.html
block->steps[A_AXIS] = labs(dx + dy);
block->steps[B_AXIS] = labs(dx - dy);
block->steps[A_AXIS] = labs(da);
block->steps[B_AXIS] = labs(db);
block->steps[Z_AXIS] = labs(dz);
#elif ENABLED(COREXZ)
// corexz planning
block->steps[A_AXIS] = labs(dx + dz);
block->steps[A_AXIS] = labs(da);
block->steps[Y_AXIS] = labs(dy);
block->steps[C_AXIS] = labs(dx - dz);
block->steps[C_AXIS] = labs(dc);
#else
// default non-h-bot planning
block->steps[X_AXIS] = labs(dx);
......@@ -603,14 +610,14 @@ float junction_deviation = 0.1;
if (dx < 0) db |= BIT(X_HEAD); // Save the real Extruder (head) direction in X Axis
if (dy < 0) db |= BIT(Y_HEAD); // ...and Y
if (dz < 0) db |= BIT(Z_AXIS);
if (dx + dy < 0) db |= BIT(A_AXIS); // Motor A direction
if (dx - dy < 0) db |= BIT(B_AXIS); // Motor B direction
if (da < 0) db |= BIT(A_AXIS); // Motor A direction
if (db < 0) db |= BIT(B_AXIS); // Motor B direction
#elif ENABLED(COREXZ)
if (dx < 0) db |= BIT(X_HEAD); // Save the real Extruder (head) direction in X Axis
if (dy < 0) db |= BIT(Y_AXIS);
if (dz < 0) db |= BIT(Z_HEAD); // ...and Z
if (dx + dz < 0) db |= BIT(A_AXIS); // Motor A direction
if (dx - dz < 0) db |= BIT(C_AXIS); // Motor B direction
if (da < 0) db |= BIT(A_AXIS); // Motor A direction
if (dc < 0) db |= BIT(C_AXIS); // Motor B direction
#else
if (dx < 0) db |= BIT(X_AXIS);
if (dy < 0) db |= BIT(Y_AXIS);
......@@ -627,7 +634,7 @@ float junction_deviation = 0.1;
enable_x();
enable_y();
}
#ifndef Z_LATE_ENABLE
#if DISABLED(Z_LATE_ENABLE)
if (block->steps[Z_AXIS]) enable_z();
#endif
#elif ENABLED(COREXZ)
......@@ -639,14 +646,14 @@ float junction_deviation = 0.1;
#else
if (block->steps[X_AXIS]) enable_x();
if (block->steps[Y_AXIS]) enable_y();
#ifndef Z_LATE_ENABLE
#if DISABLED(Z_LATE_ENABLE)
if (block->steps[Z_AXIS]) enable_z();
#endif
#endif
// Enable extruder(s)
if (block->steps[E_AXIS]) {
#if !defined(MKR4) && !defined(NPR2)
#if DISABLED(MKR4) && DISABLED(NPR2)
if (DISABLE_INACTIVE_EXTRUDER) { //enable only selected extruder
for (int i = 0; i < EXTRUDERS; i++)
......@@ -745,15 +752,15 @@ float junction_deviation = 0.1;
delta_mm[X_HEAD] = dx / axis_steps_per_unit[A_AXIS];
delta_mm[Y_HEAD] = dy / axis_steps_per_unit[B_AXIS];
delta_mm[Z_AXIS] = dz / axis_steps_per_unit[Z_AXIS];
delta_mm[A_AXIS] = (dx + dy) / axis_steps_per_unit[A_AXIS];
delta_mm[B_AXIS] = (dx - dy) / axis_steps_per_unit[B_AXIS];
delta_mm[A_AXIS] = da / axis_steps_per_unit[A_AXIS];
delta_mm[B_AXIS] = db / axis_steps_per_unit[B_AXIS];
#elif ENABLED(COREXZ)
float delta_mm[6];
delta_mm[X_HEAD] = dx / axis_steps_per_unit[A_AXIS];
delta_mm[Y_AXIS] = dy / axis_steps_per_unit[Y_AXIS];
delta_mm[Z_HEAD] = dz / axis_steps_per_unit[C_AXIS];
delta_mm[A_AXIS] = (dx + dz) / axis_steps_per_unit[A_AXIS];
delta_mm[C_AXIS] = (dx - dz) / axis_steps_per_unit[C_AXIS];
delta_mm[A_AXIS] = da / axis_steps_per_unit[A_AXIS];
delta_mm[C_AXIS] = dc / axis_steps_per_unit[C_AXIS];
#else
float delta_mm[4];
delta_mm[X_AXIS] = dx / axis_steps_per_unit[X_AXIS];
......@@ -1040,7 +1047,7 @@ float junction_deviation = 0.1;
} // plan_buffer_line()
#if ENABLED(ENABLE_AUTO_BED_LEVELING)
#if ENABLED(AUTO_BED_LEVELING_FEATURE)
vector_3 plan_get_position() {
vector_3 position = vector_3(st_get_position_mm(X_AXIS), st_get_position_mm(Y_AXIS), st_get_position_mm(Z_AXIS));
......@@ -1053,15 +1060,15 @@ float junction_deviation = 0.1;
return position;
}
#endif // ENABLE_AUTO_BED_LEVELING
#endif // AUTO_BED_LEVELING_FEATURE
#if ENABLED(ENABLE_AUTO_BED_LEVELING)
#if ENABLED(AUTO_BED_LEVELING_FEATURE)
void plan_set_position(float x, float y, float z, const float &e)
#else
void plan_set_position(const float &x, const float &y, const float &z, const float &e)
#endif // ENABLE_AUTO_BED_LEVELING
#endif // AUTO_BED_LEVELING_FEATURE
{
#if ENABLED(ENABLE_AUTO_BED_LEVELING)
#if ENABLED(AUTO_BED_LEVELING_FEATURE)
apply_rotation_xyz(plan_bed_level_matrix, x, y, z);
#endif
......
......@@ -82,7 +82,7 @@ extern volatile unsigned char block_buffer_head;
extern volatile unsigned char block_buffer_tail;
FORCE_INLINE uint8_t movesplanned() { return BLOCK_MOD(block_buffer_head - block_buffer_tail + BLOCK_BUFFER_SIZE); }
#if ENABLED(ENABLE_AUTO_BED_LEVELING)
#if ENABLED(AUTO_BED_LEVELING_FEATURE)
#include "vector_3.h"
......@@ -110,7 +110,7 @@ FORCE_INLINE uint8_t movesplanned() { return BLOCK_MOD(block_buffer_head - block
#else
void plan_buffer_line(const float &x, const float &y, const float &z, const float &e, float feed_rate, const uint8_t &extruder, const uint8_t &driver);
void plan_set_position(const float &x, const float &y, const float &z, const float &e);
#endif // ENABLE_AUTO_BED_LEVELING
#endif // AUTO_BED_LEVELING_FEATURE
void plan_set_e_position(const float &e);
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment