Skip to content

Commit 9b5f99e

Browse files
UnexpectedMakerdpgeorge
authored andcommitted
esp32/boards: Add UM_OMGS3 and UM_RGBTOUCH_MINI board definitions.
This adds two new UM boards: OMGS3 and RGB Touch Mini. Also fixed the NanoS3 deploy info. Signed-off-by: Seon Rozenblum <[email protected]>
1 parent d775db7 commit 9b5f99e

File tree

19 files changed

+410
-2
lines changed

19 files changed

+410
-2
lines changed

ports/esp32/boards/UM_NANOS3/deploy.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
Program your board using the latest version of the esptool.py program, found [here](https://github.com/espressif/esptool).
22

3-
To flash or erase your NanoS3, you have to first put it into download mode.
4-
To do this, follow these steps:
3+
To flash or erase your NANOS3, you have to first put it into download mode.
4+
NANOS3 doesn't include buttons for RESET and IO0, which should be provided by adding external buttons via a carrier board or other method.
5+
To put the NANOS3 into download, follow these steps:
56

67
- Press and hold the [BOOT] button
78
- Press and release the [RESET] button
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"deploy": [
3+
"deploy.md"
4+
],
5+
"docs": "",
6+
"features": [
7+
"Battery Charging",
8+
"RGB LED",
9+
"External RAM",
10+
"WiFi",
11+
"BLE"
12+
],
13+
"features_non_filterable": [
14+
"I2C BAT Fuel Gauge"
15+
],
16+
"id": "omgs3",
17+
"images": [
18+
"unexpectedmaker_omgs3.jpg"
19+
],
20+
"mcu": "esp32s3",
21+
"product": "OMGS3",
22+
"thumbnail": "",
23+
"url": "https://omgs3.io",
24+
"vendor": "Unexpected Maker"
25+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
The following files are firmware for the OMGS3.
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
Program your board using the latest version of the esptool.py program, found [here](https://github.com/espressif/esptool).
2+
3+
To flash or erase your OMGS3, you have to first put it into download mode.
4+
OMGS3 doesn't include buttons for RESET and IO0, which should be provided by adding external buttons via a carrier board or other method.
5+
To put the OMGS3 into download, follow these steps:
6+
7+
- Press and hold the [BOOT] button
8+
- Press and release the [RESET] button
9+
- Release the [BOOT] button
10+
11+
Now the board is in download mode and the native USB will have enumerated as a serial device.
12+
13+
If you are putting MicroPython on your board for the first time then you should
14+
first erase the entire flash using:
15+
16+
### Linux
17+
```bash
18+
esptool.py --chip esp32s3 --port /dev/ttyACM0 erase_flash
19+
```
20+
21+
### Mac
22+
Please do a `ls /dev/cu.usbm*` to determine the port your board has enumerated as.
23+
```bash
24+
esptool.py --chip esp32s3 --port /dev/cu.usbmodem01 erase_flash
25+
```
26+
27+
### Windows
28+
Change (X) to whatever COM port is being used by the board
29+
```bash
30+
esptool --chip esp32s3 --port COM(X) erase_flash
31+
```
32+
33+
Now download the version of the firmware you would like to install from the options below,
34+
then use the following command to program the firmware starting at address 0x0,
35+
remembering to replace `omgs3-micropython-firmware-version.bin` with the name of
36+
the firmware you just downloaded:
37+
38+
### Linux
39+
```bash
40+
esptool.py --chip esp32s3 --port /dev/ttyACM0 write_flash -z 0x0 omgs3-micropython-firmware-version.bin
41+
```
42+
43+
### Mac
44+
Please do a `ls /dev/cu.usbm*` to determine the port your board has enumerated as.
45+
```bash
46+
esptool.py --chip esp32s3 --port /dev/cu.usbmodem01 write_flash -z 0x0 omgs3-micropython-firmware-version.bin
47+
```
48+
49+
### Windows
50+
Change (X) to whatever COM port is being used by the board
51+
```bash
52+
esptool --chip esp32s3 --port COM(X) write_flash -z 0x0 omgs3-micropython-firmware-version.bin
53+
```
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
include("$(PORT_DIR)/boards/manifest.py")
2+
freeze("modules")
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# Basic MAX17048 library for OMGS3 and other Unexpected Maker products
2+
# MIT license; Copyright (c) 2024 Seon Rozenblum - Unexpected Maker
3+
#
4+
# Project home:
5+
# https://unexpectedmaker.com
6+
7+
from machine import I2C
8+
9+
10+
class MAX17048:
11+
_MAX17048_ADDRESS = 0x36
12+
13+
_VCELL_REGISTER = 0x02
14+
_SOC_REGISTER = 0x04
15+
_MODE_REGISTER = 0x06
16+
_VERSION_REGISTER = 0x08
17+
_HIBRT_REGISTER = 0x0A
18+
_CONFIG_REGISTER = 0x0C
19+
_COMMAND_REGISTER = 0xFE
20+
21+
def __init__(self, i2c, address=_MAX17048_ADDRESS):
22+
self.i2c = i2c
23+
self.address = address
24+
25+
def _read_register(self, register, num_bytes):
26+
result = self.i2c.readfrom_mem(self.address, register, num_bytes)
27+
return int.from_bytes(result, "big")
28+
29+
def _write_register(self, register, value, num_bytes):
30+
data = value.to_bytes(num_bytes, "big")
31+
self.i2c.writeto_mem(self.address, register, data)
32+
33+
@property
34+
def cell_voltage(self):
35+
"""The voltage of the connected cell in Volts."""
36+
raw_voltage = self._read_register(self._VCELL_REGISTER, 2)
37+
voltage = (raw_voltage >> 4) * 0.00125
38+
return voltage
39+
40+
@property
41+
def state_of_charge(self):
42+
"""The state of charge of the battery in percentage."""
43+
raw_soc = self._read_register(self._SOC_REGISTER, 2)
44+
return raw_soc / 256
45+
46+
@property
47+
def version(self):
48+
"""The chip version."""
49+
return self._read_register(self._VERSION_REGISTER, 2)
50+
51+
@property
52+
def hibernate(self):
53+
"""True if the chip is in hibernate mode, False otherwise."""
54+
hib = self._read_register(self._HIBRT_REGISTER, 2)
55+
return (hib & 0x4000) != 0
56+
57+
@hibernate.setter
58+
def hibernate(self, value):
59+
config = self._read_register(self._CONFIG_REGISTER, 2)
60+
if value:
61+
config |= 0x8000 # Set the sleep bit
62+
else:
63+
config &= ~0x8000 # Clear the sleep bit
64+
self._write_register(self._CONFIG_REGISTER, config, 2)
65+
66+
def quick_start(self):
67+
"""Perform a quick start to reset the SOC calculation in the chip."""
68+
self._write_register(self._MODE_REGISTER, 0x4000, 2)
69+
70+
def reset(self):
71+
"""Reset the chip."""
72+
self._write_register(self._COMMAND_REGISTER, 0x5400, 2)
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# OMGS3 Helper Library
2+
# MIT license; Copyright (c) 2024 Seon Rozenblum - Unexpected Maker
3+
#
4+
# Project home:
5+
# https://omgs3.io
6+
7+
# Import required libraries
8+
from micropython import const
9+
from machine import Pin, I2C
10+
from max17048 import MAX17048
11+
import time
12+
13+
# Initialize I2C bus
14+
fg_i2c = I2C(0, scl=Pin.board.I2C_SCL, sda=Pin.board.I2C_SDA)
15+
16+
# Create an instance of the MAX17048 class
17+
max17048 = MAX17048(fg_i2c)
18+
19+
20+
# Helper functions
21+
def get_bat_voltage():
22+
"""Read the battery voltage from the fuel gauge"""
23+
voltage = max17048.cell_voltage
24+
print(f"Bat Voltage: {voltage}V")
25+
return voltage
26+
27+
28+
def get_state_of_charge():
29+
"""Read the battery state of charge from the fuel gauge"""
30+
soc = max17048.state_of_charge
31+
print(f"State of Charge: {soc}%")
32+
return soc
33+
34+
35+
def get_vbus_present():
36+
"""Detect if VBUS (5V) power source is present"""
37+
return Pin(Pin.board.VBUS_SENSE, Pin.IN).value() == 1
38+
39+
40+
def set_pixel_power(state):
41+
"""Enable or Disable power to the onboard NeoPixel to either show colour, or to reduce power for deep sleep."""
42+
Pin(Pin.board.RGB_PWR, Pin.OUT).value(state)
43+
44+
45+
# NeoPixel rainbow colour wheel
46+
def rgb_color_wheel(wheel_pos):
47+
"""Color wheel to allow for cycling through the rainbow of RGB colors."""
48+
wheel_pos = wheel_pos % 255
49+
50+
if wheel_pos < 85:
51+
return 255 - wheel_pos * 3, 0, wheel_pos * 3
52+
elif wheel_pos < 170:
53+
wheel_pos -= 85
54+
return 0, wheel_pos * 3, 255 - wheel_pos * 3
55+
else:
56+
wheel_pos -= 170
57+
return wheel_pos * 3, 255 - wheel_pos * 3, 0
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
set(IDF_TARGET esp32s3)
2+
3+
set(SDKCONFIG_DEFAULTS
4+
boards/sdkconfig.base
5+
${SDKCONFIG_IDF_VERSION_SPECIFIC}
6+
boards/sdkconfig.usb
7+
boards/sdkconfig.ble
8+
boards/sdkconfig.240mhz
9+
boards/sdkconfig.spiram_sx
10+
boards/UM_OMGS3/sdkconfig.board
11+
)
12+
13+
set(MICROPY_FROZEN_MANIFEST ${MICROPY_BOARD_DIR}/manifest.py)
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#define MICROPY_HW_BOARD_NAME "OMGS3"
2+
#define MICROPY_HW_MCU_NAME "ESP32-S3-PICO-1-N8R2"
3+
#define MICROPY_PY_NETWORK_HOSTNAME_DEFAULT "OMGS3"
4+
5+
#define MICROPY_HW_I2C0_SCL (9)
6+
#define MICROPY_HW_I2C0_SDA (8)
7+
8+
#define MICROPY_HW_SPI1_MOSI (6)
9+
#define MICROPY_HW_SPI1_MISO (5)
10+
#define MICROPY_HW_SPI1_SCK (4)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
I2C_SCL,GPIO9
2+
I2C_SDA,GPIO8
3+
FG_INT,GPIO21
4+
RGB_DATA,GPIO35
5+
RGB_PWR,GPIO34
6+
UART0_TX,GPIO43
7+
UART0_RX,GPIO44
8+
VBUS_SENSE,GPIO33

0 commit comments

Comments
 (0)