Merge remote-tracking branch 'upstream/Marlin_v1' into Marlin_v1
This commit is contained in:
commit
0d4a9444c4
|
@ -93,7 +93,7 @@
|
|||
#define TEMP_SENSOR_BED 0
|
||||
|
||||
// Actual temperature must be close to target for this long before M109 returns success
|
||||
#define TEMP_RESIDENCY_TIME 10 // (seconds)
|
||||
#define TEMP_RESIDENCY_TIME 10 // (seconds)
|
||||
#define TEMP_HYSTERESIS 3 // (degC) range of +/- temperatures considered "close" to the target one
|
||||
#define TEMP_WINDOW 1 // (degC) Window around target to start the recidency timer x degC early.
|
||||
|
||||
|
@ -285,7 +285,7 @@ const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th
|
|||
|
||||
// default settings
|
||||
|
||||
#define DEFAULT_AXIS_STEPS_PER_UNIT {78.7402,78.7402,200*8/3,760*1.1} // default steps per unit for ultimaker
|
||||
#define DEFAULT_AXIS_STEPS_PER_UNIT {78.7402,78.7402,200.0*8/3,760*1.1} // default steps per unit for ultimaker
|
||||
#define DEFAULT_MAX_FEEDRATE {500, 500, 5, 25} // (mm/sec)
|
||||
#define DEFAULT_MAX_ACCELERATION {9000,9000,100,10000} // X, Y, Z, E maximum start speed for accelerated moves. E default values are good for skeinforge 40+, for older versions raise them a lot.
|
||||
|
||||
|
@ -318,9 +318,18 @@ const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th
|
|||
// please keep turned on if you can.
|
||||
//#define EEPROM_CHITCHAT
|
||||
|
||||
// Preheat Constants
|
||||
#define PLA_PREHEAT_HOTEND_TEMP 180
|
||||
#define PLA_PREHEAT_HPB_TEMP 70
|
||||
#define PLA_PREHEAT_FAN_SPEED 255 // Insert Value between 0 and 255
|
||||
|
||||
#define ABS_PREHEAT_HOTEND_TEMP 240
|
||||
#define ABS_PREHEAT_HPB_TEMP 100
|
||||
#define ABS_PREHEAT_FAN_SPEED 255 // Insert Value between 0 and 255
|
||||
|
||||
//LCD and SD support
|
||||
//#define ULTRA_LCD //general lcd support, also 16x2
|
||||
//#define DOGLCD // Support for SPI LCD 128x64 (Controller ST7565R graphic Display Family)
|
||||
//#define DOGLCD // Support for SPI LCD 128x64 (Controller ST7565R graphic Display Family)
|
||||
//#define SDSUPPORT // Enable SD Card Support in Hardware Console
|
||||
//#define SDSLOW // Use slower SD transfer mode (not normally needed - uncomment if you're getting volume init error)
|
||||
|
||||
|
@ -341,6 +350,11 @@ const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th
|
|||
// ==> REMEMBER TO INSTALL U8glib to your ARDUINO library folder: http://code.google.com/p/u8glib/wiki/u8glib
|
||||
//#define REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER
|
||||
|
||||
// The RepRapWorld REPRAPWORLD_KEYPAD v1.1
|
||||
// http://reprapworld.com/?products_details&products_id=202&cPath=1591_1626
|
||||
//#define REPRAPWORLD_KEYPAD
|
||||
//#define REPRAPWORLD_KEYPAD_MOVE_STEP 10.0 // how much should be moved when a key is pressed, eg 10.0 means 10mm per click
|
||||
|
||||
//automatic expansion
|
||||
#if defined (REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER)
|
||||
#define DOGLCD
|
||||
|
@ -353,36 +367,72 @@ const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th
|
|||
#define NEWPANEL
|
||||
#endif
|
||||
|
||||
// Preheat Constants
|
||||
#define PLA_PREHEAT_HOTEND_TEMP 180
|
||||
#define PLA_PREHEAT_HPB_TEMP 70
|
||||
#define PLA_PREHEAT_FAN_SPEED 255 // Insert Value between 0 and 255
|
||||
#if defined(REPRAPWORLD_KEYPAD)
|
||||
#define NEWPANEL
|
||||
#define ULTIPANEL
|
||||
#endif
|
||||
|
||||
#define ABS_PREHEAT_HOTEND_TEMP 240
|
||||
#define ABS_PREHEAT_HPB_TEMP 100
|
||||
#define ABS_PREHEAT_FAN_SPEED 255 // Insert Value between 0 and 255
|
||||
//I2C PANELS
|
||||
|
||||
//#define LCD_I2C_SAINSMART_YWROBOT
|
||||
#ifdef LCD_I2C_SAINSMART_YWROBOT
|
||||
// This uses the LiquidCrystal_I2C library ( https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/Home )
|
||||
// Make sure it is placed in the Arduino libraries directory.
|
||||
#define LCD_I2C_TYPE_PCF8575
|
||||
#define LCD_I2C_ADDRESS 0x27 // I2C Address of the port expander
|
||||
#define NEWPANEL
|
||||
#define ULTIPANEL
|
||||
#endif
|
||||
|
||||
// PANELOLU2 LCD with status LEDs, separate encoder and click inputs
|
||||
//#define LCD_I2C_PANELOLU2
|
||||
#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
|
||||
#define NEWPANEL
|
||||
#define ULTIPANEL
|
||||
#endif
|
||||
|
||||
// Panucatt VIKI LCD with status LEDs, integrated click & L/R/U/P buttons, separate encoder inputs
|
||||
//#define LCD_I2C_VIKI
|
||||
#ifdef LCD_I2C_VIKI
|
||||
// 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.
|
||||
// Note: The pause/stop/resume LCD button pin should be connected to the Arduino
|
||||
// BTN_ENC pin (or set BTN_ENC to -1 if not used)
|
||||
#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 (requires LiquidTWI2 v1.2.3 or later)
|
||||
#define NEWPANEL
|
||||
#define ULTIPANEL
|
||||
#endif
|
||||
|
||||
#ifdef ULTIPANEL
|
||||
// #define NEWPANEL //enable this if you have a click-encoder panel
|
||||
#define SDSUPPORT
|
||||
#define ULTRA_LCD
|
||||
#ifdef DOGLCD // Change number of lines to match the DOG graphic display
|
||||
#define LCD_WIDTH 20
|
||||
#define LCD_HEIGHT 5
|
||||
#else
|
||||
#define LCD_WIDTH 20
|
||||
#define LCD_HEIGHT 4
|
||||
#endif
|
||||
#ifdef DOGLCD // Change number of lines to match the DOG graphic display
|
||||
#define LCD_WIDTH 20
|
||||
#define LCD_HEIGHT 5
|
||||
#else
|
||||
#define LCD_WIDTH 20
|
||||
#define LCD_HEIGHT 4
|
||||
#endif
|
||||
#else //no panel but just lcd
|
||||
#ifdef ULTRA_LCD
|
||||
#ifdef DOGLCD // Change number of lines to match the 128x64 graphics display
|
||||
#define LCD_WIDTH 20
|
||||
#define LCD_HEIGHT 5
|
||||
#else
|
||||
#define LCD_WIDTH 16
|
||||
#define LCD_HEIGHT 2
|
||||
#endif
|
||||
#ifdef DOGLCD // Change number of lines to match the 128x64 graphics display
|
||||
#define LCD_WIDTH 20
|
||||
#define LCD_HEIGHT 5
|
||||
#else
|
||||
#define LCD_WIDTH 16
|
||||
#define LCD_HEIGHT 2
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@ -396,6 +446,26 @@ const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th
|
|||
// SF send wrong arc g-codes when using Arc Point as fillet procedure
|
||||
//#define SF_ARC_FIX
|
||||
|
||||
// Support for the BariCUDA Paste Extruder.
|
||||
//#define BARICUDA
|
||||
|
||||
/*********************************************************************\
|
||||
*
|
||||
* R/C SERVO support
|
||||
*
|
||||
* Sponsored by TrinityLabs, Reworked by codexmas
|
||||
*
|
||||
**********************************************************************/
|
||||
|
||||
// Number of servos
|
||||
//
|
||||
// If you select a configuration below, this will receive a default value and does not need to be set manually
|
||||
// set it manually if you have more servos than extruders and wish to manually control some
|
||||
// leaving it undefined or defining as 0 will disable the servo subsystem
|
||||
// If unsure, leave commented / disabled
|
||||
//
|
||||
// #define NUM_SERVOS 3
|
||||
|
||||
#include "Configuration_adv.h"
|
||||
#include "thermistortables.h"
|
||||
|
||||
|
|
|
@ -213,7 +213,7 @@ CXXSRC = WMath.cpp WString.cpp Print.cpp Marlin_main.cpp \
|
|||
SdFile.cpp SdVolume.cpp motion_control.cpp planner.cpp \
|
||||
stepper.cpp temperature.cpp cardreader.cpp ConfigurationStore.cpp \
|
||||
watchdog.cpp
|
||||
CXXSRC += LiquidCrystal.cpp ultralcd.cpp SPI.cpp
|
||||
CXXSRC += LiquidCrystal.cpp ultralcd.cpp SPI.cpp Servo.cpp
|
||||
|
||||
#Check for Arduino 1.0.0 or higher and use the correct sourcefiles for that version
|
||||
ifeq ($(shell [ $(ARDUINO_VERSION) -ge 100 ] && echo true), true)
|
||||
|
|
|
@ -186,6 +186,10 @@ extern float add_homeing[3];
|
|||
extern float min_pos[3];
|
||||
extern float max_pos[3];
|
||||
extern int fanSpeed;
|
||||
#ifdef BARICUDA
|
||||
extern int ValvePressure;
|
||||
extern int EtoPPressure;
|
||||
#endif
|
||||
|
||||
#ifdef FWRETRACT
|
||||
extern bool autoretract_enabled;
|
||||
|
|
|
@ -34,11 +34,17 @@
|
|||
#include "pins.h"
|
||||
|
||||
#ifdef ULTRA_LCD
|
||||
#ifdef DOGLCD
|
||||
#include <U8glib.h> // library for graphics LCD by Oli Kraus (https://code.google.com/p/u8glib/)
|
||||
#else
|
||||
#include <LiquidCrystal.h> // library for character LCD
|
||||
#endif
|
||||
#if defined(LCD_I2C_TYPE_PCF8575)
|
||||
#include <Wire.h>
|
||||
#include <LiquidCrystal_I2C.h>
|
||||
#elif defined(LCD_I2C_TYPE_MCP23017) || defined(LCD_I2C_TYPE_MCP23008)
|
||||
#include <Wire.h>
|
||||
#include <LiquidTWI2.h>
|
||||
#elif defined(DOGLCD)
|
||||
#include <U8glib.h> // library for graphics LCD by Oli Kraus (https://code.google.com/p/u8glib/)
|
||||
#else
|
||||
#include <LiquidCrystal.h> // library for character LCD
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if DIGIPOTSS_PIN > -1
|
||||
|
|
|
@ -40,7 +40,11 @@
|
|||
#include "language.h"
|
||||
#include "pins_arduino.h"
|
||||
|
||||
#if DIGIPOTSS_PIN > -1
|
||||
#if NUM_SERVOS > 0
|
||||
#include "Servo.h"
|
||||
#endif
|
||||
|
||||
#if DIGIPOTSS_PIN > 0
|
||||
#include <SPI.h>
|
||||
#endif
|
||||
|
||||
|
@ -98,9 +102,13 @@
|
|||
// M85 - Set inactivity shutdown timer with parameter S<seconds>. To disable set zero (default)
|
||||
// M92 - Set axis_steps_per_unit - same syntax as G92
|
||||
// M114 - Output current position to serial port
|
||||
// M115 - Capabilities string
|
||||
// M115 - Capabilities string
|
||||
// M117 - display message
|
||||
// M119 - Output Endstop status to serial port
|
||||
// M126 - Solenoid Air Valve Open (BariCUDA support by jmil)
|
||||
// M127 - Solenoid Air Valve Closed (BariCUDA vent to atmospheric pressure by jmil)
|
||||
// M128 - EtoP Open (BariCUDA EtoP = electricity to air pressure transducer by jmil)
|
||||
// M129 - EtoP Closed (BariCUDA EtoP = electricity to air pressure transducer by jmil)
|
||||
// M140 - Set bed target temp
|
||||
// M190 - Wait for bed current temp to reach target temp.
|
||||
// M200 - Set filament diameter
|
||||
|
@ -117,6 +125,7 @@
|
|||
// M220 S<factor in percent>- set speed factor override percentage
|
||||
// M221 S<factor in percent>- set extrude factor override percentage
|
||||
// M240 - Trigger a camera to take a photograph
|
||||
// M280 - set servo position absolute. P: servo index, S: angle or microseconds
|
||||
// M300 - Play beepsound S<frequency Hz> P<duration ms>
|
||||
// M301 - Set PID parameters P I and D
|
||||
// M302 - Allow cold extrudes
|
||||
|
@ -168,6 +177,10 @@ float extruder_offset[2][EXTRUDERS] = {
|
|||
#endif
|
||||
uint8_t active_extruder = 0;
|
||||
int fanSpeed=0;
|
||||
#ifdef BARICUDA
|
||||
int ValvePressure=0;
|
||||
int EtoPPressure=0;
|
||||
#endif
|
||||
|
||||
#ifdef FWRETRACT
|
||||
bool autoretract_enabled=true;
|
||||
|
@ -217,6 +230,10 @@ static uint8_t tmp_extruder;
|
|||
|
||||
bool Stopped=false;
|
||||
|
||||
#if NUM_SERVOS > 0
|
||||
Servo servos[NUM_SERVOS];
|
||||
#endif
|
||||
|
||||
//===========================================================================
|
||||
//=============================ROUTINES=============================
|
||||
//===========================================================================
|
||||
|
@ -292,7 +309,7 @@ void setup_killpin()
|
|||
void setup_photpin()
|
||||
{
|
||||
#ifdef PHOTOGRAPH_PIN
|
||||
#if (PHOTOGRAPH_PIN > -1)
|
||||
#if (PHOTOGRAPH_PIN > 0)
|
||||
SET_OUTPUT(PHOTOGRAPH_PIN);
|
||||
WRITE(PHOTOGRAPH_PIN, LOW);
|
||||
#endif
|
||||
|
@ -302,12 +319,12 @@ void setup_photpin()
|
|||
void setup_powerhold()
|
||||
{
|
||||
#ifdef SUICIDE_PIN
|
||||
#if (SUICIDE_PIN> -1)
|
||||
#if (SUICIDE_PIN> 0)
|
||||
SET_OUTPUT(SUICIDE_PIN);
|
||||
WRITE(SUICIDE_PIN, HIGH);
|
||||
#endif
|
||||
#endif
|
||||
#if (PS_ON_PIN > -1)
|
||||
#if (PS_ON_PIN > 0)
|
||||
SET_OUTPUT(PS_ON_PIN);
|
||||
WRITE(PS_ON_PIN, PS_ON_AWAKE);
|
||||
#endif
|
||||
|
@ -316,13 +333,32 @@ void setup_powerhold()
|
|||
void suicide()
|
||||
{
|
||||
#ifdef SUICIDE_PIN
|
||||
#if (SUICIDE_PIN> -1)
|
||||
#if (SUICIDE_PIN > 0)
|
||||
SET_OUTPUT(SUICIDE_PIN);
|
||||
WRITE(SUICIDE_PIN, LOW);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void servo_init()
|
||||
{
|
||||
#if (NUM_SERVOS >= 1) && (SERVO0_PIN > 0)
|
||||
servos[0].attach(SERVO0_PIN);
|
||||
#endif
|
||||
#if (NUM_SERVOS >= 2) && (SERVO1_PIN > 0)
|
||||
servos[1].attach(SERVO1_PIN);
|
||||
#endif
|
||||
#if (NUM_SERVOS >= 3) && (SERVO2_PIN > 0)
|
||||
servos[2].attach(SERVO2_PIN);
|
||||
#endif
|
||||
#if (NUM_SERVOS >= 4) && (SERVO3_PIN > 0)
|
||||
servos[3].attach(SERVO3_PIN);
|
||||
#endif
|
||||
#if (NUM_SERVOS >= 5)
|
||||
#error "TODO: enter initalisation code for more servos"
|
||||
#endif
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
setup_killpin();
|
||||
|
@ -371,6 +407,7 @@ void setup()
|
|||
watchdog_init();
|
||||
st_init(); // Initialize stepper, this enables interrupts!
|
||||
setup_photpin();
|
||||
servo_init();
|
||||
|
||||
lcd_init();
|
||||
|
||||
|
@ -392,9 +429,9 @@ void loop()
|
|||
#ifdef SDSUPPORT
|
||||
if(card.saving)
|
||||
{
|
||||
if(strstr_P(cmdbuffer[bufindr], PSTR("M29")) == NULL)
|
||||
{
|
||||
card.write_command(cmdbuffer[bufindr]);
|
||||
if(strstr_P(cmdbuffer[bufindr], PSTR("M29")) == NULL)
|
||||
{
|
||||
card.write_command(cmdbuffer[bufindr]);
|
||||
if(card.logging)
|
||||
{
|
||||
process_commands();
|
||||
|
@ -403,16 +440,16 @@ void loop()
|
|||
{
|
||||
SERIAL_PROTOCOLLNPGM(MSG_OK);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
card.closefile();
|
||||
SERIAL_PROTOCOLLNPGM(MSG_FILE_SAVED);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
card.closefile();
|
||||
SERIAL_PROTOCOLLNPGM(MSG_FILE_SAVED);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
process_commands();
|
||||
process_commands();
|
||||
}
|
||||
#else
|
||||
process_commands();
|
||||
|
@ -507,10 +544,10 @@ void get_command()
|
|||
case 2:
|
||||
case 3:
|
||||
if(Stopped == false) { // If printer is stopped by an error the G[0-3] codes are ignored.
|
||||
#ifdef SDSUPPORT
|
||||
#ifdef SDSUPPORT
|
||||
if(card.saving)
|
||||
break;
|
||||
#endif //SDSUPPORT
|
||||
#endif //SDSUPPORT
|
||||
SERIAL_PROTOCOLLNPGM(MSG_OK);
|
||||
}
|
||||
else {
|
||||
|
@ -604,17 +641,17 @@ bool code_seen(char code)
|
|||
return (strchr_pointer != NULL); //Return True if a character was found
|
||||
}
|
||||
|
||||
#define DEFINE_PGM_READ_ANY(type, reader) \
|
||||
static inline type pgm_read_any(const type *p) \
|
||||
{ return pgm_read_##reader##_near(p); }
|
||||
#define DEFINE_PGM_READ_ANY(type, reader) \
|
||||
static inline type pgm_read_any(const type *p) \
|
||||
{ return pgm_read_##reader##_near(p); }
|
||||
|
||||
DEFINE_PGM_READ_ANY(float, float);
|
||||
DEFINE_PGM_READ_ANY(signed char, byte);
|
||||
|
||||
#define XYZ_CONSTS_FROM_CONFIG(type, array, CONFIG) \
|
||||
static const PROGMEM type array##_P[3] = \
|
||||
{ X_##CONFIG, Y_##CONFIG, Z_##CONFIG }; \
|
||||
static inline type array(int axis) \
|
||||
#define XYZ_CONSTS_FROM_CONFIG(type, array, CONFIG) \
|
||||
static const PROGMEM type array##_P[3] = \
|
||||
{ X_##CONFIG, Y_##CONFIG, Z_##CONFIG }; \
|
||||
static inline type array(int axis) \
|
||||
{ return pgm_read_any(&array##_P[axis]); }
|
||||
|
||||
XYZ_CONSTS_FROM_CONFIG(float, base_min_pos, MIN_POS);
|
||||
|
@ -632,7 +669,7 @@ static void axis_is_at_home(int axis) {
|
|||
|
||||
static void homeaxis(int axis) {
|
||||
#define HOMEAXIS_DO(LETTER) \
|
||||
((LETTER##_MIN_PIN > -1 && LETTER##_HOME_DIR==-1) || (LETTER##_MAX_PIN > -1 && LETTER##_HOME_DIR==1))
|
||||
((LETTER##_MIN_PIN > 0 && LETTER##_HOME_DIR==-1) || (LETTER##_MAX_PIN > 0 && LETTER##_HOME_DIR==1))
|
||||
|
||||
if (axis==X_AXIS ? HOMEAXIS_DO(X) :
|
||||
axis==Y_AXIS ? HOMEAXIS_DO(Y) :
|
||||
|
@ -870,13 +907,13 @@ void process_commands()
|
|||
previous_millis_cmd = millis();
|
||||
if (codenum > 0){
|
||||
codenum += millis(); // keep track of when we started waiting
|
||||
while(millis() < codenum && !LCD_CLICKED){
|
||||
while(millis() < codenum && !lcd_clicked()){
|
||||
manage_heater();
|
||||
manage_inactivity();
|
||||
lcd_update();
|
||||
}
|
||||
}else{
|
||||
while(!LCD_CLICKED){
|
||||
while(!lcd_clicked()){
|
||||
manage_heater();
|
||||
manage_inactivity();
|
||||
lcd_update();
|
||||
|
@ -946,17 +983,17 @@ void process_commands()
|
|||
//card,saving = false;
|
||||
break;
|
||||
case 30: //M30 <filename> Delete File
|
||||
if (card.cardOK){
|
||||
card.closefile();
|
||||
starpos = (strchr(strchr_pointer + 4,'*'));
|
||||
if(starpos != NULL){
|
||||
char* npos = strchr(cmdbuffer[bufindr], 'N');
|
||||
strchr_pointer = strchr(npos,' ') + 1;
|
||||
*(starpos-1) = '\0';
|
||||
}
|
||||
card.removeFile(strchr_pointer + 4);
|
||||
}
|
||||
break;
|
||||
if (card.cardOK){
|
||||
card.closefile();
|
||||
starpos = (strchr(strchr_pointer + 4,'*'));
|
||||
if(starpos != NULL){
|
||||
char* npos = strchr(cmdbuffer[bufindr], 'N');
|
||||
strchr_pointer = strchr(npos,' ') + 1;
|
||||
*(starpos-1) = '\0';
|
||||
}
|
||||
card.removeFile(strchr_pointer + 4);
|
||||
}
|
||||
break;
|
||||
case 928: //M928 - Start SD write
|
||||
starpos = (strchr(strchr_pointer + 5,'*'));
|
||||
if(starpos != NULL){
|
||||
|
@ -999,7 +1036,7 @@ void process_commands()
|
|||
break;
|
||||
}
|
||||
}
|
||||
#if FAN_PIN > -1
|
||||
#if FAN_PIN > 0
|
||||
if (pin_number == FAN_PIN)
|
||||
fanSpeed = pin_status;
|
||||
#endif
|
||||
|
@ -1025,12 +1062,12 @@ void process_commands()
|
|||
if(setTargetedHotend(105)){
|
||||
break;
|
||||
}
|
||||
#if (TEMP_0_PIN > -1)
|
||||
#if (TEMP_0_PIN > 0)
|
||||
SERIAL_PROTOCOLPGM("ok T:");
|
||||
SERIAL_PROTOCOL_F(degHotend(tmp_extruder),1);
|
||||
SERIAL_PROTOCOLPGM(" /");
|
||||
SERIAL_PROTOCOL_F(degTargetHotend(tmp_extruder),1);
|
||||
#if TEMP_BED_PIN > -1
|
||||
#if TEMP_BED_PIN > 0
|
||||
SERIAL_PROTOCOLPGM(" B:");
|
||||
SERIAL_PROTOCOL_F(degBed(),1);
|
||||
SERIAL_PROTOCOLPGM(" /");
|
||||
|
@ -1128,7 +1165,7 @@ void process_commands()
|
|||
}
|
||||
break;
|
||||
case 190: // M190 - Wait for bed heater to reach target.
|
||||
#if TEMP_BED_PIN > -1
|
||||
#if TEMP_BED_PIN > 0
|
||||
LCD_MESSAGEPGM(MSG_BED_HEATING);
|
||||
if (code_seen('S')) setTargetBed(code_value());
|
||||
codenum = millis();
|
||||
|
@ -1155,7 +1192,7 @@ void process_commands()
|
|||
#endif
|
||||
break;
|
||||
|
||||
#if FAN_PIN > -1
|
||||
#if FAN_PIN > 0
|
||||
case 106: //M106 Fan On
|
||||
if (code_seen('S')){
|
||||
fanSpeed=constrain(code_value(),0,255);
|
||||
|
@ -1168,8 +1205,39 @@ void process_commands()
|
|||
fanSpeed = 0;
|
||||
break;
|
||||
#endif //FAN_PIN
|
||||
#ifdef BARICUDA
|
||||
// PWM for HEATER_1_PIN
|
||||
#if HEATER_1_PIN > 0
|
||||
case 126: //M126 valve open
|
||||
if (code_seen('S')){
|
||||
ValvePressure=constrain(code_value(),0,255);
|
||||
}
|
||||
else {
|
||||
ValvePressure=255;
|
||||
}
|
||||
break;
|
||||
case 127: //M127 valve closed
|
||||
ValvePressure = 0;
|
||||
break;
|
||||
#endif //HEATER_1_PIN
|
||||
|
||||
#if (PS_ON_PIN > -1)
|
||||
// PWM for HEATER_2_PIN
|
||||
#if HEATER_2_PIN > 0
|
||||
case 128: //M128 valve open
|
||||
if (code_seen('S')){
|
||||
EtoPPressure=constrain(code_value(),0,255);
|
||||
}
|
||||
else {
|
||||
EtoPPressure=255;
|
||||
}
|
||||
break;
|
||||
case 129: //M129 valve closed
|
||||
EtoPPressure = 0;
|
||||
break;
|
||||
#endif //HEATER_2_PIN
|
||||
#endif
|
||||
|
||||
#if (PS_ON_PIN > 0)
|
||||
case 80: // M80 - ATX Power On
|
||||
SET_OUTPUT(PS_ON_PIN); //GND
|
||||
WRITE(PS_ON_PIN, PS_ON_AWAKE);
|
||||
|
@ -1178,14 +1246,14 @@ void process_commands()
|
|||
|
||||
case 81: // M81 - ATX Power Off
|
||||
|
||||
#if defined SUICIDE_PIN && SUICIDE_PIN > -1
|
||||
#if defined SUICIDE_PIN && SUICIDE_PIN > 0
|
||||
st_synchronize();
|
||||
suicide();
|
||||
#elif (PS_ON_PIN > -1)
|
||||
#elif (PS_ON_PIN > 0)
|
||||
SET_OUTPUT(PS_ON_PIN);
|
||||
WRITE(PS_ON_PIN, PS_ON_ASLEEP);
|
||||
#endif
|
||||
break;
|
||||
break;
|
||||
|
||||
case 82:
|
||||
axis_relative_modes[3] = false;
|
||||
|
@ -1286,27 +1354,27 @@ void process_commands()
|
|||
break;
|
||||
case 119: // M119
|
||||
SERIAL_PROTOCOLLN(MSG_M119_REPORT);
|
||||
#if (X_MIN_PIN > -1)
|
||||
#if (X_MIN_PIN > 0)
|
||||
SERIAL_PROTOCOLPGM(MSG_X_MIN);
|
||||
SERIAL_PROTOCOLLN(((READ(X_MIN_PIN)^X_ENDSTOPS_INVERTING)?MSG_ENDSTOP_HIT:MSG_ENDSTOP_OPEN));
|
||||
#endif
|
||||
#if (X_MAX_PIN > -1)
|
||||
#if (X_MAX_PIN > 0)
|
||||
SERIAL_PROTOCOLPGM(MSG_X_MAX);
|
||||
SERIAL_PROTOCOLLN(((READ(X_MAX_PIN)^X_ENDSTOPS_INVERTING)?MSG_ENDSTOP_HIT:MSG_ENDSTOP_OPEN));
|
||||
#endif
|
||||
#if (Y_MIN_PIN > -1)
|
||||
#if (Y_MIN_PIN > 0)
|
||||
SERIAL_PROTOCOLPGM(MSG_Y_MIN);
|
||||
SERIAL_PROTOCOLLN(((READ(Y_MIN_PIN)^Y_ENDSTOPS_INVERTING)?MSG_ENDSTOP_HIT:MSG_ENDSTOP_OPEN));
|
||||
#endif
|
||||
#if (Y_MAX_PIN > -1)
|
||||
#if (Y_MAX_PIN > 0)
|
||||
SERIAL_PROTOCOLPGM(MSG_Y_MAX);
|
||||
SERIAL_PROTOCOLLN(((READ(Y_MAX_PIN)^Y_ENDSTOPS_INVERTING)?MSG_ENDSTOP_HIT:MSG_ENDSTOP_OPEN));
|
||||
#endif
|
||||
#if (Z_MIN_PIN > -1)
|
||||
#if (Z_MIN_PIN > 0)
|
||||
SERIAL_PROTOCOLPGM(MSG_Z_MIN);
|
||||
SERIAL_PROTOCOLLN(((READ(Z_MIN_PIN)^Z_ENDSTOPS_INVERTING)?MSG_ENDSTOP_HIT:MSG_ENDSTOP_OPEN));
|
||||
#endif
|
||||
#if (Z_MAX_PIN > -1)
|
||||
#if (Z_MAX_PIN > 0)
|
||||
SERIAL_PROTOCOLPGM(MSG_Z_MAX);
|
||||
SERIAL_PROTOCOLLN(((READ(Z_MAX_PIN)^Z_ENDSTOPS_INVERTING)?MSG_ENDSTOP_HIT:MSG_ENDSTOP_OPEN));
|
||||
#endif
|
||||
|
@ -1321,7 +1389,7 @@ void process_commands()
|
|||
}
|
||||
}
|
||||
// steps per sq second need to be updated to agree with the units per sq second (as they are what is used in the planner)
|
||||
reset_acceleration_rates();
|
||||
reset_acceleration_rates();
|
||||
break;
|
||||
#if 0 // Not used for Sprinter/grbl gen6
|
||||
case 202: // M202
|
||||
|
@ -1446,16 +1514,51 @@ void process_commands()
|
|||
}
|
||||
break;
|
||||
|
||||
#if defined(LARGE_FLASH) && LARGE_FLASH == true && defined(BEEPER) && BEEPER > -1
|
||||
#if NUM_SERVOS > 0
|
||||
case 280: // M280 - set servo position absolute. P: servo index, S: angle or microseconds
|
||||
{
|
||||
int servo_index = -1;
|
||||
int servo_position = 0;
|
||||
if (code_seen('P'))
|
||||
servo_index = code_value();
|
||||
if (code_seen('S')) {
|
||||
servo_position = code_value();
|
||||
if ((servo_index >= 0) && (servo_index < NUM_SERVOS)) {
|
||||
servos[servo_index].write(servo_position);
|
||||
}
|
||||
else {
|
||||
SERIAL_ECHO_START;
|
||||
SERIAL_ECHO("Servo ");
|
||||
SERIAL_ECHO(servo_index);
|
||||
SERIAL_ECHOLN(" out of range");
|
||||
}
|
||||
}
|
||||
else if (servo_index >= 0) {
|
||||
SERIAL_PROTOCOL(MSG_OK);
|
||||
SERIAL_PROTOCOL(" Servo ");
|
||||
SERIAL_PROTOCOL(servo_index);
|
||||
SERIAL_PROTOCOL(": ");
|
||||
SERIAL_PROTOCOL(servos[servo_index].read());
|
||||
SERIAL_PROTOCOLLN("");
|
||||
}
|
||||
}
|
||||
break;
|
||||
#endif // NUM_SERVOS > 0
|
||||
|
||||
#if LARGE_FLASH == true && ( BEEPER > 0 || defined(ULTRALCD) )
|
||||
case 300: // M300
|
||||
{
|
||||
int beepS = 1;
|
||||
int beepS = 400;
|
||||
int beepP = 1000;
|
||||
if(code_seen('S')) beepS = code_value();
|
||||
if(code_seen('P')) beepP = code_value();
|
||||
tone(BEEPER, beepS);
|
||||
delay(beepP);
|
||||
noTone(BEEPER);
|
||||
#if BEEPER > 0
|
||||
tone(BEEPER, beepS);
|
||||
delay(beepP);
|
||||
noTone(BEEPER);
|
||||
#elif defined(ULTRALCD)
|
||||
lcd_buzz(beepS, beepP);
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
#endif // M300
|
||||
|
@ -1473,7 +1576,7 @@ void process_commands()
|
|||
|
||||
updatePID();
|
||||
SERIAL_PROTOCOL(MSG_OK);
|
||||
SERIAL_PROTOCOL(" p:");
|
||||
SERIAL_PROTOCOL(" p:");
|
||||
SERIAL_PROTOCOL(Kp);
|
||||
SERIAL_PROTOCOL(" i:");
|
||||
SERIAL_PROTOCOL(unscalePID_i(Ki));
|
||||
|
@ -1497,7 +1600,7 @@ void process_commands()
|
|||
|
||||
updatePID();
|
||||
SERIAL_PROTOCOL(MSG_OK);
|
||||
SERIAL_PROTOCOL(" p:");
|
||||
SERIAL_PROTOCOL(" p:");
|
||||
SERIAL_PROTOCOL(bedKp);
|
||||
SERIAL_PROTOCOL(" i:");
|
||||
SERIAL_PROTOCOL(unscalePID_i(bedKi));
|
||||
|
@ -1510,7 +1613,7 @@ void process_commands()
|
|||
case 240: // M240 Triggers a camera by emulating a Canon RC-1 : http://www.doc-diy.net/photo/rc-1_hacked/
|
||||
{
|
||||
#ifdef PHOTOGRAPH_PIN
|
||||
#if (PHOTOGRAPH_PIN > -1)
|
||||
#if (PHOTOGRAPH_PIN > 0)
|
||||
const uint8_t NUM_PULSES=16;
|
||||
const float PULSE_LENGTH=0.01524;
|
||||
for(int i=0; i < NUM_PULSES; i++) {
|
||||
|
@ -1542,8 +1645,8 @@ void process_commands()
|
|||
int e=0;
|
||||
int c=5;
|
||||
if (code_seen('E')) e=code_value();
|
||||
if (e<0)
|
||||
temp=70;
|
||||
if (e<0)
|
||||
temp=70;
|
||||
if (code_seen('S')) temp=code_value();
|
||||
if (code_seen('C')) c=code_value();
|
||||
PID_autotune(temp, e, c);
|
||||
|
@ -1666,23 +1769,24 @@ void process_commands()
|
|||
delay(100);
|
||||
LCD_ALERTMESSAGEPGM(MSG_FILAMENTCHANGE);
|
||||
uint8_t cnt=0;
|
||||
while(!LCD_CLICKED){
|
||||
while(!lcd_clicked()){
|
||||
cnt++;
|
||||
manage_heater();
|
||||
manage_inactivity();
|
||||
lcd_update();
|
||||
|
||||
#if BEEPER > -1
|
||||
if(cnt==0)
|
||||
{
|
||||
#if BEEPER > 0
|
||||
SET_OUTPUT(BEEPER);
|
||||
|
||||
WRITE(BEEPER,HIGH);
|
||||
delay(3);
|
||||
WRITE(BEEPER,LOW);
|
||||
delay(3);
|
||||
}
|
||||
#else
|
||||
lcd_buzz(1000/6,100);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
//return to normal
|
||||
|
@ -1707,15 +1811,16 @@ void process_commands()
|
|||
#endif //FILAMENTCHANGEENABLE
|
||||
case 907: // M907 Set digital trimpot motor current using axis codes.
|
||||
{
|
||||
#if DIGIPOTSS_PIN > -1
|
||||
for(int i=0;i<=NUM_AXIS;i++) if(code_seen(axis_codes[i])) digipot_current(i,code_value());
|
||||
#if DIGIPOTSS_PIN > 0
|
||||
for(int i=0;i<NUM_AXIS;i++) if(code_seen(axis_codes[i])) digipot_current(i,code_value());
|
||||
if(code_seen('B')) digipot_current(4,code_value());
|
||||
if(code_seen('S')) for(int i=0;i<=4;i++) digipot_current(i,code_value());
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
case 908: // M908 Control digital trimpot directly.
|
||||
{
|
||||
#if DIGIPOTSS_PIN > -1
|
||||
#if DIGIPOTSS_PIN > 0
|
||||
uint8_t channel,current;
|
||||
if(code_seen('P')) channel=code_value();
|
||||
if(code_seen('S')) current=code_value();
|
||||
|
@ -1725,9 +1830,9 @@ void process_commands()
|
|||
break;
|
||||
case 350: // M350 Set microstepping mode. Warning: Steps per unit remains unchanged. S code sets stepping mode for all drivers.
|
||||
{
|
||||
#if X_MS1_PIN > -1
|
||||
#if X_MS1_PIN > 0
|
||||
if(code_seen('S')) for(int i=0;i<=4;i++) microstep_mode(i,code_value());
|
||||
for(int i=0;i<=NUM_AXIS;i++) if(code_seen(axis_codes[i])) microstep_mode(i,(uint8_t)code_value());
|
||||
for(int i=0;i<NUM_AXIS;i++) if(code_seen(axis_codes[i])) microstep_mode(i,(uint8_t)code_value());
|
||||
if(code_seen('B')) microstep_mode(4,code_value());
|
||||
microstep_readings();
|
||||
#endif
|
||||
|
@ -1735,15 +1840,15 @@ void process_commands()
|
|||
break;
|
||||
case 351: // M351 Toggle MS1 MS2 pins directly, S# determines MS1 or MS2, X# sets the pin high/low.
|
||||
{
|
||||
#if X_MS1_PIN > -1
|
||||
#if X_MS1_PIN > 0
|
||||
if(code_seen('S')) switch((int)code_value())
|
||||
{
|
||||
case 1:
|
||||
for(int i=0;i<=NUM_AXIS;i++) if(code_seen(axis_codes[i])) microstep_ms(i,code_value(),-1);
|
||||
for(int i=0;i<NUM_AXIS;i++) if(code_seen(axis_codes[i])) microstep_ms(i,code_value(),-1);
|
||||
if(code_seen('B')) microstep_ms(4,code_value(),-1);
|
||||
break;
|
||||
case 2:
|
||||
for(int i=0;i<=NUM_AXIS;i++) if(code_seen(axis_codes[i])) microstep_ms(i,-1,code_value());
|
||||
for(int i=0;i<NUM_AXIS;i++) if(code_seen(axis_codes[i])) microstep_ms(i,-1,code_value());
|
||||
if(code_seen('B')) microstep_ms(4,-1,code_value());
|
||||
break;
|
||||
}
|
||||
|
@ -1979,7 +2084,7 @@ void controllerFan()
|
|||
|| !READ(E2_ENABLE_PIN)
|
||||
#endif
|
||||
#if EXTRUDER > 1
|
||||
|| !READ(E2_ENABLE_PIN)
|
||||
|| !READ(E1_ENABLE_PIN)
|
||||
#endif
|
||||
|| !READ(E0_ENABLE_PIN)) //If any of the drivers are enabled...
|
||||
{
|
||||
|
@ -2060,7 +2165,7 @@ void kill()
|
|||
disable_e1();
|
||||
disable_e2();
|
||||
|
||||
if(PS_ON_PIN > -1) pinMode(PS_ON_PIN,INPUT);
|
||||
if(PS_ON_PIN > 0) pinMode(PS_ON_PIN,INPUT);
|
||||
SERIAL_ERROR_START;
|
||||
SERIAL_ERRORLNPGM(MSG_ERR_KILLED);
|
||||
LCD_ALERTMESSAGEPGM(MSG_KILLED);
|
||||
|
|
339
Marlin/Servo.cpp
Normal file
339
Marlin/Servo.cpp
Normal file
|
@ -0,0 +1,339 @@
|
|||
/*
|
||||
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
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
A servo is activated by creating an instance of the Servo class passing the desired pin to the attach() method.
|
||||
The servos are pulsed in the background using the value most recently written using the write() method
|
||||
|
||||
Note that analogWrite of PWM on pins associated with the timer are disabled when the first servo is attached.
|
||||
Timers are seized as needed in groups of 12 servos - 24 servos use two timers, 48 servos will use four.
|
||||
|
||||
The methods are:
|
||||
|
||||
Servo - Class for manipulating servo motors connected to Arduino pins.
|
||||
|
||||
attach(pin ) - Attaches a servo motor to an i/o pin.
|
||||
attach(pin, min, max ) - Attaches to a pin setting min and max values in microseconds
|
||||
default min is 544, max is 2400
|
||||
|
||||
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
|
||||
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.
|
||||
|
||||
*/
|
||||
#ifdef NUM_SERVOS
|
||||
#include <avr/interrupt.h>
|
||||
#include <Arduino.h>
|
||||
|
||||
#include "Servo.h"
|
||||
|
||||
#define usToTicks(_us) (( clockCyclesPerMicrosecond()* _us) / 8) // converts microseconds to tick (assumes prescale of 8) // 12 Aug 2009
|
||||
#define ticksToUs(_ticks) (( (unsigned)_ticks * 8)/ clockCyclesPerMicrosecond() ) // converts from ticks back to microseconds
|
||||
|
||||
|
||||
#define TRIM_DURATION 2 // compensation ticks to trim adjust for digitalWrite delays // 12 August 2009
|
||||
|
||||
//#define NBR_TIMERS (MAX_SERVOS / SERVOS_PER_TIMER)
|
||||
|
||||
static servo_t servos[MAX_SERVOS]; // static array of servo 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
|
||||
|
||||
|
||||
// convenience macros
|
||||
#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_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
|
||||
|
||||
/************ static functions common to all instances ***********************/
|
||||
|
||||
static inline void handle_interrupts(timer16_Sequence_t timer, volatile uint16_t *TCNTn, volatile uint16_t* OCRnA)
|
||||
{
|
||||
if( Channel[timer] < 0 )
|
||||
*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 == true )
|
||||
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 == true) // check if activated
|
||||
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
|
||||
if( ((unsigned)*TCNTn) + 4 < usToTicks(REFRESH_INTERVAL) ) // allow a few ticks to ensure the next OCR1A not missed
|
||||
*OCRnA = (unsigned int)usToTicks(REFRESH_INTERVAL);
|
||||
else
|
||||
*OCRnA = *TCNTn + 4; // at least REFRESH_INTERVAL has elapsed
|
||||
Channel[timer] = -1; // this will get incremented at the end of the refresh period to start again at the first channel
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef WIRING // Wiring pre-defines signal handlers so don't define any if compiling for the Wiring platform
|
||||
// Interrupt handlers for Arduino
|
||||
#if defined(_useTimer1)
|
||||
SIGNAL (TIMER1_COMPA_vect)
|
||||
{
|
||||
handle_interrupts(_timer1, &TCNT1, &OCR1A);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(_useTimer3)
|
||||
SIGNAL (TIMER3_COMPA_vect)
|
||||
{
|
||||
handle_interrupts(_timer3, &TCNT3, &OCR3A);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(_useTimer4)
|
||||
SIGNAL (TIMER4_COMPA_vect)
|
||||
{
|
||||
handle_interrupts(_timer4, &TCNT4, &OCR4A);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(_useTimer5)
|
||||
SIGNAL (TIMER5_COMPA_vect)
|
||||
{
|
||||
handle_interrupts(_timer5, &TCNT5, &OCR5A);
|
||||
}
|
||||
#endif
|
||||
|
||||
#elif defined WIRING
|
||||
// Interrupt handlers for Wiring
|
||||
#if defined(_useTimer1)
|
||||
void Timer1Service()
|
||||
{
|
||||
handle_interrupts(_timer1, &TCNT1, &OCR1A);
|
||||
}
|
||||
#endif
|
||||
#if defined(_useTimer3)
|
||||
void Timer3Service()
|
||||
{
|
||||
handle_interrupts(_timer3, &TCNT3, &OCR3A);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
static void initISR(timer16_Sequence_t timer)
|
||||
{
|
||||
#if defined (_useTimer1)
|
||||
if(timer == _timer1) {
|
||||
TCCR1A = 0; // normal counting mode
|
||||
TCCR1B = _BV(CS11); // set prescaler of 8
|
||||
TCNT1 = 0; // clear the timer count
|
||||
#if defined(__AVR_ATmega8__)|| defined(__AVR_ATmega128__)
|
||||
TIFR |= _BV(OCF1A); // clear any pending interrupts;
|
||||
TIMSK |= _BV(OCIE1A) ; // enable the output compare interrupt
|
||||
#else
|
||||
// here if not ATmega8 or ATmega128
|
||||
TIFR1 |= _BV(OCF1A); // clear any pending interrupts;
|
||||
TIMSK1 |= _BV(OCIE1A) ; // enable the output compare interrupt
|
||||
#endif
|
||||
#if defined(WIRING)
|
||||
timerAttach(TIMER1OUTCOMPAREA_INT, Timer1Service);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined (_useTimer3)
|
||||
if(timer == _timer3) {
|
||||
TCCR3A = 0; // normal counting mode
|
||||
TCCR3B = _BV(CS31); // set prescaler of 8
|
||||
TCNT3 = 0; // clear the timer count
|
||||
#if defined(__AVR_ATmega128__)
|
||||
TIFR |= _BV(OCF3A); // clear any pending interrupts;
|
||||
ETIMSK |= _BV(OCIE3A); // enable the output compare interrupt
|
||||
#else
|
||||
TIFR3 = _BV(OCF3A); // clear any pending interrupts;
|
||||
TIMSK3 = _BV(OCIE3A) ; // enable the output compare interrupt
|
||||
#endif
|
||||
#if defined(WIRING)
|
||||
timerAttach(TIMER3OUTCOMPAREA_INT, Timer3Service); // for Wiring platform only
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined (_useTimer4)
|
||||
if(timer == _timer4) {
|
||||
TCCR4A = 0; // normal counting mode
|
||||
TCCR4B = _BV(CS41); // set prescaler of 8
|
||||
TCNT4 = 0; // clear the timer count
|
||||
TIFR4 = _BV(OCF4A); // clear any pending interrupts;
|
||||
TIMSK4 = _BV(OCIE4A) ; // enable the output compare interrupt
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined (_useTimer5)
|
||||
if(timer == _timer5) {
|
||||
TCCR5A = 0; // normal counting mode
|
||||
TCCR5B = _BV(CS51); // set prescaler of 8
|
||||
TCNT5 = 0; // clear the timer count
|
||||
TIFR5 = _BV(OCF5A); // clear any pending interrupts;
|
||||
TIMSK5 = _BV(OCIE5A) ; // enable the output compare interrupt
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static void finISR(timer16_Sequence_t timer)
|
||||
{
|
||||
//disable use of the given timer
|
||||
#if defined WIRING // Wiring
|
||||
if(timer == _timer1) {
|
||||
#if defined(__AVR_ATmega1281__)||defined(__AVR_ATmega2561__)
|
||||
TIMSK1 &= ~_BV(OCIE1A) ; // disable timer 1 output compare interrupt
|
||||
#else
|
||||
TIMSK &= ~_BV(OCIE1A) ; // disable timer 1 output compare interrupt
|
||||
#endif
|
||||
timerDetach(TIMER1OUTCOMPAREA_INT);
|
||||
}
|
||||
else if(timer == _timer3) {
|
||||
#if defined(__AVR_ATmega1281__)||defined(__AVR_ATmega2561__)
|
||||
TIMSK3 &= ~_BV(OCIE3A); // disable the timer3 output compare A interrupt
|
||||
#else
|
||||
ETIMSK &= ~_BV(OCIE3A); // disable the timer3 output compare A interrupt
|
||||
#endif
|
||||
timerDetach(TIMER3OUTCOMPAREA_INT);
|
||||
}
|
||||
#else
|
||||
//For arduino - in future: call here to a currently undefined function to reset the timer
|
||||
#endif
|
||||
}
|
||||
|
||||
static boolean isTimerActive(timer16_Sequence_t timer)
|
||||
{
|
||||
// returns true if any servo is active on this timer
|
||||
for(uint8_t channel=0; channel < SERVOS_PER_TIMER; channel++) {
|
||||
if(SERVO(timer,channel).Pin.isActive == true)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/****************** end of static functions ******************************/
|
||||
|
||||
Servo::Servo()
|
||||
{
|
||||
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
|
||||
}
|
||||
else
|
||||
this->servoIndex = INVALID_SERVO ; // too many servos
|
||||
}
|
||||
|
||||
uint8_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 ) {
|
||||
pinMode( pin, OUTPUT) ; // set servo pin to output
|
||||
servos[this->servoIndex].Pin.nbr = pin;
|
||||
// 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) == false)
|
||||
initISR(timer);
|
||||
servos[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;
|
||||
timer16_Sequence_t timer = SERVO_INDEX_TO_TIMER(servoIndex);
|
||||
if(isTimerActive(timer) == false) {
|
||||
finISR(timer);
|
||||
}
|
||||
}
|
||||
|
||||
void Servo::write(int value)
|
||||
{
|
||||
if(value < MIN_PULSE_WIDTH)
|
||||
{ // treat values less than 544 as angles in degrees (valid values in microseconds are handled as microseconds)
|
||||
if(value < 0) value = 0;
|
||||
if(value > 180) value = 180;
|
||||
value = map(value, 0, 180, SERVO_MIN(), SERVO_MAX());
|
||||
}
|
||||
this->writeMicroseconds(value);
|
||||
}
|
||||
|
||||
void Servo::writeMicroseconds(int value)
|
||||
{
|
||||
// calculate and store the values for the given channel
|
||||
byte channel = this->servoIndex;
|
||||
if( (channel < MAX_SERVOS) ) // ensure channel is valid
|
||||
{
|
||||
if( value < SERVO_MIN() ) // ensure pulse width is valid
|
||||
value = SERVO_MIN();
|
||||
else if( value > SERVO_MAX() )
|
||||
value = SERVO_MAX();
|
||||
|
||||
value = value - TRIM_DURATION;
|
||||
value = usToTicks(value); // convert to ticks after compensating for interrupt overhead - 12 Aug 2009
|
||||
|
||||
uint8_t oldSREG = SREG;
|
||||
cli();
|
||||
servos[channel].ticks = value;
|
||||
SREG = oldSREG;
|
||||
}
|
||||
}
|
||||
|
||||
int Servo::read() // return the value as degrees
|
||||
{
|
||||
return map( this->readMicroseconds()+1, SERVO_MIN(), SERVO_MAX(), 0, 180);
|
||||
}
|
||||
|
||||
int Servo::readMicroseconds()
|
||||
{
|
||||
unsigned int pulsewidth;
|
||||
if( this->servoIndex != INVALID_SERVO )
|
||||
pulsewidth = ticksToUs(servos[this->servoIndex].ticks) + TRIM_DURATION ; // 12 aug 2009
|
||||
else
|
||||
pulsewidth = 0;
|
||||
|
||||
return pulsewidth;
|
||||
}
|
||||
|
||||
bool Servo::attached()
|
||||
{
|
||||
return servos[this->servoIndex].Pin.isActive ;
|
||||
}
|
||||
|
||||
#endif
|
132
Marlin/Servo.h
Normal file
132
Marlin/Servo.h
Normal file
|
@ -0,0 +1,132 @@
|
|||
/*
|
||||
Servo.h - 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
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
A servo is activated by creating an instance of the Servo class passing the desired pin to the attach() method.
|
||||
The servos are pulsed in the background using the value most recently written using the write() method
|
||||
|
||||
Note that analogWrite of PWM on pins associated with the timer are disabled when the first servo is attached.
|
||||
Timers are seized as needed in groups of 12 servos - 24 servos use two timers, 48 servos will use four.
|
||||
The sequence used to sieze timers is defined in timers.h
|
||||
|
||||
The methods are:
|
||||
|
||||
Servo - Class for manipulating servo motors connected to Arduino pins.
|
||||
|
||||
attach(pin ) - Attaches a servo motor to an i/o pin.
|
||||
attach(pin, min, max ) - Attaches to a pin setting min and max values in microseconds
|
||||
default min is 544, max is 2400
|
||||
|
||||
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
|
||||
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.
|
||||
*/
|
||||
|
||||
#ifndef Servo_h
|
||||
#define Servo_h
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
/*
|
||||
* Defines for 16 bit timers used with Servo library
|
||||
*
|
||||
* If _useTimerX is defined then TimerX is a 16 bit timer on the curent board
|
||||
* timer16_Sequence_t enumerates the sequence that the timers should be allocated
|
||||
* _Nbr_16timers indicates how many 16 bit timers are available.
|
||||
*
|
||||
*/
|
||||
|
||||
// Say which 16 bit timers can be used and in what order
|
||||
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
|
||||
#define _useTimer5
|
||||
//#define _useTimer1
|
||||
#define _useTimer3
|
||||
#define _useTimer4
|
||||
//typedef enum { _timer5, _timer1, _timer3, _timer4, _Nbr_16timers } timer16_Sequence_t ;
|
||||
typedef enum { _timer5, _timer3, _timer4, _Nbr_16timers } timer16_Sequence_t ;
|
||||
|
||||
#elif defined(__AVR_ATmega32U4__)
|
||||
//#define _useTimer1
|
||||
#define _useTimer3
|
||||
//typedef enum { _timer1, _Nbr_16timers } timer16_Sequence_t ;
|
||||
typedef enum { _timer3, _Nbr_16timers } timer16_Sequence_t ;
|
||||
|
||||
#elif defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__)
|
||||
#define _useTimer3
|
||||
//#define _useTimer1
|
||||
//typedef enum { _timer3, _timer1, _Nbr_16timers } timer16_Sequence_t ;
|
||||
typedef enum { _timer3, _Nbr_16timers } timer16_Sequence_t ;
|
||||
|
||||
#elif defined(__AVR_ATmega128__) ||defined(__AVR_ATmega1281__)||defined(__AVR_ATmega2561__)
|
||||
#define _useTimer3
|
||||
//#define _useTimer1
|
||||
//typedef enum { _timer3, _timer1, _Nbr_16timers } timer16_Sequence_t ;
|
||||
typedef enum { _timer3, _Nbr_16timers } timer16_Sequence_t ;
|
||||
|
||||
#else // everything else
|
||||
//#define _useTimer1
|
||||
//typedef enum { _timer1, _Nbr_16timers } timer16_Sequence_t ;
|
||||
typedef enum { _Nbr_16timers } timer16_Sequence_t ;
|
||||
#endif
|
||||
|
||||
#define Servo_VERSION 2 // software version of this library
|
||||
|
||||
#define MIN_PULSE_WIDTH 544 // the shortest pulse sent to a servo
|
||||
#define MAX_PULSE_WIDTH 2400 // the longest pulse sent to a servo
|
||||
#define DEFAULT_PULSE_WIDTH 1500 // default pulse width when servo is attached
|
||||
#define REFRESH_INTERVAL 20000 // minumim time to refresh servos in microseconds
|
||||
|
||||
#define SERVOS_PER_TIMER 12 // the maximum number of servos controlled by one timer
|
||||
#define MAX_SERVOS (_Nbr_16timers * SERVOS_PER_TIMER)
|
||||
|
||||
#define INVALID_SERVO 255 // flag indicating an invalid servo index
|
||||
|
||||
typedef struct {
|
||||
uint8_t nbr :6 ; // a pin number from 0 to 63
|
||||
uint8_t isActive :1 ; // true if this channel is enabled, pin not pulsed if false
|
||||
} ServoPin_t ;
|
||||
|
||||
typedef struct {
|
||||
ServoPin_t Pin;
|
||||
unsigned int ticks;
|
||||
} servo_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.
|
||||
void detach();
|
||||
void write(int value); // if value is < 200 its treated as an angle, otherwise as pulse width in microseconds
|
||||
void writeMicroseconds(int value); // Write pulse width in microseconds
|
||||
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
|
||||
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
|
||||
int8_t max; // maximum is this value times 4 added to MAX_PULSE_WIDTH
|
||||
};
|
||||
|
||||
#endif
|
263
Marlin/pins.h
263
Marlin/pins.h
|
@ -14,7 +14,7 @@
|
|||
#define DIGIPOTSS_PIN -1
|
||||
|
||||
#if MOTHERBOARD == 99
|
||||
#define KNOWN_BOARD 1
|
||||
#define KNOWN_BOARD 1
|
||||
|
||||
#define X_STEP_PIN 2
|
||||
#define X_DIR_PIN 3
|
||||
|
@ -228,7 +228,7 @@
|
|||
|
||||
//x axis pins
|
||||
#define X_STEP_PIN 21 //different from stanard GEN7
|
||||
#define X_DIR_PIN 20 //different from stanard GEN7
|
||||
#define X_DIR_PIN 20 //different from stanard GEN7
|
||||
#define X_ENABLE_PIN 24
|
||||
#define X_STOP_PIN 0
|
||||
|
||||
|
@ -274,11 +274,11 @@
|
|||
//#define RX_ENABLE_PIN 13
|
||||
|
||||
#define BEEPER -1
|
||||
#define SDCARDDETECT -1
|
||||
#define SUICIDE_PIN -1 //has to be defined; otherwise Power_off doesn't work
|
||||
#define SDCARDDETECT -1
|
||||
#define SUICIDE_PIN -1 //has to be defined; otherwise Power_off doesn't work
|
||||
|
||||
#define KILL_PIN -1
|
||||
//Pins for 4bit LCD Support
|
||||
//Pins for 4bit LCD Support
|
||||
#define LCD_PINS_RS 18
|
||||
#define LCD_PINS_ENABLE 17
|
||||
#define LCD_PINS_D4 16
|
||||
|
@ -291,14 +291,6 @@
|
|||
#define BTN_EN2 10
|
||||
#define BTN_ENC 12 //the click
|
||||
|
||||
#define BLEN_C 2
|
||||
#define BLEN_B 1
|
||||
#define BLEN_A 0
|
||||
|
||||
#define encrot0 0
|
||||
#define encrot1 2
|
||||
#define encrot2 3
|
||||
#define encrot3 1
|
||||
#endif
|
||||
|
||||
/****************************************************************************************
|
||||
|
@ -383,19 +375,14 @@
|
|||
#define HEATER_BED_PIN 8 // BED
|
||||
#define TEMP_BED_PIN 14 // ANALOG NUMBERING
|
||||
|
||||
#define SERVO0_PIN 11
|
||||
#define SERVO1_PIN 6
|
||||
#define SERVO2_PIN 5
|
||||
#define SERVO3_PIN 4
|
||||
|
||||
#ifdef ULTRA_LCD
|
||||
|
||||
#ifdef NEWPANEL
|
||||
//encoder rotation values
|
||||
#define encrot0 0
|
||||
#define encrot1 2
|
||||
#define encrot2 3
|
||||
#define encrot3 1
|
||||
|
||||
#define BLEN_A 0
|
||||
#define BLEN_B 1
|
||||
#define BLEN_C 2
|
||||
|
||||
#define LCD_PINS_RS 16
|
||||
#define LCD_PINS_ENABLE 17
|
||||
#define LCD_PINS_D4 23
|
||||
|
@ -413,12 +400,21 @@
|
|||
#define SDCARDDETECT 49
|
||||
#else
|
||||
//arduino pin which triggers an piezzo beeper
|
||||
#define BEEPER 33 // Beeper on AUX-4
|
||||
#define BEEPER 33 // Beeper on AUX-4
|
||||
|
||||
//buttons are directly attached using AUX-2
|
||||
#define BTN_EN1 37
|
||||
#define BTN_EN2 35
|
||||
#define BTN_ENC 31 //the click
|
||||
#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
|
||||
#else
|
||||
#define BTN_EN1 37
|
||||
#define BTN_EN2 35
|
||||
#define BTN_ENC 31 //the click
|
||||
#endif
|
||||
|
||||
#ifdef G3D_PANEL
|
||||
#define SDCARDDETECT 49
|
||||
|
@ -429,10 +425,10 @@
|
|||
|
||||
#else //old style panel with shift register
|
||||
//arduino pin witch triggers an piezzo beeper
|
||||
#define BEEPER 33 No Beeper added
|
||||
#define BEEPER 33 // No Beeper added
|
||||
|
||||
//buttons are attached to a shift register
|
||||
// Not wired this yet
|
||||
// Not wired this yet
|
||||
//#define SHIFT_CLK 38
|
||||
//#define SHIFT_LD 42
|
||||
//#define SHIFT_OUT 40
|
||||
|
@ -444,25 +440,6 @@
|
|||
#define LCD_PINS_D5 25
|
||||
#define LCD_PINS_D6 27
|
||||
#define LCD_PINS_D7 29
|
||||
|
||||
//encoder rotation values
|
||||
#define encrot0 0
|
||||
#define encrot1 2
|
||||
#define encrot2 3
|
||||
#define encrot3 1
|
||||
|
||||
|
||||
//bits in the shift register that carry the buttons for:
|
||||
// left up center down right red
|
||||
#define BL_LE 7
|
||||
#define BL_UP 6
|
||||
#define BL_MI 5
|
||||
#define BL_DW 4
|
||||
#define BL_RI 3
|
||||
#define BL_ST 2
|
||||
|
||||
#define BLEN_B 1
|
||||
#define BLEN_A 0
|
||||
#endif
|
||||
#endif //ULTRA_LCD
|
||||
|
||||
|
@ -636,8 +613,8 @@
|
|||
#define DEBUG_PIN 0
|
||||
|
||||
//our RS485 pins
|
||||
#define TX_ENABLE_PIN 12
|
||||
#define RX_ENABLE_PIN 13
|
||||
#define TX_ENABLE_PIN 12
|
||||
#define RX_ENABLE_PIN 13
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -736,43 +713,32 @@
|
|||
//we have no buzzer installed
|
||||
#define BEEPER -1
|
||||
//LCD Pins
|
||||
#ifdef DOGLCD
|
||||
// Pins for DOGM SPI LCD Support
|
||||
#define DOGLCD_A0 30
|
||||
#define DOGLCD_CS 29
|
||||
// GLCD features
|
||||
#define LCD_CONTRAST 1
|
||||
// Uncomment screen orientation
|
||||
// #define LCD_SCREEN_ROT_0
|
||||
// #define LCD_SCREEN_ROT_90
|
||||
#define LCD_SCREEN_ROT_180
|
||||
// #define LCD_SCREEN_ROT_270
|
||||
#else // standard Hitachi LCD controller
|
||||
#define LCD_PINS_RS 4
|
||||
#define LCD_PINS_ENABLE 17
|
||||
#define LCD_PINS_D4 30
|
||||
#define LCD_PINS_D5 29
|
||||
#define LCD_PINS_D6 28
|
||||
#define LCD_PINS_D7 27
|
||||
#endif
|
||||
#ifdef DOGLCD
|
||||
// Pins for DOGM SPI LCD Support
|
||||
#define DOGLCD_A0 30
|
||||
#define DOGLCD_CS 29
|
||||
// GLCD features
|
||||
#define LCD_CONTRAST 1
|
||||
// Uncomment screen orientation
|
||||
// #define LCD_SCREEN_ROT_0
|
||||
// #define LCD_SCREEN_ROT_90
|
||||
#define LCD_SCREEN_ROT_180
|
||||
// #define LCD_SCREEN_ROT_270
|
||||
#else // standard Hitachi LCD controller
|
||||
#define LCD_PINS_RS 4
|
||||
#define LCD_PINS_ENABLE 17
|
||||
#define LCD_PINS_D4 30
|
||||
#define LCD_PINS_D5 29
|
||||
#define LCD_PINS_D6 28
|
||||
#define LCD_PINS_D7 27
|
||||
#endif
|
||||
//The encoder and click button
|
||||
#define BTN_EN1 11 //must be a hardware interrupt pin
|
||||
#define BTN_EN2 10 //must be hardware interrupt pin
|
||||
#define BTN_EN1 11
|
||||
#define BTN_EN2 10
|
||||
#define BTN_ENC 16 //the switch
|
||||
//not connected to a pin
|
||||
#define SDCARDDETECT -1
|
||||
|
||||
//from the same bit in the RAMPS Newpanel define
|
||||
//encoder rotation values
|
||||
#define encrot0 0
|
||||
#define encrot1 2
|
||||
#define encrot2 3
|
||||
#define encrot3 1
|
||||
|
||||
#define BLEN_C 2
|
||||
#define BLEN_B 1
|
||||
#define BLEN_A 0
|
||||
|
||||
#endif //Newpanel
|
||||
#endif //Ultipanel
|
||||
|
||||
|
@ -857,17 +823,8 @@
|
|||
#define BTN_EN2 42
|
||||
#define BTN_ENC 19 //the click
|
||||
|
||||
#define BLEN_C 2
|
||||
#define BLEN_B 1
|
||||
#define BLEN_A 0
|
||||
|
||||
#define SDCARDDETECT 38
|
||||
|
||||
//encoder rotation values
|
||||
#define encrot0 0
|
||||
#define encrot1 2
|
||||
#define encrot2 3
|
||||
#define encrot3 1
|
||||
#else //old style panel with shift register
|
||||
//arduino pin witch triggers an piezzo beeper
|
||||
#define BEEPER 18
|
||||
|
@ -885,32 +842,7 @@
|
|||
#define LCD_PINS_D6 20
|
||||
#define LCD_PINS_D7 19
|
||||
|
||||
//encoder rotation values
|
||||
#ifndef ULTIMAKERCONTROLLER
|
||||
#define encrot0 0
|
||||
#define encrot1 2
|
||||
#define encrot2 3
|
||||
#define encrot3 1
|
||||
#else
|
||||
#define encrot0 0
|
||||
#define encrot1 1
|
||||
#define encrot2 3
|
||||
#define encrot3 2
|
||||
|
||||
#endif
|
||||
|
||||
#define SDCARDDETECT -1
|
||||
//bits in the shift register that carry the buttons for:
|
||||
// left up center down right red
|
||||
#define BL_LE 7
|
||||
#define BL_UP 6
|
||||
#define BL_MI 5
|
||||
#define BL_DW 4
|
||||
#define BL_RI 3
|
||||
#define BL_ST 2
|
||||
|
||||
#define BLEN_B 1
|
||||
#define BLEN_A 0
|
||||
#endif
|
||||
#endif //ULTRA_LCD
|
||||
|
||||
|
@ -1035,17 +967,56 @@
|
|||
#define PS_ON_PIN 45
|
||||
#define KILL_PIN 46
|
||||
|
||||
#define HEATER_0_PIN 2 // EXTRUDER 1
|
||||
#define HEATER_1_PIN 3 // EXTRUDER 2
|
||||
#define HEATER_2_PIN 6 // EXTRUDER 3
|
||||
//optional FAN1 can be used as 4th heater output: #define HEATER_3_PIN 8 // EXTRUDER 4
|
||||
#define HEATER_BED_PIN 9 // BED
|
||||
#if (TEMP_SENSOR_0==0)
|
||||
#define TEMP_0_PIN -1
|
||||
#define HEATER_0_PIN -1
|
||||
#else
|
||||
#define HEATER_0_PIN 2 // EXTRUDER 1
|
||||
#if (TEMP_SENSOR_0==-1)
|
||||
#define TEMP_0_PIN 6 // ANALOG NUMBERING - connector *K1* on RUMBA thermocouple ADD ON is used
|
||||
#else
|
||||
#define TEMP_0_PIN 15 // ANALOG NUMBERING - default connector for thermistor *T0* on rumba board is used
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define TEMP_0_PIN 15 // ANALOG NUMBERING
|
||||
#define TEMP_1_PIN 14 // ANALOG NUMBERING
|
||||
#define TEMP_2_PIN 13 // ANALOG NUMBERING
|
||||
//optional for extruder 4 or chamber: #define TEMP_2_PIN 12 // ANALOG NUMBERING
|
||||
#define TEMP_BED_PIN 11 // ANALOG NUMBERING
|
||||
#if (TEMP_SENSOR_1==0)
|
||||
#define TEMP_1_PIN -1
|
||||
#define HEATER_1_PIN -1
|
||||
#else
|
||||
#define HEATER_1_PIN 3 // EXTRUDER 2
|
||||
#if (TEMP_SENSOR_1==-1)
|
||||
#define TEMP_1_PIN 5 // ANALOG NUMBERING - connector *K2* on RUMBA thermocouple ADD ON is used
|
||||
#else
|
||||
#define TEMP_1_PIN 14 // ANALOG NUMBERING - default connector for thermistor *T1* on rumba board is used
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if (TEMP_SENSOR_2==0)
|
||||
#define TEMP_2_PIN -1
|
||||
#define HEATER_2_PIN -1
|
||||
#else
|
||||
#define HEATER_2_PIN 6 // EXTRUDER 3
|
||||
#if (TEMP_SENSOR_2==-1)
|
||||
#define TEMP_2_PIN 7 // ANALOG NUMBERING - connector *K3* on RUMBA thermocouple ADD ON is used <-- this can not be used when TEMP_SENSOR_BED is defined as thermocouple
|
||||
#else
|
||||
#define TEMP_2_PIN 13 // ANALOG NUMBERING - default connector for thermistor *T2* on rumba board is used
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//optional for extruder 4 or chamber: #define TEMP_X_PIN 12 // ANALOG NUMBERING - default connector for thermistor *T3* on rumba board is used
|
||||
//optional FAN1 can be used as 4th heater output: #define HEATER_3_PIN 8 // EXTRUDER 4
|
||||
|
||||
#if (TEMP_SENSOR_BED==0)
|
||||
#define TEMP_BED_PIN -1
|
||||
#define HEATER_BED_PIN -1
|
||||
#else
|
||||
#define HEATER_BED_PIN 9 // BED
|
||||
#if (TEMP_SENSOR_BED==-1)
|
||||
#define TEMP_BED_PIN 7 // ANALOG NUMBERING - connector *K3* on RUMBA thermocouple ADD ON is used <-- this can not be used when TEMP_SENSOR_2 is defined as thermocouple
|
||||
#else
|
||||
#define TEMP_BED_PIN 11 // ANALOG NUMBERING - default connector for thermistor *THB* on rumba board is used
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define SDPOWER -1
|
||||
#define SDSS 53
|
||||
|
@ -1060,14 +1031,6 @@
|
|||
#define BTN_EN1 11
|
||||
#define BTN_EN2 12
|
||||
#define BTN_ENC 43
|
||||
//encoder rotation values
|
||||
#define BLEN_C 2
|
||||
#define BLEN_B 1
|
||||
#define BLEN_A 0
|
||||
#define encrot0 0
|
||||
#define encrot1 2
|
||||
#define encrot2 3
|
||||
#define encrot3 1
|
||||
|
||||
#endif //MOTHERBOARD==80
|
||||
|
||||
|
@ -1372,12 +1335,12 @@
|
|||
#define E0_ENABLE_PIN 10
|
||||
|
||||
/* future proofing */
|
||||
#define __FS 20
|
||||
#define __FD 19
|
||||
#define __GS 18
|
||||
#define __GD 13
|
||||
#define __FS 20
|
||||
#define __FD 19
|
||||
#define __GS 18
|
||||
#define __GD 13
|
||||
|
||||
#define UNUSED_PWM 14 /* PWM on LEFT connector */
|
||||
#define UNUSED_PWM 14 /* PWM on LEFT connector */
|
||||
|
||||
#define E1_STEP_PIN -1 // 21
|
||||
#define E1_DIR_PIN -1 // 20
|
||||
|
@ -1406,8 +1369,8 @@
|
|||
#define HEATER_BED_PIN 4
|
||||
#define TEMP_BED_PIN 2 // 1,2 or I2C
|
||||
|
||||
#define I2C_SCL 16
|
||||
#define I2C_SDA 17
|
||||
#define I2C_SCL 16
|
||||
#define I2C_SDA 17
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -1456,7 +1419,11 @@
|
|||
#define HEATER_1_PIN 7
|
||||
#define TEMP_1_PIN 1
|
||||
|
||||
#ifdef BARICUDA
|
||||
#define HEATER_2_PIN 6
|
||||
#else
|
||||
#define HEATER_2_PIN -1
|
||||
#endif
|
||||
#define TEMP_2_PIN -1
|
||||
|
||||
#define E0_STEP_PIN 34
|
||||
|
@ -1551,7 +1518,7 @@
|
|||
#define HEATER_BED_PIN 10 // BED
|
||||
#define TEMP_BED_PIN 14 // ANALOG NUMBERING
|
||||
|
||||
#define BEEPER 33 // Beeper on AUX-4
|
||||
#define BEEPER 33 // Beeper on AUX-4
|
||||
|
||||
|
||||
#ifdef ULTRA_LCD
|
||||
|
@ -1571,17 +1538,7 @@
|
|||
#define BTN_EN2 64
|
||||
#define BTN_ENC 43 //the click
|
||||
|
||||
#define BLEN_C 2
|
||||
#define BLEN_B 1
|
||||
#define BLEN_A 0
|
||||
|
||||
#define SDCARDDETECT -1 // Ramps does not use this port
|
||||
|
||||
//encoder rotation values
|
||||
#define encrot0 0
|
||||
#define encrot1 2
|
||||
#define encrot2 3
|
||||
#define encrot3 1
|
||||
#define SDCARDDETECT -1 // Ramps does not use this port
|
||||
#endif
|
||||
#endif //ULTRA_LCD
|
||||
|
||||
|
|
|
@ -439,12 +439,20 @@ void check_axes_activity()
|
|||
unsigned char z_active = 0;
|
||||
unsigned char e_active = 0;
|
||||
unsigned char tail_fan_speed = fanSpeed;
|
||||
#ifdef BARICUDA
|
||||
unsigned char tail_valve_pressure = ValvePressure;
|
||||
unsigned char tail_e_to_p_pressure = EtoPPressure;
|
||||
#endif
|
||||
block_t *block;
|
||||
|
||||
if(block_buffer_tail != block_buffer_head)
|
||||
{
|
||||
uint8_t block_index = block_buffer_tail;
|
||||
tail_fan_speed = block_buffer[block_index].fan_speed;
|
||||
#ifdef BARICUDA
|
||||
tail_valve_pressure = block_buffer[block_index].valve_pressure;
|
||||
tail_e_to_p_pressure = block_buffer[block_index].e_to_p_pressure;
|
||||
#endif
|
||||
while(block_index != block_buffer_head)
|
||||
{
|
||||
block = &block_buffer[block_index];
|
||||
|
@ -486,6 +494,16 @@ void check_axes_activity()
|
|||
#ifdef AUTOTEMP
|
||||
getHighESpeed();
|
||||
#endif
|
||||
|
||||
#ifdef BARICUDA
|
||||
#if HEATER_1_PIN > -1
|
||||
analogWrite(HEATER_1_PIN,tail_valve_pressure);
|
||||
#endif
|
||||
|
||||
#if HEATER_2_PIN > -1
|
||||
analogWrite(HEATER_2_PIN,tail_e_to_p_pressure);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -559,6 +577,10 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa
|
|||
}
|
||||
|
||||
block->fan_speed = fanSpeed;
|
||||
#ifdef BARICUDA
|
||||
block->valve_pressure = ValvePressure;
|
||||
block->e_to_p_pressure = EtoPPressure;
|
||||
#endif
|
||||
|
||||
// Compute direction bits for this block
|
||||
block->direction_bits = 0;
|
||||
|
@ -582,8 +604,16 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa
|
|||
block->active_extruder = extruder;
|
||||
|
||||
//enable active axes
|
||||
#ifdef COREXY
|
||||
if((block->steps_x != 0) || (block->steps_y != 0))
|
||||
{
|
||||
enable_x();
|
||||
enable_y();
|
||||
}
|
||||
#else
|
||||
if(block->steps_x != 0) enable_x();
|
||||
if(block->steps_y != 0) enable_y();
|
||||
#endif
|
||||
#ifndef Z_LATE_ENABLE
|
||||
if(block->steps_z != 0) enable_z();
|
||||
#endif
|
||||
|
|
|
@ -60,6 +60,10 @@ typedef struct {
|
|||
unsigned long final_rate; // The minimal rate at exit
|
||||
unsigned long acceleration_st; // acceleration steps/sec^2
|
||||
unsigned long fan_speed;
|
||||
#ifdef BARICUDA
|
||||
unsigned long valve_pressure;
|
||||
unsigned long e_to_p_pressure;
|
||||
#endif
|
||||
volatile char busy;
|
||||
} block_t;
|
||||
|
||||
|
|
|
@ -309,6 +309,18 @@ int getHeaterPower(int heater) {
|
|||
|
||||
#if EXTRUDER_0_AUTO_FAN_PIN > 0 || EXTRUDER_1_AUTO_FAN_PIN > 0 || EXTRUDER_2_AUTO_FAN_PIN > 0
|
||||
|
||||
#if FAN_PIN > 0
|
||||
#if EXTRUDER_0_AUTO_FAN_PIN == FAN_PIN
|
||||
#error "You cannot set EXTRUDER_0_AUTO_FAN_PIN equal to FAN_PIN"
|
||||
#endif
|
||||
#if EXTRUDER_1_AUTO_FAN_PIN == FAN_PIN
|
||||
#error "You cannot set EXTRUDER_1_AUTO_FAN_PIN equal to FAN_PIN"
|
||||
#endif
|
||||
#if EXTRUDER_2_AUTO_FAN_PIN == FAN_PIN
|
||||
#error "You cannot set EXTRUDER_2_AUTO_FAN_PIN equal to FAN_PIN"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
void setExtruderAutoFanState(int pin, bool state)
|
||||
{
|
||||
unsigned char newFanSpeed = (state != 0) ? EXTRUDER_AUTO_FAN_SPEED : 0;
|
||||
|
@ -324,16 +336,10 @@ void checkExtruderAutoFans()
|
|||
|
||||
// which fan pins need to be turned on?
|
||||
#if EXTRUDER_0_AUTO_FAN_PIN > 0
|
||||
#if EXTRUDER_0_AUTO_FAN_PIN == FAN_PIN
|
||||
#error "You cannot set EXTRUDER_0_AUTO_FAN_PIN equal to FAN_PIN"
|
||||
#endif
|
||||
if (current_temperature[0] > EXTRUDER_AUTO_FAN_TEMPERATURE)
|
||||
fanState |= 1;
|
||||
#endif
|
||||
#if EXTRUDER_1_AUTO_FAN_PIN > 0
|
||||
#if EXTRUDER_1_AUTO_FAN_PIN == FAN_PIN
|
||||
#error "You cannot set EXTRUDER_1_AUTO_FAN_PIN equal to FAN_PIN"
|
||||
#endif
|
||||
if (current_temperature[1] > EXTRUDER_AUTO_FAN_TEMPERATURE)
|
||||
{
|
||||
if (EXTRUDER_1_AUTO_FAN_PIN == EXTRUDER_0_AUTO_FAN_PIN)
|
||||
|
@ -343,9 +349,6 @@ void checkExtruderAutoFans()
|
|||
}
|
||||
#endif
|
||||
#if EXTRUDER_2_AUTO_FAN_PIN > 0
|
||||
#if EXTRUDER_2_AUTO_FAN_PIN == FAN_PIN
|
||||
#error "You cannot set EXTRUDER_2_AUTO_FAN_PIN equal to FAN_PIN"
|
||||
#endif
|
||||
if (current_temperature[2] > EXTRUDER_AUTO_FAN_TEMPERATURE)
|
||||
{
|
||||
if (EXTRUDER_2_AUTO_FAN_PIN == EXTRUDER_0_AUTO_FAN_PIN)
|
||||
|
@ -646,6 +649,12 @@ static void updateTemperaturesFromRawValues()
|
|||
|
||||
void tp_init()
|
||||
{
|
||||
#if (MOTHERBOARD == 80) && ((TEMP_SENSOR_0==-1)||(TEMP_SENSOR_1==-1)||(TEMP_SENSOR_2==-1)||(TEMP_SENSOR_BED==-1))
|
||||
//disable RUMBA JTAG in case the thermocouple extension is plugged on top of JTAG connector
|
||||
MCUCR=(1<<JTD);
|
||||
MCUCR=(1<<JTD);
|
||||
#endif
|
||||
|
||||
// Finish init of mult extruder arrays
|
||||
for(int e = 0; e < EXTRUDERS; e++) {
|
||||
// populate with the first value
|
||||
|
@ -722,7 +731,7 @@ void tp_init()
|
|||
#if TEMP_2_PIN < 8
|
||||
DIDR0 |= 1 << TEMP_2_PIN;
|
||||
#else
|
||||
DIDR2 = 1<<(TEMP_2_PIN - 8);
|
||||
DIDR2 |= 1<<(TEMP_2_PIN - 8);
|
||||
#endif
|
||||
#endif
|
||||
#if (TEMP_BED_PIN > -1)
|
||||
|
@ -764,7 +773,7 @@ void tp_init()
|
|||
|
||||
#if (EXTRUDERS > 1) && defined(HEATER_1_MINTEMP)
|
||||
minttemp[1] = HEATER_1_MINTEMP;
|
||||
while(analog2temp(minttemp_raw[1], 1) > HEATER_1_MINTEMP) {
|
||||
while(analog2temp(minttemp_raw[1], 1) < HEATER_1_MINTEMP) {
|
||||
#if HEATER_1_RAW_LO_TEMP < HEATER_1_RAW_HI_TEMP
|
||||
minttemp_raw[1] += OVERSAMPLENR;
|
||||
#else
|
||||
|
@ -785,7 +794,7 @@ void tp_init()
|
|||
|
||||
#if (EXTRUDERS > 2) && defined(HEATER_2_MINTEMP)
|
||||
minttemp[2] = HEATER_2_MINTEMP;
|
||||
while(analog2temp(minttemp_raw[2], 2) > HEATER_2_MINTEMP) {
|
||||
while(analog2temp(minttemp_raw[2], 2) < HEATER_2_MINTEMP) {
|
||||
#if HEATER_2_RAW_LO_TEMP < HEATER_2_RAW_HI_TEMP
|
||||
minttemp_raw[2] += OVERSAMPLENR;
|
||||
#else
|
||||
|
|
|
@ -76,7 +76,11 @@ static void menu_action_setting_edit_callback_float51(const char* pstr, float* p
|
|||
static void menu_action_setting_edit_callback_float52(const char* pstr, float* ptr, float minValue, float maxValue, menuFunc_t callbackFunc);
|
||||
static void menu_action_setting_edit_callback_long5(const char* pstr, unsigned long* ptr, unsigned long minValue, unsigned long maxValue, menuFunc_t callbackFunc);
|
||||
|
||||
#define ENCODER_STEPS_PER_MENU_ITEM 5
|
||||
#if !defined(LCD_I2C_VIKI)
|
||||
#define ENCODER_STEPS_PER_MENU_ITEM 5
|
||||
#else
|
||||
#define ENCODER_STEPS_PER_MENU_ITEM 2 // VIKI LCD rotary encoder uses a different number of steps per rotation
|
||||
#endif
|
||||
|
||||
/* Helper macros for menus */
|
||||
#define START_MENU() do { \
|
||||
|
@ -112,14 +116,18 @@ static void menu_action_setting_edit_callback_long5(const char* pstr, unsigned l
|
|||
} } while(0)
|
||||
|
||||
/** Used variables to keep track of the menu */
|
||||
#ifndef REPRAPWORLD_KEYPAD
|
||||
volatile uint8_t buttons;//Contains the bits of the currently pressed buttons.
|
||||
#else
|
||||
volatile uint16_t buttons;//Contains the bits of the currently pressed buttons (extended).
|
||||
#endif
|
||||
|
||||
uint8_t currentMenuViewOffset; /* scroll offset in the current menu */
|
||||
uint32_t blocking_enc;
|
||||
uint8_t lastEncoderBits;
|
||||
int8_t encoderDiff; /* encoderDiff is updated from interrupt context and added to encoderPosition every LCD update */
|
||||
uint32_t encoderPosition;
|
||||
#if (SDCARDDETECT > -1)
|
||||
#if (SDCARDDETECT > 0)
|
||||
bool lcd_oldcardstatus;
|
||||
#endif
|
||||
#endif//ULTIPANEL
|
||||
|
@ -221,13 +229,13 @@ static void lcd_main_menu()
|
|||
}else{
|
||||
MENU_ITEM(submenu, MSG_CARD_MENU, lcd_sdcard_menu);
|
||||
#if SDCARDDETECT < 1
|
||||
MENU_ITEM(gcode, MSG_CNG_SDCARD, PSTR("M21")); // SD-card changed by user
|
||||
MENU_ITEM(gcode, MSG_CNG_SDCARD, PSTR("M21")); // SD-card changed by user
|
||||
#endif
|
||||
}
|
||||
}else{
|
||||
MENU_ITEM(submenu, MSG_NO_CARD, lcd_sdcard_menu);
|
||||
#if SDCARDDETECT < 1
|
||||
MENU_ITEM(gcode, MSG_INIT_SDCARD, PSTR("M21")); // Manually initialize the SD-card via user interface
|
||||
MENU_ITEM(gcode, MSG_INIT_SDCARD, PSTR("M21")); // Manually initialize the SD-card via user interface
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
@ -251,6 +259,7 @@ void lcd_preheat_pla()
|
|||
setTargetBed(plaPreheatHPBTemp);
|
||||
fanSpeed = plaPreheatFanSpeed;
|
||||
lcd_return_to_status();
|
||||
setWatch(); // heater sanity check timer
|
||||
}
|
||||
|
||||
void lcd_preheat_abs()
|
||||
|
@ -261,6 +270,16 @@ void lcd_preheat_abs()
|
|||
setTargetBed(absPreheatHPBTemp);
|
||||
fanSpeed = absPreheatFanSpeed;
|
||||
lcd_return_to_status();
|
||||
setWatch(); // heater sanity check timer
|
||||
}
|
||||
|
||||
static void lcd_cooldown()
|
||||
{
|
||||
setTargetHotend0(0);
|
||||
setTargetHotend1(0);
|
||||
setTargetHotend2(0);
|
||||
setTargetBed(0);
|
||||
lcd_return_to_status();
|
||||
}
|
||||
|
||||
static void lcd_tune_menu()
|
||||
|
@ -298,7 +317,7 @@ static void lcd_prepare_menu()
|
|||
//MENU_ITEM(gcode, MSG_SET_ORIGIN, PSTR("G92 X0 Y0 Z0"));
|
||||
MENU_ITEM(function, MSG_PREHEAT_PLA, lcd_preheat_pla);
|
||||
MENU_ITEM(function, MSG_PREHEAT_ABS, lcd_preheat_abs);
|
||||
MENU_ITEM(gcode, MSG_COOLDOWN, PSTR("M104 S0\nM140 S0"));
|
||||
MENU_ITEM(function, MSG_COOLDOWN, lcd_cooldown);
|
||||
MENU_ITEM(submenu, MSG_MOVE_AXIS, lcd_move_menu);
|
||||
END_MENU();
|
||||
}
|
||||
|
@ -459,9 +478,9 @@ static void lcd_control_menu()
|
|||
|
||||
static void lcd_control_temperature_menu()
|
||||
{
|
||||
// set up temp variables - undo the default scaling
|
||||
raw_Ki = unscalePID_i(Ki);
|
||||
raw_Kd = unscalePID_d(Kd);
|
||||
// set up temp variables - undo the default scaling
|
||||
raw_Ki = unscalePID_i(Ki);
|
||||
raw_Kd = unscalePID_d(Kd);
|
||||
|
||||
START_MENU();
|
||||
MENU_ITEM(back, MSG_CONTROL, lcd_control_menu);
|
||||
|
@ -484,7 +503,7 @@ static void lcd_control_temperature_menu()
|
|||
#endif
|
||||
#ifdef PIDTEMP
|
||||
MENU_ITEM_EDIT(float52, MSG_PID_P, &Kp, 1, 9990);
|
||||
// i is typically a small value so allows values below 1
|
||||
// i is typically a small value so allows values below 1
|
||||
MENU_ITEM_EDIT_CALLBACK(float52, MSG_PID_I, &raw_Ki, 0.01, 9990, copy_and_scalePID_i);
|
||||
MENU_ITEM_EDIT_CALLBACK(float52, MSG_PID_D, &raw_Kd, 1, 9990, copy_and_scalePID_d);
|
||||
# ifdef PID_ADD_EXTRUSION_RATE
|
||||
|
@ -687,6 +706,24 @@ menu_edit_type(float, float51, ftostr51, 10)
|
|||
menu_edit_type(float, float52, ftostr52, 100)
|
||||
menu_edit_type(unsigned long, long5, ftostr5, 0.01)
|
||||
|
||||
#ifdef REPRAPWORLD_KEYPAD
|
||||
static void reprapworld_keypad_move_y_down() {
|
||||
encoderPosition = 1;
|
||||
move_menu_scale = REPRAPWORLD_KEYPAD_MOVE_STEP;
|
||||
lcd_move_y();
|
||||
}
|
||||
static void reprapworld_keypad_move_y_up() {
|
||||
encoderPosition = -1;
|
||||
move_menu_scale = REPRAPWORLD_KEYPAD_MOVE_STEP;
|
||||
lcd_move_y();
|
||||
}
|
||||
static void reprapworld_keypad_move_home() {
|
||||
//enquecommand_P((PSTR("G28"))); // move all axis home
|
||||
// TODO gregor: move all axis home, i have currently only one axis on my prusa i3
|
||||
enquecommand_P((PSTR("G28 Y")));
|
||||
}
|
||||
#endif
|
||||
|
||||
/** End of menus **/
|
||||
|
||||
static void lcd_quick_feedback()
|
||||
|
@ -745,11 +782,20 @@ void lcd_init()
|
|||
#ifdef NEWPANEL
|
||||
pinMode(BTN_EN1,INPUT);
|
||||
pinMode(BTN_EN2,INPUT);
|
||||
pinMode(BTN_ENC,INPUT);
|
||||
pinMode(SDCARDDETECT,INPUT);
|
||||
WRITE(BTN_EN1,HIGH);
|
||||
WRITE(BTN_EN2,HIGH);
|
||||
#if BTN_ENC > 0
|
||||
pinMode(BTN_ENC,INPUT);
|
||||
WRITE(BTN_ENC,HIGH);
|
||||
#endif
|
||||
#ifdef REPRAPWORLD_KEYPAD
|
||||
pinMode(SHIFT_CLK,OUTPUT);
|
||||
pinMode(SHIFT_LD,OUTPUT);
|
||||
pinMode(SHIFT_OUT,INPUT);
|
||||
WRITE(SHIFT_OUT,HIGH);
|
||||
WRITE(SHIFT_LD,HIGH);
|
||||
#endif
|
||||
#else
|
||||
pinMode(SHIFT_CLK,OUTPUT);
|
||||
pinMode(SHIFT_LD,OUTPUT);
|
||||
|
@ -759,12 +805,14 @@ void lcd_init()
|
|||
WRITE(SHIFT_LD,HIGH);
|
||||
WRITE(SHIFT_EN,LOW);
|
||||
#endif//!NEWPANEL
|
||||
#if (SDCARDDETECT > -1)
|
||||
#if (SDCARDDETECT > 0)
|
||||
WRITE(SDCARDDETECT, HIGH);
|
||||
lcd_oldcardstatus = IS_SD_INSERTED;
|
||||
#endif//(SDCARDDETECT > -1)
|
||||
#endif//(SDCARDDETECT > 0)
|
||||
lcd_buttons_update();
|
||||
#ifdef ULTIPANEL
|
||||
encoderDiff = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
void lcd_update()
|
||||
|
@ -773,7 +821,11 @@ void lcd_update()
|
|||
|
||||
lcd_buttons_update();
|
||||
|
||||
#if (SDCARDDETECT > -1)
|
||||
#ifdef LCD_HAS_SLOW_BUTTONS
|
||||
buttons |= lcd_implementation_read_slow_buttons(); // buttons which take too long to read in interrupt context
|
||||
#endif
|
||||
|
||||
#if (SDCARDDETECT > 0)
|
||||
if((IS_SD_INSERTED != lcd_oldcardstatus))
|
||||
{
|
||||
lcdDrawUpdate = 2;
|
||||
|
@ -796,6 +848,17 @@ void lcd_update()
|
|||
if (lcd_next_update_millis < millis())
|
||||
{
|
||||
#ifdef ULTIPANEL
|
||||
#ifdef REPRAPWORLD_KEYPAD
|
||||
if (REPRAPWORLD_KEYPAD_MOVE_Y_DOWN) {
|
||||
reprapworld_keypad_move_y_down();
|
||||
}
|
||||
if (REPRAPWORLD_KEYPAD_MOVE_Y_UP) {
|
||||
reprapworld_keypad_move_y_up();
|
||||
}
|
||||
if (REPRAPWORLD_KEYPAD_MOVE_HOME) {
|
||||
reprapworld_keypad_move_home();
|
||||
}
|
||||
#endif
|
||||
if (encoderDiff)
|
||||
{
|
||||
lcdDrawUpdate = 1;
|
||||
|
@ -808,21 +871,26 @@ void lcd_update()
|
|||
#endif//ULTIPANEL
|
||||
|
||||
#ifdef DOGLCD // Changes due to different driver architecture of the DOGM display
|
||||
blink++; // Variable for fan animation and alive dot
|
||||
u8g.firstPage();
|
||||
do {
|
||||
u8g.setFont(u8g_font_6x10_marlin);
|
||||
u8g.setPrintPos(125,0);
|
||||
if (blink % 2) u8g.setColorIndex(1); else u8g.setColorIndex(0); // Set color for the alive dot
|
||||
u8g.drawPixel(127,63); // draw alive dot
|
||||
u8g.setColorIndex(1); // black on white
|
||||
(*currentMenu)();
|
||||
if (!lcdDrawUpdate) break; // Terminate display update, when nothing new to draw. This must be done before the last dogm.next()
|
||||
} while( u8g.nextPage() );
|
||||
blink++; // Variable for fan animation and alive dot
|
||||
u8g.firstPage();
|
||||
do
|
||||
{
|
||||
u8g.setFont(u8g_font_6x10_marlin);
|
||||
u8g.setPrintPos(125,0);
|
||||
if (blink % 2) u8g.setColorIndex(1); else u8g.setColorIndex(0); // Set color for the alive dot
|
||||
u8g.drawPixel(127,63); // draw alive dot
|
||||
u8g.setColorIndex(1); // black on white
|
||||
(*currentMenu)();
|
||||
if (!lcdDrawUpdate) break; // Terminate display update, when nothing new to draw. This must be done before the last dogm.next()
|
||||
} while( u8g.nextPage() );
|
||||
#else
|
||||
(*currentMenu)();
|
||||
#endif
|
||||
|
||||
#ifdef LCD_HAS_STATUS_INDICATORS
|
||||
lcd_implementation_update_indicators();
|
||||
#endif
|
||||
|
||||
#ifdef ULTIPANEL
|
||||
if(timeoutToStatus < millis() && currentMenu != lcd_status_screen)
|
||||
{
|
||||
|
@ -873,8 +941,24 @@ void lcd_buttons_update()
|
|||
uint8_t newbutton=0;
|
||||
if(READ(BTN_EN1)==0) newbutton|=EN_A;
|
||||
if(READ(BTN_EN2)==0) newbutton|=EN_B;
|
||||
#if BTN_ENC > 0
|
||||
if((blocking_enc<millis()) && (READ(BTN_ENC)==0))
|
||||
newbutton |= EN_C;
|
||||
#endif
|
||||
#ifdef REPRAPWORLD_KEYPAD
|
||||
// for the reprapworld_keypad
|
||||
uint8_t newbutton_reprapworld_keypad=0;
|
||||
WRITE(SHIFT_LD,LOW);
|
||||
WRITE(SHIFT_LD,HIGH);
|
||||
for(int8_t i=0;i<8;i++) {
|
||||
newbutton_reprapworld_keypad = newbutton_reprapworld_keypad>>1;
|
||||
if(READ(SHIFT_OUT))
|
||||
newbutton_reprapworld_keypad|=(1<<7);
|
||||
WRITE(SHIFT_CLK,HIGH);
|
||||
WRITE(SHIFT_CLK,LOW);
|
||||
}
|
||||
newbutton |= ((~newbutton_reprapworld_keypad) << REPRAPWORLD_BTN_OFFSET); //invert it, because a pressed switch produces a logical 0
|
||||
#endif
|
||||
buttons = newbutton;
|
||||
#else //read it from the shift register
|
||||
uint8_t newbutton=0;
|
||||
|
@ -930,6 +1014,18 @@ void lcd_buttons_update()
|
|||
}
|
||||
lastEncoderBits = enc;
|
||||
}
|
||||
|
||||
void lcd_buzz(long duration, uint16_t freq)
|
||||
{
|
||||
#ifdef LCD_USE_I2C_BUZZER
|
||||
lcd.buzz(duration,freq);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool lcd_clicked()
|
||||
{
|
||||
return LCD_CLICKED;
|
||||
}
|
||||
#endif//ULTIPANEL
|
||||
|
||||
/********************************/
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
|
||||
#ifdef ULTIPANEL
|
||||
void lcd_buttons_update();
|
||||
extern volatile uint8_t buttons; //the last checked buttons in a bit array.
|
||||
#else
|
||||
FORCE_INLINE void lcd_buttons_update() {}
|
||||
#endif
|
||||
|
@ -35,25 +34,8 @@
|
|||
extern int absPreheatHPBTemp;
|
||||
extern int absPreheatFanSpeed;
|
||||
|
||||
#ifdef NEWPANEL
|
||||
#define EN_C (1<<BLEN_C)
|
||||
#define EN_B (1<<BLEN_B)
|
||||
#define EN_A (1<<BLEN_A)
|
||||
|
||||
#define LCD_CLICKED (buttons&EN_C)
|
||||
#else
|
||||
//atomatic, do not change
|
||||
#define B_LE (1<<BL_LE)
|
||||
#define B_UP (1<<BL_UP)
|
||||
#define B_MI (1<<BL_MI)
|
||||
#define B_DW (1<<BL_DW)
|
||||
#define B_RI (1<<BL_RI)
|
||||
#define B_ST (1<<BL_ST)
|
||||
#define EN_B (1<<BLEN_B)
|
||||
#define EN_A (1<<BLEN_A)
|
||||
|
||||
#define LCD_CLICKED ((buttons&B_MI)||(buttons&B_ST))
|
||||
#endif//NEWPANEL
|
||||
void lcd_buzz(long duration,uint16_t freq);
|
||||
bool lcd_clicked();
|
||||
|
||||
#else //no lcd
|
||||
FORCE_INLINE void lcd_update() {}
|
||||
|
@ -61,6 +43,7 @@
|
|||
FORCE_INLINE void lcd_setstatus(const char* message) {}
|
||||
FORCE_INLINE void lcd_buttons_update() {}
|
||||
FORCE_INLINE void lcd_reset_alert_level() {}
|
||||
FORCE_INLINE void lcd_buzz(long duration,uint16_t freq) {}
|
||||
|
||||
#define LCD_MESSAGEPGM(x)
|
||||
#define LCD_ALERTMESSAGEPGM(x)
|
||||
|
|
|
@ -6,12 +6,191 @@
|
|||
* When selecting the rusian language, a slightly different LCD implementation is used to handle UTF8 characters.
|
||||
**/
|
||||
|
||||
#if LANGUAGE_CHOICE == 6
|
||||
#include "LiquidCrystalRus.h"
|
||||
#define LCD_CLASS LiquidCrystalRus
|
||||
#ifndef REPRAPWORLD_KEYPAD
|
||||
extern volatile uint8_t buttons; //the last checked buttons in a bit array.
|
||||
#else
|
||||
#include <LiquidCrystal.h>
|
||||
#define LCD_CLASS LiquidCrystal
|
||||
extern volatile uint16_t buttons; //an extended version of the last checked buttons in a bit array.
|
||||
#endif
|
||||
|
||||
////////////////////////////////////
|
||||
// Setup button and encode mappings for each panel (into 'buttons' variable)
|
||||
//
|
||||
// This is just to map common functions (across different panels) onto the same
|
||||
// macro name. The mapping is independent of whether the button is directly connected or
|
||||
// via a shift/i2c register.
|
||||
|
||||
#ifdef ULTIPANEL
|
||||
// All Ultipanels might have an encoder - so this is always be mapped onto first two bits
|
||||
#define BLEN_B 1
|
||||
#define BLEN_A 0
|
||||
|
||||
#define EN_B (1<<BLEN_B) // The two encoder pins are connected through BTN_EN1 and BTN_EN2
|
||||
#define EN_A (1<<BLEN_A)
|
||||
|
||||
#if defined(BTN_ENC) && BTN_ENC > -1
|
||||
// encoder click is directly connected
|
||||
#define BLEN_C 2
|
||||
#define EN_C (1<<BLEN_C)
|
||||
#endif
|
||||
|
||||
//
|
||||
// Setup other button mappings of each panel
|
||||
//
|
||||
#if defined(LCD_I2C_VIKI)
|
||||
#define B_I2C_BTN_OFFSET 3 // (the first three bit positions reserved for EN_A, EN_B, EN_C)
|
||||
|
||||
// button and encoder bit positions within 'buttons'
|
||||
#define B_LE (BUTTON_LEFT<<B_I2C_BTN_OFFSET) // The remaining normalized buttons are all read via I2C
|
||||
#define B_UP (BUTTON_UP<<B_I2C_BTN_OFFSET)
|
||||
#define B_MI (BUTTON_SELECT<<B_I2C_BTN_OFFSET)
|
||||
#define B_DW (BUTTON_DOWN<<B_I2C_BTN_OFFSET)
|
||||
#define B_RI (BUTTON_RIGHT<<B_I2C_BTN_OFFSET)
|
||||
|
||||
#if defined(BTN_ENC) && BTN_ENC > -1
|
||||
// the pause/stop/restart button is connected to BTN_ENC when used
|
||||
#define B_ST (EN_C) // Map the pause/stop/resume button into its normalized functional name
|
||||
#define LCD_CLICKED (buttons&(B_MI|B_RI|B_ST)) // pause/stop button also acts as click until we implement proper pause/stop.
|
||||
#else
|
||||
#define LCD_CLICKED (buttons&(B_MI|B_RI))
|
||||
#endif
|
||||
|
||||
// I2C buttons take too long to read inside an interrupt context and so we read them during lcd_update
|
||||
#define LCD_HAS_SLOW_BUTTONS
|
||||
|
||||
#elif defined(LCD_I2C_PANELOLU2)
|
||||
// encoder click can be read through I2C if not directly connected
|
||||
#if BTN_ENC <= 0
|
||||
#define B_I2C_BTN_OFFSET 3 // (the first three bit positions reserved for EN_A, EN_B, EN_C)
|
||||
|
||||
#define B_MI (PANELOLU2_ENCODER_C<<B_I2C_BTN_OFFSET) // requires LiquidTWI2 library v1.2.3 or later
|
||||
|
||||
#define LCD_CLICKED (buttons&B_MI)
|
||||
|
||||
// I2C buttons take too long to read inside an interrupt context and so we read them during lcd_update
|
||||
#define LCD_HAS_SLOW_BUTTONS
|
||||
#else
|
||||
#define LCD_CLICKED (buttons&EN_C)
|
||||
#endif
|
||||
|
||||
#elif defined(REPRAPWORLD_KEYPAD)
|
||||
// define register bit values, don't change it
|
||||
#define BLEN_REPRAPWORLD_KEYPAD_F3 0
|
||||
#define BLEN_REPRAPWORLD_KEYPAD_F2 1
|
||||
#define BLEN_REPRAPWORLD_KEYPAD_F1 2
|
||||
#define BLEN_REPRAPWORLD_KEYPAD_UP 3
|
||||
#define BLEN_REPRAPWORLD_KEYPAD_RIGHT 4
|
||||
#define BLEN_REPRAPWORLD_KEYPAD_MIDDLE 5
|
||||
#define BLEN_REPRAPWORLD_KEYPAD_DOWN 6
|
||||
#define BLEN_REPRAPWORLD_KEYPAD_LEFT 7
|
||||
|
||||
#define REPRAPWORLD_BTN_OFFSET 3 // bit offset into buttons for shift register values
|
||||
|
||||
#define EN_REPRAPWORLD_KEYPAD_F3 (1<<(BLEN_REPRAPWORLD_KEYPAD_F3+REPRAPWORLD_BTN_OFFSET))
|
||||
#define EN_REPRAPWORLD_KEYPAD_F2 (1<<(BLEN_REPRAPWORLD_KEYPAD_F2+REPRAPWORLD_BTN_OFFSET))
|
||||
#define EN_REPRAPWORLD_KEYPAD_F1 (1<<(BLEN_REPRAPWORLD_KEYPAD_F1+REPRAPWORLD_BTN_OFFSET))
|
||||
#define EN_REPRAPWORLD_KEYPAD_UP (1<<(BLEN_REPRAPWORLD_KEYPAD_UP+REPRAPWORLD_BTN_OFFSET))
|
||||
#define EN_REPRAPWORLD_KEYPAD_RIGHT (1<<(BLEN_REPRAPWORLD_KEYPAD_RIGHT+REPRAPWORLD_BTN_OFFSET))
|
||||
#define EN_REPRAPWORLD_KEYPAD_MIDDLE (1<<(BLEN_REPRAPWORLD_KEYPAD_MIDDLE+REPRAPWORLD_BTN_OFFSET))
|
||||
#define EN_REPRAPWORLD_KEYPAD_DOWN (1<<(BLEN_REPRAPWORLD_KEYPAD_DOWN+REPRAPWORLD_BTN_OFFSET))
|
||||
#define EN_REPRAPWORLD_KEYPAD_LEFT (1<<(BLEN_REPRAPWORLD_KEYPAD_LEFT+REPRAPWORLD_BTN_OFFSET))
|
||||
|
||||
#define LCD_CLICKED ((buttons&EN_C) || (buttons&EN_REPRAPWORLD_KEYPAD_F1))
|
||||
#define REPRAPWORLD_KEYPAD_MOVE_Y_DOWN (buttons&EN_REPRAPWORLD_KEYPAD_DOWN)
|
||||
#define REPRAPWORLD_KEYPAD_MOVE_Y_UP (buttons&EN_REPRAPWORLD_KEYPAD_UP)
|
||||
#define REPRAPWORLD_KEYPAD_MOVE_HOME (buttons&EN_REPRAPWORLD_KEYPAD_MIDDLE)
|
||||
|
||||
#elif defined(NEWPANEL)
|
||||
#define LCD_CLICKED (buttons&EN_C)
|
||||
|
||||
#else // old style ULTIPANEL
|
||||
//bits in the shift register that carry the buttons for:
|
||||
// left up center down right red(stop)
|
||||
#define BL_LE 7
|
||||
#define BL_UP 6
|
||||
#define BL_MI 5
|
||||
#define BL_DW 4
|
||||
#define BL_RI 3
|
||||
#define BL_ST 2
|
||||
|
||||
//automatic, do not change
|
||||
#define B_LE (1<<BL_LE)
|
||||
#define B_UP (1<<BL_UP)
|
||||
#define B_MI (1<<BL_MI)
|
||||
#define B_DW (1<<BL_DW)
|
||||
#define B_RI (1<<BL_RI)
|
||||
#define B_ST (1<<BL_ST)
|
||||
|
||||
#define LCD_CLICKED (buttons&(B_MI|B_ST))
|
||||
#endif
|
||||
|
||||
////////////////////////
|
||||
// Setup Rotary Encoder Bit Values (for two pin encoders to indicate movement)
|
||||
// These values are independent of which pins are used for EN_A and EN_B indications
|
||||
// The rotary encoder part is also independent to the chipset used for the LCD
|
||||
#if defined(EN_A) && defined(EN_B)
|
||||
#ifndef ULTIMAKERCONTROLLER
|
||||
#define encrot0 0
|
||||
#define encrot1 2
|
||||
#define encrot2 3
|
||||
#define encrot3 1
|
||||
#else
|
||||
#define encrot0 0
|
||||
#define encrot1 1
|
||||
#define encrot2 3
|
||||
#define encrot3 2
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif //ULTIPANEL
|
||||
|
||||
////////////////////////////////////
|
||||
// Create LCD class instance and chipset-specific information
|
||||
#if defined(LCD_I2C_TYPE_PCF8575)
|
||||
// note: these are register mapped pins on the PCF8575 controller not Arduino pins
|
||||
#define LCD_I2C_PIN_BL 3
|
||||
#define LCD_I2C_PIN_EN 2
|
||||
#define LCD_I2C_PIN_RW 1
|
||||
#define LCD_I2C_PIN_RS 0
|
||||
#define LCD_I2C_PIN_D4 4
|
||||
#define LCD_I2C_PIN_D5 5
|
||||
#define LCD_I2C_PIN_D6 6
|
||||
#define LCD_I2C_PIN_D7 7
|
||||
|
||||
#include <Wire.h>
|
||||
#include <LCD.h>
|
||||
#include <LiquidCrystal_I2C.h>
|
||||
#define LCD_CLASS LiquidCrystal_I2C
|
||||
LCD_CLASS lcd(LCD_I2C_ADDRESS,LCD_I2C_PIN_EN,LCD_I2C_PIN_RW,LCD_I2C_PIN_RS,LCD_I2C_PIN_D4,LCD_I2C_PIN_D5,LCD_I2C_PIN_D6,LCD_I2C_PIN_D7);
|
||||
|
||||
#elif defined(LCD_I2C_TYPE_MCP23017)
|
||||
//for the LED indicators (which maybe mapped to different things in lcd_implementation_update_indicators())
|
||||
#define LED_A 0x04 //100
|
||||
#define LED_B 0x02 //010
|
||||
#define LED_C 0x01 //001
|
||||
|
||||
#define LCD_HAS_STATUS_INDICATORS
|
||||
|
||||
#include <Wire.h>
|
||||
#include <LiquidTWI2.h>
|
||||
#define LCD_CLASS LiquidTWI2
|
||||
LCD_CLASS lcd(LCD_I2C_ADDRESS);
|
||||
|
||||
#elif defined(LCD_I2C_TYPE_MCP23008)
|
||||
#include <Wire.h>
|
||||
#include <LiquidTWI2.h>
|
||||
#define LCD_CLASS LiquidTWI2
|
||||
LCD_CLASS lcd(LCD_I2C_ADDRESS);
|
||||
|
||||
#else
|
||||
// Standard directly connected LCD implementations
|
||||
#if LANGUAGE_CHOICE == 6
|
||||
#include "LiquidCrystalRus.h"
|
||||
#define LCD_CLASS LiquidCrystalRus
|
||||
#else
|
||||
#include <LiquidCrystal.h>
|
||||
#define LCD_CLASS LiquidCrystal
|
||||
#endif
|
||||
LCD_CLASS lcd(LCD_PINS_RS, LCD_PINS_ENABLE, LCD_PINS_D4, LCD_PINS_D5,LCD_PINS_D6,LCD_PINS_D7); //RS,Enable,D4,D5,D6,D7
|
||||
#endif
|
||||
|
||||
/* Custom characters defined in the first 8 characters of the LCD */
|
||||
|
@ -25,7 +204,6 @@
|
|||
#define LCD_STR_CLOCK "\x07"
|
||||
#define LCD_STR_ARROW_RIGHT "\x7E" /* from the default character set */
|
||||
|
||||
LCD_CLASS lcd(LCD_PINS_RS, LCD_PINS_ENABLE, LCD_PINS_D4, LCD_PINS_D5,LCD_PINS_D6,LCD_PINS_D7); //RS,Enable,D4,D5,D6,D7
|
||||
static void lcd_implementation_init()
|
||||
{
|
||||
byte bedTemp[8] =
|
||||
|
@ -111,7 +289,27 @@ static void lcd_implementation_init()
|
|||
B00000,
|
||||
B00000
|
||||
}; //thanks Sonny Mounicou
|
||||
|
||||
#if defined(LCDI2C_TYPE_PCF8575)
|
||||
lcd.begin(LCD_WIDTH, LCD_HEIGHT);
|
||||
#ifdef LCD_I2C_PIN_BL
|
||||
lcd.setBacklightPin(LCD_I2C_PIN_BL,POSITIVE);
|
||||
lcd.setBacklight(HIGH);
|
||||
#endif
|
||||
|
||||
#elif defined(LCD_I2C_TYPE_MCP23017)
|
||||
lcd.setMCPType(LTI_TYPE_MCP23017);
|
||||
lcd.begin(LCD_WIDTH, LCD_HEIGHT);
|
||||
lcd.setBacklight(0); //set all the LEDs off to begin with
|
||||
|
||||
#elif defined(LCD_I2C_TYPE_MCP23008)
|
||||
lcd.setMCPType(LTI_TYPE_MCP23008);
|
||||
lcd.begin(LCD_WIDTH, LCD_HEIGHT);
|
||||
|
||||
#else
|
||||
lcd.begin(LCD_WIDTH, LCD_HEIGHT);
|
||||
#endif
|
||||
|
||||
lcd.createChar(LCD_STR_BEDTEMP[0], bedTemp);
|
||||
lcd.createChar(LCD_STR_DEGREE[0], degree);
|
||||
lcd.createChar(LCD_STR_THERMOMETER[0], thermometer);
|
||||
|
@ -299,9 +497,9 @@ static void lcd_implementation_drawmenu_generic(uint8_t row, const char* pstr, c
|
|||
char c;
|
||||
//Use all characters in narrow LCDs
|
||||
#if LCD_WIDTH < 20
|
||||
uint8_t n = LCD_WIDTH - 1 - 1;
|
||||
uint8_t n = LCD_WIDTH - 1 - 1;
|
||||
#else
|
||||
uint8_t n = LCD_WIDTH - 1 - 2;
|
||||
uint8_t n = LCD_WIDTH - 1 - 2;
|
||||
#endif
|
||||
lcd.setCursor(0, row);
|
||||
lcd.print(pre_char);
|
||||
|
@ -321,9 +519,9 @@ static void lcd_implementation_drawmenu_setting_edit_generic(uint8_t row, const
|
|||
char c;
|
||||
//Use all characters in narrow LCDs
|
||||
#if LCD_WIDTH < 20
|
||||
uint8_t n = LCD_WIDTH - 1 - 1 - strlen(data);
|
||||
uint8_t n = LCD_WIDTH - 1 - 1 - strlen(data);
|
||||
#else
|
||||
uint8_t n = LCD_WIDTH - 1 - 2 - strlen(data);
|
||||
uint8_t n = LCD_WIDTH - 1 - 2 - strlen(data);
|
||||
#endif
|
||||
lcd.setCursor(0, row);
|
||||
lcd.print(pre_char);
|
||||
|
@ -343,9 +541,9 @@ static void lcd_implementation_drawmenu_setting_edit_generic_P(uint8_t row, cons
|
|||
char c;
|
||||
//Use all characters in narrow LCDs
|
||||
#if LCD_WIDTH < 20
|
||||
uint8_t n = LCD_WIDTH - 1 - 1 - strlen_P(data);
|
||||
uint8_t n = LCD_WIDTH - 1 - 1 - strlen_P(data);
|
||||
#else
|
||||
uint8_t n = LCD_WIDTH - 1 - 2 - strlen_P(data);
|
||||
uint8_t n = LCD_WIDTH - 1 - 2 - strlen_P(data);
|
||||
#endif
|
||||
lcd.setCursor(0, row);
|
||||
lcd.print(pre_char);
|
||||
|
@ -402,9 +600,9 @@ void lcd_implementation_drawedit(const char* pstr, char* value)
|
|||
lcd_printPGM(pstr);
|
||||
lcd.print(':');
|
||||
#if LCD_WIDTH < 20
|
||||
lcd.setCursor(LCD_WIDTH - strlen(value), 1);
|
||||
lcd.setCursor(LCD_WIDTH - strlen(value), 1);
|
||||
#else
|
||||
lcd.setCursor(LCD_WIDTH -1 - strlen(value), 1);
|
||||
lcd.setCursor(LCD_WIDTH -1 - strlen(value), 1);
|
||||
#endif
|
||||
lcd.print(value);
|
||||
}
|
||||
|
@ -501,15 +699,50 @@ static void lcd_implementation_drawmenu_sddirectory(uint8_t row, const char* pst
|
|||
|
||||
static void lcd_implementation_quick_feedback()
|
||||
{
|
||||
#if BEEPER > -1
|
||||
#ifdef LCD_USE_I2C_BUZZER
|
||||
lcd.buzz(60,1000/6);
|
||||
#elif defined(BEEPER) && BEEPER > -1
|
||||
SET_OUTPUT(BEEPER);
|
||||
for(int8_t i=0;i<10;i++)
|
||||
{
|
||||
WRITE(BEEPER,HIGH);
|
||||
delay(3);
|
||||
WRITE(BEEPER,LOW);
|
||||
delay(3);
|
||||
WRITE(BEEPER,HIGH);
|
||||
delay(3);
|
||||
WRITE(BEEPER,LOW);
|
||||
delay(3);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef LCD_HAS_STATUS_INDICATORS
|
||||
static void lcd_implementation_update_indicators()
|
||||
{
|
||||
#if defined(LCD_I2C_PANELOLU2) || defined(LCD_I2C_VIKI)
|
||||
//set the LEDS - referred to as backlights by the LiquidTWI2 library
|
||||
static uint8_t ledsprev = 0;
|
||||
uint8_t leds = 0;
|
||||
if (target_temperature_bed > 0) leds |= LED_A;
|
||||
if (target_temperature[0] > 0) leds |= LED_B;
|
||||
if (fanSpeed) leds |= LED_C;
|
||||
#if EXTRUDERS > 1
|
||||
if (target_temperature[1] > 0) leds |= LED_C;
|
||||
#endif
|
||||
if (leds != ledsprev) {
|
||||
lcd.setBacklight(leds);
|
||||
ledsprev = leds;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef LCD_HAS_SLOW_BUTTONS
|
||||
static uint8_t lcd_implementation_read_slow_buttons()
|
||||
{
|
||||
#ifdef LCD_I2C_TYPE_MCP23017
|
||||
// Reading these buttons this is likely to be too slow to call inside interrupt context
|
||||
// so they are called during normal lcd_update
|
||||
return lcd.readButtons() << B_I2C_BTN_OFFSET;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif//ULTRA_LCD_IMPLEMENTATION_HITACHI_HD44780_H
|
||||
|
|
Loading…
Reference in a new issue