Slight efactor of st7789 driver, and addition of the flip function

pull/103/head
David Tillotson 2021-03-06 16:45:38 +00:00 zatwierdzone przez Phil Howard
rodzic 19a084f219
commit 237d59d1d1
4 zmienionych plików z 20 dodań i 8 usunięć

Wyświetl plik

@ -7,6 +7,7 @@
#include "hardware/pwm.h"
namespace pimoroni {
char madctl[2];
void ST7789::init(bool auto_init_sequence) {
// configure spi interface and pins
@ -50,15 +51,16 @@ namespace pimoroni {
sleep_ms(150);
if(width == 240 && height == 240) {
command(reg::MADCTL, 1, "\x04"); // row/column addressing order - rgb pixel order
command(reg::TEON, 1, "\x00"); // enable frame sync signal if used
command(reg::COLMOD, 1, "\x05"); // 16 bits per pixel
madctl = 0x04;
}
if(width == 240 && height == 135) {
command(reg::MADCTL, 1, "\x70");
command(reg::COLMOD, 1, "\x05");
madctl = 0x70;
}
command(reg::MADCTL, 1, madctl); // row/column addressing order - rgb pixel order
command(reg::TEON, 1, "\x00"); // enable frame sync signal if used
command(reg::COLMOD, 1, "\x05"); // 16 bits per pixel
command(reg::INVON); // set inversion mode
command(reg::SLPOUT); // leave sleep mode
@ -147,4 +149,9 @@ namespace pimoroni {
void ST7789::vsync_callback(gpio_irq_callback_t callback) {
gpio_set_irq_enabled_with_callback(vsync, GPIO_IRQ_EDGE_RISE, true, callback);
}
}
void ST7789::flip(){
madctl[0] ^= 0xC0;
command(reg::MADCTL, 1, madctl);
}
}

Wyświetl plik

@ -47,6 +47,7 @@ namespace pimoroni {
void vsync_callback(gpio_irq_callback_t callback);
void update(bool dont_block = false);
void set_backlight(uint8_t brightness);
void flip();
enum reg {
SWRESET = 0x01,

Wyświetl plik

@ -79,4 +79,7 @@ namespace pimoroni {
return !gpio_get(button);
}
}
void flip() {
screen.flip();
}
}

Wyświetl plik

@ -26,6 +26,7 @@ namespace pimoroni {
void set_backlight(uint8_t brightness);
void set_led(uint8_t r, uint8_t g, uint8_t b);
bool is_pressed(uint8_t button);
void flip();
};
}
}