util.constants – constants module¶
???
Constants¶
- util.constants.LPF2_FLIPPER_MOTOR_MEDIUM = 48¶
- util.constants.LPF2_FLIPPER_MOTOR_LARGE = 49¶
- util.constants.LPF2_ACCELERATION = 57¶
- util.constants.LPF2_GYRO = 58¶
- util.constants.LPF2_ORIENTATION = 59¶
- util.constants.LPF2_FLIPPER_COLOR = 61¶
- util.constants.LPF2_FLIPPER_DISTANCE = 62¶
- util.constants.LPF2_FLIPPER_FORCE = 63¶
- util.constants.LPF2_FLIPPER_MOTOR_SMALL = 65¶
- util.constants.LPF2_STONE_GREY_MOTOR_MEDIUM = 75¶
- util.constants.LPF2_STONE_GREY_MOTOR_LARGE = 76¶
Constants to represent various types of input device. They correspond to official PoweredUp/SpikePrime Type IDs - see for example https://github.com/pybricks/technical-info/blob/master/assigned-numbers.md
- util.constants.MOTOR_TYPES = (65, 48, 49, 75, 76)¶
A tuple specifying which of the above types are motors.
- util.constants.DEFAULT_IMAGE = (Image('09090:99999:99999:09990:00900:'), Image('09000:09900:09990:09900:09000:'))¶
Two Image objects that are the default initial display screens on the Spike Prime and the RI5 firmwares respectively.
- util.constants.SLOTS_IMAGE = (Image('09990:09090:09090:09090:09990:'), Image('00900:09900:00900:00900:09990:'), Image('09990:00090:09990:09000:09990:'), Image('09990:00090:09990:00090:09990:'), Image('09090:09090:09990:00090:00090:'), Image('09990:09000:09990:00090:09990:'), Image('09990:09000:09990:09090:09990:'), Image('09990:00090:00900:09000:09000:'), Image('09990:09090:09990:09090:09990:'), Image('09990:09090:09990:00090:09990:'), Image('90999:90909:90909:90909:90999:'), Image('09009:99099:09009:09009:09009:'), Image('90999:90009:90999:90900:90999:'), Image('90999:90009:90999:90009:90999:'), Image('90909:90909:90999:90009:90009:'), Image('90999:90900:90999:90009:90999:'), Image('90999:90900:90999:90909:90999:'), Image('90999:90009:90090:90900:90900:'), Image('90999:90909:90999:90909:90999:'), Image('90999:90909:90999:90009:90999:'))¶
Image objects shown in the menu system when navigating between slots (they are the numbers 0 - 19).
- util.constants.PORTS = {'C': Port(C), 'B': Port(B), 'D': Port(D), 'E': Port(E), 'A': Port(A), 'F': Port(F)}¶
Dictionary mapping port names to the corresponding Port objects (see
hub.Port).
- util.constants.FLOAT = 0¶
- util.constants.BRAKE = 1¶
- util.constants.HOLD = 2¶
Modes of operation for stopping a motor. FLOAT simply removes power and allows coasting, while BRAKE reverses power to stop the motor as soon as possible, and HOLD mode will deliberately try to return to the braked point if it is moved away from it.
- util.constants.USB_VCP = USB_VCP(0)¶
- util.constants.BT_VCP = BT_VCP(0)¶
Aliases for the main USB and Bluetooth objects on the Hub. See
hub.USB_VCPandhub.BT_VCP.
- util.constants.NO_KEY = -1¶
- util.constants.NUMBER = 0¶
- util.constants.STRING = 1¶
- util.constants.BOOLEAN = 2¶
- util.constants.VAR_DEFAULTS = {0: 0, 1: '', 2: False}¶
Imported by util.scratch – scratch utility module. Seems to be representing basic scratch data types numerically, with a dictionary to look up their default values.
- util.constants.TIMER_PACE_LOW = 48¶
- util.constants.TIMER_PACE_HIGH = 16¶
Imported by programrunner – run user programs and hub_runtime – Hub main module. ???
- util.constants.INACTIVE_SHUTDOWN_MS = 300000¶
- util.constants.INACTIVE_SHUTDOWN_BT_MS = 1200000¶
Imported by
ui.hubui. Presumably they represent the length of inactive time before the system shuts down. Perhaps when running alone, and when connected to bluetooth?
- util.constants.LONG_PRESS_MS = 3000¶
Not obviously used anywhere. ???
- util.constants.SUCCESS = 0¶
- util.constants.INTERRUPTED = 1¶
Seems to represent return codes of some function somewhere. Success code is imported in various places. ???
- util.constants.STALLED = 2¶
Not obviously used anywhere. May belong to the previous group? ???
- util.constants.NO_STATUS = -1¶
Imported by various methods submodules in the commands – commands module module. ???
- util.constants.DATA_DIR = /data¶
- util.constants.LINEGRAPH_DIR = /data/linegraph¶
- util.constants.LOCAL_NAME = /local_name.txt¶
Important things in the local filesystem. ???
Sounds Class¶
- class util.constants.Sounds(???)¶
???
Constants
Looks like filesystem locations of sounds associated with certain system operations.
- NAVIGATION = sounds/menu_click¶
???
- NAVIGATION_FAST = sounds/menu_fastback¶
???
- STARTUP = sounds/startup¶
???
- SHUTDOWN = sounds/menu_shutdown¶
???
- PROGRAM_STOP = sounds/menu_program_stop¶
???
- PROGRAM_START = sounds/menu_program_start¶
???
Image Class¶
- class util.constants.Image(???)¶
??? I’m not quite clear whether this class principally lives here or in hub – hub brick functionality…
Methods
- width(???)¶
???
- height(???)¶
???
- get_pixel(???)¶
???
- set_pixel(???)¶
???
- shift_left(???)¶
???
- shift_right(???)¶
???
- shift_up(???)¶
???
- shift_down(???)¶
???
Constants
- HEART = Image('09090:99999:99999:09990:00900:')¶
- HEART_SMALL = Image('00000:09090:09990:00900:00000:')¶
- HAPPY = Image('00000:09090:00000:90009:09990:')¶
- SMILE = Image('00000:00000:00000:90009:09990:')¶
- SAD = Image('00000:09090:00000:09990:90009:')¶
- CONFUSED = Image('00000:09090:00000:09090:90909:')¶
- ANGRY = Image('90009:09090:00000:99999:90909:')¶
- ASLEEP = Image('00000:99099:00000:09990:00000:')¶
- SURPRISED = Image('09090:00000:00900:09090:00900:')¶
- SILLY = Image('90009:00000:99999:00909:00999:')¶
- FABULOUS = Image('99999:99099:00000:09090:09990:')¶
- MEH = Image('09090:00000:00090:00900:09000:')¶
- YES = Image('00000:00009:00090:90900:09000:')¶
- NO = Image('90009:09090:00900:09090:90009:')¶
- CLOCK12 = Image('00900:00900:00900:00000:00000:')¶
- CLOCK1 = Image('00090:00090:00900:00000:00000:')¶
- CLOCK2 = Image('00000:00099:00900:00000:00000:')¶
- CLOCK3 = Image('00000:00000:00999:00000:00000:')¶
- CLOCK4 = Image('00000:00000:00900:00099:00000:')¶
- CLOCK5 = Image('00000:00000:00900:00090:00090:')¶
- CLOCK6 = Image('00000:00000:00900:00900:00900:')¶
- CLOCK7 = Image('00000:00000:00900:09000:09000:')¶
- CLOCK8 = Image('00000:00000:00900:99000:00000:')¶
- CLOCK9 = Image('00000:00000:99900:00000:00000:')¶
- CLOCK10 = Image('00000:99000:00900:00000:00000:')¶
- CLOCK11 = Image('09000:09000:00900:00000:00000:')¶
- ARROW_N = Image('00900:09990:90909:00900:00900:')¶
- ARROW_NE = Image('00999:00099:00909:09000:90000:')¶
- ARROW_E = Image('00900:00090:99999:00090:00900:')¶
- ARROW_SE = Image('90000:09000:00909:00099:00999:')¶
- ARROW_S = Image('00900:00900:90909:09990:00900:')¶
- ARROW_SW = Image('00009:00090:90900:99000:99900:')¶
- ARROW_W = Image('00900:09000:99999:09000:00900:')¶
- ARROW_NW = Image('99900:99000:90900:00090:00009:')¶
- GO_RIGHT = Image('09000:09900:09990:09900:09000:')¶
- GO_LEFT = Image('00090:00990:09990:00990:00090:')¶
- GO_UP = Image('00000:00900:09990:99999:00000:')¶
- GO_DOWN = Image('00000:99999:09990:00900:00000:')¶
- TRIANGLE = Image('00000:00900:09090:99999:00000:')¶
- TRIANGLE_LEFT = Image('90000:99000:90900:90090:99999:')¶
- CHESSBOARD = Image('09090:90909:09090:90909:09090:')¶
- DIAMOND = Image('00900:09090:90009:09090:00900:')¶
- DIAMOND_SMALL = Image('00000:00900:09090:00900:00000:')¶
- SQUARE = Image('99999:90009:90009:90009:99999:')¶
- SQUARE_SMALL = Image('00000:09990:09090:09990:00000:')¶
- RABBIT = Image('90900:90900:99990:99090:99990:')¶
- COW = Image('90009:90009:99999:09990:00900:')¶
- MUSIC_CROTCHET = Image('00900:00900:00900:99900:99900:')¶
- MUSIC_QUAVER = Image('00900:00990:00909:99900:99900:')¶
- MUSIC_QUAVERS = Image('09999:09009:09009:99099:99099:')¶
- PITCHFORK = Image('90909:90909:99999:00900:00900:')¶
- XMAS = Image('00900:09990:00900:09990:99999:')¶
- PACMAN = Image('09999:99090:99900:99990:09999:')¶
- TARGET = Image('00900:09990:99099:09990:00900:')¶
- TSHIRT = Image('99099:99999:09990:09990:09990:')¶
- ROLLERSKATE = Image('00099:00099:99999:99999:09090:')¶
- DUCK = Image('09900:99900:09999:09990:00000:')¶
- HOUSE = Image('00900:09990:99999:09990:09090:')¶
- TORTOISE = Image('00000:09990:99999:09090:00000:')¶
- BUTTERFLY = Image('99099:99999:00900:99999:99099:')¶
- STICKFIGURE = Image('00900:99999:00900:09090:90009:')¶
- GHOST = Image('99999:90909:99999:99999:90909:')¶
- SWORD = Image('00900:00900:00900:09990:00900:')¶
- GIRAFFE = Image('99000:09000:09000:09990:09090:')¶
- SKULL = Image('09990:90909:99999:09990:09990:')¶
- UMBRELLA = Image('09990:99999:00900:90900:09900:')¶
- SNAKE = Image('99000:99099:09090:09990:00000:')¶
These are all Image objects containing the pictures suggested by their names.
- ALL_CLOCKS = (Image('00900:00900:00900:00000:00000:'), Image('00090:00090:00900:00000:00000:'), Image('00000:00099:00900:00000:00000:'), Image('00000:00000:00999:00000:00000:'), Image('00000:00000:00900:00099:00000:'), Image('00000:00000:00900:00090:00090:'), Image('00000:00000:00900:00900:00900:'), Image('00000:00000:00900:09000:09000:'), Image('00000:00000:00900:99000:00000:'), Image('00000:00000:99900:00000:00000:'), Image('00000:99000:00900:00000:00000:'), Image('09000:09000:00900:00000:00000:'))¶
- ALL_ARROWS = (Image('00900:09990:90909:00900:00900:'), Image('00999:00099:00909:09000:90000:'), Image('00900:00090:99999:00090:00900:'), Image('90000:09000:00909:00099:00999:'), Image('00900:00900:90909:09990:00900:'), Image('00009:00090:90900:99000:99900:'), Image('00900:09000:99999:09000:00900:'), Image('99900:99000:90900:00090:00009:'))¶
A couple of tuples of sets of images you might want to iterate though.
Imports¶
Function
micropython.const