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
141 changes: 141 additions & 0 deletions build/devies/esp32/targets/m5atom_s3r/host/provider.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
/*
* Copyright (c) 2025 Moddable Tech, Inc.
*
* 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 Analog from "embedded:io/analog";
import Digital from "embedded:io/digital";
import DigitalBank from "embedded:io/digitalbank";
import I2C from "embedded:io/i2c";
import PulseCount from "embedded:io/pulsecount";
import PWM from "embedded:io/pwm";
import Serial from "embedded:io/serial";
import SMBus from "embedded:io/smbus";
import SPI from "embedded:io/spi";
import Timer from "timer";
import IMU from "embedded:sensor/Accelerometer-Gyroscope-Magnetometer/BMI270";

const ACCELERATION_SCALER = 1 / 9.80665;

class Backlight {
#io;

constructor(options) {
const io = this.#io = new SMBus({
...device.I2C.internal,
hz: 400_000,
address:48,
});

io.writeUint8(0x00, 0b01000000)
Timer.delay(1)
io.writeUint8(0x08, 0b00000001)
io.writeUint8(0x70, 0b00000000)
}
close() {
this.#io?.close();
this.#io = undefined;
}
set brightness(value) {
if (value <= 0) value = 0;
else if (value >= 1) value = 255;
else value *= 255;
this.#io.writeUint8(0x0e, value)
}
}

const device = {
I2C: {
default: {
io: I2C,
data: 2,
clock: 1,
},
internal: {
io: I2C,
data: 45,
clock: 0,
},
},
SPI: {
default: {
io: SPI,
port: 3,
clock: 15,
out: 21,
},
},
Analog: {
default: {
io: Analog,
pin: 8,
},
},
io: {
Analog,
Digital,
DigitalBank,
I2C,
PulseCount,
PWM,
Serial,
SMBus,
SPI,
},
pin: {
button: 41,
displaySelect: 14,
},
peripheral: {
Backlight: class {
constructor() {
return new Backlight();
}
},
},
sensor: {
IMU: class extends IMU {
constructor(options) {
super({
...options,
sensor: {
...device.I2C.internal,
address: 0x68,
io: device.io.SMBus,
},
});
}
sample() {
const sample = super.sample();

if (sample.accelerometer) {
[sample.accelerometer.x, sample.accelerometer.y] = [-sample.accelerometer.y * ACCELERATION_SCALER, sample.accelerometer.x * ACCELERATION_SCALER];
sample.accelerometer.z *= -ACCELERATION_SCALER;
}
if (sample.gyroscope) {
[sample.gyroscope.x, sample.gyroscope.y] = [-sample.gyroscope.y, sample.gyroscope.x];
sample.gyroscope.z *= -1;
}

return sample;
}
},
},
};

export default device;
94 changes: 94 additions & 0 deletions build/devies/esp32/targets/m5atom_s3r/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
{
"build":{
"ESP32_SUBCLASS": "esp32s3",
"USE_USB": "2",
"SDKCONFIGPATH": "./sdkconfig",
"PARTITIONS_FILE_FOR_TARGET": "./sdkconfig/partitions.csv",
"PROGRAMMING_MODE_MESSAGE": "INSTRUCTIONS: Press and hold the button until the LED lights.",
"BEFORE_DEBUGGING_MESSAGE": "Press and release the Reset button."
},
"include": [
"$(MODDABLE)/modules/io/manifest.json",
"$(MODDABLE)/modules/drivers/ili9341/manifest.json",
"$(MODDABLE)/modules/drivers/sensors/bmi270/manifest.json",
"$(MODULES)/drivers/button/manifest.json"
],
"modules": {
"*": [
"../m5stack_fire/m5button"
],
"setup/target": "./setup-target"
},
"preload": [
"setup/target",
"m5button"
],
"config": {
"screen": "ili9341",
"touch": ""
},
"creation": {
"static": 0,
"chunk": {
"initial": 78848,
"incremental": 0
},
"heap": {
"initial": 4928,
"incremental": 0
},
"stack": 512
},
"defines": {
"i2c": {
"sda_pin": 45,
"scl_pin": 0
},
"spi": {
"mosi_pin":21,
"sck_pin": 15
},
"ili9341": {
"hz": 27000000,
"width": 128,
"height": 128,
"cs_pin": 14,
"rst_pin": 48,
"dc_pin": 42,
"column_offset": 0,
"row_offset": 32,
"spi_port": "SPI3_HOST",
"registers": [
"0xFE, 0,",
"kDelayMS, 10,",
"0xEF, 0,",
"kDelayMS, 10,",
"0x36, 1, 0x08,",
"0xB0, 1, 0xC0,",
"0xB2, 1, 0x2F,",
"0xB3, 1, 0x03,",
"0xB6, 1, 0x19,",
"0xB7, 1, 0x01,",
"0xAC, 1, 0xCB,",
"0xAB, 1, 0x0E,",
"0xB4, 1, 0x04,",
"0xA8, 1, 0x19,",
"0x3A, 1, 0x05,",
"0xB8, 1, 0x08,",
"0xE8, 1, 0x24,",
"0xE9, 1, 0x48,",
"0xEA, 1, 0x22,",
"0xC6, 1, 0x30,",
"0xC7, 1, 0x18,",
"0xF0, 14, 0x1F,0x28,0x04,0x3E,0x2A,0x2E,0x20,0x00,0x0C,0x06,0x00,0x1C,0x1F,0x0F,",
"0xF1, 14, 0x00,0x2D,0x2F,0x3C,0x6F,0x1C,0x0B,0x00,0x00,0x00,0x07,0x0D,0x11,0x0F,",
"0x20, 0,",
"0x11, 0,",
"kDelayMS, 120,",
"0x29, 0,",
"kDelayMS, 20,",
"kDelayMS, 0"
]
}
}
}
84 changes: 84 additions & 0 deletions build/devies/esp32/targets/m5atom_s3r_cam/host/provider.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/*
* Copyright (c) 2021-2024 Moddable Tech, Inc.
*
* 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 Analog from "embedded:io/analog";
import Digital from "embedded:io/digital";
import DigitalBank from "embedded:io/digitalbank";
import I2C from "embedded:io/i2c";
import PulseCount from "embedded:io/pulsecount";
import PWM from "embedded:io/pwm";
import Serial from "embedded:io/serial";
import SMBus from "embedded:io/smbus";
import SPI from "embedded:io/spi";
import PulseWidth from "embedded:io/pulsewidth";
import IMU from "embedded:sensor/Accelerometer-Gyroscope-Magnetometer/BMI270";

const device = {
I2C: {
default: {
io: I2C,
data: 45,
clock: 0,
},
internal: {
io: I2C,
data: 45,
clock: 0,
}
},
Serial: {
default: {
io: Serial,
port: 1,
receive: 44,
transmit: 43
}
},
SPI: {
default: {
io: SPI,
clock: 36,
in: 37,
out: 35,
port: 2
}
},
io: {Analog, Digital, DigitalBank, I2C, PulseCount, PulseWidth, PWM, Serial, SMBus, SPI},
pin: {
//@@ button
button: 0
},
sensor: {
IMU: class {
constructor(options) {
return new IMU({
...options,
sensor: {
...device.I2C.internal,
address: 0x68,
io: device.io.SMBus
}
});
}
}
}
};

export default device;
63 changes: 63 additions & 0 deletions build/devies/esp32/targets/m5atom_s3r_cam/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{
"build": {
"SDKCONFIGPATH": "./sdkconfig",
"PARTITIONS_FILE_FOR_TARGET": "./sdkconfig/partitions.csv",
"ESP32_SUBCLASS": "esp32s3",
"USE_USB": "2"
},
"include": [
"$(MODDABLE)/modules/io/manifest.json",
"$(MODDABLE)/modules/drivers/sensors/bmi270/manifest.json",
"$(MODULES)/drivers/button/manifest.json"
],
"modules": {
"setup/target": "./setup-target"
},
"preload": [
"setup/target"
],
"config": {
"Screen": "",
"button_pin": 41,
"power_pin": 18,
"ir_pin": 47
},
"creation": {
"static": 0,
"chunk": {
"initial": 78848,
"incremental": 0
},
"heap": {
"initial": 4928,
"incremental": 0
},
"stack": 512
},
"defines": {
"i2c": {
"sda_pin": 45,
"scl_pin": 0
},
"camera": {
"powerdown": -1,
"reset": -1,
"xclk": 21,
"pclk": 40,
"href": 14,
"vsync": 10,
"scl": 9,
"sda": 12,
"i2c_port": 1,
"d0": 3,
"d1": 42,
"d2": 46,
"d3": 48,
"d4": 4,
"d5": 17,
"d6": 11,
"d7": 13
}
}
}

Loading