Skip to content

Commit b9ccc62

Browse files
authored
Merge pull request #2 from adafruit/main
merging from adafruit
2 parents cf21c4d + 75a977f commit b9ccc62

File tree

14 files changed

+151
-7
lines changed

14 files changed

+151
-7
lines changed

.github/workflows/build.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ jobs:
421421
fail-fast: false
422422
matrix:
423423
board:
424-
- "adafruit_esp32s2_eink_portal"
424+
- "adafruit_magtag_2.9_grayscale"
425425
- "adafruit_metro_esp32s2"
426426
- "electroniccats_bastwifi"
427427
- "espressif_kaluga_1"

ports/esp32s2/boards/adafruit_esp32s2_eink_portal/mpconfigboard.h renamed to ports/esp32s2/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
//Micropython setup
2828

29-
#define MICROPY_HW_BOARD_NAME "EInk Portal"
29+
#define MICROPY_HW_BOARD_NAME "MagTag"
3030
#define MICROPY_HW_MCU_NAME "ESP32S2"
3131

3232
#define MICROPY_HW_NEOPIXEL (&pin_GPIO1)

ports/esp32s2/boards/adafruit_esp32s2_eink_portal/mpconfigboard.mk renamed to ports/esp32s2/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.mk

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
USB_VID = 0x239A
22
USB_PID = 0x80E6
3-
USB_PRODUCT = "EInk Portal"
3+
USB_PRODUCT = "MagTag"
44
USB_MANUFACTURER = "Adafruit"
55

66
INTERNAL_FLASH_FILESYSTEM = 1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
/*
2+
* This file is part of the MicroPython project, http://micropython.org/
3+
*
4+
* The MIT License (MIT)
5+
*
6+
* Copyright (c) 2020 microDev
7+
*
8+
* Permission is hereby granted, free of charge, to any person obtaining a copy
9+
* of this software and associated documentation files (the "Software"), to deal
10+
* in the Software without restriction, including without limitation the rights
11+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
* copies of the Software, and to permit persons to whom the Software is
13+
* furnished to do so, subject to the following conditions:
14+
*
15+
* The above copyright notice and this permission notice shall be included in
16+
* all copies or substantial portions of the Software.
17+
*
18+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24+
* THE SOFTWARE.
25+
*/
26+
27+
#include "common-hal/rotaryio/IncrementalEncoder.h"
28+
#include "common-hal/microcontroller/Pin.h"
29+
30+
#include "py/runtime.h"
31+
#include "supervisor/shared/translate.h"
32+
33+
void common_hal_rotaryio_incrementalencoder_construct(rotaryio_incrementalencoder_obj_t* self,
34+
const mcu_pin_obj_t* pin_a, const mcu_pin_obj_t* pin_b) {
35+
claim_pin(pin_a);
36+
claim_pin(pin_b);
37+
38+
// Prepare configuration for the PCNT unit
39+
const pcnt_config_t pcnt_config = {
40+
// Set PCNT input signal and control GPIOs
41+
.pulse_gpio_num = pin_a->number,
42+
.ctrl_gpio_num = pin_b->number,
43+
.channel = PCNT_CHANNEL_0,
44+
// What to do on the positive / negative edge of pulse input?
45+
.pos_mode = PCNT_COUNT_DEC, // Count up on the positive edge
46+
.neg_mode = PCNT_COUNT_INC, // Keep the counter value on the negative edge
47+
// What to do when control input is low or high?
48+
.lctrl_mode = PCNT_MODE_REVERSE, // Reverse counting direction if low
49+
.hctrl_mode = PCNT_MODE_KEEP, // Keep the primary counter mode if high
50+
};
51+
52+
// Initialize PCNT unit
53+
const int8_t unit = peripherals_pcnt_init(pcnt_config);
54+
if (unit == -1) {
55+
mp_raise_RuntimeError(translate("All PCNT units in use"));
56+
}
57+
58+
self->pin_a = pin_a->number;
59+
self->pin_b = pin_b->number;
60+
self->unit = (pcnt_unit_t)unit;
61+
}
62+
63+
bool common_hal_rotaryio_incrementalencoder_deinited(rotaryio_incrementalencoder_obj_t* self) {
64+
return self->unit == PCNT_UNIT_MAX;
65+
}
66+
67+
void common_hal_rotaryio_incrementalencoder_deinit(rotaryio_incrementalencoder_obj_t* self) {
68+
if (common_hal_rotaryio_incrementalencoder_deinited(self)) {
69+
return;
70+
}
71+
reset_pin_number(self->pin_a);
72+
reset_pin_number(self->pin_b);
73+
peripherals_pcnt_deinit(&self->unit);
74+
}
75+
76+
mp_int_t common_hal_rotaryio_incrementalencoder_get_position(rotaryio_incrementalencoder_obj_t* self) {
77+
int16_t count;
78+
pcnt_get_counter_value(self->unit, &count);
79+
return (count/2)+self->position;
80+
}
81+
82+
void common_hal_rotaryio_incrementalencoder_set_position(rotaryio_incrementalencoder_obj_t* self,
83+
mp_int_t new_position) {
84+
self->position = new_position;
85+
pcnt_counter_clear(self->unit);
86+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* This file is part of the MicroPython project, http://micropython.org/
3+
*
4+
* The MIT License (MIT)
5+
*
6+
* Copyright (c) 2020 microDev
7+
*
8+
* Permission is hereby granted, free of charge, to any person obtaining a copy
9+
* of this software and associated documentation files (the "Software"), to deal
10+
* in the Software without restriction, including without limitation the rights
11+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
* copies of the Software, and to permit persons to whom the Software is
13+
* furnished to do so, subject to the following conditions:
14+
*
15+
* The above copyright notice and this permission notice shall be included in
16+
* all copies or substantial portions of the Software.
17+
*
18+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24+
* THE SOFTWARE.
25+
*/
26+
27+
#ifndef MICROPY_INCLUDED_ESP32S2_COMMON_HAL_ROTARYIO_INCREMENTALENCODER_H
28+
#define MICROPY_INCLUDED_ESP32S2_COMMON_HAL_ROTARYIO_INCREMENTALENCODER_H
29+
30+
#include "py/obj.h"
31+
#include "peripherals/pcnt.h"
32+
33+
typedef struct {
34+
mp_obj_base_t base;
35+
uint8_t pin_a, pin_b;
36+
mp_int_t position;
37+
pcnt_unit_t unit;
38+
} rotaryio_incrementalencoder_obj_t;
39+
40+
#endif // MICROPY_INCLUDED_ESP32S2_COMMON_HAL_ROTARYIO_INCREMENTALENCODER_H
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// No rotaryio module functions.

ports/esp32s2/common-hal/touchio/TouchIn.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* The MIT License (MIT)
55
*
6-
* Copyright (c) 2016 Scott Shawcroft for Adafruit Industries
6+
* Copyright (c) 2020 microDev
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

ports/esp32s2/common-hal/touchio/TouchIn.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* The MIT License (MIT)
55
*
6-
* Copyright (c) 2016 Scott Shawcroft
6+
* Copyright (c) 2020 microDev
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

ports/esp32s2/mpconfigport.mk

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ CIRCUITPY_CANIO = 1
2020
CIRCUITPY_COUNTIO = 1
2121
CIRCUITPY_FREQUENCYIO = 0
2222
CIRCUITPY_I2CPERIPHERAL = 0
23-
CIRCUITPY_ROTARYIO = 0
23+
CIRCUITPY_ROTARYIO = 1
2424
CIRCUITPY_NVM = 0
2525
# We don't have enough endpoints to include MIDI.
2626
CIRCUITPY_USB_MIDI = 0

ports/esp32s2/supervisor/port.c

+12-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,18 @@ uint32_t *port_stack_get_limit(void) {
148148
}
149149

150150
uint32_t *port_stack_get_top(void) {
151-
return port_stack_get_limit() + CONFIG_ESP_MAIN_TASK_STACK_SIZE / (sizeof(uint32_t) / sizeof(StackType_t));
151+
// The sizeof-arithmetic is so that the pointer arithmetic is done on units
152+
// of uint32_t instead of units of StackType_t. StackType_t is an alias
153+
// for a byte sized type.
154+
//
155+
// The main stack is bigger than CONFIG_ESP_MAIN_TASK_STACK_SIZE -- an
156+
// "extra" size is added to it (TASK_EXTRA_STACK_SIZE). This total size is
157+
// available as ESP_TASK_MAIN_STACK. Presumably TASK_EXTRA_STACK_SIZE is
158+
// additional stack that can be used by the esp-idf runtime. But what's
159+
// important for us is that some very outermost stack frames, such as
160+
// pyexec_friendly_repl, could lie inside the "extra" area and be invisible
161+
// to the garbage collector.
162+
return port_stack_get_limit() + ESP_TASK_MAIN_STACK / (sizeof(uint32_t) / sizeof(StackType_t));
152163
}
153164

154165
supervisor_allocation _fixed_stack;

shared-module/displayio/TileGrid.c

+6
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,16 @@ bool common_hal_displayio_tilegrid_get_hidden(displayio_tilegrid_t* self) {
8383

8484
void common_hal_displayio_tilegrid_set_hidden(displayio_tilegrid_t* self, bool hidden) {
8585
self->hidden = hidden;
86+
if(!hidden){
87+
self->full_change = true;
88+
}
8689
}
8790

8891
void displayio_tilegrid_set_hidden_by_parent(displayio_tilegrid_t *self, bool hidden) {
8992
self->hidden_by_parent = hidden;
93+
if(!hidden){
94+
self->full_change = true;
95+
}
9096
}
9197

9298
bool displayio_tilegrid_get_previous_area(displayio_tilegrid_t *self, displayio_area_t* area) {

0 commit comments

Comments
 (0)