Skip to content

Commit 5277138

Browse files
committed
pyportal compiles and tweak blinka colors
1 parent 84292ad commit 5277138

5 files changed

Lines changed: 64 additions & 5 deletions

File tree

ports/atmel-samd/boards/pyportal/board.c

Lines changed: 54 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* The MIT License (MIT)
55
*
6-
* Copyright (c) 2018 Scott Shawcroft for Adafruit Industries
6+
* Copyright (c) 2019 Scott Shawcroft for Adafruit Industries
77
*
88
* Permission is hereby granted, free of charge, to any person obtaining a copy
99
* of this software and associated documentation files (the "Software"), to deal
@@ -25,21 +25,72 @@
2525
*/
2626

2727
#include "boards/board.h"
28-
#include "board_busses.h"
28+
#include "supervisor/shared/board_busses.h"
2929
#include "mpconfigboard.h"
3030
#include "hal/include/hal_gpio.h"
3131

3232
#include "shared-module/displayio/__init__.h"
33+
#include "shared-module/displayio/mipi_constants.h"
3334

3435
#include "tick.h"
3536

37+
#define DELAY 0x80
38+
39+
uint8_t display_init_sequence[] = {
40+
0xEF, 3, 0x03, 0x80, 0x02,
41+
0xCF, 3, 0x00, 0xC1, 0x30,
42+
0xED, 4, 0x64, 0x03, 0x12, 0x81,
43+
0xE8, 3, 0x85, 0x00, 0x78,
44+
0xCB, 5, 0x39, 0x2C, 0x00, 0x34, 0x02,
45+
0xF7, 1, 0x20,
46+
0xEA, 2, 0x00, 0x00,
47+
0xc0, 1, 0x23, // Power control VRH[5:0]
48+
0xc1, 1, 0x10, // Power control SAP[2:0];BT[3:0]
49+
0xc5, 2, 0x3e, 0x28, // VCM control
50+
0xc7, 1, 0x86, // VCM control2
51+
0x36, 1, 0x38, // Memory Access Control
52+
0x37, 1, 0x00, // Vertical scroll zero
53+
0x3a, 1, 0x55, // COLMOD: Pixel Format Set
54+
0xb1, 2, 0x00, 0x18, // Frame Rate Control (In Normal Mode/Full Colors)
55+
0xb6, 3, 0x08, 0x82, 0x27, // Display Function Control
56+
0xF2, 1, 0x00, // 3Gamma Function Disable
57+
0x26, 1, 0x01, // Gamma curve selected
58+
0xe0, 15, 0x0F, 0x31, 0x2B, 0x0C, 0x0E, 0x08, // Set Gamma
59+
0x4E, 0xF1, 0x37, 0x07, 0x10, 0x03, 0x0E, 0x09, 0x00,
60+
0xe1, 15, 0x00, 0x0E, 0x14, 0x03, 0x11, 0x07, // Set Gamma
61+
0x31, 0xC1, 0x48, 0x08, 0x0F, 0x0C, 0x31, 0x36, 0x0F,
62+
0x11, DELAY, 120, // Exit Sleep
63+
0x29, DELAY, 120, // Display on
64+
};
65+
3666
void board_init(void) {
67+
displayio_fourwire_obj_t* bus = &displays[0].fourwire_bus;
68+
bus->base.type = &displayio_fourwire_type;
69+
common_hal_displayio_fourwire_construct(bus,
70+
board_spi(),
71+
&pin_PB09, // Command or data
72+
&pin_PB06, // Chip select
73+
&pin_PA00); // Reset
74+
75+
displayio_display_obj_t* display = &displays[0].display;
76+
display->base.type = &displayio_display_type;
77+
common_hal_displayio_display_construct(display,
78+
bus,
79+
320, // Width
80+
240, // Height
81+
0, // column start
82+
0, // row start
83+
16, // Color depth
84+
MIPI_COMMAND_SET_COLUMN_ADDRESS, // Set column command
85+
MIPI_COMMAND_SET_PAGE_ADDRESS, // Set row command
86+
MIPI_COMMAND_WRITE_MEMORY_START, // Write memory command
87+
display_init_sequence,
88+
sizeof(display_init_sequence));
3789
}
3890

3991
bool board_requests_safe_mode(void) {
4092
return false;
4193
}
4294

4395
void reset_board(void) {
44-
common_hal_displayio_display_show(&primary_display_obj, NULL);
4596
}

ports/atmel-samd/mpconfigport.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ typedef long mp_off_t;
192192
#define MICROPY_PY_REVERSE_SPECIAL_METHODS (1)
193193
#define MICROPY_PY_SYS_EXC_INFO (1)
194194
// MICROPY_PY_UERRNO_LIST - Use the default
195+
#define CIRCUITPY_DISPLAY_LIMIT (3)
195196
#endif
196197

197198
#ifdef LONGINT_IMPL_NONE

shared-module/displayio/Group.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,14 @@ void displayio_group_construct(displayio_group_t* self, mp_obj_t* child_array, u
6767
self->children = child_array;
6868
self->max_size = max_size;
6969
self->needs_refresh = false;
70+
self->scale = 1;
7071
}
7172

7273
bool displayio_group_get_pixel(displayio_group_t *self, int16_t x, int16_t y, uint16_t* pixel) {
7374
x -= self->x;
7475
y -= self->y;
76+
x /= self->scale;
77+
y /= self->scale;
7578
for (int32_t i = self->size - 1; i >= 0 ; i--) {
7679
mp_obj_t layer = self->children[i];
7780
if (MP_OBJ_IS_TYPE(layer, &displayio_sprite_type)) {

shared-module/displayio/Group.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ typedef struct {
3636
mp_obj_base_t base;
3737
int16_t x;
3838
int16_t y;
39+
uint16_t scale;
3940
uint16_t size;
4041
uint16_t max_size;
4142
mp_obj_t* children;

shared-module/displayio/__init__.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,10 @@ displayio_bitmap_t blinka_bitmap = {
105105
};
106106

107107
uint32_t blinka_transparency[1] = {0x80000000};
108-
uint32_t blinka_colors[8] = {0x1e910000, 0x72dc722b, 0xffffb05a, 0x00000000,
109-
0x80000000, 0x00000000, 0x00000000, 0x00000000};
108+
109+
// TODO(tannewt): Fix these colors
110+
uint32_t blinka_colors[8] = {0x91780000, 0x879FFC98, 0xffff0000, 0x0000f501,
111+
0x00000000, 0x00000000, 0x00000000, 0x00000000};
110112

111113
displayio_palette_t blinka_palette = {
112114
.base = {.type = &displayio_palette_type },
@@ -135,6 +137,7 @@ displayio_group_t splash = {
135137
.base = {.type = &displayio_group_type },
136138
.x = 0,
137139
.y = 0,
140+
.scale = 2,
138141
.size = 1,
139142
.max_size = 1,
140143
.children = splash_children,

0 commit comments

Comments
 (0)