Merge pull request #7097 from thinkyhead/bf_dac_percents_fix

Convert DAC percent to uint8_t
2.0.x
Scott Lahteine 8 years ago committed by GitHub
commit 0c616700f3

@ -228,10 +228,11 @@ script:
#- opt_enable MAKRPANEL
#- build_marlin
#
# REPRAP_DISCOUNT_SMART_CONTROLLER, SDSUPPORT, and BABYSTEPPING
# REPRAP_DISCOUNT_SMART_CONTROLLER, SDSUPPORT, BABYSTEPPING, RIGIDBOARD_V2, and DAC_MOTOR_CURRENT_DEFAULT
#
- restore_configs
- opt_enable REPRAP_DISCOUNT_SMART_CONTROLLER SDSUPPORT BABYSTEPPING
- opt_set MOTHERBOARD BOARD_RIGIDBOARD_V2
- opt_enable REPRAP_DISCOUNT_SMART_CONTROLLER SDSUPPORT BABYSTEPPING DAC_MOTOR_CURRENT_DEFAULT
- build_marlin
#
# G3D_PANEL with SDCARD_SORT_ALPHA and STATUS_MESSAGE_SCROLLING

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

@ -51,7 +51,7 @@ void dac_current_percent(uint8_t channel, float val);
void dac_current_raw(uint8_t channel, uint16_t val);
void dac_print_values();
void dac_commit_eeprom();
int16_t dac_current_get_percent(AxisEnum axis);
void dac_current_set_percents(int16_t pct[XYZE]);
uint8_t dac_current_get_percent(AxisEnum axis);
void dac_current_set_percents(const uint8_t pct[XYZE]);
#endif // STEPPER_DAC_H

@ -92,7 +92,7 @@ uint16_t max_display_update_time = 0;
#if ENABLED(DAC_STEPPER_CURRENT)
#include "stepper_dac.h" //was dac_mcp4728.h MarlinMain uses stepper dac for the m-codes
int16_t driverPercent[XYZE];
uint8_t driverPercent[XYZE];
#endif
#if ENABLED(ULTIPANEL)
@ -185,6 +185,7 @@ uint16_t max_display_update_time = 0;
typedef void _name##_void
DECLARE_MENU_EDIT_TYPE(int, int3);
DECLARE_MENU_EDIT_TYPE(uint8_t, int8);
DECLARE_MENU_EDIT_TYPE(float, float3);
DECLARE_MENU_EDIT_TYPE(float, float32);
DECLARE_MENU_EDIT_TYPE(float, float43);
@ -1258,10 +1259,10 @@ void kill_screen(const char* lcd_msg) {
dac_driver_getValues();
START_MENU();
MENU_BACK(MSG_CONTROL);
MENU_ITEM_EDIT_CALLBACK(int3, MSG_X " " MSG_DAC_PERCENT, &driverPercent[X_AXIS], 0, 100, dac_driver_commit);
MENU_ITEM_EDIT_CALLBACK(int3, MSG_Y " " MSG_DAC_PERCENT, &driverPercent[Y_AXIS], 0, 100, dac_driver_commit);
MENU_ITEM_EDIT_CALLBACK(int3, MSG_Z " " MSG_DAC_PERCENT, &driverPercent[Z_AXIS], 0, 100, dac_driver_commit);
MENU_ITEM_EDIT_CALLBACK(int3, MSG_E " " MSG_DAC_PERCENT, &driverPercent[E_AXIS], 0, 100, dac_driver_commit);
MENU_ITEM_EDIT_CALLBACK(int8, MSG_X " " MSG_DAC_PERCENT, &driverPercent[X_AXIS], 0, 100, dac_driver_commit);
MENU_ITEM_EDIT_CALLBACK(int8, MSG_Y " " MSG_DAC_PERCENT, &driverPercent[Y_AXIS], 0, 100, dac_driver_commit);
MENU_ITEM_EDIT_CALLBACK(int8, MSG_Z " " MSG_DAC_PERCENT, &driverPercent[Z_AXIS], 0, 100, dac_driver_commit);
MENU_ITEM_EDIT_CALLBACK(int8, MSG_E " " MSG_DAC_PERCENT, &driverPercent[E_AXIS], 0, 100, dac_driver_commit);
MENU_ITEM(function, MSG_DAC_EEPROM_WRITE, dac_driver_eeprom_write);
END_MENU();
}
@ -3936,6 +3937,7 @@ void kill_screen(const char* lcd_msg) {
typedef void _name
DEFINE_MENU_EDIT_TYPE(int, int3, itostr3, 1);
DEFINE_MENU_EDIT_TYPE(uint8_t, int8, i8tostr3, 1);
DEFINE_MENU_EDIT_TYPE(float, float3, ftostr3, 1.0);
DEFINE_MENU_EDIT_TYPE(float, float32, ftostr32, 100.0);
DEFINE_MENU_EDIT_TYPE(float, float43, ftostr43sign, 1000.0);

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

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

@ -56,15 +56,16 @@ void safe_delay(millis_t ms) {
#define RJDIGIT(n, f) ((n) >= (f) ? DIGIMOD(n, f) : ' ')
#define MINUSOR(n, alt) (n >= 0 ? (alt) : (n = -n, '-'))
// Convert unsigned int to string with 12 format
char* itostr2(const uint8_t &xx) {
conv[5] = DIGIMOD(xx, 10);
// Convert unsigned int to string 123 format
char* i8tostr3(const uint8_t xx) {
conv[4] = RJDIGIT(xx, 100);
conv[5] = RJDIGIT(xx, 10);
conv[6] = DIGIMOD(xx, 1);
return &conv[5];
return &conv[4];
}
// Convert signed int to rj string with 123 or -12 format
char* itostr3(const int &x) {
char* itostr3(const int x) {
int xx = x;
conv[4] = MINUSOR(xx, RJDIGIT(xx, 100));
conv[5] = RJDIGIT(xx, 10);
@ -73,7 +74,7 @@ void safe_delay(millis_t ms) {
}
// Convert unsigned int to lj string with 123 format
char* itostr3left(const int &xx) {
char* itostr3left(const int xx) {
char *str = &conv[6];
*str = DIGIMOD(xx, 1);
if (xx >= 10) {
@ -85,7 +86,7 @@ void safe_delay(millis_t ms) {
}
// Convert signed int to rj string with 1234, _123, -123, _-12, or __-1 format
char *itostr4sign(const int &x) {
char *itostr4sign(const int x) {
const bool neg = x < 0;
const int xx = neg ? -x : x;
if (x >= 1000) {

@ -31,17 +31,17 @@ void safe_delay(millis_t ms);
#if ENABLED(ULTRA_LCD)
// Convert unsigned int to string with 12 format
char* itostr2(const uint8_t &x);
// Convert uint8_t to string with 123 format
char* i8tostr3(const uint8_t x);
// Convert signed int to rj string with 123 or -12 format
char* itostr3(const int &x);
char* itostr3(const int x);
// Convert unsigned int to lj string with 123 format
char* itostr3left(const int &xx);
char* itostr3left(const int xx);
// Convert signed int to rj string with _123, -123, _-12, or __-1 format
char *itostr4sign(const int &x);
char *itostr4sign(const int x);
// Convert unsigned float to string with 1.23 format
char* ftostr12ns(const float &x);

Loading…
Cancel
Save