Part I of the CRE in week 9 consists of a programming assignment for the micro:bit in MicroPython.
Write an application which interprets binary strings as unsigned and signed integers, floating point reals, and character strings.
"Screens" is used in the sense of sub-programs, which are mutually exclusive (that is, only one can be active at a time), and each of which has a distinct function. The application should have two pages:
- Definition of a 32-bit binary pattern (that is, a sequence of 32 1s and 0s).
- Interpretation of the 32-bit pattern as different formats and presentation of the interpretation in decimal.
- The bit pattern should be represented on the LEDs of the micro:bit, from top-left to bottom-right, row-by-row.
- Use two pages, one for the first 25 bits, and a second for the remaining 7 bits.
- Use a blinking cursor to indicate which bit is being selected. Start from the top-left-most bit and go across and down, line-by-line.
- Button B advances the cursor.
- Button A toggles the value of the current bit.
- The LEDs mean the following:
- LED on: 1
- LED off: 0
bit_pattern = '10001111010101001001100011110010'
- The 32-bit pattern from the other screen should be interpreted in 4 different ways:
- U - unsigned integer
- I - signed integer
- F - floating-point real (single-precision IEEE 754 floating point)
- C - a string of 4 ASCII characters (Note: Some ASCII values might not have character representations on the micro:bit.)
- The screen has two different pages:
- Format menu, which cycles through
U
,I
,F
, andC
images (that is, user-definedImage()
constants) - Value page, which scrolls the interpreted number or string, and then returns to the format menu.
- Format menu, which cycles through
- Button A cycles through the format menu.
- Button B switches to the value menu with the currently selected format.
- Hint: There are datatype conversion functions in Python/MicroPython. You don't have to write them from scratch.
- Use a long press of button B to toggle between bit pattern definition and interpretation screens.
- Fork this repository on Github.
- Clone to PyCharm (or an alternative Git interface).
- Add a Python file to the repository. Don't forget to
git add
it, too. - Code in PyCharm and mu, and test until you are satisfied with the functionality.
- Commit your code in PyCharm (or an alternative Git interface).
- Push to remote on Github.
Detailed assignment guidance can be found in the program notes.