Reply To: USB Button Solution

Home Forums AR Sandbox Forum USB Button Solution Reply To: USB Button Solution

#103570
ajy00
Participant

For the RiverWey Trust version of the SARndbox, I’ve now set up three USB buttons – Flood, Drain, and Cycle – where the first is the global water tool, Drain is.. drain, and the third assigns a script (as in Oliver Kreylos’ post above) which cycles round the Water, Lava, Snow options
three buttons on the box

As a green bash script coder this works but is probably a bit clunky!

# weather.sh
#!/bin/bash

# pick up current state
  weather=$( cat /home/sandbox/src/scrip/weather_file.tmp )
  echo "Current state is " $weather
 
# use case statement to set the assignment to the next cycle value
    case $weather in
     "rain") echo "Changed rain to lava"
            sh /home/sandbox/src/scrip/switch-to-lava.sh
            echo "lava" > /home/sandbox/src/scrip/weather_file.tmp
            ;;
     "lava") echo "Changed lava to snow"
            sh /home/sandbox/src/scrip/switch-to-snow.sh 
            echo "snow" > /home/sandbox/src/scrip/weather_file.tmp
            ;;
     "snow") echo "Changed snow to rain"
            sh /home/sandbox/src/scrip/switch-to-water.sh 
            echo "rain" > /home/sandbox/src/scrip/weather_file.tmp
            ;;
    esac

The switch scripts are versions of those appearing in the ‘snow shader’ topic in this forum ..

cp ~/src/scrip/SurfaceAddWaterColor-Lava.fs ~/src/SARndbox-2.3/share/SARndbox-2.3/Shaders/SurfaceAddWaterColor.fs

using suitably updated versions of SurfaceAddWaterColor.fs

For the USB buttons, the Reyann branded button options in UK came out at some hugely inflated price on Amazon UK (equivalent $60+)… so xSource (https://www.amazon.co.uk/d/Joysticks/XCSOURCE-Delay-Arcade-Encoder-Joystick-Fighting-AC488/B01LAUYCXE/ref=pd_sim_107_2?_encoding=UTF8&psc=1&refRID=DFKRG5PA12K6NTNXYZK9) at £16.99 ($22) for the same solution is much better … and there is an option for the board without buttons should you wish.

Comments are closed.