pxt-common-packages 14.1.2 → 14.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -34,6 +34,7 @@ namespace DigitalInOutPinMethods {
|
|
|
34
34
|
*/
|
|
35
35
|
//% help=pins/digital-read weight=61
|
|
36
36
|
//% blockId=device_get_digital_pin block="digital read|pin %name" blockGap=8
|
|
37
|
+
//% parts="slideswitch" trackArgs=0
|
|
37
38
|
//% blockNamespace=pins
|
|
38
39
|
//% name.fieldEditor="gridpicker"
|
|
39
40
|
//% name.fieldOptions.width=220
|
|
@@ -49,6 +50,7 @@ bool digitalRead(DigitalInOutPin name) {
|
|
|
49
50
|
*/
|
|
50
51
|
//% help=pins/digital-write weight=60
|
|
51
52
|
//% blockId=device_set_digital_pin block="digital write|pin %name|to %value=toggleHighLow"
|
|
53
|
+
//% parts="led" trackArgs=0
|
|
52
54
|
//% blockNamespace=pins
|
|
53
55
|
//% name.fieldEditor="gridpicker"
|
|
54
56
|
//% name.fieldOptions.width=220
|
|
@@ -63,6 +65,7 @@ void digitalWrite(DigitalInOutPin name, bool value) {
|
|
|
63
65
|
*/
|
|
64
66
|
//% help=pins/on-pulsed weight=16 blockGap=8
|
|
65
67
|
//% blockId=pins_on_pulsed block="on|pin %pin|pulsed %pulse"
|
|
68
|
+
//% parts="slideswitch" trackArgs=0
|
|
66
69
|
//% blockNamespace=pins
|
|
67
70
|
//% pin.fieldEditor="gridpicker"
|
|
68
71
|
//% pin.fieldOptions.width=220
|
|
@@ -78,6 +81,7 @@ void onPulsed(DigitalInOutPin pin, PulseValue pulse, Action body) {
|
|
|
78
81
|
*/
|
|
79
82
|
//% help=pins/on-event weight=20 blockGap=8
|
|
80
83
|
//% blockId=pinsonevent block="on|pin %pin|%event"
|
|
84
|
+
//% parts="slideswitch" trackArgs=0
|
|
81
85
|
//% blockNamespace=pins
|
|
82
86
|
//% pin.fieldEditor="gridpicker"
|
|
83
87
|
//% pin.fieldOptions.width=220
|
package/libs/core/shims.d.ts
CHANGED
|
@@ -84,6 +84,7 @@ declare interface DigitalInOutPin {
|
|
|
84
84
|
*/
|
|
85
85
|
//% help=pins/digital-read weight=61
|
|
86
86
|
//% blockId=device_get_digital_pin block="digital read|pin %name" blockGap=8
|
|
87
|
+
//% parts="slideswitch" trackArgs=0
|
|
87
88
|
//% blockNamespace=pins
|
|
88
89
|
//% name.fieldEditor="gridpicker"
|
|
89
90
|
//% name.fieldOptions.width=220
|
|
@@ -97,6 +98,7 @@ declare interface DigitalInOutPin {
|
|
|
97
98
|
*/
|
|
98
99
|
//% help=pins/digital-write weight=60
|
|
99
100
|
//% blockId=device_set_digital_pin block="digital write|pin %name|to %value=toggleHighLow"
|
|
101
|
+
//% parts="led" trackArgs=0
|
|
100
102
|
//% blockNamespace=pins
|
|
101
103
|
//% name.fieldEditor="gridpicker"
|
|
102
104
|
//% name.fieldOptions.width=220
|
|
@@ -109,6 +111,7 @@ declare interface DigitalInOutPin {
|
|
|
109
111
|
*/
|
|
110
112
|
//% help=pins/on-pulsed weight=16 blockGap=8
|
|
111
113
|
//% blockId=pins_on_pulsed block="on|pin %pin|pulsed %pulse"
|
|
114
|
+
//% parts="slideswitch" trackArgs=0
|
|
112
115
|
//% blockNamespace=pins
|
|
113
116
|
//% pin.fieldEditor="gridpicker"
|
|
114
117
|
//% pin.fieldOptions.width=220
|
|
@@ -121,6 +124,7 @@ declare interface DigitalInOutPin {
|
|
|
121
124
|
*/
|
|
122
125
|
//% help=pins/on-event weight=20 blockGap=8
|
|
123
126
|
//% blockId=pinsonevent block="on|pin %pin|%event"
|
|
127
|
+
//% parts="slideswitch" trackArgs=0
|
|
124
128
|
//% blockNamespace=pins
|
|
125
129
|
//% pin.fieldEditor="gridpicker"
|
|
126
130
|
//% pin.fieldOptions.width=220
|
|
@@ -84,6 +84,7 @@ declare interface DigitalInOutPin {
|
|
|
84
84
|
*/
|
|
85
85
|
//% help=pins/digital-read weight=61
|
|
86
86
|
//% blockId=device_get_digital_pin block="digital read|pin %name" blockGap=8
|
|
87
|
+
//% parts="slideswitch" trackArgs=0
|
|
87
88
|
//% blockNamespace=pins
|
|
88
89
|
//% name.fieldEditor="gridpicker"
|
|
89
90
|
//% name.fieldOptions.width=220
|
|
@@ -97,6 +98,7 @@ declare interface DigitalInOutPin {
|
|
|
97
98
|
*/
|
|
98
99
|
//% help=pins/digital-write weight=60
|
|
99
100
|
//% blockId=device_set_digital_pin block="digital write|pin %name|to %value=toggleHighLow"
|
|
101
|
+
//% parts="led" trackArgs=0
|
|
100
102
|
//% blockNamespace=pins
|
|
101
103
|
//% name.fieldEditor="gridpicker"
|
|
102
104
|
//% name.fieldOptions.width=220
|
|
@@ -109,6 +111,7 @@ declare interface DigitalInOutPin {
|
|
|
109
111
|
*/
|
|
110
112
|
//% help=pins/on-pulsed weight=16 blockGap=8
|
|
111
113
|
//% blockId=pins_on_pulsed block="on|pin %pin|pulsed %pulse"
|
|
114
|
+
//% parts="slideswitch" trackArgs=0
|
|
112
115
|
//% blockNamespace=pins
|
|
113
116
|
//% pin.fieldEditor="gridpicker"
|
|
114
117
|
//% pin.fieldOptions.width=220
|
|
@@ -121,6 +124,7 @@ declare interface DigitalInOutPin {
|
|
|
121
124
|
*/
|
|
122
125
|
//% help=pins/on-event weight=20 blockGap=8
|
|
123
126
|
//% blockId=pinsonevent block="on|pin %pin|%event"
|
|
127
|
+
//% parts="slideswitch" trackArgs=0
|
|
124
128
|
//% blockNamespace=pins
|
|
125
129
|
//% pin.fieldEditor="gridpicker"
|
|
126
130
|
//% pin.fieldOptions.width=220
|
|
@@ -33,6 +33,21 @@ class WDisplay {
|
|
|
33
33
|
bool doubleSize;
|
|
34
34
|
uint32_t palXOR;
|
|
35
35
|
|
|
36
|
+
#ifdef USE_RGB444
|
|
37
|
+
// RGB444 streaming path for ST7735 panels lacking the RGBSET LUT (see #6861)
|
|
38
|
+
SPI *spi_ = NULL;
|
|
39
|
+
Pin *dcPin_ = NULL;
|
|
40
|
+
Pin *csPin_ = NULL;
|
|
41
|
+
bool rgb444_ = false;
|
|
42
|
+
uint8_t pal4R_[16], pal4G_[16], pal4B_[16];
|
|
43
|
+
|
|
44
|
+
inline void wrCmd1(uint8_t cmd, uint8_t a0) {
|
|
45
|
+
dcPin_->setDigitalValue(0); csPin_->setDigitalValue(0); spi_->write(cmd);
|
|
46
|
+
dcPin_->setDigitalValue(1); spi_->write(a0);
|
|
47
|
+
csPin_->setDigitalValue(1);
|
|
48
|
+
}
|
|
49
|
+
#endif
|
|
50
|
+
|
|
36
51
|
WDisplay() {
|
|
37
52
|
uint32_t cfg2 = getConfig(CFG_DISPLAY_CFG2, 0x0);
|
|
38
53
|
int conn = cfg2 >> 24;
|
|
@@ -66,6 +81,11 @@ class WDisplay {
|
|
|
66
81
|
spi = new CODAL_SPI(*LOOKUP_PIN(DISPLAY_MOSI), *miso, *LOOKUP_PIN(DISPLAY_SCK));
|
|
67
82
|
#endif
|
|
68
83
|
io = new SPIScreenIO(*spi);
|
|
84
|
+
#ifdef USE_RGB444
|
|
85
|
+
spi_ = spi;
|
|
86
|
+
dcPin_ = LOOKUP_PIN(DISPLAY_DC);
|
|
87
|
+
csPin_ = LOOKUP_PIN(DISPLAY_CS);
|
|
88
|
+
#endif
|
|
69
89
|
} else if (conn == 1) {
|
|
70
90
|
#ifdef CODAL_CREATE_PARALLEL_SCREEN_IO
|
|
71
91
|
io = CODAL_CREATE_PARALLEL_SCREEN_IO(cfg2 & 0xffffff, PIN(DISPLAY_MOSI),
|
|
@@ -77,6 +97,21 @@ class WDisplay {
|
|
|
77
97
|
target_panic(PANIC_SCREEN_ERROR);
|
|
78
98
|
}
|
|
79
99
|
|
|
100
|
+
#ifdef USE_RGB444
|
|
101
|
+
// Runtime scope: RGB444 only on known Adafruit boards. Current Adafruit
|
|
102
|
+
// bootloaders publish VID:PID (VID 0x239A) as the board-id; older ones
|
|
103
|
+
// (which new boards still ship with) published fixed per-model ids, listed
|
|
104
|
+
// below. Unknown or absent ids keep the stock RGBSET path (e.g. Kitronik).
|
|
105
|
+
uint32_t boardId = (uint32_t)getConfig(CFG_BOOTLOADER_BOARD_ID, 0);
|
|
106
|
+
rgb444_ = spi_ && ((boardId >> 16) == 0x239A || // current Adafruit (VID:PID)
|
|
107
|
+
boardId == 0x18591ab9 || // PyBadge/LC/PyGamer (2019)
|
|
108
|
+
boardId == 0x75fdeb5f || // PyBadge
|
|
109
|
+
boardId == 0x3f05ba69 || // PyBadge LC
|
|
110
|
+
boardId == 0x2dd7a88c || // PyGamer
|
|
111
|
+
boardId == 0x2b9e3d05 || // Feather M4 Arcade
|
|
112
|
+
boardId == 0x7a236324); // ItsyBitsy M4 Arcade
|
|
113
|
+
#endif
|
|
114
|
+
|
|
80
115
|
if (dispTp == DISPLAY_TYPE_ST7735)
|
|
81
116
|
lcd = new ST7735(*io, *LOOKUP_PIN(DISPLAY_CS), *LOOKUP_PIN(DISPLAY_DC));
|
|
82
117
|
else if (dispTp == DISPLAY_TYPE_ILI9341) {
|
|
@@ -127,6 +162,14 @@ class WDisplay {
|
|
|
127
162
|
|
|
128
163
|
lcd->init();
|
|
129
164
|
lcd->configure(madctl, frmctr1);
|
|
165
|
+
|
|
166
|
+
#ifdef USE_RGB444
|
|
167
|
+
if (rgb444_ && !doubleSize) {
|
|
168
|
+
// 12bpp RGB444 mode: lets us stream color without the RGBSET LUT
|
|
169
|
+
wrCmd1(0x3A, 0x03); // COLMOD
|
|
170
|
+
wrCmd1(0x20, 0x00); // INVOFF
|
|
171
|
+
}
|
|
172
|
+
#endif
|
|
130
173
|
}
|
|
131
174
|
|
|
132
175
|
width = getConfig(CFG_DISPLAY_WIDTH, 160);
|
|
@@ -246,6 +289,35 @@ class WDisplay {
|
|
|
246
289
|
return 0;
|
|
247
290
|
#endif
|
|
248
291
|
}
|
|
292
|
+
|
|
293
|
+
#ifdef USE_RGB444
|
|
294
|
+
// Stream a 4bpp indexed image as RGB444 over SPI (replaces the RGBSET LUT path).
|
|
295
|
+
// Batches up to 3 lines per SPI transfer to reduce per-transfer overhead.
|
|
296
|
+
void sendIndexedImage444(const uint8_t *src, int W, int H) {
|
|
297
|
+
static uint8_t buf444[3 * (3 * 160) / 2]; // 160 = max ST7735 width
|
|
298
|
+
const int bytesPerRow = (W + 1) >> 1;
|
|
299
|
+
dcPin_->setDigitalValue(0);
|
|
300
|
+
csPin_->setDigitalValue(0);
|
|
301
|
+
spi_->write(0x2C); // RAMWR
|
|
302
|
+
dcPin_->setDigitalValue(1);
|
|
303
|
+
int out = 0;
|
|
304
|
+
for (int y = 0; y < H; y++) {
|
|
305
|
+
const uint8_t *row = src + y * bytesPerRow;
|
|
306
|
+
for (int x = 0; x < W; x += 2) {
|
|
307
|
+
uint8_t b = *row++;
|
|
308
|
+
uint8_t i0 = b & 0x0F, i1 = (b >> 4) & 0x0F;
|
|
309
|
+
buf444[out++] = (pal4R_[i0] << 4) | pal4G_[i0];
|
|
310
|
+
buf444[out++] = (pal4B_[i0] << 4) | pal4R_[i1];
|
|
311
|
+
buf444[out++] = (pal4G_[i1] << 4) | pal4B_[i1];
|
|
312
|
+
}
|
|
313
|
+
if (out + 3 * (W + 1) / 2 > (int)sizeof(buf444) || y == H - 1) {
|
|
314
|
+
spi_->transfer((uint8_t *)buf444, out, NULL, 0);
|
|
315
|
+
out = 0;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
csPin_->setDigitalValue(1);
|
|
319
|
+
}
|
|
320
|
+
#endif
|
|
249
321
|
};
|
|
250
322
|
|
|
251
323
|
SINGLETON_IF_PIN(WDisplay, DISPLAY_MOSI);
|
|
@@ -314,6 +386,11 @@ void setPalette(Buffer buf) {
|
|
|
314
386
|
display->currPalette[i] =
|
|
315
387
|
(buf->data[i * 3] << 16) | (buf->data[i * 3 + 1] << 8) | (buf->data[i * 3 + 2] << 0);
|
|
316
388
|
display->currPalette[i] ^= display->palXOR;
|
|
389
|
+
#ifdef USE_RGB444
|
|
390
|
+
display->pal4R_[i] = (display->currPalette[i] >> 20) & 0xF;
|
|
391
|
+
display->pal4G_[i] = (display->currPalette[i] >> 12) & 0xF;
|
|
392
|
+
display->pal4B_[i] = (display->currPalette[i] >> 4) & 0xF;
|
|
393
|
+
#endif
|
|
317
394
|
}
|
|
318
395
|
display->newPalette = true;
|
|
319
396
|
}
|
|
@@ -361,20 +438,29 @@ void updateScreen(Image_ img) {
|
|
|
361
438
|
// DMESG("wait for done");
|
|
362
439
|
display->waitForSendDone();
|
|
363
440
|
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
display->
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
441
|
+
#ifdef USE_RGB444
|
|
442
|
+
if (display->rgb444_ && display->lcd && !display->doubleSize) {
|
|
443
|
+
memcpy(display->screenBuf, img->pix(), img->pixLength());
|
|
444
|
+
display->setAddrMain();
|
|
445
|
+
display->sendIndexedImage444(display->screenBuf, display->width, display->displayHeight);
|
|
446
|
+
} else
|
|
447
|
+
#endif
|
|
448
|
+
{
|
|
449
|
+
auto palette = display->currPalette;
|
|
450
|
+
|
|
451
|
+
if (display->newPalette) {
|
|
452
|
+
display->newPalette = false;
|
|
453
|
+
} else {
|
|
454
|
+
// smart mode always sends palette
|
|
455
|
+
if (!display->smart)
|
|
456
|
+
palette = NULL;
|
|
457
|
+
}
|
|
373
458
|
|
|
374
|
-
|
|
459
|
+
memcpy(display->screenBuf, img->pix(), img->pixLength());
|
|
375
460
|
|
|
376
|
-
|
|
377
|
-
|
|
461
|
+
// DMESG("send");
|
|
462
|
+
display->sendIndexedImage(display->screenBuf, img->width(), img->height(), palette);
|
|
463
|
+
}
|
|
378
464
|
}
|
|
379
465
|
|
|
380
466
|
if (display->lastStatus && !display->doubleSize && !display->smart) {
|
|
@@ -385,8 +471,15 @@ void updateScreen(Image_ img) {
|
|
|
385
471
|
target_panic(PANIC_SCREEN_ERROR);
|
|
386
472
|
memcpy(display->screenBuf, img->pix(), img->pixLength());
|
|
387
473
|
display->setAddrStatus();
|
|
388
|
-
|
|
389
|
-
display->
|
|
474
|
+
#ifdef USE_RGB444
|
|
475
|
+
if (display->rgb444_) {
|
|
476
|
+
display->sendIndexedImage444(display->screenBuf, display->width, barHeight);
|
|
477
|
+
} else
|
|
478
|
+
#endif
|
|
479
|
+
{
|
|
480
|
+
display->sendIndexedImage(display->screenBuf, img->width(), img->height(), NULL);
|
|
481
|
+
display->waitForSendDone();
|
|
482
|
+
}
|
|
390
483
|
display->setAddrMain();
|
|
391
484
|
display->lastStatus = NULL;
|
|
392
485
|
}
|