Lightweight C library for HTML5 websockets
lws-led.h File Reference
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  lws_led_sequence_def_t
struct  lws_led_state_ch
struct  lws_led_state_chs
struct  lws_led_ops
struct  lws_led_gpio_map
struct  lws_led_gpio_controller


#define LWS_LED_MAX_INTENSITY   (0xffff)
#define LWS_LED_FUNC_PHASE   65536
#define lws_led_gpio_ops


typedef uint16_t lws_led_intensity_t
typedef uint16_t lws_led_seq_phase_t
typedef lws_led_intensity_t(* lws_led_lookup_t) (lws_led_seq_phase_t ph)
typedef struct lws_led_sequence_def_t lws_led_sequence_def_t
typedef struct lws_led_state_ch lws_led_state_ch_t
typedef struct lws_led_state_chs lws_led_state_chs_t
typedef struct lws_led_ops lws_led_ops_t
typedef struct lws_led_gpio_map lws_led_gpio_map_t
typedef struct lws_led_gpio_controller lws_led_gpio_controller_t




LWS_VISIBLE LWS_EXTERN struct lws_led_state * lws_led_gpio_create (const lws_led_ops_t *led_ops)
LWS_VISIBLE LWS_EXTERN void lws_led_gpio_destroy (struct lws_led_state *lcs)
LWS_VISIBLE LWS_EXTERN void lws_led_gpio_intensity (const struct lws_led_ops *lo, const char *name, lws_led_intensity_t inten)
LWS_VISIBLE LWS_EXTERN int lws_led_transition (struct lws_led_state *lcs, const char *name, const lws_led_sequence_def_t *next, const lws_led_sequence_def_t *trans)

Data Structure Documentation

◆ lws_led_sequence_def_t

struct lws_led_sequence_def_t

Definition at line 47 of file lws-led.h.

+ Collaboration diagram for lws_led_sequence_def_t:
Data Fields
lws_led_lookup_t func
lws_led_seq_phase_t ledphase_offset
int ledphase_total
uint16_t ms
uint8_t flags

◆ lws_led_state_ch

struct lws_led_state_ch

Definition at line 61 of file lws-led.h.

+ Collaboration diagram for lws_led_state_ch:
Data Fields
const lws_led_sequence_def_t * seq
lws_led_seq_phase_t ph
lws_led_seq_phase_t step
int phase_budget
lws_led_intensity_t last

at the end of the sequence we decouple the sequencer, but leave the last computed sample behind for further transitions to base off

◆ lws_led_state_chs

struct lws_led_state_chs

Definition at line 73 of file lws-led.h.

+ Collaboration diagram for lws_led_state_chs:
Data Fields
lws_led_state_ch_t seqs[3]

◆ lws_led_gpio_map

struct lws_led_gpio_map

Definition at line 88 of file lws-led.h.

+ Collaboration diagram for lws_led_gpio_map:
Data Fields
const char * name
_lws_plat_gpio_t gpio
lws_led_lookup_t intensity_correction

May be NULL. If GPIO-based LED, ignored. If pwm_ops provided, NULL means use default CIE 100% correction function. If non-NULL, use the pointed-to correction function. This is useful to provide LED-specific intensity correction / scaling so different types of LED can "look the same".

const struct lws_pwm_ops * pwm_ops

if NULL, gpio controls the led directly. If set to a pwm_ops, the led control is outsourced to the pwm controller.

uint8_t active_level

◆ lws_led_gpio_controller

struct lws_led_gpio_controller

Definition at line 103 of file lws-led.h.

+ Collaboration diagram for lws_led_gpio_controller:
Data Fields
const lws_led_ops_t led_ops
const lws_gpio_ops_t * gpio_ops
const lws_led_gpio_map_t * led_map
uint8_t count_leds

Macro Definition Documentation


#define LWS_LED_MAX_INTENSITY   (0xffff)

Definition at line 33 of file lws-led.h.


#define LWS_LED_FUNC_PHASE   65536

Definition at line 36 of file lws-led.h.



Definition at line 38 of file lws-led.h.



Definition at line 40 of file lws-led.h.

◆ lws_led_gpio_ops

#define lws_led_gpio_ops
{ \
.create = lws_led_gpio_create, \
.destroy = lws_led_gpio_destroy, \
.intensity = lws_led_gpio_intensity, \
LWS_VISIBLE LWS_EXTERN struct lws_led_state * lws_led_gpio_create(const lws_led_ops_t *led_ops)
LWS_VISIBLE LWS_EXTERN void lws_led_gpio_destroy(struct lws_led_state *lcs)
LWS_VISIBLE LWS_EXTERN void lws_led_gpio_intensity(const struct lws_led_ops *lo, const char *name, lws_led_intensity_t inten)

Definition at line 140 of file lws-led.h.

Typedef Documentation

◆ lws_led_intensity_t

Definition at line 29 of file lws-led.h.

◆ lws_led_seq_phase_t

Definition at line 30 of file lws-led.h.

◆ lws_led_lookup_t

typedef lws_led_intensity_t(* lws_led_lookup_t) (lws_led_seq_phase_t ph)

Definition at line 45 of file lws-led.h.

◆ lws_led_sequence_def_t

◆ lws_led_state_ch_t

◆ lws_led_state_chs_t

◆ lws_led_ops_t

typedef struct lws_led_ops lws_led_ops_t

◆ lws_led_gpio_map_t

◆ lws_led_gpio_controller_t

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

Definition at line 55 of file lws-led.h.

55  {
59 };
Definition: lws-led.h:56
Definition: lws-led.h:57
Definition: lws-led.h:58

Function Documentation

◆ lws_led_gpio_create()

LWS_VISIBLE LWS_EXTERN struct lws_led_state* lws_led_gpio_create ( const lws_led_ops_t led_ops)

◆ lws_led_gpio_destroy()

LWS_VISIBLE LWS_EXTERN void lws_led_gpio_destroy ( struct lws_led_state *  lcs)

◆ lws_led_gpio_intensity()

LWS_VISIBLE LWS_EXTERN void lws_led_gpio_intensity ( const struct lws_led_ops lo,
const char *  name,
lws_led_intensity_t  inten 

lws_led_gpio_intensity() - set the static intensity of an led

lothe base class of the led controller
indexwhich led in the controller set
inten16-bit unsigned intensity

For LEDs controlled by a BOOL like GPIO, only inten b15 is significant. For PWM type LED control, as many bits as the hardware can support from b15 down are significant.

◆ lws_led_transition()

LWS_VISIBLE LWS_EXTERN int lws_led_transition ( struct lws_led_state *  lcs,
const char *  name,
const lws_led_sequence_def_t next,
const lws_led_sequence_def_t trans