Pico Led Controller 1.0.3
A project to control LEDs using Raspberry Pi Pico W
ssi.h File Reference
#include <stdint.h>
#include "lwip/apps/httpd.h"

Go to the source code of this file.

Functions

u16_t ssi_handler (int iIndex, char *pcInsert, int iInsertLen)
 SSI handler. More...
 
void ssi_init ()
 SSI init. More...
 

Function Documentation

◆ ssi_handler()

u16_t ssi_handler ( int  iIndex,
char *  pcInsert,
int  iInsertLen 
)

SSI handler.

Function handles SSI requests.

Parameters
iIndexindex of the SSI handler
pcInsertarray of inserts
iInsertLenlength of the insert
Returns
: length of the insert value

Definition at line 26 of file ssi.c.

27 {
28  size_t print_value;
29  switch (iIndex)
30  {
31  case 0: // volt
32  print_value = snprintf(pcInsert, iInsertLen, "%f", (adc_read() * 3.3f / (1 << 12)));
33  break;
34  case 1: // temp
35  print_value = snprintf(pcInsert, iInsertLen, "%f", (27.0f - ((adc_read() * 3.3f / (1 << 12)) - 0.706f) / 0.001721f));
36  break;
37  case 2: // gpio led
38  if (cyw43_arch_gpio_get(CYW43_WL_GPIO_LED_PIN))
39  print_value = snprintf(pcInsert, iInsertLen, "ON");
40  else
41  print_value = snprintf(pcInsert, iInsertLen, "OFF");
42  break;
43  case 3: // light state
44  if (light_state.state)
45  print_value = snprintf(pcInsert, iInsertLen, "ON");
46  else
47  print_value = snprintf(pcInsert, iInsertLen, "OFF");
48  break;
49  case 4: // light mode
50  switch (light_state.light_mode)
51  {
52  case MODE_RAINBOW_WHEEL:
53  print_value = snprintf(pcInsert, iInsertLen, "rainbow-wheel");
54  break;
55  case MODE_RAINBOW_CYCLE:
56  print_value = snprintf(pcInsert, iInsertLen, "rainbow-cycle");
57  break;
58  case MODE_STATIC:
59  print_value = snprintf(pcInsert, iInsertLen, "static");
60  break;
61  case MODE_BREATHING:
62  print_value = snprintf(pcInsert, iInsertLen, "breathing");
63  break;
64  case MODE_FLASHING:
65  print_value = snprintf(pcInsert, iInsertLen, "flashing");
66  break;
67  case MODE_LOADING:
68  print_value = snprintf(pcInsert, iInsertLen, "loading");
69  break;
70  case MODE_WAVE:
71  print_value = snprintf(pcInsert, iInsertLen, "wave");
72  break;
73  case MODE_FADE:
74  print_value = snprintf(pcInsert, iInsertLen, "fade");
75  break;
76  default:
77  print_value = 0;
78  break;
79  }
80  break;
81  case 5: // light color
82  switch (light_state.color)
83  {
84  case COLOR_RED:
85  print_value = snprintf(pcInsert, iInsertLen, "red");
86  break;
87  case COLOR_GREEN:
88  print_value = snprintf(pcInsert, iInsertLen, "green");
89  break;
90  case COLOR_BLUE:
91  print_value = snprintf(pcInsert, iInsertLen, "blue");
92  break;
93  case COLOR_WHITE:
94  print_value = snprintf(pcInsert, iInsertLen, "white");
95  break;
96  case COLOR_PURPLE:
97  print_value = snprintf(pcInsert, iInsertLen, "purple");
98  break;
99  case COLOR_YELLOW:
100  print_value = snprintf(pcInsert, iInsertLen, "yellow");
101  break;
102  case COLOR_CYAN:
103  print_value = snprintf(pcInsert, iInsertLen, "cyan");
104  break;
105  case COLOR_ORANGE:
106  print_value = snprintf(pcInsert, iInsertLen, "orange");
107  break;
108  case COLOR_PINK:
109  print_value = snprintf(pcInsert, iInsertLen, "pink");
110  break;
111  case COLOR_TURQUOISE:
112  print_value = snprintf(pcInsert, iInsertLen, "turquoise");
113  break;
114  case COLOR_MAGENTA:
115  print_value = snprintf(pcInsert, iInsertLen, "magenta");
116  break;
117  default:
118  print_value = 0;
119  break;
120  }
121  break;
122  case 6: // brightness
123  print_value = snprintf(pcInsert, iInsertLen, "%d", (int)(light_state.brightness / 255.0 * 100.0));
124  break;
125  case 7: // time tm
126  if (utc)
127  print_value = snprintf(pcInsert, iInsertLen, "%04d-%02d-%02dT%02d:%02d:%02dZ", utc->tm_year + 1900, utc->tm_mon + 1, utc->tm_mday, utc->tm_hour, utc->tm_min, utc->tm_sec);
128  else
129  print_value = snprintf(pcInsert, iInsertLen, "NULL");
130  break;
131  default:
132  print_value = 0;
133  break;
134  }
135  return (u16_t)print_value;
136 }
@ MODE_RAINBOW_CYCLE
Definition: light_state.h:20
@ MODE_FLASHING
Definition: light_state.h:23
@ MODE_LOADING
Definition: light_state.h:24
@ MODE_WAVE
Definition: light_state.h:25
@ MODE_BREATHING
Definition: light_state.h:22
@ MODE_STATIC
Definition: light_state.h:21
@ MODE_RAINBOW_WHEEL
Definition: light_state.h:19
@ MODE_FADE
Definition: light_state.h:26
@ COLOR_ORANGE
Definition: light_state.h:41
@ COLOR_BLUE
Definition: light_state.h:36
@ COLOR_PINK
Definition: light_state.h:43
@ COLOR_PURPLE
Definition: light_state.h:40
@ COLOR_TURQUOISE
Definition: light_state.h:42
@ COLOR_MAGENTA
Definition: light_state.h:39
@ COLOR_RED
Definition: light_state.h:34
@ COLOR_CYAN
Definition: light_state.h:37
@ COLOR_YELLOW
Definition: light_state.h:38
@ COLOR_GREEN
Definition: light_state.h:35
@ COLOR_WHITE
Definition: light_state.h:44
volatile struct light_state_t light_state
Light state.
Definition: light_state.c:8
volatile struct tm * utc
UTC time struct.
Definition: ntp.c:13
uint8_t brightness
Definition: light_state.h:59
enum light_modes light_mode
Definition: light_state.h:61
enum light_colors color
Definition: light_state.h:62

References light_state_t::brightness, light_state_t::color, COLOR_BLUE, COLOR_CYAN, COLOR_GREEN, COLOR_MAGENTA, COLOR_ORANGE, COLOR_PINK, COLOR_PURPLE, COLOR_RED, COLOR_TURQUOISE, COLOR_WHITE, COLOR_YELLOW, light_state_t::light_mode, light_state, MODE_BREATHING, MODE_FADE, MODE_FLASHING, MODE_LOADING, MODE_RAINBOW_CYCLE, MODE_RAINBOW_WHEEL, MODE_STATIC, MODE_WAVE, light_state_t::state, and utc.

Referenced by ssi_init().

◆ ssi_init()

void ssi_init ( )

SSI init.

Function initializes SSI handler and respective SSI tags.

Definition at line 138 of file ssi.c.

139 {
140  adc_init();
141  adc_set_temp_sensor_enabled(true);
142  adc_select_input(4);
143  http_set_ssi_handler(ssi_handler, ssi_tags, LWIP_ARRAYSIZE(ssi_tags));
144 }
static const char * ssi_tags[]
Definition: ssi.c:13
u16_t ssi_handler(int iIndex, char *pcInsert, int iInsertLen)
SSI handler.
Definition: ssi.c:26

References ssi_handler(), and ssi_tags.