Use uint8_t for all fan speeds (#12032)
This commit is contained in:
@ -207,7 +207,7 @@ static void lcd_implementation_status_screen() {
|
||||
static uint8_t fan_frame;
|
||||
if (old_blink != blink) {
|
||||
old_blink = blink;
|
||||
if (!fanSpeeds[0] || ++fan_frame >= FAN_ANIM_FRAMES) fan_frame = 0;
|
||||
if (!fan_speed[0] || ++fan_frame >= FAN_ANIM_FRAMES) fan_frame = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -245,7 +245,7 @@ static void lcd_implementation_status_screen() {
|
||||
fan_frame == 3 ? status_screen3_bmp :
|
||||
#endif
|
||||
#else
|
||||
blink && fanSpeeds[0] ? status_screen1_bmp :
|
||||
blink && fan_speed[0] ? status_screen1_bmp :
|
||||
#endif
|
||||
#endif
|
||||
status_screen0_bmp
|
||||
@ -269,7 +269,7 @@ static void lcd_implementation_status_screen() {
|
||||
#if HAS_FAN0
|
||||
if (PAGE_CONTAINS(STATUS_SCREEN_FAN_TEXT_Y - 7, STATUS_SCREEN_FAN_TEXT_Y)) {
|
||||
// Fan
|
||||
const int16_t per = ((fanSpeeds[0] + 1) * 100) / 256;
|
||||
const uint16_t per = (((uint16_t)fan_speed[0] + 1) * 100) / 256;
|
||||
if (per) {
|
||||
lcd_moveto(STATUS_SCREEN_FAN_TEXT_X, STATUS_SCREEN_FAN_TEXT_Y);
|
||||
lcd_put_u8str(itostr3(per));
|
||||
|
@ -710,7 +710,7 @@ bool ST7920_Lite_Status_Screen::indicators_changed() {
|
||||
// them only during blinks we gain a bit of stability.
|
||||
const bool blink = lcd_blink();
|
||||
const uint16_t feedrate_perc = feedrate_percentage;
|
||||
const uint8_t fan_speed = ((fanSpeeds[0] + 1) * 100) / 256;
|
||||
const uint8_t fs = (((uint16_t)fan_speed[0] + 1) * 100) / 256;
|
||||
const int16_t extruder_1_target = thermalManager.degTargetHotend(0);
|
||||
#if HOTENDS > 1
|
||||
const int16_t extruder_2_target = thermalManager.degTargetHotend(1);
|
||||
@ -719,7 +719,7 @@ bool ST7920_Lite_Status_Screen::indicators_changed() {
|
||||
const int16_t bed_target = thermalManager.degTargetBed();
|
||||
#endif
|
||||
static uint16_t last_checksum = 0;
|
||||
const uint16_t checksum = blink ^ feedrate_perc ^ fan_speed ^ extruder_1_target
|
||||
const uint16_t checksum = blink ^ feedrate_perc ^ fs ^ extruder_1_target
|
||||
#if HOTENDS > 1
|
||||
^ extruder_2_target
|
||||
#endif
|
||||
@ -737,7 +737,7 @@ void ST7920_Lite_Status_Screen::update_indicators(const bool forceUpdate) {
|
||||
const bool blink = lcd_blink();
|
||||
const duration_t elapsed = print_job_timer.duration();
|
||||
const uint16_t feedrate_perc = feedrate_percentage;
|
||||
const uint8_t fan_speed = ((fanSpeeds[0] + 1) * 100) / 256;
|
||||
const uint8_t fs = (((uint16_t)fan_speed[0] + 1) * 100) / 256;
|
||||
const int16_t extruder_1_temp = thermalManager.degHotend(0),
|
||||
extruder_1_target = thermalManager.degTargetHotend(0);
|
||||
#if HOTENDS > 1
|
||||
@ -756,12 +756,12 @@ void ST7920_Lite_Status_Screen::update_indicators(const bool forceUpdate) {
|
||||
#if HAS_HEATED_BED
|
||||
draw_bed_temp(bed_temp, bed_target, forceUpdate);
|
||||
#endif
|
||||
draw_fan_speed(fan_speed);
|
||||
draw_fan_speed(fs);
|
||||
draw_print_time(elapsed);
|
||||
draw_feedrate_percentage(feedrate_perc);
|
||||
|
||||
// Update the fan and bed animations
|
||||
if (fan_speed > 0) draw_fan_icon(blink);
|
||||
if (fs) draw_fan_icon(blink);
|
||||
#if HAS_HEATED_BED
|
||||
if (bed_target > 0)
|
||||
draw_heat_icon(blink, true);
|
||||
|
@ -85,7 +85,7 @@ static const uint8_t u8g_dev_st7920_128x64_HAL_init_seq[] PROGMEM = {
|
||||
U8G_ESC_END // end of sequence
|
||||
};
|
||||
|
||||
void clear_graphics_DRAM(u8g_t *u8g, u8g_dev_t *dev){
|
||||
void clear_graphics_DRAM(u8g_t *u8g, u8g_dev_t *dev) {
|
||||
u8g_SetChipSelect(u8g, dev, 1);
|
||||
u8g_Delay(1);
|
||||
u8g_SetAddress(u8g, dev, 0); // cmd mode
|
||||
|
@ -255,7 +255,7 @@ void process_lcd_p_command(const char* command) {
|
||||
print_job_timer.stop();
|
||||
thermalManager.disable_all_heaters();
|
||||
#if FAN_COUNT > 0
|
||||
for (uint8_t i = 0; i < FAN_COUNT; i++) fanSpeeds[i] = 0;
|
||||
for (uint8_t i = 0; i < FAN_COUNT; i++) fan_speed[i] = 0;
|
||||
#endif
|
||||
wait_for_heatup = false;
|
||||
write_to_lcd_P(PSTR("{SYS:STARTED}"));
|
||||
|
@ -159,7 +159,8 @@ millis_t next_lcd_update_ms;
|
||||
constexpr int8_t menu_bottom = LCD_HEIGHT - (TALL_FONT_CORRECTION);
|
||||
|
||||
// Initialized by settings.load()
|
||||
int16_t lcd_preheat_hotend_temp[2], lcd_preheat_bed_temp[2], lcd_preheat_fan_speed[2];
|
||||
int16_t lcd_preheat_hotend_temp[2], lcd_preheat_bed_temp[2];
|
||||
uint8_t lcd_preheat_fan_speed[2];
|
||||
|
||||
#if ENABLED(AUTO_BED_LEVELING_UBL) || ENABLED(G26_MESH_VALIDATION)
|
||||
bool lcd_external_control; // = false
|
||||
@ -945,7 +946,7 @@ void lcd_quick_feedback(const bool clear_buttons) {
|
||||
|
||||
// Restore print cooling fan speeds
|
||||
for (uint8_t i = 0; i < FAN_COUNT; i++) {
|
||||
int16_t f = job_recovery_info.fanSpeeds[i];
|
||||
uint8_t f = job_recovery_info.fan_speed[i];
|
||||
if (f) {
|
||||
sprintf_P(cmd, PSTR("M106 P%i S%i"), i, f);
|
||||
enqueue_and_echo_command(cmd);
|
||||
@ -1553,21 +1554,21 @@ void lcd_quick_feedback(const bool clear_buttons) {
|
||||
//
|
||||
#if FAN_COUNT > 0
|
||||
#if HAS_FAN0
|
||||
MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_FAN_SPEED FAN_SPEED_1_SUFFIX, &fanSpeeds[0], 0, 255);
|
||||
MENU_MULTIPLIER_ITEM_EDIT(int8, MSG_FAN_SPEED FAN_SPEED_1_SUFFIX, &fan_speed[0], 0, 255);
|
||||
#if ENABLED(EXTRA_FAN_SPEED)
|
||||
MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_EXTRA_FAN_SPEED FAN_SPEED_1_SUFFIX, &new_fanSpeeds[0], 3, 255);
|
||||
MENU_MULTIPLIER_ITEM_EDIT(int8, MSG_EXTRA_FAN_SPEED FAN_SPEED_1_SUFFIX, &new_fan_speed[0], 3, 255);
|
||||
#endif
|
||||
#endif
|
||||
#if HAS_FAN1
|
||||
MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_FAN_SPEED " 2", &fanSpeeds[1], 0, 255);
|
||||
MENU_MULTIPLIER_ITEM_EDIT(int8, MSG_FAN_SPEED " 2", &fan_speed[1], 0, 255);
|
||||
#if ENABLED(EXTRA_FAN_SPEED)
|
||||
MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_EXTRA_FAN_SPEED " 2", &new_fanSpeeds[1], 3, 255);
|
||||
MENU_MULTIPLIER_ITEM_EDIT(int8, MSG_EXTRA_FAN_SPEED " 2", &new_fan_speed[1], 3, 255);
|
||||
#endif
|
||||
#endif
|
||||
#if HAS_FAN2
|
||||
MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_FAN_SPEED " 3", &fanSpeeds[2], 0, 255);
|
||||
MENU_MULTIPLIER_ITEM_EDIT(int8, MSG_FAN_SPEED " 3", &fan_speed[2], 0, 255);
|
||||
#if ENABLED(EXTRA_FAN_SPEED)
|
||||
MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_EXTRA_FAN_SPEED " 3", &new_fanSpeeds[2], 3, 255);
|
||||
MENU_MULTIPLIER_ITEM_EDIT(int8, MSG_EXTRA_FAN_SPEED " 3", &new_fan_speed[2], 3, 255);
|
||||
#endif
|
||||
#endif
|
||||
#endif // FAN_COUNT > 0
|
||||
@ -1669,7 +1670,7 @@ void lcd_quick_feedback(const bool clear_buttons) {
|
||||
* "Temperature" submenu items
|
||||
*
|
||||
*/
|
||||
void _lcd_preheat(const int16_t endnum, const int16_t temph, const int16_t tempb, const int16_t fan) {
|
||||
void _lcd_preheat(const int16_t endnum, const int16_t temph, const int16_t tempb, const uint8_t fan) {
|
||||
if (temph > 0) thermalManager.setTargetHotend(MIN(heater_maxtemp[endnum], temph), endnum);
|
||||
#if HAS_HEATED_BED
|
||||
if (tempb >= 0) thermalManager.setTargetBed(tempb);
|
||||
@ -1678,9 +1679,9 @@ void lcd_quick_feedback(const bool clear_buttons) {
|
||||
#endif
|
||||
#if FAN_COUNT > 0
|
||||
#if FAN_COUNT > 1
|
||||
fanSpeeds[active_extruder < FAN_COUNT ? active_extruder : 0] = fan;
|
||||
fan_speed[active_extruder < FAN_COUNT ? active_extruder : 0] = fan;
|
||||
#else
|
||||
fanSpeeds[0] = fan;
|
||||
fan_speed[0] = fan;
|
||||
#endif
|
||||
#else
|
||||
UNUSED(fan);
|
||||
@ -1915,7 +1916,7 @@ void lcd_quick_feedback(const bool clear_buttons) {
|
||||
|
||||
void lcd_cooldown() {
|
||||
#if FAN_COUNT > 0
|
||||
for (uint8_t i = 0; i < FAN_COUNT; i++) fanSpeeds[i] = 0;
|
||||
for (uint8_t i = 0; i < FAN_COUNT; i++) fan_speed[i] = 0;
|
||||
#endif
|
||||
thermalManager.disable_all_heaters();
|
||||
lcd_return_to_status();
|
||||
@ -3609,21 +3610,21 @@ void lcd_quick_feedback(const bool clear_buttons) {
|
||||
//
|
||||
#if FAN_COUNT > 0
|
||||
#if HAS_FAN0
|
||||
MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_FAN_SPEED FAN_SPEED_1_SUFFIX, &fanSpeeds[0], 0, 255);
|
||||
MENU_MULTIPLIER_ITEM_EDIT(int8, MSG_FAN_SPEED FAN_SPEED_1_SUFFIX, &fan_speed[0], 0, 255);
|
||||
#if ENABLED(EXTRA_FAN_SPEED)
|
||||
MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_EXTRA_FAN_SPEED FAN_SPEED_1_SUFFIX, &new_fanSpeeds[0], 3, 255);
|
||||
MENU_MULTIPLIER_ITEM_EDIT(int8, MSG_EXTRA_FAN_SPEED FAN_SPEED_1_SUFFIX, &new_fan_speed[0], 3, 255);
|
||||
#endif
|
||||
#endif
|
||||
#if HAS_FAN1
|
||||
MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_FAN_SPEED " 2", &fanSpeeds[1], 0, 255);
|
||||
MENU_MULTIPLIER_ITEM_EDIT(int8, MSG_FAN_SPEED " 2", &fan_speed[1], 0, 255);
|
||||
#if ENABLED(EXTRA_FAN_SPEED)
|
||||
MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_EXTRA_FAN_SPEED " 2", &new_fanSpeeds[1], 3, 255);
|
||||
MENU_MULTIPLIER_ITEM_EDIT(int8, MSG_EXTRA_FAN_SPEED " 2", &new_fan_speed[1], 3, 255);
|
||||
#endif
|
||||
#endif
|
||||
#if HAS_FAN2
|
||||
MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_FAN_SPEED " 3", &fanSpeeds[2], 0, 255);
|
||||
MENU_MULTIPLIER_ITEM_EDIT(int8, MSG_FAN_SPEED " 3", &fan_speed[2], 0, 255);
|
||||
#if ENABLED(EXTRA_FAN_SPEED)
|
||||
MENU_MULTIPLIER_ITEM_EDIT(int3, MSG_EXTRA_FAN_SPEED " 3", &new_fanSpeeds[2], 3, 255);
|
||||
MENU_MULTIPLIER_ITEM_EDIT(int8, MSG_EXTRA_FAN_SPEED " 3", &new_fan_speed[2], 3, 255);
|
||||
#endif
|
||||
#endif
|
||||
#endif // FAN_COUNT > 0
|
||||
@ -3755,7 +3756,7 @@ void lcd_quick_feedback(const bool clear_buttons) {
|
||||
#endif
|
||||
START_MENU();
|
||||
MENU_BACK(MSG_CONFIGURATION);
|
||||
MENU_ITEM_EDIT(int3, MSG_FAN_SPEED, &lcd_preheat_fan_speed[material], 0, 255);
|
||||
MENU_ITEM_EDIT(int8, MSG_FAN_SPEED, &lcd_preheat_fan_speed[material], 0, 255);
|
||||
#if HAS_TEMP_HOTEND
|
||||
MENU_ITEM_EDIT(int3, MSG_NOZZLE, &lcd_preheat_hotend_temp[material], MINTEMP_ALL, MAXTEMP_ALL - 15);
|
||||
#endif
|
||||
|
@ -107,7 +107,8 @@
|
||||
typedef void (*screenFunc_t)();
|
||||
typedef void (*menuAction_t)();
|
||||
|
||||
extern int16_t lcd_preheat_hotend_temp[2], lcd_preheat_bed_temp[2], lcd_preheat_fan_speed[2];
|
||||
extern int16_t lcd_preheat_hotend_temp[2], lcd_preheat_bed_temp[2];
|
||||
extern uint8_t lcd_preheat_fan_speed[2];
|
||||
|
||||
#if ENABLED(AUTO_BED_LEVELING_UBL) || ENABLED(G26_MESH_VALIDATION)
|
||||
extern bool lcd_external_control;
|
||||
|
@ -1008,13 +1008,13 @@ static void lcd_implementation_status_screen() {
|
||||
#if FAN_COUNT > 0
|
||||
if (0
|
||||
#if HAS_FAN0
|
||||
|| fanSpeeds[0]
|
||||
|| fan_speed[0]
|
||||
#endif
|
||||
#if HAS_FAN1
|
||||
|| fanSpeeds[1]
|
||||
|| fan_speed[1]
|
||||
#endif
|
||||
#if HAS_FAN2
|
||||
|| fanSpeeds[2]
|
||||
|| fan_speed[2]
|
||||
#endif
|
||||
) leds |= LED_C;
|
||||
#endif // FAN_COUNT > 0
|
||||
|
Reference in New Issue
Block a user