pyportal compiles and tweak blinka colors

This commit is contained in:
Scott Shawcroft 2019-01-17 10:57:05 -08:00
parent 84292ad890
commit 5277138c99
No known key found for this signature in database
GPG Key ID: FD0EDC4B6C53CA59
5 changed files with 64 additions and 5 deletions

View File

@ -3,7 +3,7 @@
*
* The MIT License (MIT)
*
* Copyright (c) 2018 Scott Shawcroft for Adafruit Industries
* Copyright (c) 2019 Scott Shawcroft for Adafruit Industries
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -25,15 +25,67 @@
*/
#include "boards/board.h"
#include "board_busses.h"
#include "supervisor/shared/board_busses.h"
#include "mpconfigboard.h"
#include "hal/include/hal_gpio.h"
#include "shared-module/displayio/__init__.h"
#include "shared-module/displayio/mipi_constants.h"
#include "tick.h"
#define DELAY 0x80
uint8_t display_init_sequence[] = {
0xEF, 3, 0x03, 0x80, 0x02,
0xCF, 3, 0x00, 0xC1, 0x30,
0xED, 4, 0x64, 0x03, 0x12, 0x81,
0xE8, 3, 0x85, 0x00, 0x78,
0xCB, 5, 0x39, 0x2C, 0x00, 0x34, 0x02,
0xF7, 1, 0x20,
0xEA, 2, 0x00, 0x00,
0xc0, 1, 0x23, // Power control VRH[5:0]
0xc1, 1, 0x10, // Power control SAP[2:0];BT[3:0]
0xc5, 2, 0x3e, 0x28, // VCM control
0xc7, 1, 0x86, // VCM control2
0x36, 1, 0x38, // Memory Access Control
0x37, 1, 0x00, // Vertical scroll zero
0x3a, 1, 0x55, // COLMOD: Pixel Format Set
0xb1, 2, 0x00, 0x18, // Frame Rate Control (In Normal Mode/Full Colors)
0xb6, 3, 0x08, 0x82, 0x27, // Display Function Control
0xF2, 1, 0x00, // 3Gamma Function Disable
0x26, 1, 0x01, // Gamma curve selected
0xe0, 15, 0x0F, 0x31, 0x2B, 0x0C, 0x0E, 0x08, // Set Gamma
0x4E, 0xF1, 0x37, 0x07, 0x10, 0x03, 0x0E, 0x09, 0x00,
0xe1, 15, 0x00, 0x0E, 0x14, 0x03, 0x11, 0x07, // Set Gamma
0x31, 0xC1, 0x48, 0x08, 0x0F, 0x0C, 0x31, 0x36, 0x0F,
0x11, DELAY, 120, // Exit Sleep
0x29, DELAY, 120, // Display on
};
void board_init(void) {
displayio_fourwire_obj_t* bus = &displays[0].fourwire_bus;
bus->base.type = &displayio_fourwire_type;
common_hal_displayio_fourwire_construct(bus,
board_spi(),
&pin_PB09, // Command or data
&pin_PB06, // Chip select
&pin_PA00); // Reset
displayio_display_obj_t* display = &displays[0].display;
display->base.type = &displayio_display_type;
common_hal_displayio_display_construct(display,
bus,
320, // Width
240, // Height
0, // column start
0, // row start
16, // Color depth
MIPI_COMMAND_SET_COLUMN_ADDRESS, // Set column command
MIPI_COMMAND_SET_PAGE_ADDRESS, // Set row command
MIPI_COMMAND_WRITE_MEMORY_START, // Write memory command
display_init_sequence,
sizeof(display_init_sequence));
}
bool board_requests_safe_mode(void) {
@ -41,5 +93,4 @@ bool board_requests_safe_mode(void) {
}
void reset_board(void) {
common_hal_displayio_display_show(&primary_display_obj, NULL);
}

View File

@ -192,6 +192,7 @@ typedef long mp_off_t;
#define MICROPY_PY_REVERSE_SPECIAL_METHODS (1)
#define MICROPY_PY_SYS_EXC_INFO (1)
// MICROPY_PY_UERRNO_LIST - Use the default
#define CIRCUITPY_DISPLAY_LIMIT (3)
#endif
#ifdef LONGINT_IMPL_NONE

View File

@ -67,11 +67,14 @@ void displayio_group_construct(displayio_group_t* self, mp_obj_t* child_array, u
self->children = child_array;
self->max_size = max_size;
self->needs_refresh = false;
self->scale = 1;
}
bool displayio_group_get_pixel(displayio_group_t *self, int16_t x, int16_t y, uint16_t* pixel) {
x -= self->x;
y -= self->y;
x /= self->scale;
y /= self->scale;
for (int32_t i = self->size - 1; i >= 0 ; i--) {
mp_obj_t layer = self->children[i];
if (MP_OBJ_IS_TYPE(layer, &displayio_sprite_type)) {

View File

@ -36,6 +36,7 @@ typedef struct {
mp_obj_base_t base;
int16_t x;
int16_t y;
uint16_t scale;
uint16_t size;
uint16_t max_size;
mp_obj_t* children;

View File

@ -105,8 +105,10 @@ displayio_bitmap_t blinka_bitmap = {
};
uint32_t blinka_transparency[1] = {0x80000000};
uint32_t blinka_colors[8] = {0x1e910000, 0x72dc722b, 0xffffb05a, 0x00000000,
0x80000000, 0x00000000, 0x00000000, 0x00000000};
// TODO(tannewt): Fix these colors
uint32_t blinka_colors[8] = {0x91780000, 0x879FFC98, 0xffff0000, 0x0000f501,
0x00000000, 0x00000000, 0x00000000, 0x00000000};
displayio_palette_t blinka_palette = {
.base = {.type = &displayio_palette_type },
@ -135,6 +137,7 @@ displayio_group_t splash = {
.base = {.type = &displayio_group_type },
.x = 0,
.y = 0,
.scale = 2,
.size = 1,
.max_size = 1,
.children = splash_children,