Add comments, change ra logic, remove debug code

This commit is contained in:
Snorre Selmer 2023-03-30 16:41:51 +02:00
parent 1e1f1155c0
commit 55812f6c21

View File

@ -1,8 +1,23 @@
alias DiodeSlider d0 # Kit (Light) > Diode Slide
alias FirstBattery d1 # The battery closest to your base
alias SecondBattery d2 # Optional second battery type
alias CableAnalyzer d3 # Optional
alias LEDLight d4 # Kit (Light) > LED Light, required if you have Cable Analyzer
# Uses a Diode Slide to show battery-bank fill-level.
# You can add a Cable Analyzer between generators
# and batteries so an LED light can show if system
# is charging or discharging.
# Works best if your batteries are connected in
# series (battery output -> battery input).
# FirstBattery is the battery that faces your base.
# Kit (Light) > Diode Slide
alias DiodeSlider d0
# Battery closest to your base
alias FirstBattery d1
# Optional second battery type
alias SecondBattery d2
# Optional Cable Analyzer
alias CableAnalyzer d3
# Kit (Light) > LED Light,
# required if you have Cable Analyzer
alias LEDLight d4
alias FirstBattCharge r0
alias Type1Hash r1
@ -19,19 +34,30 @@ define GREEN 2
start:
yield
# Checks charge/discharge state if CA connected
bdseal CableAnalyzer systemstate
l Type1Hash FirstBattery PrefabHash
# Sums current and max capacity of batteries of the
# first type
lb Type1Max Type1Hash Maximum Sum
lb Type1Charge Type1Hash Charge Sum
# Gets charge-ratio of FirstBattery
l FirstBattCharge FirstBattery Ratio
# Gets charges from second type of batteries
bdseal SecondBattery t2getcharge
# Creates a ratio from all batteries
div Type1Charge Type1Charge Type1Max
# Displays total charge ratio of battery-bank
s DiodeSlider Setting Type1Charge
slt FirstBattCharge FirstBattCharge 0.99
# Turns on Diode Slide light if FirstBattery
# is less than full (danger low power storage)
slt FirstBattCharge FirstBattCharge 1
s DiodeSlider On FirstBattCharge
j start
t2getcharge:
# Sums current and max capacity of batteries of the
# second type (if present)
l Type2Hash SecondBattery PrefabHash
lb Type2Max Type2Hash Maximum Sum
lb Type2Charge Type2Hash Charge Sum
@ -40,16 +66,16 @@ add Type1Charge Type1Charge Type2Charge
j ra
systemstate:
# Checks if system is generating more or less power
# than it's consuming
s LEDLight On 1
l ChargeIn CableAnalyzer PowerPotential
l ChargeOut FirstBattery PowerActual
sub r9 ChargeIn ChargeOut
s db Setting r9
move r10 ra
bgtzal r9 charging
bgtz r9 charging
s LEDLight Color RED
j ra
charging:
s LEDLight Color GREEN
j r10
j ra