Oliver Fabel 1 год назад
Родитель
Сommit
811d3d519a
3 измененных файлов с 71 добавлено и 8 удалено
  1. 12 0
      docs/pages/reference.rst
  2. 16 8
      flipperzero/_gpio.py
  3. 43 0
      flipperzero/_infrared.py

+ 12 - 0
docs/pages/reference.rst

@@ -351,6 +351,18 @@ Functions
 .. autofunction:: flipperzero.pwm_stop
 .. autofunction:: flipperzero.pwm_stop
 .. autofunction:: flipperzero.pwm_is_running
 .. autofunction:: flipperzero.pwm_is_running
 
 
+Infrared
+--------
+
+Send and receive infrared signals.
+
+Functions
+~~~~~~~~~
+
+.. autofunction:: flipperzero.infrared_receive
+.. autofunction:: flipperzero.infrared_transmit
+.. autofunction:: flipperzero.infrared_is_busy
+
 Built-In
 Built-In
 --------
 --------
 
 

+ 16 - 8
flipperzero/_gpio.py

@@ -3,7 +3,8 @@ from typing import Callable
 GPIO_PIN_PC0: int
 GPIO_PIN_PC0: int
 '''
 '''
 Constant identifier for GPIO pin PC0.
 Constant identifier for GPIO pin PC0.
-This pin can be used as ADC input.
+
+* This pin can be used as ADC input.
     
     
 .. versionadded:: 1.2.0
 .. versionadded:: 1.2.0
 '''
 '''
@@ -11,7 +12,8 @@ This pin can be used as ADC input.
 GPIO_PIN_PC1: int
 GPIO_PIN_PC1: int
 '''
 '''
 Constant identifier for GPIO pin PC1.
 Constant identifier for GPIO pin PC1.
-This pin can be used as ADC input.
+
+* This pin can be used as ADC input.
     
     
 .. versionadded:: 1.2.0
 .. versionadded:: 1.2.0
 '''
 '''
@@ -19,7 +21,8 @@ This pin can be used as ADC input.
 GPIO_PIN_PC3: int
 GPIO_PIN_PC3: int
 '''
 '''
 Constant identifier for GPIO pin PC3.
 Constant identifier for GPIO pin PC3.
-This pin can be used as ADC input.
+
+* This pin can be used as ADC input.
     
     
 .. versionadded:: 1.2.0
 .. versionadded:: 1.2.0
 '''
 '''
@@ -41,8 +44,9 @@ Constant identifier for GPIO pin PB3.
 GPIO_PIN_PA4: int
 GPIO_PIN_PA4: int
 '''
 '''
 Constant identifier for GPIO pin PA4.
 Constant identifier for GPIO pin PA4.
-This pin can be used as ADC input.
-This pin can be used as PWM output.
+
+* This pin can be used as ADC input.
+* This pin can be used as PWM output.
     
     
 .. versionadded:: 1.2.0
 .. versionadded:: 1.2.0
 '''
 '''
@@ -50,7 +54,8 @@ This pin can be used as PWM output.
 GPIO_PIN_PA6: int
 GPIO_PIN_PA6: int
 '''
 '''
 Constant identifier for GPIO pin PA6.
 Constant identifier for GPIO pin PA6.
-This pin can be used as ADC input.
+
+* This pin can be used as ADC input.
     
     
 .. versionadded:: 1.2.0
 .. versionadded:: 1.2.0
 '''
 '''
@@ -58,8 +63,11 @@ This pin can be used as ADC input.
 GPIO_PIN_PA7: int
 GPIO_PIN_PA7: int
 '''
 '''
 Constant identifier for GPIO pin PA7.
 Constant identifier for GPIO pin PA7.
-This pin can be used as ADC input.
-This pin can be used as PWM output.
+
+* This pin can be used as ADC input.
+* This pin can be used as PWM output.
+* This pin can be used to transmit an infrared signal with an IR LED.
+
     
     
 .. versionadded:: 1.2.0
 .. versionadded:: 1.2.0
 '''
 '''

+ 43 - 0
flipperzero/_infrared.py

@@ -0,0 +1,43 @@
+from typing import List
+
+def infrared_receive(timeout: int = 1000000) -> List[int]:
+    '''
+    Receive an infrared signal. This is a blocking method.
+    The method blocks until a timeout occurs or the internal
+    signal buffer (capacity is 1024 timings) is filled.
+
+    :param timeout: The timeout to use in microseconds.
+    :returns: A list of timings in microseconds, starting with high.
+    
+    .. versionadded:: 1.3.0
+    '''
+    pass
+
+def infrared_transmit(signal: List[int], repeat: int = 1, use_external_pin: bool = False, frequency: int = 38000, duty: float = 0.33) -> bool:
+    '''
+    Transmit an infrared signal. This is a blocking method.
+    The method blocks until the whole signal is sent.
+    The signal list has the same format as the return value 
+    of :func:`infrared_receive`. Hence you can directly re-send
+    a received signal without any further processing.
+
+    :param signal: The signal to use.
+    :param repeat: How many times the signal should be sent.
+    :param use_external_pin: :const:`True` to use an external IR LED on GPIO pin :const:`flipperzero.GPIO_PIN_PA7`.
+    :param frequency: The frequency to use for the PWM signal.
+    :param duty: The duty cycle to use for the PWM signal.
+    :returns: :const:`True` on success, :const:`False` otherwise.
+    
+    .. versionadded:: 1.3.0
+    '''
+    pass
+
+def infrared_is_busy() -> bool:
+    '''
+    Check if the infrared subsystem is busy.
+
+    :returns: :const:`True` if occupied, :const:`False` otherwise.
+    
+    .. versionadded:: 1.3.0
+    '''
+    pass