Commit 7f1a8f8d authored by MagoKimbra's avatar MagoKimbra

Update

parent 9f02c419
......@@ -2,6 +2,7 @@
#define CONFIGURATION_H
#include "boards.h"
#include "macros.h"
//===========================================================================
//============================= Getting Started =============================
......@@ -335,9 +336,10 @@
//#define ENCODER_STEPS_PER_MENU_ITEM 5 // Set according to ENCODER_PULSES_PER_STEP or your liking
//#define ULTIMAKERCONTROLLER //as available from the Ultimaker online store.
//#define ULTIPANEL //the UltiPanel as on Thingiverse
//#define SPEAKER // The sound device is a speaker - not a buzzer. A buzzer resonates with his own frequency.
//#define LCD_FEEDBACK_FREQUENCY_DURATION_MS 100 // the duration the buzzer plays the UI feedback sound. ie Screen Click
//#define LCD_FEEDBACK_FREQUENCY_HZ 1000 // this is the tone frequency the buzzer plays when on UI feedback. ie Screen Click
// 0 to disable buzzer feedback
// 0 to disable buzzer feedback. Test with M300 S<frequency Hz> P<duration ms>
// Original RADDS Display from Willy
// http://max3dshop.org/index.php/default/elektronik/radds-lcd-sd-display-with-reset-and-back-buttom.html
......@@ -357,8 +359,7 @@
//#define VIKI2
//#define miniVIKI
// This is a new controller currently under development.
// https://github.com/eboston/Adafruit-ST7565-Full-Graphic-Controller/
// This is a new controller currently under development. https://github.com/eboston/Adafruit-ST7565-Full-Graphic-Controller/
//
// ==> REMEMBER TO INSTALL U8glib to your ARDUINO library folder: http://code.google.com/p/u8glib/wiki/u8glib
//#define ELB_FULL_GRAPHIC_CONTROLLER
......@@ -388,6 +389,10 @@
// REMEMBER TO INSTALL LiquidCrystal_I2C.h in your ARDUINO library folder: https://github.com/kiyoshigawa/LiquidCrystal_I2C
//#define RA_CONTROL_PANEL
// The MakerLab Mini Panel with graphic controller and SD support
// http://reprap.org/wiki/Mini_panel
// #define MINIPANEL
/**
* I2C Panels
*/
......@@ -395,6 +400,12 @@
//#define LCD_I2C_SAINSMART_YWROBOT
// PANELOLU2 LCD with status LEDs, separate encoder and click inputs
//
// This uses the LiquidTWI2 library v1.2.3 or later ( https://github.com/lincomatic/LiquidTWI2 )
// Make sure the LiquidTWI2 directory is placed in the Arduino or Sketchbook libraries subdirectory.
// (v1.2.3 no longer requires you to define PANELOLU in the LiquidTWI2.h library header file)
// Note: The PANELOLU2 encoder click input can either be directly connected to a pin
// (if BTN_ENC defined to != -1) or read through I2C (when BTN_ENC == -1).
//#define LCD_I2C_PANELOLU2
// Panucatt VIKI LCD with status LEDs, integrated click & L/R/U/P buttons, separate encoder inputs
......@@ -411,6 +422,12 @@
// LCD configuration: http://reprap.org/wiki/SAV_3D_LCD
//#define SAV_3DLCD
/**
* Nextion HMI panel
*/
//
//#define NEXTION
// option for invert rotary switch
//#define INVERT_ROTARY_SWITCH
......@@ -450,10 +467,10 @@
//===========================================================================
//=============================Additional Features===========================
//============================ Additional Features ==========================
//===========================================================================
//=================================== EEPROM ================================
//================================= EEPROM ==================================
// The microcontroller can store settings in the EEPROM, e.g. max velocity...
// M500 - stores parameters in EEPROM
// M501 - reads parameters from EEPROM (if you need reset them after you changed them temporarily).
......@@ -464,6 +481,11 @@
// to disable EEPROM Serial responses and decrease program space by ~1700 byte: comment this out:
// please keep turned on if you can.
//#define DISABLE_M503
//
// M100 Free Memory Watcher
//
#define M100_FREE_MEMORY_WATCHER // uncomment to add the M100 Free Memory Watcher for debug purpose
//===========================================================================
//========================== EXTRA SETTINGS ON SD ===========================
......@@ -513,12 +535,27 @@
// leaving it defining as 0 will disable the servo subsystem
#define NUM_SERVOS 0 // Servo index starts with 0 for M280 command
#if NUM_SERVOS > 0
// Servo Endstops
// This allows for servo actuated endstops, primary usage is for the Z Axis to eliminate calibration or bed height changes.
// Use M666 command to correct for switch height offset to actual nozzle height. Store that setting with M500.
//
#define SERVO_ENDSTOPS {-1, -1, 0} // Servo index for X, Y, Z. Disable with -1
#define SERVO_ENDSTOP_ANGLES {0,0,0,0,90,0} // X,Y,Z Axis Extend and Retract angles
// Servo deactivation
//
// With this option servos are powered only during movement, then turned off to prevent jitter.
//#define DEACTIVATE_SERVOS_AFTER_MOVE
#ifdef DEACTIVATE_SERVOS_AFTER_MOVE
// Delay (in microseconds) before turning the servo off. This depends on the servo speed.
// 300ms is a good value but you can try less delay.
// If the servo can't reach the requested position, increase it.
#define SERVO_DEACTIVATION_DELAY 300
#endif
#endif // NUM_SERVOS > 0
//===========================================================================
......
......@@ -26,24 +26,52 @@
#define DELTA_CARRIAGE_OFFSET 20.0 // mm
// Bed Printer radius
#define PRINTER_RADIUS 70 // mm
#define PRINTER_RADIUS 75 // mm
//Uncomment to enable autocalibration debug messages
// Radius for probe
#define DELTA_PROBABLE_RADIUS (PRINTER_RADIUS)
// Effective horizontal distance bridged by diagonal push rods.
#define DEFAULT_DELTA_RADIUS (DELTA_SMOOTH_ROD_OFFSET-DELTA_EFFECTOR_OFFSET-DELTA_CARRIAGE_OFFSET)
// Uncomment to enable autocalibration debug messages
#define DEBUG_MESSAGES
// Speed for autocalibration travel and probing moves
#define AUTOCAL_TRAVELRATE 100 // mm/sec
#define AUTOCAL_PROBERATE 50 // mm/sec
// Precision for G30 delta autocalibration function
#define AUTOCALIBRATION_PRECISION 0.1 // mm
//Endstop Offset Adjustment - All values are in mm and must be negative (to move down away from endstop switches)
#define TOWER_A_ENDSTOP_ADJ 0 // Front Left Tower
#define TOWER_B_ENDSTOP_ADJ 0 // Front Right Tower
#define TOWER_C_ENDSTOP_ADJ 0 // Rear Tower
//Tower Position Adjustment - Adj x Degrees around delta radius (- move clockwise / + move anticlockwise)
#define TOWER_A_POSITION_ADJ 0 //Front Left Tower
#define TOWER_B_POSITION_ADJ 0 //Front Right Tower
#define TOWER_C_POSITION_ADJ 0 //Rear Tower
//Tower Radius Adjustment - Adj x mm in/out from centre of printer (- move in / + move out)
#define TOWER_A_RADIUS_ADJ 0 //Front Left Tower
#define TOWER_B_RADIUS_ADJ 0 //Front Right Tower
#define TOWER_C_RADIUS_ADJ 0 //Rear Tower
//Diagonal Rod Adjustment - Adj diag rod for Tower by x mm from DEFAULT_DELTA_DIAGONAL_ROD value
#define TOWER_A_DIAGROD_ADJ 0 //Front Left Tower
#define TOWER_B_DIAGROD_ADJ 0 //Front Right Tower
#define TOWER_C_DIAGROD_ADJ 0 //Rear Tower
// Z-Probe variables
// Start and end location values are used to deploy/retract the probe (will move from start to end and back again)
#define PROBING_FEEDRATE 1000 // Speed in mm/min for individual probe Use: G30 A F600
#define Z_PROBE_OFFSET {0, 0, -1, 0} // X, Y, Z, E distance between hotend nozzle and deployed bed leveling probe.
#define Z_PROBE_DEPLOY_START_LOCATION {0, 0, 30, 0} // X, Y, Z, E start location for z-probe deployment sequence
#define Z_PROBE_DEPLOY_END_LOCATION {0, 0, 30, 0} // X, Y, Z, E end location for z-probe deployment sequence
#define Z_PROBE_RETRACT_START_LOCATION {0, 0, 30, 0} // X, Y, Z, E start location for z-probe retract sequence
#define Z_PROBE_RETRACT_END_LOCATION {0, 0, 30, 0} // X, Y, Z, E end location for z-probe retract sequence
#define Z_RAISE_BETWEEN_PROBINGS 3 // How much the nozzle will be raised when travelling from between next probing points
#define AUTOLEVEL_GRID 20 // Distance between autolevel Z probing points, should be less than print surface radius/3.
#define Z_PROBE_OFFSET {0, 0, -1} // X, Y, Z, E distance between hotend nozzle and deployed bed leveling probe.
#define Z_PROBE_DEPLOY_START_LOCATION {0, 0, 20} // X, Y, Z, E start location for z-probe deployment sequence
#define Z_PROBE_DEPLOY_END_LOCATION {0, 0, 20} // X, Y, Z, E end location for z-probe deployment sequence
#define Z_PROBE_RETRACT_START_LOCATION {0, 0, 20} // X, Y, Z, E start location for z-probe retract sequence
#define Z_PROBE_RETRACT_END_LOCATION {0, 0, 20} // X, Y, Z, E end location for z-probe retract sequence
#define Z_RAISE_BETWEEN_PROBINGS 5 // How much the nozzle will be raised when travelling from between next probing points
#define AUTO_BED_LEVELING_GRID_POINTS 9 // Works best with ACCURATE_BED_LEVELING_POINTS 5 or higher.
//===========================================================================
......
......@@ -151,12 +151,13 @@
// 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 Z_DUAL_ENDSTOPS
#ifdef Z_DUAL_ENDSTOPS
#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
#ifdef 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.
......@@ -286,7 +287,6 @@
#define ENCODER_RATE_MULTIPLIER // If defined, certain menu edit operations automatically multiply the steps when the encoder is moved quickly
#define ENCODER_10X_STEPS_PER_SEC 75 // If the encoder steps per sec exceeds this value, multiply steps moved x10 to quickly advance the value
#define ENCODER_100X_STEPS_PER_SEC 160 // If the encoder steps per sec exceeds this value, multiply steps moved x100 to really quickly advance the value
//#define ENCODER_RATE_MULTIPLIER_DEBUG // If defined, output the encoder steps per second value
//#define CHDK 4 //Pin for triggering CHDK to take a picture see how to use it here http://captain-slow.dk/2014/03/09/3d-printing-timelapses/
#define CHDK_DELAY 50 //How long in ms the pin should stay HIGH before going LOW again
......@@ -326,6 +326,12 @@
// This allows hosts to request long names for files and folders with M33
//#define LONG_FILENAME_HOST_SUPPORT
// This option allows you to abort SD printing when any endstop is triggered.
// This feature must be enabled with "M540 S1" or from the LCD menu.
// To have any effect, endstops must be enabled during SD printing.
// With ENDSTOPS_ONLY_FOR_HOMING you must send "M120" to enable endstops.
//#define ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED
#endif // SDSUPPORT
// for dogm lcd displays you can choose some additional fonts:
......@@ -349,9 +355,6 @@
//#define WATCHDOG_RESET_MANUAL
#endif
// Enable the option to stop SD printing when hitting and endstops, needs to be enabled from the LCD menu when this option is enabled.
//#define ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED
// Babystepping enables the user to control the axis in tiny amounts, independently from the normal printing process
// it can e.g. be used to change z-positions in the print startup phase in real-time
// does not respect endstops!
......
#define M100_FREE_MEMORY_DUMPER // Comment out to remove Dump sub-command
#define M100_FREE_MEMORY_CORRUPTOR // Comment out to remove Corrupt sub-command
// M100 Free Memory Watcher
//
// This code watches the free memory block between the bottom of the heap and the top of the stack.
// This memory block is initialized and watched via the M100 command.
//
// M100 I Initializes the free memory block and prints vitals statistics about the area
// M100 F Identifies how much of the free memory block remains free and unused. It also
// detects and reports any corruption within the free memory block that may have
// happened due to errant firmware.
// M100 D Does a hex display of the free memory block along with a flag for any errant
// data that does not match the expected value.
// M100 C x Corrupts x locations within the free memory block. This is useful to check the
// correctness of the M100 F and M100 D commands.
//
// Initial version by Roxy-3DPrintBoard
//
//
#include "Marlin.h"
#ifdef M100_FREE_MEMORY_WATCHER
extern void *__brkval;
extern size_t __heap_start, __heap_end, __flp;
//
// Declare all the functions we need from Marlin_Main.cpp to do the work!
//
float code_value();
long code_value_long();
bool code_seen(char );
//
// Utility functions used by M100 to get its work done.
//
unsigned char *top_of_stack();
void prt_hex_nibble( unsigned int );
void prt_hex_byte(unsigned int );
void prt_hex_word(unsigned int );
int how_many_E5s_are_here( unsigned char *);
void gcode_M100() {
static int m100_not_initialized = 1;
unsigned char *sp, *ptr;
int i, j, n;
//
// M100 D dumps the free memory block from __brkval to the stack pointer.
// malloc() eats memory from the start of the block and the stack grows
// up from the bottom of the block. Solid 0xE5's indicate nothing has
// used that memory yet. There should not be anything but 0xE5's within
// the block of 0xE5's. If there is, that would indicate memory corruption
// probably caused by bad pointers. Any unexpected values will be flagged in
// the right hand column to help spotting them.
//
#ifdef M100_FREE_MEMORY_DUMPER // Comment out to remove Dump sub-command
if ( code_seen('D') ) {
ptr = (unsigned char *) __brkval;
//
// We want to start and end the dump on a nice 16 byte boundry even though
// the values we are using are not 16 byte aligned.
//
ECHO_M("\n__brkval : ");
prt_hex_word( (unsigned int) ptr );
ptr = (unsigned char *) ((unsigned long) ptr & 0xfff0);
sp = top_of_stack();
ECHO_M("\nStack Pointer : ");
prt_hex_word( (unsigned int) sp );
ECHO_M("\n");
sp = (unsigned char *) ((unsigned long) sp | 0x000f);
n = sp - ptr;
//
// This is the main loop of the Dump command.
//
while ( ptr < sp ) {
prt_hex_word( (unsigned int) ptr); // Print the address
ECHO_M(":");
for(i = 0; i < 16; i++) { // and 16 data bytes
prt_hex_byte( *(ptr+i));
ECHO_M(" ");
delay(2);
}
ECHO_M("|"); // now show where non 0xE5's are
for(i = 0; i < 16; i++) {
delay(2);
if ( *(ptr+i)==0xe5)
ECHO_M(" ");
else
ECHO_M("?");
}
ECHO_M("\n");
ptr += 16;
delay(2);
}
ECHO_M("Done.\n");
return;
}
#endif
//
// M100 F requests the code to return the number of free bytes in the memory pool along with
// other vital statistics that define the memory pool.
//
if ( code_seen('F') ) {
int max_addr = (int) __brkval;
int max_cnt = 0;
int block_cnt = 0;
ptr = (unsigned char *) __brkval;
sp = top_of_stack();
n = sp - ptr;
// Scan through the range looking for the biggest block of 0xE5's we can find
for(i = 0; i < n; i++) {
if ( *(ptr+i) == (unsigned char) 0xe5) {
j = how_many_E5s_are_here( (unsigned char *) ptr+i );
if ( j > 8) {
ECHO_MV("Found ", j );
ECHO_M(" bytes free at 0x");
prt_hex_word( (int) ptr+i );
ECHO_M("\n");
i += j;
block_cnt++;
}
if ( j>max_cnt) { // We don't do anything with this information yet
max_cnt = j; // but we do know where the biggest free memory block is.
max_addr = (int) ptr+i;
}
}
}
if (block_cnt>1)
ECHO_EM("\nMemory Corruption detected in free memory area.\n");
ECHO_M("\nDone.\n");
return;
}
//
// M100 C x Corrupts x locations in the free memory pool and reports the locations of the corruption.
// This is useful to check the correctness of the M100 D and the M100 F commands.
//
#ifdef M100_FREE_MEMORY_CORRUPTOR
if ( code_seen('C') ) {
int x; // x gets the # of locations to corrupt within the memory pool
x = code_value();
ECHO_EM("Corrupting free memory block.\n");
ptr = (unsigned char *) __brkval;
ECHO_MV("\n__brkval : ",(long) ptr );
ptr += 8;
sp = top_of_stack();
ECHO_MV("\nStack Pointer : ",(long) sp );
ECHO_EM("\n");
n = sp - ptr - 64; // -64 just to keep us from finding interrupt activity that
// has altered the stack.
j = n / (x+1);
for(i = 1; i <= x; i++) {
*(ptr+(i*j)) = i;
ECHO_M("\nCorrupting address: 0x");
prt_hex_word( (unsigned int) (ptr+(i*j)) );
}
ECHO_EM("\n");
return;
}
#endif
//
// M100 I Initializes the free memory pool so it can be watched and prints vital
// statistics that define the free memory pool.
//
if (m100_not_initialized || code_seen('I') ) { // If no sub-command is specified, the first time
ECHO_EM("Initializing free memory block.\n"); // this happens, it will Initialize.
ptr = (unsigned char *) __brkval; // Repeated M100 with no sub-command will not destroy the
ECHO_MV("\n__brkval : ",(long) ptr ); // state of the initialized free memory pool.
ptr += 8;
sp = top_of_stack();
ECHO_MV("\nStack Pointer : ",(long) sp );
ECHO_EM("\n");
n = sp - ptr - 64; // -64 just to keep us from finding interrupt activity that
// has altered the stack.
ECHO_V( n );
ECHO_EM(" bytes of memory initialized.\n");
for(i = 0; i < n; i++)
*(ptr+i) = (unsigned char) 0xe5;
for(i = 0; i < n; i++) {
if ( *(ptr+i) != (unsigned char) 0xe5 ) {
ECHO_MV("? address : ", (unsigned long) ptr+i );
ECHO_MV("=", *(ptr+i) );
ECHO_EM("\n");
}
}
m100_not_initialized = 0;
ECHO_EM("Done.\n");
return;
}
return;
}
// top_of_stack() returns the location of a variable on its stack frame. The value returned is above
// the stack once the function returns to the caller.
unsigned char *top_of_stack() {
unsigned char x;
return &x + 1; // x is pulled on return;
}
//
// 3 support routines to print hex numbers. We can print a nibble, byte and word
//
void prt_hex_nibble( unsigned int n ) {
if ( n <= 9 )
ECHO_V(n);
else
ECHO_V( (char) ('A'+n-10) );
delay(2);
}
void prt_hex_byte(unsigned int b) {
prt_hex_nibble( ( b & 0xf0 ) >> 4 );
prt_hex_nibble( b & 0x0f );
}
void prt_hex_word(unsigned int w) {
prt_hex_byte( ( w & 0xff00 ) >> 8 );
prt_hex_byte( w & 0x0ff );
}
// how_many_E5s_are_here() is a utility function to easily find out how many 0xE5's are
// at the specified location. Having this logic as a function simplifies the search code.
//
int how_many_E5s_are_here( unsigned char *p) {
int n;
for(n = 0; n < 32000; n++) {
if ( *(p+n) != (unsigned char) 0xe5)
return n-1;
}
return -1;
}
#endif
......@@ -99,12 +99,6 @@ else ifeq ($(HARDWARE_MOTHERBOARD),34)
HARDWARE_VARIANT ?= arduino
MCU ?= atmega2560
#Duemilanove w/ ATMega328P pin assignment
else ifeq ($(HARDWARE_MOTHERBOARD),4)
HARDWARE_VARIANT ?= arduino
HARDWARE_SUB_VARIANT ?= standard
MCU ?= atmega328p
#Gen6
else ifeq ($(HARDWARE_MOTHERBOARD),5)
HARDWARE_VARIANT ?= Gen6
......@@ -269,7 +263,7 @@ CXXSRC = WMath.cpp WString.cpp Print.cpp Marlin_main.cpp \
SdFile.cpp SdVolume.cpp planner.cpp stepper.cpp \
temperature.cpp cardreader.cpp configuration_store.cpp \
watchdog.cpp SPI.cpp servo.cpp Tone.cpp ultralcd.cpp digipot_mcp4451.cpp \
vector_3.cpp qr_solve.cpp
vector_3.cpp qr_solve.cpp buzzer.cpp
ifeq ($(LIQUID_TWI2), 0)
CXXSRC += LiquidCrystal.cpp
else
......@@ -356,11 +350,11 @@ LDFLAGS = -lm
AVRDUDE_PORT = $(UPLOAD_PORT)
AVRDUDE_WRITE_FLASH = -Uflash:w:$(BUILD_DIR)/$(TARGET).hex:i
ifeq ($(shell uname -s), Linux)
AVRDUDE_CONF = $(ARDUINO_INSTALL_DIR)/hardware/tools/avrdude.conf
AVRDUDE_CONF = /etc/avrdude/avrdude.conf
else
AVRDUDE_CONF = $(ARDUINO_INSTALL_DIR)/hardware/tools/avr/etc/avrdude.conf
endif
AVRDUDE_FLAGS = -q -q -D -C$(AVRDUDE_CONF) \
AVRDUDE_FLAGS = -D -C$(AVRDUDE_CONF) \
-p$(MCU) -P$(AVRDUDE_PORT) -c$(AVRDUDE_PROGRAMMER) \
-b$(UPLOAD_RATE)
......
......@@ -31,22 +31,6 @@
#include "Arduino.h"
// Macros for bit masks
#define BIT(b) (1<<(b))
#define TEST(n,b) (((n)&BIT(b))!=0)
#define SET_BIT(n,b,value) (n) ^= ((-value)^(n)) & (BIT(b))
// Macros for maths shortcuts
#define M_PI 3.1415926536
#define RADIANS(d) ((d)*M_PI/180.0)
#define DEGREES(r) ((r)*180.0/M_PI)
#define SIN_60 0.8660254037844386
#define COS_60 0.5
// Macros to contrain values
#define NOLESS(v,n) do{ if (v < n) v = n; }while(0)
#define NOMORE(v,n) do{ if (v > n) v = n; }while(0)
typedef unsigned long millis_t;
// Arduino < 1.0.0 does not define this, so we need to do it ourselves
......@@ -157,6 +141,8 @@ void ok_to_send();
#ifdef DELTA
float probe_bed(float x, float y);
void set_delta_constants();
void adj_tower_delta(int tower);
void adj_tower_radius(int tower);
void home_delta_axis();
void calibration_report();
void bed_probe_all();
......@@ -165,6 +151,7 @@ void ok_to_send();
void save_carriage_positions(int position_num);
void calculate_delta(float cartesian[3]);
void adjust_delta(float cartesian[3]);
void adj_endstops();
void reset_bed_level();
void prepare_move_raw();
extern float delta[3];
......@@ -172,6 +159,12 @@ void ok_to_send();
extern float delta_tower1_x, delta_tower1_y;
extern float delta_tower2_x, delta_tower2_y;
extern float delta_tower3_x, delta_tower3_y;
extern float z_probe_offset[3];
extern float endstop_adj[3];
extern float tower_adj[6];
extern float diagrod_adj[3];
extern float delta_radius;
extern float delta_diagonal_rod;
#endif
#ifdef SCARA
void calculate_delta(float cartesian[3]);
......
This source diff could not be displayed because it is too large. You can view the blob instead.
/**
* @file NexButton.cpp
*
* API of NexButton.
*
* @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
* 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"
/**
* 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)
{
}
/**
* 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;
cmd += "get ";
cmd += getObjName();
cmd += ".txt";
sendCommand(cmd.c_str());
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;
cmd += getObjName();
cmd += ".txt=\"";
cmd += buffer;
cmd += "\"";
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.
*
* @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
* 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__
#ifdef __cplusplus
#include "NexTouch.h"
/**
* NexButton,subclass of NexTouch,provides simple methods to control button component.
*
*/
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);
};
#endif /* #ifdef __cplusplus */
#endif /* #ifndef __NEXBUTTON_H__ */
/**
* @file NexHotspot.cpp
*
* API of NexHotspot.
*
* @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
* 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"
/**
* 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)
{
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.
*
* @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
* 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__
#ifdef __cplusplus
#include "NexTouch.h"
/**
* NexHotspot,subclass of NexTouch,provides simple methods to control hotspot 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);
};
#endif /* #ifdef __cplusplus */
#endif /* #ifndef __NEXHOTSPOT_H__ */
/**
* @file NexPage.cpp
*
* API of NexPage.
*
* @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
* 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"
/**
* 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)
{
}
/**
* Change page.
*
* @retval true - success.
* @retval false - failed.
*/
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();
}
/**
* 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.
*
* @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
* 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__
#ifdef __cplusplus
#include "NexTouch.h"
/**
* NexPage,subclass of NexTouch,provides simple methods to control page component.
*
*/
class NexPage: public NexTouch
{
public: /* methods */
NexPage(NexPid pid, NexCid cid, char *name, NexTouchEventCb pop = NULL, void *pop_ptr = NULL);
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.
*
* @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
* 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"
/**
* 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)
{
}
/**
* 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 ");
cmd += getObjName();
cmd += ".pic";
sendCommand(cmd.c_str());
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};
String cmd;
utoa(number, buf, 10);
cmd += getObjName();
cmd += ".pic=";
cmd += buf;
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.
*
* @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
* 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__
#ifdef __cplusplus
#include "NexTouch.h"
/**
* NexPicture,subclass of NexTouch,provides simple methods to control picture component.
*
*/
class NexPicture: public NexTouch
{
public: /* methods */
NexPicture(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);
};
#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.
*
* @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
* 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"
/**
* Constructor,inherited NexTouch's constructor function.
*
*/
NexProgressBar::NexProgressBar(NexPid pid, NexCid cid, char *name)
:NexTouch(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 ");
cmd += getObjName();
cmd += ".val";
sendCommand(cmd.c_str());
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};
String cmd;
utoa(number, buf, 10);
cmd += getObjName();
cmd += ".val=";
cmd += buf;
sendCommand(cmd.c_str());
return recvRetCommandFinished();
}
/**
* @file NexProgressBar.h
*
* API of NexProgressBar.
*
* @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
* 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__
#ifdef __cplusplus
#include "NexTouch.h"
/**
* NexProgressBar,subclass of NexTouch,provides simple methods to control progress bar component.
*
*/
class NexProgressBar: public NexTouch
{
public: /* methods */
NexProgressBar(NexPid pid, NexCid cid, char *name);
bool getValue(uint32_t *number);
bool setValue(uint32_t number);
};
#endif /* #ifdef __cplusplus */
#endif /* #ifndef __NEXPROGRESSBAR_H__ */
/**
* @file NexSerialConfig.h
*
* Serial configure.
*
* @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
* 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 __NexSerialConfig_H__
#define __NexSerialConfig_H__
// Nextion Baudrate - default 9600
// 2400 - 4800 - 9600 - 19200 - 38400 - 57600 - 115200
#define NEXTION_BAUDRATE 9600
/*enable debug serial*/
//#define DEBUG_SERIAL_ENABLE
/*define serial for debug*/
#define dbSerial Serial
#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)
#endif
/*define serial for communicate with Nextion screen*/
#define nexSerial Serial1
#endif
/**
* @file NexSlice.cpp
*
* API of NexSlice.
*
* @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
* 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 "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)
{
}
/*
* 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)
{
String cmd = String("get ");
cmd += getObjName();
cmd += ".picc";
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)
{
char buf[10] = {0};
String cmd;
utoa(number, buf, 10);
cmd += getObjName();
cmd += ".picc=";
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 NexSlice.h
*
* API of NexSlice.
*
* @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
* 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 __NEXSLICE_H__
#define __NEXSLICE_H__
#ifdef __cplusplus
#include "NexTouch.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);
};
#endif /* #ifdef __cplusplus */
#endif /* #ifndef __NEXSLICE_H__ */
/**
* @file NexText.cpp
*
* API of NexText.
*
* @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
* 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"
/**
* 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)
{
}
/**
* 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;
cmd += "get ";
cmd += getObjName();
cmd += ".txt";
sendCommand(cmd.c_str());
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;
cmd += getObjName();
cmd += ".txt=\"";
cmd += buffer;
cmd += "\"";
sendCommand(cmd.c_str());
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};
String cmd;
utoa(value, buf, 10);
cmd += getObjName();
cmd += ".pco=";
cmd += buf;
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.
*
* @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
* 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__
#ifdef __cplusplus
#include "NexTouch.h"
/**
* NexText,subclass of NexTouch,provides simple methods to control text component.
*
*/
class NexText: public NexTouch
{
public: /* methods */
NexText(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);
bool setColor(uint32_t value);
};
#endif /* #ifdef __cplusplus */
#endif /* #ifndef __NEXTEXT_H__ */
/**
* @file NexTouch.cpp
*
* API of Nextion.
*
* @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
* 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"
uint8_t NexTouch::__buffer[256] = {0};
/**
* Watting for Nextion's touch event.
*
* @param list - index to Nextion Components list.
*
*/
uint8_t NexTouch::mainEventLoop(NexTouch **list) {
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) {
//memset(__buffer, 0, sizeof(__buffer));
__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])
iterate(list, (NexPid)__buffer[1], (NexCid)__buffer[2], (NexEventType)__buffer[3]);
}
}
}
return 0;
}
/**
* Constructor of Nextouch.
*
* @param pid - page id.
* @param cid - component id.
* @param name - component name.
* @param pop - pop event function pointer.
* @param pop_ptr - the parameter was transmitted to pop event function pointer.
* @param push - push event function pointer.
* @param push_ptr - the parameter was transmitted to push event function pointer.
*
*/
NexTouch::NexTouch(NexPid pid, NexCid cid, char *name,
NexTouchEventCb pop, void *pop_ptr,
NexTouchEventCb push, void *push_ptr) {
this->pid = pid;
this->cid = cid;
this->name = name;
this->cbPush = push;
this->cbPop = pop;
this->__cbpop_ptr = pop_ptr;
this->__cbpush_ptr = push_ptr;
}
/**
* Get page id.
*
* @return the id of page.
*/
NexPid NexTouch::getPid(void) {
return pid;
}
/**
* Get component id.
*
* @return the id of component.
*/
NexCid NexTouch::getCid(void) {
return cid;
}
/**
* Get component name.
*
* @return the name of component.
*/
const char* NexTouch::getObjName(void) {
return name;
}
/**
* Print current object address,page id,component id,
* component name,pop event function address,push event function address.
*
*/
void NexTouch::print(void) {
dbSerialPrint("[");
dbSerialPrint((uint32_t)this);
dbSerialPrint(":");
dbSerialPrint(pid);
dbSerialPrint(",");
dbSerialPrint(cid);
dbSerialPrint(",");
if (name) {
dbSerialPrint(name);
}
else {
dbSerialPrint("(null)");
}
dbSerialPrint(",");
dbSerialPrint((uint32_t)cbPush);
dbSerialPrint(",");
dbSerialPrint((uint32_t)cbPop);
dbSerialPrintln("]");
}
void NexTouch::attachPush(NexTouchEventCb push, void *ptr) {
this->cbPush = push;
this->__cbpush_ptr = ptr;
}
void NexTouch::detachPush(void) {
this->cbPush = NULL;
this->__cbpush_ptr = NULL;
}
void NexTouch::attachPop(NexTouchEventCb pop, void *ptr) {
this->cbPop = pop;
this->__cbpop_ptr = ptr;
}
void NexTouch::detachPop(void) {
this->cbPop = NULL;
this->__cbpop_ptr = NULL;
}
void NexTouch::iterate(NexTouch **list, NexPid pid, NexCid cid, NexEventType event) {
NexTouch *e = NULL;
uint16_t i = 0;
if (NULL == list) {
return;
}
for(i = 0; (e = list[i]) != NULL; i++) {
if (e->getPid() == pid && e->getCid() == cid) {
e->print();
if (NEX_EVENT_PUSH == event) {
e->push();
}
else if (NEX_EVENT_POP == event) {
e->pop();
}
break;
}
}
}
void NexTouch::push(void) {
if (cbPush) {
cbPush(__cbpush_ptr);
}
}
void NexTouch::pop(void) {
if (cbPop) {
cbPop(__cbpop_ptr);
}
}
/**
* Command is executed successfully.
*
* @param timeout - set timeout time.
*
* @retval true - success.
* @retval false - failed.
*
*/
bool NexTouch::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;
}
/**
* Send command to Nextion.
*
* @param cmd - the string of command.
*/
void NexTouch::sendCommand(const char* cmd)
{
while (nexSerial.available()) {
nexSerial.read();
}
nexSerial.print(cmd);
nexSerial.write(0xFF);
nexSerial.write(0xFF);
nexSerial.write(0xFF);
}
/**
* 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 NexTouch::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;
}
/**
* Receive uint32_t data.
*
* @param number - save uint32_t data.
* @param timeout - set timeout time.
*
* @retval true - success.
* @retval false - failed.
*
*/
bool NexTouch::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;
}
bool NexTouch::getBrightness(uint32_t *brightness)
{
sendCommand("get dim");
return recvRetNumber(brightness);
}
/**
* Init Nextion's baudrate,page id.
*
* @retval true - success.
* @retval false - failed.
*/
bool nexInit(void)
{
nexSerial.begin(NEXTION_BAUDRATE);
NexTouch::sendCommand("");
NexTouch::sendCommand("page 0");
delay(100);
return true;
}
/**
* Call mainEventLoop,watting for Nextion's touch event.
*
* @param nexListenList - index to Nextion Components list.
*
* @retval false - failed.
*/
bool nexLoop(NexTouch **nexListenList)
{
NexTouch::mainEventLoop(nexListenList);
return false;
}
/**
* Return current page id.
*
* @param pageId - output parameter,to save page id.
*
* @retval true - success.
* @retval false - failed.
*/
bool sendCurrentPageId(uint8_t* pageId)
{
bool ret = false;
uint8_t temp[5] = {0};
if (!pageId)
{
goto __return;
}
NexTouch::sendCommand("sendme");
delay(50);
nexSerial.setTimeout(500);
if (sizeof(temp) != nexSerial.readBytes((char *)temp, sizeof(temp)))
{
goto __return;
}
if (temp[0] == NEX_RET_CURRENT_PAGE_ID_HEAD
&& temp[2] == 0xFF
&& temp[3] == 0xFF
&& temp[4] == 0xFF
)
{
*pageId = temp[1];
ret = true;
}
__return:
if (ret)
{
dbSerialPrint("recvPageId :");
dbSerialPrintln(*pageId);
}
else
{
dbSerialPrintln("recvPageId err");
}
return ret;
}
/**
* Touch screen calibration.
*
* @retval true - success.
* @retval false - failed.
*/
bool touchCalibration(void)
{
bool ret = false;
NexTouch::sendCommand("touch_j");
delay(10);
if(NexTouch::recvRetCommandFinished())
{
dbSerialPrintln("TouchCalibration ok ");
ret = true;
}
else
{
dbSerialPrintln("TouchCalibration err ");
}
return ret;
}
/**
* Disable all touch hot.
*
* @retval true - success.
* @retval false - failed.
*/
bool disableTouchFocus(void)
{
bool ret = false;
NexTouch::sendCommand("cle_c");
delay(10);
if(NexTouch::recvRetCommandFinished())
{
dbSerialPrintln("disableTouchFocus ok ");
ret = true;
}
else
{
dbSerialPrintln("disableTouchFocus err ");
}
return ret;
}
/**
* Pause serial instruction execution.
*
* @retval true - success.
* @retval false - failed.
*/
bool pauseSerialCommand(void)
{
bool ret = false;
NexTouch::sendCommand("com_stop");
delay(10);
if(NexTouch::recvRetCommandFinished())
{
dbSerialPrintln("pauseSerialCommand ok ");
ret = true;
}
else
{
dbSerialPrintln("pauseSerialCommand err ");
}
return ret;
}
/**
* Recovery serial instruction execution.
*
* @retval true - success.
* @retval false - failed.
*/
bool recoverySerialCommand(void)
{
bool ret = false;
NexTouch::sendCommand("com_star");
delay(10);
if(NexTouch::recvRetCommandFinished())
{
dbSerialPrintln("recoverySerialCommand ok ");
ret = true;
}
else
{
dbSerialPrintln("recoverySerialCommand err ");
}
return ret;
}
/**
* Set current backlight brightness value.
*
* @param dimValue - current backlight brightness value.
*
* @retval true - success.
* @retval false - failed.
*/
bool setCurrentBrightness(uint8_t dimValue)
{
bool ret = false;
char buf[10] = {0};
String cmd;
utoa(dimValue, buf, 10);
cmd += "dim=";
cmd += buf;
NexTouch::sendCommand(cmd.c_str());
delay(10);
if(NexTouch::recvRetCommandFinished())
{
dbSerialPrint("setCurrentBrightness[ ");
dbSerialPrint(dimValue);
dbSerialPrintln("]ok ");
ret = true;
}
else
{
dbSerialPrintln("setCurrentBrightness err ");
}
return ret;
}
/**
* Set default backlight brightness value.
*
* @param dimDefaultValue - default backlight brightness value.
*
* @retval true - success.
* @retval false - failed.
*/
bool setDefaultBrightness(uint8_t dimDefaultValue)
{
bool ret = false;
char buf[10] = {0};
String cmd;
utoa(dimDefaultValue, buf, 10);
cmd += "dims=";
cmd += buf;
NexTouch::sendCommand(cmd.c_str());
delay(10);
if(NexTouch::recvRetCommandFinished())
{
dbSerialPrint("setDefaultBrightness[");
dbSerialPrint(dimDefaultValue);
dbSerialPrintln("]ok");
ret = true;
}
else
{
dbSerialPrintln("setDefaultBrightness err ");
}
return ret;
}
/**
* Set device in sleep mode.
*
* @param mode - 1:into sleep mode,0:exit sleep mode.
*
* @retval true - success.
* @retval false - failed.
*/
bool sleepMode(uint8_t mode)
{
bool ret = false;
char buf[10] = {0};
String cmd;
if(mode != 0 && mode != 1)
{
dbSerialPrintln("mode input ok ");
return ret;
}
utoa(mode, buf, 10);
cmd += "sleep=";
cmd += buf;
NexTouch::sendCommand(cmd.c_str());
delay(10);
if(NexTouch::recvRetCommandFinished())
{
dbSerialPrintln("sleepMode ok ");
ret = true;
}
else
{
dbSerialPrintln("sleepMode err ");
}
return ret;
}
/**
* Set current baudrate.
*
* @param baudrate - current baudrate,it supports 2400,4800,9600,19200,38400,57600,115200.
*
* @retval true - success.
* @retval false - failed.
*/
bool setCurrentBaudrate(uint32_t baudrate)
{
bool ret = false;
char buf[10] = {0};
String cmd;
utoa(baudrate, buf, 10);
cmd += "baud=";
cmd += buf;
NexTouch::sendCommand(cmd.c_str());
delay(10);
if(NexTouch::recvRetCommandFinished())
{
dbSerialPrintln("setCurrentBaudrate ok ");
ret = true;
}
else
{
dbSerialPrintln("setCurrentBaudrate err ");
}
return ret;
}
/**
* Set default baudrate.
*
* @param defaultBaudrate - default baudrate,it supports 2400,4800,9600,19200,38400,57600,115200.
*
* @retval true - success.
* @retval false - failed.
*/
bool setDefaultBaudrate(uint32_t defaultBaudrate)
{
bool ret = false;
char buf[10] = {0};
String cmd;
utoa(defaultBaudrate, buf, 10);
cmd += "bauds=";
cmd += buf;
NexTouch::sendCommand(cmd.c_str());
delay(10);
if(NexTouch::recvRetCommandFinished())
{
dbSerialPrintln("setDefaultBaudrate ok ");
ret = true;
}
else
{
dbSerialPrintln("setDefaultBaudrate err ");
}
return ret;
}
/**
* @file NexTouch.h
*
* API of Nextion.
*
* @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
* 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__
#ifdef __cplusplus
#include <Arduino.h>
#include "NexSerialConfig.h"
typedef uint8_t NexPid;
typedef uint8_t NexCid;
typedef enum {
NEX_EVENT_POP = 0x00,
NEX_EVENT_PUSH = 0x01,
NEX_EVENT_NULL
} NexEventType;
/*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)
typedef void (*NexTouchEventCb)(void *ptr);
/**
* Root Class of Nextion Components.
*
*/
class NexTouch
{
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: /* 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);
protected: /* methods */
void attachPush(NexTouchEventCb push, void *ptr = NULL);
void detachPush(void);
void attachPop(NexTouchEventCb pop, void *ptr = NULL);
void detachPop(void);
private: /* static methods */
static void iterate(NexTouch **list, NexPid pid, NexCid cid, NexEventType event);
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;
void *__cbpush_ptr;
NexTouchEventCb cbPop;
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__ */
......@@ -18,6 +18,7 @@
#define BOARD_RAMPS_13_EEB 34 // RAMPS 1.3 / 1.4 (Power outputs: Hotend0, Hotend1, Bed)
#define BOARD_RAMPS_13_EFF 35 // RAMPS 1.3 / 1.4 (Power outputs: Hotend, Fan, Fan)
#define BOARD_RAMPS_13_EEF 36 // RAMPS 1.3 / 1.4 (Power outputs: Hotend0, Hotend1, Fan)
#define BOARD_RAMPS_13_EEE 37 // RAMPS 1.3 / 1.4 (Power outputs: Hotend0, Hotend1, Hotend2)
#define BOARD_RAMBO 301 // Rambo
#define BOARD_MINIRAMBO 302 // Mini-Rambo
......
......@@ -9,9 +9,21 @@
lcd_buzz(duration, freq);
#elif defined(BEEPER) && BEEPER >= 0 // on-board buzzers have no further condition
SET_OUTPUT(BEEPER);
tone(BEEPER, freq);
#ifdef SPEAKER // a speaker needs a AC ore a pulsed DC
//tone(BEEPER, freq, duration); // needs a PWMable pin
unsigned int delay = 1000000 / freq / 2;
int i = duration * freq / 1000;
while (i--) {
WRITE(BEEPER,HIGH);
delayMicroseconds(delay);
WRITE(BEEPER,LOW);
delayMicroseconds(delay);
}
#else // buzzer has its own resonator - needs a DC
WRITE(BEEPER, HIGH);
delay(duration);
noTone(BEEPER);
WRITE(BEEPER, LOW);
#endif
#else
delay(duration);
#endif
......
......@@ -3,6 +3,8 @@
#if HAS_BUZZER
void buzz(long duration, uint16_t freq);
#else
FORCE_INLINE void buzz(long duration, uint16_t freq) {}
#endif
#endif //BUZZER_H
......@@ -68,8 +68,8 @@ FORCE_INLINE void PS_PGM(const char *str) {
#define ECHO_MV(msg, val, args...) ECHO_PGM(msg),ECHO_V(val, ##args)
#define ECHO_VM(val, msg, args...) ECHO_V(val, ##args),ECHO_PGM(msg)
#define ECHO_M(msg) ECHO_PGM(msg)
#define ECHO_V(msg, args...) SERIAL_PRINT(msg, ##args)
#define ECHO_C(x) SERIAL_WRITE(x)
#define ECHO_V SERIAL_PRINT
#define ECHO_C SERIAL_WRITE
#define ECHO_S(srt) ECHO_PGM(srt)
#define ECHO_SM(srt, msg) ECHO_S(srt),ECHO_M(msg)
......
......@@ -52,7 +52,16 @@
#define REPRAP_DISCOUNT_SMART_CONTROLLER
#endif
#if defined(ULTIMAKERCONTROLLER) || defined(REPRAP_DISCOUNT_SMART_CONTROLLER) || defined(G3D_PANEL)
#ifdef SPARK_FULL_GRAPHICS
#define ENCODER_PULSES_PER_STEP 2
#define ENCODER_STEPS_PER_MENU_ITEM 1
#define DOGLCD
#define U8GLIB_ST7920
#define REPRAP_DISCOUNT_SMART_CONTROLLER
#endif
#if defined(ULTIMAKERCONTROLLER) || defined(REPRAP_DISCOUNT_SMART_CONTROLLER) || defined(G3D_PANEL) || defined(RIGIDBOT_PANEL)
#define ULTIPANEL
#define NEWPANEL
#endif
......@@ -60,6 +69,7 @@
#ifdef RADDS_DISPLAY
#define ENCODER_PULSES_PER_STEP 2
#define ENCODER_STEPS_PER_MENU_ITEM 1
#define ULTIPANEL
#define NEWPANEL
#endif
......@@ -76,6 +86,14 @@
#define NEWPANEL
#endif
#ifdef MINIPANEL
#define DOGLCD
#define SDSUPPORT
#define ULTIPANEL
#define NEWPANEL
#define DEFAULT_LCD_CONTRAST 17
#endif
/**
* I2C PANELS
*/
......@@ -91,11 +109,6 @@
// PANELOLU2 LCD with status LEDs, separate encoder and click inputs
#ifdef LCD_I2C_PANELOLU2
// This uses the LiquidTWI2 library v1.2.3 or later ( https://github.com/lincomatic/LiquidTWI2 )
// Make sure the LiquidTWI2 directory is placed in the Arduino or Sketchbook libraries subdirectory.
// (v1.2.3 no longer requires you to define PANELOLU in the LiquidTWI2.h library header file)
// Note: The PANELOLU2 encoder click input can either be directly connected to a pin
// (if BTN_ENC defined to != -1) or read through I2C (when BTN_ENC == -1).
#define LCD_I2C_TYPE_MCP23017
#define LCD_I2C_ADDRESS 0x20 // I2C Address of the port expander
#define LCD_USE_I2C_BUZZER //comment out to disable buzzer on LCD
......@@ -325,7 +338,6 @@
// Effective horizontal distance bridged by diagonal push rods.
#define DEFAULT_DELTA_RADIUS (DELTA_SMOOTH_ROD_OFFSET-DELTA_EFFECTOR_OFFSET-DELTA_CARRIAGE_OFFSET)
#define DELTA_PROBABLE_RADIUS (PRINTER_RADIUS - 10)
#define LEFT_PROBE_BED_POSITION -DELTA_PROBABLE_RADIUS
#define RIGHT_PROBE_BED_POSITION DELTA_PROBABLE_RADIUS
#define FRONT_PROBE_BED_POSITION -DELTA_PROBABLE_RADIUS
......@@ -334,7 +346,6 @@
/**
* AUTOSET LOCATIONS OF LIMIT SWITCHES
* Added by ZetaPhoenix 09-15-2012
*/
#ifdef MANUAL_HOME_POSITIONS // Use manual limit switch locations
#define X_HOME_POS MANUAL_X_HOME_POS
......@@ -360,8 +371,19 @@
#define MAX_PROBE_X (min(X_MAX_POS, X_MAX_POS + X_PROBE_OFFSET_FROM_EXTRUDER))
#define MIN_PROBE_Y (max(Y_MIN_POS, Y_MIN_POS + Y_PROBE_OFFSET_FROM_EXTRUDER))
#define MAX_PROBE_Y (min(Y_MAX_POS, Y_MAX_POS + Y_PROBE_OFFSET_FROM_EXTRUDER))
// Z_RAISE_AFTER_PROBING is not for all probes. Be sure that it is zero in that cases
#if (NUM_SERVOS == 0) && !defined(Z_PROBE_SLED)
#undef Z_RAISE_AFTER_PROBING
#define Z_RAISE_AFTER_PROBING 0
#endif
#endif
/**
* Servo Leveling
*/
#define SERVO_LEVELING (defined(SERVO_ENDSTOPS) && defined(DEACTIVATE_SERVOS_AFTER_MOVE))
/**
* Sled Options
*/
......@@ -369,12 +391,6 @@
#define Z_SAFE_HOMING
#endif
/**
* Servo Leveling
*/
#define SERVO_LEVELING (NUM_SERVOS > 0 && defined(ENABLE_AUTO_BED_LEVELING))
#define SERVO_LEVELING_DELAY (SERVO_LEVELING && PROBE_SERVO_DEACTIVATION_DELAY > 0)
/**
* MAX_STEP_FREQUENCY differs for TOSHIBA OR ARDUINO DUE OR ARDUINO MEGA
*/
......@@ -492,16 +508,30 @@
/**
* ARRAY_BY_EXTRUDERS based on EXTRUDERS
*/
#if EXTRUDERS > 3
#define ARRAY_BY_EXTRUDERS(v1, v2, v3, v4) { v1, v2, v3, v4 }
#if EXTRUDERS > 9
#define ARRAY_BY_EXTRUDER(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10) { v1, v2, v3, v4, v5, v6, v7, v8, v9, v10 }
#elif EXTRUDERS > 8
#define ARRAY_BY_EXTRUDER(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10) { v1, v2, v3, v4, v5, v6, v7, v8, v9 }
#elif EXTRUDERS > 7
#define ARRAY_BY_EXTRUDER(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10) { v1, v2, v3, v4, v5, v6, v7, v8 }
#elif EXTRUDERS > 6
#define ARRAY_BY_EXTRUDER(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10) { v1, v2, v3, v4, v5, v6, v7 }
#elif EXTRUDERS > 5
#define ARRAY_BY_EXTRUDER(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10) { v1, v2, v3, v4, v5, v6 }
#elif EXTRUDERS > 4
#define ARRAY_BY_EXTRUDER(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10) { v1, v2, v3, v4, v5 }
#elif EXTRUDERS > 3
#define ARRAY_BY_EXTRUDER(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10) { v1, v2, v3, v4 }
#elif EXTRUDERS > 2
#define ARRAY_BY_EXTRUDERS(v1, v2, v3, v4) { v1, v2, v3 }
#define ARRAY_BY_EXTRUDER(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10) { v1, v2, v3 }
#elif EXTRUDERS > 1
#define ARRAY_BY_EXTRUDERS(v1, v2, v3, v4) { v1, v2 }
#define ARRAY_BY_EXTRUDER(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10) { v1, v2 }
#else
#define ARRAY_BY_EXTRUDERS(v1, v2, v3, v4) { v1 }
#define ARRAY_BY_EXTRUDER(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10) { v1 }
#endif
#define ARRAY_BY_EXTRUDERS(v1) ARRAY_BY_EXTRUDER(v1, v1, v1, v1, v1, v1, v1, v1, v1, v1)
/**
* ARRAY_BY_HOTENDS based on HOTENDS
*/
......@@ -515,6 +545,8 @@
#define ARRAY_BY_HOTENDS(v1, v2, v3, v4) { v1 }
#endif
#define ARRAY_BY_HOTENDS1(v1) ARRAY_BY_HOTENDS(v1, v1, v1, v1)
/**
* Shorthand for pin tests, used wherever needed
*/
......@@ -563,6 +595,7 @@
#define HAS_MICROSTEPS_E0 (PIN_EXISTS(E0_MS1))
#define HAS_MICROSTEPS_E1 (PIN_EXISTS(E1_MS1))
#define HAS_MICROSTEPS_E2 (PIN_EXISTS(E2_MS1))
#define HAS_STEPPER_RESET (PIN_EXISTS(STEPPER_RESET))
#define HAS_X_ENABLE (PIN_EXISTS(X_ENABLE))
#define HAS_X2_ENABLE (PIN_EXISTS(X2_ENABLE))
#define HAS_Y_ENABLE (PIN_EXISTS(Y_ENABLE))
......@@ -630,11 +663,19 @@
#define WRITE_HEATER_0(v) WRITE_HEATER_0P(v)
#endif
#if HAS_HEATER_BED
#define WRITE_HEATER_BED(v) WRITE_HEATER(HEATER_BED_PIN, v)
#ifdef INVERTED_BED_PINS
#define WRITE_HEATER_BED(v) WRITE(HEATER_BED_PIN,!v)
#else
#define WRITE_HEATER_BED(v) WRITE(HEATER_BED_PIN,v)
#endif
#endif
#if HAS_FAN
#ifdef INVERTED_HEATER_PINS
#define WRITE_FAN(v) WRITE(FAN_PIN, !v)
#else
#define WRITE_FAN(v) WRITE(FAN_PIN, v)
#endif
#endif
/**
* LCD BUZZ
......
......@@ -14,10 +14,10 @@
*
*/
#define EEPROM_VERSION "V23"
#define EEPROM_VERSION "V24"
/**
* V23 EEPROM Layout:
* V24 EEPROM Layout:
*
* ver
* M92 XYZ E0 ... axis_steps_per_unit X,Y,Z,E0 ... (per extruder)
......@@ -40,10 +40,11 @@
*
* DELTA:
* M666 XYZ endstop_adj (x3)
* M666 ABCDEFG tower_adj (x6)
* M666 R delta_radius
* M666 D delta_diagonal_rod
* M666 H Z max_pos
* M666 ABCIJK tower_adj (x6)
* M666 UVW diagrod_adj (x3)
* M666 P XYZ XYZ probe_offset (x3)
*
* Z_DUAL_ENDSTOPS
......@@ -171,6 +172,7 @@ void Config_StoreSettings() {
EEPROM_WRITE_VAR(i, delta_diagonal_rod);
EEPROM_WRITE_VAR(i, max_pos);
EEPROM_WRITE_VAR(i, tower_adj);
EEPROM_WRITE_VAR(i, diagrod_adj);
EEPROM_WRITE_VAR(i, z_probe_offset);
#elif defined(Z_DUAL_ENDSTOPS)
EEPROM_WRITE_VAR(i, z_endstop_adj); // 1 floats
......@@ -253,7 +255,7 @@ void Config_StoreSettings() {
EEPROM_WRITE_VAR(j, ver2); // validate data
// Report storage size
ECHO_SMV(DB, "Settings Stored (", i);
ECHO_SMV(DB, "Settings Stored (", (unsigned long)i);
ECHO_EM(" bytes)");
}
......@@ -307,6 +309,7 @@ void Config_RetrieveSettings() {
EEPROM_READ_VAR(i, delta_diagonal_rod);
EEPROM_READ_VAR(i, max_pos);
EEPROM_READ_VAR(i, tower_adj);
EEPROM_READ_VAR(i, diagrod_adj);
EEPROM_READ_VAR(i, z_probe_offset);
// Update delta constants for updated delta_radius & tower_adj values
set_delta_constants();
......@@ -389,7 +392,7 @@ void Config_RetrieveSettings() {
// Report settings retrieved and length
ECHO_SV(DB, ver);
ECHO_MV(" stored settings retrieved (", i);
ECHO_MV(" stored settings retrieved (", (unsigned long)i);
ECHO_EM(" bytes)");
}
......@@ -468,7 +471,7 @@ void Config_ResetDefault() {
#ifdef SCARA
for (int8_t i = 0; i < NUM_AXIS; i++) {
if (i < sizeof(axis_scaling) / sizeof(*axis_scaling))
if (i < COUNT(axis_scaling))
axis_scaling[i] = 1;
}
#endif
......@@ -492,10 +495,20 @@ void Config_ResetDefault() {
#endif
#ifdef DELTA
endstop_adj[X_AXIS] = endstop_adj[Y_AXIS] = endstop_adj[Z_AXIS] = 0;
delta_radius = DEFAULT_DELTA_RADIUS;
delta_diagonal_rod = DEFAULT_DELTA_DIAGONAL_ROD;
tower_adj[0] = tower_adj[1] = tower_adj[2] = tower_adj[3] = tower_adj[4] = tower_adj[5] = 0;
endstop_adj[0] = TOWER_A_ENDSTOP_ADJ;
endstop_adj[1] = TOWER_B_ENDSTOP_ADJ;
endstop_adj[2] = TOWER_C_ENDSTOP_ADJ;
tower_adj[0] = TOWER_A_POSITION_ADJ;
tower_adj[1] = TOWER_B_POSITION_ADJ;
tower_adj[2] = TOWER_C_POSITION_ADJ;
tower_adj[3] = TOWER_A_RADIUS_ADJ;
tower_adj[4] = TOWER_B_RADIUS_ADJ;
tower_adj[5] = TOWER_C_RADIUS_ADJ;
diagrod_adj[0] = TOWER_A_DIAGROD_ADJ;
diagrod_adj[1] = TOWER_B_DIAGROD_ADJ;
diagrod_adj[2] = TOWER_C_DIAGROD_ADJ;
max_pos[2] = MANUAL_Z_HOME_POS;
set_default_z_probe_offset();
set_delta_constants();
......@@ -679,6 +692,9 @@ void Config_ResetDefault() {
ECHO_MV(" I", tower_adj[3], 3);
ECHO_MV(" J", tower_adj[4], 3);
ECHO_MV(" K", tower_adj[5], 3);
ECHO_MV(" U", diagrod_adj[0], 3);
ECHO_MV(" V", diagrod_adj[1], 3);
ECHO_MV(" W", diagrod_adj[2], 3);
ECHO_MV(" R", delta_radius);
ECHO_MV(" D", delta_diagonal_rod);
ECHO_EMV(" H", max_pos[2]);
......
......@@ -50,7 +50,7 @@ void digipot_i2c_init() {
const float digipot_motor_current[] = DIGIPOT_I2C_MOTOR_CURRENTS;
Wire.begin();
// setup initial currents as defined in Configuration_adv.h
for(int i = 0; i <= sizeof(digipot_motor_current) / sizeof(float); i++) {
for(int i = 0; i < COUNT(digipot_motor_current); i++) {
digipot_i2c_set_current(i, digipot_motor_current[i]);
}
}
......
......@@ -115,7 +115,8 @@
// LCD selection
#ifdef U8GLIB_ST7920
//U8GLIB_ST7920_128X64_RRD u8g(0,0,0);
U8GLIB_ST7920_128X64_RRD u8g(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);
#elif defined(MAKRPANEL)
......@@ -130,6 +131,9 @@
#elif defined U8GLIB_SSD1306
// Generic support for SSD1306 OLED I2C LCDs
U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NONE);
#elif defined(MINIPANEL)
// The MINIPanel display
U8GLIB_MINI12864 u8g(DOGLCD_CS, DOGLCD_A0);
#else
// for regular DOGM128 display with HW-SPI
U8GLIB_DOGM128 u8g(DOGLCD_CS, DOGLCD_A0); // HW-SPI Com: CS, A0
......@@ -199,7 +203,13 @@ static void lcd_implementation_init() {
digitalWrite(LCD_PIN_BL, HIGH);
#endif
#ifdef LCD_PIN_RESET
pinMode(LCD_PIN_RESET, OUTPUT);
digitalWrite(LCD_PIN_RESET, HIGH);
#endif
#ifndef MINIPANEL//setContrast not working for Mini Panel
u8g.setContrast(lcd_contrast);
#endif
// FIXME: remove this workaround
// Uncomment this if you have the first generation (V1.10) of STBs board
// pinMode(17, OUTPUT); // Enable LCD backlight
......@@ -229,7 +239,7 @@ static void lcd_implementation_init() {
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);
u8g.drawStr(0, u8g.getHeight(), 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);
......
......@@ -33,21 +33,22 @@
#if MB(ULTIMAKER)|| MB(ULTIMAKER_OLD)|| MB(ULTIMAIN_2)
#define MACHINE_NAME "Ultimaker"
#define FIRMWARE_URL "https://github.com/Ultimaker/Marlin"
#define SOURCE_CODE_URL "https://github.com/Ultimaker/Marlin"
#elif MB(RUMBA)
#define MACHINE_NAME "Rumba"
#elif MB(3DRAG)
#define MACHINE_NAME "3Drag"
#define FIRMWARE_URL "http://3dprint.elettronicain.it/"
#define SOURCE_CODE_URL "http://3dprint.elettronicain.it/"
#elif MB(K8200)
#define MACHINE_NAME "K8200"
#define SOURCE_CODE_URL "https://github.com/CONSULitAS/Marlin-K8200"
#elif MB(5DPRINT)
#define MACHINE_NAME "Makibox"
#elif MB(SAV_MKI)
#define MACHINE_NAME "SAV MkI"
#define FIRMWARE_URL "https://github.com/fmalpartida/Marlin/tree/SAV-MkI-config"
#else // Default firmware set to Mendel
#define MACHINE_NAME "Mendel"
#define SOURCE_CODE_URL "https://github.com/fmalpartida/Marlin/tree/SAV-MkI-config"
#elif !defined(MACHINE_NAME)
#define MACHINE_NAME "3D Printer"
#endif
#ifdef CUSTOM_MENDEL_NAME
......@@ -60,8 +61,8 @@
#define MACHINE_NAME CUSTOM_MACHINE_NAME
#endif
#ifndef FIRMWARE_URL
#define FIRMWARE_URL "https://github.com/MagoKimbra/MarlinKimbra"
#ifndef SOURCE_CODE_URL
#define SOURCE_CODE_URL "https://github.com/MagoKimbra/MarlinKimbra"
#endif
#ifndef BUILD_VERSION
......@@ -108,11 +109,7 @@
#define MSG_INVALID_EXTRUDER "Invalid extruder"
#define MSG_INVALID_SOLENOID "Invalid solenoid"
#define MSG_ERR_NO_THERMISTORS "No thermistors - no temperature"
#define MSG_HEATING "Heating..."
#define MSG_HEATING_COMPLETE "Heating done."
#define MSG_BED_HEATING "Bed Heating."
#define MSG_BED_DONE "Bed done."
#define MSG_M115_REPORT "FIRMWARE_NAME: MarlinKimbra " BUILD_VERSION " FIRMWARE_URL:" FIRMWARE_URL " PROTOCOL_VERSION:" PROTOCOL_VERSION " MACHINE_TYPE:" MACHINE_NAME " EXTRUDER_COUNT:" STRINGIFY(EXTRUDERS) " UUID:" MACHINE_UUID "\n"
#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_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)"
......@@ -193,8 +190,8 @@
#define MSG_KP " Kp: "
#define MSG_KI " Ki: "
#define MSG_KD " Kd: "
#define MSG_T "T:"
#define MSG_B "B:"
#define MSG_T "T:"
#define MSG_AT "@:"
#define MSG_BAT "B@:"
#define MSG_W "W:"
......
......@@ -42,12 +42,14 @@
#define MSG_PREHEAT_GUM_ALL "Preheat GUM All"
#define MSG_PREHEAT_GUM_BEDONLY "Preheat GUM Bed"
#define MSG_PREHEAT_GUM_SETTINGS "Preheat GUM conf"
#define MSG_TOO_COLD_FOR_M600 "M600 Hotend too cold to change filament"
#define MSG_COOLDOWN "Enfriar"
#define MSG_SWITCH_PS_ON "Enchegar Fuent"
#define MSG_SWITCH_PS_OFF "Desenchegar Fuent"
#define MSG_EXTRUDE "Extruir"
#define MSG_RETRACT "Retraer"
#define MSG_MOVE_AXIS "Mover Eixes"
#define MSG_LEVEL_BED "Level bed"
#define MSG_MOVE_X "Move X"
#define MSG_MOVE_Y "Move Y"
#define MSG_MOVE_Z "Move Z"
......@@ -71,6 +73,9 @@
#define MSG_PID_P "PID-P"
#define MSG_PID_I "PID-I"
#define MSG_PID_D "PID-D"
#define MSG_H1 " H1"
#define MSG_H2 " H2"
#define MSG_H3 " H3"
#define MSG_ACC "Acel"
#define MSG_VXY_JERK "Vxy-jerk"
#define MSG_VZ_JERK "Vz-jerk"
......@@ -135,14 +140,24 @@
#define MSG_BABYSTEP_Y "Babystep Y"
#define MSG_BABYSTEP_Z "Babystep Z"
#define MSG_ENDSTOP_ABORT "Endstop abort"
#define MSG_HEATING_FAILED_LCD "Heating failed"
#define MSG_ERR_REDUNDANT_TEMP "Err: REDUNDANT TEMP ERROR"
#define MSG_THERMAL_RUNAWAY "THERMAL RUNAWAY"
#define MSG_ERR_MAXTEMP "Err: MAXTEMP"
#define MSG_ERR_MINTEMP "Err: MINTEMP"
#define MSG_ERR_MAXTEMP_BED "Err: MAXTEMP BED"
#define MSG_ERR_MINTEMP_BED "Err: MINTEMP BED"
#define MSG_END_DAY "days"
#define MSG_END_HOUR "hours"
#define MSG_END_MINUTE "minutes"
// Debug
#define MSG_DEBUG_ECHO "DEBUG ECHO ENABLED"
#define MSG_DEBUG_INFO "DEBUG INFO ENABLED"
#define MSG_DEBUG_ERRORS "DEBUG ERRORS ENABLED"
#define MSG_DEBUG_DRYRUN "DEBUG DRYRUN ENABLED"
// Calibrate Delta
#ifdef DELTA
#define MSG_DELTA_CALIBRATE "Delta Calibration"
#define MSG_DELTA_CALIBRATE_X "Calibrate X"
......@@ -151,18 +166,29 @@
#define MSG_DELTA_CALIBRATE_CENTER "Calibrate Center"
#endif // DELTA
// Scara
#ifdef SCARA
#define MSG_XSCALE "X Scale"
#define MSG_YSCALE "Y Scale"
#endif
#define MSG_HEATING "Heating..."
#define MSG_HEATING_COMPLETE "Heating done."
#define MSG_BED_HEATING "Bed Heating."
#define MSG_BED_DONE "Bed done."
// Extra
#define MSG_LASER "Laser Preset"
#define MSG_CONFIG "Configuration"
#define MSG_E_BOWDEN_LENGTH "Extrude " STRINGIFY(BOWDEN_LENGTH) "mm"
#define MSG_R_BOWDEN_LENGTH "Retract " STRINGIFY(BOWDEN_LENGTH) "mm"
#define MSG_PURGE_XMM "Purge " STRINGIFY(LCD_PURGE_LENGTH) "mm"
#define MSG_RETRACT_XMM "Retract " STRINGIFY(LCD_RETRACT_LENGTH) "mm"
#define MSG_SAVED_POS "Saved position"
#define MSG_RESTORING_POS "Restoring position"
#define MSG_INVALID_POS_SLOT "Invalid slot, total slots: "
// Firmware Test
#ifdef FIRMWARE_TEST
#define MSG_FWTEST_YES "Put the Y command to go next"
#define MSG_FWTEST_NO "Put the N command to go next"
......
......@@ -43,6 +43,7 @@
#define MSG_PREHEAT_GUM_ALL "Preheat GUM All"
#define MSG_PREHEAT_GUM_BEDONLY "Preheat GUM Bed"
#define MSG_PREHEAT_GUM_SETTINGS "Preheat GUM conf"
#define MSG_TOO_COLD_FOR_M600 "M600 Hotend too cold to change filament"
#define MSG_COOLDOWN "Refredar"
#define MSG_SWITCH_PS_ON "Switch power on"
#define MSG_SWITCH_PS_OFF "Switch power off"
......@@ -72,6 +73,9 @@
#define MSG_PID_P "PID-P"
#define MSG_PID_I "PID-I"
#define MSG_PID_D "PID-D"
#define MSG_H1 " H1"
#define MSG_H2 " H2"
#define MSG_H3 " H3"
#define MSG_ACC "Accel"
#define MSG_VXY_JERK "Vxy-jerk"
#define MSG_VZ_JERK "Vz-jerk"
......@@ -136,14 +140,24 @@
#define MSG_BABYSTEP_Y "Babystep Y"
#define MSG_BABYSTEP_Z "Babystep Z"
#define MSG_ENDSTOP_ABORT "Endstop abort"
#define MSG_HEATING_FAILED_LCD "Heating failed"
#define MSG_ERR_REDUNDANT_TEMP "Err: REDUNDANT TEMP ERROR"
#define MSG_THERMAL_RUNAWAY "THERMAL RUNAWAY"
#define MSG_ERR_MAXTEMP "Err: MAXTEMP"
#define MSG_ERR_MINTEMP "Err: MINTEMP"
#define MSG_ERR_MAXTEMP_BED "Err: MAXTEMP BED"
#define MSG_ERR_MINTEMP_BED "Err: MINTEMP BED"
#define MSG_END_DAY "days"
#define MSG_END_HOUR "hours"
#define MSG_END_MINUTE "minutes"
// Debug
#define MSG_DEBUG_ECHO "DEBUG ECHO ENABLED"
#define MSG_DEBUG_INFO "DEBUG INFO ENABLED"
#define MSG_DEBUG_ERRORS "DEBUG ERRORS ENABLED"
#define MSG_DEBUG_DRYRUN "DEBUG DRYRUN ENABLED"
// Calibrate Delta
#ifdef DELTA
#define MSG_DELTA_CALIBRATE "Delta Calibration"
#define MSG_DELTA_CALIBRATE_X "Calibrate X"
......@@ -152,19 +166,29 @@
#define MSG_DELTA_CALIBRATE_CENTER "Calibrate Center"
#endif // DELTA
// Scara
#ifdef SCARA
#define MSG_XSCALE "X Scale"
#define MSG_YSCALE "Y Scale"
#endif
#define MSG_HEATING "Heating..."
#define MSG_HEATING_COMPLETE "Heating done."
#define MSG_BED_HEATING "Bed Heating."
#define MSG_BED_DONE "Bed done."
// Extra
#define MSG_LASER "Laser Preset"
#define MSG_CONFIG "Configuration"
#define MSG_BAUDRATE "Baudrate"
#define MSG_E_BOWDEN_LENGTH "Extrude " STRINGIFY(BOWDEN_LENGTH) "mm"
#define MSG_R_BOWDEN_LENGTH "Retract " STRINGIFY(BOWDEN_LENGTH) "mm"
#define MSG_PURGE_XMM "Purge " STRINGIFY(LCD_PURGE_LENGTH) "mm"
#define MSG_RETRACT_XMM "Retract " STRINGIFY(LCD_RETRACT_LENGTH) "mm"
#define MSG_SAVED_POS "Saved position"
#define MSG_RESTORING_POS "Restoring position"
#define MSG_INVALID_POS_SLOT "Invalid slot, total slots: "
// Firmware Test
#ifdef FIRMWARE_TEST
#define MSG_FWTEST_YES "Put the Y command to go next"
#define MSG_FWTEST_NO "Put the N command to go next"
......
......@@ -38,16 +38,19 @@
#define MSG_PREHEAT_ABS_ALL "Vorw. ABS Alle"
#define MSG_PREHEAT_ABS_BEDONLY "Vorw. ABS Bett"
#define MSG_PREHEAT_ABS_SETTINGS "Vorwärm. ABS Ein."
#define MSG_PREHEAT_ABS_SETTINGS "Preheat ABS conf"
#define MSG_PREHEAT_GUM "Preheat GUM"
#define MSG_PREHEAT_GUM_ALL "Preheat GUM All"
#define MSG_PREHEAT_GUM_BEDONLY "Preheat GUM Bed"
#define MSG_PREHEAT_GUM_SETTINGS "Preheat GUM conf"
#define MSG_TOO_COLD_FOR_M600 "M600 Hotend too cold to change filament"
#define MSG_COOLDOWN "Abkühlen"
#define MSG_SWITCH_PS_ON "Netzteil Ein"
#define MSG_SWITCH_PS_OFF "Netzteil Aus"
#define MSG_EXTRUDE "Extrude"
#define MSG_RETRACT "Retract"
#define MSG_MOVE_AXIS "Bewegen"
#define MSG_LEVEL_BED "Level bed"
#define MSG_MOVE_X "X"
#define MSG_MOVE_Y "Y"
#define MSG_MOVE_Z "Z"
......@@ -64,25 +67,29 @@
#define MSG_MIN LCD_STR_THERMOMETER " Min"
#define MSG_MAX LCD_STR_THERMOMETER " Max"
#define MSG_FACTOR LCD_STR_THERMOMETER " Faktor"
#define MSG_IDLEOOZING "Anti oozing"
#define MSG_AUTOTEMP "AutoTemp"
#define MSG_ON "Ein"
#define MSG_OFF "Aus"
#define MSG_PID_P "PID P"
#define MSG_PID_I "PID I"
#define MSG_PID_D "PID D"
#define MSG_ACC "A"
#define MSG_VXY_JERK "V xy jerk"
#define MSG_VZ_JERK "V z jerk"
#define MSG_VE_JERK "V e jerk"
#define MSG_VMAX "V max " // space by purpose
#define MSG_X "x"
#define MSG_Y "y"
#define MSG_Z "z"
#define MSG_E "e"
#define MSG_VMIN "V min"
#define MSG_H1 " H1"
#define MSG_H2 " H2"
#define MSG_H3 " H3"
#define MSG_ACC "Accel"
#define MSG_VXY_JERK "Vxy-jerk"
#define MSG_VZ_JERK "Vz-jerk"
#define MSG_VE_JERK "Ve-jerk "
#define MSG_VMAX "Vmax "
#define MSG_X "X"
#define MSG_Y "Y"
#define MSG_Z "Z"
#define MSG_E "E"
#define MSG_VMIN "Vmin"
#define MSG_VTRAV_MIN "VTrav min"
#define MSG_AMAX "A max " // space by purpose
#define MSG_A_RETRACT "A Retract"
#define MSG_AMAX "Amax "
#define MSG_A_RETRACT "A-retract"
#define MSG_A_TRAVEL "A-travel"
#define MSG_XSTEPS "X steps/mm"
#define MSG_YSTEPS "Y steps/mm"
......@@ -94,7 +101,7 @@
#define MSG_TEMPERATURE "Temperatur"
#define MSG_MOTION "Bewegung"
#define MSG_VOLUMETRIC "Filament"
#define MSG_VOLUMETRIC_ENABLED "E in mm" STR_h3
#define MSG_VOLUMETRIC_ENABLED "E in mm3"
#define MSG_FILAMENT_SIZE_EXTRUDER "Fil. Dia."
#define MSG_CONTRAST "LCD contrast"
#define MSG_STORE_EPROM "EPROM speichern"
......@@ -134,14 +141,24 @@
#define MSG_BABYSTEP_Y "Babystep Y"
#define MSG_BABYSTEP_Z "Babystep Z"
#define MSG_ENDSTOP_ABORT "Endstop Abbr. Ein"
#define MSG_HEATING_FAILED_LCD "Heating failed"
#define MSG_ERR_REDUNDANT_TEMP "Err: REDUNDANT TEMP ERROR"
#define MSG_THERMAL_RUNAWAY "THERMAL RUNAWAY"
#define MSG_ERR_MAXTEMP "Err: MAXTEMP"
#define MSG_ERR_MINTEMP "Err: MINTEMP"
#define MSG_ERR_MAXTEMP_BED "Err: MAXTEMP BED"
#define MSG_ERR_MINTEMP_BED "Err: MINTEMP BED"
#define MSG_END_DAY "days"
#define MSG_END_HOUR "hours"
#define MSG_END_MINUTE "minutes"
// Debug
#define MSG_DEBUG_ECHO "DEBUG ECHO ENABLED"
#define MSG_DEBUG_INFO "DEBUG INFO ENABLED"
#define MSG_DEBUG_ERRORS "DEBUG ERRORS ENABLED"
#define MSG_DEBUG_DRYRUN "DEBUG DRYRUN ENABLED"
// Calibrate Delta
#ifdef DELTA
#define MSG_DELTA_CALIBRATE "Delta Calibration"
#define MSG_DELTA_CALIBRATE_X "Calibrate X"
......@@ -150,19 +167,29 @@
#define MSG_DELTA_CALIBRATE_CENTER "Calibrate Center"
#endif // DELTA
// Scara
#ifdef SCARA
#define MSG_XSCALE "X Scale"
#define MSG_YSCALE "Y Scale"
#endif
#define MSG_HEATING "Heating..."
#define MSG_HEATING_COMPLETE "Heating done."
#define MSG_BED_HEATING "Bed Heating."
#define MSG_BED_DONE "Bed done."
// Extra
#define MSG_LASER "Laser Preset"
#define MSG_CONFIG "Configuration"
#define MSG_BAUDRATE "Baudrate"
#define MSG_E_BOWDEN_LENGTH "Extrude " STRINGIFY(BOWDEN_LENGTH) "mm"
#define MSG_R_BOWDEN_LENGTH "Retract " STRINGIFY(BOWDEN_LENGTH) "mm"
#define MSG_PURGE_XMM "Purge " STRINGIFY(LCD_PURGE_LENGTH) "mm"
#define MSG_RETRACT_XMM "Retract " STRINGIFY(LCD_RETRACT_LENGTH) "mm"
#define MSG_SAVED_POS "Saved position"
#define MSG_RESTORING_POS "Restoring position"
#define MSG_INVALID_POS_SLOT "Invalid slot, total slots: "
// Firmware Test
#ifdef FIRMWARE_TEST
#define MSG_FWTEST_YES "Put the Y command to go next"
#define MSG_FWTEST_NO "Put the N command to go next"
......
......@@ -2,7 +2,7 @@
* English
*
* LCD Menu Messages
* Se also documentation/LCDLanguageFont.md
* See also documentation/LCDLanguageFont.md
*
*/
#ifndef LANGUAGE_EN_H
......@@ -13,7 +13,7 @@
#endif
//#define SIMULATE_ROMFONT //Comment in to see what is seen on the character based displays
#if !( defined(SIMULATE_ROMFONT)|| defined(DISPLAY_CHARSET_ISO10646_1)|| defined(DISPLAY_CHARSET_ISO10646_5)|| defined(DISPLAY_CHARSET_ISO10646_KANA) )
#if !( defined(SIMULATE_ROMFONT)|| defined(DISPLAY_CHARSET_ISO10646_1)|| defined(DISPLAY_CHARSET_ISO10646_5)|| defined(DISPLAY_CHARSET_ISO10646_KANA)|| defined(DISPLAY_CHARSET_ISO10646_CN) )
#define DISPLAY_CHARSET_ISO10646_1 // use the better font on full graphic displays.
#endif
......@@ -68,9 +68,9 @@
#define MSG_FAN_SPEED "Fan speed"
#define MSG_FLOW "Flow"
#define MSG_CONTROL "Control"
#define MSG_MIN " "LCD_STR_THERMOMETER " Min"
#define MSG_MAX " "LCD_STR_THERMOMETER " Max"
#define MSG_FACTOR " "LCD_STR_THERMOMETER " Fact"
#define MSG_MIN LCD_STR_THERMOMETER " Min"
#define MSG_MAX LCD_STR_THERMOMETER " Max"
#define MSG_FACTOR LCD_STR_THERMOMETER " Fact"
#define MSG_IDLEOOZING "Anti oozing"
#define MSG_AUTOTEMP "Autotemp"
#define MSG_ON "On "
......@@ -84,7 +84,7 @@
#define MSG_ACC "Accel"
#define MSG_VXY_JERK "Vxy-jerk"
#define MSG_VZ_JERK "Vz-jerk"
#define MSG_VE_JERK "Ve-jerk "
#define MSG_VE_JERK "Ve-jerk"
#define MSG_VMAX "Vmax "
#define MSG_X "X"
#define MSG_Y "Y"
......@@ -177,6 +177,11 @@
#define MSG_YSCALE "Y Scale"
#endif
#define MSG_HEATING "Heating..."
#define MSG_HEATING_COMPLETE "Heating done."
#define MSG_BED_HEATING "Bed Heating."
#define MSG_BED_DONE "Bed done."
// Extra
#define MSG_LASER "Laser Preset"
#define MSG_CONFIG "Configuration"
......
......@@ -42,12 +42,14 @@
#define MSG_PREHEAT_GUM_ALL "Preheat GUM All"
#define MSG_PREHEAT_GUM_BEDONLY "Preheat GUM Bed"
#define MSG_PREHEAT_GUM_SETTINGS "Preheat GUM conf"
#define MSG_TOO_COLD_FOR_M600 "M600 Hotend too cold to change filament"
#define MSG_COOLDOWN "Enfriar"
#define MSG_SWITCH_PS_ON "Encender"
#define MSG_SWITCH_PS_OFF "Apagar"
#define MSG_EXTRUDE "Extruir"
#define MSG_RETRACT "Retraer"
#define MSG_MOVE_AXIS "Mover ejes"
#define MSG_LEVEL_BED "Level bed"
#define MSG_MOVE_X "Mover X"
#define MSG_MOVE_Y "Mover Y"
#define MSG_MOVE_Z "Mover Z"
......@@ -61,24 +63,28 @@
#define MSG_FAN_SPEED "Ventilador"
#define MSG_FLOW "Flujo"
#define MSG_CONTROL "Control"
#define MSG_MIN " " STR_THERMOMETER " Min"
#define MSG_MAX " " STR_THERMOMETER " Max"
#define MSG_FACTOR " " STR_THERMOMETER " Fact"
#define MSG_MIN STR_THERMOMETER " Min"
#define MSG_MAX STR_THERMOMETER " Max"
#define MSG_FACTOR STR_THERMOMETER " Fact"
#define MSG_IDLEOOZING "Anti oozing"
#define MSG_AUTOTEMP "Autotemp"
#define MSG_ON "On "
#define MSG_OFF "Off"
#define MSG_PID_P "PID-P"
#define MSG_PID_I "PID-I"
#define MSG_PID_D "PID-D"
#define MSG_H1 " H1"
#define MSG_H2 " H2"
#define MSG_H3 " H3"
#define MSG_ACC "Accel"
#define MSG_VXY_JERK "Vxy-jerk"
#define MSG_VZ_JERK "Vz-jerk"
#define MSG_VE_JERK "Ve-jerk"
#define MSG_VMAX "Vmax "
#define MSG_X "x"
#define MSG_Y "y"
#define MSG_Z "z"
#define MSG_E "e"
#define MSG_X "X"
#define MSG_Y "Y"
#define MSG_Z "Z"
#define MSG_E "E"
#define MSG_VMIN "Vmin"
#define MSG_VTRAV_MIN "Vvacio min"
#define MSG_AMAX "Amax"
......@@ -94,7 +100,7 @@
#define MSG_TEMPERATURE "Temperatura"
#define MSG_MOTION "Movimiento"
#define MSG_VOLUMETRIC "Filament"
#define MSG_VOLUMETRIC_ENABLED "E in mm" STR_h3
#define MSG_VOLUMETRIC_ENABLED "E in mm3"
#define MSG_FILAMENT_SIZE_EXTRUDER "Fil. Dia."
#define MSG_CONTRAST "Contraste"
#define MSG_STORE_EPROM "Guardar memoria"
......@@ -134,14 +140,24 @@
#define MSG_BABYSTEP_Y "Babystep Y"
#define MSG_BABYSTEP_Z "Babystep Z"
#define MSG_ENDSTOP_ABORT "Endstop abort"
#define MSG_HEATING_FAILED_LCD "Heating failed"
#define MSG_ERR_REDUNDANT_TEMP "Err: REDUNDANT TEMP ERROR"
#define MSG_THERMAL_RUNAWAY "THERMAL RUNAWAY"
#define MSG_ERR_MAXTEMP "Err: MAXTEMP"
#define MSG_ERR_MINTEMP "Err: MINTEMP"
#define MSG_ERR_MAXTEMP_BED "Err: MAXTEMP BED"
#define MSG_ERR_MINTEMP_BED "Err: MINTEMP BED"
#define MSG_END_DAY "days"
#define MSG_END_HOUR "hours"
#define MSG_END_MINUTE "minutes"
// Debug
#define MSG_DEBUG_ECHO "DEBUG ECHO ENABLED"
#define MSG_DEBUG_INFO "DEBUG INFO ENABLED"
#define MSG_DEBUG_ERRORS "DEBUG ERRORS ENABLED"
#define MSG_DEBUG_DRYRUN "DEBUG DRYRUN ENABLED"
// Calibrate Delta
#ifdef DELTA
#define MSG_DELTA_CALIBRATE "Delta Calibration"
#define MSG_DELTA_CALIBRATE_X "Calibrate X"
......@@ -150,19 +166,29 @@
#define MSG_DELTA_CALIBRATE_CENTER "Calibrate Center"
#endif // DELTA
// Scara
#ifdef SCARA
#define MSG_XSCALE "X Scale"
#define MSG_YSCALE "Y Scale"
#endif
#define MSG_HEATING "Heating..."
#define MSG_HEATING_COMPLETE "Heating done."
#define MSG_BED_HEATING "Bed Heating."
#define MSG_BED_DONE "Bed done."
// Extra
#define MSG_LASER "Laser Preset"
#define MSG_CONFIG "Configuration"
#define MSG_BAUDRATE "Baudrate"
#define MSG_E_BOWDEN_LENGTH "Extrude " STRINGIFY(BOWDEN_LENGTH) "mm"
#define MSG_R_BOWDEN_LENGTH "Retract " STRINGIFY(BOWDEN_LENGTH) "mm"
#define MSG_PURGE_XMM "Purge " STRINGIFY(LCD_PURGE_LENGTH) "mm"
#define MSG_RETRACT_XMM "Retract " STRINGIFY(LCD_RETRACT_LENGTH) "mm"
#define MSG_SAVED_POS "Saved position"
#define MSG_RESTORING_POS "Restoring position"
#define MSG_INVALID_POS_SLOT "Invalid slot, total slots: "
// Firmware Test
#ifdef FIRMWARE_TEST
#define MSG_FWTEST_YES "Put the Y command to go next"
#define MSG_FWTEST_NO "Put the N command to go next"
......@@ -178,6 +204,7 @@
#define MSG_FWTEST_03 "Start check ENDSTOP"
#define MSG_FWTEST_04 "Start check MOTOR"
#define MSG_FWTEST_ATTENTION "ATTENTION! Check that the three axes are more than 5 mm from the endstop!"
#define MSG_FWTEST_END "Finish Test. Disable FIRMWARE_TEST and recompile."
#endif // FIRMWARE_TEST
#endif // LANGUAGE_ES_H
......@@ -8,14 +8,10 @@
#ifndef LANGUAGE_IT_H
#define LANGUAGE_IT_H
#if !( defined(MAPPER_NON)|| defined(MAPPER_C2C3)|| defined(MAPPER_D0D1)|| defined(MAPPER_D0D1_MOD)|| defined(MAPPER_E382E383) )
#define MAPPER_NON // For direct asci codes
#endif
//#define SIMULATE_ROMFONT //Comment in to see what is seen on the character based displays
#if !( defined(SIMULATE_ROMFONT)|| defined(DISPLAY_CHARSET_ISO10646_1)|| defined(DISPLAY_CHARSET_ISO10646_5)|| defined(DISPLAY_CHARSET_ISO10646_KANA) )
#define DISPLAY_CHARSET_ISO10646_1 // use the better font on full graphic displays.
#endif
#define MAPPER_NON
// Define SIMULATE_ROMFONT to see what is seen on the character based display defined in Configuration.h
//#define SIMULATE_ROMFONT
#define DISPLAY_CHARSET_ISO10646_1
#define WELCOME_MSG MACHINE_NAME " pronta."
#define MSG_SD_INSERTED "SD Card inserita"
......@@ -68,13 +64,13 @@
#define MSG_FAN_SPEED "Ventola"
#define MSG_FLOW "Flusso"
#define MSG_CONTROL "Controllo"
#define MSG_MIN " "LCD_STR_THERMOMETER " Min"
#define MSG_MAX " "LCD_STR_THERMOMETER " Max"
#define MSG_FACTOR " "LCD_STR_THERMOMETER " Fact"
#define MSG_MIN LCD_STR_THERMOMETER " Min"
#define MSG_MAX LCD_STR_THERMOMETER " Max"
#define MSG_FACTOR LCD_STR_THERMOMETER " Fact"
#define MSG_IDLEOOZING "Anti oozing"
#define MSG_AUTOTEMP "Autotemp"
#define MSG_ON "On "
#define MSG_OFF "Off"
#define MSG_ON "ON "
#define MSG_OFF "OFF"
#define MSG_PID_P "PID-P"
#define MSG_PID_I "PID-I"
#define MSG_PID_D "PID-D"
......@@ -116,8 +112,8 @@
#define MSG_PREPARE "Prepara"
#define MSG_TUNE "Adatta"
#define MSG_PAUSE_PRINT "Pausa"
#define MSG_RESUME_PRINT "Riprendi Stampa"
#define MSG_STOP_PRINT "Arresta Stampa"
#define MSG_RESUME_PRINT "Riprendi stampa"
#define MSG_STOP_PRINT "Arresta stampa"
#define MSG_CARD_MENU "SD Card Menu"
#define MSG_NO_CARD "No SD Card"
#define MSG_DWELL "Sospensione..."
......@@ -132,7 +128,7 @@
#define MSG_CONTROL_RETRACTF "Ritrai V"
#define MSG_CONTROL_RETRACT_ZLIFT "Salta mm"
#define MSG_CONTROL_RETRACT_RECOVER "UnRet +mm"
#define MSG_CONTROL_RETRACT_RECOVER_SWAP "S UnRet+mm"
#define MSG_CONTROL_RETRACT_RECOVER_SWAP "Scamb. UnRet +mm"
#define MSG_CONTROL_RETRACT_RECOVERF "UnRet V"
#define MSG_AUTORETRACT "AutoArretramento"
#define MSG_FILAMENTCHANGE "Cambia filamento"
......@@ -177,6 +173,11 @@
#define MSG_YSCALE "Y Scale"
#endif
#define MSG_HEATING "Riscaldamento..."
#define MSG_HEATING_COMPLETE "Riscaldamento finito."
#define MSG_BED_HEATING "Bed Riscaldamento."
#define MSG_BED_DONE "Bed done."
// Extra
#define MSG_LASER "Laser Preset"
#define MSG_CONFIG "Configurazione"
......
#ifndef MACROS_H
#define MACROS_H
// Macros for bit masks
#define BIT(b) (1<<(b))
#define TEST(n,b) (((n)&BIT(b))!=0)
#define SET_BIT(n,b,value) (n) ^= ((-value)^(n)) & (BIT(b))
// Macros for maths shortcuts
#define M_PI 3.1415926536
#define RADIANS(d) ((d)*M_PI/180.0)
#define DEGREES(r) ((r)*180.0/M_PI)
#define SIN_60 0.8660254037844386
#define COS_60 0.5
// Macros to contrain values
#define NOLESS(v,n) do{ if (v < n) v = n; }while(0)
#define NOMORE(v,n) do{ if (v > n) v = n; }while(0)
// Macros to support option testing
#define _CAT(a, ...) a ## __VA_ARGS__
#define SWITCH_ENABLED_0 0
#define SWITCH_ENABLED_1 1
#define SWITCH_ENABLED_ 1
#define ENABLED(b) _CAT(SWITCH_ENABLED_, b)
#define DISABLED(b) (!_CAT(SWITCH_ENABLED_, b))
#define COUNT(a) (sizeof(a)/sizeof(*a))
#endif //__MACROS_H
......@@ -15,9 +15,10 @@
*
* 3 BOARD_RAMPS_OLD - MEGA/RAMPS up to 1.2
* 33 BOARD_RAMPS_13_EFB - RAMPS 1.3 / 1.4 (Power outputs: Extruder, Fan, Bed)
* 34 BOARD_RAMPS_13_EEB - RAMPS 1.3 / 1.4 (Power outputs: Extruder0, Extruder1, Bed)
* 34 BOARD_RAMPS_13_EEB - RAMPS 1.3 / 1.4 (Power outputs: Hotend0, Hotend1, Bed)
* 35 BOARD_RAMPS_13_EFF - RAMPS 1.3 / 1.4 (Power outputs: Extruder, Fan, Fan)
* 36 BOARD_RAMPS_13_EEF - RAMPS 1.3 / 1.4 (Power outputs: Extruder0, Extruder1, Fan)
* 36 BOARD_RAMPS_13_EEF - RAMPS 1.3 / 1.4 (Power outputs: Hotend0, Hotend1, Fan)
* 37 BOARD_RAMPS_13_EEF - RAMPS 1.3 / 1.4 (Power outputs: Hotend0, Hotend1, Hotend2)
*
*301 BOARD_RAMBO - Rambo
*302 BOARD_MINIRAMBO - Mini Rambo
......@@ -1659,6 +1660,208 @@
/****************************************************************************************
* 37
* RAMPS 1.3 / 1.4
* RAMPS_13_EEF (Hotend0, Hotend1, Hotend2)
****************************************************************************************/
#if MB(RAMPS_13_EEE)
#define KNOWN_BOARD 1
#if !defined(__AVR_ATmega1280__) && !defined(__AVR_ATmega2560__)
#error Oops! Make sure you have 'Arduino Mega' selected from the 'Tools -> Boards' menu.
#endif
#define LARGE_FLASH true
//X axis pins
#define ORIG_X_STEP_PIN 54
#define ORIG_X_DIR_PIN 55
#define ORIG_X_ENABLE_PIN 38
#define X_MIN_PIN 3
#define X_MAX_PIN 2
//Y axis pins
#define ORIG_Y_STEP_PIN 60
#define ORIG_Y_DIR_PIN 61
#define ORIG_Y_ENABLE_PIN 56
#define Y_MIN_PIN 14
#define Y_MAX_PIN 15
#define Y2_STEP_PIN 36
#define Y2_DIR_PIN 34
#define Y2_ENABLE_PIN 30
//Z axis pins
#define ORIG_Z_STEP_PIN 46
#define ORIG_Z_DIR_PIN 48
#define ORIG_Z_ENABLE_PIN 62
#define Z_MIN_PIN 18
#define Z_MAX_PIN 19
#define Z_PROBE_PIN 18
#define Z2_STEP_PIN 36
#define Z2_DIR_PIN 34
#define Z2_ENABLE_PIN 30
//E axis pins
#define ORIG_E0_STEP_PIN 26
#define ORIG_E0_DIR_PIN 28
#define ORIG_E0_ENABLE_PIN 24
#define ORIG_E1_STEP_PIN 36
#define ORIG_E1_DIR_PIN 34
#define ORIG_E1_ENABLE_PIN 30
#define SDPOWER -1
#define SDSS 53
#define LED_PIN 13
#define ORIG_FAN_PIN 8
#define PS_ON_PIN 12
#define HEATER_0_PIN 10 // HOTEND 1
#define HEATER_1_PIN 9 // HOTEND 2
#define HEATER_2_PIN 8 // HOTEND 3
#define HEATER_3_PIN -1
#define TEMP_0_PIN 13 // ANALOG NUMBERING
#define TEMP_1_PIN 15 // ANALOG NUMBERING
#define TEMP_2_PIN 14 // ANALOG NUMBERING
#define TEMP_3_PIN -1 // ANALOG NUMBERING
#define HEATER_BED_PIN -1 // BED
#define TEMP_BED_PIN -1 // ANALOG NUMBERING
#if NUM_SERVOS > 0
#define SERVO0_PIN 11
#if NUM_SERVOS > 1
#define SERVO1_PIN 6
#if NUM_SERVOS > 2
#define SERVO2_PIN 5
#if NUM_SERVOS > 3
#define SERVO3_PIN 4
#endif
#endif
#endif
#endif
#ifdef ULTRA_LCD
#ifdef NEWPANEL
#ifdef PANEL_ONE
#define LCD_PINS_RS 40
#define LCD_PINS_ENABLE 42
#define LCD_PINS_D4 65
#define LCD_PINS_D5 66
#define LCD_PINS_D6 44
#define LCD_PINS_D7 64
#else
#define LCD_PINS_RS 16
#define LCD_PINS_ENABLE 17
#define LCD_PINS_D4 23
#define LCD_PINS_D5 25
#define LCD_PINS_D6 27
#define LCD_PINS_D7 29
#endif //PANEL_ONE
#ifdef REPRAP_DISCOUNT_SMART_CONTROLLER
#define BEEPER 37
#define BTN_EN1 31
#define BTN_EN2 33
#define BTN_ENC 35
#define SDCARDDETECT 49
#elif defined(LCD_I2C_PANELOLU2)
#define BTN_EN1 47 //reverse if the encoder turns the wrong way.
#define BTN_EN2 43
#define BTN_ENC 32
#define LCD_SDSS 53
#define SDCARDDETECT -1
#define KILL_PIN 41
#elif defined(LCD_I2C_VIKI)
#define BTN_EN1 22 //reverse if the encoder turns the wrong way.
#define BTN_EN2 7
#define BTN_ENC -1
#define LCD_SDSS 53
#define SDCARDDETECT 49
#elif defined(ELB_FULL_GRAPHIC_CONTROLLER)
#define BTN_EN1 35 // reverse if the encoder turns the wrong way.
#define BTN_EN2 37
#define BTN_ENC 31
#define SDCARDDETECT 49
#define LCD_SDSS 53
#define KILL_PIN 41
#define BEEPER 23
#define DOGLCD_CS 29
#define DOGLCD_A0 27
#define LCD_PIN_BL 33
#else
//arduino pin which triggers an piezzo beeper
#define BEEPER 33 // Beeper on AUX-4
//buttons are directly attached using AUX-2
#ifdef REPRAPWORLD_KEYPAD
#define BTN_EN1 64 // encoder
#define BTN_EN2 59 // encoder
#define BTN_ENC 63 // enter button
#define SHIFT_OUT 40 // shift register
#define SHIFT_CLK 44 // shift register
#define SHIFT_LD 42 // shift register
#elif defined(PANEL_ONE)
#define BTN_EN1 59 // AUX2 PIN 3
#define BTN_EN2 63 // AUX2 PIN 4
#define BTN_ENC 49 // AUX3 PIN 7
#else
#define BTN_EN1 37
#define BTN_EN2 35
#define BTN_ENC 31 //the click
#endif
#ifdef G3D_PANEL
#define SDCARDDETECT 49
#else
#define SDCARDDETECT -1 // Ramps does not use this port
#endif
#endif
#else //old style panel with shift register
//arduino pin witch triggers an piezzo beeper
#define BEEPER 33 //No Beeper added
//buttons are attached to a shift register
// Not wired this yet
//#define SHIFT_CLK 38
//#define SHIFT_LD 42
//#define SHIFT_OUT 40
//#define SHIFT_EN 17
#define LCD_PINS_RS 16
#define LCD_PINS_ENABLE 17
#define LCD_PINS_D4 23
#define LCD_PINS_D5 25
#define LCD_PINS_D6 27
#define LCD_PINS_D7 29
#endif //NEWPANEL
#endif //ULTRA_LCD
// SPI for Max6675 Thermocouple
#ifndef SDSUPPORT
// these pins are defined in the SD library if building with SD support
#define SCK_PIN 52
#define MISO_PIN 50
#define MOSI_PIN 51
#define MAX6675_SS 66 // Do not use pin 53 if there is even the remote possibility of using Display/SD card
#else
#define MAX6675_SS 66 // Do not use pin 49 as this is tied to the switch inside the SD card socket to detect if there is an SD card present
#endif
#endif // RAMPS_13_EEE
/****************************************************************************************/
/****************************************************************************************
* 301
......@@ -1988,9 +2191,9 @@
#if MB(RAMPS_FD_V1)
#define INVERTED_HEATER_PINS
#define RAMPS_FD_V1
#define INVERTED_HEATER_PINS
#define INVERTED_BED_PINS
// No EEPROM
// Use 4k7 thermistor tables
#else
......
......@@ -635,6 +635,7 @@ float junction_deviation = 0.1;
enable_x();
enable_z();
}
if (block->steps[Y_AXIS]) enable_y();
#else
if (block->steps[X_AXIS]) enable_x();
if (block->steps[Y_AXIS]) enable_y();
......
......@@ -174,36 +174,6 @@
#error "The given BACK_PROBE_BED_POSITION can't be reached by the probe."
#endif
#define PROBE_SIZE_X (X_PROBE_OFFSET_FROM_EXTRUDER * (AUTO_BED_LEVELING_GRID_POINTS-1))
#define PROBE_SIZE_Y (Y_PROBE_OFFSET_FROM_EXTRUDER * (AUTO_BED_LEVELING_GRID_POINTS-1))
#define PROBE_AREA_WIDTH (RIGHT_PROBE_BED_POSITION - LEFT_PROBE_BED_POSITION)
#define PROBE_AREA_DEPTH (BACK_PROBE_BED_POSITION - FRONT_PROBE_BED_POSITION)
#if X_PROBE_OFFSET_FROM_EXTRUDER < 0
#if PROBE_SIZE_X <= -PROBE_AREA_WIDTH
#define X_PROBE_ERROR
#endif
#elif PROBE_SIZE_X >= PROBE_AREA_WIDTH
#define X_PROBE_ERROR
#endif
#ifdef X_PROBE_ERROR
#error The X axis probing range is too small to fit all the points defined in AUTO_BED_LEVELING_GRID_POINTS
#endif
#if Y_PROBE_OFFSET_FROM_EXTRUDER < 0
#if PROBE_SIZE_Y <= -PROBE_AREA_DEPTH
#define Y_PROBE_ERROR
#endif
#elif PROBE_SIZE_Y >= PROBE_AREA_DEPTH
#define Y_PROBE_ERROR
#endif
#ifdef Y_PROBE_ERROR
#error The Y axis probing range is too small to fit all the points defined in AUTO_BED_LEVELING_GRID_POINTS
#endif
#undef PROBE_SIZE_X
#undef PROBE_SIZE_Y
#undef PROBE_AREA_WIDTH
#undef PROBE_AREA_DEPTH
#else // !AUTO_BED_LEVELING_GRID
// Check the triangulation points
......@@ -264,18 +234,18 @@
*/
#if HAS_AUTO_FAN && HAS_FAN
#if EXTRUDER_0_AUTO_FAN_PIN == FAN_PIN
#error You cannot set EXTRUDER_0_AUTO_FAN_PIN equal to FAN_PIN
#error You cannot set EXTRUDER_0_AUTO_FAN_PIN equal to FAN_PIN.
#elif EXTRUDER_1_AUTO_FAN_PIN == FAN_PIN
#error You cannot set EXTRUDER_1_AUTO_FAN_PIN equal to FAN_PIN
#error You cannot set EXTRUDER_1_AUTO_FAN_PIN equal to FAN_PIN.
#elif EXTRUDER_2_AUTO_FAN_PIN == FAN_PIN
#error You cannot set EXTRUDER_2_AUTO_FAN_PIN equal to FAN_PIN
#error You cannot set EXTRUDER_2_AUTO_FAN_PIN equal to FAN_PIN.
#elif EXTRUDER_3_AUTO_FAN_PIN == FAN_PIN
#error You cannot set EXTRUDER_3_AUTO_FAN_PIN equal to FAN_PIN
#error You cannot set EXTRUDER_3_AUTO_FAN_PIN equal to FAN_PIN.
#endif
#endif
#if HAS_FAN && CONTROLLERFAN_PIN == FAN_PIN
#error You cannot set CONTROLLERFAN_PIN equal to FAN_PIN
#error You cannot set CONTROLLERFAN_PIN equal to FAN_PIN.
#endif
/**
......@@ -293,28 +263,37 @@
#if !HAS_HEATER_1
#error HEATER_1_PIN not defined for this board
#endif
#endif
#elif HOTENDS > 0
#if !HAS_HEATER_0
#error HEATER_0_PIN not defined for this board
#endif
#endif
/**
* Warnings for old configurations
*/
#ifdef X_HOME_RETRACT_MM
#error [XYZ]_HOME_RETRACT_MM settings have been renamed [XYZ]_HOME_BUMP_MM
#error [XYZ]_HOME_RETRACT_MM settings have been renamed [XYZ]_HOME_BUMP_MM.
#endif
#if WATCH_TEMP_PERIOD > 500
#error WATCH_TEMP_PERIOD now uses seconds instead of milliseconds
#error WATCH_TEMP_PERIOD now uses seconds instead of milliseconds.
#endif
#if !defined(THERMAL_PROTECTION_HOTENDS) && (defined(WATCH_TEMP_PERIOD) || defined(THERMAL_PROTECTION_PERIOD))
#error Thermal Runaway Protection for hotends must now be enabled with THERMAL_PROTECTION_HOTENDS
#error Thermal Runaway Protection for hotends must now be enabled with THERMAL_PROTECTION_HOTENDS.
#endif
#if !defined(THERMAL_PROTECTION_BED) && defined(THERMAL_PROTECTION_BED_PERIOD)
#error Thermal Runaway Protection for the bed must now be enabled with THERMAL_PROTECTION_BED
#error Thermal Runaway Protection for the bed must now be enabled with THERMAL_PROTECTION_BED.
#endif
#ifdef PROBE_SERVO_DEACTIVATION_DELAY
#error PROBE_SERVO_DEACTIVATION_DELAY has been replaced with DEACTIVATE_SERVOS_AFTER_MOVE and SERVO_DEACTIVATION_DELAY.
#endif
#if defined(COREXZ) && defined(Z_LATE_ENABLE)
#error "Z_LATE_ENABLE can't be used with COREXZ."
#endif
#endif //SANITYCHECK_H
G92 X0 Z0 Y0 E0
\ No newline at end of file
M117 Test1
M117 Test1
M0
M117 Test2
G28
M23 Menu/Prepare/Level_Bed.g
Copy folder Menu in sd card.
\ No newline at end of file
/*
Servo.cpp - Interrupt driven Servo library for Arduino using 16 bit timers- Version 2
servo.cpp - Interrupt driven Servo library for Arduino using 16 bit timers- Version 2
Copyright (c) 2009 Michael Margolis. All right reserved.
This library is free software; you can redistribute it and/or
......@@ -35,12 +35,14 @@
write() - Sets the servo angle in degrees. (invalid angle that is valid as pulse in microseconds is treated as microseconds)
writeMicroseconds() - Sets the servo pulse width in microseconds
move(pin, angle) - Sequence of attach(pin), write(angle).
With DEACTIVATE_SERVOS_AFTER_MOVE it waits SERVO_DEACTIVATION_DELAY and detaches.
read() - Gets the last written servo pulse width as an angle between 0 and 180.
readMicroseconds() - Gets the last written servo pulse width in microseconds. (was read_us() in first release)
attached() - Returns true if there is a servo attached.
detach() - Stops an attached servos from pulsing its i/o pin.
*/
*/
#include "Configuration.h"
#if NUM_SERVOS > 0
......@@ -57,7 +59,7 @@
//#define NBR_TIMERS (MAX_SERVOS / SERVOS_PER_TIMER)
static servo_t servos[MAX_SERVOS]; // static array of servo structures
static ServoInfo_t servo_info[MAX_SERVOS]; // static array of servo info structures
static volatile int8_t Channel[_Nbr_16timers ]; // counter for the servo being pulsed for each timer (or -1 if refresh interval)
uint8_t ServoCount = 0; // the total number of attached servos
......@@ -67,7 +69,7 @@ uint8_t ServoCount = 0; // the total number
#define SERVO_INDEX_TO_TIMER(_servo_nbr) ((timer16_Sequence_t)(_servo_nbr / SERVOS_PER_TIMER)) // returns the timer controlling this servo
#define SERVO_INDEX_TO_CHANNEL(_servo_nbr) (_servo_nbr % SERVOS_PER_TIMER) // returns the index of the servo on this timer
#define SERVO_INDEX(_timer,_channel) ((_timer*SERVOS_PER_TIMER) + _channel) // macro to access servo index by timer and channel
#define SERVO(_timer,_channel) (servos[SERVO_INDEX(_timer,_channel)]) // macro to access servo class by timer and channel
#define SERVO(_timer,_channel) (servo_info[SERVO_INDEX(_timer,_channel)]) // macro to access servo class by timer and channel
#define SERVO_MIN() (MIN_PULSE_WIDTH - this->min * 4) // minimum value in uS for this servo
#define SERVO_MAX() (MAX_PULSE_WIDTH - this->max * 4) // maximum value in uS for this servo
......@@ -79,14 +81,14 @@ static inline void handle_interrupts(timer16_Sequence_t timer, volatile uint16_t
*TCNTn = 0; // channel set to -1 indicated that refresh interval completed so reset the timer
else {
if (SERVO_INDEX(timer,Channel[timer]) < ServoCount && SERVO(timer,Channel[timer]).Pin.isActive)
digitalWrite( SERVO(timer,Channel[timer]).Pin.nbr,LOW); // pulse this channel low if activated
digitalWrite( SERVO(timer,Channel[timer]).Pin.nbr, LOW); // pulse this channel low if activated
}
Channel[timer]++; // increment to the next channel
if (SERVO_INDEX(timer,Channel[timer]) < ServoCount && Channel[timer] < SERVOS_PER_TIMER) {
*OCRnA = *TCNTn + SERVO(timer,Channel[timer]).ticks;
if (SERVO(timer,Channel[timer]).Pin.isActive) // check if activated
digitalWrite( SERVO(timer,Channel[timer]).Pin.nbr,HIGH); // its an active channel so pulse it high
digitalWrite( SERVO(timer,Channel[timer]).Pin.nbr, HIGH); // its an active channel so pulse it high
}
else {
// finished all channels so wait for the refresh period to expire before starting over
......@@ -144,7 +146,7 @@ static void initISR(timer16_Sequence_t timer) {
TIFR1 |= _BV(OCF1A); // clear any pending interrupts;
TIMSK1 |= _BV(OCIE1A); // enable the output compare interrupt
#endif
#if defined(WIRING)
#ifdef WIRING
timerAttach(TIMER1OUTCOMPAREA_INT, Timer1Service);
#endif
}
......@@ -228,38 +230,39 @@ static boolean isTimerActive(timer16_Sequence_t timer) {
/****************** end of static functions ******************************/
Servo::Servo() {
if ( ServoCount < MAX_SERVOS) {
if (ServoCount < MAX_SERVOS) {
this->servoIndex = ServoCount++; // assign a servo index to this instance
servos[this->servoIndex].ticks = usToTicks(DEFAULT_PULSE_WIDTH); // store default values - 12 Aug 2009
servo_info[this->servoIndex].ticks = usToTicks(DEFAULT_PULSE_WIDTH); // store default values
}
else
this->servoIndex = INVALID_SERVO; // too many servos
}
uint8_t Servo::attach(int pin) {
int8_t Servo::attach(int pin) {
return this->attach(pin, MIN_PULSE_WIDTH, MAX_PULSE_WIDTH);
}
uint8_t Servo::attach(int pin, int min, int max) {
if (this->servoIndex < MAX_SERVOS ) {
#if defined(ENABLE_AUTO_BED_LEVELING) && (PROBE_SERVO_DEACTIVATION_DELAY > 0)
if (pin > 0) this->pin = pin; else pin = this->pin;
#endif
pinMode(pin, OUTPUT); // set servo pin to output
servos[this->servoIndex].Pin.nbr = pin;
int8_t Servo::attach(int pin, int min, int max) {
if (this->servoIndex >= MAX_SERVOS) return -1;
if (pin > 0) servo_info[this->servoIndex].Pin.nbr = pin;
pinMode(servo_info[this->servoIndex].Pin.nbr, OUTPUT); // set servo pin to output
// todo min/max check: abs(min - MIN_PULSE_WIDTH) /4 < 128
this->min = (MIN_PULSE_WIDTH - min) / 4; //resolution of min/max is 4 uS
this->max = (MAX_PULSE_WIDTH - max) / 4;
// initialize the timer if it has not already been initialized
timer16_Sequence_t timer = SERVO_INDEX_TO_TIMER(servoIndex);
if (!isTimerActive(timer)) initISR(timer);
servos[this->servoIndex].Pin.isActive = true; // this must be set after the check for isTimerActive
}
servo_info[this->servoIndex].Pin.isActive = true; // this must be set after the check for isTimerActive
return this->servoIndex;
}
void Servo::detach() {
servos[this->servoIndex].Pin.isActive = false;
servo_info[this->servoIndex].Pin.isActive = false;
timer16_Sequence_t timer = SERVO_INDEX_TO_TIMER(servoIndex);
if (!isTimerActive(timer)) finISR(timer);
}
......@@ -283,11 +286,11 @@ void Servo::writeMicroseconds(int value) {
value = SERVO_MAX();
value = value - TRIM_DURATION;
value = usToTicks(value); // convert to ticks after compensating for interrupt overhead - 12 Aug 2009
value = usToTicks(value); // convert to ticks after compensating for interrupt overhead
uint8_t oldSREG = SREG;
cli();
servos[channel].ticks = value;
servo_info[channel].ticks = value;
SREG = oldSREG;
}
}
......@@ -296,9 +299,19 @@ void Servo::writeMicroseconds(int value) {
int Servo::read() { return map( this->readMicroseconds()+1, SERVO_MIN(), SERVO_MAX(), 0, 180); }
int Servo::readMicroseconds() {
return (this->servoIndex == INVALID_SERVO) ? 0 : ticksToUs(servos[this->servoIndex].ticks) + TRIM_DURATION;
return (this->servoIndex == INVALID_SERVO) ? 0 : ticksToUs(servo_info[this->servoIndex].ticks) + TRIM_DURATION;
}
bool Servo::attached() { return servos[this->servoIndex].Pin.isActive; }
bool Servo::attached() { return servo_info[this->servoIndex].Pin.isActive; }
void Servo::move(int value) {
if (this->attach(0) >= 0) {
this->write(value);
#ifdef DEACTIVATE_SERVOS_AFTER_MOVE
delay(SERVO_DEACTIVATION_DELAY);
this->detach();
#endif
}
}
#endif
......@@ -40,6 +40,8 @@
readMicroseconds() - Gets the last written servo pulse width in microseconds. (was read_us() in first release)
attached() - Returns true if there is a servo attached.
detach() - Stops an attached servos from pulsing its i/o pin.
move(angle) - Sequence of attach(0), write(angle),
With DEACTIVATE_SERVOS_AFTER_MOVE wait SERVO_DEACTIVATION_DELAY and detach.
*/
#ifndef servo_h
......@@ -110,22 +112,23 @@ typedef struct {
typedef struct {
ServoPin_t Pin;
unsigned int ticks;
} servo_t;
} ServoInfo_t;
class Servo {
public:
Servo();
uint8_t attach(int pin); // attach the given pin to the next free channel, sets pinMode, returns channel number or 0 if failure
uint8_t attach(int pin, int min, int max); // as above but also sets min and max values for writes.
int8_t attach(int pin); // attach the given pin to the next free channel, set pinMode, return channel number (-1 on fail)
int8_t attach(int pin, int min, int max); // as above but also sets min and max values for writes.
void detach();
void write(int value); // if value is < 200 it is treated as an angle, otherwise as pulse width in microseconds
void writeMicroseconds(int value); // Write pulse width in microseconds
void writeMicroseconds(int value); // write pulse width in microseconds
void move(int value); // attach the servo, then move to value
// if value is < 200 it is treated as an angle, otherwise as pulse width in microseconds
// if DEACTIVATE_SERVOS_AFTER_MOVE wait SERVO_DEACTIVATION_DELAY, then detach
int read(); // returns current pulse width as an angle between 0 and 180 degrees
int readMicroseconds(); // returns current pulse width in microseconds for this servo (was read_us() in first release)
bool attached(); // return true if this servo is attached, otherwise false
#if defined(ENABLE_AUTO_BED_LEVELING) && PROBE_SERVO_DEACTIVATION_DELAY > 0
int pin; // store the hardware pin of the servo
#endif
private:
uint8_t servoIndex; // index into the channel data for this servo
int8_t min; // minimum is this value times 4 added to MIN_PULSE_WIDTH
......
......@@ -291,6 +291,175 @@ void checkHitEndstops() {
void enable_endstops(bool check) { check_endstops = check; }
// Check endstops
inline void update_endstops() {
#ifdef Z_DUAL_ENDSTOPS
uint16_t
#else
byte
#endif
current_endstop_bits = 0;
#define _ENDSTOP_PIN(AXIS, MINMAX) AXIS ##_## MINMAX ##_PIN
#define _ENDSTOP_INVERTING(AXIS, MINMAX) AXIS ##_## MINMAX ##_ENDSTOP_INVERTING
#define _AXIS(AXIS) AXIS ##_AXIS
#define _ENDSTOP_HIT(AXIS) endstop_hit_bits |= BIT(_ENDSTOP(AXIS, MIN))
#define _ENDSTOP(AXIS, MINMAX) AXIS ##_## MINMAX
// SET_ENDSTOP_BIT: set the current endstop bits for an endstop to its status
#define SET_ENDSTOP_BIT(AXIS, MINMAX) SET_BIT(current_endstop_bits, _ENDSTOP(AXIS, MINMAX), (READ(_ENDSTOP_PIN(AXIS, MINMAX)) != _ENDSTOP_INVERTING(AXIS, MINMAX)))
// COPY_BIT: copy the value of COPY_BIT to BIT in bits
#define COPY_BIT(bits, COPY_BIT, BIT) SET_BIT(bits, BIT, TEST(bits, COPY_BIT))
// TEST_ENDSTOP: test the old and the current status of an endstop
#define TEST_ENDSTOP(ENDSTOP) (TEST(current_endstop_bits, ENDSTOP) && TEST(old_endstop_bits, ENDSTOP))
#define UPDATE_ENDSTOP(AXIS,MINMAX) \
SET_ENDSTOP_BIT(AXIS, MINMAX); \
if (TEST_ENDSTOP(_ENDSTOP(AXIS, MINMAX)) && (current_block->steps[_AXIS(AXIS)] > 0)) { \
endstops_trigsteps[_AXIS(AXIS)] = count_position[_AXIS(AXIS)]; \
_ENDSTOP_HIT(AXIS); \
step_events_completed = current_block->step_event_count; \
}
#ifdef COREXY
// Head direction in -X axis for CoreXY bots.
// If DeltaX == -DeltaY, the movement is only in Y axis
if ((current_block->steps[A_AXIS] != current_block->steps[B_AXIS]) || (TEST(out_bits, A_AXIS) == TEST(out_bits, B_AXIS))) {
if (TEST(out_bits, X_HEAD))
#elif defined(COREXZ)
// Head direction in -X axis for CoreXZ bots.
// If DeltaX == -DeltaZ, the movement is only in Z axis
if ((current_block->steps[A_AXIS] != current_block->steps[C_AXIS]) || (TEST(out_bits, A_AXIS) == TEST(out_bits, C_AXIS))) {
if (TEST(out_bits, X_HEAD))
#else
if (TEST(out_bits, X_AXIS)) // stepping along -X axis (regular Cartesian bot)
#endif
{ // -direction
#ifdef DUAL_X_CARRIAGE
// with 2 x-carriages, endstops are only checked in the homing direction for the active extruder
if ((current_block->active_extruder == 0 && X_HOME_DIR == -1) || (current_block->active_extruder != 0 && X2_HOME_DIR == -1))
#endif
{
#if HAS_X_MIN
UPDATE_ENDSTOP(X, MIN);
#endif
}
}
else { // +direction
#ifdef DUAL_X_CARRIAGE
// with 2 x-carriages, endstops are only checked in the homing direction for the active extruder
if ((current_block->active_extruder == 0 && X_HOME_DIR == 1) || (current_block->active_extruder != 0 && X2_HOME_DIR == 1))
#endif
{
#if HAS_X_MAX
UPDATE_ENDSTOP(X, MAX);
#endif
}
}
#if defined(COREXY) || defined(COREXZ)
}
#endif
#ifdef COREXY
// Head direction in -Y axis for CoreXY bots.
// If DeltaX == DeltaY, the movement is only in X axis
if ((current_block->steps[A_AXIS] != current_block->steps[B_AXIS]) || (TEST(out_bits, A_AXIS) != TEST(out_bits, B_AXIS))) {
if (TEST(out_bits, Y_HEAD))
#else
if (TEST(out_bits, Y_AXIS)) // -direction
#endif
{ // -direction
#if HAS_Y_MIN
UPDATE_ENDSTOP(Y, MIN);
#endif
}
else { // +direction
#if HAS_Y_MAX
UPDATE_ENDSTOP(Y, MAX);
#endif
}
#if defined(COREXY)
}
#endif
#ifdef COREXZ
// Head direction in -Z axis for CoreXZ bots.
// If DeltaX == DeltaZ, the movement is only in X axis
if ((current_block->steps[A_AXIS] != current_block->steps[C_AXIS]) || (TEST(out_bits, A_AXIS) != TEST(out_bits, C_AXIS))) {
if (TEST(out_bits, Z_HEAD))
#else
if (TEST(out_bits, Z_AXIS))
#endif
{ // z -direction
#if HAS_Z_MIN
#ifdef Z_DUAL_ENDSTOPS
SET_ENDSTOP_BIT(Z, MIN);
#if HAS_Z2_MIN
SET_ENDSTOP_BIT(Z2, MIN);
#else
COPY_BIT(current_endstop_bits, Z_MIN, Z2_MIN);
#endif
byte z_test = TEST_ENDSTOP(Z_MIN) << 0 + TEST_ENDSTOP(Z2_MIN) << 1; // bit 0 for Z, bit 1 for Z2
if (z_test && current_block->steps[Z_AXIS] > 0) { // z_test = Z_MIN || Z2_MIN
endstops_trigsteps[Z_AXIS] = count_position[Z_AXIS];
endstop_hit_bits |= BIT(Z_MIN);
if (!performing_homing || (z_test == 0x3)) //if not performing home or if both endstops were trigged during homing...
step_events_completed = current_block->step_event_count;
}
#else // !Z_DUAL_ENDSTOPS
UPDATE_ENDSTOP(Z, MIN);
#endif // !Z_DUAL_ENDSTOPS
#endif // Z_MIN_PIN
#ifdef Z_PROBE_ENDSTOP
UPDATE_ENDSTOP(Z, PROBE);
if (TEST_ENDSTOP(Z_PROBE))
{
endstops_trigsteps[Z_AXIS] = count_position[Z_AXIS];
endstop_hit_bits |= BIT(Z_PROBE);
}
#endif
}
else { // z +direction
#if HAS_Z_MAX
#ifdef Z_DUAL_ENDSTOPS
SET_ENDSTOP_BIT(Z, MAX);
#if HAS_Z2_MAX
SET_ENDSTOP_BIT(Z2, MAX);
#else
COPY_BIT(current_endstop_bits, Z_MAX, Z2_MAX)
#endif
byte z_test = TEST_ENDSTOP(Z_MAX) << 0 + TEST_ENDSTOP(Z2_MAX) << 1; // bit 0 for Z, bit 1 for Z2
if (z_test && current_block->steps[Z_AXIS] > 0) { // t_test = Z_MAX || Z2_MAX
endstops_trigsteps[Z_AXIS] = count_position[Z_AXIS];
endstop_hit_bits |= BIT(Z_MIN);
if (!performing_homing || (z_test == 0x3)) //if not performing home or if both endstops were trigged during homing...
step_events_completed = current_block->step_event_count;
}
#else // !Z_DUAL_ENDSTOPS
UPDATE_ENDSTOP(Z, MAX);
#endif // !Z_DUAL_ENDSTOPS
#endif // Z_MAX_PIN
}
#if defined(COREXZ)
}
#endif
old_endstop_bits = current_endstop_bits;
}
// __________________________
// /| |\ _________________ ^
// / | | \ /| |\ |
......@@ -465,174 +634,8 @@ ISR(TIMER1_COMPA_vect) {
if (current_block != NULL) {
// Check endstops
if (check_endstops) {
#ifdef Z_DUAL_ENDSTOPS
uint16_t
#else
byte
#endif
current_endstop_bits = 0;
#define _ENDSTOP_PIN(AXIS, MINMAX) AXIS ##_## MINMAX ##_PIN
#define _ENDSTOP_INVERTING(AXIS, MINMAX) AXIS ##_## MINMAX ##_ENDSTOP_INVERTING
#define _AXIS(AXIS) AXIS ##_AXIS
#define _ENDSTOP_HIT(AXIS) endstop_hit_bits |= BIT(_ENDSTOP(AXIS, MIN))
#define _ENDSTOP(AXIS, MINMAX) AXIS ##_## MINMAX
// SET_ENDSTOP_BIT: set the current endstop bits for an endstop to its status
#define SET_ENDSTOP_BIT(AXIS, MINMAX) SET_BIT(current_endstop_bits, _ENDSTOP(AXIS, MINMAX), (READ(_ENDSTOP_PIN(AXIS, MINMAX)) != _ENDSTOP_INVERTING(AXIS, MINMAX)))
// COPY_BIT: copy the value of COPY_BIT to BIT in bits
#define COPY_BIT(bits, COPY_BIT, BIT) SET_BIT(bits, BIT, TEST(bits, COPY_BIT))
// TEST_ENDSTOP: test the old and the current status of an endstop
#define TEST_ENDSTOP(ENDSTOP) (TEST(current_endstop_bits, ENDSTOP) && TEST(old_endstop_bits, ENDSTOP))
#define UPDATE_ENDSTOP(AXIS,MINMAX) \
SET_ENDSTOP_BIT(AXIS, MINMAX); \
if (TEST_ENDSTOP(_ENDSTOP(AXIS, MINMAX)) && (current_block->steps[_AXIS(AXIS)] > 0)) { \
endstops_trigsteps[_AXIS(AXIS)] = count_position[_AXIS(AXIS)]; \
_ENDSTOP_HIT(AXIS); \
step_events_completed = current_block->step_event_count; \
}
#ifdef COREXY
// Head direction in -X axis for CoreXY bots.
// If DeltaX == -DeltaY, the movement is only in Y axis
if ((current_block->steps[A_AXIS] != current_block->steps[B_AXIS]) || (TEST(out_bits, A_AXIS) == TEST(out_bits, B_AXIS))) {
if (TEST(out_bits, X_HEAD))
#elif defined(COREXZ)
// Head direction in -X axis for CoreXZ bots.
// If DeltaX == -DeltaZ, the movement is only in Z axis
if ((current_block->steps[A_AXIS] != current_block->steps[C_AXIS]) || (TEST(out_bits, A_AXIS) == TEST(out_bits, C_AXIS))) {
if (TEST(out_bits, X_HEAD))
#else
if (TEST(out_bits, X_AXIS)) // stepping along -X axis (regular Cartesian bot)
#endif
{ // -direction
#ifdef DUAL_X_CARRIAGE
// with 2 x-carriages, endstops are only checked in the homing direction for the active extruder
if ((current_block->active_driver == 0 && X_HOME_DIR == -1) || (current_block->active_driver != 0 && X2_HOME_DIR == -1))
#endif
{
#if HAS_X_MIN
UPDATE_ENDSTOP(X, MIN);
#endif
}
}
else { // +direction
#ifdef DUAL_X_CARRIAGE
// with 2 x-carriages, endstops are only checked in the homing direction for the active extruder
if ((current_block->active_driver == 0 && X_HOME_DIR == 1) || (current_block->active_driver != 0 && X2_HOME_DIR == 1))
#endif
{
#if HAS_X_MAX
UPDATE_ENDSTOP(X, MAX);
#endif
}
}
#if defined(COREXY) || defined(COREXZ)
}
#endif
#ifdef COREXY
// Head direction in -Y axis for CoreXY bots.
// If DeltaX == DeltaY, the movement is only in X axis
if ((current_block->steps[A_AXIS] != current_block->steps[B_AXIS]) || (TEST(out_bits, A_AXIS) != TEST(out_bits, B_AXIS))) {
if (TEST(out_bits, Y_HEAD))
#else
if (TEST(out_bits, Y_AXIS)) // -direction
#endif
{ // -direction
#if HAS_Y_MIN
UPDATE_ENDSTOP(Y, MIN);
#endif
}
else { // +direction
#if HAS_Y_MAX
UPDATE_ENDSTOP(Y, MAX);
#endif
}
#ifdef COREXY
}
#endif
#ifdef COREXZ
// Head direction in -Z axis for CoreXZ bots.
// If DeltaX == DeltaZ, the movement is only in X axis
if ((current_block->steps[A_AXIS] != current_block->steps[C_AXIS]) || (TEST(out_bits, A_AXIS) != TEST(out_bits, C_AXIS))) {
if (TEST(out_bits, Z_HEAD))
#else
if (TEST(out_bits, Z_AXIS))
#endif
{ // z -direction
#if HAS_Z_MIN
#ifdef Z_DUAL_ENDSTOPS
SET_ENDSTOP_BIT(Z, MIN);
#if HAS_Z2_MIN
SET_ENDSTOP_BIT(Z2, MIN);
#else
COPY_BIT(current_endstop_bits, Z_MIN, Z2_MIN);
#endif
byte z_test = TEST_ENDSTOP(Z_MIN) << 0 + TEST_ENDSTOP(Z2_MIN) << 1; // bit 0 for Z, bit 1 for Z2
if (z_test && current_block->steps[Z_AXIS] > 0) { // z_test = Z_MIN || Z2_MIN
endstops_trigsteps[Z_AXIS] = count_position[Z_AXIS];
endstop_hit_bits |= BIT(Z_MIN);
if (!performing_homing || (z_test == 0x3)) //if not performing home or if both endstops were trigged during homing...
step_events_completed = current_block->step_event_count;
}
#else // !Z_DUAL_ENDSTOPS
UPDATE_ENDSTOP(Z, MIN);
#endif // !Z_DUAL_ENDSTOPS
#endif // Z_MIN_PIN
#ifdef Z_PROBE_ENDSTOP
UPDATE_ENDSTOP(Z, PROBE);
if (TEST_ENDSTOP(Z_PROBE)) {
endstops_trigsteps[Z_AXIS] = count_position[Z_AXIS];
endstop_hit_bits |= BIT(Z_PROBE);
}
#endif
}
else { // z +direction
#if HAS_Z_MAX
#ifdef Z_DUAL_ENDSTOPS
SET_ENDSTOP_BIT(Z, MAX);
#if HAS_Z2_MAX
SET_ENDSTOP_BIT(Z2, MAX);
#else
COPY_BIT(current_endstop_bits, Z_MAX, Z2_MAX)
#endif
byte z_test = TEST_ENDSTOP(Z_MAX) << 0 + TEST_ENDSTOP(Z2_MAX) << 1; // bit 0 for Z, bit 1 for Z2
if (z_test && current_block->steps[Z_AXIS] > 0) { // t_test = Z_MAX || Z2_MAX
endstops_trigsteps[Z_AXIS] = count_position[Z_AXIS];
endstop_hit_bits |= BIT(Z_MIN);
if (!performing_homing || (z_test == 0x3)) //if not performing home or if both endstops were trigged during homing...
step_events_completed = current_block->step_event_count;
}
#else // !Z_DUAL_ENDSTOPS
UPDATE_ENDSTOP(Z, MAX);
#endif // !Z_DUAL_ENDSTOPS
#endif // Z_MAX_PIN
}
old_endstop_bits = current_endstop_bits;
#ifdef COREXZ
}
#endif
}
// Update endstops state, if enabled
if (check_endstops) update_endstops();
// Take multiple steps per interrupt (For high speed moves)
for (int8_t i = 0; i < step_loops; i++) {
......@@ -1107,13 +1110,7 @@ long st_get_position(uint8_t axis) {
return count_pos;
}
#ifdef ENABLE_AUTO_BED_LEVELING
float st_get_position_mm(AxisEnum axis) {
return st_get_position(axis) / axis_steps_per_unit[axis];
}
#endif // ENABLE_AUTO_BED_LEVELING
float st_get_position_mm(AxisEnum axis) { return st_get_position(axis) / axis_steps_per_unit[axis]; }
void finishAndDisableSteppers() {
st_synchronize();
......@@ -1291,7 +1288,7 @@ void microstep_init() {
pinMode(E0_MS1_PIN,OUTPUT);
pinMode(E0_MS2_PIN,OUTPUT);
const uint8_t microstep_modes[] = MICROSTEP_MODES;
for (uint16_t i = 0; i < sizeof(microstep_modes) / sizeof(microstep_modes[0]); i++)
for (uint16_t i = 0; i < COUNT(microstep_modes); i++)
microstep_mode(i, microstep_modes[i]);
#endif
}
......
......@@ -70,16 +70,13 @@ void st_set_e_position(const long &e);
// Get current position in steps
long st_get_position(uint8_t axis);
#ifdef ENABLE_AUTO_BED_LEVELING
// Get current position in mm
float st_get_position_mm(AxisEnum axis);
#endif
// Get current position in mm
float st_get_position_mm(AxisEnum axis);
// The stepper subsystem goes to sleep when it runs out of things to execute. Call this
// to notify the subsystem that it is time to go to work.
void st_wake_up();
void checkHitEndstops(); //call from somewhere to create an serial error message with the locations the endstops where hit, in case they were triggered
void endstops_hit_on_purpose(); //avoid creation of the message, i.e. after homing and before a routine call of checkHitEndstops();
......
......@@ -75,13 +75,12 @@ unsigned char soft_pwm_bed;
#if defined(THERMAL_PROTECTION_HOTENDS) || defined(THERMAL_PROTECTION_BED)
enum TRState { TRReset, TRInactive, TRFirstHeating, TRStable, TRRunaway };
static float tr_target_temperature[HOTENDS + 1] = { 0.0 };
void thermal_runaway_protection(TRState *state, millis_t *timer, float temperature, float target_temperature, int heater_id, int period_seconds, int hysteresis_degc);
#ifdef THERMAL_PROTECTION_HOTENDS
static TRState thermal_runaway_state_machine[4] = { TRReset, TRReset, TRReset, TRReset };
static millis_t thermal_runaway_timer[4]; // = {0,0,0,0};
#endif
#ifdef THERMAL_PROTECTION_BED
#if defined(THERMAL_PROTECTION_BED) && TEMP_SENSOR_BED != 0
static TRState thermal_runaway_bed_state_machine = TRReset;
static millis_t thermal_runaway_bed_timer;
#endif
......@@ -485,6 +484,8 @@ float get_pid_output(int e) {
pid_output = constrain(target_temperature[e], 0, PID_MAX);
#else
pid_error[e] = target_temperature[e] - current_temperature[e];
dTerm[e] = K2 * PID_PARAM(Kd,e) * (current_temperature[e] - temp_dState[e]) + K1 * dTerm[e];
temp_dState[e] = current_temperature[e];
if (pid_error[e] > PID_FUNCTIONAL_RANGE) {
pid_output = BANG_MAX;
pid_reset[e] = true;
......@@ -503,7 +504,6 @@ float get_pid_output(int e) {
temp_iState[e] = constrain(temp_iState[e], temp_iState_min[e], temp_iState_max[e]);
iTerm[e] = PID_PARAM(Ki,e) * temp_iState[e];
dTerm[e] = K2 * PID_PARAM(Kd,e) * (current_temperature[e] - temp_dState[e]) + K1 * dTerm[e];
pid_output = pTerm[e] + iTerm[e] - dTerm[e];
if (pid_output > PID_MAX) {
if (pid_error[e] > 0) temp_iState[e] -= pid_error[e]; // conditional un-integration
......@@ -514,7 +514,6 @@ float get_pid_output(int e) {
pid_output = 0;
}
}
temp_dState[e] = current_temperature[e];
#endif //PID_OPENLOOP
#ifdef PID_DEBUG
......@@ -1043,7 +1042,7 @@ void tp_init() {
void start_watching_heater(int e) {
if (degHotend(e) < degTargetHotend(e) - (WATCH_TEMP_INCREASE + TEMP_HYSTERESIS + 1)) {
watch_target_temp[e] = degHotend(e) + WATCH_TEMP_INCREASE;
watch_heater_next_ms[e] = millis() + WATCH_TEMP_PERIOD * 1000;
watch_heater_next_ms[e] = millis() + WATCH_TEMP_PERIOD * 1000UL;
}
else
watch_heater_next_ms[e] = 0;
......@@ -1054,6 +1053,7 @@ void tp_init() {
void thermal_runaway_protection(TRState *state, millis_t *timer, float temperature, float target_temperature, int heater_id, int period_seconds, int hysteresis_degc) {
static float tr_target_temperature[HOTENDS + 1] = { 0.0 };
/*
ECHO_SM(DB, "Thermal Thermal Runaway Running. Heater ID: ");
if (heater_id < 0) ECHO_M("bed"); else ECHO_V(heater_id);
......@@ -1073,7 +1073,6 @@ void tp_init() {
case TRReset:
*timer = 0;
*state = TRInactive;
break;
// Inactive state waits for a target temperature to be set
case TRInactive:
if (target_temperature > 0) {
......@@ -1112,7 +1111,9 @@ void disable_all_heaters() {
}
#if HAS_TEMP_0
DISABLE_HEATER(0);
target_temperature[0] = 0;
soft_pwm[0] = 0;
WRITE_HEATER_0P(LOW); // Should HEATERS_PARALLEL apply here? Then change to DISABLE_HEATER(0)
#endif
#if HOTENDS > 1 && HAS_TEMP_1
......@@ -1396,7 +1397,6 @@ ISR(TIMER0_COMPB_vect) {
#endif
#endif
#endif
#if HAS_HEATER_BED
_SLOW_PWM_ROUTINE(BED, soft_pwm_bed); // BED
#endif
......@@ -1413,7 +1413,6 @@ ISR(TIMER0_COMPB_vect) {
#endif
#endif
#endif
#if HAS_HEATER_BED
PWM_OFF_ROUTINE(BED); // BED
#endif
......@@ -1445,7 +1444,6 @@ ISR(TIMER0_COMPB_vect) {
#endif
#endif
#endif
#if HAS_HEATER_BED
if (state_timer_heater_BED > 0) state_timer_heater_BED--;
#endif
......@@ -1569,7 +1567,7 @@ ISR(TIMER0_COMPB_vect) {
temp_state = PrepareTemp_0;
break;
//default:
// default:
// ECHO_LM(ER, MSG_TEMP_READ_ERROR);
// break;
} // switch(temp_state)
......@@ -1601,7 +1599,7 @@ ISR(TIMER0_COMPB_vect) {
if (minttemp_raw[0] GE0 current_temperature_raw[0]) min_temp_error(0);
#endif
#if HAS_TEMP_1
#if HAS_TEMP_1 && HOTENDS > 1
#if HEATER_1_RAW_LO_TEMP > HEATER_1_RAW_HI_TEMP
#define GE1 <=
#else
......@@ -1609,9 +1607,9 @@ ISR(TIMER0_COMPB_vect) {
#endif
if (current_temperature_raw[1] GE1 maxttemp_raw[1]) max_temp_error(1);
if (minttemp_raw[1] GE1 current_temperature_raw[1]) min_temp_error(1);
#endif // HAS_TEMP_1
#endif // TEMP_SENSOR_1
#if HAS_TEMP_2
#if HAS_TEMP_2 && HOTENDS > 2
#if HEATER_2_RAW_LO_TEMP > HEATER_2_RAW_HI_TEMP
#define GE2 <=
#else
......@@ -1619,9 +1617,9 @@ ISR(TIMER0_COMPB_vect) {
#endif
if (current_temperature_raw[2] GE2 maxttemp_raw[2]) max_temp_error(2);
if (minttemp_raw[2] GE2 current_temperature_raw[2]) min_temp_error(2);
#endif // HAS_TEMP_2
#endif // TEMP_SENSOR_2
#if HAS_TEMP_3
#if HAS_TEMP_3 && HOTENDS > 3
#if HEATER_3_RAW_LO_TEMP > HEATER_3_RAW_HI_TEMP
#define GE3 <=
#else
......@@ -1629,7 +1627,7 @@ ISR(TIMER0_COMPB_vect) {
#endif
if (current_temperature_raw[3] GE3 maxttemp_raw[3]) max_temp_error(3);
if (minttemp_raw[3] GE3 current_temperature_raw[3]) min_temp_error(3);
#endif // HAS_TEMP_3
#endif // TEMP_SENSOR_3
#if HAS_TEMP_BED
#if HEATER_BED_RAW_LO_TEMP > HEATER_BED_RAW_HI_TEMP
......
......@@ -146,7 +146,7 @@ int getHeaterPower(int heater);
void disable_all_heaters();
void updatePID();
void PID_autotune(float temp, int extruder, int ncycles);
void PID_autotune(float temp, int hotend, int ncycles);
void setExtruderAutoFanState(int pin, bool state);
void checkExtruderAutoFans();
......
......@@ -2,6 +2,7 @@
#define THERMISTORTABLES_H_
#include "Marlin.h"
#include "macros.h"
#define OVERSAMPLENR 16
......@@ -1123,7 +1124,7 @@ const short temptable_1047[][2] PROGMEM = {
#ifdef THERMISTORHEATER_0
# define HEATER_0_TEMPTABLE TT_NAME(THERMISTORHEATER_0)
# define HEATER_0_TEMPTABLE_LEN (sizeof(HEATER_0_TEMPTABLE)/sizeof(*HEATER_0_TEMPTABLE))
# define HEATER_0_TEMPTABLE_LEN COUNT(HEATER_0_TEMPTABLE)
#else
# ifdef HEATER_0_USES_THERMISTOR
# error No heater 0 thermistor table specified
......@@ -1146,7 +1147,7 @@ const short temptable_1047[][2] PROGMEM = {
#ifdef THERMISTORHEATER_1
# define HEATER_1_TEMPTABLE TT_NAME(THERMISTORHEATER_1)
# define HEATER_1_TEMPTABLE_LEN (sizeof(HEATER_1_TEMPTABLE)/sizeof(*HEATER_1_TEMPTABLE))
# define HEATER_1_TEMPTABLE_LEN COUNT(HEATER_1_TEMPTABLE)
#else
# ifdef HEATER_1_USES_THERMISTOR
# error No heater 1 thermistor table specified
......@@ -1169,7 +1170,7 @@ const short temptable_1047[][2] PROGMEM = {
#ifdef THERMISTORHEATER_2
# define HEATER_2_TEMPTABLE TT_NAME(THERMISTORHEATER_2)
# define HEATER_2_TEMPTABLE_LEN (sizeof(HEATER_2_TEMPTABLE)/sizeof(*HEATER_2_TEMPTABLE))
# define HEATER_2_TEMPTABLE_LEN COUNT(HEATER_2_TEMPTABLE)
#else
# ifdef HEATER_2_USES_THERMISTOR
# error No heater 2 thermistor table specified
......@@ -1192,7 +1193,7 @@ const short temptable_1047[][2] PROGMEM = {
#ifdef THERMISTORHEATER_3
# define HEATER_3_TEMPTABLE TT_NAME(THERMISTORHEATER_3)
# define HEATER_3_TEMPTABLE_LEN (sizeof(HEATER_3_TEMPTABLE)/sizeof(*HEATER_3_TEMPTABLE))
# define HEATER_3_TEMPTABLE_LEN COUNT(HEATER_3_TEMPTABLE)
#else
# ifdef HEATER_3_USES_THERMISTOR
# error No heater 3 thermistor table specified
......@@ -1215,7 +1216,7 @@ const short temptable_1047[][2] PROGMEM = {
#ifdef THERMISTORBED
# define BEDTEMPTABLE TT_NAME(THERMISTORBED)
# define BEDTEMPTABLE_LEN (sizeof(BEDTEMPTABLE)/sizeof(*BEDTEMPTABLE))
# define BEDTEMPTABLE_LEN COUNT(BEDTEMPTABLE)
#else
# ifdef BED_USES_THERMISTOR
# error No bed thermistor table specified
......
#include "ultralcd.h"
#ifdef ULTRA_LCD
#include "Marlin.h"
#include "language.h"
......@@ -350,7 +351,7 @@ static void lcd_status_screen() {
}
#endif
#ifdef ULTIPANEL
#ifdef ULTIPANEL
bool current_click = LCD_CLICKED;
......@@ -1003,21 +1004,15 @@ static void lcd_control_temperature_menu() {
#if TEMP_SENSOR_0 != 0
MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_NOZZLE " 0", &target_temperature[0], 0, HEATER_0_MAXTEMP + LCD_MAX_TEMP_OFFSET);
#endif
#if HOTENDS > 1
#if TEMP_SENSOR_1 != 0
#if HOTENDS > 1 && TEMP_SENSOR_1 != 0
MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_NOZZLE " 1", &target_temperature[1], 0, HEATER_1_MAXTEMP + LCD_MAX_TEMP_OFFSET);
#endif
#if HOTENDS > 2
#if TEMP_SENSOR_2 != 0
#if HOTENDS > 2 && TEMP_SENSOR_2 != 0
MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_NOZZLE " 2", &target_temperature[2], 0, HEATER_2_MAXTEMP + LCD_MAX_TEMP_OFFSET);
#endif
#if HOTENDS > 3
#if TEMP_SENSOR_3 != 0
#if HOTENDS > 3 && TEMP_SENSOR_3 != 0
MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_NOZZLE " 3", &target_temperature[3], 0, HEATER_3_MAXTEMP + LCD_MAX_TEMP_OFFSET);
#endif
#endif //HOTENDS > 3
#endif //HOTENDS > 2
#endif //HOTENDS > 1
#endif // HOTENDS > 3
#endif // HOTENDS > 2
#endif // HOTENDS > 1
//
// Bed
......@@ -1079,10 +1074,10 @@ static void lcd_control_temperature_menu() {
// i is typically a small value so allows values below 1
MENU_ITEM_EDIT_CALLBACK(float52, MSG_PID_I MSG_H3, &raw_Ki, 0.01, 9990, copy_and_scalePID_i_H3);
MENU_ITEM_EDIT_CALLBACK(float52, MSG_PID_D MSG_H3, &raw_Kd, 1, 9990, copy_and_scalePID_d_H3);
#endif //HOTENDS > 3
#endif //HOTENDS > 2
#endif //HOTENDS > 1
#endif //PIDTEMP
#endif // HOTENDS > 3
#endif // HOTENDS > 2
#endif // HOTENDS > 1
#endif // PIDTEMP
//
// Preheat PLA conf
......@@ -1583,6 +1578,7 @@ void lcd_init() {
#ifdef ULTIPANEL
encoderDiff = 0;
#endif
}
int lcd_strlen(char *s) {
......@@ -2258,7 +2254,564 @@ char *ftostr52(const float &x) {
pageShowInfo = 0;
lcd_goto_menu(lcd_level_bed);
}
#endif
#elif defined(NEXTION)
#include "Marlin.h"
#include "language.h"
#include "cardreader.h"
#include "temperature.h"
#include "stepper.h"
#include "configuration_store.h"
#include "NexText.h"
#include "NexHotspot.h"
#include "NexProgressBar.h"
char buffer[100] = {0};
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;
// Text
NexText Hotend0 = NexText(1, 3, "t0");
NexText Hotend1 = NexText(1, 7, "t1");
NexText Hotend2 = NexText(1, 9, "t2");
NexText Hotend3 = NexText(1, 12, "t3");
NexText Bed = NexText(1, 16, "t4");
NexText LedStatus = NexText(1, 26, "t5");
NexText LedCoord = NexText(1, 27, "t6");
NexText set0 = NexText(2, 2, "set0");
NexText set1 = NexText(2, 15, "set1");
// Progress Bar
NexProgressBar jp0 = NexProgressBar(1, 2, "jp0");
NexProgressBar jp1 = NexProgressBar(1, 5, "jp1");
NexProgressBar jp2 = NexProgressBar(1, 8, "jp2");
NexProgressBar jp3 = NexProgressBar(1, 11, "jp3");
NexProgressBar jp4 = NexProgressBar(1, 14, "jp4");
// Touch area
NexHotspot homex = NexHotspot(1, 17, "homex", homePopCallback, &homex);
NexHotspot homey = NexHotspot(1, 18, "homey", homePopCallback, &homey);
NexHotspot homez = NexHotspot(1, 19, "homez", homePopCallback, &homez);
NexHotspot home0 = NexHotspot(1, 20, "home0", homePopCallback, &home0);
NexHotspot hot0 = NexHotspot(1, 21, "hot0", hotPopCallback, &hot0);
NexHotspot hot1 = NexHotspot(1, 22, "hot1", hotPopCallback, &hot1);
NexHotspot hot2 = NexHotspot(1, 23, "hot2", hotPopCallback, &hot2);
NexHotspot hot3 = NexHotspot(1, 24, "hot3", hotPopCallback, &hot3);
NexHotspot hot4 = NexHotspot(1, 25, "hot4", hotPopCallback, &hot4);
NexHotspot m11 = NexHotspot(2, 14, "m11", sethotPopCallback, &m11);
NexHotspot tup = NexHotspot(2, 16, "tup", settempPopCallback, &tup);
NexHotspot tdown = NexHotspot(2, 17, "tdown", settempPopCallback, &tdown);
NexTouch *nexListenList[] =
{
&homex,
&homey,
&homez,
&home0,
&hot0,
&hot1,
&hot2,
&hot3,
&hot4,
&m11,
&tup,
&tdown,
NULL
};
void homePopCallback(void *ptr) {
if (ptr == &homex)
enqueuecommands_P(PSTR("G28 X"));
else if (ptr == &homey)
enqueuecommands_P(PSTR("G28 Y"));
else if (ptr == &homey)
enqueuecommands_P(PSTR("G28 Z"));
else if (ptr == &home0)
enqueuecommands_P(PSTR("G28"));
}
void hotPopCallback(void *ptr) {
NexTouch::sendCommand("page 2");
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 (ptr == &hot2) {
if (degTargetHotend(2) != 0) {
itoa(degTargetHotend(2), buffer, 10);
}
set1.setText("M104 T2 S");
}
if (ptr == &hot3) {
if (degTargetHotend(3) != 0) {
itoa(degTargetHotend(3), buffer, 10);
}
set1.setText("M104 T3 S");
}
if (ptr == &hot4) {
if (degTargetBed() != 0) {
itoa(degTargetBed(), buffer, 10);
}
set1.setText("M140 S");
}
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);
NexTouch::sendCommand("page menu");
lcd_setstatus(lcd_status_message);
}
millis_t next_lcd_update_ms;
void lcd_init() {
nexInit();
delay(SPLASH_SCREEN_DURATION); // wait to display the splash screen
NexTouch::sendCommand("page menu");
lcd_setstatus(WELCOME_MSG);
}
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;
String tempprc = String(prc);
String bar_id = "j" + String(h);
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);
jp0.setValue(prc);
break;
}
case 1:
{
Hotend1.setText(buffer);
Hotend1.setColor(color);
jp1.setValue(prc);
break;
}
case 2:
{
Hotend2.setText(buffer);
Hotend2.setColor(color);
jp2.setValue(prc);
break;
}
case 3:
{
Hotend3.setText(buffer);
Hotend3.setColor(color);
jp3.setValue(prc);
break;
}
case 4:
{
Bed.setText(buffer);
Bed.setColor(color);
jp4.setValue(prc);
break;
}
}
}
static void coordtoLCD() {
char *valuetemp;
memset(buffer, 0, sizeof(buffer));
strcat(buffer, "X");
if (axis_known_position[X_AXIS]) {
#ifdef 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]) {
#ifdef 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() {
millis_t ms = millis();
if (ms > next_lcd_update_ms) {
nexLoop(nexListenList);
for (int h = 0; h < HOTENDS; h++) temptoLCD(h, degHotend(h), degTargetHotend(h));
#if TEMP_SENSOR_BED != 0
temptoLCD(4, degBed(), degTargetBed());
#endif
coordtoLCD();
next_lcd_update_ms = ms + LCD_UPDATE_INTERVAL;
}
}
void lcd_setstatus(const char* message, bool persist) {
if (lcd_status_message_level > 0) 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) {
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
......@@ -112,6 +112,28 @@
#define LCD_CLICKED ((buttons&B_MI)||(buttons&B_ST))
#endif//NEWPANEL
#elif defined(NEXTION)
#define LCD_UPDATE_INTERVAL 1000
void homePopCallback(void *ptr);
void hotPopCallback(void *ptr);
void sethotPopCallback(void *ptr);
void settempPopCallback(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();
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() {}
......
......@@ -24,8 +24,7 @@
static void ST7920_SWSPI_SND_8BIT(uint8_t val)
{
uint8_t i;
for( i = 0; i < 8; i++ )
{
for( i = 0; i < 8; i++ ) {
WRITE(ST7920_CLK_PIN,0);
#if F_CPU == 20000000
__asm__("nop\n\t");
......
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