esp32/boards/LOLIN_S2_PICO: Add LOLIN_S2_PICO board definition files.

This commit is contained in:
Mike Causer 2021-10-27 19:01:18 +11:00 committed by Damien George
parent 1e4849557d
commit 3ace779e8e
7 changed files with 137 additions and 0 deletions

View File

@ -0,0 +1,18 @@
{
"deploy": [
"../deploy_s2.md"
],
"docs": "",
"features": [
"WiFi",
"USB-C"
],
"images": [
"lolin_s2_pico.jpg"
],
"mcu": "esp32s2",
"product": "S2 pico",
"thumbnail": "",
"url": "https://www.wemos.cc/en/latest/s2/s2_pico.html",
"vendor": "Wemos"
}

View File

@ -0,0 +1,4 @@
include("$(PORT_DIR)/boards/manifest.py")
freeze("./modules")
freeze("$(MPY_DIR)/drivers/display", "ssd1306.py")

View File

@ -0,0 +1,38 @@
# LOLIN S2 PICO MicroPython Helper Library
from micropython import const
from machine import Pin, I2C, Signal
from s2pico_oled import OLED
# Pin Assignments
# SPI
SPI_MOSI = const(35)
SPI_MISO = const(36)
SPI_CLK = const(37)
# I2C
I2C_SDA = const(8)
I2C_SCL = const(9)
# DAC
DAC1 = const(17)
DAC2 = const(18)
# LED
LED = const(10)
# OLED
OLED_RST = const(18)
# BUTTON
BUTTON = const(0)
# Helper methods for built in sensors
led = Signal(LED, Pin.OUT, value=0, invert=True)
button = Pin(BUTTON, Pin.IN, Pin.PULL_UP)
i2c = I2C(0)
oled = OLED(i2c, Pin(OLED_RST))

View File

@ -0,0 +1,48 @@
from time import sleep_ms
from ssd1306 import SSD1306_I2C
import network
class OLED(SSD1306_I2C):
def __init__(self, i2c, reset):
reset.init(reset.OUT, value=1)
self._reset = reset
self.reset(False)
super().__init__(128, 32, i2c)
def reset(self, reinit=True):
self._reset(1)
sleep_ms(1)
self._reset(0)
sleep_ms(10)
self._reset(1)
if reinit:
self.init_display()
def test(self):
self.fill(0)
self.fill_rect(0, 0, 32, 32, 1)
self.fill_rect(2, 2, 28, 28, 0)
self.vline(9, 8, 22, 1)
self.vline(16, 2, 22, 1)
self.vline(23, 8, 22, 1)
self.fill_rect(26, 24, 2, 4, 1)
self.text("MicroPython", 40, 0, 1)
self.text("SSD1306", 40, 12, 1)
self.text("OLED 128x32", 40, 24, 1)
self.show()
def display_wifi(self):
self.fill(0)
self.text("Scan...", 0, 0, 1)
self.show()
sta_if = network.WLAN(network.STA_IF)
sta_if.active(True)
_wifi = sta_if.scan()
self.fill(0)
self.text(str(len(_wifi)) + " Networks", 0, 0, 1)
self.text(str(_wifi[0][3]) + " " + (_wifi[0][0]).decode("utf-8"), 0, 12, 1)
self.text(str(_wifi[1][3]) + " " + (_wifi[1][0]).decode("utf-8"), 0, 24, 1)
self.show()

View File

@ -0,0 +1,11 @@
set(IDF_TARGET esp32s2)
set(SDKCONFIG_DEFAULTS
boards/sdkconfig.base
boards/sdkconfig.spiram_sx
boards/sdkconfig.usb
)
if(NOT MICROPY_FROZEN_MANIFEST)
set(MICROPY_FROZEN_MANIFEST ${MICROPY_BOARD_DIR}/manifest.py)
endif()

View File

@ -0,0 +1,12 @@
#define MICROPY_HW_BOARD_NAME "LOLIN_S2_PICO"
#define MICROPY_HW_MCU_NAME "ESP32-S2FN4R2"
#define MICROPY_PY_BLUETOOTH (0)
#define MICROPY_HW_ENABLE_SDCARD (0)
#define MICROPY_HW_I2C0_SCL (9)
#define MICROPY_HW_I2C0_SDA (8)
#define MICROPY_HW_SPI1_MOSI (35)
#define MICROPY_HW_SPI1_MISO (36)
#define MICROPY_HW_SPI1_SCK (37)

View File

@ -0,0 +1,6 @@
CONFIG_FLASHMODE_QIO=y
CONFIG_ESPTOOLPY_FLASHFREQ_80M=y
CONFIG_USB_AND_UART=y
# LWIP
CONFIG_LWIP_LOCAL_HOSTNAME="LOLIN_S2_PICO"
# end of LWIP