2020-03-10 14:12:01 -04:00
|
|
|
/*
|
|
|
|
* This file is part of the MicroPython project, http://micropython.org/
|
|
|
|
*
|
|
|
|
* The MIT License (MIT)
|
|
|
|
*
|
|
|
|
* Copyright (c) 2019 Scott Shawcroft for Adafruit Industries
|
2020-04-17 09:16:56 -04:00
|
|
|
* Copyright (c) 2020 Jeff Epler for Adafruit Industries
|
2020-03-10 14:12:01 -04:00
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
|
|
* in the Software without restriction, including without limitation the rights
|
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
* THE SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef MICROPY_INCLUDED_SHARED_MODULE_DISPLAYIO_FRAMEBUFFERDISPLAY_H
|
|
|
|
#define MICROPY_INCLUDED_SHARED_MODULE_DISPLAYIO_FRAMEBUFFERDISPLAY_H
|
|
|
|
|
|
|
|
#include "py/obj.h"
|
|
|
|
#include "py/proto.h"
|
|
|
|
|
|
|
|
#include "shared-bindings/digitalio/DigitalInOut.h"
|
|
|
|
#include "shared-bindings/displayio/Group.h"
|
|
|
|
|
|
|
|
#include "shared-module/displayio/area.h"
|
|
|
|
#include "shared-module/displayio/display_core.h"
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
mp_obj_base_t base;
|
|
|
|
displayio_display_core_t core;
|
|
|
|
mp_obj_t framebuffer;
|
|
|
|
const struct _framebuffer_p_t *framebuffer_protocol;
|
|
|
|
mp_buffer_info_t bufinfo;
|
|
|
|
uint64_t last_refresh_call;
|
|
|
|
uint16_t native_frames_per_second;
|
|
|
|
uint16_t native_ms_per_frame;
|
2020-08-12 13:50:08 -04:00
|
|
|
uint16_t first_pixel_offset;
|
|
|
|
uint16_t row_stride;
|
2020-03-10 14:12:01 -04:00
|
|
|
bool auto_refresh;
|
|
|
|
bool first_manual_refresh;
|
|
|
|
} framebufferio_framebufferdisplay_obj_t;
|
|
|
|
|
2021-03-15 09:57:36 -04:00
|
|
|
void framebufferio_framebufferdisplay_background(framebufferio_framebufferdisplay_obj_t *self);
|
|
|
|
void release_framebufferdisplay(framebufferio_framebufferdisplay_obj_t *self);
|
|
|
|
void framebufferio_framebufferdisplay_reset(framebufferio_framebufferdisplay_obj_t *self);
|
2020-03-10 14:12:01 -04:00
|
|
|
|
2021-03-15 09:57:36 -04:00
|
|
|
void framebufferio_framebufferdisplay_collect_ptrs(framebufferio_framebufferdisplay_obj_t *self);
|
2020-03-10 14:12:01 -04:00
|
|
|
|
2021-03-15 09:57:36 -04:00
|
|
|
mp_obj_t common_hal_framebufferio_framebufferdisplay_get_framebuffer(framebufferio_framebufferdisplay_obj_t *self);
|
2020-03-10 14:12:01 -04:00
|
|
|
|
2020-08-06 15:46:54 -04:00
|
|
|
typedef bool (*framebuffer_get_reverse_pixels_in_byte_fun)(mp_obj_t);
|
|
|
|
typedef bool (*framebuffer_get_reverse_pixels_in_word_fun)(mp_obj_t);
|
|
|
|
typedef bool (*framebuffer_set_brightness_fun)(mp_obj_t, mp_float_t);
|
2020-04-15 13:29:32 -04:00
|
|
|
typedef int (*framebuffer_get_bytes_per_cell_fun)(mp_obj_t);
|
2020-08-06 15:46:54 -04:00
|
|
|
typedef int (*framebuffer_get_color_depth_fun)(mp_obj_t);
|
|
|
|
typedef int (*framebuffer_get_first_pixel_offset_fun)(mp_obj_t);
|
|
|
|
typedef int (*framebuffer_get_grayscale_fun)(mp_obj_t);
|
|
|
|
typedef int (*framebuffer_get_height_fun)(mp_obj_t);
|
2020-04-15 13:29:32 -04:00
|
|
|
typedef int (*framebuffer_get_native_frames_per_second_fun)(mp_obj_t);
|
2020-08-06 17:03:31 -04:00
|
|
|
typedef bool (*framebuffer_get_pixels_in_byte_share_row_fun)(mp_obj_t);
|
2020-08-06 15:46:54 -04:00
|
|
|
typedef int (*framebuffer_get_row_stride_fun)(mp_obj_t);
|
|
|
|
typedef int (*framebuffer_get_width_fun)(mp_obj_t);
|
|
|
|
typedef mp_float_t (*framebuffer_get_brightness_fun)(mp_obj_t);
|
|
|
|
typedef void (*framebuffer_deinit_fun)(mp_obj_t);
|
|
|
|
typedef void (*framebuffer_get_bufinfo_fun)(mp_obj_t, mp_buffer_info_t *bufinfo);
|
2020-08-06 15:51:52 -04:00
|
|
|
typedef void (*framebuffer_swapbuffers_fun)(mp_obj_t, uint8_t *dirty_row_bitmask);
|
2020-03-10 14:12:01 -04:00
|
|
|
|
|
|
|
typedef struct _framebuffer_p_t {
|
|
|
|
MP_PROTOCOL_HEAD // MP_QSTR_protocol_framebuffer
|
2020-08-06 15:46:54 -04:00
|
|
|
|
|
|
|
// Mandatory
|
2020-03-10 14:12:01 -04:00
|
|
|
framebuffer_get_bufinfo_fun get_bufinfo;
|
|
|
|
framebuffer_swapbuffers_fun swapbuffers;
|
|
|
|
framebuffer_deinit_fun deinit;
|
2020-04-15 13:29:32 -04:00
|
|
|
framebuffer_get_width_fun get_width;
|
|
|
|
framebuffer_get_height_fun get_height;
|
2020-08-06 15:46:54 -04:00
|
|
|
|
|
|
|
// Optional getters
|
|
|
|
framebuffer_get_bytes_per_cell_fun get_bytes_per_cell; // default: 2
|
|
|
|
framebuffer_get_color_depth_fun get_color_depth; // default: 16
|
|
|
|
framebuffer_get_first_pixel_offset_fun get_first_pixel_offset; // default: 0
|
|
|
|
framebuffer_get_grayscale_fun get_grayscale; // default: grayscale if depth < 8
|
|
|
|
framebuffer_get_native_frames_per_second_fun get_native_frames_per_second; // default: 60
|
|
|
|
framebuffer_get_pixels_in_byte_share_row_fun get_pixels_in_byte_share_row; // default: false
|
|
|
|
framebuffer_get_reverse_pixels_in_byte_fun get_reverse_pixels_in_byte; // default: false
|
|
|
|
framebuffer_get_reverse_pixels_in_word_fun get_reverse_pixels_in_word; // default: false
|
|
|
|
framebuffer_get_row_stride_fun get_row_stride; // default: 0 (no extra row padding)
|
|
|
|
|
|
|
|
// Optional -- default is no brightness control
|
2020-04-10 10:07:06 -04:00
|
|
|
framebuffer_get_brightness_fun get_brightness;
|
2020-03-10 14:12:01 -04:00
|
|
|
framebuffer_set_brightness_fun set_brightness;
|
2020-08-06 15:46:54 -04:00
|
|
|
|
2020-03-10 14:12:01 -04:00
|
|
|
} framebuffer_p_t;
|
|
|
|
|
|
|
|
#endif // MICROPY_INCLUDED_SHARED_MODULE_DISPLAYIO_FRAMEBUFFERDISPLAY_H
|