Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 11 additions & 33 deletions build/devices/esp32/targets/m5nanoc6/setup-target.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2024 Moddable Tech, Inc.
* Copyright (c) 2026 Moddable Tech, Inc., Satoshi Tanaka
*
* This file is part of the Moddable SDK Runtime.
*
Expand All @@ -20,46 +20,18 @@

import config from "mc/config";
import NeoPixel from "neopixel";
import Timer from "timer";
import Button from "button";
import LED from "led";
import Digital from "pins/digital";

class NeoPixelLED extends NeoPixel {
#value = 0;
constructor(options) {
// Enable RGB LED Power
const power = new Digital({
pin: config.led.rgb.power_pin,
mode: Digital.Output,
});
power.write(1);

super({
return new NeoPixel({
...options,
pin: config.led.rgb.data_pin,
length: 1,
order: "GRB",
});
super.brightness = config.led.rgb.brightness;
}
read() {
return this.#value;
}
write(value) {
this.#value = value;
if (value) {
super.setPixel(0, super.makeRGB(255, 255, 255));
} else {
super.setPixel(0, super.makeRGB(0, 0, 0));
}
super.update();
}
on() {
this.write(1);
}
off() {
this.write(0);
}
}

Expand All @@ -72,7 +44,7 @@ class BlueLED {
}
}

class Flash {
class buttonA {
constructor(options) {
return new Button({
...options,
Expand All @@ -90,13 +62,19 @@ globalThis.Host = Object.freeze(
Blue: BlueLED,
},
Button: {
Default: Flash,
Flash,
Default: buttonA,
a: buttonA,
},
},
true
);

export default function (done) {
// Enable RGB LED Power
const power = new Digital({
pin: config.led.rgb.power_pin,
mode: Digital.Output,
});
power.write(1);
done?.();
}
36 changes: 36 additions & 0 deletions build/devices/esp32/targets/m5nanoh2/host/provider.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*
*/

import I2C from "embedded:io/i2c";
import SMBus from "embedded:io/smbus";
import Digital from "embedded:io/digital";

const device = {
I2C: {
default: {
io: I2C,
data: 2,
clock: 1
}
},
io: {I2C, SMBus, Digital}
};

export default device;
48 changes: 48 additions & 0 deletions build/devices/esp32/targets/m5nanoh2/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"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": [
"$(MODULES)/drivers/button/manifest.json",
"$(MODULES)/drivers/led/manifest.json",
"$(MODULES)/drivers/neopixel/manifest.json"
],
"modules": {
"setup/target": "./setup-target"
},
"preload": [
"setup/target",
"neopixel"
],
"config": {
"screen": "",
"led": {
"rgb": {
"power_pin": 10,
"data_pin": 11,
"rainbow": false,
"brightness": 32
},
"blue": {
"pin": 4
}
}
},
"creation": {
"static": 0,
"chunk": {
"initial": 78848,
"incremental": 0
},
"heap": {
"initial": 4928,
"incremental": 0
},
"stack": 512
}
}
24 changes: 24 additions & 0 deletions build/devices/esp32/targets/m5nanoh2/sdkconfig/partitions.csv
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>.
#

# 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,
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
CONFIG_ESPTOOLPY_FLASHSIZE_2MB=n


80 changes: 80 additions & 0 deletions build/devices/esp32/targets/m5nanoh2/setup-target.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*
*/

import config from "mc/config";
import NeoPixel from "neopixel";
import Button from "button";
import LED from "led";
import Digital from "pins/digital";

class NeoPixelLED extends NeoPixel {
constructor(options) {
return new NeoPixel({
...options,
pin: config.led.rgb.data_pin,
length: 1,
order: "GRB",
});
}
}

class BlueLED {
constructor(options) {
return new LED({
...options,
pin: config.led.blue.pin,
});
}
}

class buttonA {
constructor(options) {
return new Button({
...options,
pin: 9,
invert: true,
});
}
}

globalThis.Host = Object.freeze(
{
LED: {
Default: NeoPixelLED,
RGB: NeoPixelLED,
Blue: BlueLED,
},
Button: {
Default: buttonA,
a: buttonA,
},
},
true
);

export default function (done) {
// Enable RGB LED Power
const power = new Digital({
pin: config.led.rgb.power_pin,
mode: Digital.Output,
});
power.write(1);
done?.();
}
Binary file added documentation/assets/devices/m5nanoh2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions documentation/devices/esp32.md
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ The Moddable SDK supports these ESP32-H2 development kits:
| Name | Platform identifier | Key features | Links |
| :---: | :--- | :--- | :--- |
| <img src="./../assets/devices/esp32-h2-devkitm.png" width=125><BR>ESP32-H2-DevKitM-1 | `esp32/esp32h2` | NeoPixel, Button | <li>[Product page](https://docs.espressif.com/projects/espressif-esp-dev-kits/en/latest/esp32h2/esp32-h2-devkitm-1/user_guide.html)</li> |
| <img src="./../assets/devices/m5nanoh2.png" width=125><BR>M5NanoH2 | `esp32/m5nanoh2` | LED, NeoPixel, Button | <li>[Product page](https://docs.m5stack.com/en/core/NanoH2)</li> |

<a id="platforms-manifest"></a>
### Specifying ESP32 Subclass in Manifest
Expand Down
5 changes: 5 additions & 0 deletions modules/io/manifests/esp32/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,11 @@
"embedded:provider/builtin": "$(SUBPLATFORMDIRECTORY)/host/provider"
}
},
"esp32/m5nanoh2": {
"modules": {
"embedded:provider/builtin": "$(SUBPLATFORMDIRECTORY)/host/provider"
}
},
"esp32/*": {
"include": [
"$(MODDABLE)/examples/manifest_net.json"
Expand Down