summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Sprinter/Sprinter.h42
-rw-r--r--Sprinter/Sprinter.pde52
2 files changed, 48 insertions, 46 deletions
diff --git a/Sprinter/Sprinter.h b/Sprinter/Sprinter.h
index a7c7a8f..e77da12 100644
--- a/Sprinter/Sprinter.h
+++ b/Sprinter/Sprinter.h
@@ -11,31 +11,29 @@ void manage_inactivity(byte debug);
void setup_acceleration();
void manage_heater();
-int temp2analogu(int celsius, const short table[][2], int numtemps, int source);
-int analog2tempu(int raw, const short table[][2], int numtemps, int source);
-#ifdef HEATER_USES_THERMISTOR
- #define HEATERSOURCE 1
-#endif
-#ifdef HEATER_USES_AD595
- #define HEATERSOURCE 2
-#endif
-#ifdef HEATER_USES_MAX6675
- #define HEATERSOURCE 3
-#endif
-#ifdef BED_USES_THERMISTOR
- #define BEDSOURCE 1
-#endif
-#ifdef BED_USES_AD595
- #define BEDSOURCE 2
+
+#if defined HEATER_USES_THERMISTOR
+#define temp2analogh( c ) temp2analog_thermistor(c,temptable,NUMTEMPS)
+#define analog2temp( c ) analog2temp_thermistor(c,temptable,NUMTEMPS)
+#elif defined HEATER_USES_AD595
+#define temp2analogh( c ) temp2analog_ad595(c)
+#define analog2temp( c ) analog2temp_ad595(c)
+#elif defined HEATER_USES_MAX6675
+#define temp2analogh( c ) temp2analog_max6675(c)
+#define analog2temp( c ) analog2temp_max6675(c)
#endif
-#ifdef BED_USES_MAX6675
- #define BEDSOURCE 3
+
+#if defined BED_USES_THERMISTOR
+#define temp2analogBed( c ) temp2analog_thermistor((c),bedtemptable,BNUMTEMPS)
+#define analog2tempBed( c ) analog2temp_thermistor((c),bedtemptable,BNUMTEMPS)
+#elif defined BED_USES_AD595
+#define temp2analogBed( c ) temp2analog_ad595(c)
+#define analog2tempBed( c ) analog2temp_ad595(c)
+#elif defined BED_USES_MAX6675
+#define temp2analogBed( c ) temp2analog_max6675(c)
+#define analog2tempBed( c ) analog2temp_max6675(c)
#endif
-#define temp2analogh( c ) temp2analogu((c),temptable,NUMTEMPS,HEATERSOURCE)
-#define temp2analogBed( c ) temp2analogu((c),bedtemptable,BNUMTEMPS,BEDSOURCE)
-#define analog2temp( c ) analog2tempu((c),temptable,NUMTEMPS,HEATERSOURCE)
-#define analog2tempBed( c ) analog2tempu((c),bedtemptable,BNUMTEMPS,BEDSOURCE)
#if X_ENABLE_PIN > -1
#define enable_x() WRITE(X_ENABLE_PIN, X_ENABLE_ON)
#define disable_x() WRITE(X_ENABLE_PIN,!X_ENABLE_ON)
diff --git a/Sprinter/Sprinter.pde b/Sprinter/Sprinter.pde
index 5daee2f..cc1434f 100644
--- a/Sprinter/Sprinter.pde
+++ b/Sprinter/Sprinter.pde
@@ -1539,10 +1539,8 @@ void manage_heater()
#endif
}
-
-int temp2analogu(int celsius, const short table[][2], int numtemps, int source) {
- #if defined (HEATER_USES_THERMISTOR) || defined (BED_USES_THERMISTOR)
- if(source==1){
+#if defined (HEATER_USES_THERMISTOR) || defined (BED_USES_THERMISTOR)
+int temp2analog_thermistor(int celsius, const short table[][2], int numtemps) {
int raw = 0;
byte i;
@@ -1563,20 +1561,23 @@ int temp2analogu(int celsius, const short table[][2], int numtemps, int source)
if (i == numtemps) raw = table[i-1][0];
return 1023 - raw;
- }
- #elif defined (HEATER_USES_AD595) || defined (BED_USES_AD595)
- if(source==2)
- return celsius * 1024 / (500);
- #elif defined (HEATER_USES_MAX6675) || defined (BED_USES_MAX6675)
- if(source==3)
- return celsius * 4;
- #endif
- return -1;
}
+#endif
+
+#if defined (HEATER_USES_AD595) || defined (BED_USES_AD595)
+int temp2analog_ad595(int celsius) {
+ return celsius * 1024 / (500);
+}
+#endif
+
+#if defined (HEATER_USES_MAX6675) || defined (BED_USES_MAX6675)
+int temp2analog_max6675(int celsius) {
+ return celsius * 4;
+}
+#endif
-int analog2tempu(int raw,const short table[][2], int numtemps, int source) {
- #if defined (HEATER_USES_THERMISTOR) || defined (BED_USES_THERMISTOR)
- if(source==1){
+#if defined (HEATER_USES_THERMISTOR) || defined (BED_USES_THERMISTOR)
+int analog2temp_thermistor(int raw,const short table[][2], int numtemps) {
int celsius = 0;
byte i;
@@ -1599,17 +1600,20 @@ int analog2tempu(int raw,const short table[][2], int numtemps, int source) {
if (i == numtemps) celsius = table[i-1][1];
return celsius;
- }
- #elif defined (HEATER_USES_AD595) || defined (BED_USES_AD595)
- if(source==2)
+}
+#endif
+
+#if defined (HEATER_USES_AD595) || defined (BED_USES_AD595)
+int analog2temp_ad595(int raw) {
return raw * 500 / 1024;
- #elif defined (HEATER_USES_MAX6675) || defined (BED_USES_MAX6675)
- if(source==3)
- return raw / 4;
- #endif
- return -1;
}
+#endif
+#if defined (HEATER_USES_MAX6675) || defined (BED_USES_MAX6675)
+int analog2temp_max6675(int raw) {
+ return raw / 4;
+}
+#endif
inline void kill()
{