This commit is contained in:
wyrdsec 2024-06-06 20:29:50 -04:00
parent 1214b699ca
commit bafe45fde9
3 changed files with 82 additions and 11 deletions

View file

@ -28,7 +28,52 @@
#include "shared-bindings/microcontroller/Pin.h"
#include "shared-module/displayio/__init__.h"
//| class AuroraMemoryFramebuffer:
//| """A framebuffer for Pervasive Displays Aurora E-paper display. These displays are 2 color only.
//|
//| This initializes a display and connects it to CircuitPython.
//|
//| For Example::
//|
//| import busio
//| import framebufferio
//| from aurora_epaper import AuroraMemoryFramebuffer
//| spi = busio.SPI(EINK_CLKS, EINK_MOSI, EINK_MISO)
//| aurora = AuroraMemoryFramebuffer(spi, EINK_CS, EINK_RST, EINK_BUSY, EINK_DISCHARGE, HEIGHT, WIDTH)
//| display = framebufferio.FramebufferDisplay(t, auto_refresh=False)
//| display.refresh()
//|
//| For more information on how these displays are driven see:
//| https://www.pervasivedisplays.com/wp-content/uploads/2023/02/4P018-00_04_G2_Aurora-Mb_COG_Driver_Interface_Timing_for_small-size_20231107.pdf
//| """
//|
//| def __init__(
//| self,
//| spi_bus: busio.SPI,
//| chip_select: microcontroller.Pin,
//| reset: microcontroller.Pin,
//| busy: microcontroller.Pin,
//| discharge: microcontroller.Pin,
//| width: int,
//| height: int,
//| power: Optional[microcontroller.Pin] = None,
//| free_bus: Optional[bool] = True,
//| ) -> None:
//| """Create a framebuffer for the Aurora CoG display.
//|
//| .. note:: Displays of size 1.9" and 2.6" are not tested, and exibit unexpected behavior.
//|
//| :param busio.SPI spi_bus: The SPI bus that the display is connected to
//| :param microcontroller.Pin chip_select: The pin connected to the displays chip select input
//| :param microcontroller.Pin reset: The pin connected to the displays reset input
//| :param microcontroller.Pin busy: The pin connected to the displays busy output
//| :param microcontroller.Pin discharge: The pin connected to the displays discharge input
//| :param int width: The width of the display in pixels
//| :param int height: The height of the display in pixels
//| :param microcontroller.Pin power: The pin that controls power to the display (optional).
//| :param bool free_bus: Determines whether the SPI bus passed in will be freed when the frame buffer is freed.
//| """
//|...
static mp_obj_t aurora_epaper_framebuffer_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) {
enum { ARG_spi_bus, ARG_chip_select, ARG_reset, ARG_busy, ARG_discharge, ARG_width, ARG_height, ARG_power, ARG_free_bus, NUM_ARGS };
static const mp_arg_t allowed_args[] = {
@ -71,7 +116,11 @@ static mp_int_t aurora_epaper_framebuffer_get_buffer(mp_obj_t self_in, mp_buffer
return 0;
}
//| def deinit(self) -> None:
//| """Free the resources (pins, timers, etc.) associated with this
//| AuroraMemoryFramebuffer instance. After deinitialization, no further operations
//| may be performed."""
//| ...
static mp_obj_t aurora_epaper_framebuffer_deinit(mp_obj_t self_in) {
aurora_epaper_framebuffer_obj_t *self = (aurora_epaper_framebuffer_obj_t *)self_in;
common_hal_aurora_epaper_framebuffer_deinit(self);
@ -80,7 +129,13 @@ static mp_obj_t aurora_epaper_framebuffer_deinit(mp_obj_t self_in) {
}
static MP_DEFINE_CONST_FUN_OBJ_1(aurora_epaper_framebuffer_deinit_obj, aurora_epaper_framebuffer_deinit);
//| def set_temperature(
//| self, celsius: int
//| ) -> None:
//| """Set the ambient temperature (in celsius) for the display driver.
//| Higher temperature means faster update speed.
//| """
//| ...
static mp_obj_t aurora_epaper_frambuffer_set_temperature(mp_obj_t self_in, mp_obj_t temperature) {
aurora_epaper_framebuffer_obj_t *self = (aurora_epaper_framebuffer_obj_t *)self_in;
@ -90,7 +145,10 @@ static mp_obj_t aurora_epaper_frambuffer_set_temperature(mp_obj_t self_in, mp_ob
}
static MP_DEFINE_CONST_FUN_OBJ_2(aurora_epaper_frambuffer_set_temperature_obj, aurora_epaper_frambuffer_set_temperature);
//| free_bus: bool
//| """When True the spi bus passed into the device will be freed on deinit.
//| If you have multiple displays this could be used to keep the other active on soft reset."""
//| ...
static mp_obj_t aurora_epaper_framebuffer_get_free_bus(mp_obj_t self_in) {
aurora_epaper_framebuffer_obj_t *self = (aurora_epaper_framebuffer_obj_t *)self_in;
return mp_obj_new_bool(self->free_bus);

View file

@ -1,3 +1,22 @@
/*
* Copyright (c) wyrdsec (MIT License)
*
* 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.
*/
#pragma once
#include "py/objtype.h"

View file

@ -75,10 +75,4 @@ void common_hal_aurora_epaper_framebuffer_power_off(aurora_epaper_framebuffer_ob
void common_hal_aurora_epaper_framebuffer_draw_frame(aurora_epaper_framebuffer_obj_t *self, uint8_t *buf, uint32_t whiteMap, uint32_t blackMap, uint8_t border, uint16_t iterations);
void common_hal_aurora_epaper_framebuffer_draw_line(aurora_epaper_framebuffer_obj_t *self, uint8_t *buf, int row, uint32_t whiteMap, uint32_t blackMap, uint8_t border);
void common_hal_aurora_epaper_framebuffer_collect_ptrs(aurora_epaper_framebuffer_obj_t *);
/* Notes
- https://learn.adafruit.com/extending-circuitpython?view=all
- https://micropython-usermod.readthedocs.io/en/latest/usermods_05.html
- https://docs.circuitpython.org/en/latest/shared-bindings/framebufferio/index.html
*/
void common_hal_aurora_epaper_framebuffer_collect_ptrs(aurora_epaper_framebuffer_obj_t *);