|
@@ -1,8 +1,9 @@
|
|
|
"""
|
|
|
Example Lib
|
|
|
"""
|
|
|
+from machine import Pin, Timer
|
|
|
|
|
|
-class foo:
|
|
|
+class foo(object):
|
|
|
"""
|
|
|
Example class.
|
|
|
"""
|
|
@@ -11,13 +12,49 @@ class foo:
|
|
|
|
|
|
|
|
|
############################## Constructor ##############################
|
|
|
- def __init__(self):
|
|
|
- pass
|
|
|
+ def __init__(self,led_pin_time:Pin,led_pin_button:Pin,button:Pin):
|
|
|
+ """_summary_
|
|
|
|
|
|
- ############################## Methods ##############################
|
|
|
- def bar(self):
|
|
|
+ Args:
|
|
|
+ led_pin_time (Pin): _description_
|
|
|
+ led_pin_button (Pin): _description_
|
|
|
+ button (Pin): _description_
|
|
|
"""
|
|
|
- Example Method.
|
|
|
+
|
|
|
+ self.__led_pin_timer = self.__check_pin(led_pin_time)
|
|
|
+ self.__led_pin_button = self.__check_pin(led_pin_button)
|
|
|
+ self.__button = self.__check_pin(button)
|
|
|
+ self.__led_pin_timer.init(mode=Pin.OUT)
|
|
|
+ self.__led_pin_button.init(mode=Pin.OUT)
|
|
|
+ self.__button.init(mode=Pin.IN)
|
|
|
+ self.__timer = Timer()
|
|
|
+ self.__timer.init(mode=Timer.PERIODIC;period = 200,callback= self.__bliink_handler)
|
|
|
+ self.__button.irq(handler=self.__int_handler,hard=True,trigger=Pin.IRQ_FALLING)
|
|
|
+
|
|
|
+ ############################## Property ##############################
|
|
|
+ @property
|
|
|
+ def button(self):
|
|
|
+ return self.__button
|
|
|
+ @button.setter
|
|
|
+ def button(self,pin):
|
|
|
+ #self.__button = self.__check_pin(pin)
|
|
|
+ raise AttributeError("Du darfst Pin nicht verändern")
|
|
|
+ ############################## Methods ##############################
|
|
|
+
|
|
|
+
|
|
|
+ def __check_pin(self,pin:Pin):
|
|
|
+ """_summary_
|
|
|
+
|
|
|
+ Args:
|
|
|
+ pin (Pin): _description_
|
|
|
"""
|
|
|
+ if not isinstance(pin,Pin):
|
|
|
+ raise ValueError(f"Value\"{pin}\" of \"pin\" is not type \"Pin\"!")
|
|
|
+ else:
|
|
|
+ return pin
|
|
|
|
|
|
- print("class foo, method bar")
|
|
|
+def __blink_handler(self,timer):
|
|
|
+ self.__led_pin_timer.toggle()
|
|
|
+
|
|
|
+def __int_handler(self,pin):
|
|
|
+ self.__led_pin_button.toggle()
|