-
Notifications
You must be signed in to change notification settings - Fork 1
/
menu_tune.cpp
98 lines (84 loc) · 2.51 KB
/
menu_tune.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#include "language.h"
#include "temperature.h"
#include "ultralcd.h"
#ifdef ULTRA_LCD
#include "Marlin.h"
#include "language.h"
#include "temperature.h"
#include "EEPROMwrite.h"
extern volatile int feedmultiply;
extern volatile bool feedmultiplychanged;
extern volatile int extrudemultiply;
extern long position[4];
/*
* Axis movement menu
*/
#define TUNE_SPEED 0
#define EXTRUDER_1 0
#define EXTRUDER_2 1
#define EXTRUDER_3 2
static void mt_Show(uint8_t line, const char *value)
{
lcd.setCursor(13,line);
lcd.print(value);
}
static void mt_ShowSpeed(uint8_t line, uint8_t arg)
{
mt_Show(line, ftostr3(feedmultiply));
}
static void mt_ClickSpeed(uint8_t line, volatile long &pos, bool &adjustValue, uint8_t arg)
{
adjustValue = !adjustValue;
if(adjustValue) {
pos = feedmultiply;
}
}
void mt_AdjustSpeed(uint8_t line, volatile long &pos, uint8_t arg)
{
limitEncoder(pos, 1, 400);
feedmultiply = encoderpos;
feedmultiplychanged = true;
mt_Show(line, itostr3(encoderpos));
}
static void mt_ShowFlow(uint8_t line, uint8_t arg)
{
mt_Show(line, ftostr3(feedmultiply));
}
static void mt_ClickFlow(uint8_t line, volatile long &pos, bool &adjustValue, uint8_t arg)
{
adjustValue =! adjustValue;
if (adjustValue) {
pos = axis_steps_per_unit[E_AXIS]*100.0;
} else {
float factor = float(encoderpos)/100.0/float(axis_steps_per_unit[E_AXIS]);
position[E_AXIS] = lround(position[E_AXIS]*factor);
axis_steps_per_unit[E_AXIS] = pos/100.0;
}
}
void mt_AdjustFlow(uint8_t line, volatile long &pos, uint8_t arg)
{
limitEncoder(pos, 5, 999999);
mt_Show(line, ftostr52(encoderpos/100.0));
}
static const menu_t menu[] __attribute__((__progmem__)) = {
{ MSG_MAIN, NULL, mct_ClickMenu, NULL, Main_Menu },
{ MSG_SPEED, mt_ShowSpeed, mt_ClickSpeed, mt_AdjustSpeed, 0 },
{ MSG_FLOW, mt_ShowFlow, mt_ClickFlow, mt_AdjustFlow, 0 },
{ MSG_NOZZLE, mct_ShowNozzle, mct_ClickNozzle, mct_AdjustTemp, EXTRUDER_1 },
#if EXTRUDERS > 1
{ MSG_NOZZLE1, mct_ShowNozzle, mct_ClickNozzle, mct_AdjustTemp, EXTRUDER_2 },
#endif
#if EXTRUDERS > 2
{ MSG_NOZZLE2, mct_ShowNozzle, mct_ClickNozzle, mct_AdjustTemp, EXTRUDER_3 },
#endif
#if defined BED_USES_THERMISTOR || defined BED_USES_AD595
{ MSG_BED, mct_ShowBed, mct_ClickBed, mct_AdjustTemp, 0 },
#endif
{ MSG_FAN_SPEED,mct_ShowFan, mct_ClickFan, mct_AdjustFan, 0 },
};
#define MENU_MAX (sizeof(menu) / sizeof(menu[0]))
void MainMenu::showTune()
{
show(menu, MENU_MAX);
}
#endif