Rewrote variables to not use snake-case

Added automatic light-switch
This commit is contained in:
Snorre Selmer 2022-09-13 20:22:22 +02:00
parent e47ade1f57
commit 0eaec70c48
11 changed files with 265 additions and 232 deletions

View File

@ -1,18 +1,18 @@
alias furnace d0 alias Furnace d0
alias import_occupied r0 alias ImportOccupied r0
alias active r1 alias Active r1
alias run_furnace r2 alias RunFurnace r2
start: start:
yield yield
ls import_occupied furnace 0 Occupied ls ImportOccupied Furnace 0 Occupied
l active furnace Activate l Active Furnace Activate
xor run_furnace import_occupied active xor RunFurnace ImportOccupied Active
bgtz run_furnace run bgtz RunFurnace run
j start j start
run: run:
bgtz active start # already running = go to start bgtz Active start # already running = go to start
s furnace Activate 1 s Furnace Activate 1
j start j start

View File

@ -1,33 +1,33 @@
# Runs up to six sorters that filter throughput by ItemClass # Runs up to six sorters that filter throughput by ItemClass
# When looking at the outputs, left = ITEMCLASS, right = everything else # When looking at the outputs, left = ITEMCLASS, right = everything else
alias occupied r0 alias SlotOccupied r0
alias input_class r1 alias InputClass r1
alias is_class r2 alias IsClass r2
alias sorter_counter r3 alias SorterCounter r3
move sorter_counter 0 move SorterCounter 0
define ITEMCLASS 19 # 10=ores, 19=ingots, 33=wrekage define ITEMCLASS 19 # 10=ores, 19=ingots, 33=wrekage
define INPUTSLOT 0 # sorter input-slot define INPUTSLOT 0 # sorter input-slot
start: start:
jal sort jal sort
add sorter_counter sorter_counter 1 add SorterCounter SorterCounter 1
bgt sorter_counter 5 reset bgt SorterCounter 5 reset
j start j start
sort: sort:
bdns dr3 ra bdns dr3 ra
s dr3 Mode 2 # set sorter to IC mode s dr3 Mode 2 # set sorter to IC mode
ls occupied dr3 INPUTSLOT Occupied # check if anything to sort ls SlotOccupied dr3 INPUTSLOT Occupied # check if anything to sort
beqz occupied ra beqz SlotOccupied ra
ls input_class dr3 INPUTSLOT Class ls InputClass dr3 INPUTSLOT Class
seq is_class input_class ITEMCLASS # change seq to sne to swap output ports seq IsClass InputClass ITEMCLASS # change seq to sne to swap output ports
s dr3 Output is_class s dr3 Output IsClass
j ra j ra
reset: reset:
yield yield
move sorter_counter 0 move SorterCounter 0
j start j start

27
auto_lights.ic10 Normal file
View File

@ -0,0 +1,27 @@
# Uses Occupancy Sensor and (optional) Daylight
# Sensor to control lights in a room.
# Can of course control other things too...
alias Detector d0
alias DaySens d1 # Optional
alias Lights d2
alias RoomOccupied r0
alias NightTime r1
alias LightHash r2
l LightHash Lights PrefabHash
move NightTime 1
check:
yield
l RoomOccupied Detector Activate
bdns DaySens light
l NightTime DaySens Activate
slt NightTime NightTime 1
j light
light:
and RoomOccupied RoomOccupied NightTime
sb LightHash On RoomOccupied
j check

View File

@ -4,56 +4,56 @@
# !!! Remember to set volume pump to no more !!! # !!! Remember to set volume pump to no more !!!
# !!! than 10l! I have mine at 2l for safety !!! # !!! than 10l! I have mine at 2l for safety !!!
alias canister_storage d0 alias CanisterStorage d0
alias fill_pump d1 alias FillPump d1
alias evac_pump d2 alias EvacPump d2
alias analyzer d4 alias Analyzer d4
alias canister_present r0 alias CanisterPresent r0
alias canister_hash r1 alias CanisterHash r1
alias storage_pressure r2 alias StoragePressure r2
alias gas_to_move r3 alias GasToMove r3
alias fill_pressure r4 alias FillPressure r4
alias pump_active r5 alias PumpActive r5
define CANISTER 42280099 define CANISTER 42280099
define SMART_CANISTER -668314371 define SMARTCANISTER -668314371
start: start:
yield yield
# check if canister is present # check if canister is present
ls canister_present canister_storage 0 Occupied ls CanisterPresent CanisterStorage 0 Occupied
# identify canister # identify canister
ls canister_hash canister_storage 0 OccupantHash ls CanisterHash CanisterStorage 0 OccupantHash
# set safe fill-pressure # set safe fill-pressure
beq canister_hash CANISTER regular beq CanisterHash CANISTER regular
beq canister_hash SMART_CANISTER smart beq CanisterHash SMARTCANISTER smart
regular: regular:
move fill_pressure 8000000 # regular can safe max move FillPressure 8000000 # regular can safe max
j fill # start filling j fill # start filling
smart: smart:
move fill_pressure 18000000 # smart can safe max move FillPressure 18000000 # smart can safe max
j fill # start filling j fill # start filling
fill: # fills canister if present and <8Mpa fill: # fills canister if present and <8Mpa
# get canister pressure in Pa # get canister pressure in Pa
ls storage_pressure canister_storage 0 Pressure ls StoragePressure CanisterStorage 0 Pressure
# is there room in the canister for more gas? # is there room in the canister for more gas?
slt gas_to_move storage_pressure fill_pressure slt GasToMove StoragePressure FillPressure
# is there a can in the slot that has room? # is there a can in the slot that has room?
and pump_active gas_to_move canister_present and PumpActive GasToMove CanisterPresent
# trigger fill pump # trigger fill pump
s fill_pump On pump_active s FillPump On PumpActive
beqz canister_present evac# break if no can beqz CanisterPresent evac # break if no can
j start j start
evac: # evacuates pipe on can removed and >0Pa evac: # evacuates pipe on can removed and >0Pa
l storage_pressure analyzer Pressure l StoragePressure Analyzer Pressure
# is there gas in the pipe? # is there gas in the pipe?
sgt gas_to_move storage_pressure 0 sgt GasToMove StoragePressure 0
# trigger evac pump # trigger evac pump
s evac_pump On gas_to_move s EvacPump On GasToMove
bgtz gas_to_move evac bgtz GasToMove evac
j start j start

View File

@ -1,32 +1,32 @@
# Automatically evacuates cooling-tower when temp # Automatically evacuates cooling-tower when temp
# is below 40C (39.85C) # is below 40C
# needs a volume pump and a gas analyzer # needs a volume pump and a gas analyzer
alias sensor d0 alias Sensor d0
alias pump d1 alias Pump d1
alias pipe_temp r0 alias PipeTemp r0
alias pipe_press r1 alias PipePress r1
alias temp_go r2 alias TempGo r2
alias press_go r3 alias PressGo r3
alias pump_go r4 alias PumpGo r4
define TEMP_THRESH 313 # 39.85C define TEMPTHRESH 313.15
# Sets volume pump max capacity # Sets volume pump max capacity
l pipe_press pump Maximum l PipePress Pump Maximum
s pump Setting pipe_press s Pump Setting PipePress
start: start:
yield yield
# Loads cooling-tower pressure and temp # Loads cooling-tower pressure and temp
l pipe_temp sensor Temperature l PipeTemp Sensor Temperature
l pipe_press sensor Pressure l PipePress Sensor Pressure
# Checks if temp is below threshold # Checks if temp is below threshold
slt temp_go pipe_temp TEMP_THRESH slt TempGo PipeTemp TEMPTHRESH
sgtz press_go pipe_press sgtz PressGo PipePress
# If cooling-tower has pressure, and temp is safe.. # If cooling-tower has pressure, and temp is safe..
and pump_go temp_go press_go and PumpGo TempGo PressGo
# ...activate pump # ...activate pump
s pump On pump_go s Pump On PumpGo
j start j start

View File

@ -6,69 +6,68 @@
# filtration units, where all gasses are mixed into # filtration units, where all gasses are mixed into
# a "mud" before being filtered. # a "mud" before being filtered.
alias mud_sensor d0 # Pipe Analyzer alias MudSensor d0 # Pipe Analyzer
alias tank d1 # Tank alias Tank d1 # Tank
alias purge_button d2 # Logic (Switch) alias PurgeButton d2 # Logic (Switch)
alias purge_pump d3 # Volume (Turbo) Pump alias PurgePump d3 # Volume (Turbo) Pump
alias filter_unit d4 # Kit (Atmospherics) alias FilterUnit d4 # Kit (Atmospherics)
alias filter_display d5 # Kit (Console) alias FilterDisplay d5 # Kit (Console)
alias mud_temp r0 alias MudTemp r0
alias filter1 r1 alias Filter1 r1
alias filter2 r2 alias Filter2 r2
alias tank_press r3 alias TankPress r3
alias button r4 alias FilterRun r4
alias filter_run r5 alias FilterTest r5
alias filter_test r6 alias PurgeRun r6
alias purge_run r7 alias HasGas r7
alias has_gas r8
define MAX_PRESS 58000 # 58MPa define MAX_PRESS 58000 # 58MPa
define MAX_TEMP 313 # 40C define MAX_TEMP 313.15 # 40C
l r9 purge_pump Maximum l r9 PurgePump Maximum
s purge_pump Setting r9 s PurgePump Setting r9
s filter_display Color 4 # red s FilterDisplay Color 4 # red
start: start:
yield yield
s purge_pump On 0 s PurgePump On 0
ls filter1 filter_unit 0 Quantity ls Filter1 FilterUnit 0 Quantity
ls filter2 filter_unit 1 Quantity ls Filter2 FilterUnit 1 Quantity
beqz filter1 swap_filter_1 beqz Filter1 swap_filter_1
beqz filter2 swap_filter_2 beqz Filter2 swap_filter_2
s filter_display On 0 s FilterDisplay On 0
l purge_run purge_button Setting l PurgeRun PurgeButton Setting
bgtz purge_run purge bgtz PurgeRun purge
j filter j filter
swap_filter_1: # if right filter needs swapping swap_filter_1: # if right filter needs swapping
s filter_display Setting 1 s FilterDisplay Setting 1
s filter_display On 1 s FilterDisplay On 1
j filter # then continue filtering j filter # then continue filtering
swap_filter_2: # if left filter needs swapping swap_filter_2: # if left filter needs swapping
s filter_display Setting 2 s FilterDisplay Setting 2
s filter_display On 1 s FilterDisplay On 1
j filter # then continue filtering j filter # then continue filtering
filter: filter:
l mud_temp mud_sensor Temperature l MudTemp MudSensor Temperature
l tank_press tank Pressure l TankPress Tank Pressure
l has_gas mud_sensor RatioCarbonDioxide l HasGas MudSensor RatioCarbonDioxide
sgtz has_gas has_gas sgtz HasGas HasGas
slt filter_run mud_temp MAX_TEMP slt FilterRun MudTemp MAX_TEMP
slt filter_test tank_press MAX_PRESS slt FilterTest TankPress MAX_PRESS
and filter_run filter_run filter_test and FilterRun FilterRun FilterTest
and filter_run filter_run has_gas and FilterRun FilterRun HasGas
s filter_unit On filter_run s FilterUnit On FilterRun
j start j start
purge: purge:
yield yield
s filter_unit On 0 s FilterUnit On 0
l tank_press tank Pressure l TankPress Tank Pressure
s purge_pump On 1 s PurgePump On 1
bgtz tank_press purge bgtz TankPress purge
j start j start

View File

@ -3,61 +3,61 @@
# and a Kit (Button, moment type) to trigger purge. # and a Kit (Button, moment type) to trigger purge.
# Gas mixer ratio is manually set! # Gas mixer ratio is manually set!
alias tank_a d0 alias TankA d0
alias tank_b d1 alias TankB d1
alias tank_out d2 alias TankOut d2
alias mixer d3 alias Mixer d3
alias pump d4 alias Pump d4
alias button d5 alias Button d5
alias tank_a_press r0 alias TankAPress r0
alias tank_b_press r1 alias TankBPress r1
alias tank_out_press r2 alias TankOutPress r2
alias tank_a_ok r3 alias TankAOK r3
alias tank_b_ok r4 alias TankBOK r4
alias tank_out_ok r5 alias TankOutOK r5
alias mixer_run r6 alias MixerRun r6
alias purge_activate r7 alias PurgeActivate r7
# Stops mixing if either input-gas is below 500kPa # Stops mixing if either input-gas is below 500kPa
define PRESS_IN_MIN 500 define PRESSINMIN 500
# Stops mixing if output-tank is "full" # Stops mixing if output-tank is "full"
define PRESS_OUT_MAX 58000 define PRESSOUTMAX 58000
# Sets purge pump to max output # Sets purge pump to max output
l tank_a_press pump Maximum l TankAPress Pump Maximum
s pump Setting tank_a_press s Pump Setting TankAPress
start: start:
yield yield
s pump On 0 # Ensures purge pump is off s Pump On 0 # Ensures purge pump is off
# Checks is purge is activated # Checks is purge is activated
l purge_activate button Setting l PurgeActivate Button Setting
bgtz purge_activate purge bgtz PurgeActivate purge
# Loads tank pressures # Loads tank pressures
l tank_a_press tank_a Pressure l TankAPress TankA Pressure
l tank_b_press tank_b Pressure l TankBPress TankB Pressure
l tank_out_press tank_out Pressure l TankOutPress TankOut Pressure
# Checks if pressures are within tolerances # Checks if pressures are within tolerances
sgt tank_a_ok tank_a_press PRESS_IN_MIN sgt TankAOK TankAPress PRESSINMIN
sgt tank_b_ok tank_b_press PRESS_IN_MIN sgt TankBOK TankBPress PRESSINMIN
slt tank_out_ok tank_out_press PRESS_OUT_MAX slt TankOutOK TankOutPress PRESSOUTMAX
and mixer_run tank_a_ok tank_b_ok and MixerRun TankAOK TankBOK
and mixer_run tank_out_ok mixer_run and MixerRun TankOutOK MixerRun
# Activates mixer if all is ok # Activates mixer if all is ok
s mixer On mixer_run s Mixer On MixerRun
j start j start
purge: purge:
yield yield
s mixer On 0 # Turns mixer off s Mixer On 0 # Turns mixer off
# Gets output tank pressure # Gets output tank pressure
l tank_out_press tank_out Pressure l TankOutPress TankOut Pressure
s pump On 1 # Activates purge pump s Pump On 1 # Activates purge pump
# Runs pump until tank is empty # Runs pump until tank is empty
bgtz tank_out_press purge bgtz TankOutPress purge
j start j start

View File

@ -1,68 +1,68 @@
alias gas_sensor d0 alias GasSensor d0
# d1= Logic Switch, Dial variant (Max=30) # d1= Logic Switch, Dial variant (Max=30)
alias thermostat d1 alias Thermostat d1
# d2 = Logic Memory, must be more than 0 # d2 = Logic Memory, must be more than 0
alias temp_variance d2 alias TempVariance d2
# d3 = Console, LED Display variant, optional # d3 = Console, LED Display variant, optional
alias temp_disp d3 alias TempDisplay d3
# d4 = Wall Cooler # d4 = Wall Cooler
alias w_cooler d4 alias WallCooler d4
# d5 = Wall Heater # d5 = Wall Heater
alias w_heater d5 alias WallHeater d5
alias curr_temp r0 alias CurrentTemp r0
alias target_temp r1 alias TargetTemp r1
alias variance r2 alias Variance r2
alias min_temp r3 alias MinTemp r3
alias max_temp r4 alias MaxTemp r4
alias cooling_active r5 alias CoolingActive r5
alias heating_active r6 alias HeatingActive r6
alias cooler r7 alias Cooler r7
alias heater r8 alias Heater r8
define TEMP_CONVERT 273.15 define TEMPCONVERT 273.15
move cooling_active 0 move CoolingActive 0
move heating_active 0 move HeatingActive 0
l cooler w_cooler PrefabHash l Cooler WallCooler PrefabHash
l heater w_heater PrefabHash l Heater WallHeater PrefabHash
start: start:
yield yield
# establish min- and max-temps to registry # establish min- and max-temps to registry
l variance temp_variance Setting l Variance TempVariance Setting
l min_temp thermostat Setting l MinTemp Thermostat Setting
sub min_temp min_temp variance sub MinTemp MinTemp Variance
l max_temp thermostat Setting l MaxTemp Thermostat Setting
add max_temp max_temp variance add MaxTemp MaxTemp Variance
l target_temp thermostat Setting l TargetTemp Thermostat Setting
# get current temperature # get current temperature
jal temp_read jal temp_read
# update display # update display
brdns temp_disp 2 brdns TempDisplay 2
jal display jal display
# compare current temp to max/min temp and # compare current temp to max/min temp and
# initiate cooling or heating if needed # initiate cooling or heating if needed
bgt curr_temp max_temp cooling bgt CurrentTemp MaxTemp cooling
blt curr_temp min_temp heating blt CurrentTemp MinTemp heating
sb cooler On cooling_active sb Cooler On CoolingActive
sb heater On heating_active sb Heater On HeatingActive
j start j start
temp_read: temp_read:
l curr_temp gas_sensor Temperature l CurrentTemp GasSensor Temperature
sub curr_temp curr_temp TEMP_CONVERT sub CurrentTemp CurrentTemp TEMPCONVERT
j ra j ra
display: display:
s temp_disp Setting curr_temp s TempDisplay Setting CurrentTemp
j ra j ra
cooling: cooling:
@ -70,15 +70,15 @@ yield
jal temp_read jal temp_read
# test if coolers need to be on or not # test if coolers need to be on or not
sgt cooling_active curr_temp target_temp sgt CoolingActive CurrentTemp TargetTemp
brdns temp_disp 2 brdns TempDisplay 2
jal display jal display
# send state to coolers # send state to coolers
sb cooler On cooling_active sb Cooler On CoolingActive
bgtz cooling_active cooling bgtz CoolingActive cooling
j start j start
heating: heating:
@ -86,13 +86,13 @@ yield
jal temp_read jal temp_read
# test if heaters need to be on or not # test if heaters need to be on or not
slt heating_active curr_temp target_temp slt HeatingActive CurrentTemp TargetTemp
brdns temp_disp 2 brdns TempDisplay 2
jal display jal display
# send state to heaters # send state to heaters
sb heater On heating_active sb Heater On HeatingActive
bgtz heating_active heating bgtz HeatingActive heating
j start j start

View File

@ -1,23 +1,20 @@
alias dial d0 alias Dial d0
alias order_display d1 alias DisplayOrder d1
alias remaining_display d2 alias DisplayExport d2
alias printer d3 alias Printer d3
alias order_count r0 alias CountOrder r0
alias export_count r1 alias CountExport r1
alias remaining_count r2
move remaining_count 0
start: start:
yield yield
l order_count dial Setting l CountOrder Dial Setting
s order_display Setting order_count s DisplayOrder Setting CountOrder
l export_count printer ExportCount l CountExport Printer ExportCount
sub remaining_count order_count export_count s DisplayExport Setting CountExport
s remaining_display Setting remaining_count blt CountExport CountOrder start
bgtz remaining_count start s Printer Activate 0
s printer ClearMemory 1 s Printer ClearMemory 1
s dial Setting 0 sleep 1
s printer Activate 0 s Dial Setting 0
j start j start

View File

@ -9,7 +9,8 @@ alias AngleHorizontal r1
alias CorrectionAngle r2 alias CorrectionAngle r2
alias Panel1Hash r3 alias Panel1Hash r3
alias Panel2Hash r4 alias Panel2Hash r4
alias PanelEfficiency r5 alias PanelOutput1 r5
alias PanelOutput2 r6
# define directions of sensor and panel power ports # define directions of sensor and panel power ports
define SENSORDATAANGLE 0 define SENSORDATAANGLE 0
@ -24,6 +25,10 @@ l Panel1Hash PanelType1 PrefabHash
bdns PanelType2 start bdns PanelType2 start
l Panel2Hash PanelType2 PrefabHash l Panel2Hash PanelType2 PrefabHash
# set Display to Power-mode
bdns Display start
s Display Mode 2
start: start:
yield yield
l AngleVertical Sensor Vertical l AngleVertical Sensor Vertical
@ -32,8 +37,13 @@ l AngleHorizontal Sensor Horizontal
add AngleHorizontal AngleHorizontal CorrectionAngle add AngleHorizontal AngleHorizontal CorrectionAngle
bdns Display panelmove bdns Display panelmove
lb PanelEfficiency Panel1Hash Ratio Average lb PanelOutput1 Panel1Hash Charge Sum
s Display Setting PanelEfficiency bdns PanelType2 paneldisplay
lb PanelOutput2 Panel2Hash Charge Sum
add PanelOutput1 PanelOutput1 PanelOutput2
paneldisplay:
s Display Setting PanelOutput1
panelmove: panelmove:
sb Panel1Hash Vertical AngleVertical sb Panel1Hash Vertical AngleVertical

View File

@ -2,42 +2,42 @@
# a siren and an announcer (2x Kit (Speaker)) # a siren and an announcer (2x Kit (Speaker))
# and a display of some sort (Kit (Console)) # and a display of some sort (Kit (Console))
alias weather d0 # Weather Station alias Weather d0 # Weather Station
alias readout d1 # Kit (Console) alias Readout d1 # Kit (Console)
alias announcer d2 # Kit (Speaker) alias Announcer d2 # Kit (Speaker)
alias siren d3 # Kit (Speaker) alias Siren d3 # Kit (Speaker)
alias storm_mode r0 alias StormMode r0
alias minutes r1 alias Minutes r1
alias siren_high r2 alias SirenHigh r2
alias siren_low r3 alias SirenLow r3
alias siren_on r4 alias SirenOn r4
s announcer Mode 18 # "StormIncoming" s Announcer Mode 18 # "StormIncoming"
s siren Mode 10 # "Alarm8" s Siren Mode 10 # "Alarm8"
start: start:
yield yield
l storm_mode weather Mode # check weather l StormMode Weather Mode # check weather
s announcer On 0 # reset announcer s Announcer On 0 # reset Announcer
beq storm_mode 1 countdown # countdown if incoming beq StormMode 1 countdown # countdown if incoming
j start # else return to start j start # else return to start
countdown: countdown:
yield yield
l storm_mode weather Mode # check weather l StormMode Weather Mode # check weather
s announcer On 1 # announce storm s Announcer On 1 # announce storm
# get countdown value # get countdown value
l minutes weather NextWeatherEventTime l Minutes Weather NextWeatherEventTime
div minutes minutes 60 # convert to minutes div Minutes Minutes 60 # convert to minutes
trunc minutes minutes # drop decimals trunc Minutes Minutes # drop decimals
s readout Setting minutes # send to display s Readout Setting Minutes # send to display
j warning j warning
warning: warning:
slt siren_high minutes 3 # got less than 3m? slt SirenHigh Minutes 3 # got less than 3m?
sgt siren_low minutes 0 # got more than 60s? sgt SirenLow Minutes 0 # got more than 60s?
and siren_on siren_high siren_low # sound siren? and SirenOn SirenHigh SirenLow # sound siren?
s siren On siren_on # start siren if 1<minutes<3 s Siren On SirenOn # start siren if 1<minutes<3
beq storm_mode 1 countdown # still waiting? go back beq StormMode 1 countdown # still waiting? go back
j start # reset and start waiting again j start # reset and start waiting again