| 1 |
|
| 2 |
#ifndef __MICROPY_INCLUDED_MICROBIT_DISPLAY_H__ |
| 3 |
#define __MICROPY_INCLUDED_MICROBIT_DISPLAY_H__ |
| 4 |
|
| 5 |
#include "py/runtime.h" |
| 6 |
#include "microbitimage.h" |
| 7 |
|
| 8 |
typedef struct _microbit_display_obj_t { |
| 9 |
mp_obj_base_t base; |
| 10 |
uint8_t image_buffer[5][5]; |
| 11 |
uint8_t previous_brightness; |
| 12 |
bool active; |
| 13 |
/* Current row for strobing */ |
| 14 |
uint8_t strobe_row; |
| 15 |
/* boolean histogram of brightness in buffer */ |
| 16 |
uint16_t brightnesses; |
| 17 |
uint16_t pins_for_brightness[MAX_BRIGHTNESS+1]; |
| 18 |
} microbit_display_obj_t; |
| 19 |
|
| 20 |
#define ASYNC_MODE_STOPPED 0 |
| 21 |
#define ASYNC_MODE_ANIMATION 1 |
| 22 |
#define ASYNC_MODE_CLEAR 2 |
| 23 |
|
| 24 |
extern microbit_display_obj_t microbit_display_obj; |
| 25 |
extern const mp_obj_type_t microbit_image_type; |
| 26 |
|
| 27 |
void microbit_display_show(microbit_display_obj_t *display, microbit_image_obj_t *image); |
| 28 |
|
| 29 |
void microbit_display_animate(microbit_display_obj_t *display, mp_obj_t iterable, mp_int_t delay, bool clear, bool wait); |
| 30 |
|
| 31 |
void microbit_display_scroll(microbit_display_obj_t *display, const char* str, bool wait); |
| 32 |
|
| 33 |
mp_int_t microbit_display_get_pixel(microbit_display_obj_t *display, mp_int_t x, mp_int_t y); |
| 34 |
|
| 35 |
void microbit_display_set_pixel(microbit_display_obj_t *display, mp_int_t x, mp_int_t y, mp_int_t val); |
| 36 |
|
| 37 |
void microbit_display_clear(void); |
| 38 |
|
| 39 |
void microbit_display_init(void); |
| 40 |
|
| 41 |
void microbit_display_tick(void); |
| 42 |
|
| 43 |
bool microbit_display_active_animation(void); |
| 44 |
|
| 45 |
#endif // __MICROPY_INCLUDED_MICROBIT_DISPLAY_H__ |