LCD backlight brightnes pwm control and lcd blinking.

This commit is contained in:
Robert Pelnar 2017-08-21 17:23:30 +02:00
parent d63045fdb3
commit 1e705198e0
4 changed files with 75 additions and 10 deletions

View File

@ -269,6 +269,11 @@ extern void homeaxis(int axis);
extern unsigned char fanSpeedSoftPwm;
#endif
#if defined(LCD_PWM_PIN) && (LCD_PWM_PIN > -1)
extern unsigned char lcdSoftPwm;
extern unsigned char lcdBlinkDelay;
#endif
#ifdef FILAMENT_SENSOR
extern float filament_width_nominal; //holds the theoretical filament diameter ie., 3.00 or 1.75
extern bool filament_sensor; //indicates that filament sensor readings should control extrusion

View File

@ -1256,10 +1256,14 @@ void setup()
#if defined(CONTROLLERFAN_PIN) && CONTROLLERFAN_PIN > -1
#if defined(CONTROLLERFAN_PIN) && (CONTROLLERFAN_PIN > -1)
SET_OUTPUT(CONTROLLERFAN_PIN); //Set pin used for driver cooling fan
#endif
#if defined(LCD_PWM_PIN) && (LCD_PWM_PIN > -1)
SET_OUTPUT(LCD_PWM_PIN); //Set pin used for driver cooling fan
#endif
#ifdef DIGIPOT_I2C
digipot_i2c_init();
#endif
@ -6034,18 +6038,28 @@ case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp
}
break;
case 3:
calibrate_z_auto();
if (code_seen('L')) // lcd pwm (0-255)
{
lcdSoftPwm = (int)code_value();
}
if (code_seen('B')) // lcd blink delay (0-255)
{
lcdBlinkDelay = (int)code_value();
}
// calibrate_z_auto();
/* MYSERIAL.print("fsensor_enable()");
#ifdef PAT9125
fsensor_enable();
#endif*/
break;
case 4:
// lcdBlinkDelay = 10;
/* MYSERIAL.print("fsensor_disable()");
#ifdef PAT9125
fsensor_disable();
#endif
break;*/
break;
case 5:
{
/* MYSERIAL.print("tmc2130_rd_MSCNT(0)=");

View File

@ -98,6 +98,9 @@
#ifdef NEWPANEL
#define LCD_PWM_PIN 32 // lcd backlight brightnes pwm control pin
#define LCD_PWM_MAX 0x0f // lcd pwm maximum value (0x07=64Hz, 0x0f=32Hz, 0x1f=16Hz)
#define BEEPER 84 // Beeper on AUX-4
#define LCD_PINS_RS 82
#define LCD_PINS_ENABLE 61 // !!! changed from 18 (EINY03)

View File

@ -75,8 +75,13 @@ float current_temperature_bed = 0.0;
unsigned char fanSpeedSoftPwm;
#endif
#if defined(LCD_PWM_PIN) && (LCD_PWM_PIN > -1)
unsigned char lcdSoftPwm = (LCD_PWM_MAX * 2 + 1); //set default value to maximum
unsigned char lcdBlinkDelay = 0; //lcd blinking delay (0 = no blink)
#endif
unsigned char soft_pwm_bed;
#ifdef BABYSTEPPING
volatile int babystepsTodo[3]={0,0,0};
#endif
@ -129,6 +134,12 @@ static volatile bool temp_meas_ready = false;
static unsigned long extruder_autofan_last_check;
#endif
#if defined(LCD_PWM_PIN) && (LCD_PWM_PIN > -1)
static unsigned char soft_pwm_lcd = 0;
static unsigned char lcd_blink_delay = 0;
static bool lcd_blink_on = false;
#endif
#if EXTRUDERS > 3
# error Unsupported number of extruders
#elif EXTRUDERS > 2
@ -942,7 +953,12 @@ void tp_init()
#ifdef FAN_SOFT_PWM
soft_pwm_fan = fanSpeedSoftPwm / 2;
#endif
#endif
#if defined(LCD_PWM_PIN) && (LCD_PWM_PIN > -1)
soft_pwm_lcd = lcdSoftPwm / 2;
lcd_blink_delay = lcdBlinkDelay;
lcd_blink_on = true;
#endif
#endif
#ifdef HEATER_0_USES_MAX6675
#ifndef SDSUPPORT
@ -1507,15 +1523,16 @@ ISR(TIMER0_COMPB_vect)
/*
* standard PWM modulation
*/
if(pwm_count == 0){
if (pwm_count == 0)
{
soft_pwm_0 = soft_pwm[0];
if(soft_pwm_0 > 0) {
if(soft_pwm_0 > 0)
{
WRITE(HEATER_0_PIN,1);
#ifdef HEATERS_PARALLEL
WRITE(HEATER_1_PIN,1);
#endif
} else WRITE(HEATER_0_PIN,0);
#if EXTRUDERS > 1
soft_pwm_1 = soft_pwm[1];
if(soft_pwm_1 > 0) WRITE(HEATER_1_PIN,1); else WRITE(HEATER_1_PIN,0);
@ -1533,12 +1550,35 @@ ISR(TIMER0_COMPB_vect)
if(soft_pwm_fan > 0) WRITE(FAN_PIN,1); else WRITE(FAN_PIN,0);
#endif
}
if(soft_pwm_0 < pwm_count) {
if(soft_pwm_0 < pwm_count)
{
WRITE(HEATER_0_PIN,0);
#ifdef HEATERS_PARALLEL
WRITE(HEATER_1_PIN,0);
#endif
}
#if defined(LCD_PWM_PIN) && (LCD_PWM_PIN > -1)
if ((pwm_count & LCD_PWM_MAX) == 0)
{
if (lcd_blink_delay)
{
lcd_blink_delay--;
if (lcd_blink_delay == 0)
{
lcd_blink_delay = lcdBlinkDelay;
lcd_blink_on = !lcd_blink_on;
}
}
else
{
lcd_blink_delay = lcdBlinkDelay;
lcd_blink_on = true;
}
soft_pwm_lcd = (lcd_blink_on) ? (lcdSoftPwm / 2) : 0;
if (soft_pwm_lcd > 0) WRITE(LCD_PWM_PIN,1); else WRITE(LCD_PWM_PIN,0);
}
#endif
#if EXTRUDERS > 1
if(soft_pwm_1 < pwm_count) WRITE(HEATER_1_PIN,0);
#endif
@ -1551,10 +1591,13 @@ ISR(TIMER0_COMPB_vect)
#ifdef FAN_SOFT_PWM
if(soft_pwm_fan < pwm_count) WRITE(FAN_PIN,0);
#endif
#if defined(LCD_PWM_PIN) && (LCD_PWM_PIN > -1)
if (soft_pwm_lcd < (pwm_count & LCD_PWM_MAX)) WRITE(LCD_PWM_PIN,0);
#endif
pwm_count += (1 << SOFT_PWM_SCALE);
pwm_count &= 0x7f;
#else //ifndef SLOW_PWM_HEATERS
/*
* SLOW PWM HEATERS
@ -1742,7 +1785,7 @@ ISR(TIMER0_COMPB_vect)
}
if (soft_pwm_fan < pwm_count) WRITE(FAN_PIN,0);
#endif
pwm_count += (1 << SOFT_PWM_SCALE);
pwm_count &= 0x7f;