Improved text handling
This change allows for more precise control over the position of text labels
This commit is contained in:
		
				
					committed by
					
						 GitHub
						GitHub
					
				
			
			
				
	
			
			
			
						parent
						
							5b88d8a880
						
					
				
				
					commit
					dcbed64aa9
				
			| @@ -10,8 +10,6 @@ from kmk.extensions import Extension | ||||
| from kmk.handlers.stock import passthrough as handler_passthrough | ||||
| from kmk.keys import make_key | ||||
|  | ||||
| DISPLAY_OFFSET = 4  # Used to calculate a new zero level since SSD1306 is clipped. | ||||
|  | ||||
|  | ||||
| class OledEntryType: | ||||
|     TXT = 0 | ||||
| @@ -27,13 +25,15 @@ class OledData: | ||||
|             self.data = entries | ||||
|  | ||||
|     @staticmethod | ||||
|     def oled_text_entry(x=0, y=0, text='', layer=None): | ||||
|     def oled_text_entry(x=0, y=0, x_anchor=0.0, y_anchor=0.0, text='', layer=None): | ||||
|         return { | ||||
|             0: text, | ||||
|             1: x, | ||||
|             2: y, | ||||
|             3: layer, | ||||
|             4: OledEntryType.TXT, | ||||
|             5: x_anchor, | ||||
|             6: y_anchor, | ||||
|         } | ||||
|  | ||||
|     @staticmethod | ||||
| @@ -88,8 +88,8 @@ class Oled(Extension): | ||||
|                             terminalio.FONT, | ||||
|                             text=view[0], | ||||
|                             color=0xFFFFFF, | ||||
|                             x=view[1], | ||||
|                             y=view[2] + DISPLAY_OFFSET, | ||||
|                             anchor_point=(view[5],view[6]), | ||||
|                             anchored_position = (view[1],view[2]), | ||||
|                         ) | ||||
|                     ) | ||||
|                 elif view[4] == OledEntryType.IMG: | ||||
| @@ -98,7 +98,7 @@ class Oled(Extension): | ||||
|                             view[0], | ||||
|                             pixel_shader=view[0].pixel_shader, | ||||
|                             x=view[1], | ||||
|                             y=view[2] + DISPLAY_OFFSET, | ||||
|                             y=view[2], | ||||
|                         ) | ||||
|                     ) | ||||
|         gc.collect() | ||||
|   | ||||
		Reference in New Issue
	
	Block a user