MeterLogger
Functions | Variables
led.c File Reference
#include <esp8266.h>
#include "debug.h"
#include "led.h"
Include dependency graph for led.c:

Go to the source code of this file.

Functions

ICACHE_FLASH_ATTR static void led_blinker_timer_func (void *arg)
 
ICACHE_FLASH_ATTR static void led_single_blink_off_timer_func (void *arg)
 
ICACHE_FLASH_ATTR static void led_double_blink_timer_func (void *arg)
 
ICACHE_FLASH_ATTR void led_init (void)
 
ICACHE_FLASH_ATTR void led_on (void)
 
ICACHE_FLASH_ATTR void led_off (void)
 
ICACHE_FLASH_ATTR void led_blink (void)
 
ICACHE_FLASH_ATTR void led_pattern_a (void)
 
ICACHE_FLASH_ATTR void led_pattern_b (void)
 
ICACHE_FLASH_ATTR void led_pattern_c (void)
 
ICACHE_FLASH_ATTR void led_stop_pattern (void)
 

Variables

static os_timer_t led_blinker_timer
 
static os_timer_t led_single_blink_off_timer
 
static os_timer_t led_double_blink_timer
 
static os_timer_t led_sub_pattern_timer
 
static volatile bool led_blinker_timer_running = false
 
static volatile bool led_double_blinker_timer_running = false
 
static uint8_t led_sub_pattern_state = 0
 

Function Documentation

◆ led_blink()

ICACHE_FLASH_ATTR void led_blink ( void  )

Definition at line 99 of file led.c.

References led_on(), led_single_blink_off_timer, led_single_blink_off_timer_func(), NULL, os_timer_arm, os_timer_disarm, os_timer_func_t, and os_timer_setfn.

Referenced by en61107_receive_timeout_timer_func().

99  {
100  led_on();
104 }
#define os_timer_disarm
Definition: osapi.h:51
static os_timer_t led_single_blink_off_timer
Definition: led.c:6
#define NULL
Definition: def.h:47
#define os_timer_func_t
Definition: os_type.h:35
#define os_timer_setfn
Definition: osapi.h:52
ICACHE_FLASH_ATTR static void led_single_blink_off_timer_func(void *arg)
Definition: led.c:32
ICACHE_FLASH_ATTR void led_on(void)
Definition: led.c:88
#define os_timer_arm(a, b, c)
Definition: osapi.h:50
Here is the call graph for this function:
Here is the caller graph for this function:

◆ led_blinker_timer_func()

ICACHE_FLASH_ATTR static void led_blinker_timer_func ( void *  arg)
static

Definition at line 16 of file led.c.

References BIT2, GPIO_OUT_ADDRESS, GPIO_REG_READ, led_blinker_timer, led_blinker_timer_running, led_off(), led_on(), and os_timer_disarm.

Referenced by led_pattern_a(), and led_pattern_b().

16  {
17  if (led_blinker_timer_running == false) {
18  // stop blinking if asked to stop via state variable led_blinker_timer_running
20  return;
21  }
22 
23  // do blinky stuff
25  led_on();
26  }
27  else {
28  led_off();
29  }
30 }
#define os_timer_disarm
Definition: osapi.h:51
#define GPIO_REG_READ(reg)
Definition: eagle_soc.h:97
ICACHE_FLASH_ATTR void led_off(void)
Definition: led.c:93
#define BIT2
Definition: eagle_soc.h:58
static volatile bool led_blinker_timer_running
Definition: led.c:11
static os_timer_t led_blinker_timer
Definition: led.c:5
ICACHE_FLASH_ATTR void led_on(void)
Definition: led.c:88
#define GPIO_OUT_ADDRESS
Definition: eagle_soc.h:99
Here is the call graph for this function:
Here is the caller graph for this function:

◆ led_double_blink_timer_func()

ICACHE_FLASH_ATTR static void led_double_blink_timer_func ( void *  arg)
static

Definition at line 36 of file led.c.

References led_double_blink_timer, led_double_blinker_timer_running, led_off(), led_on(), led_sub_pattern_state, led_sub_pattern_timer, NULL, os_timer_arm, os_timer_disarm, os_timer_func_t, and os_timer_setfn.

Referenced by led_pattern_c().

36  {
37  // blink fast two times
38  if (led_double_blinker_timer_running == false) {
39  // stop blinking if asked to stop via state variable led_double_blinker_timer_running
41  return;
42  }
43 
44  led_off();
45 
46  switch (led_sub_pattern_state) {
47  case 0:
48  led_on();
49 
54  break;
55  case 1:
56  led_off();
57 
62  break;
63  case 2:
64  led_on();
65 
70  break;
71  case 3:
72  led_off();
73 
76  break;
77  }
78 }
static os_timer_t led_sub_pattern_timer
Definition: led.c:9
#define os_timer_disarm
Definition: osapi.h:51
#define NULL
Definition: def.h:47
#define os_timer_func_t
Definition: os_type.h:35
static uint8_t led_sub_pattern_state
Definition: led.c:14
#define os_timer_setfn
Definition: osapi.h:52
ICACHE_FLASH_ATTR void led_off(void)
Definition: led.c:93
static os_timer_t led_double_blink_timer
Definition: led.c:8
ICACHE_FLASH_ATTR void led_on(void)
Definition: led.c:88
#define os_timer_arm(a, b, c)
Definition: osapi.h:50
ICACHE_FLASH_ATTR static void led_double_blink_timer_func(void *arg)
Definition: led.c:36
static volatile bool led_double_blinker_timer_running
Definition: led.c:12
Here is the call graph for this function:
Here is the caller graph for this function:

◆ led_init()

ICACHE_FLASH_ATTR void led_init ( void  )

Definition at line 80 of file led.c.

References BIT2, FUNC_GPIO2, gpio_output_set(), PERIPHS_IO_MUX_GPIO2_U, and PIN_FUNC_SELECT.

80  {
81  //Set GPIO2 to output mode
83 
84  // Set GPIO2 to HIGH (turn blue led off)
85  gpio_output_set(BIT2, 0, BIT2, 0);
86 }
#define PIN_FUNC_SELECT(PIN_NAME, FUNC)
Definition: eagle_soc.h:270
#define PERIPHS_IO_MUX_GPIO2_U
Definition: eagle_soc.h:258
#define BIT2
Definition: eagle_soc.h:58
void gpio_output_set(uint32 set_mask, uint32 clear_mask, uint32 enable_mask, uint32 disable_mask)
#define FUNC_GPIO2
Definition: eagle_soc.h:259
Here is the call graph for this function:

◆ led_off()

ICACHE_FLASH_ATTR void led_off ( void  )

Definition at line 93 of file led.c.

References BIT2, and gpio_output_set().

Referenced by ac_out_off_timer_func(), ac_pwm_timer_func(), led_blinker_timer_func(), led_double_blink_timer_func(), led_single_blink_off_timer_func(), and led_stop_pattern().

93  {
94 
95  // Set GPIO2 to HIGH
96  gpio_output_set(BIT2, 0, BIT2, 0);
97 }
#define BIT2
Definition: eagle_soc.h:58
void gpio_output_set(uint32 set_mask, uint32 clear_mask, uint32 enable_mask, uint32 disable_mask)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ led_on()

ICACHE_FLASH_ATTR void led_on ( void  )

Definition at line 88 of file led.c.

References BIT2, and gpio_output_set().

Referenced by ac_pwm_timer_func(), led_blink(), led_blinker_timer_func(), and led_double_blink_timer_func().

88  {
89  //Set GPIO2 to LOW
90  gpio_output_set(0, BIT2, BIT2, 0);
91 }
#define BIT2
Definition: eagle_soc.h:58
void gpio_output_set(uint32 set_mask, uint32 clear_mask, uint32 enable_mask, uint32 disable_mask)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ led_pattern_a()

ICACHE_FLASH_ATTR void led_pattern_a ( void  )

Definition at line 106 of file led.c.

References led_blinker_timer, led_blinker_timer_func(), led_blinker_timer_running, NULL, os_timer_arm, os_timer_disarm, os_timer_func_t, and os_timer_setfn.

Referenced by ac_motor_valve_open(), ac_test(), ac_test_timer_func(), ac_thermo_close(), and wifi_scan_done_cb().

106  {
109  led_blinker_timer_running = true; // state variable to control stopping after pattern is done
110  os_timer_arm(&led_blinker_timer, 1000, 1);
111 }
#define os_timer_disarm
Definition: osapi.h:51
ICACHE_FLASH_ATTR static void led_blinker_timer_func(void *arg)
Definition: led.c:16
#define NULL
Definition: def.h:47
#define os_timer_func_t
Definition: os_type.h:35
#define os_timer_setfn
Definition: osapi.h:52
static volatile bool led_blinker_timer_running
Definition: led.c:11
static os_timer_t led_blinker_timer
Definition: led.c:5
#define os_timer_arm(a, b, c)
Definition: osapi.h:50
Here is the call graph for this function:
Here is the caller graph for this function:

◆ led_pattern_b()

ICACHE_FLASH_ATTR void led_pattern_b ( void  )

Definition at line 113 of file led.c.

References led_blinker_timer, led_blinker_timer_func(), led_blinker_timer_running, NULL, os_timer_arm, os_timer_disarm, os_timer_func_t, and os_timer_setfn.

Referenced by ac_motor_valve_close(), ac_test_timer_func(), ac_thermo_open(), and watchdog_timer_func().

113  {
116  led_blinker_timer_running = true; // state variable to control stopping after pattern is done
118 }
#define os_timer_disarm
Definition: osapi.h:51
ICACHE_FLASH_ATTR static void led_blinker_timer_func(void *arg)
Definition: led.c:16
#define NULL
Definition: def.h:47
#define os_timer_func_t
Definition: os_type.h:35
#define os_timer_setfn
Definition: osapi.h:52
static volatile bool led_blinker_timer_running
Definition: led.c:11
static os_timer_t led_blinker_timer
Definition: led.c:5
#define os_timer_arm(a, b, c)
Definition: osapi.h:50
Here is the call graph for this function:
Here is the caller graph for this function:

◆ led_pattern_c()

ICACHE_FLASH_ATTR void led_pattern_c ( void  )

Definition at line 120 of file led.c.

References led_double_blink_timer, led_double_blink_timer_func(), led_double_blinker_timer_running, NULL, os_timer_arm, os_timer_disarm, os_timer_func_t, and os_timer_setfn.

120  {
121  // blink fast two times every 5th second
124  led_double_blinker_timer_running = true; // state variable to control stopping after pattern is done
126 }
#define os_timer_disarm
Definition: osapi.h:51
#define NULL
Definition: def.h:47
#define os_timer_func_t
Definition: os_type.h:35
#define os_timer_setfn
Definition: osapi.h:52
static os_timer_t led_double_blink_timer
Definition: led.c:8
#define os_timer_arm(a, b, c)
Definition: osapi.h:50
ICACHE_FLASH_ATTR static void led_double_blink_timer_func(void *arg)
Definition: led.c:36
static volatile bool led_double_blinker_timer_running
Definition: led.c:12
Here is the call graph for this function:

◆ led_single_blink_off_timer_func()

ICACHE_FLASH_ATTR static void led_single_blink_off_timer_func ( void *  arg)
static

Definition at line 32 of file led.c.

References led_off().

Referenced by led_blink().

32  {
33  led_off();
34 }
ICACHE_FLASH_ATTR void led_off(void)
Definition: led.c:93
Here is the call graph for this function:
Here is the caller graph for this function:

◆ led_stop_pattern()

ICACHE_FLASH_ATTR void led_stop_pattern ( void  )

Definition at line 128 of file led.c.

References led_blinker_timer_running, led_double_blinker_timer_running, and led_off().

Referenced by ac_out_off_timer_func(), ac_thermo_pwm(), wifi_reconnect_timer_func(), and wifi_scan_done_cb().

128  {
131  led_off();
132 }
ICACHE_FLASH_ATTR void led_off(void)
Definition: led.c:93
static volatile bool led_blinker_timer_running
Definition: led.c:11
static volatile bool led_double_blinker_timer_running
Definition: led.c:12
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ led_blinker_timer

os_timer_t led_blinker_timer
static

Definition at line 5 of file led.c.

Referenced by led_blinker_timer_func(), led_pattern_a(), and led_pattern_b().

◆ led_blinker_timer_running

volatile bool led_blinker_timer_running = false
static

Definition at line 11 of file led.c.

Referenced by led_blinker_timer_func(), led_pattern_a(), led_pattern_b(), and led_stop_pattern().

◆ led_double_blink_timer

os_timer_t led_double_blink_timer
static

Definition at line 8 of file led.c.

Referenced by led_double_blink_timer_func(), and led_pattern_c().

◆ led_double_blinker_timer_running

volatile bool led_double_blinker_timer_running = false
static

Definition at line 12 of file led.c.

Referenced by led_double_blink_timer_func(), led_pattern_c(), and led_stop_pattern().

◆ led_single_blink_off_timer

os_timer_t led_single_blink_off_timer
static

Definition at line 6 of file led.c.

Referenced by led_blink().

◆ led_sub_pattern_state

uint8_t led_sub_pattern_state = 0
static

Definition at line 14 of file led.c.

Referenced by led_double_blink_timer_func().

◆ led_sub_pattern_timer

os_timer_t led_sub_pattern_timer
static

Definition at line 9 of file led.c.

Referenced by led_double_blink_timer_func().