You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
			
				
					15 lines
				
				432 B
			
		
		
			
		
	
	
					15 lines
				
				432 B
			| 
								 
											5 years ago
										 
									 | 
							
								def gpio_init(pin, output):
							 | 
						||
| 
								 | 
							
								  try:
							 | 
						||
| 
								 | 
							
								    with open(f"/sys/class/gpio/gpio{pin}/direction", 'wb') as f:
							 | 
						||
| 
								 | 
							
								      f.write(b"out" if output else b"in")
							 | 
						||
| 
								 | 
							
								  except Exception as e:
							 | 
						||
| 
								 | 
							
								    print(f"Failed to set gpio {pin} direction: {e}")
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								def gpio_set(pin, high):
							 | 
						||
| 
								 | 
							
								  try:
							 | 
						||
| 
								 | 
							
								    with open(f"/sys/class/gpio/gpio{pin}/value", 'wb') as f:
							 | 
						||
| 
								 | 
							
								      f.write(b"1" if high else b"0")
							 | 
						||
| 
								 | 
							
								  except Exception as e:
							 | 
						||
| 
								 | 
							
								    print(f"Failed to set gpio {pin} value: {e}")
							 |