Skip to content

Commit

Permalink
Fix HeaterFire effect
Browse files Browse the repository at this point in the history
  • Loading branch information
julianschill committed Apr 28, 2024
1 parent 71d8b30 commit 4396f04
Showing 1 changed file with 23 additions and 10 deletions.
33 changes: 23 additions & 10 deletions src/led_effect.py
Original file line number Diff line number Diff line change
Expand Up @@ -908,6 +908,10 @@ def __init__(self, **kwargs):

self.frameCount = len(self.thisFrame)

if self.handler.heater is None:
raise self.handler.printer.config_error(
"LED Effect '%s' has no heater defined." % (self.handler.name))

def nextFrame(self, eventtime):
heaterTarget = self.frameHandler.heaterTarget[self.handler.heater]
heaterCurrent = self.frameHandler.heaterCurrent[self.handler.heater]
Expand Down Expand Up @@ -945,6 +949,11 @@ def __init__(self, **kwargs):
for i in range(len(gradient)):
self.thisFrame.append(gradient[i] * self.ledCount)
self.frameCount = len(self.thisFrame)

if self.handler.heater is None:
raise self.handler.printer.config_error(
"LED Effect '%s' has no heater defined." % (self.handler.name))

def nextFrame(self, eventtime):
if self.effectCutoff == self.effectRate:
s = 200 if self.frameHandler.heaterCurrent[self.handler.heater] >= self.effectRate else 0
Expand Down Expand Up @@ -1109,7 +1118,10 @@ def __init__(self, **kwargs):
self.frameLen = len(self.gradient)
self.heatLen = len(self.heatMap)
self.heatSource = int(self.ledCount / 10.0)
self.effectRate = 0

if self.handler.heater is None:
raise self.handler.printer.config_error(
"LED Effect '%s' has no heater defined." % (self.handler.name))

if self.heatSource < 1:
self.heatSource = 1
Expand All @@ -1122,22 +1134,23 @@ def nextFrame(self, eventtime):
heaterLast = self.frameHandler.heaterLast[self.handler.heater]

if heaterTarget > 0.0 and heaterCurrent > 0.0:
if heaterCurrent <= heaterTarget-2:
spark = int((heaterCurrent / heaterTarget) * 80)
brightness = int((heaterCurrent / heaterTarget) * 100)
elif self.effectCutoff > 0:
spark = 0
else:
spark = 80
brightness = 100
if (heaterCurrent >= self.effectRate):
if heaterCurrent <= heaterTarget-2:
spark = int((heaterCurrent / heaterTarget) * 80)
brightness = int((heaterCurrent / heaterTarget) * 100)
elif self.effectCutoff > 0:
spark = 0
else:
spark = 80
brightness = 100
elif self.effectRate > 0 and heaterCurrent > 0.0:
if heaterCurrent >= self.effectRate:
spark = int(((heaterCurrent - self.effectRate)
/ heaterLast) * 80)
brightness = int(((heaterCurrent - self.effectRate)
/ heaterLast) * 100)

if spark > 0:
if spark > 0 and heaterTarget != 0:
cooling = int((heaterCurrent / heaterTarget) * 20)

for h in range(self.heatLen):
Expand Down

0 comments on commit 4396f04

Please sign in to comment.