mirror of
https://github.com/synthetos/g2.git
synced 2026-09-22 19:43:53 +08:00
Refactor tool (startup tool is 1 now), speedup marlin temp display, added str_concat utility.
This commit is contained in:
+84
-74
@@ -666,7 +666,6 @@ stat_t cm_set_heater_p(nvObj_t *nv)
|
||||
case '2': { pid2._p_factor = nv->value / 100.0; break; }
|
||||
case '3': { pid3._p_factor = nv->value / 100.0; break; }
|
||||
|
||||
// Failsafe. We can only get here if we set it up in config_app, but not here.
|
||||
default: { break; }
|
||||
}
|
||||
|
||||
@@ -684,7 +683,6 @@ stat_t cm_get_heater_i(nvObj_t *nv)
|
||||
case '2': { nv->value = pid2._i_factor * 100.0; break; }
|
||||
case '3': { nv->value = pid3._i_factor * 100.0; break; }
|
||||
|
||||
// Failsafe. We can only get here if we set it up in config_app, but not here.
|
||||
default: { nv->value = 0.0; break; }
|
||||
}
|
||||
|
||||
@@ -700,7 +698,6 @@ stat_t cm_set_heater_i(nvObj_t *nv)
|
||||
case '2': { pid2._i_factor = nv->value / 100.0; break; }
|
||||
case '3': { pid3._i_factor = nv->value / 100.0; break; }
|
||||
|
||||
// Failsafe. We can only get here if we set it up in config_app, but not here.
|
||||
default: { break; }
|
||||
}
|
||||
|
||||
@@ -717,7 +714,6 @@ stat_t cm_get_heater_d(nvObj_t *nv)
|
||||
case '2': { nv->value = pid2._d_factor * 100.0; break; }
|
||||
case '3': { nv->value = pid3._d_factor * 100.0; break; }
|
||||
|
||||
// Failsafe. We can only get here if we set it up in config_app, but not here.
|
||||
default: { nv->value = 0.0; break; }
|
||||
}
|
||||
nv->precision = GET_TABLE_WORD(precision);
|
||||
@@ -732,7 +728,6 @@ stat_t cm_set_heater_d(nvObj_t *nv)
|
||||
case '2': { pid2._d_factor = nv->value / 100.0; break; }
|
||||
case '3': { pid3._d_factor = nv->value / 100.0; break; }
|
||||
|
||||
// Failsafe. We can only get here if we set it up in config_app, but not here.
|
||||
default: { break; }
|
||||
}
|
||||
return (STAT_OK);
|
||||
@@ -740,67 +735,81 @@ stat_t cm_set_heater_d(nvObj_t *nv)
|
||||
|
||||
/*
|
||||
* cm_get_set_temperature()/cm_set_set_temperature() - get/set the set value of the PID
|
||||
*
|
||||
* There are both the file-to-file use version, and the NV-pair form (which uses the other).
|
||||
*/
|
||||
stat_t cm_get_set_temperature(nvObj_t *nv)
|
||||
float cm_get_set_temperature(const uint8_t heater)
|
||||
{
|
||||
switch(_get_heater_number(nv)) {
|
||||
case '1': { nv->value = pid1._set_point; break; }
|
||||
case '2': { nv->value = pid2._set_point; break; }
|
||||
case '3': { nv->value = pid3._set_point; break; }
|
||||
|
||||
// Failsafe. We can only get here if we set it up in config_app, but not here.
|
||||
default: { nv->value = 0.0; break; }
|
||||
switch(heater) {
|
||||
case 1: { return pid1._set_point; break; }
|
||||
case 2: { return pid2._set_point; break; }
|
||||
case 3: { return pid3._set_point; break; }
|
||||
default: { break; }
|
||||
}
|
||||
|
||||
return 0.0;
|
||||
}
|
||||
stat_t cm_get_set_temperature(nvObj_t *nv)
|
||||
{
|
||||
nv->value = cm_get_set_temperature(_get_heater_number(nv) - '0');
|
||||
nv->precision = GET_TABLE_WORD(precision);
|
||||
nv->valuetype = TYPE_FLOAT;
|
||||
|
||||
return (STAT_OK);
|
||||
}
|
||||
stat_t cm_set_set_temperature(nvObj_t *nv)
|
||||
void cm_set_set_temperature(const uint8_t heater, const float value)
|
||||
{
|
||||
switch(_get_heater_number(nv)) {
|
||||
case '1': { pid1._set_point = min(TEMP_MAX_SETPOINT, nv->value); break; }
|
||||
case '2': { pid2._set_point = min(TEMP_MAX_SETPOINT, nv->value); break; }
|
||||
case '3': { pid3._set_point = min(TEMP_MAX_SETPOINT, nv->value); break; }
|
||||
switch(heater) {
|
||||
case 1: { pid1._set_point = min(TEMP_MAX_SETPOINT, value); break; }
|
||||
case 2: { pid2._set_point = min(TEMP_MAX_SETPOINT, value); break; }
|
||||
case 3: { pid3._set_point = min(TEMP_MAX_SETPOINT, value); break; }
|
||||
|
||||
// Failsafe. We can only get here if we set it up in config_app, but not here.
|
||||
// default to quiet the compiler
|
||||
default: { break; }
|
||||
}
|
||||
|
||||
}
|
||||
stat_t cm_set_set_temperature(nvObj_t *nv)
|
||||
{
|
||||
cm_set_set_temperature(_get_heater_number(nv) - '0', nv->value);
|
||||
return (STAT_OK);
|
||||
}
|
||||
|
||||
/*
|
||||
* cm_get_fan_power()/cm_set_fan_power() - get/set the set high-value setting of the heater fan
|
||||
*/
|
||||
stat_t cm_get_fan_power(nvObj_t *nv)
|
||||
float cm_get_fan_power(const uint8_t heater)
|
||||
{
|
||||
switch(_get_heater_number(nv)) {
|
||||
case '1': { nv->value = min(1.0f, heater_fan1.max_value); break; }
|
||||
// case '2': { nv->value = min(1.0f, heater_fan2.max_value); break; }
|
||||
// case '3': { nv->value = min(1.0f, heater_fan3.max_value); break; }
|
||||
switch(heater) {
|
||||
case 1: { return min(1.0f, heater_fan1.max_value); }
|
||||
// case 2: { return min(1.0f, heater_fan2.max_value); }
|
||||
// case 3: { return min(1.0f, heater_fan3.max_value); }
|
||||
|
||||
// Failsafe. We can only get here if we set it up in config_app, but not here.
|
||||
default: { nv->value = 0.0; break; }
|
||||
default: { break; }
|
||||
}
|
||||
|
||||
return 0.0;
|
||||
}
|
||||
stat_t cm_get_fan_power(nvObj_t *nv)
|
||||
{
|
||||
nv->value = cm_get_fan_power(_get_heater_number(nv) - '0');
|
||||
nv->precision = GET_TABLE_WORD(precision);
|
||||
nv->valuetype = TYPE_FLOAT;
|
||||
|
||||
return (STAT_OK);
|
||||
}
|
||||
stat_t cm_set_fan_power(nvObj_t *nv)
|
||||
{
|
||||
switch(_get_heater_number(nv)) {
|
||||
case '1': { heater_fan1.max_value = max(0.0f, nv->value); break; }
|
||||
// case '2': { heater_fan2.max_value = max(0.0, nv->value); break; }
|
||||
// case '3': { heater_fan3.max_value = max(0.0, nv->value); break; }
|
||||
|
||||
// Failsafe. We can only get here if we set it up in config_app, but not here.
|
||||
void cm_set_fan_power(const uint8_t heater, const float value)
|
||||
{
|
||||
switch(heater) {
|
||||
case 1: { heater_fan1.max_value = max(0.0f, value); break; }
|
||||
// case 2: { heater_fan2.max_value = max(0.0, value); break; }
|
||||
// case 3: { heater_fan3.max_value = max(0.0, value); break; }
|
||||
default: { break; }
|
||||
}
|
||||
|
||||
}
|
||||
stat_t cm_set_fan_power(nvObj_t *nv)
|
||||
{
|
||||
cm_set_fan_power(_get_heater_number(nv) - '0', nv->value);
|
||||
return (STAT_OK);
|
||||
}
|
||||
|
||||
@@ -814,7 +823,6 @@ stat_t cm_get_fan_min_power(nvObj_t *nv)
|
||||
// case '2': { nv->value = heater_fan2.min_value; break; }
|
||||
// case '3': { nv->value = heater_fan3.min_value; break; }
|
||||
|
||||
// Failsafe. We can only get here if we set it up in config_app, but not here.
|
||||
default: { nv->value = 0.0; break; }
|
||||
}
|
||||
|
||||
@@ -830,10 +838,9 @@ stat_t cm_set_fan_min_power(nvObj_t *nv)
|
||||
// case '2': { heater_fan2.min_value = min(0.0, nv->value); break; }
|
||||
// case '3': { heater_fan3.min_value = min(0.0, nv->value); break; }
|
||||
|
||||
// Failsafe. We can only get here if we set it up in config_app, but not here.
|
||||
default: { break; }
|
||||
}
|
||||
|
||||
|
||||
return (STAT_OK);
|
||||
}
|
||||
|
||||
@@ -847,7 +854,6 @@ stat_t cm_get_fan_low_temp(nvObj_t *nv)
|
||||
// case '2': { nv->value = heater_fan2.low_temp; break; }
|
||||
// case '3': { nv->value = heater_fan3.low_temp; break; }
|
||||
|
||||
// Failsafe. We can only get here if we set it up in config_app, but not here.
|
||||
default: { nv->value = 0.0; break; }
|
||||
}
|
||||
|
||||
@@ -863,10 +869,9 @@ stat_t cm_set_fan_low_temp(nvObj_t *nv)
|
||||
// case '2': { heater_fan2.low_temp = min(0.0f, nv->value); break; }
|
||||
// case '3': { heater_fan3.low_temp = min(0.0f, nv->value); break; }
|
||||
|
||||
// Failsafe. We can only get here if we set it up in config_app, but not here.
|
||||
default: { break; }
|
||||
}
|
||||
|
||||
|
||||
return (STAT_OK);
|
||||
}
|
||||
|
||||
@@ -880,7 +885,6 @@ stat_t cm_get_fan_high_temp(nvObj_t *nv)
|
||||
// case '2': { nv->value = heater_fan2.high_temp; break; }
|
||||
// case '3': { nv->value = heater_fan3.high_temp; break; }
|
||||
|
||||
// Failsafe. We can only get here if we set it up in config_app, but not here.
|
||||
default: { nv->value = 0.0; break; }
|
||||
}
|
||||
|
||||
@@ -896,27 +900,30 @@ stat_t cm_set_fan_high_temp(nvObj_t *nv)
|
||||
// case '2': { heater_fan2.high_temp = min(0.0f, nv->value); break; }
|
||||
// case '3': { heater_fan3.high_temp = min(0.0f, nv->value); break; }
|
||||
|
||||
// Failsafe. We can only get here if we set it up in config_app, but not here.
|
||||
default: { break; }
|
||||
}
|
||||
|
||||
|
||||
return (STAT_OK);
|
||||
}
|
||||
|
||||
/*
|
||||
* cm_get_at_temperature() - get a boolean if the heater has reaced the set value of the PID
|
||||
*/
|
||||
stat_t cm_get_at_temperature(nvObj_t *nv)
|
||||
bool cm_get_at_temperature(const uint8_t heater)
|
||||
{
|
||||
switch(_get_heater_number(nv)) {
|
||||
case '1': { nv->value = pid1._at_set_point; break; }
|
||||
case '2': { nv->value = pid2._at_set_point; break; }
|
||||
case '3': { nv->value = pid3._at_set_point; break; }
|
||||
switch(heater) {
|
||||
case 1: { return pid1._at_set_point; }
|
||||
case 2: { return pid2._at_set_point; }
|
||||
case 3: { return pid3._at_set_point; }
|
||||
|
||||
// Failsafe. We can only get here if we set it up in config_app, but not here.
|
||||
default: { nv->value = 0.0; break; }
|
||||
default: { break; }
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
stat_t cm_get_at_temperature(nvObj_t *nv)
|
||||
{
|
||||
nv->value = cm_get_at_temperature(_get_heater_number(nv) - '0');
|
||||
nv->precision = GET_TABLE_WORD(precision);
|
||||
nv->valuetype = TYPE_BOOL;
|
||||
|
||||
@@ -927,16 +934,20 @@ stat_t cm_get_at_temperature(nvObj_t *nv)
|
||||
/*
|
||||
* cm_get_heater_output() - get the output value (PWM duty cycle) of the PID
|
||||
*/
|
||||
float cm_get_heater_output(const uint8_t heater)
|
||||
{
|
||||
switch(heater) {
|
||||
case 1: { return (float)fet_pin1; }
|
||||
case 2: { return (float)fet_pin2; }
|
||||
case 3: { return (float)fet_pin3; }
|
||||
|
||||
default: { break; }
|
||||
}
|
||||
return 0.0;
|
||||
}
|
||||
stat_t cm_get_heater_output(nvObj_t *nv)
|
||||
{
|
||||
switch(_get_heater_number(nv)) {
|
||||
case '1': { nv->value = (float)fet_pin1; break; }
|
||||
case '2': { nv->value = (float)fet_pin2; break; }
|
||||
case '3': { nv->value = (float)fet_pin3; break; }
|
||||
|
||||
// Failsafe. We can only get here if we set it up in config_app, but not here.
|
||||
default: { nv->value = 0.0; break; }
|
||||
}
|
||||
nv->value = cm_get_heater_output(_get_heater_number(nv) - '0');
|
||||
nv->precision = GET_TABLE_WORD(precision);
|
||||
nv->valuetype = TYPE_FLOAT;
|
||||
|
||||
@@ -953,7 +964,6 @@ stat_t cm_get_heater_adc(nvObj_t *nv)
|
||||
case '2': { nv->value = (float)thermistor2.raw_adc_value; break; }
|
||||
case '3': { nv->value = (float)thermistor3.raw_adc_value; break; }
|
||||
|
||||
// Failsafe. We can only get here if we set it up in config_app, but not here.
|
||||
default: { nv->value = 0.0; break; }
|
||||
}
|
||||
nv->precision = GET_TABLE_WORD(precision);
|
||||
@@ -965,17 +975,21 @@ stat_t cm_get_heater_adc(nvObj_t *nv)
|
||||
/*
|
||||
* cm_get_temperature() - get the current temperature
|
||||
*/
|
||||
float cm_get_temperature(const uint8_t heater)
|
||||
{
|
||||
switch(heater) {
|
||||
case 1: { return (last_reported_temp1 = thermistor1.temperature_exact()); }
|
||||
case 2: { return (last_reported_temp2 = thermistor2.temperature_exact()); }
|
||||
case 3: { return (last_reported_temp3 = thermistor3.temperature_exact()); }
|
||||
|
||||
default: { break; }
|
||||
}
|
||||
|
||||
return 0.0;
|
||||
}
|
||||
stat_t cm_get_temperature(nvObj_t *nv)
|
||||
{
|
||||
switch(_get_heater_number(nv)) {
|
||||
case '1': { nv->value = last_reported_temp1 = thermistor1.temperature_exact(); break; }
|
||||
case '2': { nv->value = last_reported_temp2 = thermistor2.temperature_exact(); break; }
|
||||
case '3': { nv->value = last_reported_temp3 = thermistor3.temperature_exact(); break; }
|
||||
|
||||
// Failsafe. We can only get here if we set it up in config_app, but not here.
|
||||
default: { nv->value = 0.0; break; }
|
||||
}
|
||||
|
||||
nv->value = cm_get_temperature(_get_heater_number(nv) - '0');
|
||||
nv->precision = GET_TABLE_WORD(precision);
|
||||
nv->valuetype = TYPE_FLOAT;
|
||||
|
||||
@@ -992,7 +1006,6 @@ stat_t cm_get_thermistor_resistance(nvObj_t *nv)
|
||||
case '2': { nv->value = thermistor2.get_resistance(); break; }
|
||||
case '3': { nv->value = thermistor3.get_resistance(); break; }
|
||||
|
||||
// Failsafe. We can only get here if we set it up in config_app, but not here.
|
||||
default: { nv->value = 0.0; break; }
|
||||
}
|
||||
nv->precision = GET_TABLE_WORD(precision);
|
||||
@@ -1022,7 +1035,6 @@ stat_t cm_get_pid_p(nvObj_t *nv)
|
||||
case '2': { nv->value = pid2._proportional; break; }
|
||||
case '3': { nv->value = pid3._proportional; break; }
|
||||
|
||||
// Failsafe. We can only get here if we set it up in config_app, but not here.
|
||||
default: { nv->value = 0.0; break; }
|
||||
}
|
||||
nv->precision = GET_TABLE_WORD(precision);
|
||||
@@ -1041,7 +1053,6 @@ stat_t cm_get_pid_i(nvObj_t *nv)
|
||||
case '2': { nv->value = pid2._integral; break; }
|
||||
case '3': { nv->value = pid3._integral; break; }
|
||||
|
||||
// Failsafe. We can only get here if we set it up in config_app, but not here.
|
||||
default: { nv->value = 0.0; break; }
|
||||
}
|
||||
nv->precision = GET_TABLE_WORD(precision);
|
||||
@@ -1060,12 +1071,11 @@ stat_t cm_get_pid_d(nvObj_t *nv)
|
||||
case '2': { nv->value = pid2._derivative; break; }
|
||||
case '3': { nv->value = pid3._derivative; break; }
|
||||
|
||||
// Failsafe. We can only get here if we set it up in config_app, but not here.
|
||||
default: { nv->value = 0.0; break; }
|
||||
}
|
||||
nv->precision = GET_TABLE_WORD(precision);
|
||||
nv->valuetype = TYPE_FLOAT;
|
||||
|
||||
|
||||
return (STAT_OK);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user