spike.lightmatrix
Hub light matrix mock API
Classes
Hub light matrix mocking class |
- class spike.lightmatrix.LightMatrix
Hub light matrix mocking class
Class is accessed simultaneously by the user side thread and the ground truth update thread. It is therefore protected by a mutex
- __init__()
Contructor
- show_image(image, brightness=100)
Shows an image on the Light Matrix.
- Parameters:
image (string (ANGRY, ARROW_E, ARROW_N, ARROW_NE, ARROW_NW, ARROW_S, ARROW_SE, ARROW_SW, ARROW_W, ASLEEP, BUTTERFLY, CHESSBOARD, CLOCK1, CLOCK10, CLOCK11, CLOCK12, CLOCK2, CLOCK3, CLOCK4, CLOCK5, CLOCK6, CLOCK7, CLOCK8, CLOCK9, CONFUSED, COW, DIAMOND, DIAMOND_SMALL, DUCK, FABULOUS, GHOST, GIRAFFE, GO_RIGHT, GO_LEFT, GO_UP, GO_DOWN, HAPPY, HEART, HEART_SMALL, HOUSE, MEH, MUSIC_CROTCHET, MUSIC_QUAVER, MUSIC_QUAVERS, NO, PACMAN, PITCHFORK, RABBIT, ROLLERSKATE, SAD, SILLY, SKULL, SMILE, SNAKE, SQUARE, SQUARE_SMALL, STICKFIGURE, SURPRISED, SWORD, TARGET, TORTOISE, TRIANGLE, TRIANGLE_LEFT, TSHIRT, UMBRELLA, XMAS, YES)) – the name of the image to display
brightness (integer [0,100]) – brightness of the image
- Raises:
TypeError – image is not a string or brightness is not an integer
ValueError – image is not one of the allowed values.
- set_pixel(x, y, brightness=100)
Sets the brightness of one pixel (one of the 25 LEDs) on the Light Matrix.
- Parameters:
x (integer [0,4]) – pixel position, counting from the left.
y (integer [0,4]) – pixel position, counting from the top.
brightness (integer [0,100]) – brightness of the pixel
- Raises:
TypeError – x, y or brightness is not an integer.
ValueError – x, y is not within the allowed range of 0-4.
- write(text)
Displays text on the Light Matrix, one letter at a time, scrolling from right to left. Your program will not continue until all of the letters have been shown.
- Parameters:
text (string) – text to display
- off()
Turns off all of the pixels on the Light Matrix.
- __process_command(command)
Process command until over
- Parameters:
command (generator function) – command to process
- c_reset()
Reset function
Warning
This function is not part of the spike API. It is provided to update the component from scenario data and shall not be used by the end-user.
- c_set_pixel(x, y, brightness=100)
Pixel lighting function
Warning
This function is not part of the spike API. It is provided to update the component from scenario data and shall not be used by the end-user.
- Parameters:
x (integer [0,4]) – pixel position, counting from the left.
y (integer [0,4]) – pixel position, counting from the top.
brightness (integer [0,100]) – brightness of the pixel
- c_show_image(image, brightness=100)
Image displaying function
Warning
This function is not part of the spike API. It is provided to update the component from scenario data and shall not be used by the end-user.
- Parameters:
image (string (ANGRY, ARROW_E, ARROW_N, ARROW_NE, ARROW_NW, ARROW_S, ARROW_SE, ARROW_SW, ARROW_W, ASLEEP, BUTTERFLY, CHESSBOARD, CLOCK1, CLOCK10, CLOCK11, CLOCK12, CLOCK2, CLOCK3, CLOCK4, CLOCK5, CLOCK6, CLOCK7, CLOCK8, CLOCK9, CONFUSED, COW, DIAMOND, DIAMOND_SMALL, DUCK, FABULOUS, GHOST, GIRAFFE, GO_RIGHT, GO_LEFT, GO_UP, GO_DOWN, HAPPY, HEART, HEART_SMALL, HOUSE, MEH, MUSIC_CROTCHET, MUSIC_QUAVER, MUSIC_QUAVERS, NO, PACMAN, PITCHFORK, RABBIT, ROLLERSKATE, SAD, SILLY, SKULL, SMILE, SNAKE, SQUARE, SQUARE_SMALL, STICKFIGURE, SURPRISED, SWORD, TARGET, TORTOISE, TRIANGLE, TRIANGLE_LEFT, TSHIRT, UMBRELLA, XMAS, YES)) – the name of the image to display
brightness (integer [0,100]) – brightness of the image
- c_write(text)
Text writing function (letters are displayed one by one)
Warning
This function is not part of the spike API. It is provided to update the component from scenario data and shall not be used by the end-user.
- Parameters:
text (string) – text to display
- c_off()
Shut down all the pixel of the light matrix
Warning
This function is not part of the spike API. It is provided to update the component from scenario data and shall not be used by the end-user.
- c_get_matrix()
Return matrix state
Warning
This function is not part of the spike API. It is provided to update the component from scenario data and shall not be used by the end-user.
- Returns:
5x5 array containing each pixel state
- Return type:
list