Display
Display
Game Display is a class that abstracts different S^3 panels into one display
Source code in display/display.py
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 |
|
__init__(board_objects, x_width, y_height)
Constructor
board_objects -- 2d array of seven segment objects oriented how the sign is put together, i.e. [[panel0, panel1],[panel2,panel3]] x_width -- number of digits in the display on the x axis y_height -- number of pixels on the y axis (each vertical digit is split into two pixels)
Source code in display/display.py
clear()
Clear all the panels on the display
Source code in display/display.py
draw_hline(start_x, start_y, length, top=True, combine=True, push=False)
Draw horizontal line
start_x -- x coordinate start_y -- y coordinate length -- length of line to draw top -- draw horizontal line on the top or bottom of the pixel combine -- digits are split into two pixels, when drawing to one combine keeps what is already drawn on the other side of the digit push -- when true all the recent changes are pushed to the display
Source code in display/display.py
draw_pixel(x, y, value, combine=True, push=False)
Draw shape to one pixel location
x -- x coordinate y -- y coordinate value -- which leds to turn on for the pixel (1 for bottom, 2 for left, 4 for top, 8 for right, add sides together for multiple sides) combine -- digits are split into two pixels, when drawing to one combine keeps what is already drawn on the other side of the digit push -- when true all the recent changes are pushed to the display
Source code in display/display.py
draw_raw(x, y, value, push=False)
Draw to a specific segment on the screen
x -- x coordinate y -- y coordinate value -- which leds to turn on for the segment push -- when true all the recent changes are pushed to the display
Source code in display/display.py
draw_shape_line(start_x, start_y, end_x, end_y, value, combine=True, push=False)
Draw line with given value at each pixel, can be diagonal
start_x -- starting x coordinate start_y -- starting y coordinate end_x -- ending x coordinate end_y -- ending y coordiante value -- which leds to turn on for the pixel (1 for bottom, 2 for left, 4 for top, 8 for right, add sides together for multiple sides) combine -- digits are split into two pixels, when drawing to one combine keeps what is already drawn on the other side of the digit push -- when true all the recent changes are pushed to the display
Source code in display/display.py
draw_text(x, y, msg, combine=True, push=False)
Print a message to the screen, y_height-2 is lowest y value accepted without error
x -- x coordinate y -- y coordinate msg -- string message to print combine -- digits are split into two pixels, when drawing to one combine keeps what is already drawn on the other side of the digit push -- when true all the recent changes are pushed to the display
Source code in display/display.py
draw_vline(start_x, start_y, length, left=True, combine=True, push=False)
Draw vertical line
start_x -- x coordinate start_y -- y coordinate length -- length of line to draw left -- draw vertial line on the left or right of the pixel combine -- digits are split into two pixels, when drawing to one combine keeps what is already drawn on the other side of the digit push -- when true all the recent changes are pushed to the display
Source code in display/display.py
get_pixel(x, y)
Get the value already at the pixel
x -- x coordinate y -- y coordinate
Source code in display/display.py
get_raw(x, y)
push()
Push all the recent changes to the display
Source code in display/display.py
SegmentDisplay
SegmentDisplay is a class that abstracts the S^3 screen into individually controllable segments. Instead of making each circle of a segment a pixel, this class lets you control each segment as a pixel. This means this display is 2 times wider (there are two horizontal segments) and 3 times higher (there are three vertical segments) than the Display object.
Source code in display/segment_display.py
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
|
draw(push=True)
Updates the screen with all of the lines drawn using draw_line.
push -- when true all the recent changes are pushed to the display
Source code in display/segment_display.py
draw_line(start_x, start_y, end_x, end_y)
Draws a line from coordinate to another. To display the line, you must use the draw function. This function only updates the underlying data buffer.
start_x -- the starting x point start_y -- the starting y point end_x -- the ending x point end_y -- the ending y point
Source code in display/segment_display.py
undraw()
Clears all segments drawn both from the screen and from the underlying data structure.
Source code in display/segment_display.py
SevenSegment
Source code in display/seven_seg.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 |
|
__init__(num_digits=8, num_per_segment=MAX7219_DIGITS, baudrate=DEFAULT_BAUDRATE, cs_num=0, brightness=7, clear=True, segment_orientation_array=None)
Constructor
num_digits -- total number of digits in your display (default 8) num_per_segment -- total number of digits per MAX7219 segment (default 8) baudrate -- rate at which data is transfered (default 9000kHz), excessive rate may result in instability cs_num -- which control select line is being used (default 0) brightness -- starting brightness of the leds (default 7) clear -- clear the screen on initialization (default True) segment_orientation_array -- a 2d array of where the MAX7219 segments are located, one indexed (default None) : example [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12]] (height is 6 and width is 16) : this needs to be populated to use coordinate grid style functions i.e. letter2 (default None)
Source code in display/seven_seg.py
brightness(value)
Sets the brightness for all of the segments ranging from 0 - 15
Source code in display/seven_seg.py
clear(flush=True)
close(clear=True, shutdown=True)
command(register_num, value)
Sets control registers for each segment in the display
Source code in display/seven_seg.py
flush()
Flush all the current changes to the display
Source code in display/seven_seg.py
flush_legacy()
Cascade the buffer onto the display
Source code in display/seven_seg.py
letter(position, char, dot=False, flush=False)
Outputs ascii letter as close as it can, working letters/symbols found in symbols.py
Source code in display/seven_seg.py
letter2(x, y, char, dot=False, flush=False)
Output letter on the display at the coordinates provided if possible
Source code in display/seven_seg.py
raw(position, value, flush=False)
Given raw 0-255 value draw symbol at given postion
Source code in display/seven_seg.py
raw2(x, y, value, flush=False)
text(txt, start_position=0, flush=False)
Output text on the display at the start position if possible
Source code in display/seven_seg.py
text2(x, y, txt, horizontal=True, flush=False)
Output text on the display at the given x, y - option to display horizontal or vertical text
Source code in display/seven_seg.py
Created: July 13, 2022