esp32/boards: Add support for LilyGO LoRa32 boards.

Boards use ESP32-PICO-D4.

Added pins for hardware versions v1.0, v1.2, v1.6 and v2.0.

Signed-off-by: Algy Tynan <algy@tynan.io>
This commit is contained in:
Algy Tynan 2022-03-15 18:18:42 +11:00 committed by Damien George
parent 09b55dc297
commit afceb56ee2
7 changed files with 154 additions and 0 deletions

View File

@ -0,0 +1,23 @@
{
"deploy": [
"../deploy.md"
],
"docs": "",
"features": [
"BLE",
"LoRa",
"OLED",
"SDCard",
"USB-MICRO",
"WiFi"
],
"id": "esp32",
"images": [
"lilygo-ttgo-lora-32-v1-6.jpg"
],
"mcu": "esp32",
"product": "LILYGO TTGO LoRa32",
"thumbnail": "",
"url": "http://www.lilygo.cn/prod_view.aspx?TypeId=50060&Id=1270&FId=t3:50060:3",
"vendor": "LILYGO"
}

View File

@ -0,0 +1,3 @@
The following files are daily firmware for the LILYGO TTGO LoRa32.
Support for hardware versions v1.0, v1.2, v1.6 and v2.0.

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,36 @@
from time import sleep_ms
from ssd1306 import SSD1306_I2C
import network
class OLED(SSD1306_I2C):
def __init__(self, i2c):
super().__init__(128, 32, i2c)
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,79 @@
"""LILYGO TTGO LoRa32 MicroPython Helper Library."""
from machine import Pin, SoftI2C, Signal
from lilygo_oled import OLED
from micropython import const
class Lora32Base:
"""Base class defining common pins."""
def __init__(self, define_helpers=True):
# LORA
self.LORA_MOSI = const(27)
self.LORA_MISO = const(19)
self.LORA_SCLK = const(5)
self.LORA_CS = const(18)
self.LORA_DIO = const(26)
self.LORA_RST = const(23)
# DAC
self.DAC1 = const(26)
# LED
self.LED = const(25)
# OLED
self.OLED_SDA = const(21)
self.OLED_SCL = const(22)
if define_helpers:
self.create_helpers()
def create_helpers(self):
self.led = Pin(self.LED, Pin.OUT)
self.i2c = SoftI2C(scl=Pin(self.OLED_SCL), sda=Pin(self.OLED_SDA))
self.oled = OLED(self.i2c)
class Lora32v1_0(Lora32Base):
"""Device Support for LILYGO TTGO LoRa32 v1.0."""
def __init__(self):
super().__init__(define_helpers=False)
# v1.0 has different pins for the following
self.LORA_RST = const(14)
self.OLED_SDA = const(4)
self.OLED_SCL = const(15)
# Also has a reset for the OLED that the others don't have
self.OLED_RST = const(16)
super().create_helpers()
class Lora32v1_2(Lora32Base):
"""Device Support for LILYGO TTGO LoRa32 v1.2 (T-Fox)."""
def __init__(self):
super().__init__()
# v1.2 Has a DS3231 RTC
self.DS3231_SDA = const(21)
self.DS3231_SCL = const(22)
class Lora32(Lora32Base):
"""Device Support for LILYGO TTGO LoRa32 v1.6 and v2.0."""
def __init__(self):
super().__init__()
# v1.6 and v2.0 support an SDCard
self.SD_CS = const(13)
self.SD_MOSI = const(15)
self.SD_MISO = const(2)
self.SD_SCLK = const(14)

View File

@ -0,0 +1,7 @@
set(SDKCONFIG_DEFAULTS
boards/sdkconfig.base
boards/sdkconfig.ble
)
if(NOT MICROPY_FROZEN_MANIFEST)
set(MICROPY_FROZEN_MANIFEST ${MICROPY_BOARD_DIR}/manifest.py)
endif()

View File

@ -0,0 +1,2 @@
#define MICROPY_HW_BOARD_NAME "LILYGO TTGO LoRa32"
#define MICROPY_HW_MCU_NAME "ESP32"