]> Repositories - hackapet/Adafruit_Blinka_Displayio.git/blob - displayio/_helpers.py
Fewer bugs, more code, shape done
[hackapet/Adafruit_Blinka_Displayio.git] / displayio / _helpers.py
1 # SPDX-FileCopyrightText: 2023 Melissa LeBlanc-Williams for Adafruit Industries
2 #
3 # SPDX-License-Identifier: MIT
4
5 """
6 `displayio.helpers`
7 ================================================================================
8
9 displayio for Blinka
10
11 **Software and Dependencies:**
12
13 * Adafruit Blinka:
14   https://github.com/adafruit/Adafruit_Blinka/releases
15
16 * Author(s): Melissa LeBlanc-Williams
17
18 """
19
20 __version__ = "0.0.0+auto.0"
21 __repo__ = "https://github.com/adafruit/Adafruit_Blinka_displayio.git"
22
23
24 def clamp(value, min_value, max_value):
25     """Clamp a value between a minimum and maximum value"""
26     return max(min(max_value, value), min_value)
27
28
29 def bswap16(value):
30     """Swap the bytes in a 16 bit value"""
31     return (value & 0xFF00) >> 8 | (value & 0x00FF) << 8