Skip to content

Commit

Permalink
added fan control into menu
Browse files Browse the repository at this point in the history
  • Loading branch information
bkubicek committed Oct 21, 2011
1 parent ad4ae7c commit 743f775
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Marlin/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ bool axis_relative_modes[] = {false, false, false, false};
#define SMOOTHFACTOR 5.0
float current_raw_average=0;

#define PIDTEMP
//#define PIDTEMP
#ifdef PIDTEMP
//#define PID_DEBUG 1 // Sends debug data to the serial port.
//#define PID_OPENLOOP 1 // Puts PID in open loop. M104 sets the output power in %
Expand Down
7 changes: 5 additions & 2 deletions Marlin/Marlin.pde
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ unsigned long previous_millis_heater, previous_millis_bed_heater;
bool relative_mode = false; //Determines Absolute or Relative Coordinates
bool relative_mode_e = false; //Determines Absolute or Relative E Codes while in Absolute Coordinates mode. E is always relative in Relative Coordinates mode.
unsigned long axis_steps_per_sqr_second[NUM_AXIS];
uint8_t fanpwm=0;

volatile int feedmultiply=100; //100->1 200->2
// comm variables
Expand Down Expand Up @@ -1027,12 +1028,14 @@ inline void process_commands()
case 106: //M106 Fan On
if (code_seen('S')){
digitalWrite(FAN_PIN,HIGH);
analogWrite(FAN_PIN, constrain(code_value(),0,255) );
fanpwm=constrain(code_value(),0,255);
analogWrite(FAN_PIN, fanpwm);
}
else
{
digitalWrite(FAN_PIN,HIGH);
analogWrite(FAN_PIN, 255);
fanpwm=255;
analogWrite(FAN_PIN, fanpwm);
}
break;
case 107: //M107 Fan Off
Expand Down
40 changes: 39 additions & 1 deletion Marlin/ultralcd.pde
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ void MainMenu::showPrepare()
}
}
enum {
ItemC_exit, ItemC_nozzle, ItemC_acc, ItemC_xyjerk,
ItemC_exit, ItemC_nozzle, ItemC_fan, ItemC_acc, ItemC_xyjerk,
ItemC_vmaxx, ItemC_vmaxy, ItemC_vmaxz, ItemC_vmaxe,
ItemC_vmin,
ItemC_amaxx, ItemC_amaxy, ItemC_amaxz, ItemC_amaxe,
Expand Down Expand Up @@ -560,6 +560,44 @@ void MainMenu::showControl()
}
}
}break;

case ItemC_fan:
{
if(force_lcd_update)
{
lcd.setCursor(0,line);lcd.print(" Fan speed:");
lcd.setCursor(13,line);lcd.print(ftostr3(fanpwm));
}

if((activeline==line) )
{
if(CLICKED) //nalogWrite(FAN_PIN, fanpwm);
{
linechanging=!linechanging;
if(linechanging)
{
encoderpos=fanpwm;
}
else
{
fanpwm = constrain(encoderpos,0,255);
encoderpos=fanpwm;
analogWrite(FAN_PIN, fanpwm);

beepshort();
}
BLOCK;
}
if(linechanging)
{
if(encoderpos<0) encoderpos=0;
if(encoderpos>255) encoderpos=255;
fanpwm=encoderpos;
analogWrite(FAN_PIN, fanpwm);
lcd.setCursor(13,line);lcd.print(itostr3(encoderpos));
}
}
}break;
case ItemC_acc:
{
if(force_lcd_update)
Expand Down

0 comments on commit 743f775

Please sign in to comment.