Просмотр исходного кода

Cutter Power in percent format (#20410)

Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
Co-authored-by: Jason Smith <jason.inet@gmail.com>
Co-authored-by: Luu Lac <45380455+shitcreek@users.noreply.github.com>
Mike La Spina 4 лет назад
Родитель
Сommit
1fc0dcdc97
Аккаунт пользователя с таким Email не найден

+ 9
- 4
Marlin/src/feature/spindle_laser_types.h Просмотреть файл

39
 
39
 
40
 #if CUTTER_UNIT_IS(RPM) && SPEED_POWER_MAX > 255
40
 #if CUTTER_UNIT_IS(RPM) && SPEED_POWER_MAX > 255
41
   typedef uint16_t cutter_power_t;
41
   typedef uint16_t cutter_power_t;
42
-  #define CUTTER_MENU_POWER_TYPE uint16_5
43
-  #define cutter_power2str       ui16tostr5rj
42
+  #define CUTTER_MENU_POWER_TYPE   uint16_5
43
+  #define cutter_power2str         ui16tostr5rj
44
 #else
44
 #else
45
   typedef uint8_t cutter_power_t;
45
   typedef uint8_t cutter_power_t;
46
-  #define CUTTER_MENU_POWER_TYPE uint8
47
-  #define cutter_power2str       ui8tostr3rj
46
+  #if CUTTER_UNIT_IS(PERCENT)
47
+    #define CUTTER_MENU_POWER_TYPE percent_3
48
+    #define cutter_power2str       pcttostrpctrj
49
+  #else
50
+    #define CUTTER_MENU_POWER_TYPE uint8
51
+    #define cutter_power2str       ui8tostr3rj
52
+  #endif
48
 #endif
53
 #endif
49
 
54
 
50
 #if ENABLED(MARLIN_DEV_MODE)
55
 #if ENABLED(MARLIN_DEV_MODE)

+ 0
- 1
Marlin/src/lcd/dogm/status_screen_DOGM.cpp Просмотреть файл

618
       if (cutter.isReady && PAGE_CONTAINS(STATUS_CUTTER_TEXT_Y - INFO_FONT_ASCENT, STATUS_CUTTER_TEXT_Y - 1)) {
618
       if (cutter.isReady && PAGE_CONTAINS(STATUS_CUTTER_TEXT_Y - INFO_FONT_ASCENT, STATUS_CUTTER_TEXT_Y - 1)) {
619
         #if CUTTER_UNIT_IS(PERCENT)
619
         #if CUTTER_UNIT_IS(PERCENT)
620
           lcd_put_u8str(STATUS_CUTTER_TEXT_X, STATUS_CUTTER_TEXT_Y, cutter_power2str(cutter.unitPower));
620
           lcd_put_u8str(STATUS_CUTTER_TEXT_X, STATUS_CUTTER_TEXT_Y, cutter_power2str(cutter.unitPower));
621
-          lcd_put_wchar('%');
622
         #elif CUTTER_UNIT_IS(RPM)
621
         #elif CUTTER_UNIT_IS(RPM)
623
           lcd_put_u8str(STATUS_CUTTER_TEXT_X - 2, STATUS_CUTTER_TEXT_Y, ftostr51rj(float(cutter.unitPower) / 1000));
622
           lcd_put_u8str(STATUS_CUTTER_TEXT_X - 2, STATUS_CUTTER_TEXT_Y, ftostr51rj(float(cutter.unitPower) / 1000));
624
           lcd_put_wchar('K');
623
           lcd_put_wchar('K');

+ 1
- 0
Marlin/src/lcd/menu/menu_item.h Просмотреть файл

122
 
122
 
123
 //                         NAME         TYPE      STRFUNC          SCALE         +ROUND
123
 //                         NAME         TYPE      STRFUNC          SCALE         +ROUND
124
 DEFINE_MENU_EDIT_ITEM_TYPE(percent     ,uint8_t  ,ui8tostr4pctrj  , 100.f/255.f, 0.5f);  // 100%   right-justified
124
 DEFINE_MENU_EDIT_ITEM_TYPE(percent     ,uint8_t  ,ui8tostr4pctrj  , 100.f/255.f, 0.5f);  // 100%   right-justified
125
+DEFINE_MENU_EDIT_ITEM_TYPE(percent_3   ,uint8_t  ,pcttostrpctrj   ,   1     );   // 100%   right-justified
125
 DEFINE_MENU_EDIT_ITEM_TYPE(int3        ,int16_t  ,i16tostr3rj     ,   1     );   // 123, -12   right-justified
126
 DEFINE_MENU_EDIT_ITEM_TYPE(int3        ,int16_t  ,i16tostr3rj     ,   1     );   // 123, -12   right-justified
126
 DEFINE_MENU_EDIT_ITEM_TYPE(int4        ,int16_t  ,i16tostr4signrj ,   1     );   // 1234, -123 right-justified
127
 DEFINE_MENU_EDIT_ITEM_TYPE(int4        ,int16_t  ,i16tostr4signrj ,   1     );   // 1234, -123 right-justified
127
 DEFINE_MENU_EDIT_ITEM_TYPE(int8        ,int8_t   ,i8tostr3rj      ,   1     );   // 123, -12   right-justified
128
 DEFINE_MENU_EDIT_ITEM_TYPE(int8        ,int8_t   ,i8tostr3rj      ,   1     );   // 123, -12   right-justified

+ 10
- 6
Marlin/src/libs/numtostr.cpp Просмотреть файл

34
 #define INTFLOAT(V,N) (((V) * 10 * pow(10, N) + ((V) < 0 ? -5: 5)) / 10)      // pow10?
34
 #define INTFLOAT(V,N) (((V) * 10 * pow(10, N) + ((V) < 0 ? -5: 5)) / 10)      // pow10?
35
 #define UINTFLOAT(V,N) INTFLOAT((V) < 0 ? -(V) : (V), N)
35
 #define UINTFLOAT(V,N) INTFLOAT((V) < 0 ? -(V) : (V), N)
36
 
36
 
37
-// Convert a full-range unsigned 8bit int to a percentage
38
-const char* ui8tostr4pctrj(const uint8_t i) {
39
-  const uint8_t n = ui8_to_percent(i);
40
-  conv[3] = RJDIGIT(n, 100);
41
-  conv[4] = RJDIGIT(n, 10);
42
-  conv[5] = DIGIMOD(n, 1);
37
+// Format uint8_t (0-100) as rj string with 123% / _12% / __1% format
38
+const char* pcttostrpctrj(const uint8_t i) {
39
+  conv[3] = RJDIGIT(i, 100);
40
+  conv[4] = RJDIGIT(i, 10);
41
+  conv[5] = DIGIMOD(i, 1);
43
   conv[6] = '%';
42
   conv[6] = '%';
44
   return &conv[3];
43
   return &conv[3];
45
 }
44
 }
46
 
45
 
46
+// Convert uint8_t (0-255) to a percentage, format as above
47
+const char* ui8tostr4pctrj(const uint8_t i) {
48
+  return pcttostrpctrj(ui8_to_percent(i));
49
+}
50
+
47
 // Convert unsigned 8bit int to string 123 format
51
 // Convert unsigned 8bit int to string 123 format
48
 const char* ui8tostr3rj(const uint8_t i) {
52
 const char* ui8tostr3rj(const uint8_t i) {
49
   conv[4] = RJDIGIT(i, 100);
53
   conv[4] = RJDIGIT(i, 100);

+ 4
- 1
Marlin/src/libs/numtostr.h Просмотреть файл

23
 
23
 
24
 #include <stdint.h>
24
 #include <stdint.h>
25
 
25
 
26
-// Convert a full-range unsigned 8bit int to a percentage
26
+// Format uint8_t (0-100) as rj string with 123% / _12% / __1% format
27
+const char* pcttostrpctrj(const uint8_t i);
28
+
29
+// Convert uint8_t (0-255) to a percentage, format as above
27
 const char* ui8tostr4pctrj(const uint8_t i);
30
 const char* ui8tostr4pctrj(const uint8_t i);
28
 
31
 
29
 // Convert uint8_t to string with 12 format
32
 // Convert uint8_t to string with 12 format

+ 9
- 0
buildroot/tests/BIGTREE_SKR_PRO-tests Просмотреть файл

28
 opt_enable BLTOUCH EEPROM_SETTINGS AUTO_BED_LEVELING_3POINT Z_SAFE_HOMING PINS_DEBUGGING
28
 opt_enable BLTOUCH EEPROM_SETTINGS AUTO_BED_LEVELING_3POINT Z_SAFE_HOMING PINS_DEBUGGING
29
 exec_test $1 $2 "BigTreeTech SKR Pro 3 Extruders, Auto-Fan, BLTOUCH, mixed TMC drivers" "$3"
29
 exec_test $1 $2 "BigTreeTech SKR Pro 3 Extruders, Auto-Fan, BLTOUCH, mixed TMC drivers" "$3"
30
 
30
 
31
+restore_configs
32
+opt_set MOTHERBOARD BOARD_BTT_SKR_PRO_V1_1
33
+opt_set SERIAL_PORT -1
34
+opt_enable LASER_FEATURE REPRAP_DISCOUNT_SMART_CONTROLLER
35
+opt_set CUTTER_POWER_UNIT PERCENT
36
+opt_add SPINDLE_LASER_PWM_PIN HEATER_1_PIN
37
+opt_add SPINDLE_LASER_ENA_PIN HEATER_2_PIN
38
+exec_test $1 $2 "Laser, LCD, PERCENT power unit" "$3"
39
+
31
 # clean up
40
 # clean up
32
 restore_configs
41
 restore_configs

Загрузка…
Отмена
Сохранить