Merge branch 'Marlin_v1' of https://github.com/ErikZalm/Marlin into Marlin_v1

This commit is contained in:
bkubicek 2013-10-22 10:08:21 +02:00
commit 2fb2a0a119
11 changed files with 989 additions and 767 deletions

29
Marlin/BlinkM.cpp Normal file
View File

@ -0,0 +1,29 @@
/*
BlinkM.cpp - Library for controlling a BlinkM over i2c
Created by Tim Koster, August 21 2013.
*/
#include "Marlin.h"
#ifdef BLINKM
#if (ARDUINO >= 100)
# include "Arduino.h"
#else
# include "WProgram.h"
#endif
#include "BlinkM.h"
void SendColors(byte red, byte grn, byte blu)
{
Wire.begin();
Wire.beginTransmission(0x09);
Wire.write('o'); //to disable ongoing script, only needs to be used once
Wire.write('n');
Wire.write(red);
Wire.write(grn);
Wire.write(blu);
Wire.endTransmission();
}
#endif //BLINKM

14
Marlin/BlinkM.h Normal file
View File

@ -0,0 +1,14 @@
/*
BlinkM.h
Library header file for BlinkM library
*/
#if (ARDUINO >= 100)
# include "Arduino.h"
#else
# include "WProgram.h"
#endif
#include "Wire.h"
void SendColors(byte red, byte grn, byte blu);

View File

@ -310,6 +310,9 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of
#define Y_PROBE_OFFSET_FROM_EXTRUDER -29
#define Z_PROBE_OFFSET_FROM_EXTRUDER -12.35
#define Z_RAISE_BEFORE_HOMING 4 // (in mm) Raise Z before homing (G28) for Probe Clearance.
// Be sure you have this distance over your Z_MAX_POS in case
#define XY_TRAVEL_SPEED 8000 // X and Y axis travel speed between probes, in mm/min
#define Z_RAISE_BEFORE_PROBING 15 //How much the extruder will be raised before traveling to the first probing point.
@ -330,12 +333,7 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of
#define Y_MAX_POS 205
#define Y_MIN_POS 0
#define Z_MAX_POS 200
#ifndef ENABLE_AUTO_BED_LEVELING
#define Z_MIN_POS 0
#else
#define Z_MIN_POS (-1*Z_PROBE_OFFSET_FROM_EXTRUDER) //With Auto Bed Leveling, the Z_MIN MUST have the same distance as Z_PROBE
#endif
#define X_MAX_LENGTH (X_MAX_POS - X_MIN_POS)
#define Y_MAX_LENGTH (Y_MAX_POS - Y_MIN_POS)
@ -542,6 +540,11 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of
// Increase the FAN pwm frequency. Removes the PWM noise but increases heating in the FET/Arduino
//#define FAST_PWM_FAN
// Temperature status leds that display the hotend and bet temperature.
// If alle hotends and bed temperature and temperature setpoint are < 54C then the BLUE led is on.
// Otherwise the RED led is on. There is 1C hysteresis.
//#define TEMP_STAT_LEDS
// Use software PWM to drive the fan, as for the heaters. This uses a very low frequency
// which is not ass annoying as with the hardware PWM. On the other hand, if this frequency
// is too low, you should also increment SOFT_PWM_SCALE.
@ -563,6 +566,9 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of
// Support for the BariCUDA Paste Extruder.
//#define BARICUDA
//define BlinkM/CyzRgb Support
//#define BLINKM
/*********************************************************************\
* R/C SERVO support
* Sponsored by TrinityLabs, Reworked by codexmas

View File

@ -40,6 +40,10 @@
#define AUTOTEMP_OLDWEIGHT 0.98
#endif
//Show Temperature ADC value
//The M105 command return, besides traditional information, the ADC value read from temperature sensors.
//#define SHOW_TEMP_ADC_VALUES
// extruder run-out prevention.
//if the machine is idle, and the temperature over MINTEMP, every couple of SECONDS some filament is extruded
//#define EXTRUDER_RUNOUT_PREVENT
@ -146,6 +150,21 @@
#define EXTRUDERS 1
#endif
// Same again but for Y Axis.
//#define Y_DUAL_STEPPER_DRIVERS
// Define if the two Y drives need to rotate in opposite directions
#define INVERT_Y2_VS_Y_DIR true
#ifdef Y_DUAL_STEPPER_DRIVERS
#undef EXTRUDERS
#define EXTRUDERS 1
#endif
#ifdef Z_DUAL_STEPPER_DRIVERS && Y_DUAL_STEPPER_DRIVERS
#error "You cannot have dual drivers for both Y and Z"
#endif
// Enable this for dual x-carriage printers.
// A dual x-carriage design has the advantage that the inactive extruder can be parked which
// prevents hot-end ooze contaminating the print. It also reduces the weight of each x-carriage

View File

@ -109,8 +109,13 @@ void manage_inactivity();
#endif
#if defined(Y_ENABLE_PIN) && Y_ENABLE_PIN > -1
#define enable_y() WRITE(Y_ENABLE_PIN, Y_ENABLE_ON)
#define disable_y() WRITE(Y_ENABLE_PIN,!Y_ENABLE_ON)
#ifdef Y_DUAL_STEPPER_DRIVERS
#define enable_y() { WRITE(Y_ENABLE_PIN, Y_ENABLE_ON); WRITE(Y2_ENABLE_PIN, Y_ENABLE_ON); }
#define disable_y() { WRITE(Y_ENABLE_PIN,!Y_ENABLE_ON); WRITE(Y2_ENABLE_PIN, !Y_ENABLE_ON); }
#else
#define enable_y() WRITE(Y_ENABLE_PIN, Y_ENABLE_ON)
#define disable_y() WRITE(Y_ENABLE_PIN,!Y_ENABLE_ON)
#endif
#else
#define enable_y() ;
#define disable_y() ;

View File

@ -44,6 +44,11 @@
#include "language.h"
#include "pins_arduino.h"
#ifdef BLINKM
#include "BlinkM.h"
#include "Wire.h"
#endif
#if NUM_SERVOS > 0
#include "Servo.h"
#endif
@ -118,6 +123,7 @@
// 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
// M150 - Set BlinkM Colour Output R: Red<0-255> U(!): Green<0-255> B: Blue<0-255> over i2c, G for green does not work.
// M190 - Sxxx Wait for bed current temp to reach target temp. Waits only when heating
// Rxxx Wait for bed current temp to reach target temp. Waits when heating and cooling
// M200 - Set filament diameter
@ -935,19 +941,28 @@ static void homeaxis(int axis) {
axis_home_dir = x_home_dir(active_extruder);
#endif
current_position[axis] = 0;
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
// Engage Servo endstop if enabled
#ifdef SERVO_ENDSTOPS
#if defined (ENABLE_AUTO_BED_LEVELING) && (PROBE_SERVO_DEACTIVATION_DELAY > 0)
if (axis==Z_AXIS) engage_z_probe();
else
#endif
#if defined (ENABLE_AUTO_BED_LEVELING) && (PROBE_SERVO_DEACTIVATION_DELAY > 0)
if (axis==Z_AXIS) {
#if defined (Z_RAISE_BEFORE_HOMING) && (Z_RAISE_BEFORE_HOMING > 0)
destination[axis] = Z_RAISE_BEFORE_HOMING * axis_home_dir * (-1); // Set destination away from bed
feedrate = max_feedrate[axis];
plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate, active_extruder);
st_synchronize();
#endif
engage_z_probe();
}
else
#endif
if (servo_endstops[axis] > -1) {
servos[servo_endstops[axis]].write(servo_endstop_angles[axis * 2]);
}
#endif
current_position[axis] = 0;
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
destination[axis] = 1.5 * max_length(axis) * axis_home_dir;
feedrate = homing_feedrate[axis];
plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder);
@ -1213,6 +1228,9 @@ void process_commands()
current_position[Z_AXIS]=code_value()+add_homeing[2];
}
}
#ifdef ENABLE_AUTO_BED_LEVELING
current_position[Z_AXIS] -= Z_PROBE_OFFSET_FROM_EXTRUDER; //Add Z_Probe offset (the distance is negative)
#endif
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
#endif // else DELTA
@ -1607,6 +1625,23 @@ void process_commands()
SERIAL_PROTOCOLPGM(" B@:");
SERIAL_PROTOCOL(getHeaterPower(-1));
#ifdef SHOW_TEMP_ADC_VALUES
#if defined(TEMP_BED_PIN) && TEMP_BED_PIN > -1
SERIAL_PROTOCOLPGM(" ADC B:");
SERIAL_PROTOCOL_F(degBed(),1);
SERIAL_PROTOCOLPGM("C->");
SERIAL_PROTOCOL_F(rawBedTemp()/OVERSAMPLENR,0);
#endif
for (int8_t cur_extruder = 0; cur_extruder < EXTRUDERS; ++cur_extruder) {
SERIAL_PROTOCOLPGM(" T");
SERIAL_PROTOCOL(cur_extruder);
SERIAL_PROTOCOLPGM(":");
SERIAL_PROTOCOL_F(degHotend(cur_extruder),1);
SERIAL_PROTOCOLPGM("C->");
SERIAL_PROTOCOL_F(rawHotendTemp(cur_extruder)/OVERSAMPLENR,0);
}
#endif
SERIAL_PROTOCOLLN("");
return;
break;
@ -1943,6 +1978,21 @@ void process_commands()
#endif
break;
//TODO: update for all axis, use for loop
#ifdef BLINKM
case 150: // M150
{
byte red;
byte grn;
byte blu;
if(code_seen('R')) red = code_value();
if(code_seen('U')) grn = code_value();
if(code_seen('B')) blu = code_value();
SendColors(red,grn,blu);
}
break;
#endif //BLINKM
case 201: // M201
for(int8_t i=0; i < NUM_AXIS; i++)
{
@ -2925,6 +2975,39 @@ void controllerFan()
}
#endif
#ifdef TEMP_STAT_LEDS
static bool blue_led = false;
static bool red_led = false;
static uint32_t stat_update = 0;
void handle_status_leds(void) {
float max_temp = 0.0;
if(millis() > stat_update) {
stat_update += 500; // Update every 0.5s
for (int8_t cur_extruder = 0; cur_extruder < EXTRUDERS; ++cur_extruder) {
max_temp = max(max_temp, degHotend(cur_extruder));
max_temp = max(max_temp, degTargetHotend(cur_extruder));
}
#if defined(TEMP_BED_PIN) && TEMP_BED_PIN > -1
max_temp = max(max_temp, degTargetBed());
max_temp = max(max_temp, degBed());
#endif
if((max_temp > 55.0) && (red_led == false)) {
digitalWrite(STAT_LED_RED, 1);
digitalWrite(STAT_LED_BLUE, 0);
red_led = true;
blue_led = false;
}
if((max_temp < 54.0) && (blue_led == false)) {
digitalWrite(STAT_LED_RED, 0);
digitalWrite(STAT_LED_BLUE, 1);
red_led = false;
blue_led = true;
}
}
}
#endif
void manage_inactivity()
{
if( (millis() - previous_millis_cmd) > max_inactive_time )
@ -2979,6 +3062,9 @@ void manage_inactivity()
prepare_move();
}
#endif
#ifdef TEMP_STAT_LEDS
handle_status_leds();
#endif
check_axes_activity();
}

View File

@ -544,6 +544,13 @@
#endif
#endif
#ifdef TEMP_STAT_LEDS
#if MOTHERBOARD == 67
#define STAT_LED_RED 6
#define STAT_LED_BLUE 11
#endif
#endif
#ifdef ULTRA_LCD
#ifdef NEWPANEL

View File

@ -383,10 +383,20 @@ ISR(TIMER1_COMPA_vect)
}
if((out_bits & (1<<Y_AXIS))!=0){
WRITE(Y_DIR_PIN, INVERT_Y_DIR);
#ifdef Y_DUAL_STEPPER_DRIVERS
WRITE(Y2_DIR_PIN, !(INVERT_Y_DIR == INVERT_Y2_VS_Y_DIR));
#endif
count_direction[Y_AXIS]=-1;
}
else{
WRITE(Y_DIR_PIN, !INVERT_Y_DIR);
#ifdef Y_DUAL_STEPPER_DRIVERS
WRITE(Y2_DIR_PIN, (INVERT_Y_DIR == INVERT_Y2_VS_Y_DIR));
#endif
count_direction[Y_AXIS]=1;
}
@ -582,9 +592,18 @@ ISR(TIMER1_COMPA_vect)
counter_y += current_block->steps_y;
if (counter_y > 0) {
WRITE(Y_STEP_PIN, !INVERT_Y_STEP_PIN);
#ifdef Y_DUAL_STEPPER_DRIVERS
WRITE(Y2_STEP_PIN, !INVERT_Y_STEP_PIN);
#endif
counter_y -= current_block->step_event_count;
count_position[Y_AXIS]+=count_direction[Y_AXIS];
WRITE(Y_STEP_PIN, INVERT_Y_STEP_PIN);
#ifdef Y_DUAL_STEPPER_DRIVERS
WRITE(Y2_STEP_PIN, INVERT_Y_STEP_PIN);
#endif
}
counter_z += current_block->steps_z;
@ -756,6 +775,10 @@ void st_init()
#endif
#if defined(Y_DIR_PIN) && Y_DIR_PIN > -1
SET_OUTPUT(Y_DIR_PIN);
#if defined(Y_DUAL_STEPPER_DRIVERS) && defined(Y2_DIR_PIN) && (Y2_DIR_PIN > -1)
SET_OUTPUT(Y2_DIR_PIN);
#endif
#endif
#if defined(Z_DIR_PIN) && Z_DIR_PIN > -1
SET_OUTPUT(Z_DIR_PIN);
@ -787,6 +810,11 @@ void st_init()
#if defined(Y_ENABLE_PIN) && Y_ENABLE_PIN > -1
SET_OUTPUT(Y_ENABLE_PIN);
if(!Y_ENABLE_ON) WRITE(Y_ENABLE_PIN,HIGH);
#if defined(Y_DUAL_STEPPER_DRIVERS) && defined(Y2_ENABLE_PIN) && (Y2_ENABLE_PIN > -1)
SET_OUTPUT(Y2_ENABLE_PIN);
if(!Y_ENABLE_ON) WRITE(Y2_ENABLE_PIN,HIGH);
#endif
#endif
#if defined(Z_ENABLE_PIN) && Z_ENABLE_PIN > -1
SET_OUTPUT(Z_ENABLE_PIN);
@ -869,6 +897,10 @@ void st_init()
#if defined(Y_STEP_PIN) && (Y_STEP_PIN > -1)
SET_OUTPUT(Y_STEP_PIN);
WRITE(Y_STEP_PIN,INVERT_Y_STEP_PIN);
#if defined(Y_DUAL_STEPPER_DRIVERS) && defined(Y2_STEP_PIN) && (Y2_STEP_PIN > -1)
SET_OUTPUT(Y2_STEP_PIN);
WRITE(Y2_STEP_PIN,INVERT_Y_STEP_PIN);
#endif
disable_y();
#endif
#if defined(Z_STEP_PIN) && (Z_STEP_PIN > -1)

View File

@ -35,6 +35,10 @@ void manage_heater(); //it is critical that this is called periodically.
// do not use these routines and variables outside of temperature.cpp
extern int target_temperature[EXTRUDERS];
extern float current_temperature[EXTRUDERS];
#ifdef SHOW_TEMP_ADC_VALUES
extern int current_temperature_raw[EXTRUDERS];
extern int current_temperature_bed_raw;
#endif
extern int target_temperature_bed;
extern float current_temperature_bed;
#ifdef TEMP_SENSOR_1_AS_REDUNDANT
@ -66,6 +70,16 @@ FORCE_INLINE float degHotend(uint8_t extruder) {
return current_temperature[extruder];
};
#ifdef SHOW_TEMP_ADC_VALUES
FORCE_INLINE float rawHotendTemp(uint8_t extruder) {
return current_temperature_raw[extruder];
};
FORCE_INLINE float rawBedTemp() {
return current_temperature_bed_raw;
};
#endif
FORCE_INLINE float degBed() {
return current_temperature_bed;
};

View File

@ -104,6 +104,7 @@ static void menu_action_setting_edit_callback_long5(const char* pstr, unsigned l
if (encoderPosition > 0x8000) encoderPosition = 0; \
if (encoderPosition / ENCODER_STEPS_PER_MENU_ITEM < currentMenuViewOffset) currentMenuViewOffset = encoderPosition / ENCODER_STEPS_PER_MENU_ITEM;\
uint8_t _lineNr = currentMenuViewOffset, _menuItemNr; \
bool wasClicked = LCD_CLICKED;\
for(uint8_t _drawLineNr = 0; _drawLineNr < LCD_HEIGHT; _drawLineNr++, _lineNr++) { \
_menuItemNr = 0;
#define MENU_ITEM(type, label, args...) do { \
@ -142,7 +143,6 @@ uint8_t currentMenuViewOffset; /* scroll offset in the current menu
uint32_t blocking_enc;
uint8_t lastEncoderBits;
uint32_t encoderPosition;
bool wasClicked;
#if (SDCARDDETECT > 0)
bool lcd_oldcardstatus;
#endif
@ -1042,7 +1042,6 @@ void lcd_update()
if (lcd_next_update_millis < millis())
{
wasClicked = LCD_CLICKED;
#ifdef ULTIPANEL
#ifdef REPRAPWORLD_KEYPAD
if (REPRAPWORLD_KEYPAD_MOVE_Z_UP) {

View File

@ -737,12 +737,23 @@ static void lcd_implementation_update_indicators()
#endif
#ifdef LCD_HAS_SLOW_BUTTONS
extern uint32_t blocking_enc;
static uint8_t lcd_implementation_read_slow_buttons()
{
#ifdef LCD_I2C_TYPE_MCP23017
uint8_t slow_buttons;
// 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;
slow_buttons = lcd.readButtons() << B_I2C_BTN_OFFSET;
#if defined(LCD_I2C_VIKI)
if(slow_buttons & (B_MI|B_RI)) { //LCD clicked
if(blocking_enc > millis()) {
slow_buttons &= ~(B_MI|B_RI); // Disable LCD clicked buttons if screen is updated
}
}
#endif
return slow_buttons;
#endif
}
#endif