瀏覽代碼

Merge pull request #7097 from thinkyhead/bf_dac_percents_fix

Convert DAC percent to uint8_t
Scott Lahteine 7 年之前
父節點
當前提交
0c616700f3
共有 8 個檔案被更改,包括 29 行新增23 行删除
  1. 3
    2
      .travis.yml
  2. 2
    2
      Marlin/stepper_dac.cpp
  3. 2
    2
      Marlin/stepper_dac.h
  4. 7
    5
      Marlin/ultralcd.cpp
  5. 1
    0
      Marlin/ultralcd_impl_DOGM.h
  6. 1
    0
      Marlin/ultralcd_impl_HD44780.h
  7. 8
    7
      Marlin/utility.cpp
  8. 5
    5
      Marlin/utility.h

+ 3
- 2
.travis.yml 查看文件

@@ -228,10 +228,11 @@ script:
228 228
   #- opt_enable MAKRPANEL
229 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 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 236
   - build_marlin
236 237
   #
237 238
   # G3D_PANEL with SDCARD_SORT_ALPHA and STATUS_MESSAGE_SCROLLING

+ 2
- 2
Marlin/stepper_dac.cpp 查看文件

@@ -94,8 +94,8 @@
94 94
   static float dac_perc(int8_t n) { return 100.0 * mcp4728_getValue(dac_order[n]) * (1.0 / (DAC_STEPPER_MAX)); }
95 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 99
     LOOP_XYZE(i) dac_channel_pct[i] = pct[dac_order[i]];
100 100
     mcp4728_setDrvPct(dac_channel_pct);
101 101
   }

+ 2
- 2
Marlin/stepper_dac.h 查看文件

@@ -51,7 +51,7 @@ void dac_current_percent(uint8_t channel, float val);
51 51
 void dac_current_raw(uint8_t channel, uint16_t val);
52 52
 void dac_print_values();
53 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 57
 #endif // STEPPER_DAC_H

+ 7
- 5
Marlin/ultralcd.cpp 查看文件

@@ -92,7 +92,7 @@ uint16_t max_display_update_time = 0;
92 92
 
93 93
 #if ENABLED(DAC_STEPPER_CURRENT)
94 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 96
 #endif
97 97
 
98 98
 #if ENABLED(ULTIPANEL)
@@ -185,6 +185,7 @@ uint16_t max_display_update_time = 0;
185 185
     typedef void _name##_void
186 186
 
187 187
   DECLARE_MENU_EDIT_TYPE(int, int3);
188
+  DECLARE_MENU_EDIT_TYPE(uint8_t, int8);
188 189
   DECLARE_MENU_EDIT_TYPE(float, float3);
189 190
   DECLARE_MENU_EDIT_TYPE(float, float32);
190 191
   DECLARE_MENU_EDIT_TYPE(float, float43);
@@ -1258,10 +1259,10 @@ void kill_screen(const char* lcd_msg) {
1258 1259
       dac_driver_getValues();
1259 1260
       START_MENU();
1260 1261
       MENU_BACK(MSG_CONTROL);
1261
-      MENU_ITEM_EDIT_CALLBACK(int3, MSG_X " " MSG_DAC_PERCENT, &driverPercent[X_AXIS], 0, 100, dac_driver_commit);
1262
-      MENU_ITEM_EDIT_CALLBACK(int3, MSG_Y " " MSG_DAC_PERCENT, &driverPercent[Y_AXIS], 0, 100, dac_driver_commit);
1263
-      MENU_ITEM_EDIT_CALLBACK(int3, MSG_Z " " MSG_DAC_PERCENT, &driverPercent[Z_AXIS], 0, 100, dac_driver_commit);
1264
-      MENU_ITEM_EDIT_CALLBACK(int3, MSG_E " " MSG_DAC_PERCENT, &driverPercent[E_AXIS], 0, 100, dac_driver_commit);
1262
+      MENU_ITEM_EDIT_CALLBACK(int8, MSG_X " " MSG_DAC_PERCENT, &driverPercent[X_AXIS], 0, 100, dac_driver_commit);
1263
+      MENU_ITEM_EDIT_CALLBACK(int8, MSG_Y " " MSG_DAC_PERCENT, &driverPercent[Y_AXIS], 0, 100, dac_driver_commit);
1264
+      MENU_ITEM_EDIT_CALLBACK(int8, MSG_Z " " MSG_DAC_PERCENT, &driverPercent[Z_AXIS], 0, 100, dac_driver_commit);
1265
+      MENU_ITEM_EDIT_CALLBACK(int8, MSG_E " " MSG_DAC_PERCENT, &driverPercent[E_AXIS], 0, 100, dac_driver_commit);
1265 1266
       MENU_ITEM(function, MSG_DAC_EEPROM_WRITE, dac_driver_eeprom_write);
1266 1267
       END_MENU();
1267 1268
     }
@@ -3936,6 +3937,7 @@ void kill_screen(const char* lcd_msg) {
3936 3937
     typedef void _name
3937 3938
 
3938 3939
   DEFINE_MENU_EDIT_TYPE(int, int3, itostr3, 1);
3940
+  DEFINE_MENU_EDIT_TYPE(uint8_t, int8, i8tostr3, 1);
3939 3941
   DEFINE_MENU_EDIT_TYPE(float, float3, ftostr3, 1.0);
3940 3942
   DEFINE_MENU_EDIT_TYPE(float, float32, ftostr32, 100.0);
3941 3943
   DEFINE_MENU_EDIT_TYPE(float, float43, ftostr43sign, 1000.0);

+ 1
- 0
Marlin/ultralcd_impl_DOGM.h 查看文件

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

+ 1
- 0
Marlin/ultralcd_impl_HD44780.h 查看文件

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

+ 8
- 7
Marlin/utility.cpp 查看文件

@@ -56,15 +56,16 @@ void safe_delay(millis_t ms) {
56 56
   #define RJDIGIT(n, f) ((n) >= (f) ? DIGIMOD(n, f) : ' ')
57 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 63
     conv[6] = DIGIMOD(xx, 1);
63
-    return &conv[5];
64
+    return &conv[4];
64 65
   }
65 66
 
66 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 69
     int xx = x;
69 70
     conv[4] = MINUSOR(xx, RJDIGIT(xx, 100));
70 71
     conv[5] = RJDIGIT(xx, 10);
@@ -73,7 +74,7 @@ void safe_delay(millis_t ms) {
73 74
   }
74 75
 
75 76
   // Convert unsigned int to lj string with 123 format
76
-  char* itostr3left(const int &xx) {
77
+  char* itostr3left(const int xx) {
77 78
     char *str = &conv[6];
78 79
     *str = DIGIMOD(xx, 1);
79 80
     if (xx >= 10) {
@@ -85,7 +86,7 @@ void safe_delay(millis_t ms) {
85 86
   }
86 87
 
87 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 90
     const bool neg = x < 0;
90 91
     const int xx = neg ? -x : x;
91 92
     if (x >= 1000) {

+ 5
- 5
Marlin/utility.h 查看文件

@@ -31,17 +31,17 @@ void safe_delay(millis_t ms);
31 31
 
32 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 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 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 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 46
   // Convert unsigned float to string with 1.23 format
47 47
   char* ftostr12ns(const float &x);

Loading…
取消
儲存