Robot Arena LED Control
This page details how to control the LEDs for the Robot Arena in P/T/410. The LEDs are run from an ESP32 which provides a web interface and API. It can only be accessed on the robotlab network.
As of writing the IP address for the controller is 144.32.70.199. This may change due to how our network works. If you are unable to access the controls, please ask a technician for help
Web Interface
The web interface is found by navigating to the IP of the controller in any web browser, while on the robotlab network.
It offers a quick way to change the current mode of the lighting. You can select from a range of pre-set modes using the mode dropdown. You can select the colour for the effect using the three colour pickers. Some effects do not use these colours if they have their own colour palette, and most effects only use the primary and secondary colours e.g. the "Blink" effect just alternates between the two colours. Setting a colour to black is equivalent to off, e.g. if the secondary colour is black, then the "Blink" effect will just flash the primary colour on and off. You can also adjust the overall brightness of the lighting. The "Return to idle settings" button will return everything back to the default settings as set by the technicians.
You can also access the countdown timer from this page. The countdown timer will fill up the sides of the arena in the chosen colour to represent the elapsed time, ending when the bar has reached the end of the side. The primary colour specifies the bar colour, the secondary colour is the background and the tertiary colour is the colour the arena will blink at the end to show the countdown has finished. You can start a countdown by either using one of the quick buttons, or specifying a custom time using the input box
API
You are also able the control the lighting through an API. You access the API by sending HTTP GET requests to various endpoints, with the request parameters encoded into the URL of the request. e.g. to find the current brightness you would make a GET request as follows:
GET http://144.32.70.199/get?brightness=
Where 144.32.70.199 is the IP address of the controller, get is the endpoint, ? designates the start of the parameters, brightness is the key for retrieving the brightness, and the = is the value of the parameter, in this case there is no parameter so there is nothing after the =. You must still include the = or it will not be recognised by the server. You can try this yourself be navigating to the address in you web browser: http://144.32.70.199/get?brightness= . This is because a HTTP GET request is the same type of request used by your web browser to retrieve web pages. You should be directed to a page that contains the current brightness value in plain text.
The full list of endpoints and their commands are as follows:
/get
/get is used to get values from the controller about the current state of the lighting. It will only return one value at a time, so requests made for multiple values in the same GET will only return the value of the first. Its parameters are as follows:
colour
?colour returns the current set colours of the current arena effect. Specifying no value or a value of 0 will return the current primary colour, and specifying a value of 1 or 2 will return the current secondary and tertiary colour respectively. Values are returned as a HTML hex colour code.
mode
?mode returns the ID of the current active mode.
brightness
?brightness returns the current brightness of the lighting, in a range from 0 to 255, with 255 being max brightness.
getpixelcolour
?getpixelcolour returns the current colour of a specific pixel. Values are returned as a HTML hex colour code.
/set
/set is used to set different value on the controller, and trigger certain functions. Its parameters are as follows:
colour0, colour1, colour2
?colour0, ?colour1 and ?colour2 are used to set the primary, secondary and tertiary colours respectively. They take a value formatted as a HTML hex code, either with or without the leading #.
mode
?mode is used to set the current effect mode. It takes the ID number of the mode
brightness
?brightness is used to set the current brightness of the lighting. It takes an integer value from 0 to 255
returnidle
?returnidle resets the current mode and colours back to the idle mode as specified by the technicians. It takes no value
pause
?pause pauses the currently running effect. This is required if you want to manually set the pixels yourself, otherwise the running animation will overwrite your colours. It takes no value
resume
?resume resumes the current effect. You should run this after you are done controlling the LEDs. It takes no value
clear
?clear clears the current pixel colour data, resetting the whole strip to black/off. It takes no value
show
?show sends the current pixel data to the LEDs. This should be ran after you have sent pixel data to display it on the LEDs. It takes no value
setpixelcolour and pixel
?setpixelcolour is used to set the colour of an individual pixel. It takes a HTML hex colour code, either with or without the leading #. You must also specify the index of the pixel you wish to set using the pixel parameter. You send multiple parameters by putting them one after the other with & symbols in between e.g.
http://144.32.70.199/set?setpixelcolour=ff00ff&pixel=0
This will set the first pixel (counting starts at 0) to the colour 0xff00ff, which is magenta.
/countdown
/countdown is used to start a countdown timer. It only has one parameter, ?seconds, which takes an integer value of seconds to count down for.
Manually programming the LEDs
The arena has 20 panels, 4 on each short side, 6 on each long side. Each panel has 27 LEDs inside it, for a total of 540 LEDs. LEDs are indexed from 0, with the first LED being in the centre of the top of the arena, nearest the desks, then continuing on clockwise.
To send your own colour data to the LEDs the process goes as follows:
- Pause the current animation
- Clear the strip
- Send per pixel colour data times as many pixels as you want to light
- Show the data on the LEDs
- Repeat steps 3 and 4 as many times as needed
- When done, resume the animation
In GET commands this would look something like:
- /set?pause=
- /set?clear=
- /set?setpixelcolour={colour}&pixel={pixel}
- /set?show=
- Repeat steps 3 and 4
- /set?resume=