UC8151: Rotation support.
This commit is contained in:
parent
6b232ddb30
commit
0e72369c7b
|
@ -327,15 +327,14 @@ namespace pimoroni {
|
|||
|
||||
update_speed = speed;
|
||||
|
||||
if(speed == 0) {
|
||||
command(PSR, {
|
||||
RES_128x296 | LUT_OTP | FORMAT_BW | SHIFT_RIGHT | BOOSTER_ON | RESET_NONE
|
||||
});
|
||||
} else {
|
||||
command(PSR, {
|
||||
RES_128x296 | LUT_REG | FORMAT_BW | SHIFT_RIGHT | BOOSTER_ON | RESET_NONE
|
||||
});
|
||||
}
|
||||
uint8_t psr_setting = RES_128x296 | FORMAT_BW | BOOSTER_ON | RESET_NONE;
|
||||
|
||||
psr_setting |= speed == 0 ? LUT_OTP : LUT_REG;
|
||||
|
||||
psr_setting |= rotation == ROTATE_180 ? SHIFT_LEFT | SCAN_UP : SHIFT_RIGHT | SCAN_DOWN;
|
||||
|
||||
command(PSR, 1, &psr_setting);
|
||||
|
||||
switch(speed) {
|
||||
case 0:
|
||||
// Note: the defult luts are built in so we don't really need to flash them here
|
||||
|
|
|
@ -142,10 +142,10 @@ namespace pimoroni {
|
|||
bool blocking = true;
|
||||
|
||||
public:
|
||||
UC8151(uint16_t width, uint16_t height) : UC8151(width, height, {PIMORONI_SPI_DEFAULT_INSTANCE, SPI_BG_FRONT_CS, SPI_DEFAULT_SCK, SPI_DEFAULT_MOSI, PIN_UNUSED, 20, PIN_UNUSED}) {};
|
||||
UC8151(uint16_t width, uint16_t height, Rotation rotate) : UC8151(width, height, rotate, {PIMORONI_SPI_DEFAULT_INSTANCE, SPI_BG_FRONT_CS, SPI_DEFAULT_SCK, SPI_DEFAULT_MOSI, PIN_UNUSED, 20, PIN_UNUSED}) {};
|
||||
|
||||
UC8151(uint16_t width, uint16_t height, SPIPins pins, uint busy=26, uint reset=21) :
|
||||
DisplayDriver(width, height, ROTATE_0),
|
||||
UC8151(uint16_t width, uint16_t height, Rotation rotate, SPIPins pins, uint busy=26, uint reset=21) :
|
||||
DisplayDriver(width, height, rotate),
|
||||
spi(pins.spi),
|
||||
CS(pins.cs), DC(pins.dc), SCK(pins.sck), MOSI(pins.mosi), BUSY(busy), RESET(reset) {
|
||||
init();
|
||||
|
|
|
@ -32,7 +32,7 @@ enum Pin {
|
|||
};
|
||||
|
||||
|
||||
UC8151 uc8151(296, 128);
|
||||
UC8151 uc8151(296, 128, ROTATE_0);
|
||||
PicoGraphics_Pen1BitY graphics(uc8151.width, uc8151.height, nullptr);
|
||||
|
||||
Button button_a(Pin::A);
|
||||
|
|
|
@ -162,10 +162,10 @@ mp_obj_t ModPicoGraphics_make_new(const mp_obj_type_t *type, size_t n_args, size
|
|||
}
|
||||
} else if (display == DISPLAY_INKY_PACK) {
|
||||
if (args[ARG_bus].u_obj == mp_const_none) {
|
||||
self->display = m_new_class(UC8151, width, height);
|
||||
self->display = m_new_class(UC8151, width, height, (Rotation)rotate);
|
||||
} else if (mp_obj_is_type(args[ARG_bus].u_obj, &SPIPins_type)) {
|
||||
_PimoroniBus_obj_t *bus = (_PimoroniBus_obj_t *)MP_OBJ_TO_PTR(args[ARG_bus].u_obj);
|
||||
self->display = m_new_class(UC8151, width, height, *(SPIPins *)(bus->pins));
|
||||
self->display = m_new_class(UC8151, width, height, (Rotation)rotate, *(SPIPins *)(bus->pins));
|
||||
} else {
|
||||
mp_raise_ValueError("SPIBus expected!");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue