better visibility of public/private/imported variables

master
Bernhard Kubicek 13 years ago
parent 977fd2b2c7
commit 72ace55e6a

@ -65,7 +65,10 @@
#include "temperature.h" #include "temperature.h"
#include "ultralcd.h" #include "ultralcd.h"
//public variables //===========================================================================
//=============================public variables ============================
//===========================================================================
unsigned long minsegmenttime; unsigned long minsegmenttime;
float max_feedrate[4]; // set the max speeds float max_feedrate[4]; // set the max speeds
float axis_steps_per_unit[4]; float axis_steps_per_unit[4];
@ -77,17 +80,23 @@ float max_xy_jerk; //speed than can be stopped at once, if i understand correctl
float max_z_jerk; float max_z_jerk;
float mintravelfeedrate; float mintravelfeedrate;
unsigned long axis_steps_per_sqr_second[NUM_AXIS]; unsigned long axis_steps_per_sqr_second[NUM_AXIS];
// The current position of the tool in absolute steps
long position[4]; //rescaled from extern when axis_steps_per_unit are changed by gcode long position[4]; //rescaled from extern when axis_steps_per_unit are changed by gcode
//private variables //===========================================================================
//=============================private variables ============================
//===========================================================================
static block_t block_buffer[BLOCK_BUFFER_SIZE]; // A ring buffer for motion instfructions static block_t block_buffer[BLOCK_BUFFER_SIZE]; // A ring buffer for motion instfructions
static volatile unsigned char block_buffer_head; // Index of the next block to be pushed static volatile unsigned char block_buffer_head; // Index of the next block to be pushed
static volatile unsigned char block_buffer_tail; // Index of the block to process now static volatile unsigned char block_buffer_tail; // Index of the block to process now
// The current position of the tool in absolute steps
//===========================================================================
//=============================functions ============================
//===========================================================================
#define ONE_MINUTE_OF_MICROSECONDS 60000000.0 #define ONE_MINUTE_OF_MICROSECONDS 60000000.0
// Calculates the distance (not time) it takes to accelerate from initial_rate to target_rate using the // Calculates the distance (not time) it takes to accelerate from initial_rate to target_rate using the

@ -32,6 +32,38 @@
#include "speed_lookuptable.h" #include "speed_lookuptable.h"
//===========================================================================
//=============================public variables ============================
//===========================================================================
block_t *current_block; // A pointer to the block currently being traced
//===========================================================================
//=============================private variables ============================
//===========================================================================
//static makes it inpossible to be called from outside of this file by extern.!
// Variables used by The Stepper Driver Interrupt
static unsigned char out_bits; // The next stepping-bits to be output
static long counter_x, // Counter variables for the bresenham line tracer
counter_y,
counter_z,
counter_e;
static unsigned long step_events_completed; // The number of step events executed in the current block
#ifdef ADVANCE
static long advance_rate, advance, final_advance = 0;
static short old_advance = 0;
static short e_steps;
#endif
static unsigned char busy = false; // TRUE when SIG_OUTPUT_COMPARE1A is being serviced. Used to avoid retriggering that handler.
static long acceleration_time, deceleration_time;
//static unsigned long accelerate_until, decelerate_after, acceleration_rate, initial_rate, final_rate, nominal_rate;
static unsigned short acc_step_rate; // needed for deccelaration start point
static char step_loops;
// if DEBUG_STEPS is enabled, M114 can be used to compare two methods of determining the X,Y,Z position of the printer. // if DEBUG_STEPS is enabled, M114 can be used to compare two methods of determining the X,Y,Z position of the printer.
// for debugging purposes only, should be disabled by default // for debugging purposes only, should be disabled by default
#ifdef DEBUG_STEPS #ifdef DEBUG_STEPS
@ -39,6 +71,10 @@
volatile int count_direction[NUM_AXIS] = { 1, 1, 1, 1}; volatile int count_direction[NUM_AXIS] = { 1, 1, 1, 1};
#endif #endif
//===========================================================================
//=============================functions ============================
//===========================================================================
// intRes = intIn1 * intIn2 >> 16 // intRes = intIn1 * intIn2 >> 16
// uses: // uses:
@ -115,27 +151,9 @@ asm volatile ( \
#define ENABLE_STEPPER_DRIVER_INTERRUPT() TIMSK1 |= (1<<OCIE1A) #define ENABLE_STEPPER_DRIVER_INTERRUPT() TIMSK1 |= (1<<OCIE1A)
#define DISABLE_STEPPER_DRIVER_INTERRUPT() TIMSK1 &= ~(1<<OCIE1A) #define DISABLE_STEPPER_DRIVER_INTERRUPT() TIMSK1 &= ~(1<<OCIE1A)
block_t *current_block; // A pointer to the block currently being traced
//static makes it inpossible to be called from outside of this file by extern.!
// Variables used by The Stepper Driver Interrupt
static unsigned char out_bits; // The next stepping-bits to be output
static long counter_x, // Counter variables for the bresenham line tracer
counter_y,
counter_z,
counter_e;
static unsigned long step_events_completed; // The number of step events executed in the current block
#ifdef ADVANCE
static long advance_rate, advance, final_advance = 0;
static short old_advance = 0;
static short e_steps;
#endif
static unsigned char busy = false; // TRUE when SIG_OUTPUT_COMPARE1A is being serviced. Used to avoid retriggering that handler.
static long acceleration_time, deceleration_time;
//static unsigned long accelerate_until, decelerate_after, acceleration_rate, initial_rate, final_rate, nominal_rate;
static unsigned short acc_step_rate; // needed for deccelaration start point
static char step_loops;
// __________________________ // __________________________

@ -38,10 +38,29 @@
#include "temperature.h" #include "temperature.h"
#include "watchdog.h" #include "watchdog.h"
//===========================================================================
//=============================public variables============================
//===========================================================================
int target_raw[3] = {0, 0, 0}; int target_raw[3] = {0, 0, 0};
int current_raw[3] = {0, 0, 0}; int current_raw[3] = {0, 0, 0};
#ifdef PIDTEMP
// probably used external
float HeaterPower;
float pid_setpoint = 0.0;
float Kp=DEFAULT_Kp;
float Ki=DEFAULT_Ki;
float Kd=DEFAULT_Kd;
float Kc=DEFAULT_Kc;
#endif //PIDTEMP
//===========================================================================
//=============================private variables============================
//===========================================================================
static bool temp_meas_ready = false; static bool temp_meas_ready = false;
static unsigned long previous_millis_heater, previous_millis_bed_heater; static unsigned long previous_millis_heater, previous_millis_bed_heater;
@ -53,7 +72,7 @@ static unsigned long previous_millis_heater, previous_millis_bed_heater;
static float pTerm; static float pTerm;
static float iTerm; static float iTerm;
static float dTerm; static float dTerm;
//int output; //int output;
static float pid_error; static float pid_error;
static float temp_iState_min; static float temp_iState_min;
static float temp_iState_max; static float temp_iState_max;
@ -61,15 +80,6 @@ static unsigned long previous_millis_heater, previous_millis_bed_heater;
static float pid_output; static float pid_output;
static bool pid_reset; static bool pid_reset;
// probably used external
float HeaterPower;
float pid_setpoint = 0.0;
float Kp=DEFAULT_Kp;
float Ki=DEFAULT_Ki;
float Kd=DEFAULT_Kd;
float Kc=DEFAULT_Kc;
#endif //PIDTEMP #endif //PIDTEMP
#ifdef WATCHPERIOD #ifdef WATCHPERIOD
@ -98,6 +108,10 @@ static unsigned long previous_millis_heater, previous_millis_bed_heater;
static int bed_maxttemp = temp2analog(BED_MAXTEMP); static int bed_maxttemp = temp2analog(BED_MAXTEMP);
#endif //BED_MAXTEMP #endif //BED_MAXTEMP
//===========================================================================
//=============================functions ============================
//===========================================================================
void manage_heater() void manage_heater()
{ {
#ifdef USE_WATCHDOG #ifdef USE_WATCHDOG
@ -545,3 +559,4 @@ ISR(TIMER0_COMPB_vect)
} }
} }

@ -1,6 +1,9 @@
#include "ultralcd.h" #include "ultralcd.h"
#ifdef ULTRA_LCD #ifdef ULTRA_LCD
//===========================================================================
//=============================imported variables============================
//===========================================================================
extern volatile int feedmultiply; extern volatile int feedmultiply;
extern volatile bool feedmultiplychanged; extern volatile bool feedmultiplychanged;
@ -8,25 +11,43 @@ extern volatile bool feedmultiplychanged;
extern long position[4]; extern long position[4];
extern CardReader card; extern CardReader card;
//===========================================================================
//=============================public variables============================
//===========================================================================
volatile char buttons=0; //the last checked buttons in a bit array.
int encoderpos=0;
short lastenc=0;
//===========================================================================
//=============================private variables============================
//===========================================================================
static char messagetext[LCD_WIDTH]=""; static char messagetext[LCD_WIDTH]="";
//return for string conversion routines
static char conv[8];
#include <LiquidCrystal.h> #include <LiquidCrystal.h>
LiquidCrystal 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 LiquidCrystal 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 unsigned long previous_millis_lcd=0; static unsigned long previous_millis_lcd=0;
static long previous_millis_buttons=0; static long previous_millis_buttons=0;
inline int intround(const float &x){return int(0.5+x);}
volatile char buttons=0; //the last checked buttons in a bit array.
int encoderpos=0;
short lastenc=0;
#ifdef NEWPANEL #ifdef NEWPANEL
static long blocking=0; static long blocking=0;
#else #else
static long blocking[8]={0,0,0,0,0,0,0,0}; static long blocking[8]={0,0,0,0,0,0,0,0};
#endif #endif
MainMenu menu;
static MainMenu menu;
//===========================================================================
//=============================functions ============================
//===========================================================================
inline int intround(const float &x){return int(0.5+x);}
void lcd_status(const char* message) void lcd_status(const char* message)
{ {
@ -1106,7 +1127,7 @@ void MainMenu::showControl()
} }
} }
#include "SdFat.h"
@ -1437,8 +1458,7 @@ void MainMenu::update()
//return for string conversion routines
static char conv[8];
// convert float to string with +123.4 format // convert float to string with +123.4 format
char *ftostr3(const float &x) char *ftostr3(const float &x)

@ -3,10 +3,37 @@
#include <avr/wdt.h> #include <avr/wdt.h>
#include <avr/interrupt.h> #include <avr/interrupt.h>
//===========================================================================
//=============================private variables ============================
//===========================================================================
static volatile uint8_t timeout_seconds=0; static volatile uint8_t timeout_seconds=0;
void(* ctrlaltdelete) (void) = 0; //does not work on my atmega2560 void(* ctrlaltdelete) (void) = 0; //does not work on my atmega2560
//===========================================================================
//=============================functinos ============================
//===========================================================================
/// intialise watch dog with a 1 sec interrupt time
void wd_init()
{
WDTCSR = (1<<WDCE )|(1<<WDE ); //allow changes
WDTCSR = (1<<WDIF)|(1<<WDIE)| (1<<WDCE )|(1<<WDE )| (1<<WDP2 )|(1<<WDP1)|(0<<WDP0);
}
/// reset watchdog. MUST be called every 1s after init or avr will reset.
void wd_reset()
{
wdt_reset();
timeout_seconds=0; //reset counter for resets
}
//===========================================================================
//=============================ISR ============================
//===========================================================================
//Watchdog timer interrupt, called if main program blocks >1sec //Watchdog timer interrupt, called if main program blocks >1sec
ISR(WDT_vect) ISR(WDT_vect)
{ {
@ -31,18 +58,4 @@ ISR(WDT_vect)
} }
} }
/// intialise watch dog with a 1 sec interrupt time
void wd_init()
{
WDTCSR = (1<<WDCE )|(1<<WDE ); //allow changes
WDTCSR = (1<<WDIF)|(1<<WDIE)| (1<<WDCE )|(1<<WDE )| (1<<WDP2 )|(1<<WDP1)|(0<<WDP0);
}
/// reset watchdog. MUST be called every 1s after init or avr will reset.
void wd_reset()
{
wdt_reset();
timeout_seconds=0; //reset counter for resets
}
#endif /* USE_WATCHDOG */ #endif /* USE_WATCHDOG */

Loading…
Cancel
Save