Commit 05115f24 authored by MagoKimbra's avatar MagoKimbra

Add Delta menu Calibration

parent aa275606
...@@ -65,7 +65,7 @@ ...@@ -65,7 +65,7 @@
#include "firmware_test.h" #include "firmware_test.h"
#endif #endif
#define VERSION_STRING "4.0.0" #define VERSION_STRING " 4.0.1 "
// look here for descriptions of G-codes: http://linuxcnc.org/handbook/gcode/g-code.html // look here for descriptions of G-codes: http://linuxcnc.org/handbook/gcode/g-code.html
// http://objects.reprap.org/wiki/Mendel_User_Manual:_RepRapGCodes // http://objects.reprap.org/wiki/Mendel_User_Manual:_RepRapGCodes
......
...@@ -26,21 +26,24 @@ ...@@ -26,21 +26,24 @@
/** Amount of free RAM /** Amount of free RAM
* \return The number of free bytes. * \return The number of free bytes.
*/ */
#ifdef __arm__
extern "C" char* sbrk(int incr);
int SdFatUtil::FreeRam() { int SdFatUtil::FreeRam() {
extern int __bss_end; char top;
extern int* __brkval; return &top - reinterpret_cast<char*>(sbrk(0));
int free_memory;
if (reinterpret_cast<int>(__brkval) == 0) {
// if no heap use from end of bss section
free_memory = reinterpret_cast<int>(&free_memory)
- reinterpret_cast<int>(&__bss_end);
} else {
// use from top of stack to heap
free_memory = reinterpret_cast<int>(&free_memory)
- reinterpret_cast<int>(__brkval);
}
return free_memory;
} }
#else // __arm__
extern char *__brkval;
extern char __bss_end;
/** Amount of free RAM
* \return The number of free bytes.
*/
int SdFatUtil::FreeRam() {
char top;
return __brkval ? &top - __brkval : &top - &__bss_end;
}
#endif // __arm
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
/** %Print a string in flash memory. /** %Print a string in flash memory.
* *
......
...@@ -337,7 +337,7 @@ static void lcd_implementation_drawmenu_generic(uint8_t row, const char* pstr, c ...@@ -337,7 +337,7 @@ static void lcd_implementation_drawmenu_generic(uint8_t row, const char* pstr, c
u8g.setColorIndex(1); // restore settings to black on white u8g.setColorIndex(1); // restore settings to black on white
} }
static void _drawmenu_setting_edit_generic(uint8_t row, const char* pstr, char pre_char, char* data, bool pgm) { static void _drawmenu_setting_edit_generic(uint8_t row, const char* pstr, char pre_char, const char* data, bool pgm) {
char c; char c;
uint8_t n = LCD_WIDTH - 1 - 2 - (pgm ? strlen_P(data) : strlen(data)); uint8_t n = LCD_WIDTH - 1 - 2 - (pgm ? strlen_P(data) : strlen(data));
......
...@@ -148,6 +148,14 @@ ...@@ -148,6 +148,14 @@
#define MSG_PURGE_XMM "Purge " STRINGIFY(LCD_PURGE_LENGTH) "mm" #define MSG_PURGE_XMM "Purge " STRINGIFY(LCD_PURGE_LENGTH) "mm"
#define MSG_RETRACT_XMM "Retract " STRINGIFY(LCD_RETRACT_LENGTH) "mm" #define MSG_RETRACT_XMM "Retract " STRINGIFY(LCD_RETRACT_LENGTH) "mm"
#ifdef DELTA
#define MSG_DELTA_CALIBRATE "Delta Calibration"
#define MSG_DELTA_CALIBRATE_X "Calibrate X"
#define MSG_DELTA_CALIBRATE_Y "Calibrate Y"
#define MSG_DELTA_CALIBRATE_Z "Calibrate Z"
#define MSG_DELTA_CALIBRATE_CENTER "Calibrate Center"
#endif // DELTA
#ifdef FIRMWARE_TEST #ifdef FIRMWARE_TEST
#define MSG_FWTEST_YES "Put the Y command to go next" #define MSG_FWTEST_YES "Put the Y command to go next"
#define MSG_FWTEST_NO "Put the N command to go next" #define MSG_FWTEST_NO "Put the N command to go next"
......
...@@ -73,6 +73,10 @@ static void lcd_set_contrast(); ...@@ -73,6 +73,10 @@ static void lcd_set_contrast();
static void lcd_control_retract_menu(); static void lcd_control_retract_menu();
static void lcd_sdcard_menu(); static void lcd_sdcard_menu();
#ifdef DELTA
static void lcd_delta_calibrate_menu();
#endif // DELTA
static void lcd_quick_feedback();//Cause an LCD refresh, and give the user visual or audible feedback that something has happened static void lcd_quick_feedback();//Cause an LCD refresh, and give the user visual or audible feedback that something has happened
/* Different types of actions that can be used in menu items. */ /* Different types of actions that can be used in menu items. */
...@@ -342,6 +346,9 @@ static void lcd_main_menu() ...@@ -342,6 +346,9 @@ static void lcd_main_menu()
MENU_ITEM(submenu, MSG_TUNE, lcd_tune_menu); MENU_ITEM(submenu, MSG_TUNE, lcd_tune_menu);
}else{ }else{
MENU_ITEM(submenu, MSG_PREPARE, lcd_prepare_menu); MENU_ITEM(submenu, MSG_PREPARE, lcd_prepare_menu);
#ifdef DELTA
MENU_ITEM(submenu, MSG_DELTA_CALIBRATE, lcd_delta_calibrate_menu);
#endif // DELTA
} }
MENU_ITEM(submenu, MSG_CONTROL, lcd_control_menu); MENU_ITEM(submenu, MSG_CONTROL, lcd_control_menu);
#ifdef SDSUPPORT #ifdef SDSUPPORT
...@@ -762,7 +769,9 @@ static void lcd_prepare_menu() ...@@ -762,7 +769,9 @@ static void lcd_prepare_menu()
#endif #endif
MENU_ITEM(gcode, MSG_DISABLE_STEPPERS, PSTR("M84")); MENU_ITEM(gcode, MSG_DISABLE_STEPPERS, PSTR("M84"));
MENU_ITEM(gcode, MSG_AUTO_HOME, PSTR("G28")); MENU_ITEM(gcode, MSG_AUTO_HOME, PSTR("G28"));
#ifndef DELTA
MENU_ITEM(gcode, MSG_BED_SETTING, PSTR("G28 M")); MENU_ITEM(gcode, MSG_BED_SETTING, PSTR("G28 M"));
#endif
MENU_ITEM(function, MSG_SET_HOME_OFFSETS, lcd_set_home_offsets); MENU_ITEM(function, MSG_SET_HOME_OFFSETS, lcd_set_home_offsets);
//MENU_ITEM(gcode, MSG_SET_ORIGIN, PSTR("G92 X0 Y0 Z0")); //MENU_ITEM(gcode, MSG_SET_ORIGIN, PSTR("G92 X0 Y0 Z0"));
//Add Preset menu for LASER setting '14. 7. 22 //Add Preset menu for LASER setting '14. 7. 22
...@@ -804,6 +813,19 @@ static void lcd_prepare_menu() ...@@ -804,6 +813,19 @@ static void lcd_prepare_menu()
END_MENU(); END_MENU();
} }
#ifdef DELTA
static void lcd_delta_calibrate_menu()
{
START_MENU();
MENU_ITEM(back, MSG_MAIN, lcd_main_menu);
MENU_ITEM(gcode, MSG_AUTO_HOME, PSTR("G28"));
MENU_ITEM(gcode, MSG_DELTA_CALIBRATE_X, PSTR("G0 F8000 X-77.94 Y-45 Z0"));
MENU_ITEM(gcode, MSG_DELTA_CALIBRATE_Y, PSTR("G0 F8000 X77.94 Y-45 Z0"));
MENU_ITEM(gcode, MSG_DELTA_CALIBRATE_Z, PSTR("G0 F8000 X0 Y90 Z0"));
MENU_ITEM(gcode, MSG_DELTA_CALIBRATE_CENTER, PSTR("G0 F8000 X0 Y0 Z0"));
END_MENU();
}
#endif // DELTA
float move_menu_scale; float move_menu_scale;
static void lcd_move_menu_axis(); static void lcd_move_menu_axis();
...@@ -1725,7 +1747,52 @@ char *ftostr12ns(const float &x) ...@@ -1725,7 +1747,52 @@ char *ftostr12ns(const float &x)
return conv; return conv;
} }
// Convert int to lj string with +123.0 format // convert float to space-padded string with -_23.4_ format
char *ftostr32sp(const float &x) {
long xx = abs(x * 100);
uint8_t dig;
if (x < 0) { // negative val = -_0
conv[0] = '-';
dig = (xx / 1000) % 10;
conv[1] = dig ? '0' + dig : ' ';
}
else { // positive val = __0
dig = (xx / 10000) % 10;
if (dig) {
conv[0] = '0' + dig;
conv[1] = '0' + (xx / 1000) % 10;
}
else {
conv[0] = ' ';
dig = (xx / 1000) % 10;
conv[1] = dig ? '0' + dig : ' ';
}
}
conv[2] = '0' + (xx / 100) % 10; // lsd always
dig = xx % 10;
if (dig) { // 2 decimal places
conv[5] = '0' + dig;
conv[4] = '0' + (xx / 10) % 10;
conv[3] = '.';
}
else { // 1 or 0 decimal place
dig = (xx / 10) % 10;
if (dig) {
conv[4] = '0' + dig;
conv[3] = '.';
}
else {
conv[3] = conv[4] = ' ';
}
conv[5] = ' ';
}
conv[6] = '\0';
return conv;
}
char *itostr31(const int &xx) char *itostr31(const int &xx)
{ {
conv[0]=(xx>=0)?'+':'-'; conv[0]=(xx>=0)?'+':'-';
......
...@@ -126,6 +126,7 @@ char *ftostr31ns(const float &x); // float to string without sign character ...@@ -126,6 +126,7 @@ char *ftostr31ns(const float &x); // float to string without sign character
char *ftostr31(const float &x); char *ftostr31(const float &x);
char *ftostr32(const float &x); char *ftostr32(const float &x);
char *ftostr12ns(const float &x); char *ftostr12ns(const float &x);
char *ftostr32sp(const float &x); // remove zero-padding from ftostr32
char *ftostr5(const float &x); char *ftostr5(const float &x);
char *ftostr51(const float &x); char *ftostr51(const float &x);
char *ftostr52(const float &x); char *ftostr52(const float &x);
......
...@@ -572,7 +572,7 @@ static void lcd_implementation_status_screen() ...@@ -572,7 +572,7 @@ static void lcd_implementation_status_screen()
# endif//LCD_WIDTH > 19 # endif//LCD_WIDTH > 19
lcd.setCursor(LCD_WIDTH - 8, 1); lcd.setCursor(LCD_WIDTH - 8, 1);
lcd.print('Z'); lcd.print('Z');
lcd.print(ftostr32(current_position[Z_AXIS] + 0.00001)); lcd.print(ftostr32sp(current_position[Z_AXIS] + 0.00001));
#endif//LCD_HEIGHT > 2 #endif//LCD_HEIGHT > 2
#if LCD_HEIGHT > 3 #if LCD_HEIGHT > 3
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment