Lines Matching refs:disp
80 static int update_content(struct mb_display *disp, const struct mb_image *img) in update_content() argument
91 if (disp->msb) { in update_content()
96 ret = display_write(disp->lm_dev, 0, 0, &buf_desc, &tmp_img); in update_content()
98 ret = display_write(disp->lm_dev, 0, 0, &buf_desc, img); in update_content()
106 LOG_DBG("Image duration %d", disp->duration); in update_content()
107 if (disp->duration != SYS_FOREVER_MS) { in update_content()
108 k_work_reschedule(&disp->dwork, K_MSEC(disp->duration)); in update_content()
114 static int start_image(struct mb_display *disp, const struct mb_image *img) in start_image() argument
118 ret = display_blanking_off(disp->lm_dev); in start_image()
124 return update_content(disp, img); in start_image()
127 static int reset_display(struct mb_display *disp) in reset_display() argument
131 disp->str = NULL; in reset_display()
132 disp->cur_img = 0U; in reset_display()
133 disp->img = NULL; in reset_display()
134 disp->img_count = 0U; in reset_display()
135 disp->scroll = SCROLL_OFF; in reset_display()
137 ret = display_blanking_on(disp->lm_dev); in reset_display()
145 static const struct mb_image *current_img(struct mb_display *disp) in current_img() argument
147 if (disp->scroll && disp->first) { in current_img()
151 if (disp->text) { in current_img()
152 return get_font(disp->str[disp->cur_img]); in current_img()
154 return &disp->img[disp->cur_img]; in current_img()
158 static const struct mb_image *next_img(struct mb_display *disp) in next_img() argument
160 if (disp->text) { in next_img()
161 if (disp->first) { in next_img()
162 return get_font(disp->str[0]); in next_img()
163 } else if (disp->str[disp->cur_img]) { in next_img()
164 return get_font(disp->str[disp->cur_img + 1]); in next_img()
169 if (disp->first) { in next_img()
170 return &disp->img[0]; in next_img()
171 } else if (disp->cur_img < (disp->img_count - 1)) { in next_img()
172 return &disp->img[disp->cur_img + 1]; in next_img()
179 static inline bool last_frame(struct mb_display *disp) in last_frame() argument
181 if (disp->text) { in last_frame()
182 return (disp->str[disp->cur_img] == '\0'); in last_frame()
184 return (disp->cur_img >= disp->img_count); in last_frame()
188 static inline uint8_t scroll_steps(struct mb_display *disp) in scroll_steps() argument
190 return MB_DISP_XRES + disp->img_sep; in scroll_steps()
193 static int update_scroll(struct mb_display *disp) in update_scroll() argument
195 if (disp->scroll < scroll_steps(disp)) { in update_scroll()
199 const struct mb_image *i1 = current_img(disp); in update_scroll()
200 const struct mb_image *i2 = next_img(disp); in update_scroll()
202 img.row[i] = ((i1->row[i] >> disp->scroll) | in update_scroll()
203 (i2->row[i] << (scroll_steps(disp) - in update_scroll()
204 disp->scroll))); in update_scroll()
207 disp->scroll++; in update_scroll()
208 return update_content(disp, &img); in update_scroll()
210 if (disp->first) { in update_scroll()
211 disp->first = 0U; in update_scroll()
213 disp->cur_img++; in update_scroll()
216 if (last_frame(disp)) { in update_scroll()
217 if (!disp->loop) { in update_scroll()
218 return reset_display(disp); in update_scroll()
221 disp->cur_img = 0U; in update_scroll()
222 disp->first = 1U; in update_scroll()
225 disp->scroll = SCROLL_START; in update_scroll()
226 return update_content(disp, current_img(disp)); in update_scroll()
230 static int update_image(struct mb_display *disp) in update_image() argument
232 disp->cur_img++; in update_image()
234 if (last_frame(disp)) { in update_image()
235 if (!disp->loop) { in update_image()
236 return reset_display(disp); in update_image()
239 disp->cur_img = 0U; in update_image()
242 return update_content(disp, current_img(disp)); in update_image()
248 struct mb_display *disp = CONTAINER_OF(dwork, struct mb_display, dwork); in update_display_work() local
251 if (disp->scroll) { in update_display_work()
252 ret = update_scroll(disp); in update_display_work()
254 ret = update_image(disp); in update_display_work()
260 static int start_scroll(struct mb_display *disp, int32_t duration) in start_scroll() argument
264 disp->duration = duration / scroll_steps(disp); in start_scroll()
266 disp->duration = SCROLL_DEFAULT_DURATION_MS; in start_scroll()
269 disp->scroll = SCROLL_START; in start_scroll()
270 disp->first = 1U; in start_scroll()
271 disp->cur_img = 0U; in start_scroll()
272 return start_image(disp, get_font(' ')); in start_scroll()
275 static int start_single(struct mb_display *disp, int32_t duration) in start_single() argument
277 disp->duration = duration; in start_single()
279 if (disp->text) { in start_single()
280 return start_image(disp, get_font(disp->str[0])); in start_single()
282 return start_image(disp, disp->img); in start_single()
286 void mb_display_stop(struct mb_display *disp) in mb_display_stop() argument
291 k_work_cancel_delayable_sync(&disp->dwork, &sync); in mb_display_stop()
292 LOG_DBG("delayable work stopped %p", disp); in mb_display_stop()
293 ret = reset_display(disp); in mb_display_stop()
297 void mb_display_image(struct mb_display *disp, uint32_t mode, int32_t duration, in mb_display_image() argument
302 mb_display_stop(disp); in mb_display_image()
306 disp->text = 0U; in mb_display_image()
307 disp->img_count = img_count; in mb_display_image()
308 disp->img = img; in mb_display_image()
309 disp->img_sep = 0U; in mb_display_image()
310 disp->cur_img = 0U; in mb_display_image()
311 disp->loop = !!(mode & MB_DISPLAY_FLAG_LOOP); in mb_display_image()
316 ret = start_single(disp, duration); in mb_display_image()
320 ret = start_scroll(disp, duration); in mb_display_image()
328 void mb_display_print(struct mb_display *disp, uint32_t mode, in mb_display_print() argument
334 mb_display_stop(disp); in mb_display_print()
337 vsnprintk(disp->str_buf, sizeof(disp->str_buf), fmt, ap); in mb_display_print()
340 if (disp->str_buf[0] == '\0') { in mb_display_print()
344 disp->str = disp->str_buf; in mb_display_print()
345 disp->text = 1U; in mb_display_print()
346 disp->img_sep = 1U; in mb_display_print()
347 disp->cur_img = 0U; in mb_display_print()
348 disp->loop = !!(mode & MB_DISPLAY_FLAG_LOOP); in mb_display_print()
353 ret = start_scroll(disp, duration); in mb_display_print()
357 ret = start_single(disp, duration); in mb_display_print()
365 static int mb_display_init(struct mb_display *disp) in mb_display_init() argument
370 display_get_capabilities(disp->lm_dev, &caps); in mb_display_init()
378 disp->msb = 1U; in mb_display_init()
381 ret = display_set_brightness(disp->lm_dev, 0xFF); in mb_display_init()
387 k_work_init_delayable(&disp->dwork, update_display_work); in mb_display_init()