|
@@ -60,6 +60,7 @@ uint8_t mcp4728_analogWrite(uint8_t channel, uint16_t value) {
|
60
|
60
|
mcp4728_values[channel] = value;
|
61
|
61
|
return mcp4728_fastWrite();
|
62
|
62
|
}
|
|
63
|
+
|
63
|
64
|
/**
|
64
|
65
|
* Write all input resistor values to EEPROM using SequencialWrite method.
|
65
|
66
|
* This will update both input register and EEPROM value
|
|
@@ -68,7 +69,7 @@ uint8_t mcp4728_analogWrite(uint8_t channel, uint16_t value) {
|
68
|
69
|
uint8_t mcp4728_eepromWrite() {
|
69
|
70
|
Wire.beginTransmission(DAC_DEV_ADDRESS);
|
70
|
71
|
Wire.write(SEQWRITE);
|
71
|
|
- for (uint8_t channel = 0; channel < COUNT(channel); channel++) {
|
|
72
|
+ for (uint8_t channel = 0; channel < COUNT(mcp4728_values); channel++) {
|
72
|
73
|
Wire.write(DAC_STEPPER_VREF << 7 | DAC_STEPPER_GAIN << 4 | highByte(mcp4728_values[channel]));
|
73
|
74
|
Wire.write(lowByte(mcp4728_values[channel]));
|
74
|
75
|
}
|
|
@@ -109,10 +110,15 @@ uint16_t mcp4728_getVout(uint8_t channel) {
|
109
|
110
|
}
|
110
|
111
|
*/
|
111
|
112
|
|
112
|
|
-/* Returns DAC values as a 0-100 percentage of drive strength */
|
|
113
|
+/**
|
|
114
|
+ * Returns DAC values as a 0-100 percentage of drive strength
|
|
115
|
+ */
|
113
|
116
|
uint16_t mcp4728_getDrvPct(uint8_t channel) { return uint16_t(100.0 * mcp4728_values[channel] / (DAC_STEPPER_MAX) + 0.5); }
|
114
|
117
|
|
115
|
|
-/* Recieves all Drive strengths as 0-100 percent values, updates DAC Values array and calls fastwrite to update the DAC */
|
|
118
|
+/**
|
|
119
|
+ * Receives all Drive strengths as 0-100 percent values, updates
|
|
120
|
+ * DAC Values array and calls fastwrite to update the DAC.
|
|
121
|
+ */
|
116
|
122
|
void mcp4728_setDrvPct(int16_t pct[XYZE]) {
|
117
|
123
|
LOOP_XYZE(i) mcp4728_values[i] = 0.01 * pct[i] * (DAC_STEPPER_MAX);
|
118
|
124
|
mcp4728_fastWrite();
|
|
@@ -125,7 +131,7 @@ void mcp4728_setDrvPct(int16_t pct[XYZE]) {
|
125
|
131
|
*/
|
126
|
132
|
uint8_t mcp4728_fastWrite() {
|
127
|
133
|
Wire.beginTransmission(DAC_DEV_ADDRESS);
|
128
|
|
- for (uint8_t channel = 0; channel < COUNT(channel); channel++) {
|
|
134
|
+ for (uint8_t channel = 0; channel < COUNT(mcp4728_values); channel++) {
|
129
|
135
|
Wire.write(highByte(mcp4728_values[channel]));
|
130
|
136
|
Wire.write(lowByte(mcp4728_values[channel]));
|
131
|
137
|
}
|