libwebsockets
Lightweight C library for HTML5 websockets
Loading...
Searching...
No Matches
lws-display.h
Go to the documentation of this file.
1/*
2 * lws abstract display
3 *
4 * Copyright (C) 2019 - 2022 Andy Green <andy@warmcat.com>
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to
8 * deal in the Software without restriction, including without limitation the
9 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 * sell copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
22 * IN THE SOFTWARE.
23 */
24
25#if !defined(__LWS_DISPLAY_H__)
26#define __LWS_DISPLAY_H__
27
33
40
42struct lws_display;
43
50
51typedef struct lws_surface_info {
57 uint8_t greyscale:1; /* line: 0 = RGBA, 1 = YA */
58 uint8_t partial:1; /* can handle partial */
59 uint8_t render_to_rgba:1; /* render to 32-bit RGBA, not 24-bit RGB */
61
65
66typedef struct lws_colour_error {
67 int16_t rgb[3];
69
70typedef union {
71 lws_greyscale_error_t grey; /* when ic->greyscale set */
72 lws_colour_error_t colour; /* when ic->greyscale == 0 */
74
77 const lws_display_colour_t *c);
78
81 const lws_display_colour_t *palette, size_t pdepth,
83
86 const lws_display_colour_t *palette, size_t pdepth,
88
89/*
90 * This is embedded in the actual display implementation object at the top,
91 * so a pointer to this can be cast to a pointer to the implementation object
92 * by any code that is specific to how it was implemented.
93 *
94 * Notice for the backlight / display intensity we contain pwm_ops... these can
95 * be some other pwm_ops like existing gpio pwm ops, or handled in a customized
96 * way like set oled contrast. Either way, the pwm level is arrived at via a
97 * full set of lws_led_sequences capable of generic lws transitions
98 */
99
126
127/*
128 * This contains dynamic data related to display state
129 */
130
133 LWSDISPS_AUTODIMMED, /* is in pre- blanking static dim mode */
134 LWSDISPS_BECOMING_ACTIVE, /* waiting for wake latency before active */
135 LWSDISPS_ACTIVE, /* is active */
136 LWSDISPS_GOING_OFF /* dimming then off */
137};
138
139typedef struct lws_display_state {
140
142
143 char current_url[96];
144
146 struct lws_context *ctx;
147
148 void *priv; /* subclass driver alloc'd priv */
149
152
153 struct lws_led_state *bl_lcs;
154
156 /* set of sequencer transition channels */
157
159
161
163
164/* Used for async display driver events, eg, EPD refresh completion */
166
186lws_display_state_init(lws_display_state_t *lds, struct lws_context *ctx,
187 int autodim_ms, int off_ms, struct lws_led_state *bl_lcs,
188 const lws_display_t *disp);
189
200 const lws_led_sequence_def_t *pwmseq);
201
202/*
203 * lws_display_state_active() - inform the system the display is active
204 *
205 * \param lds: the display state we are marking as active
206 *
207 * Resets the auto-dim and auto-off timers and makes sure the display is on and
208 * at the active brightness level
209 */
212
213/*
214 * lws_display_state_off() - turns off the related display
215 *
216 * \param lds: the display state we are turning off
217 *
218 * Turns the display to least power mode or completely off if possible.
219 * Disables the timers related to dimming and blanking.
220 */
223
224#endif
struct lws_dll2_owner lws_dll2_owner_t
unsigned short uint16_t
unsigned int uint32_t
#define LWS_EXTERN
unsigned char uint8_t
struct lws_fixed3232 lws_fx_t
#define LWS_VISIBLE
lws_fx_t w
Definition lws-display.h:37
LWS_VISIBLE LWS_EXTERN lws_display_palette_idx_t lws_display_palettize_col(const lws_surface_info_t *ic, const lws_display_colour_t *palette, size_t pdepth, lws_display_colour_t c, lws_colour_error_t *ectx)
struct lws_colour_error lws_colour_error_t
LWS_VISIBLE LWS_EXTERN void lws_surface_set_px(const lws_surface_info_t *ic, uint8_t *line, int x, const lws_display_colour_t *c)
const lws_display_colour_t * palette
Definition lws-display.h:54
enum lws_display_controller_state state
LWS_VISIBLE LWS_EXTERN void lws_display_state_off(lws_display_state_t *lds)
int(* lws_display_completion_t)(lws_display_state_t *lds, int a)
const lws_display_t * disp
int(* contrast)(struct lws_display_state *lds, uint8_t contrast)
lws_led_state_chs_t chs
lws_fx_t h
Definition lws-display.h:38
uint16_t latency_wake_ms
LWS_VISIBLE LWS_EXTERN void lws_display_state_active(lws_display_state_t *lds)
lws_surface_type_t type
Definition lws-display.h:56
LWS_VISIBLE LWS_EXTERN lws_display_palette_idx_t lws_display_palettize_grey(const lws_surface_info_t *ic, const lws_display_colour_t *palette, size_t pdepth, lws_display_colour_t c, lws_greyscale_error_t *ectx)
uint16_t lws_display_palette_idx_t
Definition lws-display.h:32
struct lws_display_state lws_display_state_t
const lws_led_sequence_def_t * bl_active
lws_surface_info_t ic
struct lws_context * ctx
uint16_t lws_display_rotation_t
Definition lws-display.h:30
const char * name
int(* blit)(struct lws_display_state *lds, const uint8_t *src, lws_box_t *box, lws_dll2_owner_t *ids)
const lws_pwm_ops_t * bl_pwm_ops
lws_colour_error_t colour
Definition lws-display.h:72
uint32_t lws_display_colour_t
Definition lws-display.h:31
struct lws_surface_info lws_surface_info_t
lws_fx_t x
Definition lws-display.h:35
int16_t lws_display_list_coord_t
Definition lws-display.h:28
struct lws_greyscale_error lws_greyscale_error_t
void * variant
const lws_led_sequence_def_t * bl_dim
const lws_led_sequence_def_t * bl_transition
lws_fx_t wh_mm[2]
Definition lws-display.h:53
uint8_t render_to_rgba
Definition lws-display.h:59
lws_display_controller_state
@ LWSDISPS_AUTODIMMED
@ LWSDISPS_ACTIVE
@ LWSDISPS_OFF
@ LWSDISPS_BECOMING_ACTIVE
@ LWSDISPS_GOING_OFF
LWS_VISIBLE LWS_EXTERN void lws_display_state_set_brightness(lws_display_state_t *lds, const lws_led_sequence_def_t *pwmseq)
uint16_t latency_update_ms
lws_sorted_usec_list_t sul_autodim
struct lws_display lws_display_t
lws_fx_t y
Definition lws-display.h:36
uint16_t lws_display_scalar
Definition lws-display.h:29
lws_greyscale_error_t grey
Definition lws-display.h:71
int16_t rgb[3]
Definition lws-display.h:67
struct lws_box lws_box_t
lws_fx_t wh_px[2]
Definition lws-display.h:52
int(* init)(struct lws_display_state *lds)
LWS_VISIBLE LWS_EXTERN void lws_display_state_init(lws_display_state_t *lds, struct lws_context *ctx, int autodim_ms, int off_ms, struct lws_led_state *bl_lcs, const lws_display_t *disp)
struct lws_led_state * bl_lcs
lws_surface_type_t
Definition lws-display.h:44
@ LWSSURF_QUANTIZED_4BPP
Definition lws-display.h:48
@ LWSSURF_565
Definition lws-display.h:46
@ LWSSURF_TRUECOLOR32
Definition lws-display.h:45
@ LWSSURF_PALETTE
Definition lws-display.h:47
int(* power)(struct lws_display_state *lds, int state)
struct lws_led_state_chs lws_led_state_chs_t
struct lws_pwm_ops lws_pwm_ops_t
struct lws_sorted_usec_list lws_sorted_usec_list_t