diff --git a/build/devices/esp32/targets/m5nanoh2/host/provider.js b/build/devices/esp32/targets/m5nanoh2/host/provider.js new file mode 100644 index 000000000..6fe894dd9 --- /dev/null +++ b/build/devices/esp32/targets/m5nanoh2/host/provider.js @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2026 Satoshi Tanaka + * + * This file is part of the Moddable SDK Runtime. + * + * The Moddable SDK Runtime is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Moddable SDK Runtime is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Moddable SDK Runtime. If not, see . + * + */ + +import Digital from "embedded:io/digital"; +import I2C from "embedded:io/i2c"; +import PWM from "embedded:io/pwm"; +import SMBus from "embedded:io/smbus"; + +import Button from "button"; +import LED from "led/pwm"; +import LEDneopixel from "led/neopixel"; +import NeoPixel from "neopixel"; + +class ButtonFlash { + constructor(options) { + return new Button({ + ...options, + io: Digital, + pin: device.pin.button, + mode: Digital.InputPullUp, + activeLow: true + }); + } +} + +const device = { + I2C: { + default: { + io: I2C, + data: 2, + clock: 1 + } + }, + io: {Digital, I2C, PWM, SMBus}, + pin: { + button: 9, + buttonA: 9, + led: 11, + ledPower: 10, + ledBlue: 4, + IRTX: 3 + }, + peripheral: { + button: { + Default: ButtonFlash, + Flash: ButtonFlash + }, + led: { + RGB: class { + constructor(options) { + return new LEDneopixel({ + ...options, + neopixels: { + io: NeoPixel, + length: 1, + pin: device.pin.led, + order: "GRB", + brightness: 32 + }, + power: { + io: Digital, + pin: device.pin.ledPower + } + }); + } + }, + Blue: class { + constructor(options) { + return new LED({ + ...options, + io: PWM, + pin: device.pin.ledBlue + }); + } + } + } + } +}; +device.peripheral.led.Default = device.peripheral.led.RGB; + +export default device; diff --git a/build/devices/esp32/targets/m5nanoh2/manifest.json b/build/devices/esp32/targets/m5nanoh2/manifest.json new file mode 100644 index 000000000..ea2bc47f2 --- /dev/null +++ b/build/devices/esp32/targets/m5nanoh2/manifest.json @@ -0,0 +1,43 @@ +{ + "build": { + "ESP32_SUBCLASS": "esp32h2", + "USE_USB": "2", + "SDKCONFIGPATH": "./sdkconfig", + "PARTITIONS_FILE_FOR_TARGET": "./sdkconfig/partitions.csv", + "PROGRAMMING_MODE_MESSAGE": "INSTRUCTIONS: Hold the BOOT button and press then release the RST button.", + "BEFORE_DEBUGGING_MESSAGE": "Press and release the RST button." + }, + "include": [ + "$(MODDABLE)/modules/io/manifest.json", + "$(MODULES)/drivers/peripherals/button/manifest.json", + "$(MODULES)/drivers/peripherals/led/pwm/manifest.json", + "$(MODULES)/drivers/peripherals/led/neopixel/manifest.json" + ], + "modules": { + "setup/target": "./setup-target" + }, + "preload": [ + "setup/target" + ], + "config": { + "screen": "", + "led": { + "rgb": { + "rainbow": false, + "brightness": 32 + } + } + }, + "creation": { + "static": 0, + "chunk": { + "initial": 78848, + "incremental": 0 + }, + "heap": { + "initial": 4928, + "incremental": 0 + }, + "stack": 512 + } +} diff --git a/build/devices/esp32/targets/m5nanoh2/sdkconfig/partitions.csv b/build/devices/esp32/targets/m5nanoh2/sdkconfig/partitions.csv new file mode 100644 index 000000000..251bf913b --- /dev/null +++ b/build/devices/esp32/targets/m5nanoh2/sdkconfig/partitions.csv @@ -0,0 +1,24 @@ +# +# Copyright (c) 2016-2023 Moddable Tech, Inc. +# +# This file is part of the Moddable SDK Tools. +# +# The Moddable SDK Tools is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# The Moddable SDK Tools is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with the Moddable SDK Tools. If not, see . +# + +# Name, Type, SubType, Offset, Size, Flags +# Note: if you change the phy_init or app partition offset, make sure to change the offset in Kconfig.projbuild,,,, +nvs, data, nvs, 0x9000, 0x006000, +phy_init, data, phy, 0xf000, 0x001000, +factory, app, factory, 0x10000, 0x3E0000, diff --git a/build/devices/esp32/targets/m5nanoh2/sdkconfig/sdkconfig.defaults b/build/devices/esp32/targets/m5nanoh2/sdkconfig/sdkconfig.defaults new file mode 100644 index 000000000..70d3b27ae --- /dev/null +++ b/build/devices/esp32/targets/m5nanoh2/sdkconfig/sdkconfig.defaults @@ -0,0 +1,4 @@ +CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y +CONFIG_ESPTOOLPY_FLASHSIZE_2MB=n + + diff --git a/build/devices/esp32/targets/m5nanoh2/setup-target.js b/build/devices/esp32/targets/m5nanoh2/setup-target.js new file mode 100644 index 000000000..c7d0318a4 --- /dev/null +++ b/build/devices/esp32/targets/m5nanoh2/setup-target.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2026 Satoshi Tanaka + * + * This file is part of the Moddable SDK Runtime. + * + * The Moddable SDK Runtime is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Moddable SDK Runtime is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with the Moddable SDK Runtime. If not, see . + * + */ + +import config from "mc/config"; + +export default function (done) { + if (config.led?.rgb?.rainbow || config.led?.rainbow) { + const led = new device.peripheral.led.Default({}); + led.rainbow(3); + } + + done?.(); +} diff --git a/documentation/assets/devices/m5nanoh2.png b/documentation/assets/devices/m5nanoh2.png new file mode 100644 index 000000000..195e29587 Binary files /dev/null and b/documentation/assets/devices/m5nanoh2.png differ diff --git a/documentation/devices/esp32.md b/documentation/devices/esp32.md index 79637da52..4034c553a 100644 --- a/documentation/devices/esp32.md +++ b/documentation/devices/esp32.md @@ -246,6 +246,7 @@ The Moddable SDK supports these ESP32-H2 development kits: | Name | Platform identifier | Key features | Links | | :---: | :--- | :--- | :--- | |
ESP32-H2-DevKitM-1 | `esp32/esp32h2` | NeoPixel, Button |
  • [Product page](https://docs.espressif.com/projects/espressif-esp-dev-kits/en/latest/esp32h2/esp32-h2-devkitm-1/user_guide.html)
  • | +|
    M5NanoH2 | `esp32/m5nanoh2` | LED, NeoPixel, Button |
  • [Product page](https://docs.m5stack.com/en/core/NanoH2)
  • | ### Specifying ESP32 Subclass in Manifest