diff options
| author | IAMLIUBO <imliubo@makingfun.xyz> | 2021-05-27 11:11:34 +0800 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2021-05-30 23:15:13 +1000 |
| commit | a18f695e294baf22bd7862e5be57aa0c820c7c77 (patch) | |
| tree | 8861539a1757c2c963c4dd956b09de471dec415d | |
| parent | a6a8941d84a4d38129bdc00be701a7ca8fc867b6 (diff) | |
esp32/boards: Add M5STACK_ATOM board definition.
ATOM is a very small ESP32 development board produced by M5Stack, with a
size of 24mm * 24mm, with peripherals such as WS2812, IR, button, MPU6886
(Only Matrix), and 8 GPIO extensions. It also has a plastic shell.
| -rw-r--r-- | ports/esp32/boards/M5STACK_ATOM/manifest.py | 2 | ||||
| -rw-r--r-- | ports/esp32/boards/M5STACK_ATOM/modules/atom.py | 75 | ||||
| -rw-r--r-- | ports/esp32/boards/M5STACK_ATOM/mpconfigboard.cmake | 10 | ||||
| -rw-r--r-- | ports/esp32/boards/M5STACK_ATOM/mpconfigboard.h | 2 | ||||
| -rw-r--r-- | ports/esp32/boards/M5STACK_ATOM/sdkconfig.board | 5 |
5 files changed, 94 insertions, 0 deletions
diff --git a/ports/esp32/boards/M5STACK_ATOM/manifest.py b/ports/esp32/boards/M5STACK_ATOM/manifest.py new file mode 100644 index 000000000..7ae2ed15d --- /dev/null +++ b/ports/esp32/boards/M5STACK_ATOM/manifest.py @@ -0,0 +1,2 @@ +include("$(PORT_DIR)/boards/manifest.py") +freeze("modules") diff --git a/ports/esp32/boards/M5STACK_ATOM/modules/atom.py b/ports/esp32/boards/M5STACK_ATOM/modules/atom.py new file mode 100644 index 000000000..8f47585f1 --- /dev/null +++ b/ports/esp32/boards/M5STACK_ATOM/modules/atom.py @@ -0,0 +1,75 @@ +# M5Stack ATOM MicroPython Helper Library +# MIT license; Copyright (c) 2021 IAMLIUBO work for M5STACK +# +# Hardware details: +# ATOM Lite https://docs.m5stack.com/en/core/atom_lite +# ATOM Matrix https://docs.m5stack.com/en/core/atom_matrix + +from micropython import const +from machine import Pin +import neopixel + +# M5STACK ATOM Hardware Pin Assignments +""" + FRONT + |3V3| +|G21| IR G12 |G22| +|G25| BTN G39 |G19| +| 5V| WS2812 G27 |G23| +|GNG| MPU G21 G25 |G33| + G32 G26 5V GND + Grove Port +""" + +# WS2812 +WS2812_PIN = const(27) + +# Button +BUTTON_PIN = const(39) + +# IR +IR_PIN = const(12) + +# I2C +I2C0_SCL_PIN = const(21) +I2C0_SDA_PIN = const(25) + +# Grove port +GROVE_PORT_PIN = (const(26), const(32)) + + +class ATOM: + def __init__(self, np_n): + self._np = neopixel.NeoPixel(pin=Pin(WS2812_PIN), n=np_n) + self._btn = Pin(BUTTON_PIN, Pin.IN, Pin.PULL_UP) + + def get_button_status(self): + return self._btn.value() + + def set_button_callback(self, cb): + self._btn.irq(trigger=Pin.IRQ_FALLING, handler=cb) + + def set_pixel_color(self, num, r, g, b): + if num <= self._np.n: + self._np[num] = [r, g, b] + self._np.write() + + def get_pixel_color(self, num): + if num <= self._np.n: + return self._np[num] + + def set_pixels_color(self, r, g, b): + self._np.fill([r, g, b]) + self._np.write() + + +class Lite(ATOM): + # WS2812 number: 1 + def __init__(self): + super(Lite, self).__init__(np_n=1) + + +class Matrix(ATOM): + # WS2812 number: 25 + def __init__(self): + super(Matrix, self).__init__(np_n=25) diff --git a/ports/esp32/boards/M5STACK_ATOM/mpconfigboard.cmake b/ports/esp32/boards/M5STACK_ATOM/mpconfigboard.cmake new file mode 100644 index 000000000..548337a47 --- /dev/null +++ b/ports/esp32/boards/M5STACK_ATOM/mpconfigboard.cmake @@ -0,0 +1,10 @@ +set(SDKCONFIG_DEFAULTS + boards/sdkconfig.base + boards/sdkconfig.ble + boards/sdkconfig.240mhz + boards/M5STACK_ATOM/sdkconfig.board +) + +if(NOT MICROPY_FROZEN_MANIFEST) + set(MICROPY_FROZEN_MANIFEST ${MICROPY_BOARD_DIR}/manifest.py) +endif() diff --git a/ports/esp32/boards/M5STACK_ATOM/mpconfigboard.h b/ports/esp32/boards/M5STACK_ATOM/mpconfigboard.h new file mode 100644 index 000000000..4270b19ca --- /dev/null +++ b/ports/esp32/boards/M5STACK_ATOM/mpconfigboard.h @@ -0,0 +1,2 @@ +#define MICROPY_HW_BOARD_NAME "M5Stack ATOM" +#define MICROPY_HW_MCU_NAME "ESP32-PICO-D4" diff --git a/ports/esp32/boards/M5STACK_ATOM/sdkconfig.board b/ports/esp32/boards/M5STACK_ATOM/sdkconfig.board new file mode 100644 index 000000000..b299822dc --- /dev/null +++ b/ports/esp32/boards/M5STACK_ATOM/sdkconfig.board @@ -0,0 +1,5 @@ +CONFIG_FLASHMODE_QIO=y +CONFIG_ESPTOOLPY_FLASHFREQ_80M=y +CONFIG_SPIRAM_SPEED_80M=y +CONFIG_ESP32_REV_MIN_1=y +CONFIG_LWIP_LOCAL_HOSTNAME="M5StackATOM" |
