force inline

This commit is contained in:
Bernhard 2011-11-27 16:04:58 +01:00
parent f8e170a44b
commit 26a1de1e44
8 changed files with 59 additions and 52 deletions

View File

@ -38,7 +38,7 @@ template <class T> int EEPROM_readAnything(int &ee, T& value)
// ALSO: always make sure the variables in the Store and retrieve sections are in the same order. // ALSO: always make sure the variables in the Store and retrieve sections are in the same order.
#define EEPROM_VERSION "V04" #define EEPROM_VERSION "V04"
inline void StoreSettings() FORCE_INLINE void StoreSettings()
{ {
#ifdef EEPROM_SETTINGS #ifdef EEPROM_SETTINGS
char ver[4]= "000"; char ver[4]= "000";
@ -71,7 +71,7 @@ inline void StoreSettings()
#endif //EEPROM_SETTINGS #endif //EEPROM_SETTINGS
} }
inline void RetrieveSettings(bool def=false) FORCE_INLINE void RetrieveSettings(bool def=false)
{ // if def=true, the default values will be used { // if def=true, the default values will be used
#ifdef EEPROM_SETTINGS #ifdef EEPROM_SETTINGS
int i=EEPROM_OFFSET; int i=EEPROM_OFFSET;

View File

@ -8,6 +8,8 @@
#include <avr/pgmspace.h> #include <avr/pgmspace.h>
#include "Configuration.h" #include "Configuration.h"
#define FORCE_INLINE __attribute__((always_inline)) inline
//#define SERIAL_ECHO(x) Serial << "echo: " << x; //#define SERIAL_ECHO(x) Serial << "echo: " << x;
//#define SERIAL_ECHOLN(x) Serial << "echo: "<<x<<endl; //#define SERIAL_ECHOLN(x) Serial << "echo: "<<x<<endl;
//#define SERIAL_ERROR(x) Serial << "Error: " << x; //#define SERIAL_ERROR(x) Serial << "Error: " << x;
@ -41,7 +43,7 @@ const char echomagic[] PROGMEM ="echo:";
//things to write to serial from Programmemory. saves 400 to 2k of RAM. //things to write to serial from Programmemory. saves 400 to 2k of RAM.
#define SerialprintPGM(x) serialprintPGM(PSTR(x)) #define SerialprintPGM(x) serialprintPGM(PSTR(x))
inline void serialprintPGM(const char *str) FORCE_INLINE void serialprintPGM(const char *str)
{ {
char ch=pgm_read_byte(str); char ch=pgm_read_byte(str);
while(ch) while(ch)

View File

@ -32,11 +32,11 @@ public:
void chdir(const char * relpath); void chdir(const char * relpath);
void updir(); void updir();
inline bool eof() { return sdpos>=filesize ;}; FORCE_INLINE bool eof() { return sdpos>=filesize ;};
inline int16_t get() { sdpos = file.curPosition();return (int16_t)file.read();}; FORCE_INLINE int16_t get() { sdpos = file.curPosition();return (int16_t)file.read();};
inline void setIndex(long index) {sdpos = index;file.seekSet(index);}; FORCE_INLINE void setIndex(long index) {sdpos = index;file.seekSet(index);};
inline uint8_t percentDone(){if(!sdprinting) return 0; if(filesize) return sdpos*100/filesize; else return 0;}; FORCE_INLINE uint8_t percentDone(){if(!sdprinting) return 0; if(filesize) return sdpos*100/filesize; else return 0;};
inline char* getWorkDirName(){workDir.getFilename(filename);return filename;}; FORCE_INLINE char* getWorkDirName(){workDir.getFilename(filename);return filename;};
public: public:
bool saving; bool saving;
@ -69,31 +69,31 @@ private:
class CardReader class CardReader
{ {
public: public:
inline CardReader(){}; FORCE_INLINE CardReader(){};
inline static void initsd(){}; FORCE_INLINE static void initsd(){};
inline static void write_command(char *buf){}; FORCE_INLINE static void write_command(char *buf){};
inline static void checkautostart(bool x) {}; FORCE_INLINE static void checkautostart(bool x) {};
inline static void openFile(char* name,bool read){}; FORCE_INLINE static void openFile(char* name,bool read){};
inline static void closefile() {}; FORCE_INLINE static void closefile() {};
inline static void release(){}; FORCE_INLINE static void release(){};
inline static void startFileprint(){}; FORCE_INLINE static void startFileprint(){};
inline static void startFilewrite(char *name){}; FORCE_INLINE static void startFilewrite(char *name){};
inline static void pauseSDPrint(){}; FORCE_INLINE static void pauseSDPrint(){};
inline static void getStatus(){}; FORCE_INLINE static void getStatus(){};
inline static void selectFile(char* name){}; FORCE_INLINE static void selectFile(char* name){};
inline static void getfilename(const uint8_t nr){}; FORCE_INLINE static void getfilename(const uint8_t nr){};
inline static uint8_t getnrfilenames(){return 0;}; FORCE_INLINE static uint8_t getnrfilenames(){return 0;};
inline static void ls() {}; FORCE_INLINE static void ls() {};
inline static bool eof() {return true;}; FORCE_INLINE static bool eof() {return true;};
inline static char get() {return 0;}; FORCE_INLINE static char get() {return 0;};
inline static void setIndex(){}; FORCE_INLINE static void setIndex(){};
inline uint8_t percentDone(){return 0;}; FORCE_INLINE uint8_t percentDone(){return 0;};
}; };
#endif //SDSUPPORT #endif //SDSUPPORT
#endif #endif

View File

@ -132,7 +132,8 @@ static int8_t prev_block_index(int8_t block_index) {
// 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
// given acceleration: // given acceleration:
inline float estimate_acceleration_distance(float initial_rate, float target_rate, float acceleration) { FORCE_INLINE float estimate_acceleration_distance(float initial_rate, float target_rate, float acceleration)
{
if (acceleration!=0) { if (acceleration!=0) {
return((target_rate*target_rate-initial_rate*initial_rate)/ return((target_rate*target_rate-initial_rate*initial_rate)/
(2.0*acceleration)); (2.0*acceleration));
@ -147,7 +148,8 @@ inline float estimate_acceleration_distance(float initial_rate, float target_rat
// a total travel of distance. This can be used to compute the intersection point between acceleration and // a total travel of distance. This can be used to compute the intersection point between acceleration and
// deceleration in the cases where the trapezoid has no plateau (i.e. never reaches maximum speed) // deceleration in the cases where the trapezoid has no plateau (i.e. never reaches maximum speed)
inline float intersection_distance(float initial_rate, float final_rate, float acceleration, float distance) { FORCE_INLINE float intersection_distance(float initial_rate, float final_rate, float acceleration, float distance)
{
if (acceleration!=0) { if (acceleration!=0) {
return((2.0*acceleration*distance-initial_rate*initial_rate+final_rate*final_rate)/ return((2.0*acceleration*distance-initial_rate*initial_rate+final_rate*final_rate)/
(4.0*acceleration) ); (4.0*acceleration) );
@ -211,7 +213,7 @@ void calculate_trapezoid_for_block(block_t *block, float entry_factor, float exi
// Calculates the maximum allowable speed at this point when you must be able to reach target_velocity using the // Calculates the maximum allowable speed at this point when you must be able to reach target_velocity using the
// acceleration within the allotted distance. // acceleration within the allotted distance.
inline float max_allowable_speed(float acceleration, float target_velocity, float distance) { FORCE_INLINE float max_allowable_speed(float acceleration, float target_velocity, float distance) {
return sqrt(target_velocity*target_velocity-2*acceleration*distance); return sqrt(target_velocity*target_velocity-2*acceleration*distance);
} }

View File

@ -25,6 +25,7 @@
#define planner_h #define planner_h
#include "Configuration.h" #include "Configuration.h"
#include "Marlin.h"
// This struct is used when buffering the setup for each linear movement "nominal" values are as specified in // This struct is used when buffering the setup for each linear movement "nominal" values are as specified in
// the source g-code and may never actually be reached if acceleration management is active. // the source g-code and may never actually be reached if acceleration management is active.
@ -106,14 +107,16 @@ extern volatile unsigned char block_buffer_head; // Index of the next
extern volatile unsigned char block_buffer_tail; extern volatile unsigned char block_buffer_tail;
// Called when the current block is no longer needed. Discards the block and makes the memory // Called when the current block is no longer needed. Discards the block and makes the memory
// availible for new blocks. // availible for new blocks.
inline void plan_discard_current_block() { FORCE_INLINE void plan_discard_current_block()
{
if (block_buffer_head != block_buffer_tail) { if (block_buffer_head != block_buffer_tail) {
block_buffer_tail = (block_buffer_tail + 1) & (BLOCK_BUFFER_SIZE - 1); block_buffer_tail = (block_buffer_tail + 1) & (BLOCK_BUFFER_SIZE - 1);
} }
} }
// Gets the current block. Returns NULL if buffer empty // Gets the current block. Returns NULL if buffer empty
inline block_t *plan_get_current_block() { FORCE_INLINE block_t *plan_get_current_block()
{
if (block_buffer_head == block_buffer_tail) { if (block_buffer_head == block_buffer_tail) {
return(NULL); return(NULL);
} }

View File

@ -59,31 +59,31 @@ extern float Kp,Ki,Kd,Kc;
//inline so that there is no performance decrease. //inline so that there is no performance decrease.
//deg=degreeCelsius //deg=degreeCelsius
inline float degHotend0(){ return analog2temp(current_raw[TEMPSENSOR_HOTEND_0]);}; FORCE_INLINE float degHotend0(){ return analog2temp(current_raw[TEMPSENSOR_HOTEND_0]);};
inline float degHotend1(){ return analog2temp(current_raw[TEMPSENSOR_HOTEND_1]);}; FORCE_INLINE float degHotend1(){ return analog2temp(current_raw[TEMPSENSOR_HOTEND_1]);};
inline float degBed() { return analog2tempBed(current_raw[TEMPSENSOR_BED]);}; FORCE_INLINE float degBed() { return analog2tempBed(current_raw[TEMPSENSOR_BED]);};
inline float degTargetHotend0() { return analog2temp(target_raw[TEMPSENSOR_HOTEND_0]);}; FORCE_INLINE float degTargetHotend0() { return analog2temp(target_raw[TEMPSENSOR_HOTEND_0]);};
inline float degTargetHotend1() { return analog2temp(target_raw[TEMPSENSOR_HOTEND_1]);}; FORCE_INLINE float degTargetHotend1() { return analog2temp(target_raw[TEMPSENSOR_HOTEND_1]);};
inline float degTargetBed() { return analog2tempBed(target_raw[TEMPSENSOR_BED]);}; FORCE_INLINE float degTargetBed() { return analog2tempBed(target_raw[TEMPSENSOR_BED]);};
inline void setTargetHotend0(const float &celsius) FORCE_INLINE void setTargetHotend0(const float &celsius)
{ {
target_raw[TEMPSENSOR_HOTEND_0]=temp2analog(celsius); target_raw[TEMPSENSOR_HOTEND_0]=temp2analog(celsius);
#ifdef PIDTEMP #ifdef PIDTEMP
pid_setpoint = celsius; pid_setpoint = celsius;
#endif //PIDTEMP #endif //PIDTEMP
}; };
inline void setTargetHotend1(const float &celsius) { target_raw[TEMPSENSOR_HOTEND_1]=temp2analog(celsius);}; FORCE_INLINE void setTargetHotend1(const float &celsius) { target_raw[TEMPSENSOR_HOTEND_1]=temp2analog(celsius);};
inline void setTargetBed(const float &celsius) { target_raw[TEMPSENSOR_BED ]=temp2analogBed(celsius);}; FORCE_INLINE void setTargetBed(const float &celsius) { target_raw[TEMPSENSOR_BED ]=temp2analogBed(celsius);};
inline bool isHeatingHotend0() {return target_raw[TEMPSENSOR_HOTEND_0] > current_raw[TEMPSENSOR_HOTEND_0];}; FORCE_INLINE bool isHeatingHotend0() {return target_raw[TEMPSENSOR_HOTEND_0] > current_raw[TEMPSENSOR_HOTEND_0];};
inline bool isHeatingHotend1() {return target_raw[TEMPSENSOR_HOTEND_1] > current_raw[TEMPSENSOR_HOTEND_1];}; FORCE_INLINE bool isHeatingHotend1() {return target_raw[TEMPSENSOR_HOTEND_1] > current_raw[TEMPSENSOR_HOTEND_1];};
inline bool isHeatingBed() {return target_raw[TEMPSENSOR_BED] > current_raw[TEMPSENSOR_BED];}; FORCE_INLINE bool isHeatingBed() {return target_raw[TEMPSENSOR_BED] > current_raw[TEMPSENSOR_BED];};
inline bool isCoolingHotend0() {return target_raw[TEMPSENSOR_HOTEND_0] < current_raw[TEMPSENSOR_HOTEND_0];}; FORCE_INLINE bool isCoolingHotend0() {return target_raw[TEMPSENSOR_HOTEND_0] < current_raw[TEMPSENSOR_HOTEND_0];};
inline bool isCoolingHotend1() {return target_raw[TEMPSENSOR_HOTEND_1] < current_raw[TEMPSENSOR_HOTEND_1];}; FORCE_INLINE bool isCoolingHotend1() {return target_raw[TEMPSENSOR_HOTEND_1] < current_raw[TEMPSENSOR_HOTEND_1];};
inline bool isCoolingBed() {return target_raw[TEMPSENSOR_BED] < current_raw[TEMPSENSOR_BED];}; FORCE_INLINE bool isCoolingBed() {return target_raw[TEMPSENSOR_BED] < current_raw[TEMPSENSOR_BED];};
void disable_heater(); void disable_heater();
void setWatch(); void setWatch();

View File

@ -79,7 +79,7 @@
bool tune; bool tune;
private: private:
inline void updateActiveLines(const uint8_t &maxlines,volatile int &encoderpos) FORCE_INLINE void updateActiveLines(const uint8_t &maxlines,volatile int &encoderpos)
{ {
if(linechanging) return; // an item is changint its value, do not switch lines hence if(linechanging) return; // an item is changint its value, do not switch lines hence
lastlineoffset=lineoffset; lastlineoffset=lineoffset;
@ -119,7 +119,7 @@
} }
} }
inline void clearIfNecessary() FORCE_INLINE void clearIfNecessary()
{ {
if(lastlineoffset!=lineoffset ||force_lcd_update) if(lastlineoffset!=lineoffset ||force_lcd_update)
{ {
@ -143,7 +143,7 @@
#define LCD_STATUS #define LCD_STATUS
#define LCD_MESSAGE(x) #define LCD_MESSAGE(x)
#define LCD_MESSAGEPGM(x) #define LCD_MESSAGEPGM(x)
inline void lcd_status() {}; FORCE_INLINE void lcd_status() {};
#endif #endif
#ifndef ULTIPANEL #ifndef ULTIPANEL

View File

@ -9,8 +9,8 @@
void wd_reset(); void wd_reset();
#else #else
inline void wd_init() {}; FORCE_INLINE void wd_init() {};
inline void wd_reset() {}; FORCE_INLINE void wd_reset() {};
#endif #endif
#endif #endif