Allow POWER_SUPPLY 0 for no power switch

master
Scott Lahteine 10 years ago
parent baa6787393
commit 2faed961ce

@ -265,16 +265,15 @@
#ifndef POWER_SUPPLY #ifndef POWER_SUPPLY
#define POWER_SUPPLY 1 #define POWER_SUPPLY 1
#endif #endif
// 1 = ATX #if (POWER_SUPPLY == 1) // 1 = ATX
#if (POWER_SUPPLY == 1)
#define PS_ON_AWAKE LOW #define PS_ON_AWAKE LOW
#define PS_ON_ASLEEP HIGH #define PS_ON_ASLEEP HIGH
#endif #endif
// 2 = X-Box 360 203W #if (POWER_SUPPLY == 2) // 2 = X-Box 360 203W
#if (POWER_SUPPLY == 2)
#define PS_ON_AWAKE HIGH #define PS_ON_AWAKE HIGH
#define PS_ON_ASLEEP LOW #define PS_ON_ASLEEP LOW
#endif #endif
HAS_POWER_SWITCH = POWER_SUPPLY > 0 && defined(PS_ON_PIN) && PS_ON_PIN >= 0
/** /**
* Temp Sensor defines * Temp Sensor defines

@ -170,7 +170,7 @@
// M404 - N<dia in mm> Enter the nominal filament width (3mm, 1.75mm ) or will display nominal filament width without parameters // M404 - N<dia in mm> Enter the nominal filament width (3mm, 1.75mm ) or will display nominal filament width without parameters
// M405 - Turn on Filament Sensor extrusion control. Optional D<delay in cm> to set delay in centimeters between sensor and extruder // M405 - Turn on Filament Sensor extrusion control. Optional D<delay in cm> to set delay in centimeters between sensor and extruder
// M406 - Turn off Filament Sensor extrusion control // M406 - Turn off Filament Sensor extrusion control
// M407 - Displays measured filament diameter // M407 - Display measured filament diameter
// M500 - Store parameters in EEPROM // M500 - Store parameters in EEPROM
// M501 - Read parameters from EEPROM (if you need reset them after you changed them temporarily). // M501 - Read parameters from EEPROM (if you need reset them after you changed them temporarily).
// M502 - Revert to the default "factory settings". You still need to store them in EEPROM afterwards if you want to. // M502 - Revert to the default "factory settings". You still need to store them in EEPROM afterwards if you want to.
@ -311,13 +311,13 @@ bool cancel_heatup = false;
#ifdef FILAMENT_SENSOR #ifdef FILAMENT_SENSOR
//Variables for Filament Sensor input //Variables for Filament Sensor input
float filament_width_nominal=DEFAULT_NOMINAL_FILAMENT_DIA; //Set nominal filament width, can be changed with M404 float filament_width_nominal = DEFAULT_NOMINAL_FILAMENT_DIA; //Set nominal filament width, can be changed with M404
bool filament_sensor=false; //M405 turns on filament_sensor control, M406 turns it off bool filament_sensor = false; //M405 turns on filament_sensor control, M406 turns it off
float filament_width_meas=DEFAULT_MEASURED_FILAMENT_DIA; //Stores the measured filament diameter float filament_width_meas = DEFAULT_MEASURED_FILAMENT_DIA; //Stores the measured filament diameter
signed char measurement_delay[MAX_MEASUREMENT_DELAY+1]; //ring buffer to delay measurement store extruder factor after subtracting 100 signed char measurement_delay[MAX_MEASUREMENT_DELAY+1]; //ring buffer to delay measurement store extruder factor after subtracting 100
int delay_index1=0; //index into ring buffer int delay_index1 = 0; //index into ring buffer
int delay_index2=-1; //index into ring buffer - set to -1 on startup to indicate ring buffer needs to be initialized int delay_index2 = -1; //index into ring buffer - set to -1 on startup to indicate ring buffer needs to be initialized
float delay_dist=0; //delay distance counter float delay_dist = 0; //delay distance counter
int meas_delay_cm = MEASUREMENT_DELAY_CM; //distance delay setting int meas_delay_cm = MEASUREMENT_DELAY_CM; //distance delay setting
#endif #endif
@ -516,7 +516,7 @@ void setup_powerhold()
#if defined(SUICIDE_PIN) && SUICIDE_PIN > -1 #if defined(SUICIDE_PIN) && SUICIDE_PIN > -1
OUT_WRITE(SUICIDE_PIN, HIGH); OUT_WRITE(SUICIDE_PIN, HIGH);
#endif #endif
#if defined(PS_ON_PIN) && PS_ON_PIN > -1 #if HAS_POWER_SWITCH
#if defined(PS_DEFAULT_OFF) #if defined(PS_DEFAULT_OFF)
OUT_WRITE(PS_ON_PIN, PS_ON_ASLEEP); OUT_WRITE(PS_ON_PIN, PS_ON_ASLEEP);
#else #else
@ -3291,7 +3291,7 @@ inline void gcode_M140() {
if (code_seen('S')) setTargetBed(code_value()); if (code_seen('S')) setTargetBed(code_value());
} }
#if defined(PS_ON_PIN) && PS_ON_PIN > -1 #if HAS_POWER_SWITCH
/** /**
* M80: Turn on Power Supply * M80: Turn on Power Supply
@ -3313,12 +3313,10 @@ inline void gcode_M140() {
#endif #endif
} }
#endif // PS_ON_PIN /**
/**
* M81: Turn off Power Supply * M81: Turn off Power Supply
*/ */
inline void gcode_M81() { inline void gcode_M81() {
disable_heater(); disable_heater();
st_synchronize(); st_synchronize();
disable_e0(); disable_e0();
@ -3331,7 +3329,7 @@ inline void gcode_M81() {
#if defined(SUICIDE_PIN) && SUICIDE_PIN > -1 #if defined(SUICIDE_PIN) && SUICIDE_PIN > -1
st_synchronize(); st_synchronize();
suicide(); suicide();
#elif defined(PS_ON_PIN) && PS_ON_PIN > -1 #elif HAS_POWER_SWITCH
OUT_WRITE(PS_ON_PIN, PS_ON_ASLEEP); OUT_WRITE(PS_ON_PIN, PS_ON_ASLEEP);
#endif #endif
#ifdef ULTIPANEL #ifdef ULTIPANEL
@ -3339,7 +3337,9 @@ inline void gcode_M81() {
LCD_MESSAGEPGM(MACHINE_NAME " " MSG_OFF "."); LCD_MESSAGEPGM(MACHINE_NAME " " MSG_OFF ".");
lcd_update(); lcd_update();
#endif #endif
} }
#endif // PS_ON_PIN
/** /**
* M82: Set E codes absolute (default) * M82: Set E codes absolute (default)

@ -616,6 +616,7 @@ static void lcd_prepare_menu() {
MENU_ITEM(gcode, MSG_AUTO_HOME, PSTR("G28")); MENU_ITEM(gcode, MSG_AUTO_HOME, PSTR("G28"));
MENU_ITEM(function, MSG_SET_HOME_OFFSETS, lcd_set_home_offsets); MENU_ITEM(function, MSG_SET_HOME_OFFSETS, lcd_set_home_offsets);
//MENU_ITEM(gcode, MSG_SET_ORIGIN, PSTR("G92 X0 Y0 Z0")); //MENU_ITEM(gcode, MSG_SET_ORIGIN, PSTR("G92 X0 Y0 Z0"));
#if TEMP_SENSOR_0 != 0 #if TEMP_SENSOR_0 != 0
#if TEMP_SENSOR_1 != 0 || TEMP_SENSOR_2 != 0 || TEMP_SENSOR_3 != 0 || TEMP_SENSOR_BED != 0 #if TEMP_SENSOR_1 != 0 || TEMP_SENSOR_2 != 0 || TEMP_SENSOR_3 != 0 || TEMP_SENSOR_BED != 0
MENU_ITEM(submenu, MSG_PREHEAT_PLA, lcd_preheat_pla_menu); MENU_ITEM(submenu, MSG_PREHEAT_PLA, lcd_preheat_pla_menu);
@ -625,15 +626,16 @@ static void lcd_prepare_menu() {
MENU_ITEM(function, MSG_PREHEAT_ABS, lcd_preheat_abs0); MENU_ITEM(function, MSG_PREHEAT_ABS, lcd_preheat_abs0);
#endif #endif
#endif #endif
MENU_ITEM(function, MSG_COOLDOWN, lcd_cooldown); MENU_ITEM(function, MSG_COOLDOWN, lcd_cooldown);
#if defined(POWER_SUPPLY) && POWER_SUPPLY > 0 && defined(PS_ON_PIN) && PS_ON_PIN > -1
if (powersupply) { #if HAS_POWER_SWITCH
if (powersupply)
MENU_ITEM(gcode, MSG_SWITCH_PS_OFF, PSTR("M81")); MENU_ITEM(gcode, MSG_SWITCH_PS_OFF, PSTR("M81"));
} else
else {
MENU_ITEM(gcode, MSG_SWITCH_PS_ON, PSTR("M80")); MENU_ITEM(gcode, MSG_SWITCH_PS_ON, PSTR("M80"));
}
#endif #endif
MENU_ITEM(submenu, MSG_MOVE_AXIS, lcd_move_menu); MENU_ITEM(submenu, MSG_MOVE_AXIS, lcd_move_menu);
#if defined(MANUAL_BED_LEVELING) #if defined(MANUAL_BED_LEVELING)
@ -1338,7 +1340,7 @@ void lcd_update() {
} }
lastEncoderMovementMillis = ms; lastEncoderMovementMillis = ms;
} } // encoderRateMultiplierEnabled
#endif //ENCODER_RATE_MULTIPLIER #endif //ENCODER_RATE_MULTIPLIER
lcdDrawUpdate = 1; lcdDrawUpdate = 1;
@ -1541,70 +1543,62 @@ bool lcd_clicked() { return LCD_CLICKED; }
#endif //ULTIPANEL #endif //ULTIPANEL
/********************************/ /*********************************/
/** Float conversion utilities **/ /** Number to string conversion **/
/********************************/ /*********************************/
// convert float to string with +123.4 format
char conv[8]; char conv[8];
char *ftostr3(const float &x)
{ // Convert float to string with +123.4 format
char *ftostr3(const float &x) {
return itostr3((int)x); return itostr3((int)x);
} }
char *itostr2(const uint8_t &x) // Convert int to string with 12 format
{ char *itostr2(const uint8_t &x) {
//sprintf(conv,"%5.1f",x); //sprintf(conv,"%5.1f",x);
int xx=x; int xx = x;
conv[0]=(xx/10)%10+'0'; conv[0] = (xx / 10) % 10 + '0';
conv[1]=(xx)%10+'0'; conv[1] = xx % 10 + '0';
conv[2]=0; conv[2] = 0;
return conv; return conv;
} }
// Convert float to string with 123.4 format, dropping sign // Convert float to string with +123.4 format
char *ftostr31(const float &x) char *ftostr31(const float &x) {
{ int xx = abs(x * 10);
int xx=x*10; conv[0] = (x >= 0) ? '+' : '-';
conv[0]=(xx>=0)?'+':'-'; conv[1] = (xx / 1000) % 10 + '0';
xx=abs(xx); conv[2] = (xx / 100) % 10 + '0';
conv[1]=(xx/1000)%10+'0'; conv[3] = (xx / 10) % 10 + '0';
conv[2]=(xx/100)%10+'0'; conv[4] = '.';
conv[3]=(xx/10)%10+'0'; conv[5] = xx % 10 + '0';
conv[4]='.'; conv[6] = 0;
conv[5]=(xx)%10+'0';
conv[6]=0;
return conv; return conv;
} }
// Convert float to string with 123.4 format // Convert float to string with 123.4 format, dropping sign
char *ftostr31ns(const float &x) char *ftostr31ns(const float &x) {
{ int xx = abs(x * 10);
int xx=x*10; conv[0] = (xx / 1000) % 10 + '0';
//conv[0]=(xx>=0)?'+':'-'; conv[1] = (xx / 100) % 10 + '0';
xx=abs(xx); conv[2] = (xx / 10) % 10 + '0';
conv[0]=(xx/1000)%10+'0'; conv[3] = '.';
conv[1]=(xx/100)%10+'0'; conv[4] = xx % 10 + '0';
conv[2]=(xx/10)%10+'0'; conv[5] = 0;
conv[3]='.';
conv[4]=(xx)%10+'0';
conv[5]=0;
return conv; return conv;
} }
char *ftostr32(const float &x) // Convert float to string with 123.4 format
{ char *ftostr32(const float &x) {
long xx=x*100; long xx = abs(x * 100);
if (xx >= 0) conv[0] = x >= 0 ? (xx / 10000) % 10 + '0' : '-';
conv[0]=(xx/10000)%10+'0'; conv[1] = (xx / 1000) % 10 + '0';
else conv[2] = (xx / 100) % 10 + '0';
conv[0]='-'; conv[3] = '.';
xx=abs(xx); conv[4] = (xx / 10) % 10 + '0';
conv[1]=(xx/1000)%10+'0'; conv[5] = xx % 10 + '0';
conv[2]=(xx/100)%10+'0'; conv[6] = 0;
conv[3]='.';
conv[4]=(xx/10)%10+'0';
conv[5]=(xx)%10+'0';
conv[6]=0;
return conv; return conv;
} }
@ -1625,7 +1619,7 @@ char *ftostr43(const float &x)
return conv; return conv;
} }
//Float to string with 1.23 format // Convert float to string with 1.23 format
char *ftostr12ns(const float &x) char *ftostr12ns(const float &x)
{ {
long xx=x*100; long xx=x*100;
@ -1639,7 +1633,7 @@ char *ftostr12ns(const float &x)
return conv; return conv;
} }
// convert float to space-padded string with -_23.4_ format // Convert float to space-padded string with -_23.4_ format
char *ftostr32sp(const float &x) { char *ftostr32sp(const float &x) {
long xx = abs(x * 100); long xx = abs(x * 100);
uint8_t dig; uint8_t dig;
@ -1685,58 +1679,51 @@ char *ftostr32sp(const float &x) {
return conv; return conv;
} }
char *itostr31(const int &xx) // Convert int to lj string with +123.0 format
{ char *itostr31(const int &x) {
conv[0]=(xx>=0)?'+':'-'; conv[0] = x >= 0 ? '+' : '-';
conv[1]=(xx/1000)%10+'0'; int xx = abs(x);
conv[2]=(xx/100)%10+'0'; conv[1] = (xx / 100) % 10 + '0';
conv[3]=(xx/10)%10+'0'; conv[2] = (xx / 10) % 10 + '0';
conv[4]='.'; conv[3] = xx % 10 + '0';
conv[5]=(xx)%10+'0'; conv[4] = '.';
conv[6]=0; conv[5] = '0';
conv[6] = 0;
return conv; return conv;
} }
// Convert int to rj string with 123 or -12 format // Convert int to rj string with 123 or -12 format
char *itostr3(const int &x) char *itostr3(const int &x) {
{
int xx = x; int xx = x;
if (xx < 0) { if (xx < 0) {
conv[0]='-'; conv[0] = '-';
xx = -xx; xx = -xx;
} else if (xx >= 100) }
conv[0]=(xx/100)%10+'0';
else
conv[0]=' ';
if (xx >= 10)
conv[1]=(xx/10)%10+'0';
else else
conv[1]=' '; conv[0] = xx >= 100 ? (xx / 100) % 10 + '0' : ' ';
conv[2]=(xx)%10+'0';
conv[3]=0; conv[1] = xx >= 10 ? (xx / 10) % 10 + '0' : ' ';
conv[2] = xx % 10 + '0';
conv[3] = 0;
return conv; return conv;
} }
// Convert int to lj string with 123 format // Convert int to lj string with 123 format
char *itostr3left(const int &xx) char *itostr3left(const int &xx) {
{ if (xx >= 100) {
if (xx >= 100) conv[0] = (xx / 100) % 10 + '0';
{ conv[1] = (xx / 10) % 10 + '0';
conv[0]=(xx/100)%10+'0'; conv[2] = xx % 10 + '0';
conv[1]=(xx/10)%10+'0'; conv[3] = 0;
conv[2]=(xx)%10+'0'; }
conv[3]=0; else if (xx >= 10) {
conv[0] = (xx / 10) % 10 + '0';
conv[1] = xx % 10 + '0';
conv[2] = 0;
} }
else if (xx >= 10) else {
{ conv[0] = xx % 10 + '0';
conv[0]=(xx/10)%10+'0'; conv[1] = 0;
conv[1]=(xx)%10+'0';
conv[2]=0;
}
else
{
conv[0]=(xx)%10+'0';
conv[1]=0;
} }
return conv; return conv;
} }
@ -1764,34 +1751,30 @@ char *ftostr5(const float &x) {
} }
// Convert float to string with +1234.5 format // Convert float to string with +1234.5 format
char *ftostr51(const float &x) char *ftostr51(const float &x) {
{ long xx = abs(x * 10);
long xx=x*10; conv[0] = (x >= 0) ? '+' : '-';
conv[0]=(xx>=0)?'+':'-'; conv[1] = (xx / 10000) % 10 + '0';
xx=abs(xx); conv[2] = (xx / 1000) % 10 + '0';
conv[1]=(xx/10000)%10+'0'; conv[3] = (xx / 100) % 10 + '0';
conv[2]=(xx/1000)%10+'0'; conv[4] = (xx / 10) % 10 + '0';
conv[3]=(xx/100)%10+'0'; conv[5] = '.';
conv[4]=(xx/10)%10+'0'; conv[6] = xx % 10 + '0';
conv[5]='.'; conv[7] = 0;
conv[6]=(xx)%10+'0';
conv[7]=0;
return conv; return conv;
} }
// Convert float to string with +123.45 format // Convert float to string with +123.45 format
char *ftostr52(const float &x) char *ftostr52(const float &x) {
{ conv[0] = (x >= 0) ? '+' : '-';
long xx=x*100; long xx = abs(x * 100);
conv[0]=(xx>=0)?'+':'-'; conv[1] = (xx / 10000) % 10 + '0';
xx=abs(xx); conv[2] = (xx / 1000) % 10 + '0';
conv[1]=(xx/10000)%10+'0'; conv[3] = (xx / 100) % 10 + '0';
conv[2]=(xx/1000)%10+'0'; conv[4] = '.';
conv[3]=(xx/100)%10+'0'; conv[5] = (xx / 10) % 10 + '0';
conv[4]='.'; conv[6] = xx % 10 + '0';
conv[5]=(xx/10)%10+'0'; conv[7] = 0;
conv[6]=(xx)%10+'0';
conv[7]=0;
return conv; return conv;
} }

Loading…
Cancel
Save