16. Screen Class

Exercises

  1. Design a screen class that keeps track of the brightness of all pixels on the 5 by 5 LED display of the microbit.

  2. Initialize the class instance with all pixels at 0 brightness.

  3. Create a method to reset all pixels to 0 brightness.

  4. Create a method to set all pixels to a given brightness.

  5. Create a method to set all pixels to a random brightness.

  6. Create a method to show the screen using the pixel brightness values.

  7. Create a method to set a pixel brightness like the standard set_pixel method: .set_pixel(x, y, value).

  8. Create a method to get a pixel brightness like the standard set_pixel method: .get_pixel(x, y, value).

  9. Create a method to set the pixel brightness for a row.

  10. Create a method to set the pixel brightness for a column.

  11. Create a method to set the pixel brightness for a column.

  12. Create a method to set the pixel brightness for a random pixel.

  13. Create a method to set a random pixel brightness for a given pixel.

  14. Create a method to set a random pixel brightness for a random pixel.

  15. Create a method that returns the number of pixels with brightness greater than 0.

  16. Create a method that returns the number of pixels with brightness greater than a specified value.

  17. Create a method that returns the number of pixels with brightness of a specified value.