Buffer size > 16

This commit is contained in:
Erik van der Zalm 2011-11-14 18:53:09 +01:00
parent 2643ae93d6
commit 331e82dcd3
3 changed files with 129 additions and 127 deletions

View File

@ -311,9 +311,9 @@ const int dropsegments=0; //everything with less than this number of steps will
// The number of linear motions that can be in the plan at any give time. // The number of linear motions that can be in the plan at any give time.
// THE BLOCK_BUFFER_SIZE NEEDS TO BE A POWER OF 2, i.g. 8,16,32 because shifts and ors are used to do the ringbuffering. // THE BLOCK_BUFFER_SIZE NEEDS TO BE A POWER OF 2, i.g. 8,16,32 because shifts and ors are used to do the ringbuffering.
#if defined SDSUPPORT #if defined SDSUPPORT
#define BLOCK_BUFFER_SIZE 8 // SD,LCD,Buttons take more memory, block buffer needs to be smaller #define BLOCK_BUFFER_SIZE 16 // SD,LCD,Buttons take more memory, block buffer needs to be smaller
#else #else
#define BLOCK_BUFFER_SIZE 8 // maximize block buffer #define BLOCK_BUFFER_SIZE 16 // maximize block buffer
#endif #endif

View File

@ -203,6 +203,7 @@ void manage_heater()
#endif #endif
} }
#define PGM_RD_W(x) (short)pgm_read_word(&x)
// Takes hot end temperature value as input and returns corresponding raw value. // Takes hot end temperature value as input and returns corresponding raw value.
// For a thermistor, it uses the RepRap thermistor temp table. // For a thermistor, it uses the RepRap thermistor temp table.
// This is needed because PID in hydra firmware hovers around a given analog value, not a temp value. // This is needed because PID in hydra firmware hovers around a given analog value, not a temp value.
@ -214,18 +215,18 @@ int temp2analog(int celsius) {
for (i=1; i<NUMTEMPS_HEATER_0; i++) for (i=1; i<NUMTEMPS_HEATER_0; i++)
{ {
if (pgm_read_word(&(heater_0_temptable[i][1])) < celsius) if (PGM_RD_W(heater_0_temptable[i][1]) < celsius)
{ {
raw = pgm_read_word(&(heater_0_temptable[i-1][0])) + raw = PGM_RD_W(heater_0_temptable[i-1][0]) +
(celsius - pgm_read_word(&(heater_0_temptable[i-1][1]))) * (celsius - PGM_RD_W(heater_0_temptable[i-1][1])) *
(pgm_read_word(&(heater_0_temptable[i][0])) - pgm_read_word(&(heater_0_temptable[i-1][0]))) / (PGM_RD_W(heater_0_temptable[i][0]) - PGM_RD_W(heater_0_temptable[i-1][0])) /
(pgm_read_word(&(heater_0_temptable[i][1])) - pgm_read_word(&(heater_0_temptable[i-1][1]))); (PGM_RD_W(heater_0_temptable[i][1]) - PGM_RD_W(heater_0_temptable[i-1][1]));
break; break;
} }
} }
// Overflow: Set to last value in the table // Overflow: Set to last value in the table
if (i == NUMTEMPS_HEATER_0) raw = pgm_read_word(&(heater_0_temptable[i-1][0])); if (i == NUMTEMPS_HEATER_0) raw = PGM_RD_W(heater_0_temptable[i-1][0]);
return (1023 * OVERSAMPLENR) - raw; return (1023 * OVERSAMPLENR) - raw;
#elif defined HEATER_0_USES_AD595 #elif defined HEATER_0_USES_AD595
@ -245,19 +246,19 @@ int temp2analogBed(int celsius) {
for (i=1; i<BNUMTEMPS; i++) for (i=1; i<BNUMTEMPS; i++)
{ {
if (pgm_read_word(&)bedtemptable[i][1])) < celsius) if (PGM_RD_W(bedtemptable[i][1]) < celsius)
{ {
raw = pgm_read_word(&(bedtemptable[i-1][0])) + raw = PGM_RD_W(bedtemptable[i-1][0]) +
(celsius - pgm_read_word(&(bedtemptable[i-1][1]))) * (celsius - PGM_RD_W(bedtemptable[i-1][1])) *
(pgm_read_word(&(bedtemptable[i][0])) - pgm_read_word(&(bedtemptable[i-1][0]))) / (PGM_RD_W(bedtemptable[i][0]) - PGM_RD_W(bedtemptable[i-1][0])) /
(pgm_read_word(&(bedtemptable[i][1])) - pgm_read_word(&(bedtemptable[i-1][1]))); (PGM_RD_W(bedtemptable[i][1]) - PGM_RD_W(bedtemptable[i-1][1]));
break; break;
} }
} }
// Overflow: Set to last value in the table // Overflow: Set to last value in the table
if (i == BNUMTEMPS) raw = pgm_read_word(&(bedtemptable[i-1][0])); if (i == BNUMTEMPS) raw = PGM_RD_W(bedtemptable[i-1][0]);
return (1023 * OVERSAMPLENR) - raw; return (1023 * OVERSAMPLENR) - raw;
#elif defined BED_USES_AD595 #elif defined BED_USES_AD595
@ -274,18 +275,18 @@ float analog2temp(int raw) {
raw = (1023 * OVERSAMPLENR) - raw; raw = (1023 * OVERSAMPLENR) - raw;
for (i=1; i<NUMTEMPS_HEATER_0; i++) for (i=1; i<NUMTEMPS_HEATER_0; i++)
{ {
if ((short)pgm_read_word(&heater_0_temptable[i][0]) > raw) if (PGM_RD_W(heater_0_temptable[i][0]) > raw)
{ {
celsius = (short)pgm_read_word(&heater_0_temptable[i-1][1]) + celsius = PGM_RD_W(heater_0_temptable[i-1][1]) +
(raw - (short)pgm_read_word(&heater_0_temptable[i-1][0])) * (raw - PGM_RD_W(heater_0_temptable[i-1][0])) *
(float)((short)pgm_read_word(&heater_0_temptable[i][1]) - (short)pgm_read_word(&heater_0_temptable[i-1][1])) / (float)(PGM_RD_W(heater_0_temptable[i][1]) - PGM_RD_W(heater_0_temptable[i-1][1])) /
(float)((short)pgm_read_word(&heater_0_temptable[i][0]) - (short)pgm_read_word(&heater_0_temptable[i-1][0])); (float)(PGM_RD_W(heater_0_temptable[i][0]) - PGM_RD_W(heater_0_temptable[i-1][0]));
break; break;
} }
} }
// Overflow: Set to last value in the table // Overflow: Set to last value in the table
if (i == NUMTEMPS_HEATER_0) celsius = (short)pgm_read_word(&(heater_0_temptable[i-1][1])); if (i == NUMTEMPS_HEATER_0) celsius = PGM_RD_W(heater_0_temptable[i-1][1]);
return celsius; return celsius;
#elif defined HEATER_0_USES_AD595 #elif defined HEATER_0_USES_AD595
@ -304,19 +305,19 @@ float analog2tempBed(int raw) {
for (i=1; i<BNUMTEMPS; i++) for (i=1; i<BNUMTEMPS; i++)
{ {
if (pgm_read_word(&(bedtemptable[i][0])) > raw) if (PGM_RD_W(bedtemptable[i][0]) > raw)
{ {
celsius = pgm_read_word(&(bedtemptable[i-1][1])) + celsius = PGM_RD_W(bedtemptable[i-1][1]) +
(raw - pgm_read_word(&(bedtemptable[i-1][0]))) * (raw - PGM_RD_W(bedtemptable[i-1][0])) *
(pgm_read_word(&(bedtemptable[i][1])) - pgm_read_word(&(bedtemptable[i-1][1]))) / (PGM_RD_W(bedtemptable[i][1]) - PGM_RD_W(bedtemptable[i-1][1])) /
(pgm_read_word(&(bedtemptable[i][0])) - pgm_read_word(&(bedtemptable[i-1][0]))); (PGM_RD_W(bedtemptable[i][0]) - PGM_RD_W(bedtemptable[i-1][0]));
break; break;
} }
} }
// Overflow: Set to last value in the table // Overflow: Set to last value in the table
if (i == BNUMTEMPS) celsius = pgm_read_word(&(bedtemptable[i-1][1])); if (i == BNUMTEMPS) celsius = PGM_RD_W(bedtemptable[i-1][1]);
return celsius; return celsius;

View File

@ -1,102 +1,103 @@
#ifndef __ULTRALCDH #ifndef __ULTRALCDH
#define __ULTRALCDH #define __ULTRALCDH
#include "Configuration.h" #include "Configuration.h"
#ifdef ULTRA_LCD #ifdef ULTRA_LCD
void lcd_status(); void lcd_status();
void lcd_init(); void lcd_init();
void lcd_status(const char* message); void lcd_status(const char* message);
void beep(); void beep();
void buttons_check(); void buttons_check();
#define LCD_UPDATE_INTERVAL 100 #define LCD_UPDATE_INTERVAL 100
#define STATUSTIMEOUT 15000 #define STATUSTIMEOUT 15000
#include <LiquidCrystal.h> #include <LiquidCrystal.h>
extern LiquidCrystal lcd; extern LiquidCrystal lcd;
#ifdef NEWPANEL #ifdef NEWPANEL
#define EN_C (1<<BLEN_C) #define EN_C (1<<BLEN_C)
#define EN_B (1<<BLEN_B) #define EN_B (1<<BLEN_B)
#define EN_A (1<<BLEN_A) #define EN_A (1<<BLEN_A)
#define CLICKED (buttons&EN_C) #define CLICKED (buttons&EN_C)
#define BLOCK {blocking=millis()+blocktime;} #define BLOCK {blocking=millis()+blocktime;}
#define CARDINSERTED (READ(SDCARDDETECT)==0) #define CARDINSERTED (READ(SDCARDDETECT)==0)
#else #else
//atomatic, do not change //atomatic, do not change
#define B_LE (1<<BL_LE) #define B_LE (1<<BL_LE)
#define B_UP (1<<BL_UP) #define B_UP (1<<BL_UP)
#define B_MI (1<<BL_MI) #define B_MI (1<<BL_MI)
#define B_DW (1<<BL_DW) #define B_DW (1<<BL_DW)
#define B_RI (1<<BL_RI) #define B_RI (1<<BL_RI)
#define B_ST (1<<BL_ST) #define B_ST (1<<BL_ST)
#define EN_B (1<<BLEN_B) #define EN_B (1<<BLEN_B)
#define EN_A (1<<BLEN_A) #define EN_A (1<<BLEN_A)
#define CLICKED ((buttons&B_MI)||(buttons&B_ST)) #define CLICKED ((buttons&B_MI)||(buttons&B_ST))
#define BLOCK {blocking[BL_MI]=millis()+blocktime;blocking[BL_ST]=millis()+blocktime;} #define BLOCK {blocking[BL_MI]=millis()+blocktime;blocking[BL_ST]=millis()+blocktime;}
#endif #endif
// blocking time for recognizing a new keypress of one key, ms // blocking time for recognizing a new keypress of one key, ms
#define blocktime 500 #define blocktime 500
#define lcdslow 5 #define lcdslow 5
enum MainStatus{Main_Status, Main_Menu, Main_Prepare, Main_Control, Main_SD}; enum MainStatus{Main_Status, Main_Menu, Main_Prepare, Main_Control, Main_SD};
class MainMenu{ class MainMenu{
public: public:
MainMenu(); MainMenu();
void update(); void update();
uint8_t activeline; uint8_t activeline;
MainStatus status; MainStatus status;
uint8_t displayStartingRow; uint8_t displayStartingRow;
void showStatus(); void showStatus();
void showMainMenu(); void showMainMenu();
void showPrepare(); void showPrepare();
void showControl(); void showControl();
void showSD(); void showSD();
bool force_lcd_update; bool force_lcd_update;
int lastencoderpos; int lastencoderpos;
int8_t lineoffset; int8_t lineoffset;
int8_t lastlineoffset; int8_t lastlineoffset;
bool linechanging; bool linechanging;
}; };
//conversion routines, could need some overworking //conversion routines, could need some overworking
char *fillto(int8_t n,char *c); char *fillto(int8_t n,char *c);
char *ftostr51(const float &x); char *ftostr51(const float &x);
char *ftostr31(const float &x); char *ftostr31(const float &x);
char *ftostr3(const float &x); char *ftostr3(const float &x);
#define LCD_MESSAGE(x) lcd_status(x); #define LCD_MESSAGE(x) lcd_status(x);
#define LCD_MESSAGEPGM(x) lcd_statuspgm(PSTR(x)); #define LCD_MESSAGEPGM(x) lcd_statuspgm(PSTR(x));
#define LCD_STATUS lcd_status() #define LCD_STATUS lcd_status()
#else //no lcd #else //no lcd
#define LCD_STATUS #define LCD_STATUS
#define LCD_MESSAGE(x) #define LCD_MESSAGE(x)
inline void lcd_status() {}; #define LCD_MESSAGEPGM(x)
#endif inline void lcd_status() {};
#endif
#ifndef ULTIPANEL
#define CLICKED false #ifndef ULTIPANEL
#define BLOCK ; #define CLICKED false
#endif #define BLOCK ;
#endif
#endif //ULTRALCD
#endif //ULTRALCD