mirror of
https://github.com/openmv/openmv.git
synced 2025-09-26 23:09:13 +08:00
Merge pull request #2758 from kwagyeman/kwabena/lcd_shield
Some checks are pending
🔥 Firmware Build / build-firmware (ARDUINO_GIGA) (push) Waiting to run
🔥 Firmware Build / build-firmware (ARDUINO_NANO_33_BLE_SENSE) (push) Waiting to run
🔥 Firmware Build / build-firmware (ARDUINO_NANO_RP2040_CONNECT) (push) Waiting to run
🔥 Firmware Build / build-firmware (ARDUINO_NICLA_VISION) (push) Waiting to run
🔥 Firmware Build / build-firmware (ARDUINO_PORTENTA_H7) (push) Waiting to run
🔥 Firmware Build / build-firmware (DOCKER) (push) Waiting to run
🔥 Firmware Build / build-firmware (OPENMV2) (push) Waiting to run
🔥 Firmware Build / build-firmware (OPENMV3) (push) Waiting to run
🔥 Firmware Build / build-firmware (OPENMV4) (push) Waiting to run
🔥 Firmware Build / build-firmware (OPENMV4P) (push) Waiting to run
🔥 Firmware Build / build-firmware (OPENMVPT) (push) Waiting to run
🔥 Firmware Build / build-firmware (OPENMV_AE3) (push) Waiting to run
🔥 Firmware Build / build-firmware (OPENMV_N6) (push) Waiting to run
🔥 Firmware Build / build-firmware (OPENMV_RT1060) (push) Waiting to run
🔥 Firmware Build / code-size-report (push) Blocked by required conditions
🔥 Firmware Build / stable-release (push) Blocked by required conditions
🔥 Firmware Build / development-release (push) Blocked by required conditions
Some checks are pending
🔥 Firmware Build / build-firmware (ARDUINO_GIGA) (push) Waiting to run
🔥 Firmware Build / build-firmware (ARDUINO_NANO_33_BLE_SENSE) (push) Waiting to run
🔥 Firmware Build / build-firmware (ARDUINO_NANO_RP2040_CONNECT) (push) Waiting to run
🔥 Firmware Build / build-firmware (ARDUINO_NICLA_VISION) (push) Waiting to run
🔥 Firmware Build / build-firmware (ARDUINO_PORTENTA_H7) (push) Waiting to run
🔥 Firmware Build / build-firmware (DOCKER) (push) Waiting to run
🔥 Firmware Build / build-firmware (OPENMV2) (push) Waiting to run
🔥 Firmware Build / build-firmware (OPENMV3) (push) Waiting to run
🔥 Firmware Build / build-firmware (OPENMV4) (push) Waiting to run
🔥 Firmware Build / build-firmware (OPENMV4P) (push) Waiting to run
🔥 Firmware Build / build-firmware (OPENMVPT) (push) Waiting to run
🔥 Firmware Build / build-firmware (OPENMV_AE3) (push) Waiting to run
🔥 Firmware Build / build-firmware (OPENMV_N6) (push) Waiting to run
🔥 Firmware Build / build-firmware (OPENMV_RT1060) (push) Waiting to run
🔥 Firmware Build / code-size-report (push) Blocked by required conditions
🔥 Firmware Build / stable-release (push) Blocked by required conditions
🔥 Firmware Build / development-release (push) Blocked by required conditions
modules/py_spi_display: Add vflip/hmirror support.
This commit is contained in:
commit
c6d5ff90ac
@ -360,8 +360,8 @@ static void spi_display_deinit(py_display_obj_t *self) {
|
||||
|
||||
mp_obj_t spi_display_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) {
|
||||
enum {
|
||||
ARG_width, ARG_height, ARG_refresh, ARG_bgr, ARG_byte_swap, ARG_triple_buffer,
|
||||
ARG_controller, ARG_backlight
|
||||
ARG_width, ARG_height, ARG_refresh, ARG_bgr, ARG_byte_swap, ARG_hmirror, ARG_vflip,
|
||||
ARG_triple_buffer, ARG_controller, ARG_backlight
|
||||
};
|
||||
static const mp_arg_t allowed_args[] = {
|
||||
{ MP_QSTR_width, MP_ARG_INT, {.u_int = 128 } },
|
||||
@ -369,6 +369,8 @@ mp_obj_t spi_display_make_new(const mp_obj_type_t *type, size_t n_args, size_t n
|
||||
{ MP_QSTR_refresh, MP_ARG_INT, {.u_int = 60 } },
|
||||
{ MP_QSTR_bgr, MP_ARG_BOOL, {.u_bool = false} },
|
||||
{ MP_QSTR_byte_swap, MP_ARG_BOOL, {.u_bool = false} },
|
||||
{ MP_QSTR_hmirror, MP_ARG_BOOL, {.u_bool = true} },
|
||||
{ MP_QSTR_vflip, MP_ARG_BOOL, {.u_bool = true} },
|
||||
{ MP_QSTR_triple_buffer, MP_ARG_BOOL, {.u_bool = LCD_TRIPLE_BUFFER_DEFAULT} },
|
||||
{ MP_QSTR_controller, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_rom_obj = MP_ROM_NONE} },
|
||||
{ MP_QSTR_backlight, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_rom_obj = MP_ROM_NONE} },
|
||||
@ -435,7 +437,17 @@ mp_obj_t spi_display_make_new(const mp_obj_type_t *type, size_t n_args, size_t n
|
||||
spi_display_command(self, LCD_COMMAND_SLPOUT, 0);
|
||||
mp_hal_delay_ms(120);
|
||||
// Memory data access control
|
||||
spi_display_command(self, LCD_COMMAND_MADCTL, self->bgr ? 0xC8 : 0xC0);
|
||||
uint8_t madctl = 0;
|
||||
if (args[ARG_hmirror].u_bool) {
|
||||
madctl |= 0x40;
|
||||
}
|
||||
if (args[ARG_vflip].u_bool) {
|
||||
madctl |= 0x80;
|
||||
}
|
||||
if (self->bgr) {
|
||||
madctl |= 0x08;
|
||||
}
|
||||
spi_display_command(self, LCD_COMMAND_MADCTL, madctl);
|
||||
// Interface pixel format
|
||||
spi_display_command(self, LCD_COMMAND_COLMOD, 0x05);
|
||||
}
|
||||
|
@ -1,26 +0,0 @@
|
||||
# This work is licensed under the MIT license.
|
||||
# Copyright (c) 2013-2023 OpenMV LLC. All rights reserved.
|
||||
# https://github.com/openmv/openmv/blob/master/LICENSE
|
||||
#
|
||||
# LCD Example
|
||||
#
|
||||
# Note: To run this example you will need a LCD Shield for your OpenMV Cam.
|
||||
#
|
||||
# The LCD Shield allows you to view your OpenMV Cam's frame buffer on the go.
|
||||
|
||||
import sensor
|
||||
import display
|
||||
|
||||
sensor.reset() # Initialize the camera sensor.
|
||||
sensor.set_pixformat(sensor.RGB565) # or sensor.GRAYSCALE
|
||||
sensor.set_framesize(sensor.QQVGA2) # Special 128x160 framesize for LCD Shield.
|
||||
# Initialize the lcd screen.
|
||||
# Note: A DAC or a PWM backlight controller can be used to control the
|
||||
# backlight intensity if supported:
|
||||
# lcd = display.SPIDisplay(backlight=display.DACBacklight(channel=2))
|
||||
# lcd.backlight(25) # 25% intensity
|
||||
# Otherwise the default GPIO (on/off) controller is used.
|
||||
lcd = display.SPIDisplay()
|
||||
|
||||
while True:
|
||||
lcd.write(sensor.snapshot()) # Take a picture and display the image.
|
@ -0,0 +1,35 @@
|
||||
# This work is licensed under the MIT license.
|
||||
# Copyright (c) 2013-2025 OpenMV LLC. All rights reserved.
|
||||
# https://github.com/openmv/openmv/blob/master/LICENSE
|
||||
#
|
||||
# LCD Shield Example
|
||||
#
|
||||
# Note: To run this example you will need a LCD Shield for your OpenMV Cam.
|
||||
#
|
||||
# The LCD shield allows you to view your OpenMV Cam's frame buffer on the go.
|
||||
|
||||
import sensor
|
||||
import time
|
||||
import display
|
||||
import image
|
||||
|
||||
sensor.reset()
|
||||
sensor.set_pixformat(sensor.RGB565)
|
||||
sensor.set_framesize(sensor.LCD)
|
||||
|
||||
# Initialize the lcd screen.
|
||||
# Note: A DAC or a PWM backlight controller can be used to control the
|
||||
# backlight intensity if supported:
|
||||
# lcd = display.SPIDisplay(backlight=display.DACBacklight(channel=2))
|
||||
# lcd.backlight(25) # 25% intensity
|
||||
# Otherwise the default GPIO (on/off) controller is used.
|
||||
# OpenMV Cam M4/M7/H7/H7 Plus -> DAC and GPIO Support
|
||||
# OpenMV Cam RT1062 -> GPIO Support
|
||||
# OpenMV Cam N6 -> PWM and GPIO Support
|
||||
lcd = display.SPIDisplay(vflip=True, hmirror=True)
|
||||
clock = time.clock()
|
||||
|
||||
while True:
|
||||
clock.tick()
|
||||
lcd.write(sensor.snapshot(), hint=image.CENTER | image.SCALE_ASPECT_KEEP)
|
||||
print(clock.fps())
|
@ -0,0 +1,39 @@
|
||||
# This work is licensed under the MIT license.
|
||||
# Copyright (c) 2013-2025 OpenMV LLC. All rights reserved.
|
||||
# https://github.com/openmv/openmv/blob/master/LICENSE
|
||||
#
|
||||
# Touch LCD Shield Example
|
||||
#
|
||||
# Note: To run this example you will need a Touch LCD Shield for your OpenMV Cam.
|
||||
#
|
||||
# The touch LCD shield allows you to view your OpenMV Cam's frame buffer on the go.
|
||||
|
||||
import sensor
|
||||
import time
|
||||
import display
|
||||
import image
|
||||
|
||||
sensor.reset()
|
||||
sensor.set_pixformat(sensor.RGB565)
|
||||
sensor.set_framesize(sensor.QVGA)
|
||||
|
||||
# Initialize the lcd screen.
|
||||
# Note: A DAC or a PWM backlight controller can be used to control the
|
||||
# backlight intensity if supported:
|
||||
# lcd = display.SPIDisplay(backlight=display.DACBacklight(channel=2))
|
||||
# lcd.backlight(25) # 25% intensity
|
||||
# Otherwise the default GPIO (on/off) controller is used.
|
||||
# OpenMV Cam M4/M7/H7/H7 Plus -> DAC and GPIO Support
|
||||
# OpenMV Cam RT1062 -> GPIO Support
|
||||
# OpenMV Cam N6 -> PWM and GPIO Support
|
||||
lcd = display.SPIDisplay(width=320,
|
||||
height=240,
|
||||
bgr=True,
|
||||
vflip=False,
|
||||
hmirror=False)
|
||||
clock = time.clock()
|
||||
|
||||
while True:
|
||||
clock.tick()
|
||||
lcd.write(sensor.snapshot(), hint=image.CENTER | image.SCALE_ASPECT_KEEP)
|
||||
print(clock.fps())
|
Loading…
Reference in New Issue
Block a user