Browse Source

convert DAC percent to uint8_t

=====================

add test to Travis
Bob-the-Kuhn 7 years ago
parent
commit
a1c65fd3d5

+ 3
- 2
.travis.yml View File

228
   #- opt_enable MAKRPANEL
228
   #- opt_enable MAKRPANEL
229
   #- build_marlin
229
   #- build_marlin
230
   #
230
   #
231
-  # REPRAP_DISCOUNT_SMART_CONTROLLER, SDSUPPORT, and BABYSTEPPING
231
+  # REPRAP_DISCOUNT_SMART_CONTROLLER, SDSUPPORT, BABYSTEPPING, RIGIDBOARD_V2, and DAC_MOTOR_CURRENT_DEFAULT
232
   #
232
   #
233
   - restore_configs
233
   - restore_configs
234
-  - opt_enable REPRAP_DISCOUNT_SMART_CONTROLLER SDSUPPORT BABYSTEPPING
234
+  - opt_set MOTHERBOARD BOARD_RIGIDBOARD_V2
235
+  - opt_enable REPRAP_DISCOUNT_SMART_CONTROLLER SDSUPPORT BABYSTEPPING DAC_MOTOR_CURRENT_DEFAULT
235
   - build_marlin
236
   - build_marlin
236
   #
237
   #
237
   # G3D_PANEL with SDCARD_SORT_ALPHA and STATUS_MESSAGE_SCROLLING
238
   # G3D_PANEL with SDCARD_SORT_ALPHA and STATUS_MESSAGE_SCROLLING

+ 2
- 2
Marlin/stepper_dac.cpp View File

94
   static float dac_perc(int8_t n) { return 100.0 * mcp4728_getValue(dac_order[n]) * (1.0 / (DAC_STEPPER_MAX)); }
94
   static float dac_perc(int8_t n) { return 100.0 * mcp4728_getValue(dac_order[n]) * (1.0 / (DAC_STEPPER_MAX)); }
95
   static float dac_amps(int8_t n) { return mcp4728_getDrvPct(dac_order[n]) * (DAC_STEPPER_MAX) * 0.125 * (1.0 / (DAC_STEPPER_SENSE)); }
95
   static float dac_amps(int8_t n) { return mcp4728_getDrvPct(dac_order[n]) * (DAC_STEPPER_MAX) * 0.125 * (1.0 / (DAC_STEPPER_SENSE)); }
96
 
96
 
97
-  int16_t dac_current_get_percent(AxisEnum axis) { return mcp4728_getDrvPct(dac_order[axis]); }
98
-  void dac_current_set_percents(const int8_t pct[XYZE]) {
97
+  uint8_t dac_current_get_percent(AxisEnum axis) { return mcp4728_getDrvPct(dac_order[axis]); }
98
+  void dac_current_set_percents(const uint8_t pct[XYZE]) {
99
     LOOP_XYZE(i) dac_channel_pct[i] = pct[dac_order[i]];
99
     LOOP_XYZE(i) dac_channel_pct[i] = pct[dac_order[i]];
100
     mcp4728_setDrvPct(dac_channel_pct);
100
     mcp4728_setDrvPct(dac_channel_pct);
101
   }
101
   }

+ 2
- 2
Marlin/stepper_dac.h View File

51
 void dac_current_raw(uint8_t channel, uint16_t val);
51
 void dac_current_raw(uint8_t channel, uint16_t val);
52
 void dac_print_values();
52
 void dac_print_values();
53
 void dac_commit_eeprom();
53
 void dac_commit_eeprom();
54
-int16_t dac_current_get_percent(AxisEnum axis);
55
-void dac_current_set_percents(int16_t pct[XYZE]);
54
+uint8_t dac_current_get_percent(AxisEnum axis);
55
+void dac_current_set_percents(const uint8_t pct[XYZE]);
56
 
56
 
57
 #endif // STEPPER_DAC_H
57
 #endif // STEPPER_DAC_H

+ 7
- 5
Marlin/ultralcd.cpp View File

92
 
92
 
93
 #if ENABLED(DAC_STEPPER_CURRENT)
93
 #if ENABLED(DAC_STEPPER_CURRENT)
94
   #include "stepper_dac.h" //was dac_mcp4728.h MarlinMain uses stepper dac for the m-codes
94
   #include "stepper_dac.h" //was dac_mcp4728.h MarlinMain uses stepper dac for the m-codes
95
-  int16_t driverPercent[XYZE];
95
+  uint8_t driverPercent[XYZE];
96
 #endif
96
 #endif
97
 
97
 
98
 #if ENABLED(ULTIPANEL)
98
 #if ENABLED(ULTIPANEL)
185
     typedef void _name##_void
185
     typedef void _name##_void
186
 
186
 
187
   DECLARE_MENU_EDIT_TYPE(int, int3);
187
   DECLARE_MENU_EDIT_TYPE(int, int3);
188
+  DECLARE_MENU_EDIT_TYPE(uint8_t, int8);
188
   DECLARE_MENU_EDIT_TYPE(float, float3);
189
   DECLARE_MENU_EDIT_TYPE(float, float3);
189
   DECLARE_MENU_EDIT_TYPE(float, float32);
190
   DECLARE_MENU_EDIT_TYPE(float, float32);
190
   DECLARE_MENU_EDIT_TYPE(float, float43);
191
   DECLARE_MENU_EDIT_TYPE(float, float43);
1253
       dac_driver_getValues();
1254
       dac_driver_getValues();
1254
       START_MENU();
1255
       START_MENU();
1255
       MENU_BACK(MSG_CONTROL);
1256
       MENU_BACK(MSG_CONTROL);
1256
-      MENU_ITEM_EDIT_CALLBACK(int3, MSG_X " " MSG_DAC_PERCENT, &driverPercent[X_AXIS], 0, 100, dac_driver_commit);
1257
-      MENU_ITEM_EDIT_CALLBACK(int3, MSG_Y " " MSG_DAC_PERCENT, &driverPercent[Y_AXIS], 0, 100, dac_driver_commit);
1258
-      MENU_ITEM_EDIT_CALLBACK(int3, MSG_Z " " MSG_DAC_PERCENT, &driverPercent[Z_AXIS], 0, 100, dac_driver_commit);
1259
-      MENU_ITEM_EDIT_CALLBACK(int3, MSG_E " " MSG_DAC_PERCENT, &driverPercent[E_AXIS], 0, 100, dac_driver_commit);
1257
+      MENU_ITEM_EDIT_CALLBACK(int8, MSG_X " " MSG_DAC_PERCENT, &driverPercent[X_AXIS], 0, 100, dac_driver_commit);
1258
+      MENU_ITEM_EDIT_CALLBACK(int8, MSG_Y " " MSG_DAC_PERCENT, &driverPercent[Y_AXIS], 0, 100, dac_driver_commit);
1259
+      MENU_ITEM_EDIT_CALLBACK(int8, MSG_Z " " MSG_DAC_PERCENT, &driverPercent[Z_AXIS], 0, 100, dac_driver_commit);
1260
+      MENU_ITEM_EDIT_CALLBACK(int8, MSG_E " " MSG_DAC_PERCENT, &driverPercent[E_AXIS], 0, 100, dac_driver_commit);
1260
       MENU_ITEM(function, MSG_DAC_EEPROM_WRITE, dac_driver_eeprom_write);
1261
       MENU_ITEM(function, MSG_DAC_EEPROM_WRITE, dac_driver_eeprom_write);
1261
       END_MENU();
1262
       END_MENU();
1262
     }
1263
     }
3932
     typedef void _name
3933
     typedef void _name
3933
 
3934
 
3934
   DEFINE_MENU_EDIT_TYPE(int, int3, itostr3, 1);
3935
   DEFINE_MENU_EDIT_TYPE(int, int3, itostr3, 1);
3936
+  DEFINE_MENU_EDIT_TYPE(uint8_t, int8, i8tostr3, 1);
3935
   DEFINE_MENU_EDIT_TYPE(float, float3, ftostr3, 1.0);
3937
   DEFINE_MENU_EDIT_TYPE(float, float3, ftostr3, 1.0);
3936
   DEFINE_MENU_EDIT_TYPE(float, float32, ftostr32, 100.0);
3938
   DEFINE_MENU_EDIT_TYPE(float, float32, ftostr32, 100.0);
3937
   DEFINE_MENU_EDIT_TYPE(float, float43, ftostr43sign, 1000.0);
3939
   DEFINE_MENU_EDIT_TYPE(float, float43, ftostr43sign, 1000.0);

+ 1
- 0
Marlin/ultralcd_impl_DOGM.h View File

848
     typedef void _name##_void
848
     typedef void _name##_void
849
 
849
 
850
   DEFINE_LCD_IMPLEMENTATION_DRAWMENU_SETTING_EDIT_TYPE(int, int3, itostr3);
850
   DEFINE_LCD_IMPLEMENTATION_DRAWMENU_SETTING_EDIT_TYPE(int, int3, itostr3);
851
+  DEFINE_LCD_IMPLEMENTATION_DRAWMENU_SETTING_EDIT_TYPE(uint8_t, int8, i8tostr3);
851
   DEFINE_LCD_IMPLEMENTATION_DRAWMENU_SETTING_EDIT_TYPE(float, float3, ftostr3);
852
   DEFINE_LCD_IMPLEMENTATION_DRAWMENU_SETTING_EDIT_TYPE(float, float3, ftostr3);
852
   DEFINE_LCD_IMPLEMENTATION_DRAWMENU_SETTING_EDIT_TYPE(float, float32, ftostr32);
853
   DEFINE_LCD_IMPLEMENTATION_DRAWMENU_SETTING_EDIT_TYPE(float, float32, ftostr32);
853
   DEFINE_LCD_IMPLEMENTATION_DRAWMENU_SETTING_EDIT_TYPE(float, float43, ftostr43sign);
854
   DEFINE_LCD_IMPLEMENTATION_DRAWMENU_SETTING_EDIT_TYPE(float, float43, ftostr43sign);

+ 1
- 0
Marlin/ultralcd_impl_HD44780.h View File

959
     typedef void _name##_void
959
     typedef void _name##_void
960
 
960
 
961
   DEFINE_LCD_IMPLEMENTATION_DRAWMENU_SETTING_EDIT_TYPE(int, int3, itostr3);
961
   DEFINE_LCD_IMPLEMENTATION_DRAWMENU_SETTING_EDIT_TYPE(int, int3, itostr3);
962
+  DEFINE_LCD_IMPLEMENTATION_DRAWMENU_SETTING_EDIT_TYPE(uint8_t, int8, i8tostr3);
962
   DEFINE_LCD_IMPLEMENTATION_DRAWMENU_SETTING_EDIT_TYPE(float, float3, ftostr3);
963
   DEFINE_LCD_IMPLEMENTATION_DRAWMENU_SETTING_EDIT_TYPE(float, float3, ftostr3);
963
   DEFINE_LCD_IMPLEMENTATION_DRAWMENU_SETTING_EDIT_TYPE(float, float32, ftostr32);
964
   DEFINE_LCD_IMPLEMENTATION_DRAWMENU_SETTING_EDIT_TYPE(float, float32, ftostr32);
964
   DEFINE_LCD_IMPLEMENTATION_DRAWMENU_SETTING_EDIT_TYPE(float, float43, ftostr43sign);
965
   DEFINE_LCD_IMPLEMENTATION_DRAWMENU_SETTING_EDIT_TYPE(float, float43, ftostr43sign);

+ 8
- 7
Marlin/utility.cpp View File

56
   #define RJDIGIT(n, f) ((n) >= (f) ? DIGIMOD(n, f) : ' ')
56
   #define RJDIGIT(n, f) ((n) >= (f) ? DIGIMOD(n, f) : ' ')
57
   #define MINUSOR(n, alt) (n >= 0 ? (alt) : (n = -n, '-'))
57
   #define MINUSOR(n, alt) (n >= 0 ? (alt) : (n = -n, '-'))
58
 
58
 
59
-  // Convert unsigned int to string with 12 format
60
-  char* itostr2(const uint8_t &xx) {
61
-    conv[5] = DIGIMOD(xx, 10);
59
+  // Convert unsigned int to string 123 format
60
+  char* i8tostr3(const uint8_t xx) {
61
+    conv[4] = RJDIGIT(xx, 100);
62
+    conv[5] = RJDIGIT(xx, 10);
62
     conv[6] = DIGIMOD(xx, 1);
63
     conv[6] = DIGIMOD(xx, 1);
63
-    return &conv[5];
64
+    return &conv[4];
64
   }
65
   }
65
 
66
 
66
   // Convert signed int to rj string with 123 or -12 format
67
   // Convert signed int to rj string with 123 or -12 format
67
-  char* itostr3(const int &x) {
68
+  char* itostr3(const int x) {
68
     int xx = x;
69
     int xx = x;
69
     conv[4] = MINUSOR(xx, RJDIGIT(xx, 100));
70
     conv[4] = MINUSOR(xx, RJDIGIT(xx, 100));
70
     conv[5] = RJDIGIT(xx, 10);
71
     conv[5] = RJDIGIT(xx, 10);
73
   }
74
   }
74
 
75
 
75
   // Convert unsigned int to lj string with 123 format
76
   // Convert unsigned int to lj string with 123 format
76
-  char* itostr3left(const int &xx) {
77
+  char* itostr3left(const int xx) {
77
     char *str = &conv[6];
78
     char *str = &conv[6];
78
     *str = DIGIMOD(xx, 1);
79
     *str = DIGIMOD(xx, 1);
79
     if (xx >= 10) {
80
     if (xx >= 10) {
85
   }
86
   }
86
 
87
 
87
   // Convert signed int to rj string with 1234, _123, -123, _-12, or __-1 format
88
   // Convert signed int to rj string with 1234, _123, -123, _-12, or __-1 format
88
-  char *itostr4sign(const int &x) {
89
+  char *itostr4sign(const int x) {
89
     const bool neg = x < 0;
90
     const bool neg = x < 0;
90
     const int xx = neg ? -x : x;
91
     const int xx = neg ? -x : x;
91
     if (x >= 1000) {
92
     if (x >= 1000) {

+ 5
- 5
Marlin/utility.h View File

31
 
31
 
32
 #if ENABLED(ULTRA_LCD)
32
 #if ENABLED(ULTRA_LCD)
33
 
33
 
34
-  // Convert unsigned int to string with 12 format
35
-  char* itostr2(const uint8_t &x);
34
+  // Convert uint8_t to string with 123 format
35
+  char* i8tostr3(const uint8_t x);
36
 
36
 
37
   // Convert signed int to rj string with 123 or -12 format
37
   // Convert signed int to rj string with 123 or -12 format
38
-  char* itostr3(const int &x);
38
+  char* itostr3(const int x);
39
 
39
 
40
   // Convert unsigned int to lj string with 123 format
40
   // Convert unsigned int to lj string with 123 format
41
-  char* itostr3left(const int &xx);
41
+  char* itostr3left(const int xx);
42
 
42
 
43
   // Convert signed int to rj string with _123, -123, _-12, or __-1 format
43
   // Convert signed int to rj string with _123, -123, _-12, or __-1 format
44
-  char *itostr4sign(const int &x);
44
+  char *itostr4sign(const int x);
45
 
45
 
46
   // Convert unsigned float to string with 1.23 format
46
   // Convert unsigned float to string with 1.23 format
47
   char* ftostr12ns(const float &x);
47
   char* ftostr12ns(const float &x);

Loading…
Cancel
Save