Browse Source

Merge pull request #5036 from thinkyhead/rc_dac_code_deps

Fix DAC current code
Scott Lahteine 8 years ago
parent
commit
f257c4bcae
2 changed files with 9 additions and 8 deletions
  1. 8
    7
      Marlin/dac_mcp4728.cpp
  2. 1
    1
      Marlin/dac_mcp4728.h

+ 8
- 7
Marlin/dac_mcp4728.cpp View File

31
  */
31
  */
32
 
32
 
33
 #include "dac_mcp4728.h"
33
 #include "dac_mcp4728.h"
34
+#include "enum.h"
34
 
35
 
35
 #if ENABLED(DAC_STEPPER_CURRENT)
36
 #if ENABLED(DAC_STEPPER_CURRENT)
36
 
37
 
69
 uint8_t mcp4728_eepromWrite() {
70
 uint8_t mcp4728_eepromWrite() {
70
   Wire.beginTransmission(DAC_DEV_ADDRESS);
71
   Wire.beginTransmission(DAC_DEV_ADDRESS);
71
   Wire.write(SEQWRITE);
72
   Wire.write(SEQWRITE);
72
-  for (uint8_t channel = 0; channel < COUNT(mcp4728_values); channel++) {
73
-    Wire.write(DAC_STEPPER_VREF << 7 | DAC_STEPPER_GAIN << 4 | highByte(mcp4728_values[channel]));
74
-    Wire.write(lowByte(mcp4728_values[channel]));
73
+  LOOP_XYZE(i) {
74
+    Wire.write(DAC_STEPPER_VREF << 7 | DAC_STEPPER_GAIN << 4 | highByte(mcp4728_values[i]));
75
+    Wire.write(lowByte(mcp4728_values[i]));
75
   }
76
   }
76
   return Wire.endTransmission();
77
   return Wire.endTransmission();
77
 }
78
 }
119
  * Receives all Drive strengths as 0-100 percent values, updates
120
  * Receives all Drive strengths as 0-100 percent values, updates
120
  * DAC Values array and calls fastwrite to update the DAC.
121
  * DAC Values array and calls fastwrite to update the DAC.
121
  */
122
  */
122
-void mcp4728_setDrvPct(int16_t pct[XYZE]) {
123
+void mcp4728_setDrvPct(uint16_t pct[XYZE]) {
123
   LOOP_XYZE(i) mcp4728_values[i] = 0.01 * pct[i] * (DAC_STEPPER_MAX);
124
   LOOP_XYZE(i) mcp4728_values[i] = 0.01 * pct[i] * (DAC_STEPPER_MAX);
124
   mcp4728_fastWrite();
125
   mcp4728_fastWrite();
125
 }
126
 }
131
  */
132
  */
132
 uint8_t mcp4728_fastWrite() {
133
 uint8_t mcp4728_fastWrite() {
133
   Wire.beginTransmission(DAC_DEV_ADDRESS);
134
   Wire.beginTransmission(DAC_DEV_ADDRESS);
134
-  for (uint8_t channel = 0; channel < COUNT(mcp4728_values); channel++) {
135
-    Wire.write(highByte(mcp4728_values[channel]));
136
-    Wire.write(lowByte(mcp4728_values[channel]));
135
+  LOOP_XYZE(i) {
136
+    Wire.write(highByte(mcp4728_values[i]));
137
+    Wire.write(lowByte(mcp4728_values[i]));
137
   }
138
   }
138
   return Wire.endTransmission();
139
   return Wire.endTransmission();
139
 }
140
 }

+ 1
- 1
Marlin/dac_mcp4728.h View File

60
 uint8_t mcp4728_fastWrite();
60
 uint8_t mcp4728_fastWrite();
61
 uint8_t mcp4728_simpleCommand(byte simpleCommand);
61
 uint8_t mcp4728_simpleCommand(byte simpleCommand);
62
 uint16_t mcp4728_getDrvPct(uint8_t channel);
62
 uint16_t mcp4728_getDrvPct(uint8_t channel);
63
-void mcp4728_setDrvPct(int16_t pct[XYZE]);
63
+void mcp4728_setDrvPct(uint16_t pct[XYZE]);
64
 
64
 
65
 #endif
65
 #endif
66
 #endif // DAC_MCP4728_H
66
 #endif // DAC_MCP4728_H

Loading…
Cancel
Save