# 2020-Jan # solar angle from sensor facing east # panel vertical %age = (solar_angle / 1.5) -10 # alias angle d0 day: l r0 angle SolarAngle bge r0 165 sunset # when the sun gets low enough, transition to the sunset state # max( (angle/1.5)-10, 0 ) div r0 r0 1.5 sub r0 r0 10 max r0 r0 0 jal setAll yield j day sunset: move r0 100 jal setAll sunset2: l r0 angle SolarAngle ble r0 160 night # when it gets really low, switch to night mode yield j sunset2 night: # night mode, move the panels to catch sunrise, just in case power dies overnight move r0 0 jal setAll night2: l r0 angle SolarAngle ble r0 5 day # dawn s angle On 0 sleep 10 # power saving mode s angle On 1 yield j night2 setAll: s db Setting r0 # for a batch writer # in case you don't use the batch writer, but have <=5 solar panels connected to the data pins. bdns d5 set4 s d5 Vertical r0 set4: bdns d4 set3 s d4 Vertical r0 set3: bdns d3 set2 s d3 Vertical r0 set2: bdns d2 set1 s d2 Vertical r0 set1: bdns d1 ra s d1 Vertical r0 j ra |
MIPS is the programming language used by IC (integrated circuits) in the game Stationeers. Stationeering web site has a MIPS emulator with syntax highlighting and error detection.