Skip to content
This repository has been archived by the owner on Aug 27, 2023. It is now read-only.

Commit

Permalink
Add M155 support for periodic temperature reporting
Browse files Browse the repository at this point in the history
M155 turns on automatic periodic temperature reporting.

Enables live temperature reporting while waiting for temps (M119)
and during normal gcode processing without depending on M105 requests
from the host.

Also add "cap: AUTOREPORT_TEMP" capability report to M115. It's a
thing Marlin does and Octorprint needs to see it before it will use
M155.

Usage: M155 S<period> [P<probe>]
 S specifies the period in seconds to report the temperatures
 P optionally specifies which sensor to report

  S0 disables automatic reporting
  Omitting the P field reports on all sensors
  • Loading branch information
phord committed Aug 5, 2018
1 parent db91699 commit 329012a
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 1 deletion.
2 changes: 2 additions & 0 deletions clock.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ static void clock_250ms(void) {

temp_residency_tick();

temp_periodic_print();

if (temp_waiting()) {
serial_writestr_P(PSTR("Waiting for target temp\n"));
wait_for_temp = 1;
Expand Down
36 changes: 35 additions & 1 deletion gcode_process.c
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,12 @@ void process_gcode_command() {
//? FIRMWARE_NAME:Teacup FIRMWARE_URL:http://github.com/traumflug/Teacup_Firmware/ PROTOCOL_VERSION:1.0 MACHINE_TYPE:Mendel EXTRUDER_COUNT:1 TEMP_SENSOR_COUNT:1 HEATER_COUNT:1
//?

sersendf_P(PSTR("FIRMWARE_NAME:Teacup FIRMWARE_URL:http://github.com/traumflug/Teacup_Firmware/ PROTOCOL_VERSION:1.0 MACHINE_TYPE:Mendel EXTRUDER_COUNT:%d TEMP_SENSOR_COUNT:%d HEATER_COUNT:%d\n"), 1, NUM_TEMP_SENSORS, NUM_HEATERS);
sersendf_P(PSTR("FIRMWARE_NAME:Teacup "
"FIRMWARE_URL:http://github.com/traumflug/Teacup_Firmware/ "
"PROTOCOL_VERSION:1.0 MACHINE_TYPE:Mendel EXTRUDER_COUNT:%d "
"TEMP_SENSOR_COUNT:%d HEATER_COUNT:%d\n"
"cap:AUTOREPORT_TEMP:%d\n"),
1, NUM_TEMP_SENSORS, NUM_HEATERS, 1);
break;

case 116:
Expand Down Expand Up @@ -848,6 +853,35 @@ void process_gcode_command() {
#endif
break;

case 155:
//? --- M155: Report Temperature(s) Periodically ---
//?
//? Example: M155 Sn
//?
//? turns on periodic reporting of the temperatures of the current
//? extruder and the build base in degrees Celsius. The reporting
//? interval is given in seconds as the S parameter. Use S0 to disable
//? periodic temperature reporting. The reporting format is the same
//? as for M105, except there is no "ok" at the start of each report.
//? For example, the line sent to the host periodically looks like
//?
//? <tt>T:201 B:117</tt>
//?
//? Teacup supports an optional P parameter as a zero-based temperature
//? sensor index to address.
//?

// S<period-seconds> is required
if ( ! next_target.seen_S)
break;
#ifdef ENFORCE_ORDER
queue_wait();
#endif
if ( ! next_target.seen_P)
next_target.P = TEMP_SENSOR_none;
temp_periodic_config(next_target.S, next_target.P);
break;

case 220:
//? --- M220: Set speed factor override percentage ---
if ( ! next_target.seen_S)
Expand Down
28 changes: 28 additions & 0 deletions temp.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,13 @@ static struct {
static uint8_t wait_for_temp = 0;


// How often to report temperature automatically
static uint8_t periodic_seconds;
static temp_sensor_t periodic_index;

// Count time between temperature reports
static uint8_t periodic_timer;

/// Set up temp sensors.
void temp_init() {
temp_sensor_t i;
Expand Down Expand Up @@ -626,6 +633,27 @@ static void single_temp_print(temp_sensor_t index) {
#endif
}

/// set parameters for periodic temperature reporting
/// \param secs reporting interval in seconds; 0 to disable reporting
/// \param index sensor to report
void temp_periodic_config(uint8_t secs, temp_sensor_t index) {
periodic_seconds = secs;
periodic_index = index;
periodic_timer = secs;
}

/// send temperatures to the host periodically.
/// Called once per second from clock.c
void temp_periodic_print() {
if (periodic_seconds == 0)
return;
if (--periodic_timer != 0)
return;

temp_print(periodic_index);
periodic_timer = periodic_seconds;
}

/// send temperatures to host
/// \param index sensor value to send
void temp_print(temp_sensor_t index) {
Expand Down
3 changes: 3 additions & 0 deletions temp.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ void temp_heater_tick(void);

void temp_residency_tick(void);

void temp_periodic_config(uint8_t secs, temp_sensor_t index);
void temp_periodic_print(void);

uint8_t temp_achieved(void);

void temp_set_wait(void);
Expand Down

0 comments on commit 329012a

Please sign in to comment.