├── .github └── workflows │ ├── circuitpython.yml │ ├── t-call.yml │ ├── t-display.yml │ ├── t-displays3-amoled.yml │ ├── t-displays3.yml │ ├── t-echo.yml │ ├── t-picoc3.yml │ ├── t-rgb.yml │ ├── t-sim7000g.yml │ ├── t5-4.7-plus.yml │ ├── t5-4.7.yml │ └── t7-s3.yml ├── .gitignore ├── .travis.yml ├── LICENSE ├── Makefile ├── README.md ├── circuitpython └── circuitpython.mk ├── config_T-CALL ├── config_T-Display ├── config_T-DisplayS3 ├── config_T-DisplayS3-AMOLED ├── config_T-Echo ├── config_T-PicoC3 ├── config_T-RGB ├── config_T-SIM7000G ├── config_T5-4.7 ├── config_T5-4.7-Plus ├── config_T7-S3 ├── extmod ├── display │ ├── epd │ │ ├── Makefile │ │ ├── README.md │ │ ├── src │ │ │ ├── epd_epd47.c │ │ │ ├── font │ │ │ │ ├── FiraSans.h │ │ │ │ └── FiraSans │ │ │ │ │ ├── FiraSansBold12pt.h │ │ │ │ │ ├── FiraSansBold18pt.h │ │ │ │ │ ├── FiraSansBold24pt.h │ │ │ │ │ ├── FiraSansBold9pt.h │ │ │ │ │ ├── FiraSansBoldItalic12pt.h │ │ │ │ │ ├── FiraSansBoldItalic18pt.h │ │ │ │ │ ├── FiraSansBoldItalic24pt.h │ │ │ │ │ ├── FiraSansBoldItalic9pt.h │ │ │ │ │ ├── FiraSansBook12pt.h │ │ │ │ │ ├── FiraSansBook18pt.h │ │ │ │ │ ├── FiraSansBook24pt.h │ │ │ │ │ ├── FiraSansBook9pt.h │ │ │ │ │ ├── FiraSansBookItalic12pt.h │ │ │ │ │ ├── FiraSansBookItalic18pt.h │ │ │ │ │ ├── FiraSansBookItalic24pt.h │ │ │ │ │ ├── FiraSansBookItalic9pt.h │ │ │ │ │ ├── FiraSansEight12pt.h │ │ │ │ │ ├── FiraSansEight18pt.h │ │ │ │ │ ├── FiraSansEight24pt.h │ │ │ │ │ ├── FiraSansEight9pt.h │ │ │ │ │ ├── FiraSansEightItalic12pt.h │ │ │ │ │ ├── FiraSansEightItalic18pt.h │ │ │ │ │ ├── FiraSansEightItalic24pt.h │ │ │ │ │ ├── FiraSansEightItalic9pt.h │ │ │ │ │ ├── FiraSansExtraBold12pt.h │ │ │ │ │ ├── FiraSansExtraBold18pt.h │ │ │ │ │ ├── FiraSansExtraBold24pt.h │ │ │ │ │ ├── FiraSansExtraBold9pt.h │ │ │ │ │ ├── FiraSansExtraBoldItalic12pt.h │ │ │ │ │ ├── FiraSansExtraBoldItalic18pt.h │ │ │ │ │ ├── FiraSansExtraBoldItalic24pt.h │ │ │ │ │ ├── FiraSansExtraBoldItalic9pt.h │ │ │ │ │ ├── FiraSansExtraLight12pt.h │ │ │ │ │ ├── FiraSansExtraLight18pt.h │ │ │ │ │ ├── FiraSansExtraLight24pt.h │ │ │ │ │ ├── FiraSansExtraLight9pt.h │ │ │ │ │ ├── FiraSansExtraLightItalic12pt.h │ │ │ │ │ ├── FiraSansExtraLightItalic18pt.h │ │ │ │ │ ├── FiraSansExtraLightItalic24pt.h │ │ │ │ │ ├── FiraSansExtraLightItalic9pt.h │ │ │ │ │ ├── FiraSansFour12pt.h │ │ │ │ │ ├── FiraSansFour18pt.h │ │ │ │ │ ├── FiraSansFour24pt.h │ │ │ │ │ ├── FiraSansFour9pt.h │ │ │ │ │ ├── FiraSansFourItalic12pt.h │ │ │ │ │ ├── FiraSansFourItalic18pt.h │ │ │ │ │ ├── FiraSansFourItalic24pt.h │ │ │ │ │ ├── FiraSansFourItalic9pt.h │ │ │ │ │ ├── FiraSansHair12pt.h │ │ │ │ │ ├── FiraSansHair18pt.h │ │ │ │ │ ├── FiraSansHair24pt.h │ │ │ │ │ ├── FiraSansHair9pt.h │ │ │ │ │ ├── FiraSansHairItalic12pt.h │ │ │ │ │ ├── FiraSansHairItalic18pt.h │ │ │ │ │ ├── FiraSansHairItalic24pt.h │ │ │ │ │ ├── FiraSansHairItalic9pt.h │ │ │ │ │ ├── FiraSansHeavy12pt.h │ │ │ │ │ ├── FiraSansHeavy18pt.h │ │ │ │ │ ├── FiraSansHeavy24pt.h │ │ │ │ │ ├── FiraSansHeavy9pt.h │ │ │ │ │ ├── FiraSansHeavyItalic12pt.h │ │ │ │ │ ├── FiraSansHeavyItalic18pt.h │ │ │ │ │ ├── FiraSansHeavyItalic24pt.h │ │ │ │ │ ├── FiraSansHeavyItalic9pt.h │ │ │ │ │ ├── FiraSansItalic12pt.h │ │ │ │ │ ├── FiraSansItalic18pt.h │ │ │ │ │ ├── FiraSansItalic24pt.h │ │ │ │ │ ├── FiraSansItalic9pt.h │ │ │ │ │ ├── FiraSansLight12pt.h │ │ │ │ │ ├── FiraSansLight18pt.h │ │ │ │ │ ├── FiraSansLight24pt.h │ │ │ │ │ ├── FiraSansLight9pt.h │ │ │ │ │ ├── FiraSansLightItalic12pt.h │ │ │ │ │ ├── FiraSansLightItalic18pt.h │ │ │ │ │ ├── FiraSansLightItalic24pt.h │ │ │ │ │ ├── FiraSansLightItalic9pt.h │ │ │ │ │ ├── FiraSansMedium12pt.h │ │ │ │ │ ├── FiraSansMedium18pt.h │ │ │ │ │ ├── FiraSansMedium24pt.h │ │ │ │ │ ├── FiraSansMedium9pt.h │ │ │ │ │ ├── FiraSansMediumItalic12pt.h │ │ │ │ │ ├── FiraSansMediumItalic18pt.h │ │ │ │ │ ├── FiraSansMediumItalic24pt.h │ │ │ │ │ ├── FiraSansMediumItalic9pt.h │ │ │ │ │ ├── FiraSansRegular12pt.h │ │ │ │ │ ├── FiraSansRegular18pt.h │ │ │ │ │ ├── FiraSansRegular24pt.h │ │ │ │ │ ├── FiraSansRegular9pt.h │ │ │ │ │ ├── FiraSansSemiBold12pt.h │ │ │ │ │ ├── FiraSansSemiBold18pt.h │ │ │ │ │ ├── FiraSansSemiBold24pt.h │ │ │ │ │ ├── FiraSansSemiBold9pt.h │ │ │ │ │ ├── FiraSansSemiBoldItalic12pt.h │ │ │ │ │ ├── FiraSansSemiBoldItalic18pt.h │ │ │ │ │ ├── FiraSansSemiBoldItalic24pt.h │ │ │ │ │ ├── FiraSansSemiBoldItalic9pt.h │ │ │ │ │ ├── FiraSansThin12pt.h │ │ │ │ │ ├── FiraSansThin18pt.h │ │ │ │ │ ├── FiraSansThin24pt.h │ │ │ │ │ ├── FiraSansThin9pt.h │ │ │ │ │ ├── FiraSansThinItalic12pt.h │ │ │ │ │ ├── FiraSansThinItalic18pt.h │ │ │ │ │ ├── FiraSansThinItalic24pt.h │ │ │ │ │ ├── FiraSansThinItalic9pt.h │ │ │ │ │ ├── FiraSansTwo12pt.h │ │ │ │ │ ├── FiraSansTwo18pt.h │ │ │ │ │ ├── FiraSansTwo24pt.h │ │ │ │ │ ├── FiraSansTwo9pt.h │ │ │ │ │ ├── FiraSansTwoItalic12pt.h │ │ │ │ │ ├── FiraSansTwoItalic18pt.h │ │ │ │ │ ├── FiraSansTwoItalic24pt.h │ │ │ │ │ ├── FiraSansTwoItalic9pt.h │ │ │ │ │ ├── FiraSansUltra12pt.h │ │ │ │ │ ├── FiraSansUltra18pt.h │ │ │ │ │ ├── FiraSansUltra24pt.h │ │ │ │ │ ├── FiraSansUltra9pt.h │ │ │ │ │ ├── FiraSansUltraItalic12pt.h │ │ │ │ │ ├── FiraSansUltraItalic18pt.h │ │ │ │ │ ├── FiraSansUltraItalic24pt.h │ │ │ │ │ ├── FiraSansUltraItalic9pt.h │ │ │ │ │ ├── FiraSansUltraLight12pt.h │ │ │ │ │ ├── FiraSansUltraLight18pt.h │ │ │ │ │ ├── FiraSansUltraLight24pt.h │ │ │ │ │ ├── FiraSansUltraLight9pt.h │ │ │ │ │ ├── FiraSansUltraLightItalic12pt.h │ │ │ │ │ ├── FiraSansUltraLightItalic18pt.h │ │ │ │ │ ├── FiraSansUltraLightItalic24pt.h │ │ │ │ │ └── FiraSansUltraLightItalic9pt.h │ │ │ ├── micropython.cmake │ │ │ ├── micropython.mk │ │ │ ├── modepd.c │ │ │ └── modepd.h │ │ └── test │ │ │ ├── l58.py │ │ │ ├── logo.py │ │ │ └── main.py │ ├── framebuf1 │ │ ├── .gitignore │ │ ├── examples │ │ │ └── demo │ │ │ │ ├── FiraSansRegular10pt.py │ │ │ │ └── demo.py │ │ ├── manifest.py │ │ ├── src │ │ │ └── framebuf1.py │ │ ├── tests │ │ │ └── test_framebuf1.py │ │ └── tools │ │ │ ├── README.md │ │ │ └── fontconvert.py │ ├── framebuf_plus │ │ ├── Makefile │ │ └── src │ │ │ └── micropython.cmake │ ├── lcd │ │ ├── Makefile │ │ └── src │ │ │ └── micropython.cmake │ └── st7789 │ │ ├── Makefile │ │ └── src │ │ └── micropython.cmake ├── micropython.cmake ├── network │ ├── at │ │ ├── __init__.py │ │ ├── gprs.py │ │ ├── gps.py │ │ ├── manifest.py │ │ ├── modem.py │ │ ├── sim7000.py │ │ └── test │ │ │ ├── gps_test.py │ │ │ └── network_test.py │ └── gsm │ │ └── src │ │ ├── gsm_ppp.c │ │ ├── libGSM.c │ │ ├── libGSM.h │ │ ├── micropython.cmake │ │ ├── micropython.mk │ │ ├── modgsm.c │ │ └── modgsm.h ├── sensor │ └── bma │ │ ├── Makefile │ │ ├── patches │ │ └── 000-Adapt-to-micropython-v1.18.patch │ │ └── src │ │ └── micropython.cmake └── touch │ ├── l58.py │ └── manifest.py ├── include ├── download.mk └── package.mk ├── libs └── LilyGo-EPD47 │ ├── Makefile │ └── patches │ ├── 000-adapt-to-micropython.patch │ ├── 001-Add-deinitialized-interface.patch │ ├── 002-Modify-libjpeg.patch │ └── 003-adapt-to-esp-idf-v4.0.2.patch ├── micropython ├── micropython.mk ├── patches-v1.18 │ ├── 000-modify-partition-table.patch │ ├── 001-Added-EXTMOD_FROZEN_DIR-parameter.patch │ ├── 008-Added-MICROPY_BOARD_DIR-parameter.patch │ ├── 009-Add-T-PicoC3-board-file.patch │ ├── 010-Modify-makefile-of-rp2.patch │ ├── 011-Add-esp_lcd-component.patch │ └── 012-Automatically-download-ble-stack.patch ├── patches-v1.19 │ ├── 0001-Added-EXTMOD_FROZEN_DIR-parameter.patch │ ├── 0008-Added-MICROPY_BOARD_DIR-parameter.patch │ ├── 0009-Add-T-PicoC3-board-file.patch │ ├── 0010-Modify-makefile-of-rp2.patch │ ├── 0011-Add-esp_lcd-component.patch │ └── 0012-Automatically-download-ble-stack.patch └── patches │ ├── 000-modify-partition-table.patch │ ├── 001-Added-EXTMOD_FROZEN_DIR-parameter.patch │ ├── 002-Add-LILYGO_EPD47-board.patch │ ├── 003-Add-LILYGO_T-SIM7000G-board.patch │ ├── 004-Add-LILYGO_T-CALL-board.patch │ ├── 005-Integrate-framebuf1-module.patch │ ├── 006-Add-LILYGO_T-PicoC3-board.patch │ └── 007-Add-LILYGO-T5-4.7-plus.patch └── target ├── esp32 ├── boards │ ├── LILYGO_T-CALL │ │ ├── .gitignore │ │ ├── manifest.py │ │ ├── modules │ │ │ └── board.py │ │ ├── mpconfigboard.cmake │ │ ├── mpconfigboard.h │ │ └── sdkconfig.board │ ├── LILYGO_T-Display │ │ ├── .gitignore │ │ ├── board.json │ │ ├── board.md │ │ ├── mpconfigboard.cmake │ │ ├── mpconfigboard.h │ │ ├── partitions.csv │ │ └── sdkconfig.board │ ├── LILYGO_T-SIM7000G │ │ ├── .gitignore │ │ ├── mpconfigboard.cmake │ │ ├── mpconfigboard.h │ │ └── sdkconfig.board │ └── LILYGO_T5-4.7 │ │ ├── .gitignore │ │ ├── mpconfigboard.cmake │ │ ├── mpconfigboard.h │ │ ├── partitions.csv │ │ └── sdkconfig.board └── esp32.mk ├── esp32s3 ├── boards │ ├── LILYGO_T-DisplayS3-AMOLED │ │ ├── .gitignore │ │ ├── board.json │ │ ├── manifest.py │ │ ├── modules │ │ │ ├── inisetup.py │ │ │ ├── logo.py │ │ │ └── tft_config.py │ │ ├── mpconfigboard.cmake │ │ ├── mpconfigboard.h │ │ ├── partitions.csv │ │ └── sdkconfig.board │ ├── LILYGO_T-DisplayS3 │ │ ├── .gitignore │ │ ├── board.json │ │ ├── manifest.py │ │ ├── modules │ │ │ ├── inisetup.py │ │ │ └── logo.py │ │ ├── mpconfigboard.cmake │ │ ├── mpconfigboard.h │ │ ├── partitions.csv │ │ └── sdkconfig.board │ ├── LILYGO_T-RGB │ │ ├── .gitignore │ │ ├── board.json │ │ ├── manifest.py │ │ ├── modules │ │ │ ├── inisetup.py │ │ │ ├── logo.py │ │ │ ├── tft_config.py │ │ │ └── xl9535.py │ │ ├── mpconfigboard.cmake │ │ ├── mpconfigboard.h │ │ ├── partitions.csv │ │ └── sdkconfig.board │ ├── LILYGO_T5-4.7-PLUS │ │ ├── .gitignore │ │ ├── board.json │ │ ├── mpconfigboard.cmake │ │ ├── mpconfigboard.h │ │ ├── partitions.csv │ │ └── sdkconfig.board │ └── LILYGO_T7-S3 │ │ ├── .gitignore │ │ ├── board.json │ │ ├── mpconfigboard.cmake │ │ ├── mpconfigboard.h │ │ ├── partitions.csv │ │ └── sdkconfig.board └── esp32s3.mk ├── nrf ├── boards │ ├── LILYGO_T-Echo-circuitpython │ │ ├── board.c │ │ ├── mpconfigboard.h │ │ ├── mpconfigboard.mk │ │ └── pins.c │ └── LILYGO_T-Echo-micropython │ │ ├── board.json │ │ ├── modules │ │ ├── boardmodules.h │ │ ├── boardmodules.mk │ │ └── recover_uicr_regout0.c │ │ ├── mpconfigboard.h │ │ ├── mpconfigboard.mk │ │ └── pins.csv └── nrf.mk └── rp2 ├── boards └── LILYGO_T_PicoC3 │ ├── board.json │ ├── mpconfigboard.cmake │ └── mpconfigboard.h └── rp2.mk /.github/workflows/circuitpython.yml: -------------------------------------------------------------------------------- 1 | name: CircuitPython CI 2 | 3 | on: 4 | push: 5 | paths: 6 | - '' 7 | pull_request: 8 | paths: 9 | - '' 10 | 11 | jobs: 12 | build_t-echo: 13 | runs-on: ubuntu-20.04 14 | steps: 15 | - uses: actions/checkout@v2 16 | - name: Install packages 17 | run: sudo apt-get install git make python3 python3-pip cmake quilt 18 | - name: Install dependence 19 | run: sudo apt install gcc-arm-none-eabi libnewlib-arm-none-eabi build-essential 20 | - name: Build T-Echo 21 | run: | 22 | cp config_T-Echo config 23 | make 24 | - name: Deliver firmware 25 | uses: actions/upload-artifact@v2 26 | with: 27 | name: LILYGO_T-Echo_firmware 28 | path: ./bin/nrf/LILYGO_T-Echo/ 29 | -------------------------------------------------------------------------------- /.github/workflows/t-call.yml: -------------------------------------------------------------------------------- 1 | name: T-CALL CI 2 | 3 | on: 4 | push: 5 | paths: 6 | - 'target/esp32/boards/LILYGO_T-CALL/**' 7 | - 'target/esp32/esp32.mk' 8 | - '.github/workflows/t-call.yml' 9 | pull_request: 10 | paths: 11 | - 'target/esp32/boards/LILYGO_T-CALL/**' 12 | - 'target/esp32/esp32.mk' 13 | - '.github/workflows/t-call.yml' 14 | 15 | jobs: 16 | build_t-call: 17 | runs-on: ubuntu-20.04 18 | steps: 19 | - uses: actions/checkout@v3 20 | - name: Install packages 21 | run: sudo apt-get install git make python3 python3-pip cmake quilt 22 | - name: Build T-Call 23 | run: | 24 | cp config_T-CALL config 25 | make 26 | - name: Deliver firmware 27 | uses: actions/upload-artifact@v3 28 | with: 29 | name: LILYGO_T-CALL_firmware 30 | path: ./bin/esp32/LILYGO_T-CALL/ -------------------------------------------------------------------------------- /.github/workflows/t-display.yml: -------------------------------------------------------------------------------- 1 | name: T-Display CI 2 | 3 | on: 4 | push: 5 | paths: 6 | - 'target/esp32/boards/LILYGO_T-Display/**' 7 | - 'target/esp32/esp32.mk' 8 | - '.github/workflows/t-display.yml' 9 | pull_request: 10 | paths: 11 | - 'target/esp32/boards/LILYGO_T-Display/**' 12 | - 'target/esp32/esp32.mk' 13 | - '.github/workflows/t-display.yml' 14 | 15 | jobs: 16 | build_t-display: 17 | runs-on: ubuntu-20.04 18 | steps: 19 | - uses: actions/checkout@v3 20 | - name: Install packages 21 | run: sudo apt-get install git make python3 python3-pip cmake quilt 22 | - name: Build T-Display 23 | run: | 24 | cp config_T-Display config 25 | make 26 | - name: Deliver firmware 27 | uses: actions/upload-artifact@v3 28 | with: 29 | name: LILYGO_T-Display_firmware 30 | path: ./bin/esp32/LILYGO_T-Display/ -------------------------------------------------------------------------------- /.github/workflows/t-displays3-amoled.yml: -------------------------------------------------------------------------------- 1 | name: T-DisplayS3-AMOLED CI 2 | 3 | on: 4 | push: 5 | paths: 6 | - 'target/esp32s3/boards/LILYGO_T-DisplayS3-AMOLED/**' 7 | - 'target/esp32s3/esp32s3.mk' 8 | - '.github/workflows/t-displays3.yml' 9 | pull_request: 10 | paths: 11 | - 'target/esp32s3/boards/LILYGO_T-DisplayS3-AMOLED/**' 12 | - 'target/esp32s3/esp32s3.mk' 13 | - '.github/workflows/t-displays3.yml' 14 | 15 | jobs: 16 | build_t-displays3-amoled: 17 | runs-on: ubuntu-20.04 18 | steps: 19 | - uses: actions/checkout@v3 20 | - name: Install packages 21 | run: sudo apt-get install git make python3 python3-pip cmake quilt 22 | - name: Build T-DisplayS3-AMOLED 23 | run: | 24 | cp config_T-DisplayS3-AMOLED config 25 | make 26 | - name: Deliver firmware 27 | uses: actions/upload-artifact@v3 28 | with: 29 | name: LILYGO_T-DisplayS3-AMOLED_firmware 30 | path: ./bin/esp32s3/LILYGO_T-DisplayS3-AMOLED/ 31 | -------------------------------------------------------------------------------- /.github/workflows/t-displays3.yml: -------------------------------------------------------------------------------- 1 | name: T-DisplayS3 CI 2 | 3 | on: 4 | push: 5 | paths: 6 | - 'target/esp32s3/boards/LILYGO_T-DisplayS3/**' 7 | - 'target/esp32s3/esp32s3.mk' 8 | - '.github/workflows/t-displays3.yml' 9 | pull_request: 10 | paths: 11 | - 'target/esp32s3/boards/LILYGO_T-DisplayS3/**' 12 | - 'target/esp32s3/esp32s3.mk' 13 | - '.github/workflows/t-displays3.yml' 14 | 15 | jobs: 16 | build_t-displays3: 17 | runs-on: ubuntu-20.04 18 | steps: 19 | - uses: actions/checkout@v3 20 | - name: Install packages 21 | run: sudo apt-get install git make python3 python3-pip cmake quilt 22 | - name: Build T-DisplayS3 23 | run: | 24 | cp config_T-DisplayS3 config 25 | make 26 | - name: Deliver firmware 27 | uses: actions/upload-artifact@v3 28 | with: 29 | name: LILYGO_T-DisplayS3_firmware 30 | path: ./bin/esp32s3/LILYGO_T-DisplayS3/ -------------------------------------------------------------------------------- /.github/workflows/t-echo.yml: -------------------------------------------------------------------------------- 1 | name: T-Echo CI 2 | 3 | on: 4 | push: 5 | paths: 6 | - '' 7 | pull_request: 8 | paths: 9 | - '' 10 | 11 | jobs: 12 | build_t-echo: 13 | runs-on: ubuntu-20.04 14 | steps: 15 | - uses: actions/checkout@v3 16 | - name: Install packages 17 | run: sudo apt-get install git make python3 python3-pip cmake quilt 18 | - name: Build T-Echo 19 | run: | 20 | cp config_T-Echo config 21 | make 22 | - name: Deliver firmware 23 | uses: actions/upload-artifact@v3 24 | with: 25 | name: LILYGO_T-Echo_firmware 26 | path: ./bin/nrf/LILYGO_T-Echo/ 27 | -------------------------------------------------------------------------------- /.github/workflows/t-picoc3.yml: -------------------------------------------------------------------------------- 1 | name: T-PicoC3 CI 2 | 3 | on: 4 | push: 5 | paths: 6 | - 'target/rp2/boards/LILYGO_T_PicoC3/**' 7 | - 'target/rp2/rp2.mk' 8 | - '.github/workflows/t-picoc3.yml' 9 | pull_request: 10 | paths: 11 | - 'target/rp2/boards/LILYGO_T_PicoC3/**' 12 | - 'target/rp2/rp2.mk' 13 | - '.github/workflows/t-picoc3.yml' 14 | 15 | jobs: 16 | build_t-picoc3: 17 | runs-on: ubuntu-20.04 18 | steps: 19 | - uses: actions/checkout@v3 20 | - name: Install packages 21 | run: sudo apt-get install git make python3 python3-pip cmake quilt 22 | - name: Build T-PicoC3 23 | run: | 24 | cp config_T-PicoC3 config 25 | sudo apt install gcc-arm-none-eabi libnewlib-arm-none-eabi build-essential 26 | make 27 | - name: Deliver firmware 28 | uses: actions/upload-artifact@v3 29 | with: 30 | name: LILYGO_T_PicoC3_firmware 31 | path: ./bin/rp2/LILYGO_T_PicoC3/ -------------------------------------------------------------------------------- /.github/workflows/t-rgb.yml: -------------------------------------------------------------------------------- 1 | name: T-RGB CI 2 | 3 | on: 4 | push: 5 | paths: 6 | - 'target/esp32s3/boards/LILYGO_T-/**' 7 | - 'target/esp32s3/esp32s3.mk' 8 | - '.github/workflows/t-displays3.yml' 9 | pull_request: 10 | paths: 11 | - 'target/esp32s3/boards/LILYGO_T-RGB/**' 12 | - 'target/esp32s3/esp32s3.mk' 13 | - '.github/workflows/t-displays3.yml' 14 | 15 | jobs: 16 | build_t-rgb: 17 | runs-on: ubuntu-20.04 18 | steps: 19 | - uses: actions/checkout@v3 20 | - name: Install packages 21 | run: sudo apt-get install git make python3 python3-pip cmake quilt 22 | - name: Build T-RGB 23 | run: | 24 | cp config_T-RGB config 25 | make 26 | - name: Deliver firmware 27 | uses: actions/upload-artifact@v3 28 | with: 29 | name: LILYGO_T-RGB_firmware 30 | path: ./bin/esp32s3/LILYGO_T-RGB/ -------------------------------------------------------------------------------- /.github/workflows/t-sim7000g.yml: -------------------------------------------------------------------------------- 1 | name: T-SIM7000G CI 2 | 3 | on: 4 | push: 5 | paths: 6 | - 'target/esp32/boards/LILYGO_T-SIM7000G/**' 7 | - 'target/esp32/esp32.mk' 8 | - '.github/workflows/t-sim7000g.yml' 9 | pull_request: 10 | paths: 11 | - 'target/esp32/boards/LILYGO_T-SIM7000G/**' 12 | - 'target/esp32/esp32.mk' 13 | - '.github/workflows/t-sim7000g.yml' 14 | 15 | jobs: 16 | build_t-sim7000g: 17 | runs-on: ubuntu-20.04 18 | steps: 19 | - uses: actions/checkout@v3 20 | - name: Install packages 21 | run: sudo apt-get install git make python3 python3-pip cmake quilt 22 | - name: Build T-SIM7000G 23 | run: | 24 | cp config_T-SIM7000G config 25 | make 26 | - name: Deliver firmware 27 | uses: actions/upload-artifact@v3 28 | with: 29 | name: LILYGO_T-SIM7000G_firmware 30 | path: ./bin/esp32/LILYGO_T-SIM7000G/ -------------------------------------------------------------------------------- /.github/workflows/t5-4.7-plus.yml: -------------------------------------------------------------------------------- 1 | name: T5-4.7 PLUS CI 2 | 3 | on: 4 | push: 5 | paths: 6 | - 'target/esp32s3/boards/LILYGO_T5-4.7-PLUS/**' 7 | - 'target/esp32s3/esp32s3.mk' 8 | - '.github/workflows/t5-4.7-plus.yml' 9 | pull_request: 10 | paths: 11 | - 'target/esp32s3/boards/LILYGO_T5-4.7-PLUS/**' 12 | - 'target/esp32s3/esp32s3.mk' 13 | - '.github/workflows/t5-4.7-plus.yml' 14 | 15 | jobs: 16 | build_t5-47-plus: 17 | runs-on: ubuntu-20.04 18 | steps: 19 | - uses: actions/checkout@v3 20 | - name: Install packages 21 | run: sudo apt-get install git make python3 python3-pip cmake quilt 22 | - name: Build T5-4.7 Plus 23 | run: | 24 | cp config_T5-4.7-Plus config 25 | make 26 | - name: Deliver firmware 27 | uses: actions/upload-artifact@v3 28 | with: 29 | name: LILYGO_T5-4.7-PLUS_firmware 30 | path: ./bin/esp32s3/LILYGO_T5-4.7-PLUS/ -------------------------------------------------------------------------------- /.github/workflows/t5-4.7.yml: -------------------------------------------------------------------------------- 1 | name: T5-4.7 CI 2 | 3 | on: 4 | push: 5 | paths: 6 | - 'target/esp32/boards/LILYGO_T5-4.7/**' 7 | - 'target/esp32/esp32.mk' 8 | - '.github/workflows/t5-4.7.yml' 9 | pull_request: 10 | paths: 11 | - 'target/esp32/boards/LILYGO_T5-4.7/**' 12 | - 'target/esp32/esp32.mk' 13 | - '.github/workflows/t5-4.7.yml' 14 | 15 | jobs: 16 | build_t5-47: 17 | runs-on: ubuntu-20.04 18 | steps: 19 | - uses: actions/checkout@v3 20 | - name: Install packages 21 | run: sudo apt-get install git make python3 python3-pip cmake quilt 22 | - name: Build T5-4.7 23 | run: | 24 | cp config_T5-4.7 config 25 | make 26 | - name: Deliver firmware 27 | uses: actions/upload-artifact@v3 28 | with: 29 | name: LILYGO_T5-4.7_firmware 30 | path: ./bin/esp32/LILYGO_T5-4.7/ -------------------------------------------------------------------------------- /.github/workflows/t7-s3.yml: -------------------------------------------------------------------------------- 1 | name: T7-S3 CI 2 | 3 | on: 4 | push: 5 | paths: 6 | - 'target/esp32s3/boards/LILYGO_T7-S3/**' 7 | - 'target/esp32s3/esp32s3.mk' 8 | - '.github/workflows/t-displays3.yml' 9 | pull_request: 10 | paths: 11 | - 'target/esp32s3/boards/LILYGO_T7-S3/**' 12 | - 'target/esp32s3/esp32s3.mk' 13 | - '.github/workflows/t-displays3.yml' 14 | 15 | jobs: 16 | build_t7-s3: 17 | runs-on: ubuntu-20.04 18 | steps: 19 | - uses: actions/checkout@v3 20 | - name: Install packages 21 | run: sudo apt-get install git make python3 python3-pip cmake quilt 22 | - name: Build T7-S3 23 | run: | 24 | cp config_T7-S3 config 25 | make 26 | - name: Deliver firmware 27 | uses: actions/upload-artifact@v3 28 | with: 29 | name: LILYGO_T7-S3_firmware 30 | path: ./bin/esp32s3/LILYGO_T7-S3/ -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .vscode 2 | build_dir 3 | tmp 4 | bin 5 | dl 6 | config -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: c 2 | 3 | branches: 4 | only: 5 | - master 6 | 7 | 8 | jobs: 9 | include: 10 | - stage: micropython_build 11 | env: NAME="micropython build" 12 | install: 13 | - sudo apt-get update 14 | - sudo apt-get install git make python3 python3-pip cmake 15 | script: 16 | - cp config_T5-4.7 config 17 | - make 18 | - cp config_T-CALL config 19 | - make 20 | - cp config_T-SIM7000G config 21 | - make 22 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | SHELL:=/bin/bash 2 | 3 | TOP_DIR:=$(shell pwd) 4 | TMP_DIR:=$(TOP_DIR)/tmp 5 | DL_DIR:=$(TOP_DIR)/dl 6 | INCLUDE_DIR:=$(TOP_DIR)/include 7 | BUILD_DIR:=$(TOP_DIR)/build_dir 8 | BIN_DIR:=$(TOP_DIR)/bin 9 | 10 | LOG_LEVEL := $(if $(V),$(V),1) 11 | ifeq ($(LOG_LEVEL),1) 12 | LOG_LEVEL := @ 13 | else 14 | LOG_LEVEL := 15 | endif 16 | 17 | include config 18 | 19 | TARGET:=$(if $(CONFIG_TARGET),$(CONFIG_TARGET),esp32) 20 | BOARD:=$(if $(CONFIG_BOARD),$(CONFIG_BOARD),GENERIC_SPIRAM) 21 | MICROPYTHON_CORE:=$(if $(CONFIG_MICROPYTHON_CORE),$(CONFIG_MICROPYTHON_CORE),micropython) 22 | 23 | TARGET_BUILD_DIR:=$(BUILD_DIR)/$(TARGET) 24 | 25 | export TMP_DIR DL_DIR INCLUDE_DIR BUILD_DIR TARGET_BUILD_DIR TOP_DIR SHELL LOG_LEVEL 26 | 27 | include $(TOP_DIR)/target/$(TARGET)/$(TARGET).mk 28 | include $(TOP_DIR)/$(MICROPYTHON_CORE)/$(MICROPYTHON_CORE).mk 29 | 30 | # $(foreach var, $(dir), make -C $(shell dirname $(var));) 31 | # make -C $(TOP_DIR)/target/$(TARGET) 32 | # $(call micropython/prereq) 33 | 34 | all: prereq $(MICROPYTHON_CORE) extmod 35 | $(call $(TARGET)/prereq) 36 | $(call $(TARGET)/compile) 37 | $(call $(TARGET)/install) 38 | 39 | .PHONY: micropython 40 | micropython: 41 | $(LOG_LEVEL)echo "Prepare micropython source code ..." 42 | $(call micropython/prereq) 43 | $(LOG_LEVEL)echo "Prepare micropython source code ... ok" 44 | 45 | .PHONY: circuitpython 46 | circuitpython: 47 | $(LOG_LEVEL)echo "Prepare circuitpython source code ..." 48 | $(call circuitpython/prereq) 49 | $(LOG_LEVEL)echo "Prepare circuitpython source code ... ok" 50 | 51 | .PHONY: extmod 52 | extmod: 53 | $(LOG_LEVEL)echo "Prepare expansion module ..." 54 | $(foreach var, $(shell find extmod -name Makefile), make -C $(shell dirname $(var));) 55 | $(LOG_LEVEL)echo "Prepare expansion module ... ok" 56 | 57 | .PHONY: prereq 58 | prereq: 59 | $(LOG_LEVEL)echo "Prepare working directory ..." 60 | $(LOG_LEVEL)if [ ! -d $(TMP_DIR) ]; then \ 61 | mkdir -p $(TMP_DIR); \ 62 | fi 63 | $(LOG_LEVEL)if [ ! -d $(DL_DIR) ]; then \ 64 | mkdir -p $(DL_DIR); \ 65 | fi 66 | $(LOG_LEVEL)if [ ! -d $(TARGET_BUILD_DIR) ]; then \ 67 | mkdir -p $(TARGET_BUILD_DIR); \ 68 | fi 69 | $(LOG_LEVEL)if [ ! -d $(BIN_DIR) ]; then \ 70 | mkdir -p $(BIN_DIR); \ 71 | fi 72 | $(LOG_LEVEL)echo "Prepare working directory ... ok" 73 | 74 | 75 | .PHONY: clean 76 | clean: 77 | $(LOG_LEVEL)echo "Clear working directory ..." 78 | $(LOG_LEVEL)rm -rf $(TARGET_BUILD_DIR)/build-$(BOARD) 79 | $(LOG_LEVEL)echo "Clear working directory ... ok" 80 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # LilyGo MicroPython 2 | 3 | # Index 4 | 5 | - [1. Install Prerequisites](#install-prerequisites) 6 | - [2. Supported Boards](#supported-boards) 7 | - [3. Build](#build) 8 | - [3.1 T-SIM7000G](#t-sim7000g) 9 | - [3.1 T5-4.7](#t5-47) 10 | - [3.2 T-CALL SIM800](#t-call-sim800) 11 | - [3.3 T-PicoC3](#t-picoc3) 12 | - [3.4 T5-4.7 Plus](#t5-47-plus) 13 | - [3.5 T-Echo](#t-echo) 14 | - [3.6 T-Display](#t-display) 15 | - [3.7 T-DisplayS3](#t-displays3) 16 | - [3.8 T-RGB](#t-rgb) 17 | - [3.9 T7-S3](#t7-s3) 18 | - [3.10 T-DisplayS3-AMOLED](#t-displays3-amoled) 19 | - [4. Modules](#modules) 20 | - [4.1 Display Module](#display-module) 21 | - [5. Interesting Project](#interesting-project) 22 | - [6. Issue](#issue) 23 | - [7. Future plans](#future-plans) 24 | 25 | --- 26 | 27 | ## Install Prerequisites 28 | 29 | To compile with lilygo-micropython you need to get the following packages. The command to run depends on which distribution of Linux you are using: 30 | 31 | - Ubuntu and Debian: 32 | 33 | ``` 34 | sudo apt-get install git make python3 python3-pip cmake quilt 35 | ``` 36 | 37 | ## Supported Boards 38 | 39 | - LILYGO T-SIM7000G 40 | - LILYGO T5-4.7 41 | - LILYGO T-T-CALL SIM800 42 | - LILYGO T-PicoC3 43 | - LILYGO T5-4.7 Plus (esp32s3) 44 | - LILYGO T-Echo 45 | - LILYGO T-Display 46 | - LILYGO T-DisplayS3 47 | - LILYGO T-RGB 48 | - LILYGO T7-S3 49 | - LILYGO T-DisplayS3-AMOLED 50 | 51 | ## Build 52 | 53 | ### T-SIM7000G 54 | 55 | ```shell 56 | $ cp config_T-SIM7000G config 57 | $ make 58 | ``` 59 | 60 | ### T5-4.7 61 | 62 | ```shell 63 | $ cp config_T5-4.7 config 64 | $ make 65 | ``` 66 | 67 | ### T-CALL SIM800 68 | 69 | ```shell 70 | $ cp config_T-CALL config 71 | $ make 72 | ``` 73 | 74 | ### T-PicoC3 75 | 76 | ```shell 77 | $ cp config_T-PicoC3 config 78 | $ sudo apt install gcc-arm-none-eabi libnewlib-arm-none-eabi build-essential 79 | $ make 80 | ``` 81 | 82 | ### T5-4.7 Plus 83 | 84 | ```shell 85 | $ cp config_T5-4.7-Plus config 86 | $ make 87 | ``` 88 | 89 | ### T-Echo 90 | 91 | ```shell 92 | $ cp config_T-Echo config 93 | $ make 94 | ``` 95 | 96 | > Use circuitpython by default 97 | 98 | To use micropython, you need to modify the config file: 99 | 100 | ```diff 101 | --- config_T-Echo 2022-07-13 17:11:04.374660308 +0800 102 | +++ config 2022-07-13 17:11:00.694565940 +0800 103 | @@ -1,3 +1,3 @@ 104 | CONFIG_TARGET=nrf 105 | CONFIG_BOARD=LILYGO_T-Echo 106 | -CONFIG_MICROPYTHON_CORE=circuitpython 107 | +# CONFIG_MICROPYTHON_CORE=circuitpython 108 | ``` 109 | 110 | ### T-Display 111 | 112 | ```shell 113 | $ cp config_T-Display config 114 | $ make 115 | ``` 116 | 117 | ### T-DisplayS3 118 | 119 | ```shell 120 | $ cp config_T-DisplayS3 config 121 | $ make 122 | ``` 123 | 124 | ### T-RGB 125 | 126 | ```shell 127 | $ cp config_T-RGB config 128 | $ make 129 | ``` 130 | 131 | ### T7-S3 132 | 133 | ```shell 134 | $ cp config_T7-S3 config 135 | $ make 136 | ``` 137 | 138 | ### T-DisplayS3-AMOLED 139 | 140 | ```shell 141 | $ cp config_T-DisplayS3-AMOLED config 142 | $ make 143 | ``` 144 | 145 | ## Modules 146 | 147 | ### Display Module 148 | 149 | - [epd](./extmod/display/epd/README.md): [LilyGo-EPD47](https://github.com/Xinyuan-LilyGO/LilyGo-EPD47) using in micropython. 150 | - [framebuf1](./extmod/display/framebuf1/): This module provides a general frame buffer which can be used to epd module. 151 | - [st7789](./extmod/display/st7789/): Fast MicroPython driver for ST7789 display module written in C. 152 | - [bma](./extmod/sensor/bma/): micropython driver library for bma423 153 | - [lcd](./extmod/display/lcd/): Driver library supporting I8080 and RGB interface 154 | - [framebuf_plus](extmod/display/framebuf_plus): Added gfx font support on the basis of [framebuf](https://docs.micropython.org/en/latest/library/framebuf.html). 155 | 156 | ## Interesting Project 157 | 158 | [LilyGo-EPD-4-7-OWM-Weather-Display](https://github.com/Xinyuan-LilyGO/LilyGo-EPD-4-7-OWM-Weather-Display/tree/web/micropython): Using the LilyGo EPD 4.7" display to show OWM Weather Data 159 | 160 | ## Issue 161 | 162 | ### 1. Compilation error caused by ninja 163 | 164 | Compilation gives the following error: 165 | 166 | ``` 167 | ninja: build stopped: subcommand failed. 168 | ninja failed with exit code 1 169 | make[1]: *** [Makefile:42: all] Error 2 170 | make[1]: Leaving directory '/home/scruss/c/lilygo-micropython/build_dir/esp32s3/micropython/ports/esp32' 171 | make: *** [Makefile:36: all] Error 2 172 | ``` 173 | 174 | Please uninstall ninja and try to compile again 175 | 176 | ```shell 177 | sudo apt remove ninja-build 178 | rm build_dir -rf 179 | ``` 180 | 181 | ## Future plans 182 | 183 | - Support menuconfig 184 | - More boards 185 | - Complete development documentation 186 | -------------------------------------------------------------------------------- /circuitpython/circuitpython.mk: -------------------------------------------------------------------------------- 1 | 2 | include $(INCLUDE_DIR)/download.mk 3 | include $(INCLUDE_DIR)/package.mk 4 | 5 | define circuitpython/info 6 | PKG_NAME:=circuitpython 7 | PKG_SOURCE_URL:=https://github.com/adafruit/circuitpython.git 8 | PKG_SOURCE_PROTO:=git 9 | PKG_SOURCE_VERSION:=7.3.1 10 | PKG_SOURCE_MD5:=639c7fcbe62a8252cf9367147d94c150 11 | # PKG_SOURCE_OPT:=--recurse-submodules --depth=1 12 | endef 13 | 14 | define circuitpython/prereq 15 | $(eval $(circuitpython/info)) 16 | $(call Package/prereq,$(TARGET_BUILD_DIR)) 17 | $(call Package/patches,$(TARGET_BUILD_DIR)/$(PKG_NAME),$(TOP_DIR)/$(PKG_NAME)/patches-$(PKG_SOURCE_VERSION)) 18 | endef 19 | -------------------------------------------------------------------------------- /config_T-CALL: -------------------------------------------------------------------------------- 1 | CONFIG_TARGET=esp32 2 | CONFIG_BOARD=LILYGO_T-CALL -------------------------------------------------------------------------------- /config_T-Display: -------------------------------------------------------------------------------- 1 | CONFIG_TARGET=esp32 2 | CONFIG_BOARD=LILYGO_T-Display -------------------------------------------------------------------------------- /config_T-DisplayS3: -------------------------------------------------------------------------------- 1 | CONFIG_TARGET=esp32s3 2 | CONFIG_BOARD=LILYGO_T-DisplayS3 3 | -------------------------------------------------------------------------------- /config_T-DisplayS3-AMOLED: -------------------------------------------------------------------------------- 1 | CONFIG_TARGET=esp32s3 2 | CONFIG_BOARD=LILYGO_T-DisplayS3-AMOLED -------------------------------------------------------------------------------- /config_T-Echo: -------------------------------------------------------------------------------- 1 | CONFIG_TARGET=nrf 2 | CONFIG_BOARD=LILYGO_T-Echo 3 | CONFIG_MICROPYTHON_CORE=circuitpython 4 | -------------------------------------------------------------------------------- /config_T-PicoC3: -------------------------------------------------------------------------------- 1 | CONFIG_TARGET=rp2 2 | CONFIG_BOARD=LILYGO_T_PicoC3 -------------------------------------------------------------------------------- /config_T-RGB: -------------------------------------------------------------------------------- 1 | CONFIG_TARGET=esp32s3 2 | CONFIG_BOARD=LILYGO_T-RGB 3 | -------------------------------------------------------------------------------- /config_T-SIM7000G: -------------------------------------------------------------------------------- 1 | CONFIG_TARGET=esp32 2 | CONFIG_BOARD=LILYGO_T-SIM7000G -------------------------------------------------------------------------------- /config_T5-4.7: -------------------------------------------------------------------------------- 1 | CONFIG_TARGET=esp32 2 | CONFIG_BOARD=LILYGO_T5-4.7 -------------------------------------------------------------------------------- /config_T5-4.7-Plus: -------------------------------------------------------------------------------- 1 | CONFIG_TARGET=esp32s3 2 | CONFIG_BOARD=LILYGO_T5-4.7-PLUS 3 | -------------------------------------------------------------------------------- /config_T7-S3: -------------------------------------------------------------------------------- 1 | CONFIG_TARGET=esp32s3 2 | CONFIG_BOARD=LILYGO_T7-S3 3 | -------------------------------------------------------------------------------- /extmod/display/epd/Makefile: -------------------------------------------------------------------------------- 1 | 2 | define epd/info 3 | PKG_NAME:=epd 4 | PKG_DEPEND:=LilyGo-EPD47 5 | endef 6 | 7 | include $(INCLUDE_DIR)/download.mk 8 | include $(INCLUDE_DIR)/package.mk 9 | 10 | # PKG_DEPEND:=LilyGo-EPD47 11 | # $(foreach var, $(PKG_DEPEND), make -C $(TOP_DIR)/libs/$(var);) 12 | all: 13 | $(eval $(epd/info)) 14 | $(call Package/depend) -------------------------------------------------------------------------------- /extmod/display/epd/README.md: -------------------------------------------------------------------------------- 1 | # `epd` -- Parallel e-Paper 2 | 3 | 该模块为并口墨水屏提供驱动接口。目前支持的墨水屏显示器有`ED047TC1`。相关产品有[TTGO T5-4.7 Inch E-paper](https://www.aliexpress.com/item/1005002006058892.html). 4 | 5 | ## Class EPD47 6 | 7 | ### Constructors 8 | 9 | #### class epd.EPD47() 10 | 11 | 返回EPD47的对象 12 | 13 | ### Methods 14 | 15 | #### EPD47.power(active) 16 | 17 | 打开或者关闭电子纸的电源,并返回当前的电源状态。 18 | 19 | 在使用此类上的任何其他方法之前,必须先激活电源。 20 | 21 | #### EPD47.bitmap(framebuffer, x, y, width, height) 22 | 23 | 显示位图数据。 24 | 25 | - `framebuffer`: List 类型。位图数据。 26 | 27 | - `x`: Numbers 类型。x坐标,范围为0 - 960。 28 | 29 | - `y`: Numbers 类型。y坐标,范围为0 - 540。 30 | 31 | - `width`: Numbers 类型。显示区域的宽度,范围为0 - 960。 32 | 33 | - `height`: Numbers 类型。显示区域的高度,范围为0 - 540。 34 | 35 | #### EPD47.jpeg(pathname, x, y) 36 | 37 | 显示jpeg图像。 38 | 39 | - `pathname`: String 类型。jpeg图像文字在micropython的绝对路径。 40 | 41 | - `x`: Numbers 类型。x坐标,范围为0 - 960。 42 | 43 | - `y`: Numbers 类型。y坐标,范围为0 - 540。 44 | 45 | #### EPD47.text(text, x, y, font_size=12) 46 | 47 | 显示文字。目前内置FiraSans字体,支持9、12、18、24四种字体大小。 48 | 49 | - `text`: String 类型。显示的文本。 50 | 51 | - `x`: Numbers 类型。x坐标,范围为0 - 960。 52 | 53 | - `y`: Numbers 类型。y坐标,范围为0 - 540。 54 | 55 | - `font_size`: Numbers 类型。字体大小,取值只能是9、12、18、24。 56 | 57 | #### EPD47.clear([x=0, y=0, width=960, height=540]) 58 | 59 | 清除屏幕 60 | 61 | #### EPD47.width() 62 | 63 | 返回电子纸的宽度 64 | 65 | #### EPD47.height() 66 | 67 | 返回电子纸的高度 68 | 69 | ### example 70 | 71 | 文本显示: 72 | 73 | ```python 74 | from epd import EPD47 75 | 76 | e = EPD47() 77 | e.power(True) 78 | e.clear() 79 | e.text("hello world", 100, 100, font_size=9) 80 | e.text("hello world", 100, 120, font_size=12) 81 | e.text("hello world", 100, 150, font_size=18) 82 | e.text("hello world", 100, 190, font_size=24) 83 | 84 | del e 85 | ``` 86 | 87 | jpeg图像显示: 88 | 89 | ```python 90 | from epd import EPD47 91 | from random import randint 92 | from time import sleep 93 | 94 | e = EPD47() 95 | 96 | e.power(True) 97 | 98 | e.clear() 99 | 100 | while True: 101 | x = randint(0, 960-200) 102 | y = randint(0, 540-200) 103 | e.jpeg("/logo.jpeg", x, y) 104 | sleep(1) 105 | e.jpeg("/cat.jpg", 0, 0) 106 | sleep(1) 107 | e.clear() 108 | sleep(1) 109 | ``` -------------------------------------------------------------------------------- /extmod/display/epd/src/epd_epd47.c: -------------------------------------------------------------------------------- 1 | #include "py/obj.h" 2 | #include "py/objarray.h" 3 | #include "py/runtime.h" 4 | #include "py/mphal.h" 5 | #include "py/mpthread.h" 6 | #include "py/stream.h" 7 | #include "py/objtype.h" 8 | #include "py/mperrno.h" 9 | #include "py/gc.h" 10 | #include "extmod/vfs.h" 11 | 12 | #include "epd_driver.h" 13 | #include "ed047tc1.h" 14 | #include "libjpeg/libjpeg.h" 15 | #include "font/FiraSans.h" 16 | 17 | #include 18 | #include 19 | #include 20 | 21 | typedef struct epd47_if_obj_t { 22 | mp_obj_base_t base; 23 | uint8_t *jpeg_buf; 24 | } epd47_if_obj_t; 25 | 26 | const mp_obj_type_t epd47_if_type; 27 | 28 | STATIC mp_obj_t epd47_make_new() 29 | { 30 | /** 31 | * When using del obj to destroy the current object, the epd47_delete() 32 | * method will not be called immediately, resulting in hardware resources 33 | * not being destroyed in time. It is necessary to call gc_collect() to 34 | * destroy the previous hardware resources when creating the object, 35 | * or use obj.deinit() to destroy the corresponding hardware resources in 36 | * micropython. 37 | */ 38 | gc_collect(); 39 | 40 | epd_init(); 41 | 42 | epd47_if_obj_t *self = m_new_obj_with_finaliser(epd47_if_obj_t); 43 | if (!self) 44 | { 45 | mp_raise_TypeError(MP_ERROR_TEXT("malloc fail")); 46 | return mp_const_none; 47 | } 48 | 49 | self->base.type = &epd47_if_type; 50 | 51 | self->jpeg_buf = m_malloc(540 * 960); 52 | if (!self->jpeg_buf) 53 | { 54 | mp_raise_TypeError(MP_ERROR_TEXT("malloc fail")); 55 | return mp_const_none; 56 | } 57 | 58 | libjpeg_init(); 59 | 60 | return MP_OBJ_FROM_PTR(self); 61 | } 62 | MP_DEFINE_CONST_FUN_OBJ_0(epd47_make_new_obj, epd47_make_new); 63 | 64 | 65 | STATIC mp_obj_t epd47_power(mp_obj_t self_in, mp_obj_t onoff_in) 66 | { 67 | // epd47_if_obj_t *self = MP_OBJ_TO_PTR(self_in); 68 | 69 | if (mp_obj_is_true(onoff_in)) 70 | epd_poweron(); 71 | else 72 | epd_poweroff(); 73 | 74 | return mp_const_none; 75 | } 76 | STATIC MP_DEFINE_CONST_FUN_OBJ_2(epd47_power_obj, epd47_power); 77 | 78 | 79 | STATIC mp_obj_t epd47_bitmap(size_t n_args, const mp_obj_t *args) 80 | { 81 | Rect_t area; 82 | mp_buffer_info_t bufinfo; 83 | 84 | if (n_args < 2 || n_args > 6) return mp_const_none; 85 | 86 | mp_get_buffer_raise(args[1], &bufinfo, MP_BUFFER_WRITE); 87 | area.x = mp_obj_get_int(args[2]); 88 | area.y = mp_obj_get_int(args[3]); 89 | area.width = mp_obj_get_int(args[4]); 90 | area.height = mp_obj_get_int(args[5]); 91 | 92 | epd_draw_image(area, (uint8_t *)bufinfo.buf, BLACK_ON_WHITE); 93 | 94 | return mp_const_none; 95 | } 96 | STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(epd47_bitmap_obj, 6, 6, epd47_bitmap); 97 | 98 | 99 | // 100 | // jpeg file name 101 | // area.x 102 | // area.y 103 | // 104 | STATIC mp_obj_t epd47_jpeg(size_t n_args, const mp_obj_t *args) 105 | { 106 | int errcode; 107 | mp_uint_t len; 108 | Rect_t area; 109 | epd47_if_obj_t *self = MP_OBJ_TO_PTR(args[0]); 110 | mp_obj_t vfs_args[2] = { 111 | args[1], 112 | MP_OBJ_NEW_QSTR(MP_QSTR_rb), 113 | }; 114 | mp_obj_t o = mp_vfs_open(MP_ARRAY_SIZE(vfs_args), &vfs_args[0], (mp_map_t *)&mp_const_empty_map); 115 | 116 | len = mp_stream_rw(o, self->jpeg_buf, 540 * 960, &errcode, MP_STREAM_RW_READ); 117 | 118 | area.x = mp_obj_get_int(args[2]); 119 | area.y = mp_obj_get_int(args[3]); 120 | 121 | show_jpg_from_buff(self->jpeg_buf, len, area); 122 | 123 | return mp_const_none; 124 | } 125 | STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(epd47_jpeg_obj, 2, 4, epd47_jpeg); 126 | 127 | 128 | STATIC mp_obj_t epd47_text(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) 129 | { 130 | const mp_arg_t allowed_args[] = { 131 | {MP_QSTR_text, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = mp_const_none} }, 132 | {MP_QSTR_cursorx, MP_ARG_REQUIRED | MP_ARG_INT, {.u_int = -1} }, 133 | {MP_QSTR_cursory, MP_ARG_REQUIRED | MP_ARG_INT, {.u_int = -1} }, 134 | // {MP_QSTR_font, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = mp_const_none} }, 135 | {MP_QSTR_font_size, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 12} }, 136 | }; 137 | mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; 138 | 139 | mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); 140 | 141 | int x = args[1].u_int; 142 | int y = args[2].u_int; 143 | const GFXfont *gfx = &FiraSansRegular12pt; 144 | 145 | if (args[0].u_obj == mp_const_none || x == -1 || y == -1) 146 | { 147 | return mp_const_none; 148 | } 149 | 150 | if (x < 0 || x > EPD_WIDTH || y < 0 || y > EPD_HEIGHT) 151 | { 152 | return mp_const_none; 153 | } 154 | 155 | if (args[3].u_int == 9) 156 | gfx = &FiraSansRegular9pt; 157 | if (args[3].u_int == 18) 158 | gfx = &FiraSansRegular18pt; 159 | if (args[3].u_int == 24) 160 | gfx = &FiraSansRegular24pt; 161 | 162 | writeln((GFXfont *)gfx, 163 | mp_obj_str_get_str(args[0].u_obj), 164 | &x, 165 | &y, 166 | NULL); 167 | 168 | return mp_const_none; 169 | } 170 | STATIC MP_DEFINE_CONST_FUN_OBJ_KW(epd47_text_obj, 3, epd47_text); 171 | 172 | 173 | STATIC mp_obj_t epd47_clear(size_t n_args, const mp_obj_t *args) 174 | { 175 | Rect_t area = {.x = 0, .y = 0, .width = EPD_WIDTH, .height = EPD_HEIGHT}; 176 | 177 | if (n_args < 1 || n_args > 5) return mp_const_none; 178 | 179 | if (n_args > 1 && mp_obj_get_int(args[1]) > 0 && mp_obj_get_int(args[1]) < EPD_WIDTH) 180 | { 181 | area.x = mp_obj_get_int(args[1]); 182 | } 183 | 184 | if (n_args > 2 && mp_obj_get_int(args[2]) > 0 && mp_obj_get_int(args[2]) < EPD_HEIGHT) 185 | { 186 | area.y = mp_obj_get_int(args[2]); 187 | } 188 | 189 | if (n_args > 3 && mp_obj_get_int(args[3]) > 0 && mp_obj_get_int(args[3]) < EPD_WIDTH) 190 | { 191 | area.width = mp_obj_get_int(args[3]); 192 | } 193 | 194 | if (n_args > 4 && mp_obj_get_int(args[4]) > 0 && mp_obj_get_int(args[4]) < EPD_HEIGHT) 195 | { 196 | area.height = mp_obj_get_int(args[4]); 197 | } 198 | 199 | epd_clear_area(area); 200 | 201 | return mp_const_none; 202 | } 203 | STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(epd47_clear_obj, 1, 5, epd47_clear); 204 | 205 | 206 | STATIC mp_obj_t epd47_width(mp_obj_t self_in) 207 | { 208 | return mp_obj_new_int(EPD_WIDTH); 209 | } 210 | STATIC MP_DEFINE_CONST_FUN_OBJ_1(epd47_width_obj, epd47_width); 211 | 212 | 213 | STATIC mp_obj_t epd47_height(mp_obj_t self_in) 214 | { 215 | return mp_obj_new_int(EPD_HEIGHT); 216 | } 217 | STATIC MP_DEFINE_CONST_FUN_OBJ_1(epd47_height_obj, epd47_height); 218 | 219 | 220 | STATIC mp_obj_t epd47_delete(mp_obj_t self_in) 221 | { 222 | epd47_if_obj_t *self = MP_OBJ_TO_PTR(self_in); 223 | 224 | epd_deinit(); 225 | libjpeg_deinit(); 226 | m_free(self->jpeg_buf); 227 | return mp_const_none; 228 | } 229 | MP_DEFINE_CONST_FUN_OBJ_1(epd47_delete_obj, epd47_delete); 230 | 231 | 232 | STATIC const mp_rom_map_elem_t epd47_if_locals_dict_table[] = { 233 | // method 234 | { MP_ROM_QSTR(MP_QSTR_power), MP_ROM_PTR(&epd47_power_obj) }, 235 | { MP_ROM_QSTR(MP_QSTR_bitmap), MP_ROM_PTR(&epd47_bitmap_obj) }, 236 | { MP_ROM_QSTR(MP_QSTR_jpeg), MP_ROM_PTR(&epd47_jpeg_obj) }, 237 | { MP_ROM_QSTR(MP_QSTR_text), MP_ROM_PTR(&epd47_text_obj) }, 238 | { MP_ROM_QSTR(MP_QSTR_clear), MP_ROM_PTR(&epd47_clear_obj) }, 239 | { MP_ROM_QSTR(MP_QSTR_width), MP_ROM_PTR(&epd47_width_obj) }, 240 | { MP_ROM_QSTR(MP_QSTR_height), MP_ROM_PTR(&epd47_height_obj) }, 241 | { MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&epd47_delete_obj) }, 242 | { MP_ROM_QSTR(MP_QSTR___del__), MP_ROM_PTR(&epd47_delete_obj) }, 243 | }; 244 | STATIC MP_DEFINE_CONST_DICT(epd47_if_locals_dict, epd47_if_locals_dict_table); 245 | 246 | const mp_obj_type_t epd47_if_type = { 247 | { &mp_type_type }, 248 | .name = MP_QSTR_EPD47, 249 | .make_new = epd47_make_new, 250 | .locals_dict = (mp_obj_dict_t *)&epd47_if_locals_dict, 251 | }; -------------------------------------------------------------------------------- /extmod/display/epd/src/font/FiraSans.h: -------------------------------------------------------------------------------- 1 | //#include "FiraSans/FiraSansBold12pt.h" 2 | //#include "FiraSans/FiraSansBold18pt.h" 3 | //#include "FiraSans/FiraSansBold24pt.h" 4 | //#include "FiraSans/FiraSansBold9pt.h" 5 | //#include "FiraSans/FiraSansBoldItalic12pt.h" 6 | //#include "FiraSans/FiraSansBoldItalic18pt.h" 7 | //#include "FiraSans/FiraSansBoldItalic24pt.h" 8 | //#include "FiraSans/FiraSansBoldItalic9pt.h" 9 | //#include "FiraSans/FiraSansBook12pt.h" 10 | //#include "FiraSans/FiraSansBook18pt.h" 11 | //#include "FiraSans/FiraSansBook24pt.h" 12 | //#include "FiraSans/FiraSansBook9pt.h" 13 | //#include "FiraSans/FiraSansBookItalic12pt.h" 14 | //#include "FiraSans/FiraSansBookItalic18pt.h" 15 | //#include "FiraSans/FiraSansBookItalic24pt.h" 16 | //#include "FiraSans/FiraSansBookItalic9pt.h" 17 | //#include "FiraSans/FiraSansEight12pt.h" 18 | //#include "FiraSans/FiraSansEight18pt.h" 19 | //#include "FiraSans/FiraSansEight24pt.h" 20 | //#include "FiraSans/FiraSansEight9pt.h" 21 | //#include "FiraSans/FiraSansEightItalic12pt.h" 22 | //#include "FiraSans/FiraSansEightItalic18pt.h" 23 | //#include "FiraSans/FiraSansEightItalic24pt.h" 24 | //#include "FiraSans/FiraSansEightItalic9pt.h" 25 | //#include "FiraSans/FiraSansExtraBold12pt.h" 26 | //#include "FiraSans/FiraSansExtraBold18pt.h" 27 | //#include "FiraSans/FiraSansExtraBold24pt.h" 28 | //#include "FiraSans/FiraSansExtraBold9pt.h" 29 | //#include "FiraSans/FiraSansExtraBoldItalic12pt.h" 30 | //#include "FiraSans/FiraSansExtraBoldItalic18pt.h" 31 | //#include "FiraSans/FiraSansExtraBoldItalic24pt.h" 32 | //#include "FiraSans/FiraSansExtraBoldItalic9pt.h" 33 | //#include "FiraSans/FiraSansExtraLight12pt.h" 34 | //#include "FiraSans/FiraSansExtraLight18pt.h" 35 | //#include "FiraSans/FiraSansExtraLight24pt.h" 36 | //#include "FiraSans/FiraSansExtraLight9pt.h" 37 | //#include "FiraSans/FiraSansExtraLightItalic12pt.h" 38 | //#include "FiraSans/FiraSansExtraLightItalic18pt.h" 39 | //#include "FiraSans/FiraSansExtraLightItalic24pt.h" 40 | //#include "FiraSans/FiraSansExtraLightItalic9pt.h" 41 | //#include "FiraSans/FiraSansFour12pt.h" 42 | //#include "FiraSans/FiraSansFour18pt.h" 43 | //#include "FiraSans/FiraSansFour24pt.h" 44 | //#include "FiraSans/FiraSansFour9pt.h" 45 | //#include "FiraSans/FiraSansFourItalic12pt.h" 46 | //#include "FiraSans/FiraSansFourItalic18pt.h" 47 | //#include "FiraSans/FiraSansFourItalic24pt.h" 48 | //#include "FiraSans/FiraSansFourItalic9pt.h" 49 | //#include "FiraSans/FiraSansHair12pt.h" 50 | //#include "FiraSans/FiraSansHair18pt.h" 51 | //#include "FiraSans/FiraSansHair24pt.h" 52 | //#include "FiraSans/FiraSansHair9pt.h" 53 | //#include "FiraSans/FiraSansHairItalic12pt.h" 54 | //#include "FiraSans/FiraSansHairItalic18pt.h" 55 | //#include "FiraSans/FiraSansHairItalic24pt.h" 56 | //#include "FiraSans/FiraSansHairItalic9pt.h" 57 | //#include "FiraSans/FiraSansHeavy12pt.h" 58 | //#include "FiraSans/FiraSansHeavy18pt.h" 59 | //#include "FiraSans/FiraSansHeavy24pt.h" 60 | //#include "FiraSans/FiraSansHeavy9pt.h" 61 | //#include "FiraSans/FiraSansHeavyItalic12pt.h" 62 | //#include "FiraSans/FiraSansHeavyItalic18pt.h" 63 | //#include "FiraSans/FiraSansHeavyItalic24pt.h" 64 | //#include "FiraSans/FiraSansHeavyItalic9pt.h" 65 | //#include "FiraSans/FiraSansItalic12pt.h" 66 | //#include "FiraSans/FiraSansItalic18pt.h" 67 | //#include "FiraSans/FiraSansItalic24pt.h" 68 | //#include "FiraSans/FiraSansItalic9pt.h" 69 | //#include "FiraSans/FiraSansLight12pt.h" 70 | //#include "FiraSans/FiraSansLight18pt.h" 71 | //#include "FiraSans/FiraSansLight24pt.h" 72 | //#include "FiraSans/FiraSansLight9pt.h" 73 | //#include "FiraSans/FiraSansLightItalic12pt.h" 74 | //#include "FiraSans/FiraSansLightItalic18pt.h" 75 | //#include "FiraSans/FiraSansLightItalic24pt.h" 76 | //#include "FiraSans/FiraSansLightItalic9pt.h" 77 | //#include "FiraSans/FiraSansMedium12pt.h" 78 | //#include "FiraSans/FiraSansMedium18pt.h" 79 | //#include "FiraSans/FiraSansMedium24pt.h" 80 | //#include "FiraSans/FiraSansMedium9pt.h" 81 | //#include "FiraSans/FiraSansMediumItalic12pt.h" 82 | //#include "FiraSans/FiraSansMediumItalic18pt.h" 83 | //#include "FiraSans/FiraSansMediumItalic24pt.h" 84 | //#include "FiraSans/FiraSansMediumItalic9pt.h" 85 | #include "FiraSans/FiraSansRegular12pt.h" 86 | #include "FiraSans/FiraSansRegular18pt.h" 87 | #include "FiraSans/FiraSansRegular24pt.h" 88 | #include "FiraSans/FiraSansRegular9pt.h" 89 | //#include "FiraSans/FiraSansSemiBold12pt.h" 90 | //#include "FiraSans/FiraSansSemiBold18pt.h" 91 | //#include "FiraSans/FiraSansSemiBold24pt.h" 92 | //#include "FiraSans/FiraSansSemiBold9pt.h" 93 | //#include "FiraSans/FiraSansSemiBoldItalic12pt.h" 94 | //#include "FiraSans/FiraSansSemiBoldItalic18pt.h" 95 | //#include "FiraSans/FiraSansSemiBoldItalic24pt.h" 96 | //#include "FiraSans/FiraSansSemiBoldItalic9pt.h" 97 | //#include "FiraSans/FiraSansThin12pt.h" 98 | //#include "FiraSans/FiraSansThin18pt.h" 99 | //#include "FiraSans/FiraSansThin24pt.h" 100 | //#include "FiraSans/FiraSansThin9pt.h" 101 | //#include "FiraSans/FiraSansThinItalic12pt.h" 102 | //#include "FiraSans/FiraSansThinItalic18pt.h" 103 | //#include "FiraSans/FiraSansThinItalic24pt.h" 104 | //#include "FiraSans/FiraSansThinItalic9pt.h" 105 | //#include "FiraSans/FiraSansTwo12pt.h" 106 | //#include "FiraSans/FiraSansTwo18pt.h" 107 | //#include "FiraSans/FiraSansTwo24pt.h" 108 | //#include "FiraSans/FiraSansTwo9pt.h" 109 | //#include "FiraSans/FiraSansTwoItalic12pt.h" 110 | //#include "FiraSans/FiraSansTwoItalic18pt.h" 111 | //#include "FiraSans/FiraSansTwoItalic24pt.h" 112 | //#include "FiraSans/FiraSansTwoItalic9pt.h" 113 | //#include "FiraSans/FiraSansUltra12pt.h" 114 | //#include "FiraSans/FiraSansUltra18pt.h" 115 | //#include "FiraSans/FiraSansUltra24pt.h" 116 | //#include "FiraSans/FiraSansUltra9pt.h" 117 | //#include "FiraSans/FiraSansUltraItalic12pt.h" 118 | //#include "FiraSans/FiraSansUltraItalic18pt.h" 119 | //#include "FiraSans/FiraSansUltraItalic24pt.h" 120 | //#include "FiraSans/FiraSansUltraItalic9pt.h" 121 | //#include "FiraSans/FiraSansUltraLight12pt.h" 122 | //#include "FiraSans/FiraSansUltraLight18pt.h" 123 | //#include "FiraSans/FiraSansUltraLight24pt.h" 124 | //#include "FiraSans/FiraSansUltraLight9pt.h" 125 | //#include "FiraSans/FiraSansUltraLightItalic12pt.h" 126 | //#include "FiraSans/FiraSansUltraLightItalic18pt.h" 127 | //#include "FiraSans/FiraSansUltraLightItalic24pt.h" 128 | //#include "FiraSans/FiraSansUltraLightItalic9pt.h" -------------------------------------------------------------------------------- /extmod/display/epd/src/micropython.cmake: -------------------------------------------------------------------------------- 1 | # Create an INTERFACE library for our C module. 2 | add_library(usermod_epd INTERFACE) 3 | 4 | set(EPD47_DIR ${CMAKE_BINARY_DIR}/../LilyGo-EPD47) 5 | 6 | file(GLOB LIBEPD47_SRC ${EPD47_DIR}/src/*.c) 7 | file(GLOB ZLIB_SRC ${EPD47_DIR}/src/zlib/*.c) 8 | file(GLOB LIBJPEG_SRC ${EPD47_DIR}/src/libjpeg/*.c) 9 | 10 | # Add our source files to the lib 11 | target_sources(usermod_epd INTERFACE 12 | ${CMAKE_CURRENT_LIST_DIR}/modepd.c 13 | ${CMAKE_CURRENT_LIST_DIR}/epd_epd47.c 14 | ${LIBEPD47_SRC} 15 | ${ZLIB_SRC} 16 | ${LIBJPEG_SRC} 17 | ) 18 | 19 | # Add the current directory as an include directory. 20 | target_include_directories(usermod_epd INTERFACE 21 | ${CMAKE_CURRENT_LIST_DIR} 22 | ${EPD47_DIR}/src/ 23 | ${EPD47_DIR}/src/zlib/ 24 | ${EPD47_DIR}/src/libjpeg/ 25 | ) 26 | 27 | # Link our INTERFACE library to the usermod target. 28 | target_link_libraries(usermod INTERFACE usermod_epd) 29 | -------------------------------------------------------------------------------- /extmod/display/epd/src/micropython.mk: -------------------------------------------------------------------------------- 1 | EXAMPLE_MOD_DIR := $(USERMOD_DIR) 2 | 3 | # Add all C files to SRC_USERMOD. 4 | SRC_USERMOD += $(EXAMPLE_MOD_DIR)/modepd.c 5 | SRC_USERMOD += $(EXAMPLE_MOD_DIR)/epd_epd47.c 6 | 7 | # We can add our module folder to include paths if needed 8 | # This is not actually needed in this example. 9 | CFLAGS_USERMOD += -I$(EXAMPLE_MOD_DIR) 10 | CEXAMPLE_MOD_DIR := $(USERMOD_DIR) 11 | -------------------------------------------------------------------------------- /extmod/display/epd/src/modepd.c: -------------------------------------------------------------------------------- 1 | 2 | #include "py/runtime.h" 3 | #include "py/obj.h" 4 | 5 | #include "mphalport.h" 6 | 7 | #include "modepd.h" 8 | 9 | STATIC const mp_rom_map_elem_t mp_module_epd_globals_table[] = { 10 | { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_epd) }, 11 | 12 | { MP_ROM_QSTR(MP_QSTR_EPD47), MP_ROM_PTR(&epd47_make_new_obj) }, 13 | }; 14 | STATIC MP_DEFINE_CONST_DICT(mp_module_epd_globals, mp_module_epd_globals_table); 15 | 16 | 17 | const mp_obj_module_t mp_module_epd = { 18 | .base = {&mp_type_module}, 19 | .globals = (mp_obj_dict_t *)&mp_module_epd_globals, 20 | }; 21 | 22 | MP_REGISTER_MODULE(MP_QSTR_epd, mp_module_epd); 23 | -------------------------------------------------------------------------------- /extmod/display/epd/src/modepd.h: -------------------------------------------------------------------------------- 1 | 2 | MP_DECLARE_CONST_FUN_OBJ_0(epd47_make_new_obj); 3 | -------------------------------------------------------------------------------- /extmod/display/epd/test/l58.py: -------------------------------------------------------------------------------- 1 | from machine import Pin, I2C 2 | from collections import namedtuple 3 | 4 | TouchData = namedtuple("TouchData", ["id", "state", "x", "y"]) 5 | 6 | class L58(): 7 | def __init__(self, bus, address): 8 | self.bus = bus 9 | self.address = address 10 | self.touchData = [] 11 | 12 | def begin(self): 13 | self.wakeup() 14 | 15 | def readBytes(self, write, nbytes): 16 | self.bus.start() 17 | self.bus.writeto(self.address, write) 18 | read = self.bus.readfrom(self.address, nbytes) 19 | return list(read) 20 | 21 | def clearFlags(self): 22 | self.bus.writeto(self.address, [0xD0, 0x00, 0xAB]) 23 | 24 | def scanPoint(self): 25 | sumL = 0 26 | sumH = 0 27 | pointData = [] 28 | 29 | buffer = self.readBytes([0xD0, 0x00], 7) 30 | if buffer[0] == 0xAB: 31 | self.clearFlags() 32 | return 0 33 | 34 | pointData.extend(buffer[0:5]) 35 | 36 | point = buffer[5] & 0x0F 37 | if point == 1: 38 | buffer = self.readBytes( [0xD0, 0x07], 2) 39 | sumL = buffer[0] << 8 | buffer [1] 40 | pointData.extend(buffer) 41 | elif point > 1: 42 | buffer = self.readBytes([0xD0, 0x07], 5 * (point - 1) + 3) 43 | pointData.extend(buffer) 44 | sumL = pointData[5 * point + 1] << 8 | pointData[5 * point + 2] 45 | self.clearFlags() 46 | 47 | 48 | for i in range(0, 5 * point): 49 | sumH += pointData[i] 50 | 51 | if sumH != sumL: 52 | point = 0 53 | 54 | if (point): 55 | for i in range(0, point): 56 | if i == 0: 57 | offset = 0 58 | else: 59 | offset = 4 60 | 61 | id = (pointData[i * 5 + offset] >> 4) & 0x0F 62 | state = pointData[i * 5 + offset] & 0x0F 63 | if state == 0x06: 64 | state = 0x07 65 | else: 66 | state = 0x06 67 | y = ((pointData[i * 5 + 1 + offset] << 4) | ((pointData[i * 5 + 3 + offset] >> 4) & 0x0F)) 68 | x = ((pointData[i * 5 + 2 + offset] << 4) | (pointData[i * 5 + 3 + offset] & 0x0F)) 69 | touchdata = TouchData(id = id, state= state, x = x, y = y) 70 | self.touchData.append(touchdata) 71 | # print(id, state, x, y) 72 | else: 73 | point = 1 74 | id = pointData[0] >> 4 & 0x0F 75 | state = 0x06 76 | y = pointData[1] << 4 | pointData[3] >> 4 & 0x0F 77 | x = pointData[2] << 4 | pointData[3] & 0x0F 78 | touchdata = TouchData(id = id, state= state, x = x, y = y) 79 | self.touchData.append(touchdata) 80 | point = 1 81 | # print(id, state, x, y) 82 | return point 83 | 84 | def getPoint(self): 85 | return self.touchData.pop() 86 | 87 | def sleep(self): 88 | self.bus.writeto(self.address, bytearray([0xD1, 0x05])) 89 | 90 | def wakeup(self): 91 | self.bus.writeto(self.address, bytearray([0xD1, 0x06])) 92 | 93 | 94 | if __name__ == '__main__': 95 | from time import sleep 96 | 97 | tp = L58(I2C(1, scl=Pin(14), sda=Pin(15)), 0x5A) 98 | tp.begin() 99 | while True: 100 | for i in range(0, tp.scanPoint()): 101 | data = tp.getPoint() 102 | print(data) 103 | sleep(0.1) 104 | 105 | -------------------------------------------------------------------------------- /extmod/display/epd/test/main.py: -------------------------------------------------------------------------------- 1 | import epd 2 | import logo 3 | from time import sleep 4 | import random 5 | 6 | epd47 = epd.EPD47() 7 | 8 | while True: 9 | print("display") 10 | epd47.power(True) 11 | sleep(0.1) 12 | x = random.randint(0, 960-200) 13 | y = random.randint(0, 540-200) 14 | epd47.bitmap(logo.logo_data, x, y, logo.logo_width, logo.logo_height) 15 | epd47.power(False) 16 | sleep(1) 17 | -------------------------------------------------------------------------------- /extmod/display/framebuf1/.gitignore: -------------------------------------------------------------------------------- 1 | __pycache__ 2 | fira-sans -------------------------------------------------------------------------------- /extmod/display/framebuf1/examples/demo/demo.py: -------------------------------------------------------------------------------- 1 | if __name__ == "__main__": 2 | from FiraSansRegular10pt import FiraSansRegular10pt 3 | from framebuf1 import FrameBuffer 4 | 5 | buffer = bytearray(int(960 * 540 / 2)) 6 | fb = FrameBuffer(buffer, 960, 540) 7 | fb.fill(0) 8 | 9 | fb.hline(100, 100, 100, 255) 10 | 11 | fb.vline(100, 100, 100, 255) 12 | 13 | fb.circle(200, 200, 50, 255) 14 | fb.fill_circle(400, 200, 50, 255) 15 | 16 | fb.rect(600, 200, 100, 100, 255) 17 | fb.fill_rect(800, 200, 100, 100, 255) 18 | 19 | fb.line(100, 300, 400, 500, 255) 20 | fb.line(400, 500, 100, 300, 255) 21 | fb.line(400, 300, 100, 500, 255) 22 | fb.line(100, 500, 400, 300, 255) 23 | 24 | fb.triangle(200, 400, 150, 500, 250, 400, 255) 25 | fb.fill_triangle(600, 400, 600, 500, 700, 500, 255) 26 | 27 | fb.text(FiraSansRegular10pt, "1234", 50, 50) 28 | try: 29 | from epd import EPD47 30 | e = EPD47() 31 | e.power(True) 32 | e.clear() 33 | e.bitmap(buffer, 0, 0, 960, 540) 34 | except: 35 | print("The current parser is not micropython") 36 | -------------------------------------------------------------------------------- /extmod/display/framebuf1/manifest.py: -------------------------------------------------------------------------------- 1 | # This list of frozen files doesn't include task.py because that's provided by the C module. 2 | freeze("./src", "framebuf1.py") 3 | -------------------------------------------------------------------------------- /extmod/display/framebuf1/tests/test_framebuf1.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import epd 3 | from framebuf1 import FrameBuffer 4 | import time 5 | 6 | class TestFrameBuffer(unittest.TestCase): 7 | 8 | def __init__(self): 9 | self.e = epd.EPD47() 10 | self.buffer = bytearray(int(960 * 540 / 2)) 11 | self.fb = FrameBuffer(self.buffer, 960, 540) 12 | 13 | def setUpClass(self): 14 | self.e.power(True) 15 | self.e.clear() 16 | 17 | def tearDownClass(self): 18 | self.e.power(False) 19 | del self.e 20 | del self.fb 21 | del self.buffer 22 | 23 | def setUp(self): 24 | self.e.clear() 25 | self.fb.fill(0) 26 | 27 | def tearDown(self): 28 | self.e.bitmap(self.buffer, 0, 0, 960, 540) 29 | time.sleep(1) 30 | 31 | def test_hline(self): 32 | self.fb.hline(430, 270, 100, 255) 33 | 34 | def test_vhine(self): 35 | self.fb.vline(480, 220, 100, 255) 36 | 37 | def test_line(self): 38 | self.fb.line(430, 220, 530, 320, 255) 39 | self.fb.line(430, 320, 530, 220, 255) 40 | 41 | def test_rect(self): 42 | self.fb.rect(430, 220, 100, 100, 255) 43 | 44 | def test_fill_rect(self): 45 | self.fb.fill_rect(430, 220, 100, 100, 255) 46 | 47 | def test_circle(self): 48 | self.fb.circle(480, 270, 50, 255) 49 | 50 | def test_fill_circle(self): 51 | self.fb.fill_circle(480, 270, 50, 255) 52 | 53 | def test_triangle(self): 54 | self.fb.triangle(430, 220, 430, 320, 530, 320, 255) 55 | 56 | def test_fill_triangle(self): 57 | self.fb.fill_triangle(430, 220, 430, 320, 530, 320, 255) 58 | 59 | if __name__ == "__main__": 60 | unittest.main() 61 | -------------------------------------------------------------------------------- /extmod/display/framebuf1/tools/README.md: -------------------------------------------------------------------------------- 1 | # fontconvert 2 | 3 | Prerequisite you need to install python3 and install `freetype-py` using pip 4 | The approximate process is like this: 5 | 6 | ``` 7 | sudo apt install python3-pip 8 | python3 -m pip install freetype-py 9 | ``` 10 | 11 | The previous is the prerequisite for implementation, and then you need to store 12 | the font file you want to convert in the same path as fontconvert.py. This is 13 | just for more convenient operation. You can also fill in the font path. 14 | 15 | Then just follow the command below to convert the font. 16 | 17 | ``` 18 | python3 fontconvert.py --compress demo 16 msyh.ttc> font.h 19 | ``` 20 | 21 | Explanation of specific parameters: 22 | 23 | ``` 24 | python3 fontconvert.py --compress [generated font name] [font size] [font file path]> [generated font file] 25 | ``` 26 | 27 | Of course, this only demonstrates the generation of standard ascii codes. If you 28 | need other fonts, you only need to fill in the unicode encoding of the font to 29 | be generated in the `fontconvert.py` `intervals` list. 30 | 31 | Please make sure that the unicode encoding in the fontconvert.py intervals list 32 | is included in your font file, otherwise please comment other encodings and only 33 | keep the 32,126 range! -------------------------------------------------------------------------------- /extmod/display/framebuf1/tools/fontconvert.py: -------------------------------------------------------------------------------- 1 | #!python3 2 | import freetype 3 | import zlib 4 | import sys 5 | import math 6 | import argparse 7 | from collections import namedtuple 8 | 9 | parser = argparse.ArgumentParser(description="Generate a header file from a font to be used with epdiy.") 10 | parser.add_argument("name", action="store", help="name of the font.") 11 | parser.add_argument("size", type=int, help="font size to use.") 12 | parser.add_argument("fontstack", action="store", nargs='+', help="list of font files, ordered by descending priority.") 13 | parser.add_argument("--compress", dest="compress", action="store_true", help="compress glyph bitmaps.") 14 | args = parser.parse_args() 15 | 16 | GlyphProps = namedtuple("GlyphProps", ["width", "height", "advance_x", "left", "top", "compressed_size", "data_offset", "code_point"]) 17 | 18 | font_stack = [freetype.Face(f) for f in args.fontstack] 19 | compress = args.compress 20 | size = args.size 21 | font_name = args.name 22 | 23 | # inclusive unicode code point intervals 24 | # must not overlap and be in ascending order 25 | intervals = [ 26 | (32, 126), 27 | (160, 255), 28 | # (0x2500, 0x259F), 29 | # (0x2700, 0x27BF), 30 | # # powerline symbols 31 | # (0xE0A0, 0xE0A2), 32 | # (0xE0B0, 0xE0B3), 33 | # (0x1F600, 0x1F680), 34 | ] 35 | 36 | 37 | def norm_floor(val): 38 | return int(math.floor(val / (1 << 6))) 39 | 40 | def norm_ceil(val): 41 | return int(math.ceil(val / (1 << 6))) 42 | 43 | for face in font_stack: 44 | # shift by 6 bytes, because sizes are given as 6-bit fractions 45 | # the display has about 150 dpi. 46 | face.set_char_size(size << 6, size << 6, 150, 150) 47 | 48 | def chunks(l, n): 49 | for i in range(0, len(l), n): 50 | yield l[i:i + n] 51 | 52 | total_size = 0 53 | total_packed = 0 54 | all_glyphs = [] 55 | 56 | def load_glyph(code_point): 57 | face_index = 0 58 | while face_index < len(font_stack): 59 | face = font_stack[face_index] 60 | glyph_index = face.get_char_index(code_point) 61 | if glyph_index > 0: 62 | face.load_glyph(glyph_index, freetype.FT_LOAD_RENDER) 63 | return face 64 | break 65 | face_index += 1 66 | print (f"falling back to font {face_index} for {chr(code_point)}.", file=sys.stderr) 67 | raise ValueError(f"code point {code_point} not found in font stack!") 68 | 69 | for i_start, i_end in intervals: 70 | for code_point in range(i_start, i_end + 1): 71 | face = load_glyph(code_point) 72 | bitmap = face.glyph.bitmap 73 | pixels = [] 74 | px = 0 75 | for i, v in enumerate(bitmap.buffer): 76 | y = i / bitmap.width 77 | x = i % bitmap.width 78 | if x % 2 == 0: 79 | px = (v >> 4) 80 | else: 81 | px = px | (v & 0xF0) 82 | pixels.append(px) 83 | px = 0 84 | # eol 85 | if x == bitmap.width - 1 and bitmap.width % 2 > 0: 86 | pixels.append(px) 87 | px = 0 88 | 89 | packed = bytes(pixels) 90 | total_packed += len(packed) 91 | compressed = packed 92 | if compress: 93 | compressed = zlib.compress(packed) 94 | 95 | glyph = GlyphProps( 96 | width = bitmap.width, 97 | height = bitmap.rows, 98 | advance_x = norm_floor(face.glyph.advance.x), 99 | left = face.glyph.bitmap_left, 100 | top = face.glyph.bitmap_top, 101 | compressed_size = len(compressed), 102 | data_offset = total_size, 103 | code_point = code_point, 104 | ) 105 | total_size += len(compressed) 106 | all_glyphs.append((glyph, compressed)) 107 | 108 | # pipe seems to be a good heuristic for the "real" descender 109 | face = load_glyph(ord('|')) 110 | 111 | glyph_data = [] 112 | glyph_props = [] 113 | for index, glyph in enumerate(all_glyphs): 114 | props, compressed = glyph 115 | glyph_data.extend([b for b in compressed]) 116 | glyph_props.append(props) 117 | 118 | print("total", total_packed, file=sys.stderr) 119 | print("compressed", total_size, file=sys.stderr) 120 | 121 | ## out 122 | print("from collections import namedtuple") 123 | print() 124 | print("GFXfont = namedtuple(\"GFXfont\", [\"bitmap\", \"glyph\", \"intervals\",\n\ 125 | \"interval_count\", \"compressed\", \"advance_y\",\n\ 126 | \"ascender\", \"descender\"])") 127 | print() 128 | print("UnicodeInterval = namedtuple(\"UnicodeInterval\", [\"first\", \"last\", \"offset\"])") 129 | print() 130 | print("GFXglyph = namedtuple(\"GFXglyph\", [\"width\", \"height\", \"advance_x\", \"left\",\n\ 131 | \"top\", \"compressed_size\", \"data_offset\"])") 132 | print() 133 | print("{}Bitmaps = [".format(font_name)) 134 | for c in chunks(glyph_data, 16): 135 | print (" " + " ".join(f"0x{b:02X}," for b in c)) 136 | print ("]") 137 | print() 138 | print("{}Glyphs = [".format(font_name)) 139 | for i, g in enumerate(glyph_props): 140 | print (" GFXglyph(width = {:>2d}, height = {:>2d}, advance_x = {:>2d}, left = {:>2d}, \ 141 | top = {:>2d}, compressed_size = {:>3d}, data_offset = {:>4d}), # {}".format(g.width, g.height, 142 | g.advance_x, g.left, g.top, g.compressed_size, g.data_offset, chr(g.code_point) if g.code_point != 92 else '' 143 | )) 144 | print ("]") 145 | print() 146 | # UnicodeInterval(first = 0x20, last= 0x7E, offset = 0x0) 147 | print("{}Intervals = [".format(font_name)) 148 | offset = 0 149 | for i_start, i_end in intervals: 150 | print(" UnicodeInterval(first = {:>2d}, last = {:>2d}, offset = {:>2d}),".format(i_start, i_end, offset)) 151 | offset += i_end - i_start + 1 152 | print ("]") 153 | print() 154 | print("{} = GFXfont(".format(font_name)) 155 | print(" bitmap = {}Bitmaps,".format(font_name)) 156 | print(" glyph = {}Glyphs,".format(font_name)) 157 | print(" intervals = {}Intervals,".format(font_name)) 158 | print(" interval_count = {:d},".format(len(intervals))) 159 | print(" compressed = {},".format("True" if compress else "False")) 160 | print(" advance_y = {},".format(norm_ceil(face.size.height))) 161 | print(" ascender = {},".format(norm_ceil(face.size.ascender))) 162 | print(" descender = {},".format(norm_floor(face.size.descender))) 163 | print(")") -------------------------------------------------------------------------------- /extmod/display/framebuf_plus/Makefile: -------------------------------------------------------------------------------- 1 | 2 | define framebuf_plus/info 3 | PKG_NAME:=framebuf-plus 4 | PKG_SOURCE_URL:=https://github.com/lbuque/framebuf-plus.git 5 | PKG_SOURCE_PROTO:=git 6 | PKG_SOURCE_VERSION:=12a80666d1c38d1bddeb2261b71f1c622ea7efa5 7 | PKG_SOURCE_MD5:= 8 | endef 9 | 10 | include $(INCLUDE_DIR)/download.mk 11 | include $(INCLUDE_DIR)/package.mk 12 | 13 | # PKG_DEPEND:=LilyGo-EPD47 14 | # $(foreach var, $(PKG_DEPEND), make -C $(TOP_DIR)/libs/$(var);) 15 | all: 16 | $(eval $(framebuf_plus/info)) 17 | $(call Package/prereq,$(TARGET_BUILD_DIR)) 18 | # $(call Package/patches,$(TARGET_BUILD_DIR)/$(PKG_NAME),$(shell pwd)/patches) -------------------------------------------------------------------------------- /extmod/display/framebuf_plus/src/micropython.cmake: -------------------------------------------------------------------------------- 1 | set(FRAMEBUF_PLUS_DIR ${CMAKE_BINARY_DIR}/../framebuf-plus) 2 | 3 | include(${FRAMEBUF_PLUS_DIR}/framebuf/micropython.cmake) -------------------------------------------------------------------------------- /extmod/display/lcd/Makefile: -------------------------------------------------------------------------------- 1 | 2 | define lcd/info 3 | PKG_NAME:=lcd_binding_micropython 4 | PKG_SOURCE_URL:=https://github.com/liangyingy/lcd_binding_micropython.git 5 | PKG_SOURCE_PROTO:=git 6 | PKG_SOURCE_VERSION:=59bbbdae5ecc9ae84b986ce54c089250a13cb768 7 | PKG_SOURCE_MD5:= 8 | endef 9 | 10 | include $(INCLUDE_DIR)/download.mk 11 | include $(INCLUDE_DIR)/package.mk 12 | 13 | # PKG_DEPEND:=LilyGo-EPD47 14 | # $(foreach var, $(PKG_DEPEND), make -C $(TOP_DIR)/libs/$(var);) 15 | all: 16 | $(eval $(lcd/info)) 17 | $(call Package/prereq,$(TARGET_BUILD_DIR)) 18 | # $(call Package/patches,$(TARGET_BUILD_DIR)/$(PKG_NAME),$(shell pwd)/patches) -------------------------------------------------------------------------------- /extmod/display/lcd/src/micropython.cmake: -------------------------------------------------------------------------------- 1 | set(LCD_DIR ${CMAKE_BINARY_DIR}/../lcd_binding_micropython) 2 | 3 | include(${LCD_DIR}/lcd/micropython.cmake) -------------------------------------------------------------------------------- /extmod/display/st7789/Makefile: -------------------------------------------------------------------------------- 1 | 2 | define st7789/info 3 | PKG_NAME:=st7789 4 | PKG_SOURCE_URL:=https://github.com/russhughes/st7789_mpy.git 5 | PKG_SOURCE_PROTO:=git 6 | PKG_SOURCE_VERSION:=f45a298dfa1119f584bcf218ac600f7a897647f4 7 | PKG_SOURCE_MD5:= 8 | endef 9 | 10 | include $(INCLUDE_DIR)/download.mk 11 | include $(INCLUDE_DIR)/package.mk 12 | 13 | # PKG_DEPEND:=LilyGo-EPD47 14 | # $(foreach var, $(PKG_DEPEND), make -C $(TOP_DIR)/libs/$(var);) 15 | all: 16 | $(eval $(st7789/info)) 17 | $(call Package/prereq,$(TARGET_BUILD_DIR)) 18 | # $(call Package/patches,$(TARGET_BUILD_DIR)/$(PKG_NAME),$(shell pwd)/patches) -------------------------------------------------------------------------------- /extmod/display/st7789/src/micropython.cmake: -------------------------------------------------------------------------------- 1 | set(ST7789_DIR ${CMAKE_BINARY_DIR}/../st7789) 2 | 3 | include(${ST7789_DIR}/st7789/micropython.cmake) -------------------------------------------------------------------------------- /extmod/micropython.cmake: -------------------------------------------------------------------------------- 1 | # This top-level micropython.cmake is responsible for listing 2 | # the individual modules we want to include. 3 | # Paths are absolute, and ${CMAKE_CURRENT_LIST_DIR} can be 4 | # used to prefix subdirectories. 5 | 6 | if(EXTMOD_EPD) 7 | include(${CMAKE_CURRENT_LIST_DIR}/display/epd/src/micropython.cmake) 8 | endif() 9 | 10 | if(EXTMOD_GSM) 11 | include(${CMAKE_CURRENT_LIST_DIR}/network/gsm/src/micropython.cmake) 12 | endif() 13 | 14 | if(EXTMOD_ST7789) 15 | include(${CMAKE_CURRENT_LIST_DIR}/display/st7789/src/micropython.cmake) 16 | endif() 17 | 18 | if(EXTMOD_LCD) 19 | include(${CMAKE_CURRENT_LIST_DIR}/display/lcd/src/micropython.cmake) 20 | endif() 21 | 22 | if(EXTMOD_BMA) 23 | include(${CMAKE_CURRENT_LIST_DIR}/sensor/bma/src/micropython.cmake) 24 | endif() 25 | 26 | if(EXTMOD_FRAMEBUF_PLUS) 27 | include(${CMAKE_CURRENT_LIST_DIR}/display/framebuf_plus/src/micropython.cmake) 28 | endif() 29 | -------------------------------------------------------------------------------- /extmod/network/at/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2022 Lilygo https://github.com/Xinyuan-LilyGO 2 | # Author: liangying 3 | # Contact: 1102390310@qq.com 4 | 5 | from time import ticks_ms 6 | from at.sim7000 import * 7 | 8 | __version__ = (0, 1, 0) 9 | 10 | def constructAT(base_class): 11 | 12 | class AT(base_class): 13 | DISCONNECT = const(0) 14 | CONNECT = const(1) 15 | BUSY = const(2) 16 | 17 | def __init__(self, stream): 18 | # check arg 19 | if not hasattr(stream, "write") or not hasattr(stream, "readline"): 20 | raise Exception("Invalid Argument", stream) 21 | super(AT, self).__init__() 22 | self.stream = stream 23 | self.__status = DISCONNECT 24 | 25 | def sendCmd(self, cmd): 26 | # check arg 27 | if not isinstance("a", str): 28 | raise Exception("Invalid Argument", cmd) 29 | 30 | # check cmd 31 | if cmd.find('AT') == -1: 32 | raise Exception("String 'AT' not found ", cmd) 33 | if cmd.find('AT') != 0: 34 | raise Exception("Command must start with 'AT'", cmd) 35 | 36 | if cmd.find('\r') != (len(cmd) - 2) or \ 37 | cmd.find('\n') != (len(cmd) - 1): 38 | cmd = cmd + '\r\n' 39 | 40 | self.stream.write(cmd) 41 | 42 | def waitResponse(self, rsp1 = 'OK\r\n', rsp2 = 'ERROR\r\n', timeout=1000): 43 | rsp = bytearray() 44 | startMillis = ticks_ms() 45 | while (ticks_ms() - startMillis) < timeout: 46 | if self.stream.any(): 47 | rsp.extend(bytearray(self.stream.readline())) 48 | if rsp.decode('utf-8').endswith(rsp1): 49 | return True, rsp 50 | if rsp.decode('utf-8').endswith(rsp2): 51 | return False, rsp 52 | return False, rsp 53 | 54 | def connect(self, timeout=20000): 55 | res = False 56 | startMillis = ticks_ms() 57 | while not res: 58 | self.sendCmd("AT\r\n") 59 | res, data = self.waitResponse() 60 | if (ticks_ms() - startMillis) > timeout: 61 | raise Exception("Timeout") 62 | self.__status = CONNECT 63 | 64 | def parseResponse(self, data, head): 65 | # check cmd 66 | if not (isinstance(data, str) or isinstance(data, bytearray)): 67 | raise Exception("Invalid Argument", data) 68 | if not isinstance(head, str): 69 | raise Exception("Invalid Argument", head) 70 | 71 | s = '' 72 | if isinstance(data, bytearray): 73 | s = data.decode('utf-8') 74 | s = s[s.find(head) + len(head):] 75 | s = s[:s.find('\r\n')] 76 | return s.lstrip() 77 | 78 | return AT 79 | 80 | 81 | 82 | -------------------------------------------------------------------------------- /extmod/network/at/gprs.py: -------------------------------------------------------------------------------- 1 | from time import sleep, ticks_ms 2 | 3 | class GPRS(): 4 | 5 | ''' 6 | SIM card functions 7 | ''' 8 | 9 | def simUnlock(self): 10 | ''' 11 | Unlocks the SIM 12 | 13 | TODO: to be realized 14 | ''' 15 | pass 16 | 17 | def getSimCCID(self): 18 | ''' 19 | Gets the CCID of a sim card via AT+CCID 20 | 21 | TODO: to be realized 22 | ''' 23 | pass 24 | 25 | def getIMEI(self): 26 | ''' 27 | Asks for TA Serial Number Identification (IMEI) 28 | 29 | TODO: to be realized 30 | ''' 31 | pass 32 | 33 | def getIMSI(self): 34 | ''' 35 | Asks for International Mobile Subscriber Identity IMSI 36 | 37 | TODO: to be realized 38 | ''' 39 | pass 40 | 41 | def getSimStatus(self, timeout = 10000): 42 | ''' 43 | TODO: Not Tested 44 | ''' 45 | startMillis = ticks_ms() 46 | while (ticks_ms() - startMillis) < timeout: 47 | self.sendCmd("AT+CPIN?") 48 | res, data = self.waitResponse() 49 | if not res: 50 | sleep(1) 51 | continue 52 | s = self.parseResponse(data, "+CPIN:") 53 | if s == 'READY': 54 | return (1, 'READY') 55 | elif s == 'SIM PIN': 56 | return (2, 'SIM PIN') 57 | elif s == 'SIM PUK': 58 | return (3, 'SIM PUK') 59 | elif s == 'PH_SIM PIN': 60 | return (4, 'PH_SIM PIN') 61 | elif s == 'PH_SIM PUK': 62 | return (5, 'PH_SIM PUK') 63 | elif s == 'SIM PIN2': 64 | return (5, 'SIM PIN2') 65 | elif s == 'SIM PUK2': 66 | return (5, 'SIM PUK2') 67 | return (0, "") 68 | 69 | ''' 70 | GPRS functions 71 | ''' 72 | def gprsConnect(self, apn = "", user = "", pwd = ""): 73 | ''' 74 | TODO: to be realized 75 | ''' 76 | pass 77 | 78 | def gprsDisconnect(self): 79 | ''' 80 | TODO: to be realized 81 | ''' 82 | pass 83 | 84 | def isGprsConnected(self): 85 | ''' 86 | Checks if current attached to GPRS/EPS service 87 | 88 | TODO: to be realized 89 | ''' 90 | pass 91 | 92 | def getOperator(self): 93 | ''' 94 | Gets the current network operator 95 | 96 | TODO: to be realized 97 | ''' 98 | pass 99 | 100 | def getRegistrationStatus(self): 101 | self.sendCmd("AT+CEREG?") 102 | res, data = self.waitResponse() 103 | if res: 104 | s = self.parseResponse(data, "+CEREG:") 105 | a = s.split(',') 106 | return int(a[1]) 107 | return -1 108 | -------------------------------------------------------------------------------- /extmod/network/at/gps.py: -------------------------------------------------------------------------------- 1 | from collections import namedtuple 2 | 3 | gpsinfo = namedtuple("gpsinfo", ["lat", # Latitude 4 | "lon", # Longitude 5 | "speed", # Speed Over Ground. Unit is knots. 6 | "alt", # MSL Altitude. Unit is meters 7 | "vsat", # GNSS Satellites in View 8 | "usat", # GNSS Satellites Used 9 | "accuracy", # Horizontal Dilution Of Precision 10 | "year", # Four digit year 11 | "month", # Two digit month 12 | "day", # Two digit day 13 | "hour", # Two digit hour 14 | "minute", # Two digit minute 15 | "second"]) # 6 digit second with subseconds 16 | 17 | class GPS(): 18 | ''' 19 | GPS/GNSS/GLONASS Basic Class 20 | ''' 21 | 22 | def enableGPS(self): 23 | ''' 24 | enable GPS 25 | ''' 26 | self.sendCmd("AT+CGNSPWR=1") 27 | res, data = self.waitResponse() 28 | return res 29 | 30 | def disableGPS(self): 31 | ''' 32 | disable GPS 33 | ''' 34 | self.sendCmd("AT+CGNSPWR=0") 35 | res, data = self.waitResponse() 36 | return res 37 | 38 | def getGPSRAW(self): 39 | ''' 40 | get the RAW GPS output 41 | ''' 42 | self.sendCmd("AT+CGNSINF") 43 | res, data = self.waitResponse(timeout = 10000) 44 | if not res: 45 | return "" 46 | return data 47 | 48 | def getGPS(self): 49 | ''' 50 | get GPS informations 51 | ''' 52 | data = self.getGPSRAW() 53 | s = self.parseResponse(data, "+CGNSINF:") 54 | a = s.split(',') 55 | if int(a[0]) == 1 and int(a[1]) == 1: 56 | return gpsinfo( 57 | lat = float(a[3]) if a[3] != '' else float(0), # Latitude 58 | lon = float(a[4]) if a[4] != '' else float(0), # Longitude 59 | speed = float(a[6]) if a[6] != '' else float(0), # Speed Over Ground. Unit is knots. 60 | alt = float(a[5]) if a[5] != '' else float(0), # MSL Altitude. Unit is meters 61 | vsat = int(a[14]) if a[14] != '' else int(0), # GNSS Satellites in View 62 | usat = int(a[16]) if a[16] != '' else int(0), # GNSS Satellites Used 63 | accuracy = float(a[10]) if a[10] != '' else float(0), # Horizontal Dilution Of Precision 64 | year = int(a[2][0:4]) if a[2] != '' else int(0), # Four digit year 65 | month = int(a[2][4:6]) if a[2] != '' else int(0), # Two digit month 66 | day = int(a[2][6:8]) if a[2] != '' else int(0), # Two digit day 67 | hour = int(a[2][8:10]) if a[2] != '' else int(0), # Two digit hour 68 | minute = int(a[2][10:12]) if a[2] != '' else int(0), # Two digit minute 69 | second = int(a[2][12:14]) if a[2] != '' else int(0), # 6 digit second with subseconds 70 | ) 71 | return None 72 | 73 | def getGPSTime(self): 74 | ''' 75 | get GPS Time informations 76 | ''' 77 | data = self.getGPSRAW() 78 | s = self.parseResponse(data, "+CGNSINF:") 79 | a = s.split(',') 80 | if int(a[0]) == 1 and int(a[1]) == 1: 81 | return ( 82 | int(a[2][0:4]) if a[2] != '' else int(0), # Four digit year 83 | int(a[2][4:6]) if a[2] != '' else int(0), # Two digit month 84 | int(a[2][6:8]) if a[2] != '' else int(0), # Two digit day 85 | int(a[2][8:10]) if a[2] != '' else int(0), # Two digit hour 86 | int(a[2][10:12]) if a[2] != '' else int(0), # Two digit minute 87 | int(a[2][12:14]) if a[2] != '' else int(0), # 6 digit second with subseconds 88 | ) 89 | return None 90 | 91 | def setGNSSMode(self, gps, glonass, beidou, galilean): 92 | ''' 93 | GNSS Work Mode Set 94 | 95 | TODO: Not Tested 96 | ''' 97 | cmd = 'AT+CGNSMOD=' + str(gps) + ',' + str(glonass) + ',' + str(beidou) + ',' + str(galilean) 98 | self.sendCmd(cmd) 99 | res, data = self.waitResponse(timeout = 10000) 100 | return res 101 | 102 | def getGNSSMode(self): 103 | ''' 104 | GNSS Work Mode Get 105 | ''' 106 | self.sendCmd("AT+CGNSMOD?") 107 | res, data = self.waitResponse(timeout = 10000) 108 | if res: 109 | s = self.parseResponse(data, "+CGNSMOD:") 110 | a = s.split(',') 111 | return ( 112 | int(a[0]) if a[0] != '' else int(-1), # GPS work mode 113 | int(a[1]) if a[1] != '' else int(-1), # GLONASS work mode 114 | int(a[2]) if a[2] != '' else int(-1), # BEIDOU work mode 115 | int(a[3]) if a[3] != '' else int(-1) # GALILEAN work mode 116 | ) 117 | return None 118 | 119 | -------------------------------------------------------------------------------- /extmod/network/at/manifest.py: -------------------------------------------------------------------------------- 1 | # This list of frozen files doesn't include task.py because that's provided by the C module. 2 | freeze( 3 | "..", 4 | ( 5 | "at/__init__.py", 6 | "at/gprs.py", 7 | "at/gps.py", 8 | "at/modem.py", 9 | "at/sim7000.py", 10 | ), 11 | opt=3, 12 | ) 13 | -------------------------------------------------------------------------------- /extmod/network/at/modem.py: -------------------------------------------------------------------------------- 1 | 2 | class MODEM(): 3 | ''' 4 | Basic functions 5 | ''' 6 | 7 | def init(self): 8 | self.sendCmd('AT+CLTS=1') 9 | res, data = self.waitResponse() 10 | if not res: 11 | return False 12 | 13 | self.sendCmd('AT+CBATCHK=1') 14 | res, data = self.waitResponse() 15 | if not res: 16 | return False 17 | 18 | return True 19 | 20 | def setBaud(self, baud): 21 | ''' 22 | Set TE-TA Fixed Local Rate 23 | 24 | TODO: Not Tested 25 | ''' 26 | cmd = "AT+IPR=" + baud 27 | self.sendCmd(cmd) 28 | self.waitResponse() 29 | 30 | def testAT(self): 31 | ''' 32 | Test response to AT commands 33 | 34 | TODO: Not Tested 35 | ''' 36 | self.sendCmd("AT") 37 | self.waitResponse() 38 | 39 | def getModemInfo(self): 40 | ''' 41 | Asks for modem information via the V.25TER standard ATI command 42 | 43 | NOTE: The actual value and style of the response is quite varied 44 | 45 | TODO: Not Tested 46 | ''' 47 | self.sendCmd("ATI") 48 | res, data = self.waitResponse() 49 | if res: 50 | return data 51 | return "" 52 | 53 | def getModemName(self): 54 | ''' 55 | Gets the modem name (as it calls itself) 56 | 57 | TODO: Not Tested 58 | ''' 59 | s = "" 60 | self.sendCmd("AT+CGMI") 61 | res, data = self.waitResponse() 62 | if res: 63 | data = data.replace("\r\nOK\r\n", "") 64 | s += data.replace("\rOK\r", "") 65 | else: 66 | return "" 67 | self.sendCmd("AT+GMM") 68 | res, data = self.waitResponse() 69 | if res: 70 | data = data.replace("\r\nOK\r\n", "") 71 | s += data.replace("\rOK\r", "") 72 | else: 73 | return "" 74 | return s 75 | 76 | def factoryDefault(self): 77 | ''' 78 | TODO 79 | ''' 80 | pass 81 | 82 | ''' 83 | Power functions 84 | ''' 85 | def restart(self): 86 | ''' 87 | not anything no single thing 88 | ''' 89 | pass 90 | 91 | def poweroff(self): 92 | ''' 93 | TODO: Not Tested 94 | ''' 95 | self.sendCmd("+CPOWD=1") 96 | res = self.waitResponse(rsp1 = 'NORMAL POWER DOWN\r\n') 97 | return res 98 | 99 | def radioOff(self): 100 | pass 101 | 102 | def sleepEnable(self, enable = True): 103 | ''' 104 | During sleep, the SIM70xx module has its serial communication disabled. 105 | 106 | In order to reestablish communication pull the DRT-pin of the SIM70xx 107 | module LOW for at least 50ms. 108 | 109 | Then use this function to disable sleep mode. 110 | 111 | The DTR-pin can then be released again. 112 | 113 | TODO: Not Tested 114 | ''' 115 | self.sendCmd("+CSCLK=" + "1" if enable else "0") 116 | res, data = self.waitResponse() 117 | return res 118 | 119 | def setPhoneFunctionality(self, fun, rst): 120 | ''' 121 | TODO: Not Tested 122 | ''' 123 | cmd = "AT+CFUN=" + fun + ",1" if rst else "" 124 | self.sendCmd(cmd) 125 | res, data = self.waitResponse() 126 | return res 127 | 128 | def getSignalQuality(self): 129 | ''' 130 | Gets signal quality report 131 | ''' 132 | self.sendCmd("AT+CSQ") 133 | res, data = self.waitResponse() 134 | if res: 135 | s = self.parseResponse(data, '+CSQ:') 136 | a = s.split(',') 137 | if int(a[0]) == 0: 138 | return (0, '-115 dBm or less') 139 | elif int(a[0]) == 1: 140 | return (1, '-111 dBm') 141 | elif int(a[0]) >= 2 and int(a[0]) <= 31: 142 | dBm = (-110+2 * (int(a[0]) - 2 )) 143 | return ( int(a[0]), "{} dBm".format(dBm)) 144 | elif int(a[0]) == 31: 145 | return ( 31, '-52 dBm or greater') 146 | return (99, 'not known or not detectable') 147 | 148 | -------------------------------------------------------------------------------- /extmod/network/at/sim7000.py: -------------------------------------------------------------------------------- 1 | from at.gps import GPS 2 | from at.gprs import GPRS 3 | from at.modem import MODEM 4 | 5 | class SIM7000(GPS, GPRS, MODEM): 6 | 7 | def setNetworkMode(self, mode): 8 | ''' 9 | 2 Automatic 10 | 13 GSM only 11 | 38 LTE only 12 | 51 GSM and LTE only 13 | ''' 14 | self.sendCmd("AT+CNMP=" + str(mode)) 15 | res, data = self.waitResponse() 16 | return res 17 | 18 | def isNetworkConnected(self): 19 | status = self.getRegistrationStatus() 20 | return status == 1 or status == 5 21 | 22 | -------------------------------------------------------------------------------- /extmod/network/at/test/gps_test.py: -------------------------------------------------------------------------------- 1 | from at import constructAT, SIM7000 2 | from time import sleep 3 | 4 | if __name__ == "__main__": 5 | from machine import UART 6 | from machine import Pin 7 | 8 | def power(active): 9 | if active == True: 10 | GSM_PWR.value(1) 11 | sleep(0.5) 12 | GSM_PWR.value(0) 13 | sleep(0.5) 14 | GSM_PWR.value(1) 15 | sleep(10) 16 | else: 17 | GSM_PWR.value(0) 18 | sleep(1) 19 | 20 | GSM_PWR = Pin(4, Pin.OUT) 21 | power(True) 22 | 23 | uart = UART(1, baudrate=115200, rx=26, tx=27) 24 | g = constructAT(SIM7000)(uart) 25 | print(g) 26 | g.connect() 27 | 28 | g.sendCmd("AT+SGPIO=0,4,1,1"); 29 | res, data = g.waitResponse(timeout = 10000) 30 | if not res: 31 | print("error") 32 | g.enableGPS() 33 | 34 | while True: 35 | print(g.getGPS()) 36 | print(g.getGPSTime()) 37 | print(g.getGNSSMode()) 38 | sleep(1) 39 | -------------------------------------------------------------------------------- /extmod/network/at/test/network_test.py: -------------------------------------------------------------------------------- 1 | from at import constructAT, SIM7000 2 | 3 | from time import sleep 4 | 5 | if __name__ == "__main__": 6 | from machine import UART 7 | from machine import Pin 8 | 9 | def power(active): 10 | if active == True: 11 | GSM_PWR.value(1) 12 | sleep(0.5) 13 | GSM_PWR.value(0) 14 | sleep(0.5) 15 | GSM_PWR.value(1) 16 | sleep(10) 17 | else: 18 | GSM_PWR.value(0) 19 | sleep(1) 20 | 21 | GSM_PWR = Pin(4, Pin.OUT) 22 | power(True) 23 | 24 | uart = UART(1, baudrate=115200, rx=26, tx=27) 25 | g = constructAT(SIM7000)(uart) 26 | print(g) 27 | g.connect() 28 | 29 | while True: 30 | g.init() 31 | isConnected = False 32 | for i in [ 2, 13, 38, 51 ]: 33 | ''' 34 | 2, # Automatic 35 | 13, # GSM only 36 | 38, # LTE only 37 | 51 # GSM and LTE only 38 | ''' 39 | g.setNetworkMode(i) 40 | sleep(3) 41 | tryCount = 60 42 | while tryCount: 43 | print(g.getSignalQuality()) 44 | isConnected = g.isNetworkConnected() 45 | print("CONNECT" if isConnected else "NO CONNECT") 46 | if isConnected: 47 | break 48 | tryCount -= 1 49 | if isConnected: 50 | break 51 | 52 | print("Device is connected .") 53 | print("=====Inquiring UE system information=====") 54 | g.sendCmd("AT+CPSI?") 55 | res, data = g.waitResponse() 56 | print(data) 57 | break 58 | -------------------------------------------------------------------------------- /extmod/network/gsm/src/micropython.cmake: -------------------------------------------------------------------------------- 1 | # Create an INTERFACE library for our C module. 2 | add_library(usermod_gsm INTERFACE) 3 | 4 | # Add our source files to the lib 5 | target_sources(usermod_gsm INTERFACE 6 | ${CMAKE_CURRENT_LIST_DIR}/libGSM.c 7 | ${CMAKE_CURRENT_LIST_DIR}/gsm_ppp.c 8 | ${CMAKE_CURRENT_LIST_DIR}/modgsm.c 9 | ) 10 | 11 | # Add the current directory as an include directory. 12 | target_include_directories(usermod_gsm INTERFACE 13 | ${CMAKE_CURRENT_LIST_DIR} 14 | ) 15 | 16 | # Link our INTERFACE library to the usermod target. 17 | target_link_libraries(usermod INTERFACE usermod_gsm) 18 | -------------------------------------------------------------------------------- /extmod/network/gsm/src/micropython.mk: -------------------------------------------------------------------------------- 1 | EXAMPLE_MOD_DIR := $(USERMOD_DIR) 2 | 3 | # Add all C files to SRC_USERMOD. 4 | SRC_USERMOD += $(EXAMPLE_MOD_DIR)/modgsm.c 5 | SRC_USERMOD += $(EXAMPLE_MOD_DIR)/gsm_ppp.c 6 | SRC_USERMOD += $(EXAMPLE_MOD_DIR)/libGSM.c 7 | 8 | # We can add our module folder to include paths if needed 9 | # This is not actually needed in this example. 10 | CFLAGS_USERMOD += -I$(EXAMPLE_MOD_DIR) 11 | CEXAMPLE_MOD_DIR := $(USERMOD_DIR) 12 | -------------------------------------------------------------------------------- /extmod/network/gsm/src/modgsm.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the MicroPython ESP32 project, https://github.com/loboris/MicroPython_ESP32_psRAM_LoBo 3 | * 4 | * The MIT License (MIT) 5 | * 6 | * Copyright (c) 2018 LoBo (https://github.com/loboris) 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | // #ifdef CONFIG_MICROPY_USE_GSM 28 | 29 | #include 30 | #include 31 | #include 32 | 33 | #include "tcpip_adapter.h" 34 | 35 | #include "py/runtime.h" 36 | #include "py/obj.h" 37 | #include "shared/netutils/netutils.h" 38 | #include "mphalport.h" 39 | #include "libGSM.h" 40 | 41 | #include "modgsm.h" 42 | 43 | STATIC const mp_rom_map_elem_t mp_module_gsm_globals_table[] = { 44 | { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_gsm) }, 45 | 46 | { MP_ROM_QSTR(MP_QSTR_GSM), MP_ROM_PTR(&gsm_make_new_obj) }, 47 | }; 48 | STATIC MP_DEFINE_CONST_DICT(mp_module_gsm_globals, mp_module_gsm_globals_table); 49 | 50 | 51 | const mp_obj_module_t mp_module_gsm = { 52 | .base = {&mp_type_module}, 53 | .globals = (mp_obj_dict_t *)&mp_module_gsm_globals, 54 | }; 55 | 56 | MP_REGISTER_MODULE(MP_QSTR_gsm, mp_module_gsm, 1); 57 | 58 | // #endif 59 | -------------------------------------------------------------------------------- /extmod/network/gsm/src/modgsm.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | MP_DECLARE_CONST_FUN_OBJ_1(gsm_make_new_obj); 4 | -------------------------------------------------------------------------------- /extmod/sensor/bma/Makefile: -------------------------------------------------------------------------------- 1 | 2 | define bma/info 3 | PKG_NAME:=bma 4 | PKG_SOURCE_URL:=https://github.com/liangyingy/bma_binding_micropython.git 5 | PKG_SOURCE_PROTO:=git 6 | PKG_SOURCE_VERSION:=master 7 | PKG_SOURCE_MD5:= 8 | endef 9 | 10 | include $(INCLUDE_DIR)/download.mk 11 | include $(INCLUDE_DIR)/package.mk 12 | 13 | # PKG_DEPEND:=LilyGo-EPD47 14 | # $(foreach var, $(PKG_DEPEND), make -C $(TOP_DIR)/libs/$(var);) 15 | all: 16 | $(eval $(bma/info)) 17 | $(call Package/prereq,$(TARGET_BUILD_DIR)) 18 | $(call Package/patches,$(TARGET_BUILD_DIR)/$(PKG_NAME),$(shell pwd)/patches) -------------------------------------------------------------------------------- /extmod/sensor/bma/patches/000-Adapt-to-micropython-v1.18.patch: -------------------------------------------------------------------------------- 1 | diff --git a/src/modbma.c b/src/modbma.c 2 | index e213980..4aec157 100644 3 | --- a/src/modbma.c 4 | +++ b/src/modbma.c 5 | @@ -45,6 +45,6 @@ const mp_obj_module_t mp_module_bma = { 6 | .globals = (mp_obj_dict_t *)&bma_module_globals, 7 | }; 8 | 9 | -MP_REGISTER_MODULE(MP_QSTR_bma, mp_module_bma); 10 | +MP_REGISTER_MODULE(MP_QSTR_bma, mp_module_bma, 1); 11 | 12 | // #endif 13 | \ No newline at end of file 14 | -------------------------------------------------------------------------------- /extmod/sensor/bma/src/micropython.cmake: -------------------------------------------------------------------------------- 1 | set(BMA_DIR ${CMAKE_BINARY_DIR}/../bma) 2 | 3 | include(${BMA_DIR}/micropython.cmake) -------------------------------------------------------------------------------- /extmod/touch/l58.py: -------------------------------------------------------------------------------- 1 | from collections import namedtuple 2 | 3 | TouchData = namedtuple("TouchData", ["id", "state", "x", "y"]) 4 | 5 | class L58(): 6 | def __init__(self, bus, address): 7 | self.bus = bus 8 | self.address = address 9 | self.touchData = [] 10 | 11 | def begin(self): 12 | self.wakeup() 13 | 14 | def readBytes(self, write, nbytes): 15 | self.bus.writeto(self.address, write) 16 | read = self.bus.readfrom(self.address, nbytes) 17 | return list(read) 18 | 19 | def clearFlags(self): 20 | self.bus.writeto_mem(self.address, 0xD0, b'\x00\xAB') 21 | 22 | def scanPoint(self): 23 | sumL = 0 24 | sumH = 0 25 | pointData = [] 26 | 27 | buffer = self.readBytes(b'\xD0\x00', 7) 28 | if buffer[0] == 0xAB: 29 | self.clearFlags() 30 | return 0 31 | 32 | pointData.extend(buffer[0:5]) 33 | 34 | point = buffer[5] & 0x0F 35 | if point == 1: 36 | buffer = self.readBytes(b'\xD0\x07', 2) 37 | sumL = buffer[0] << 8 | buffer [1] 38 | pointData.extend(buffer) 39 | elif point > 1: 40 | buffer = self.readBytes(b'\xD0\x07', 5 * (point - 1) + 3) 41 | pointData.extend(buffer) 42 | sumL = pointData[5 * point + 1] << 8 | pointData[5 * point + 2] 43 | self.clearFlags() 44 | 45 | 46 | for i in range(0, 5 * point): 47 | sumH += pointData[i] 48 | 49 | if sumH != sumL: 50 | point = 0 51 | 52 | if (point): 53 | for i in range(0, point): 54 | if i == 0: 55 | offset = 0 56 | else: 57 | offset = 4 58 | 59 | id = (pointData[i * 5 + offset] >> 4) & 0x0F 60 | state = pointData[i * 5 + offset] & 0x0F 61 | if state == 0x06: 62 | state = 0x07 63 | else: 64 | state = 0x06 65 | y = ((pointData[i * 5 + 1 + offset] << 4) | ((pointData[i * 5 + 3 + offset] >> 4) & 0x0F)) 66 | x = ((pointData[i * 5 + 2 + offset] << 4) | (pointData[i * 5 + 3 + offset] & 0x0F)) 67 | touchdata = TouchData(id = id, state= state, x = x, y = y) 68 | self.touchData.append(touchdata) 69 | # print(id, state, x, y) 70 | else: 71 | point = 1 72 | id = pointData[0] >> 4 & 0x0F 73 | state = 0x06 74 | y = pointData[1] << 4 | pointData[3] >> 4 & 0x0F 75 | x = pointData[2] << 4 | pointData[3] & 0x0F 76 | touchdata = TouchData(id = id, state= state, x = x, y = y) 77 | self.touchData.append(touchdata) 78 | point = 1 79 | # print(id, state, x, y) 80 | return point 81 | 82 | def getPoint(self): 83 | return self.touchData.pop() 84 | 85 | def sleep(self): 86 | self.bus.writeto_mem(self.address, 0xD1, b'\x05') 87 | 88 | def wakeup(self): 89 | self.bus.writeto_mem(self.address, 0xD1, b'\x06') 90 | 91 | 92 | if __name__ == '__main__': 93 | from machine import I2C 94 | from machine import Pin 95 | from time import sleep 96 | tp = L58(I2C(1, scl=Pin(14), sda=Pin(15), freq=400000), 0x5A) 97 | tp.begin() 98 | while True: 99 | for i in range(0, tp.scanPoint()): 100 | data = tp.getPoint() 101 | print(data) 102 | sleep(0.1) 103 | 104 | -------------------------------------------------------------------------------- /extmod/touch/manifest.py: -------------------------------------------------------------------------------- 1 | # This list of frozen files doesn't include task.py because that's provided by the C module. 2 | freeze(".", "l58.py") 3 | -------------------------------------------------------------------------------- /include/download.mk: -------------------------------------------------------------------------------- 1 | 2 | ifdef PKG_SOURCE_VERSION 3 | # PKG_VERSION := $(if $(shell echo $(PKG_VERSION) | grep "[0-9a-f]\{5,40\}")) 4 | PKG_SOURCE_SUBDIR := $(PKG_NAME)-$(PKG_VERSION) 5 | PKG_SOURCE := $(PKG_SOURCE_SUBDIR).tar.xz 6 | endif 7 | 8 | ## 9 | ## $(1) SUBDIR 10 | ## $(2) URL 11 | ## $(3) VERSION 12 | ## $(4) OPTS 13 | ## 14 | define DownloadMethod/git 15 | echo "Download $(1)-$(3).tar.gz over git" && \ 16 | [ -d $(TMP_DIR) ] && mkdir -p $(TMP_DIR)/dl && \ 17 | cd $(TMP_DIR)/dl && \ 18 | rm -rf $(1) && \ 19 | [ \! -d $(1) ] && \ 20 | git clone $(4) $(2) $(1) && \ 21 | (cd $(1) && git checkout $(3) && git submodule update) && \ 22 | echo "Packing checkout..." && \ 23 | tar czf $(DL_DIR)/$(1)-$(3).tar.gz $(1) 24 | endef 25 | 26 | 27 | define Download 28 | retry=0 ; \ 29 | while [ $$retry -le 2 ]; \ 30 | do \ 31 | if [ ! -e $(DL_DIR)/$(PKG_NAME)-$(PKG_SOURCE_VERSION).tar.gz ]; then \ 32 | if [ $(PKG_SOURCE_PROTO) = "git" ]; then \ 33 | $(call DownloadMethod/git,$(PKG_NAME),$(PKG_SOURCE_URL),$(PKG_SOURCE_VERSION),$(PKG_SOURCE_OPT)) ; \ 34 | fi ; \ 35 | fi ; \ 36 | retry=`expr $$retry + 1` ; \ 37 | done 38 | endef 39 | 40 | -------------------------------------------------------------------------------- /include/package.mk: -------------------------------------------------------------------------------- 1 | 2 | ## 3 | ## $(1) TARGET_BUILD_DIR 4 | ## 5 | define Package/prereq 6 | $(LOG_LEVEL)if [ -e $(1)/$(PKG_NAME) ]; then \ 7 | if [ \! -e $(1)/$(PKG_NAME)/prereq ]; then \ 8 | rm -rf $(1)/$(PKG_NAME) ; \ 9 | if [ \! -e $(DL_DIR)/$(PKG_NAME)-$(PKG_SOURCE_VERSION).tar.gz ]; then \ 10 | $(call Download) ; \ 11 | fi ;\ 12 | echo "unpack $(PKG_NAME)-$(PKG_SOURCE_VERSION).tar.gz" ; \ 13 | tar -xf $(DL_DIR)/$(PKG_NAME)-$(PKG_SOURCE_VERSION).tar.gz -C $(1) ; \ 14 | touch $(1)/$(PKG_NAME)/prereq ; \ 15 | fi ; \ 16 | else \ 17 | if [ \! -e $(DL_DIR)/$(PKG_NAME)-$(PKG_SOURCE_VERSION).tar.gz ]; then \ 18 | $(call Download) ; \ 19 | fi ; \ 20 | echo "unpack $(PKG_NAME)-$(PKG_SOURCE_VERSION).tar.gz" ; \ 21 | tar -xf $(DL_DIR)/$(PKG_NAME)-$(PKG_SOURCE_VERSION).tar.gz -C $(1) ; \ 22 | touch $(1)/$(PKG_NAME)/prereq ; \ 23 | fi 24 | endef 25 | 26 | ## 27 | ## 28 | ## 29 | define Package/depend 30 | $(foreach var, $(PKG_DEPEND), make -C $(TOP_DIR)/libs/$(var);) 31 | endef 32 | 33 | ## 34 | ## $(1) TARGET_DIR 35 | ## $(2) PATCH_DIR 36 | ## 37 | ## 38 | define Package/patches 39 | $(LOG_LEVEL)echo "Push patch on $(1)" && \ 40 | cd $(1) ; \ 41 | quilt import $(2)/* ; \ 42 | quilt push -a ; \ 43 | cd - ; \ 44 | for patch in `ls $(2)` ; \ 45 | do \ 46 | if [ ! -e $(1)/prereq_$$patch ]; then \ 47 | touch $(1)/prereq_$$patch ; \ 48 | fi ; \ 49 | done 50 | endef 51 | -------------------------------------------------------------------------------- /libs/LilyGo-EPD47/Makefile: -------------------------------------------------------------------------------- 1 | SHELL:=/bin/bash 2 | 3 | include $(INCLUDE_DIR)/download.mk 4 | include $(INCLUDE_DIR)/package.mk 5 | 6 | define LilyGo-EPD47/info 7 | PKG_NAME:=LilyGo-EPD47 8 | PKG_SOURCE_URL:=https://github.com/Xinyuan-LilyGO/LilyGo-EPD47.git 9 | PKG_SOURCE_PROTO:=git 10 | PKG_SOURCE_VERSION:=deae2d2cbfb062198e6b4647d29eab6bc4d80d8a 11 | PKG_SOURCE_MD5:=505c09c8fdef57c04180f2b1676ccab8 12 | endef 13 | 14 | define LilyGo-EPD47/prereq 15 | $(eval $(LilyGo-EPD47/info)) 16 | $(call Package/prereq,$(TARGET_BUILD_DIR)) 17 | $(call Package/patches,$(TARGET_BUILD_DIR)/$(PKG_NAME),$(shell pwd)/patches) 18 | endef 19 | 20 | all: 21 | $(call LilyGo-EPD47/prereq) 22 | -------------------------------------------------------------------------------- /libs/LilyGo-EPD47/patches/000-adapt-to-micropython.patch: -------------------------------------------------------------------------------- 1 | Index: LilyGo-EPD47/src/epd_driver.c 2 | =================================================================== 3 | --- LilyGo-EPD47.orig/src/epd_driver.c 4 | +++ LilyGo-EPD47/src/epd_driver.c 5 | @@ -156,9 +156,9 @@ void epd_init() 6 | skipping = 0; 7 | epd_base_init(EPD_WIDTH); 8 | 9 | - conversion_lut = (uint8_t *)heap_caps_malloc(1 << 16, MALLOC_CAP_8BIT); 10 | + conversion_lut = (uint8_t *)malloc(1 << 16); 11 | assert(conversion_lut != NULL); 12 | - output_queue = xQueueCreate(64, EPD_WIDTH / 2); 13 | + output_queue = xQueueCreate(32, EPD_WIDTH / 2); 14 | } 15 | 16 | 17 | @@ -213,7 +213,7 @@ void epd_push_pixels(Rect_t area, int16_ 18 | 19 | void epd_clear_area(Rect_t area) 20 | { 21 | - epd_clear_area_cycles(area, 4, 50); 22 | + epd_clear_area_cycles(area, 1, 50); 23 | } 24 | 25 | 26 | @@ -224,11 +224,11 @@ void epd_clear_area_cycles(Rect_t area, 27 | 28 | for (int32_t c = 0; c < cycles; c++) 29 | { 30 | - for (int32_t i = 0; i < 4; i++) 31 | + for (int32_t i = 0; i < 16; i++) 32 | { 33 | epd_push_pixels(area, dark_time, 0); 34 | } 35 | - for (int32_t i = 0; i < 4; i++) 36 | + for (int32_t i = 0; i < 16; i++) 37 | { 38 | epd_push_pixels(area, white_time, 1); 39 | } 40 | @@ -295,7 +295,7 @@ void IRAM_ATTR calc_epd_input_1bpp(uint8 41 | } 42 | 43 | 44 | -inline uint32_t min(uint32_t x, uint32_t y) 45 | +uint32_t min(uint32_t x, uint32_t y) 46 | { 47 | return x < y ? x : y; 48 | } 49 | Index: LilyGo-EPD47/src/libjpeg/libjpeg.c 50 | =================================================================== 51 | --- LilyGo-EPD47.orig/src/libjpeg/libjpeg.c 52 | +++ LilyGo-EPD47/src/libjpeg/libjpeg.c 53 | @@ -8,7 +8,7 @@ 54 | 55 | #include "esp_heap_caps.h" 56 | #include "esp_log.h" 57 | -#include "esp_spiffs.h" 58 | +// #include "esp_spiffs.h" 59 | #include "esp_task_wdt.h" 60 | #include "esp_timer.h" 61 | 62 | -------------------------------------------------------------------------------- /libs/LilyGo-EPD47/patches/001-Add-deinitialized-interface.patch: -------------------------------------------------------------------------------- 1 | Index: LilyGo-EPD47/src/epd_driver.c 2 | =================================================================== 3 | --- LilyGo-EPD47.orig/src/epd_driver.c 4 | +++ LilyGo-EPD47/src/epd_driver.c 5 | @@ -162,6 +162,14 @@ void epd_init() 6 | } 7 | 8 | 9 | +void epd_deinit() 10 | +{ 11 | + epd_base_deinit(); 12 | + free(conversion_lut); 13 | + vQueueDelete(output_queue); 14 | +} 15 | + 16 | + 17 | void epd_push_pixels(Rect_t area, int16_t time, int32_t color) 18 | { 19 | uint8_t row[EPD_LINE_BYTES] = { 0 }; 20 | Index: LilyGo-EPD47/src/ed047tc1.h 21 | =================================================================== 22 | --- LilyGo-EPD47.orig/src/ed047tc1.h 23 | +++ LilyGo-EPD47/src/ed047tc1.h 24 | @@ -82,6 +82,7 @@ extern "C" { 25 | /******************************************************************************/ 26 | 27 | void epd_base_init(uint32_t epd_row_width); 28 | +void epd_base_deinit(); 29 | void epd_poweron(); 30 | void epd_poweroff(); 31 | 32 | @@ -138,4 +139,4 @@ void IRAM_ATTR epd_switch_buffer(); 33 | #endif 34 | /******************************************************************************/ 35 | /*** END OF FILE ***/ 36 | -/******************************************************************************/ 37 | \ No newline at end of file 38 | +/******************************************************************************/ 39 | Index: LilyGo-EPD47/src/epd_driver.h 40 | =================================================================== 41 | --- LilyGo-EPD47.orig/src/epd_driver.h 42 | +++ LilyGo-EPD47/src/epd_driver.h 43 | @@ -89,6 +89,8 @@ typedef struct 44 | */ 45 | void epd_init(); 46 | 47 | +void epd_deinit(); 48 | + 49 | /** 50 | * @brief Enable display power supply. 51 | */ 52 | @@ -395,4 +397,4 @@ void write_string(const GFXfont *font, c 53 | #endif 54 | /******************************************************************************/ 55 | /*** END OF FILE ***/ 56 | -/******************************************************************************/ 57 | \ No newline at end of file 58 | +/******************************************************************************/ 59 | Index: LilyGo-EPD47/src/rmt_pulse.c 60 | =================================================================== 61 | --- LilyGo-EPD47.orig/src/rmt_pulse.c 62 | +++ LilyGo-EPD47/src/rmt_pulse.c 63 | @@ -80,6 +80,12 @@ void rmt_pulse_init(gpio_num_t pin) 64 | } 65 | 66 | 67 | +void rmt_pulse_deinit() 68 | +{ 69 | + rmt_driver_uninstall(row_rmt_config.channel); 70 | +} 71 | + 72 | + 73 | void IRAM_ATTR pulse_ckv_ticks(uint16_t high_time_ticks, 74 | uint16_t low_time_ticks, bool wait) 75 | { 76 | @@ -133,4 +139,4 @@ void IRAM_ATTR pulse_ckv_us(uint16_t hig 77 | 78 | /******************************************************************************/ 79 | /*** END OF FILE ***/ 80 | -/******************************************************************************/ 81 | \ No newline at end of file 82 | +/******************************************************************************/ 83 | Index: LilyGo-EPD47/src/rmt_pulse.h 84 | =================================================================== 85 | --- LilyGo-EPD47.orig/src/rmt_pulse.h 86 | +++ LilyGo-EPD47/src/rmt_pulse.h 87 | @@ -41,6 +41,8 @@ extern "C" { 88 | */ 89 | void rmt_pulse_init(gpio_num_t pin); 90 | 91 | +void rmt_pulse_deinit(); 92 | + 93 | /** 94 | * @brief Outputs a single pulse (high -> low) on the configured pin. 95 | * 96 | @@ -75,4 +77,4 @@ void IRAM_ATTR pulse_ckv_ticks(uint16_t 97 | #endif 98 | /******************************************************************************/ 99 | /*** END OF FILE ***/ 100 | -/******************************************************************************/ 101 | \ No newline at end of file 102 | +/******************************************************************************/ 103 | Index: LilyGo-EPD47/src/i2s_data_bus.c 104 | =================================================================== 105 | --- LilyGo-EPD47.orig/src/i2s_data_bus.c 106 | +++ LilyGo-EPD47/src/i2s_data_bus.c 107 | @@ -40,8 +40,6 @@ typedef struct 108 | uint8_t *buf_b; 109 | } i2s_parallel_state_t; 110 | 111 | -static esp_lcd_panel_io_handle_t io_handle = NULL; 112 | - 113 | /******************************************************************************/ 114 | /*** local function prototypes ***/ 115 | /******************************************************************************/ 116 | @@ -100,6 +98,9 @@ static gpio_num_t start_pulse_pin; 117 | 118 | static uint8_t buffer[(960 + 32) / 4] = { 0 }; 119 | 120 | +static esp_lcd_i80_bus_handle_t i80_bus = NULL; 121 | +static esp_lcd_panel_io_handle_t io_handle = NULL; 122 | + 123 | /******************************************************************************/ 124 | /*** exported functions ***/ 125 | /******************************************************************************/ 126 | @@ -362,7 +363,7 @@ void i2s_bus_init(i2s_bus_config *cfg) 127 | // start_pulse_pin = cfg->start_pulse; 128 | 129 | ESP_LOGI(TAG, "Initialize Intel 8080 bus"); 130 | - esp_lcd_i80_bus_handle_t i80_bus = NULL; 131 | + 132 | esp_lcd_i80_bus_config_t bus_config = { 133 | .dc_gpio_num = cfg->start_pulse, 134 | .wr_gpio_num = cfg->clock, 135 | @@ -404,6 +405,7 @@ void i2s_bus_init(i2s_bus_config *cfg) 136 | 137 | void i2s_deinit() 138 | { 139 | +#if USER_I2S_REG 140 | esp_intr_free(gI2S_intr_handle); 141 | 142 | free(i2s_state.buf_a); 143 | @@ -412,6 +414,10 @@ void i2s_deinit() 144 | free((void *)i2s_state.dma_desc_b); 145 | 146 | periph_module_disable(PERIPH_I2S1_MODULE); 147 | +#else 148 | + esp_lcd_panel_io_del(io_handle); 149 | + esp_lcd_del_i80_bus(i80_bus); 150 | +#endif 151 | } 152 | 153 | /******************************************************************************/ 154 | Index: LilyGo-EPD47/src/ed047tc1.c 155 | =================================================================== 156 | --- LilyGo-EPD47.orig/src/ed047tc1.c 157 | +++ LilyGo-EPD47/src/ed047tc1.c 158 | @@ -142,6 +142,14 @@ void epd_base_init(uint32_t epd_row_widt 159 | rmt_pulse_init(CKV); 160 | } 161 | 162 | + 163 | +void epd_base_deinit() 164 | +{ 165 | + rmt_pulse_deinit(); 166 | + i2s_deinit(); 167 | +} 168 | + 169 | + 170 | void epd_poweron() 171 | { 172 | config_reg.ep_scan_direction = true; 173 | -------------------------------------------------------------------------------- /libs/LilyGo-EPD47/patches/002-Modify-libjpeg.patch: -------------------------------------------------------------------------------- 1 | Index: LilyGo-EPD47/src/libjpeg/libjpeg.c 2 | =================================================================== 3 | --- LilyGo-EPD47.orig/src/libjpeg/libjpeg.c 4 | +++ LilyGo-EPD47/src/libjpeg/libjpeg.c 5 | @@ -19,6 +19,8 @@ 6 | #include "rom/tjpgd.h" 7 | #endif 8 | 9 | +#include "py/runtime.h" 10 | + 11 | #include 12 | #include 13 | #include 14 | @@ -126,7 +128,7 @@ const char *TAG = "LIB_JPEG"; 15 | void libjpeg_init(void) 16 | { 17 | //解码图像内存申请, 来自PSRAM 18 | - decoded_image = (uint8_t *)heap_caps_malloc(EPD_WIDTH * EPD_HEIGHT, MALLOC_CAP_SPIRAM); 19 | + decoded_image = (uint8_t *)m_malloc(EPD_WIDTH * EPD_HEIGHT); 20 | if (decoded_image == NULL) 21 | { 22 | ESP_LOGE(TAG, "Initial alloc decoded_image failed!"); 23 | @@ -222,7 +224,7 @@ void show_jpg_from_buff(uint8_t *buff, u 24 | 25 | void libjpeg_deinit(void) 26 | { 27 | - free(decoded_image); 28 | + m_free(decoded_image); 29 | } 30 | 31 | /******************************************************************************/ 32 | -------------------------------------------------------------------------------- /libs/LilyGo-EPD47/patches/003-adapt-to-esp-idf-v4.0.2.patch: -------------------------------------------------------------------------------- 1 | Index: LilyGo-EPD47/src/epd_driver.c 2 | =================================================================== 3 | --- LilyGo-EPD47.orig/src/epd_driver.c 4 | +++ LilyGo-EPD47/src/epd_driver.c 5 | @@ -5,6 +5,7 @@ 6 | #include "epd_driver.h" 7 | #include "ed047tc1.h" 8 | 9 | +#include 10 | #include 11 | #include 12 | #include 13 | @@ -39,6 +40,12 @@ 14 | } 15 | #endif 16 | 17 | +#if CONFIG_IDF_TARGET_ESP32 == 1 18 | +#define USER_I2S_REG 1 19 | +#elif CONFIG_IDF_TARGET_ESP32S3 == 1 20 | +#define USER_I2S_REG 0 21 | +#endif 22 | + 23 | /******************************************************************************/ 24 | /*** type definitions ***/ 25 | /******************************************************************************/ 26 | Index: LilyGo-EPD47/src/i2s_data_bus.c 27 | =================================================================== 28 | --- LilyGo-EPD47.orig/src/i2s_data_bus.c 29 | +++ LilyGo-EPD47/src/i2s_data_bus.c 30 | @@ -5,21 +5,29 @@ 31 | 32 | #include "i2s_data_bus.h" 33 | 34 | -#include 35 | +#include 36 | +#include 37 | +#include 38 | #include 39 | +#if CONFIG_IDF_TARGET_ESP32 == 1 40 | +#include 41 | #include 42 | #include 43 | #include 44 | #include 45 | -#include "esp_lcd_panel_io.h" 46 | -#include "esp_err.h" 47 | -#include "esp_log.h" 48 | +#elif CONFIG_IDF_TARGET_ESP32S3 == 1 49 | +#include 50 | +#endif 51 | 52 | /******************************************************************************/ 53 | /*** macro definitions ***/ 54 | /******************************************************************************/ 55 | 56 | +#if CONFIG_IDF_TARGET_ESP32 == 1 57 | +#define USER_I2S_REG 1 58 | +#elif CONFIG_IDF_TARGET_ESP32S3 == 1 59 | #define USER_I2S_REG 0 60 | +#endif 61 | 62 | /******************************************************************************/ 63 | /*** type definitions ***/ 64 | @@ -30,6 +38,7 @@ static const char *TAG = "I80"; 65 | /// DMA descriptors for front and back line buffer. 66 | /// We use two buffers, so one can be filled while the other 67 | /// is transmitted. 68 | +#if USER_I2S_REG == 1 69 | typedef struct 70 | { 71 | volatile lldesc_t *dma_desc_a; 72 | @@ -39,6 +48,7 @@ typedef struct 73 | uint8_t *buf_a; 74 | uint8_t *buf_b; 75 | } i2s_parallel_state_t; 76 | +#endif 77 | 78 | /******************************************************************************/ 79 | /*** local function prototypes ***/ 80 | @@ -47,6 +57,7 @@ typedef struct 81 | /** 82 | * @brief Initializes a DMA descriptor. 83 | */ 84 | +#if USER_I2S_REG == 1 85 | static void fill_dma_desc(volatile lldesc_t *dmadesc, uint8_t *buf, i2s_bus_config *cfg); 86 | 87 | /** 88 | @@ -64,6 +75,7 @@ static void gpio_setup_out(int32_t gpio, 89 | * @brief Resets "Start Pulse" signal when the current row output is done. 90 | */ 91 | static void IRAM_ATTR i2s_int_hdl(void *arg); 92 | +#endif 93 | 94 | /******************************************************************************/ 95 | /*** exported variables ***/ 96 | @@ -73,6 +85,7 @@ static void IRAM_ATTR i2s_int_hdl(void * 97 | /*** local variables ***/ 98 | /******************************************************************************/ 99 | 100 | +#if USER_I2S_REG == 1 101 | /** 102 | * @brief Indicates which line buffer is currently back / front. 103 | */ 104 | @@ -84,22 +97,27 @@ static int32_t current_buffer = 0; 105 | static i2s_parallel_state_t i2s_state; 106 | 107 | static intr_handle_t gI2S_intr_handle = NULL; 108 | +#endif 109 | 110 | /** 111 | * @brief Indicates the device has finished its transmission and is ready again. 112 | */ 113 | static volatile bool output_done = true; 114 | 115 | +#if USER_I2S_REG == 1 116 | /** 117 | * @brief The start pulse pin extracted from the configuration for use in 118 | * the "done" interrupt. 119 | */ 120 | static gpio_num_t start_pulse_pin; 121 | +#endif 122 | 123 | static uint8_t buffer[(960 + 32) / 4] = { 0 }; 124 | 125 | +#if USER_I2S_REG == 0 126 | static esp_lcd_i80_bus_handle_t i80_bus = NULL; 127 | static esp_lcd_panel_io_handle_t io_handle = NULL; 128 | +#endif 129 | 130 | /******************************************************************************/ 131 | /*** exported functions ***/ 132 | @@ -424,6 +442,7 @@ void i2s_deinit() 133 | /*** local functions ***/ 134 | /******************************************************************************/ 135 | 136 | +#if USER_I2S_REG == 1 137 | /// Initializes a DMA descriptor. 138 | static void fill_dma_desc(volatile lldesc_t *dmadesc, uint8_t *buf, 139 | i2s_bus_config *cfg) 140 | @@ -459,7 +478,6 @@ static void gpio_setup_out(int32_t gpio, 141 | } 142 | 143 | 144 | -#if USER_I2S_REG 145 | /// Resets "Start Pulse" signal when the current row output is done. 146 | static void IRAM_ATTR i2s_int_hdl(void *arg) 147 | { 148 | -------------------------------------------------------------------------------- /micropython/micropython.mk: -------------------------------------------------------------------------------- 1 | 2 | include $(INCLUDE_DIR)/download.mk 3 | include $(INCLUDE_DIR)/package.mk 4 | 5 | define micropython/info 6 | PKG_NAME:=micropython 7 | PKG_SOURCE_URL:=https://github.com/micropython/micropython.git 8 | PKG_SOURCE_PROTO:=git 9 | PKG_SOURCE_VERSION:=v1.19 10 | PKG_SOURCE_MD5:=639c7fcbe62a8252cf9367147d94c150 11 | PKG_SOURCE_OPT:=--recurse-submodules 12 | endef 13 | 14 | define micropython/prereq 15 | $(eval $(micropython/info)) 16 | $(call Package/prereq,$(TARGET_BUILD_DIR)) 17 | $(call Package/patches,$(TARGET_BUILD_DIR)/$(PKG_NAME),$(TOP_DIR)/$(PKG_NAME)/patches-$(PKG_SOURCE_VERSION)) 18 | endef 19 | -------------------------------------------------------------------------------- /micropython/patches-v1.18/000-modify-partition-table.patch: -------------------------------------------------------------------------------- 1 | Index: micropython/ports/esp32/partitions.csv 2 | =================================================================== 3 | --- micropython.orig/ports/esp32/partitions.csv 4 | +++ micropython/ports/esp32/partitions.csv 5 | @@ -3,5 +3,5 @@ 6 | # Name, Type, SubType, Offset, Size, Flags 7 | nvs, data, nvs, 0x9000, 0x6000, 8 | phy_init, data, phy, 0xf000, 0x1000, 9 | -factory, app, factory, 0x10000, 0x180000, 10 | +factory, app, factory, 0x10000, 0x190000, 11 | vfs, data, fat, 0x200000, 0x200000, 12 | -------------------------------------------------------------------------------- /micropython/patches-v1.18/001-Added-EXTMOD_FROZEN_DIR-parameter.patch: -------------------------------------------------------------------------------- 1 | Index: micropython/ports/esp32/Makefile 2 | =================================================================== 3 | --- micropython.orig/ports/esp32/Makefile 4 | +++ micropython/ports/esp32/Makefile 5 | @@ -30,6 +30,10 @@ ifdef FROZEN_MANIFEST 6 | IDFPY_FLAGS += -D MICROPY_FROZEN_MANIFEST=$(FROZEN_MANIFEST) 7 | endif 8 | 9 | +ifdef EXTMOD_FROZEN_DIR 10 | + IDFPY_FLAGS += -D EXTMOD_FROZEN_DIR=$(EXTMOD_FROZEN_DIR) 11 | +endif 12 | + 13 | all: 14 | idf.py $(IDFPY_FLAGS) build 15 | @$(PYTHON) makeimg.py \ 16 | -------------------------------------------------------------------------------- /micropython/patches-v1.18/008-Added-MICROPY_BOARD_DIR-parameter.patch: -------------------------------------------------------------------------------- 1 | Index: micropython/ports/esp32/Makefile 2 | =================================================================== 3 | --- micropython.orig/ports/esp32/Makefile 4 | +++ micropython/ports/esp32/Makefile 5 | @@ -34,6 +34,10 @@ ifdef EXTMOD_FROZEN_DIR 6 | IDFPY_FLAGS += -D EXTMOD_FROZEN_DIR=$(EXTMOD_FROZEN_DIR) 7 | endif 8 | 9 | +ifdef MICROPY_BOARD_DIR 10 | + IDFPY_FLAGS += -D MICROPY_BOARD_DIR=$(MICROPY_BOARD_DIR) 11 | +endif 12 | + 13 | all: 14 | idf.py $(IDFPY_FLAGS) build 15 | @$(PYTHON) makeimg.py \ 16 | -------------------------------------------------------------------------------- /micropython/patches-v1.18/009-Add-T-PicoC3-board-file.patch: -------------------------------------------------------------------------------- 1 | Index: micropython/lib/pico-sdk/src/boards/include/boards/lilygo_t_picoc3.h 2 | =================================================================== 3 | --- /dev/null 4 | +++ micropython/lib/pico-sdk/src/boards/include/boards/lilygo_t_picoc3.h 5 | @@ -0,0 +1,84 @@ 6 | +/* 7 | + * Copyright (c) 2020 Raspberry Pi (Trading) Ltd. 8 | + * 9 | + * SPDX-License-Identifier: BSD-3-Clause 10 | + */ 11 | + 12 | +// ----------------------------------------------------- 13 | +// NOTE: THIS HEADER IS ALSO INCLUDED BY ASSEMBLER SO 14 | +// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES 15 | +// ----------------------------------------------------- 16 | + 17 | +// This header may be included by other board headers as "boards/pico.h" 18 | + 19 | +#ifndef _BOARDS_PICO_H 20 | +#define _BOARDS_PICO_H 21 | + 22 | +// For board detection 23 | +#define RASPBERRYPI_PICO 24 | + 25 | +// --- UART --- 26 | +#ifndef PICO_DEFAULT_UART 27 | +#define PICO_DEFAULT_UART 0 28 | +#endif 29 | +#ifndef PICO_DEFAULT_UART_TX_PIN 30 | +#define PICO_DEFAULT_UART_TX_PIN 0 31 | +#endif 32 | +#ifndef PICO_DEFAULT_UART_RX_PIN 33 | +#define PICO_DEFAULT_UART_RX_PIN 1 34 | +#endif 35 | + 36 | +// --- LED --- 37 | +#ifndef PICO_DEFAULT_LED_PIN 38 | +#define PICO_DEFAULT_LED_PIN 25 39 | +#endif 40 | +// no PICO_DEFAULT_WS2812_PIN 41 | + 42 | +// --- I2C --- 43 | +#ifndef PICO_DEFAULT_I2C 44 | +#define PICO_DEFAULT_I2C 0 45 | +#endif 46 | +#ifndef PICO_DEFAULT_I2C_SDA_PIN 47 | +#define PICO_DEFAULT_I2C_SDA_PIN 4 48 | +#endif 49 | +#ifndef PICO_DEFAULT_I2C_SCL_PIN 50 | +#define PICO_DEFAULT_I2C_SCL_PIN 5 51 | +#endif 52 | + 53 | +// --- SPI --- 54 | +#ifndef PICO_DEFAULT_SPI 55 | +#define PICO_DEFAULT_SPI 0 56 | +#endif 57 | +#ifndef PICO_DEFAULT_SPI_SCK_PIN 58 | +#define PICO_DEFAULT_SPI_SCK_PIN 18 59 | +#endif 60 | +#ifndef PICO_DEFAULT_SPI_TX_PIN 61 | +#define PICO_DEFAULT_SPI_TX_PIN 19 62 | +#endif 63 | +#ifndef PICO_DEFAULT_SPI_RX_PIN 64 | +#define PICO_DEFAULT_SPI_RX_PIN 16 65 | +#endif 66 | +#ifndef PICO_DEFAULT_SPI_CSN_PIN 67 | +#define PICO_DEFAULT_SPI_CSN_PIN 17 68 | +#endif 69 | + 70 | +// --- FLASH --- 71 | + 72 | +#define PICO_BOOT_STAGE2_CHOOSE_W25Q080 1 73 | + 74 | +#ifndef PICO_FLASH_SPI_CLKDIV 75 | +#define PICO_FLASH_SPI_CLKDIV 2 76 | +#endif 77 | + 78 | +#ifndef PICO_FLASH_SIZE_BYTES 79 | +#define PICO_FLASH_SIZE_BYTES (2 * 1024 * 1024) 80 | +#endif 81 | + 82 | +// Drive high to force power supply into PWM mode (lower ripple on 3V3 at light loads) 83 | +#define PICO_SMPS_MODE_PIN 23 84 | + 85 | +#ifndef PICO_RP2040_B0_SUPPORTED 86 | +#define PICO_RP2040_B0_SUPPORTED 1 87 | +#endif 88 | + 89 | +#endif 90 | -------------------------------------------------------------------------------- /micropython/patches-v1.18/010-Modify-makefile-of-rp2.patch: -------------------------------------------------------------------------------- 1 | Index: micropython/ports/rp2/Makefile 2 | =================================================================== 3 | --- micropython.orig/ports/rp2/Makefile 4 | +++ micropython/ports/rp2/Makefile 5 | @@ -14,6 +14,14 @@ ifdef USER_C_MODULES 6 | CMAKE_ARGS += -DUSER_C_MODULES=${USER_C_MODULES} 7 | endif 8 | 9 | +ifdef EXTMOD_FROZEN_DIR 10 | + CMAKE_ARGS += -D EXTMOD_FROZEN_DIR=$(EXTMOD_FROZEN_DIR) 11 | +endif 12 | + 13 | +ifdef MICROPY_BOARD_DIR 14 | + CMAKE_ARGS += -D MICROPY_BOARD_DIR=$(MICROPY_BOARD_DIR) 15 | +endif 16 | + 17 | all: 18 | [ -d $(BUILD) ] || cmake -S . -B $(BUILD) -DPICO_BUILD_DOCS=0 ${CMAKE_ARGS} 19 | $(MAKE) $(MAKESILENT) -C $(BUILD) 20 | -------------------------------------------------------------------------------- /micropython/patches-v1.18/011-Add-esp_lcd-component.patch: -------------------------------------------------------------------------------- 1 | Index: micropython/ports/esp32/main/CMakeLists.txt 2 | =================================================================== 3 | --- micropython.orig/ports/esp32/main/CMakeLists.txt 4 | +++ micropython/ports/esp32/main/CMakeLists.txt 5 | @@ -121,6 +121,12 @@ set(IDF_COMPONENTS 6 | xtensa 7 | ) 8 | 9 | +string(COMPARE EQUAL MICROPY_BOARD "LILYGO_T5-4.7-PLUS" S_out) 10 | + 11 | +if(IDF_TARGET STREQUAL "esp32s3" AND S_out STREQUAL "0") 12 | + list(APPEND IDF_COMPONENTS esp_lcd) 13 | +endif() 14 | + 15 | if(IDF_VERSION_MINOR GREATER_EQUAL 1 OR IDF_VERSION_MAJOR GREATER_EQUAL 5) 16 | list(APPEND IDF_COMPONENTS esp_netif) 17 | endif() 18 | -------------------------------------------------------------------------------- /micropython/patches-v1.18/012-Automatically-download-ble-stack.patch: -------------------------------------------------------------------------------- 1 | Index: micropython/ports/nrf/Makefile 2 | =================================================================== 3 | --- micropython.orig/ports/nrf/Makefile 4 | +++ micropython/ports/nrf/Makefile 5 | @@ -358,13 +358,16 @@ $(filter $(PY_BUILD)/../extmod/vfs_fat_% 6 | .PHONY: all flash deploy sd binary hex 7 | 8 | ifeq ($(MCU_VARIANT), nrf91) 9 | -all: binary hex secureboot 10 | +all: $(NEED_DOWN_BLE_STACK) binary hex secureboot 11 | else 12 | -all: binary hex 13 | +all: $(NEED_DOWN_BLE_STACK) binary hex 14 | endif 15 | 16 | OUTPUT_FILENAME = firmware 17 | 18 | +download_ble_stack: 19 | + drivers/bluetooth/download_ble_stack.sh 20 | + 21 | ## Create binary .bin file from the .out file 22 | binary: $(BUILD)/$(OUTPUT_FILENAME).bin 23 | 24 | Index: micropython/ports/nrf/drivers/bluetooth/bluetooth_common.mk 25 | =================================================================== 26 | --- micropython.orig/ports/nrf/drivers/bluetooth/bluetooth_common.mk 27 | +++ micropython/ports/nrf/drivers/bluetooth/bluetooth_common.mk 28 | @@ -1,6 +1,7 @@ 29 | 30 | SOFTDEV_HEX_NAME ?= 31 | SOFTDEV_HEX_PATH ?= 32 | +NEED_DOWN_BLE_STACK ?= 33 | 34 | ifeq ($(SD), s110) 35 | INC += -Idrivers/bluetooth/$(SD)_$(MCU_VARIANT)_$(SOFTDEV_VERSION)/$(SD)_$(MCU_VARIANT)_$(SOFTDEV_VERSION)_API/include 36 | @@ -45,5 +46,6 @@ endef 37 | SOFTDEV_HEX = $(SOFTDEV_HEX_PATH)/$(SOFTDEV_HEX_NAME) 38 | 39 | ifeq ($(shell test ! -e $(SOFTDEV_HEX) && echo -n no),no) 40 | - $(error $(STACK_MISSING_ERROR)) 41 | + $(warning $(STACK_MISSING_ERROR)) 42 | + NEED_DOWN_BLE_STACK = download_ble_stack 43 | endif 44 | -------------------------------------------------------------------------------- /micropython/patches-v1.19/0001-Added-EXTMOD_FROZEN_DIR-parameter.patch: -------------------------------------------------------------------------------- 1 | Index: micropython/ports/esp32/Makefile 2 | =================================================================== 3 | --- micropython.orig/ports/esp32/Makefile 4 | +++ micropython/ports/esp32/Makefile 5 | @@ -31,7 +31,11 @@ endif 6 | IDFPY_FLAGS += -D MICROPY_BOARD=$(BOARD) -B $(BUILD) $(CMAKE_ARGS) 7 | 8 | ifdef FROZEN_MANIFEST 9 | - IDFPY_FLAGS += -D MICROPY_FROZEN_MANIFEST=$(FROZEN_MANIFEST) 10 | + IDFPY_FLAGS += -D MICROPY_FROZEN_MANIFEST=$(FROZEN_MANIFEST) 11 | +endif 12 | + 13 | +ifdef EXTMOD_FROZEN_DIR 14 | + IDFPY_FLAGS += -D EXTMOD_FROZEN_DIR=$(EXTMOD_FROZEN_DIR) 15 | endif 16 | 17 | all: 18 | -------------------------------------------------------------------------------- /micropython/patches-v1.19/0008-Added-MICROPY_BOARD_DIR-parameter.patch: -------------------------------------------------------------------------------- 1 | Index: micropython/ports/esp32/Makefile 2 | =================================================================== 3 | --- micropython.orig/ports/esp32/Makefile 4 | +++ micropython/ports/esp32/Makefile 5 | @@ -38,6 +38,10 @@ ifdef EXTMOD_FROZEN_DIR 6 | IDFPY_FLAGS += -D EXTMOD_FROZEN_DIR=$(EXTMOD_FROZEN_DIR) 7 | endif 8 | 9 | +ifdef MICROPY_BOARD_DIR 10 | + IDFPY_FLAGS += -D MICROPY_BOARD_DIR=$(MICROPY_BOARD_DIR) 11 | +endif 12 | + 13 | all: 14 | idf.py $(IDFPY_FLAGS) build 15 | @$(PYTHON) makeimg.py \ 16 | -------------------------------------------------------------------------------- /micropython/patches-v1.19/0009-Add-T-PicoC3-board-file.patch: -------------------------------------------------------------------------------- 1 | Index: micropython/lib/pico-sdk/src/boards/include/boards/lilygo_t_picoc3.h 2 | =================================================================== 3 | --- /dev/null 4 | +++ micropython/lib/pico-sdk/src/boards/include/boards/lilygo_t_picoc3.h 5 | @@ -0,0 +1,84 @@ 6 | +/* 7 | + * Copyright (c) 2020 Raspberry Pi (Trading) Ltd. 8 | + * 9 | + * SPDX-License-Identifier: BSD-3-Clause 10 | + */ 11 | + 12 | +// ----------------------------------------------------- 13 | +// NOTE: THIS HEADER IS ALSO INCLUDED BY ASSEMBLER SO 14 | +// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES 15 | +// ----------------------------------------------------- 16 | + 17 | +// This header may be included by other board headers as "boards/pico.h" 18 | + 19 | +#ifndef _BOARDS_PICO_H 20 | +#define _BOARDS_PICO_H 21 | + 22 | +// For board detection 23 | +#define RASPBERRYPI_PICO 24 | + 25 | +// --- UART --- 26 | +#ifndef PICO_DEFAULT_UART 27 | +#define PICO_DEFAULT_UART 0 28 | +#endif 29 | +#ifndef PICO_DEFAULT_UART_TX_PIN 30 | +#define PICO_DEFAULT_UART_TX_PIN 0 31 | +#endif 32 | +#ifndef PICO_DEFAULT_UART_RX_PIN 33 | +#define PICO_DEFAULT_UART_RX_PIN 1 34 | +#endif 35 | + 36 | +// --- LED --- 37 | +#ifndef PICO_DEFAULT_LED_PIN 38 | +#define PICO_DEFAULT_LED_PIN 25 39 | +#endif 40 | +// no PICO_DEFAULT_WS2812_PIN 41 | + 42 | +// --- I2C --- 43 | +#ifndef PICO_DEFAULT_I2C 44 | +#define PICO_DEFAULT_I2C 0 45 | +#endif 46 | +#ifndef PICO_DEFAULT_I2C_SDA_PIN 47 | +#define PICO_DEFAULT_I2C_SDA_PIN 4 48 | +#endif 49 | +#ifndef PICO_DEFAULT_I2C_SCL_PIN 50 | +#define PICO_DEFAULT_I2C_SCL_PIN 5 51 | +#endif 52 | + 53 | +// --- SPI --- 54 | +#ifndef PICO_DEFAULT_SPI 55 | +#define PICO_DEFAULT_SPI 0 56 | +#endif 57 | +#ifndef PICO_DEFAULT_SPI_SCK_PIN 58 | +#define PICO_DEFAULT_SPI_SCK_PIN 18 59 | +#endif 60 | +#ifndef PICO_DEFAULT_SPI_TX_PIN 61 | +#define PICO_DEFAULT_SPI_TX_PIN 19 62 | +#endif 63 | +#ifndef PICO_DEFAULT_SPI_RX_PIN 64 | +#define PICO_DEFAULT_SPI_RX_PIN 16 65 | +#endif 66 | +#ifndef PICO_DEFAULT_SPI_CSN_PIN 67 | +#define PICO_DEFAULT_SPI_CSN_PIN 17 68 | +#endif 69 | + 70 | +// --- FLASH --- 71 | + 72 | +#define PICO_BOOT_STAGE2_CHOOSE_W25Q080 1 73 | + 74 | +#ifndef PICO_FLASH_SPI_CLKDIV 75 | +#define PICO_FLASH_SPI_CLKDIV 2 76 | +#endif 77 | + 78 | +#ifndef PICO_FLASH_SIZE_BYTES 79 | +#define PICO_FLASH_SIZE_BYTES (2 * 1024 * 1024) 80 | +#endif 81 | + 82 | +// Drive high to force power supply into PWM mode (lower ripple on 3V3 at light loads) 83 | +#define PICO_SMPS_MODE_PIN 23 84 | + 85 | +#ifndef PICO_RP2040_B0_SUPPORTED 86 | +#define PICO_RP2040_B0_SUPPORTED 1 87 | +#endif 88 | + 89 | +#endif 90 | -------------------------------------------------------------------------------- /micropython/patches-v1.19/0010-Modify-makefile-of-rp2.patch: -------------------------------------------------------------------------------- 1 | Index: micropython/ports/rp2/Makefile 2 | =================================================================== 3 | --- micropython.orig/ports/rp2/Makefile 4 | +++ micropython/ports/rp2/Makefile 5 | @@ -22,6 +22,14 @@ ifeq ($(DEBUG),1) 6 | CMAKE_ARGS += -DCMAKE_BUILD_TYPE=Debug 7 | endif 8 | 9 | +ifdef EXTMOD_FROZEN_DIR 10 | + CMAKE_ARGS += -D EXTMOD_FROZEN_DIR=$(EXTMOD_FROZEN_DIR) 11 | +endif 12 | + 13 | +ifdef MICROPY_BOARD_DIR 14 | + CMAKE_ARGS += -D MICROPY_BOARD_DIR=$(MICROPY_BOARD_DIR) 15 | +endif 16 | + 17 | all: 18 | [ -e $(BUILD)/Makefile ] || cmake -S . -B $(BUILD) -DPICO_BUILD_DOCS=0 ${CMAKE_ARGS} 19 | $(MAKE) $(MAKESILENT) -C $(BUILD) 20 | -------------------------------------------------------------------------------- /micropython/patches-v1.19/0011-Add-esp_lcd-component.patch: -------------------------------------------------------------------------------- 1 | Index: micropython/ports/esp32/main/CMakeLists.txt 2 | =================================================================== 3 | --- micropython.orig/ports/esp32/main/CMakeLists.txt 4 | +++ micropython/ports/esp32/main/CMakeLists.txt 5 | @@ -126,6 +126,13 @@ set(IDF_COMPONENTS 6 | xtensa 7 | ) 8 | 9 | +string(COMPARE EQUAL MICROPY_BOARD "LILYGO_T5-4.7-PLUS" S_out) 10 | + 11 | +if(IDF_TARGET STREQUAL "esp32s3" AND S_out STREQUAL "0") 12 | + list(APPEND IDF_COMPONENTS esp_lcd) 13 | +endif() 14 | + 15 | + 16 | if(IDF_VERSION_MINOR GREATER_EQUAL 1 OR IDF_VERSION_MAJOR GREATER_EQUAL 5) 17 | list(APPEND IDF_COMPONENTS esp_netif) 18 | endif() 19 | -------------------------------------------------------------------------------- /micropython/patches-v1.19/0012-Automatically-download-ble-stack.patch: -------------------------------------------------------------------------------- 1 | Index: micropython/ports/nrf/Makefile 2 | =================================================================== 3 | --- micropython.orig/ports/nrf/Makefile 4 | +++ micropython/ports/nrf/Makefile 5 | @@ -362,13 +362,16 @@ $(filter $(PY_BUILD)/../extmod/vfs_fat_% 6 | .PHONY: all flash deploy sd binary hex 7 | 8 | ifeq ($(MCU_VARIANT), nrf91) 9 | -all: binary hex secureboot 10 | +all: $(NEED_DOWN_BLE_STACK) binary hex secureboot 11 | else 12 | -all: binary hex 13 | +all: $(NEED_DOWN_BLE_STACK) binary hex 14 | endif 15 | 16 | OUTPUT_FILENAME = firmware 17 | 18 | +download_ble_stack: 19 | + drivers/bluetooth/download_ble_stack.sh 20 | + 21 | ## Create binary .bin file from the .out file 22 | binary: $(BUILD)/$(OUTPUT_FILENAME).bin 23 | 24 | Index: micropython/ports/nrf/drivers/bluetooth/bluetooth_common.mk 25 | =================================================================== 26 | --- micropython.orig/ports/nrf/drivers/bluetooth/bluetooth_common.mk 27 | +++ micropython/ports/nrf/drivers/bluetooth/bluetooth_common.mk 28 | @@ -1,6 +1,7 @@ 29 | 30 | SOFTDEV_HEX_NAME ?= 31 | SOFTDEV_HEX_PATH ?= 32 | +NEED_DOWN_BLE_STACK ?= 33 | 34 | ifeq ($(SD), s110) 35 | INC += -Idrivers/bluetooth/$(SD)_$(MCU_VARIANT)_$(SOFTDEV_VERSION)/$(SD)_$(MCU_VARIANT)_$(SOFTDEV_VERSION)_API/include 36 | @@ -45,5 +46,6 @@ endef 37 | SOFTDEV_HEX = $(SOFTDEV_HEX_PATH)/$(SOFTDEV_HEX_NAME) 38 | 39 | ifeq ($(shell test ! -e $(SOFTDEV_HEX) && echo -n no),no) 40 | - $(error $(STACK_MISSING_ERROR)) 41 | + $(warning $(STACK_MISSING_ERROR)) 42 | + NEED_DOWN_BLE_STACK = download_ble_stack 43 | endif 44 | -------------------------------------------------------------------------------- /micropython/patches/000-modify-partition-table.patch: -------------------------------------------------------------------------------- 1 | Index: micropython/ports/esp32/partitions.csv 2 | =================================================================== 3 | --- micropython.orig/ports/esp32/partitions.csv 4 | +++ micropython/ports/esp32/partitions.csv 5 | @@ -3,5 +3,5 @@ 6 | # Name, Type, SubType, Offset, Size, Flags 7 | nvs, data, nvs, 0x9000, 0x6000, 8 | phy_init, data, phy, 0xf000, 0x1000, 9 | -factory, app, factory, 0x10000, 0x180000, 10 | +factory, app, factory, 0x10000, 0x190000, 11 | vfs, data, fat, 0x200000, 0x200000, 12 | -------------------------------------------------------------------------------- /micropython/patches/001-Added-EXTMOD_FROZEN_DIR-parameter.patch: -------------------------------------------------------------------------------- 1 | Index: micropython/ports/esp32/Makefile 2 | =================================================================== 3 | --- micropython.orig/ports/esp32/Makefile 4 | +++ micropython/ports/esp32/Makefile 5 | @@ -30,6 +30,10 @@ ifdef FROZEN_MANIFEST 6 | IDFPY_FLAGS += -D MICROPY_FROZEN_MANIFEST=$(FROZEN_MANIFEST) 7 | endif 8 | 9 | +ifdef EXTMOD_FROZEN_DIR 10 | + IDFPY_FLAGS += -D EXTMOD_FROZEN_DIR=$(EXTMOD_FROZEN_DIR) 11 | +endif 12 | + 13 | all: 14 | idf.py $(IDFPY_FLAGS) build 15 | @$(PYTHON) makeimg.py \ 16 | -------------------------------------------------------------------------------- /micropython/patches/002-Add-LILYGO_EPD47-board.patch: -------------------------------------------------------------------------------- 1 | Index: micropython/ports/esp32/boards/LILYGO_EPD47/mpconfigboard.cmake 2 | =================================================================== 3 | --- /dev/null 4 | +++ micropython/ports/esp32/boards/LILYGO_EPD47/mpconfigboard.cmake 5 | @@ -0,0 +1,15 @@ 6 | +set(SDKCONFIG_DEFAULTS 7 | + boards/sdkconfig.base 8 | + boards/sdkconfig.ble 9 | + boards/sdkconfig.spiram 10 | + #boards/GENERIC_SPIRAM/sdkconfig.board 11 | +) 12 | + 13 | +if(NOT MICROPY_FROZEN_MANIFEST) 14 | + set(MICROPY_FROZEN_MANIFEST 15 | + ${MICROPY_PORT_DIR}/boards/manifest.py 16 | + $(EXTMOD_FROZEN_DIR)/touch/manifest.py 17 | + ) 18 | +endif() 19 | + 20 | +set(EXTMOD_EPD 1) 21 | \ No newline at end of file 22 | Index: micropython/ports/esp32/boards/LILYGO_EPD47/mpconfigboard.h 23 | =================================================================== 24 | --- /dev/null 25 | +++ micropython/ports/esp32/boards/LILYGO_EPD47/mpconfigboard.h 26 | @@ -0,0 +1,2 @@ 27 | +#define MICROPY_HW_BOARD_NAME "ESP32 LILYGO EPD47" 28 | +#define MICROPY_HW_MCU_NAME "ESP32" 29 | \ No newline at end of file 30 | -------------------------------------------------------------------------------- /micropython/patches/003-Add-LILYGO_T-SIM7000G-board.patch: -------------------------------------------------------------------------------- 1 | Index: micropython/ports/esp32/boards/LILYGO_T-SIM7000G/mpconfigboard.cmake 2 | =================================================================== 3 | --- /dev/null 4 | +++ micropython/ports/esp32/boards/LILYGO_T-SIM7000G/mpconfigboard.cmake 5 | @@ -0,0 +1,13 @@ 6 | +set(SDKCONFIG_DEFAULTS 7 | + boards/sdkconfig.base 8 | + boards/sdkconfig.ble 9 | + boards/sdkconfig.spiram 10 | + #boards/GENERIC_SPIRAM/sdkconfig.board 11 | +) 12 | + 13 | +if(NOT MICROPY_FROZEN_MANIFEST) 14 | + set(MICROPY_FROZEN_MANIFEST 15 | + ${MICROPY_PORT_DIR}/boards/manifest.py 16 | + $(EXTMOD_FROZEN_DIR)/network/at/manifest.py 17 | + ) 18 | +endif() 19 | \ No newline at end of file 20 | Index: micropython/ports/esp32/boards/LILYGO_T-SIM7000G/mpconfigboard.h 21 | =================================================================== 22 | --- /dev/null 23 | +++ micropython/ports/esp32/boards/LILYGO_T-SIM7000G/mpconfigboard.h 24 | @@ -0,0 +1,2 @@ 25 | +#define MICROPY_HW_BOARD_NAME "ESP32 LILYGO T-SIM7000G" 26 | +#define MICROPY_HW_MCU_NAME "ESP32" 27 | \ No newline at end of file 28 | -------------------------------------------------------------------------------- /micropython/patches/005-Integrate-framebuf1-module.patch: -------------------------------------------------------------------------------- 1 | Index: micropython/ports/esp32/boards/LILYGO_EPD47/mpconfigboard.cmake 2 | =================================================================== 3 | --- micropython.orig/ports/esp32/boards/LILYGO_EPD47/mpconfigboard.cmake 4 | +++ micropython/ports/esp32/boards/LILYGO_EPD47/mpconfigboard.cmake 5 | @@ -9,6 +9,7 @@ if(NOT MICROPY_FROZEN_MANIFEST) 6 | set(MICROPY_FROZEN_MANIFEST 7 | ${MICROPY_PORT_DIR}/boards/manifest.py 8 | $(EXTMOD_FROZEN_DIR)/touch/manifest.py 9 | + $(EXTMOD_FROZEN_DIR)/display/framebuf1/manifest.py 10 | ) 11 | endif() 12 | 13 | -------------------------------------------------------------------------------- /micropython/patches/006-Add-LILYGO_T-PicoC3-board.patch: -------------------------------------------------------------------------------- 1 | Index: micropython/lib/pico-sdk/src/boards/include/boards/lilygo_t_picoc3.h 2 | =================================================================== 3 | --- /dev/null 4 | +++ micropython/lib/pico-sdk/src/boards/include/boards/lilygo_t_picoc3.h 5 | @@ -0,0 +1,84 @@ 6 | +/* 7 | + * Copyright (c) 2020 Raspberry Pi (Trading) Ltd. 8 | + * 9 | + * SPDX-License-Identifier: BSD-3-Clause 10 | + */ 11 | + 12 | +// ----------------------------------------------------- 13 | +// NOTE: THIS HEADER IS ALSO INCLUDED BY ASSEMBLER SO 14 | +// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES 15 | +// ----------------------------------------------------- 16 | + 17 | +// This header may be included by other board headers as "boards/pico.h" 18 | + 19 | +#ifndef _BOARDS_PICO_H 20 | +#define _BOARDS_PICO_H 21 | + 22 | +// For board detection 23 | +#define RASPBERRYPI_PICO 24 | + 25 | +// --- UART --- 26 | +#ifndef PICO_DEFAULT_UART 27 | +#define PICO_DEFAULT_UART 0 28 | +#endif 29 | +#ifndef PICO_DEFAULT_UART_TX_PIN 30 | +#define PICO_DEFAULT_UART_TX_PIN 0 31 | +#endif 32 | +#ifndef PICO_DEFAULT_UART_RX_PIN 33 | +#define PICO_DEFAULT_UART_RX_PIN 1 34 | +#endif 35 | + 36 | +// --- LED --- 37 | +#ifndef PICO_DEFAULT_LED_PIN 38 | +#define PICO_DEFAULT_LED_PIN 25 39 | +#endif 40 | +// no PICO_DEFAULT_WS2812_PIN 41 | + 42 | +// --- I2C --- 43 | +#ifndef PICO_DEFAULT_I2C 44 | +#define PICO_DEFAULT_I2C 0 45 | +#endif 46 | +#ifndef PICO_DEFAULT_I2C_SDA_PIN 47 | +#define PICO_DEFAULT_I2C_SDA_PIN 4 48 | +#endif 49 | +#ifndef PICO_DEFAULT_I2C_SCL_PIN 50 | +#define PICO_DEFAULT_I2C_SCL_PIN 5 51 | +#endif 52 | + 53 | +// --- SPI --- 54 | +#ifndef PICO_DEFAULT_SPI 55 | +#define PICO_DEFAULT_SPI 0 56 | +#endif 57 | +#ifndef PICO_DEFAULT_SPI_SCK_PIN 58 | +#define PICO_DEFAULT_SPI_SCK_PIN 18 59 | +#endif 60 | +#ifndef PICO_DEFAULT_SPI_TX_PIN 61 | +#define PICO_DEFAULT_SPI_TX_PIN 19 62 | +#endif 63 | +#ifndef PICO_DEFAULT_SPI_RX_PIN 64 | +#define PICO_DEFAULT_SPI_RX_PIN 16 65 | +#endif 66 | +#ifndef PICO_DEFAULT_SPI_CSN_PIN 67 | +#define PICO_DEFAULT_SPI_CSN_PIN 17 68 | +#endif 69 | + 70 | +// --- FLASH --- 71 | + 72 | +#define PICO_BOOT_STAGE2_CHOOSE_W25Q080 1 73 | + 74 | +#ifndef PICO_FLASH_SPI_CLKDIV 75 | +#define PICO_FLASH_SPI_CLKDIV 2 76 | +#endif 77 | + 78 | +#ifndef PICO_FLASH_SIZE_BYTES 79 | +#define PICO_FLASH_SIZE_BYTES (2 * 1024 * 1024) 80 | +#endif 81 | + 82 | +// Drive high to force power supply into PWM mode (lower ripple on 3V3 at light loads) 83 | +#define PICO_SMPS_MODE_PIN 23 84 | + 85 | +#ifndef PICO_RP2040_B0_SUPPORTED 86 | +#define PICO_RP2040_B0_SUPPORTED 1 87 | +#endif 88 | + 89 | +#endif 90 | Index: micropython/ports/rp2/boards/LILYGO_T_PicoC3/board.json 91 | =================================================================== 92 | --- /dev/null 93 | +++ micropython/ports/rp2/boards/LILYGO_T_PicoC3/board.json 94 | @@ -0,0 +1,23 @@ 95 | +{ 96 | + "deploy": [ 97 | + "../deploy.md" 98 | + ], 99 | + "docs": "", 100 | + "features": [ 101 | + "WiFi ESP32-C3", 102 | + "Bluetooth ESP32-C3", 103 | + "LCD ST7789", 104 | + "SPI Flash 4MB", 105 | + "Battery", 106 | + "USB TYPE-C" 107 | + ], 108 | + "id": "rp2-pico", 109 | + "images": [ 110 | + "rp2-pico.jpg" 111 | + ], 112 | + "mcu": "rp2040", 113 | + "product": "Pico", 114 | + "thumbnail": "", 115 | + "url": "https://www.raspberrypi.org/products/raspberry-pi-pico/", 116 | + "vendor": "Raspberry Pi" 117 | +} 118 | Index: micropython/ports/rp2/boards/LILYGO_T_PicoC3/mpconfigboard.cmake 119 | =================================================================== 120 | --- /dev/null 121 | +++ micropython/ports/rp2/boards/LILYGO_T_PicoC3/mpconfigboard.cmake 122 | @@ -0,0 +1,2 @@ 123 | +# cmake file for Raspberry Pi Pico 124 | +set(EXTMOD_ST7789 1) 125 | \ No newline at end of file 126 | Index: micropython/ports/rp2/boards/LILYGO_T_PicoC3/mpconfigboard.h 127 | =================================================================== 128 | --- /dev/null 129 | +++ micropython/ports/rp2/boards/LILYGO_T_PicoC3/mpconfigboard.h 130 | @@ -0,0 +1,3 @@ 131 | +// Board and hardware specific configuration 132 | +#define MICROPY_HW_BOARD_NAME "Raspberry Pi Pico" 133 | +#define MICROPY_HW_FLASH_STORAGE_BYTES (1408 * 1024) 134 | -------------------------------------------------------------------------------- /micropython/patches/007-Add-LILYGO-T5-4.7-plus.patch: -------------------------------------------------------------------------------- 1 | Index: micropython/ports/esp32/boards/LILYGO_T5-4.7-PLUS/board.json 2 | =================================================================== 3 | --- /dev/null 4 | +++ micropython/ports/esp32/boards/LILYGO_T5-4.7-PLUS/board.json 5 | @@ -0,0 +1,18 @@ 6 | +{ 7 | + "deploy": [ 8 | + "../deploy.md" 9 | + ], 10 | + "docs": "", 11 | + "features": [ 12 | + "BLE", 13 | + "WiFi" 14 | + ], 15 | + "images": [ 16 | + "generic_s3.jpg" 17 | + ], 18 | + "mcu": "esp32s3", 19 | + "product": "T5-4.7 Plus (SPIRAM)", 20 | + "thumbnail": "", 21 | + "url": "https://www.espressif.com/en/products/modules", 22 | + "vendor": "LilyGo" 23 | +} 24 | Index: micropython/ports/esp32/boards/LILYGO_T5-4.7-PLUS/mpconfigboard.cmake 25 | =================================================================== 26 | --- /dev/null 27 | +++ micropython/ports/esp32/boards/LILYGO_T5-4.7-PLUS/mpconfigboard.cmake 28 | @@ -0,0 +1,14 @@ 29 | +set(IDF_TARGET esp32s3) 30 | + 31 | +set(SDKCONFIG_DEFAULTS 32 | + boards/sdkconfig.base 33 | + boards/sdkconfig.usb 34 | + boards/LILYGO_T5-4.7-PLUS/sdkconfig.board 35 | +) 36 | + 37 | +if(NOT MICROPY_FROZEN_MANIFEST) 38 | + set(MICROPY_FROZEN_MANIFEST ${MICROPY_PORT_DIR}/boards/manifest.py 39 | + $(EXTMOD_FROZEN_DIR)/touch/manifest.py 40 | + $(EXTMOD_FROZEN_DIR)/display/framebuf1/manifest.py) 41 | +endif() 42 | +set(EXTMOD_EPD 1) 43 | Index: micropython/ports/esp32/boards/LILYGO_T5-4.7-PLUS/mpconfigboard.h 44 | =================================================================== 45 | --- /dev/null 46 | +++ micropython/ports/esp32/boards/LILYGO_T5-4.7-PLUS/mpconfigboard.h 47 | @@ -0,0 +1,8 @@ 48 | +#define MICROPY_HW_BOARD_NAME "T5-4.7 Plus (spiram)" 49 | +#define MICROPY_HW_MCU_NAME "ESP32S3" 50 | + 51 | +#define MICROPY_PY_BLUETOOTH (0) 52 | +#define MICROPY_PY_MACHINE_DAC (0) 53 | + 54 | +#define MICROPY_HW_I2C0_SCL (9) 55 | +#define MICROPY_HW_I2C0_SDA (8) 56 | Index: micropython/ports/esp32/boards/LILYGO_T5-4.7-PLUS/sdkconfig.board 57 | =================================================================== 58 | --- /dev/null 59 | +++ micropython/ports/esp32/boards/LILYGO_T5-4.7-PLUS/sdkconfig.board 60 | @@ -0,0 +1,23 @@ 61 | +CONFIG_FLASHMODE_QIO=y 62 | +CONFIG_ESPTOOLPY_FLASHFREQ_80M=y 63 | +CONFIG_ESPTOOLPY_FLASHSIZE_DETECT=y 64 | +CONFIG_ESPTOOLPY_AFTER_NORESET=y 65 | + 66 | +CONFIG_SPIRAM_MEMTEST= 67 | + 68 | +CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y 69 | +CONFIG_PARTITION_TABLE_CUSTOM=y 70 | +CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions-16MiB.csv" 71 | + 72 | +CONFIG_ESP32S3_SPIRAM_SUPPORT=y 73 | +CONFIG_SPIRAM_MODE_OCT=y 74 | +CONFIG_SPIRAM_TYPE_AUTO=y 75 | +CONFIG_SPIRAM_SIZE=-1 76 | +CONFIG_SPIRAM_SPEED_80M=y 77 | +CONFIG_SPIRAM=y 78 | +CONFIG_SPIRAM_BOOT_INIT=y 79 | +CONFIG_SPIRAM_IGNORE_NOTFOUND=y 80 | +CONFIG_SPIRAM_USE_MEMMAP=y 81 | +CONFIG_SPIRAM_MEMTEST=y 82 | +CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=16384 83 | +CONFIG_SPIRAM_MALLOC_RESERVE_INTERNAL=32768 84 | \ No newline at end of file 85 | Index: micropython/ports/esp32/main/CMakeLists.txt 86 | =================================================================== 87 | --- micropython.orig/ports/esp32/main/CMakeLists.txt 88 | +++ micropython/ports/esp32/main/CMakeLists.txt 89 | @@ -121,6 +121,14 @@ set(IDF_COMPONENTS 90 | xtensa 91 | ) 92 | 93 | + 94 | +string(COMPARE EQUAL MICROPY_BOARD "LILYGO_T5-4.7-PLUS" S_out) 95 | +message(WARNING "S_out ${S_out}") 96 | + 97 | +if(IDF_TARGET STREQUAL "esp32s3" AND S_out STREQUAL "0") 98 | + list(APPEND IDF_COMPONENTS esp_lcd) 99 | +endif() 100 | + 101 | if(IDF_VERSION_MINOR GREATER_EQUAL 1 OR IDF_VERSION_MAJOR GREATER_EQUAL 5) 102 | list(APPEND IDF_COMPONENTS esp_netif) 103 | endif() 104 | -------------------------------------------------------------------------------- /target/esp32/boards/LILYGO_T-CALL/.gitignore: -------------------------------------------------------------------------------- 1 | sdkconfig.partitions 2 | -------------------------------------------------------------------------------- /target/esp32/boards/LILYGO_T-CALL/manifest.py: -------------------------------------------------------------------------------- 1 | freeze("modules") -------------------------------------------------------------------------------- /target/esp32/boards/LILYGO_T-CALL/modules/board.py: -------------------------------------------------------------------------------- 1 | from machine import Pin 2 | from time import sleep 3 | 4 | class BoardV20190610(): 5 | MODEM_RST_PIN = 5 6 | MODEM_PWRKEY_PIN = 4 7 | MODEM_POWER_PIN = 23 8 | MODEM_TX = 27 9 | MODEM_RX = 26 10 | LED_PIN = 13 11 | 12 | def __init__(self): 13 | self.version = "20190610" 14 | self.pmu = "IP5306" 15 | 16 | def info(self): 17 | print(" _ _____ _ __ _______ ____ ") 18 | print(" | | |_ _| | \ \ / / ____|/ __ \ ") 19 | print(" | | | | | | \ \_/ / | __| | | | ") 20 | print(" | | | | | | \ /| | |_ | | | | ") 21 | print(" | |____ _| |_| |____| | | |__| | |__| | ") 22 | print(" |______|_____|______|_| \_____|\____/ ") 23 | print(" ") 24 | print(" ") 25 | print("Board: LILYGO T-CALL SIM800") 26 | print("") 27 | print("Version: %s" %(self.version)) 28 | print("") 29 | print("PMU: %s" %(self.pmu)) 30 | 31 | def pinmap(self): 32 | print("Pin Map:") 33 | print("") 34 | print(" ----------------------- ") 35 | print(" 3V3 | ------------- | GND ") 36 | print(" NC | | | | 23 VSPI_MOSI ") 37 | print(" ADC0 GPIO36 SVP | | | | 22 SCL ") 38 | print(" ADC3 GPIO39 SVN | | ESP32 | | TXD GPIO1 ") 39 | print(" ADC6 GPIO34 34 | | | | RXD GPIO3 ") 40 | print(" ADC7 GPIO35 35 | | | | 21 SDA ") 41 | print("TOUCH9 ADC4 GPIO32 32 | ------------- | GND ") 42 | print("TOUCH8 ADC5 GPIO33 32 | | 19 VSPI_MISO ") 43 | print(" DAC1 ADC18 GPIO24 24 | | 18 VSPI_SCK ") 44 | print(" DAC2 ADC19 GPIO26 26 | | 5 VSPI_SS ") 45 | print("TOUCH7 ADC17 GPIO27 27 | | NC ") 46 | print("TOUCH6 ADC16 GPIO14 14 | | NC ") 47 | print("TOUCH5 ADC15 GPIO12 12 | | 4 GPIO4 ADC10 TOUCH4") 48 | print(" GND | | 0 GPIO11 ADC11 TOUCH1") 49 | print("TOUCH4 ADC14 GPIO13 13 | ------------- | 2 GPIO12 ADC12 TOUCH2") 50 | print(" SD2 | | | | 15 GPIO13 ADC13 TOUCH3") 51 | print(" SD3 | | | | SD1 ") 52 | print(" CMD | | SIM800 | | SD0 ") 53 | print(" 5V | | | | CLK ") 54 | print(" SPK+ | | | | MIC- ") 55 | print(" SPK- | ------------- | MIC+ ") 56 | print(" ----------------------- ") 57 | 58 | def sim800_restart(self): 59 | '''Reset SIM800 module 60 | 61 | 复位SIM800模块 62 | 63 | Electrical Connections: 64 | 65 | | ESP32 | SIM800 | 66 | | ----- | ------ | 67 | | GPIO5 | 49 | 68 | ''' 69 | RST_PIN = Pin(self.MODEM_RST_PIN, Pin.OUT) 70 | RST_PIN.value(1) 71 | RST_PIN.value(0) 72 | sleep(0.2) 73 | RST_PIN.value(1) 74 | del RST_PIN 75 | 76 | def sim800_power(self, active): 77 | '''Control the power supply of SIM800 module 78 | 79 | 控制SIM800模块的电源 80 | ''' 81 | POWER_PIN = Pin(self.MODEM_POWER_PIN, Pin.OUT) 82 | POWER_PIN.value(active) 83 | del POWER_PIN 84 | 85 | def sim800_boot(self): 86 | '''sim800 module boot 87 | 88 | sim800模块开机启动 89 | ''' 90 | PWRKEY_PIN = Pin(self.MODEM_PWRKEY_PIN, Pin.OUT) 91 | 92 | PWRKEY_PIN.value(1) 93 | sleep(0.5) 94 | PWRKEY_PIN.value(0) 95 | sleep(1) 96 | PWRKEY_PIN.value(1) 97 | 98 | del PWRKEY_PIN 99 | 100 | def sim800_shutdown(self): 101 | '''sim800 module shutdown 102 | 103 | sim800模块关机 104 | ''' 105 | PWRKEY_PIN = Pin(self.MODEM_PWRKEY_PIN, Pin.OUT) 106 | 107 | PWRKEY_PIN.value(1) 108 | sleep(0.1) 109 | PWRKEY_PIN.value(0) 110 | sleep(3) 111 | PWRKEY_PIN.value(1) 112 | 113 | del PWRKEY_PIN 114 | 115 | def sim800_init(self): 116 | '''sim800 initialization 117 | 118 | sim800初始化 119 | ''' 120 | self.sim800_power(True) 121 | self.sim800_boot() 122 | self.status_light(True) 123 | 124 | def status_light(self, onoff): 125 | led = Pin(self.LED_PIN, Pin.OUT) 126 | led.value(onoff) 127 | del led 128 | 129 | class BoardV20200811(BoardV20190610): 130 | MODEM_PWRKEY_PIN = 4 131 | MODEM_POWER_PIN = 23 132 | MODEM_TX = 27 133 | MODEM_RX = 26 134 | MODEM_DTR = 32 135 | MODEM_RI = 33 136 | LED_PIN = 13 137 | 138 | def __init__(self): 139 | self.version = "20200327" 140 | self.pmu = "IP5306" 141 | 142 | class BoardV20200327(BoardV20190610): 143 | MODEM_RST_PIN = 5 144 | MODEM_PWRKEY_PIN = 4 145 | MODEM_POWER_PIN = 25 146 | MODEM_TX = 27 147 | MODEM_RX = 26 148 | MODEM_DTR = 32 149 | MODEM_RI = 33 150 | LED_PIN = 13 151 | 152 | def __init__(self): 153 | self.version = "20200327" 154 | self.pmu = "AXP192" 155 | 156 | class BoardV20200609(BoardV20190610): 157 | MODEM_PWRKEY_PIN = 4 158 | MODEM_POWER_PIN = 23 159 | MODEM_TX = 27 160 | MODEM_RX = 26 161 | MODEM_DTR = 32 162 | MODEM_RI = 33 163 | LED_PIN = 12 164 | 165 | def __init__(self): 166 | self.version = "20200609" 167 | self.pmu = "AXP192" 168 | 169 | def sim800_restart(self): 170 | pass 171 | 172 | if __name__ == '__main__': 173 | b = BoardV20190610() 174 | b.sim800_init() 175 | -------------------------------------------------------------------------------- /target/esp32/boards/LILYGO_T-CALL/mpconfigboard.cmake: -------------------------------------------------------------------------------- 1 | set(SDKCONFIG_DEFAULTS ${MICROPY_PORT_DIR}/boards/sdkconfig.240mhz 2 | ${MICROPY_PORT_DIR}/boards/sdkconfig.base 3 | ${MICROPY_PORT_DIR}/boards/sdkconfig.ble 4 | ${MICROPY_PORT_DIR}/boards/sdkconfig.spiram 5 | ${CMAKE_CURRENT_LIST_DIR}/sdkconfig.board 6 | ) 7 | 8 | if(NOT MICROPY_FROZEN_MANIFEST) 9 | set(MICROPY_FROZEN_MANIFEST ${MICROPY_PORT_DIR}/boards/manifest.py 10 | ${MICROPY_BOARD_DIR}/manifest.py 11 | ${EXTMOD_FROZEN_DIR}/network/at/manifest.py 12 | ) 13 | endif() -------------------------------------------------------------------------------- /target/esp32/boards/LILYGO_T-CALL/mpconfigboard.h: -------------------------------------------------------------------------------- 1 | #define MICROPY_HW_BOARD_NAME "T-CALL SIM800 (spiram)" 2 | #define MICROPY_HW_MCU_NAME "ESP32" -------------------------------------------------------------------------------- /target/esp32/boards/LILYGO_T-CALL/sdkconfig.board: -------------------------------------------------------------------------------- 1 | # SPIRAM increases the size of the firmware, use -Os to reduce it again to fit in iram 2 | CONFIG_COMPILER_OPTIMIZATION_SIZE=y 3 | 4 | CONFIG_ESPTOOLPY_FLASHMODE_QIO=y 5 | CONFIG_ESPTOOLPY_FLASHMODE="dio" 6 | CONFIG_ESPTOOLPY_FLASHFREQ_80M=y 7 | CONFIG_ESPTOOLPY_FLASHFREQ="80m" 8 | 9 | # 10 | # Bootloader log verbosity 11 | # 12 | # CONFIG_BOOTLOADER_LOG_LEVEL_NONE=y 13 | # CONFIG_BOOTLOADER_LOG_LEVEL_ERROR=y 14 | CONFIG_BOOTLOADER_LOG_LEVEL_WARN=y 15 | # CONFIG_BOOTLOADER_LOG_LEVEL_INFO=y 16 | # CONFIG_BOOTLOADER_LOG_LEVEL_DEBUG=y 17 | # CONFIG_BOOTLOADER_LOG_LEVEL_VERBOSE=y 18 | 19 | # 20 | # Default log verbosity 21 | # 22 | # CONFIG_LOG_DEFAULT_LEVEL_NONE=y 23 | # CONFIG_LOG_DEFAULT_LEVEL_ERROR=y 24 | CONFIG_LOG_DEFAULT_LEVEL_WARN=y 25 | # CONFIG_LOG_DEFAULT_LEVEL_INFO=y 26 | # CONFIG_LOG_DEFAULT_LEVEL_DEBUG=y 27 | # CONFIG_LOG_DEFAULT_LEVEL_VERBOSE=y 28 | -------------------------------------------------------------------------------- /target/esp32/boards/LILYGO_T-Display/.gitignore: -------------------------------------------------------------------------------- 1 | sdkconfig.partitions 2 | -------------------------------------------------------------------------------- /target/esp32/boards/LILYGO_T-Display/board.json: -------------------------------------------------------------------------------- 1 | { 2 | "deploy": [ 3 | "../deploy.md" 4 | ], 5 | "docs": "", 6 | "features": [ 7 | "BLE", 8 | "WiFi" 9 | ], 10 | "id": "esp32", 11 | "images": [ 12 | "esp32_devkitc.jpg" 13 | ], 14 | "mcu": "esp32", 15 | "product": "ESP32", 16 | "thumbnail": "", 17 | "url": "https://www.espressif.com/en/products/modules", 18 | "variants": { 19 | "idf3": "Compiled with IDF 3.x" 20 | }, 21 | "vendor": "Espressif" 22 | } 23 | -------------------------------------------------------------------------------- /target/esp32/boards/LILYGO_T-Display/board.md: -------------------------------------------------------------------------------- 1 | The following files are daily firmware for ESP32-based boards without external SPIRAM. 2 | 3 | This firmware is compiled using ESP-IDF v4.x. Some older releases are also provided that are compiled with ESP-IDF v3.x. 4 | -------------------------------------------------------------------------------- /target/esp32/boards/LILYGO_T-Display/mpconfigboard.cmake: -------------------------------------------------------------------------------- 1 | 2 | 3 | # 4 | # Generate sdkconfig.partitions file 5 | # 6 | file(WRITE ${CMAKE_CURRENT_LIST_DIR}/sdkconfig.partitions 7 | "CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y\n") 8 | file(APPEND ${CMAKE_CURRENT_LIST_DIR}/sdkconfig.partitions 9 | "CONFIG_PARTITION_TABLE_CUSTOM=y\n") 10 | file(APPEND ${CMAKE_CURRENT_LIST_DIR}/sdkconfig.partitions 11 | "CONFIG_PARTITION_TABLE_CUSTOM_FILENAME=\"${CMAKE_CURRENT_LIST_DIR}/partitions.csv\"\n") 12 | 13 | set(SDKCONFIG_DEFAULTS ${MICROPY_PORT_DIR}/boards/sdkconfig.240mhz 14 | ${MICROPY_PORT_DIR}/boards/sdkconfig.base 15 | ${MICROPY_PORT_DIR}/boards/sdkconfig.ble 16 | ${CMAKE_CURRENT_LIST_DIR}/sdkconfig.board 17 | ${CMAKE_CURRENT_LIST_DIR}/sdkconfig.partitions 18 | ) 19 | 20 | set(EXTMOD_ST7789 1) 21 | -------------------------------------------------------------------------------- /target/esp32/boards/LILYGO_T-Display/mpconfigboard.h: -------------------------------------------------------------------------------- 1 | #define MICROPY_HW_BOARD_NAME "LILYGO T-Display" 2 | #define MICROPY_HW_MCU_NAME "ESP32" 3 | -------------------------------------------------------------------------------- /target/esp32/boards/LILYGO_T-Display/partitions.csv: -------------------------------------------------------------------------------- 1 | # Notes: the offset of the partition table itself is set in 2 | # $IDF_PATH/components/partition_table/Kconfig.projbuild. 3 | # Name, Type, SubType, Offset, Size, Flags 4 | nvs, data, nvs, 0x9000, 0x6000, 5 | phy_init, data, phy, 0xf000, 0x1000, 6 | factory, app, factory, 0x10000, 0x250000, 7 | vfs, data, fat, 0x260000, 0x1a0000, 8 | -------------------------------------------------------------------------------- /target/esp32/boards/LILYGO_T-Display/sdkconfig.board: -------------------------------------------------------------------------------- 1 | 2 | CONFIG_ESPTOOLPY_FLASHMODE_QIO=y 3 | CONFIG_ESPTOOLPY_FLASHMODE="dio" 4 | CONFIG_ESPTOOLPY_FLASHFREQ_80M=y 5 | CONFIG_ESPTOOLPY_FLASHFREQ="80m" 6 | 7 | # 8 | # Bootloader log verbosity 9 | # 10 | # CONFIG_BOOTLOADER_LOG_LEVEL_NONE=y 11 | # CONFIG_BOOTLOADER_LOG_LEVEL_ERROR=y 12 | CONFIG_BOOTLOADER_LOG_LEVEL_WARN=y 13 | # CONFIG_BOOTLOADER_LOG_LEVEL_INFO=y 14 | # CONFIG_BOOTLOADER_LOG_LEVEL_DEBUG=y 15 | # CONFIG_BOOTLOADER_LOG_LEVEL_VERBOSE=y 16 | 17 | # 18 | # Default log verbosity 19 | # 20 | # CONFIG_LOG_DEFAULT_LEVEL_NONE=y 21 | # CONFIG_LOG_DEFAULT_LEVEL_ERROR=y 22 | CONFIG_LOG_DEFAULT_LEVEL_WARN=y 23 | # CONFIG_LOG_DEFAULT_LEVEL_INFO=y 24 | # CONFIG_LOG_DEFAULT_LEVEL_DEBUG=y 25 | # CONFIG_LOG_DEFAULT_LEVEL_VERBOSE=y 26 | -------------------------------------------------------------------------------- /target/esp32/boards/LILYGO_T-SIM7000G/.gitignore: -------------------------------------------------------------------------------- 1 | sdkconfig.partitions 2 | -------------------------------------------------------------------------------- /target/esp32/boards/LILYGO_T-SIM7000G/mpconfigboard.cmake: -------------------------------------------------------------------------------- 1 | set(SDKCONFIG_DEFAULTS ${MICROPY_PORT_DIR}/boards/sdkconfig.240mhz 2 | ${MICROPY_PORT_DIR}/boards/sdkconfig.base 3 | ${MICROPY_PORT_DIR}/boards/sdkconfig.ble 4 | ${MICROPY_PORT_DIR}/boards/sdkconfig.spiram 5 | ${CMAKE_CURRENT_LIST_DIR}/sdkconfig.board 6 | ) 7 | 8 | if(NOT MICROPY_FROZEN_MANIFEST) 9 | set(MICROPY_FROZEN_MANIFEST ${MICROPY_PORT_DIR}/boards/manifest.py 10 | ${EXTMOD_FROZEN_DIR}/network/at/manifest.py 11 | ) 12 | endif() -------------------------------------------------------------------------------- /target/esp32/boards/LILYGO_T-SIM7000G/mpconfigboard.h: -------------------------------------------------------------------------------- 1 | #define MICROPY_HW_BOARD_NAME "T-SIM7000G (spiram)" 2 | #define MICROPY_HW_MCU_NAME "ESP32" -------------------------------------------------------------------------------- /target/esp32/boards/LILYGO_T-SIM7000G/sdkconfig.board: -------------------------------------------------------------------------------- 1 | # SPIRAM increases the size of the firmware, use -Os to reduce it again to fit in iram 2 | CONFIG_COMPILER_OPTIMIZATION_SIZE=y 3 | 4 | CONFIG_ESPTOOLPY_FLASHMODE_QIO=y 5 | CONFIG_ESPTOOLPY_FLASHMODE="dio" 6 | CONFIG_ESPTOOLPY_FLASHFREQ_80M=y 7 | CONFIG_ESPTOOLPY_FLASHFREQ="80m" 8 | 9 | # 10 | # Bootloader log verbosity 11 | # 12 | # CONFIG_BOOTLOADER_LOG_LEVEL_NONE=y 13 | # CONFIG_BOOTLOADER_LOG_LEVEL_ERROR=y 14 | CONFIG_BOOTLOADER_LOG_LEVEL_WARN=y 15 | # CONFIG_BOOTLOADER_LOG_LEVEL_INFO=y 16 | # CONFIG_BOOTLOADER_LOG_LEVEL_DEBUG=y 17 | # CONFIG_BOOTLOADER_LOG_LEVEL_VERBOSE=y 18 | 19 | # 20 | # Default log verbosity 21 | # 22 | # CONFIG_LOG_DEFAULT_LEVEL_NONE=y 23 | # CONFIG_LOG_DEFAULT_LEVEL_ERROR=y 24 | CONFIG_LOG_DEFAULT_LEVEL_WARN=y 25 | # CONFIG_LOG_DEFAULT_LEVEL_INFO=y 26 | # CONFIG_LOG_DEFAULT_LEVEL_DEBUG=y 27 | # CONFIG_LOG_DEFAULT_LEVEL_VERBOSE=y 28 | -------------------------------------------------------------------------------- /target/esp32/boards/LILYGO_T5-4.7/.gitignore: -------------------------------------------------------------------------------- 1 | sdkconfig.partitions 2 | -------------------------------------------------------------------------------- /target/esp32/boards/LILYGO_T5-4.7/mpconfigboard.cmake: -------------------------------------------------------------------------------- 1 | 2 | 3 | # 4 | # Generate sdkconfig.partitions file 5 | # 6 | file(WRITE ${CMAKE_CURRENT_LIST_DIR}/sdkconfig.partitions 7 | "CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y\n") 8 | file(APPEND ${CMAKE_CURRENT_LIST_DIR}/sdkconfig.partitions 9 | "CONFIG_PARTITION_TABLE_CUSTOM=y\n") 10 | file(APPEND ${CMAKE_CURRENT_LIST_DIR}/sdkconfig.partitions 11 | "CONFIG_PARTITION_TABLE_CUSTOM_FILENAME=\"${CMAKE_CURRENT_LIST_DIR}/partitions.csv\"\n") 12 | 13 | set(SDKCONFIG_DEFAULTS ${MICROPY_PORT_DIR}/boards/sdkconfig.240mhz 14 | ${MICROPY_PORT_DIR}/boards/sdkconfig.base 15 | ${MICROPY_PORT_DIR}/boards/sdkconfig.ble 16 | ${MICROPY_PORT_DIR}/boards/sdkconfig.spiram 17 | ${CMAKE_CURRENT_LIST_DIR}/sdkconfig.board 18 | ${CMAKE_CURRENT_LIST_DIR}/sdkconfig.partitions 19 | ) 20 | 21 | if(NOT MICROPY_FROZEN_MANIFEST) 22 | set(MICROPY_FROZEN_MANIFEST ${MICROPY_PORT_DIR}/boards/manifest.py 23 | ${EXTMOD_FROZEN_DIR}/touch/manifest.py 24 | ${EXTMOD_FROZEN_DIR}/display/framebuf1/manifest.py 25 | ) 26 | endif() 27 | 28 | set(EXTMOD_EPD 1) -------------------------------------------------------------------------------- /target/esp32/boards/LILYGO_T5-4.7/mpconfigboard.h: -------------------------------------------------------------------------------- 1 | #define MICROPY_HW_BOARD_NAME "T5-4.7 (spiram)" 2 | #define MICROPY_HW_MCU_NAME "ESP32" -------------------------------------------------------------------------------- /target/esp32/boards/LILYGO_T5-4.7/partitions.csv: -------------------------------------------------------------------------------- 1 | # Notes: the offset of the partition table itself is set in 2 | # $IDF_PATH/components/partition_table/Kconfig.projbuild. 3 | # Name, Type, SubType, Offset, Size, Flags 4 | nvs, data, nvs, 0x9000, 0x6000, 5 | phy_init, data, phy, 0xf000, 0x1000, 6 | factory, app, factory, 0x10000, 0x3F0000, 7 | vfs, data, fat, 0x400000, 0xc00000, 8 | -------------------------------------------------------------------------------- /target/esp32/boards/LILYGO_T5-4.7/sdkconfig.board: -------------------------------------------------------------------------------- 1 | # SPIRAM increases the size of the firmware, use -Os to reduce it again to fit in iram 2 | CONFIG_COMPILER_OPTIMIZATION_SIZE=y 3 | 4 | CONFIG_ESPTOOLPY_FLASHMODE_QIO=y 5 | CONFIG_ESPTOOLPY_FLASHMODE="dio" 6 | CONFIG_ESPTOOLPY_FLASHFREQ_80M=y 7 | CONFIG_ESPTOOLPY_FLASHFREQ="80m" 8 | 9 | # 10 | # Bootloader log verbosity 11 | # 12 | # CONFIG_BOOTLOADER_LOG_LEVEL_NONE=y 13 | # CONFIG_BOOTLOADER_LOG_LEVEL_ERROR=y 14 | CONFIG_BOOTLOADER_LOG_LEVEL_WARN=y 15 | # CONFIG_BOOTLOADER_LOG_LEVEL_INFO=y 16 | # CONFIG_BOOTLOADER_LOG_LEVEL_DEBUG=y 17 | # CONFIG_BOOTLOADER_LOG_LEVEL_VERBOSE=y 18 | 19 | # 20 | # Default log verbosity 21 | # 22 | # CONFIG_LOG_DEFAULT_LEVEL_NONE=y 23 | # CONFIG_LOG_DEFAULT_LEVEL_ERROR=y 24 | CONFIG_LOG_DEFAULT_LEVEL_WARN=y 25 | # CONFIG_LOG_DEFAULT_LEVEL_INFO=y 26 | # CONFIG_LOG_DEFAULT_LEVEL_DEBUG=y 27 | # CONFIG_LOG_DEFAULT_LEVEL_VERBOSE=y 28 | -------------------------------------------------------------------------------- /target/esp32/esp32.mk: -------------------------------------------------------------------------------- 1 | 2 | include $(INCLUDE_DIR)/download.mk 3 | include $(INCLUDE_DIR)/package.mk 4 | 5 | define esp32/info 6 | PKG_NAME:=esp-idf 7 | PKG_SOURCE_URL:=https://github.com/espressif/esp-idf.git 8 | PKG_SOURCE_PROTO:=git 9 | PKG_SOURCE_VERSION:=v4.4 10 | PKG_SOURCE_MD5:=9416da50831df089fcf60db5fc2750f0 11 | PKG_SOURCE_OPT:=--recurse-submodules 12 | endef 13 | 14 | # $(call DownloadMethod/git,$(PKG_NAME),$(PKG_SOURCE_URL),$(PKG_SOURCE_VERSION)) ; 15 | define esp32/prereq 16 | $(eval $(esp32/info)) 17 | $(call Package/prereq,$(TARGET_BUILD_DIR)) 18 | endef 19 | 20 | ## 21 | ## $(1) MODULES 22 | ## 23 | define esp32/compile 24 | $(TARGET_BUILD_DIR)/esp-idf/install.sh 25 | . $(TARGET_BUILD_DIR)/esp-idf/export.sh && \ 26 | make -C $(TARGET_BUILD_DIR)/micropython/ports/esp32 \ 27 | MICROPY_BOARD_DIR=$(TOP_DIR)/target/$(TARGET)/boards/$(BOARD) \ 28 | BOARD=$(BOARD) \ 29 | BUILD=$(TARGET_BUILD_DIR)/build-$(BOARD) \ 30 | USER_C_MODULES=$(TOP_DIR)/extmod/micropython.cmake \ 31 | EXTMOD_FROZEN_DIR=$(TOP_DIR)/extmod 32 | endef 33 | 34 | 35 | define esp32/install 36 | @[ -d $(BIN_DIR) ] && mkdir -p $(BIN_DIR)/esp32/$(BOARD) 37 | @img_name=LilyGo-MicroPython_$(TARGET)_$(BOARD) && \ 38 | cd $(TARGET_BUILD_DIR)/micropython && \ 39 | micropython_version=`git show -s --pretty=format:%h` && \ 40 | img_name=$${img_name}_MPY-$${micropython_version} && \ 41 | cd $(TARGET_BUILD_DIR)/$(PKG_NAME) && \ 42 | idf_version=`git show -s --pretty=format:%h` && \ 43 | img_name=$${img_name}_IDF-$${idf_version} && \ 44 | time=`date +"%Y%m%d"` && \ 45 | img_name=$${img_name}_B$${time} && \ 46 | md5=`md5sum $(TARGET_BUILD_DIR)/build-$(BOARD)/firmware.bin | awk '{print $$1}'` && \ 47 | img_name=$${img_name}_$${md5:0:10} && \ 48 | cp $(TARGET_BUILD_DIR)/build-$(BOARD)/firmware.bin $(BIN_DIR)/esp32/$(BOARD)/$${img_name}.bin 49 | endef 50 | -------------------------------------------------------------------------------- /target/esp32s3/boards/LILYGO_T-DisplayS3-AMOLED/.gitignore: -------------------------------------------------------------------------------- 1 | sdkconfig.partitions 2 | -------------------------------------------------------------------------------- /target/esp32s3/boards/LILYGO_T-DisplayS3-AMOLED/board.json: -------------------------------------------------------------------------------- 1 | { 2 | "deploy": [ 3 | "../deploy.md" 4 | ], 5 | "docs": "", 6 | "features": [ 7 | "BLE", 8 | "WiFi" 9 | ], 10 | "images": [ 11 | "generic_s3.jpg" 12 | ], 13 | "mcu": "esp32s3", 14 | "product": "T-DisplayS3-AMOLED (SPIRAM)", 15 | "thumbnail": "", 16 | "url": "https://www.aliexpress.com/item/3256804310228562.html", 17 | "vendor": "LILYGO" 18 | } 19 | -------------------------------------------------------------------------------- /target/esp32s3/boards/LILYGO_T-DisplayS3-AMOLED/manifest.py: -------------------------------------------------------------------------------- 1 | freeze("$(PORT_DIR)/modules", ("_boot.py", "apa106.py", "flashbdev.py")) 2 | freeze("$(MPY_DIR)/tools", ("upip.py", "upip_utarfile.py")) 3 | freeze("$(MPY_DIR)/ports/esp8266/modules", "ntptime.py") 4 | freeze("$(MPY_DIR)/drivers/dht", "dht.py") 5 | freeze("$(MPY_DIR)/drivers/onewire") 6 | include("$(MPY_DIR)/extmod/uasyncio/manifest.py") 7 | include("$(MPY_DIR)/extmod/webrepl/manifest.py") 8 | include("$(MPY_DIR)/drivers/neopixel/manifest.py") 9 | freeze("modules") 10 | -------------------------------------------------------------------------------- /target/esp32s3/boards/LILYGO_T-DisplayS3-AMOLED/modules/inisetup.py: -------------------------------------------------------------------------------- 1 | import uos 2 | from flashbdev import bdev 3 | 4 | 5 | def check_bootsec(): 6 | buf = bytearray(bdev.ioctl(5, 0)) # 5 is SEC_SIZE 7 | bdev.readblocks(0, buf) 8 | empty = True 9 | for b in buf: 10 | if b != 0xFF: 11 | empty = False 12 | break 13 | if empty: 14 | return True 15 | fs_corrupted() 16 | 17 | 18 | def fs_corrupted(): 19 | import time 20 | 21 | while 1: 22 | print( 23 | """\ 24 | The filesystem appears to be corrupted. If you had important data there, you 25 | may want to make a flash snapshot to try to recover it. Otherwise, perform 26 | factory reprogramming of MicroPython firmware (completely erase flash, followed 27 | by firmware programming). 28 | """ 29 | ) 30 | time.sleep(3) 31 | 32 | 33 | def setup(): 34 | check_bootsec() 35 | print("Performing initial setup") 36 | uos.VfsLfs2.mkfs(bdev) 37 | vfs = uos.VfsLfs2(bdev) 38 | uos.mount(vfs, "/") 39 | with open("boot.py", "w") as f: 40 | f.write( 41 | """\ 42 | import tft_config 43 | import logo 44 | import gc 45 | import time 46 | 47 | gc.enable() 48 | disp = tft_config.config() 49 | disp.rotation(1) 50 | disp.bitmap(0, 0, logo.WIDTH, logo.HEIGHT, logo.BITMAP) 51 | 52 | time.sleep(1) 53 | disp.deinit() 54 | del tft_config 55 | del logo 56 | del disp 57 | gc.collect() 58 | """ 59 | ) 60 | return vfs 61 | -------------------------------------------------------------------------------- /target/esp32s3/boards/LILYGO_T-DisplayS3-AMOLED/modules/tft_config.py: -------------------------------------------------------------------------------- 1 | import lcd 2 | from machine import Pin, SPI 3 | 4 | rm67162_spi_init = ( 5 | (0xFE, b'\x00', 0), # PAGE 6 | (0x36, b'\x00', 0), # Scan Direction Control 7 | (0x3A, b'\x75', 0), # Interface Pixel Format 16bit/pixel 8 | (0x51, b'\x00', 0), # Write Display Brightness MAX_VAL=0XFF 9 | (0x11, b'\x00', 120), # Sleep Out 10 | (0x29, b'\x00', 120), # Display on 11 | (0x51, b'\xD0', 0), # Write Display Brightness MAX_VAL=0XFF 12 | ) 13 | 14 | rm67162_qspi_init = ( 15 | (0x11, b'\x00', 120), # Sleep Out 16 | (0x3A, b'\x55', 0), # Interface Pixel Format 16bit/pixel 17 | (0x51, b'\x00', 0), # Write Display Brightness MAX_VAL=0XFF 18 | (0x29, b'\x00', 120), # Display on 19 | (0x51, b'\xD0', 0), # Write Display Brightness MAX_VAL=0XFF 20 | ) 21 | 22 | def config(): 23 | hspi = SPI(2, sck=Pin(47), mosi=None, miso=None, polarity=0, phase=0) 24 | panel = lcd.QSPIPanel( 25 | spi=hspi, 26 | data=(Pin(18), Pin(7), Pin(48), Pin(5)), 27 | command=Pin(7), 28 | cs=Pin(6), 29 | pclk=80 * 1000 * 1000, 30 | width=240, 31 | height=536 32 | ) 33 | rm = lcd.RM67162(panel, reset=Pin(17), bpp=16) 34 | rm.reset() 35 | rm.init() 36 | # rm.custom_init(rm67162_qspi_init) 37 | rm.rotation(0) 38 | rm.backlight_on() 39 | return rm 40 | -------------------------------------------------------------------------------- /target/esp32s3/boards/LILYGO_T-DisplayS3-AMOLED/mpconfigboard.cmake: -------------------------------------------------------------------------------- 1 | set(IDF_TARGET esp32s3) 2 | 3 | # 4 | # Generate sdkconfig.partitions file 5 | # 6 | file(WRITE ${CMAKE_CURRENT_LIST_DIR}/sdkconfig.partitions 7 | "CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y\n") 8 | file(APPEND ${CMAKE_CURRENT_LIST_DIR}/sdkconfig.partitions 9 | "CONFIG_PARTITION_TABLE_CUSTOM=y\n") 10 | file(APPEND ${CMAKE_CURRENT_LIST_DIR}/sdkconfig.partitions 11 | "CONFIG_PARTITION_TABLE_CUSTOM_FILENAME=\"${CMAKE_CURRENT_LIST_DIR}/partitions.csv\"\n") 12 | 13 | set(SDKCONFIG_DEFAULTS boards/sdkconfig.base 14 | boards/sdkconfig.usb 15 | boards/sdkconfig.ble 16 | boards/sdkconfig.240mhz 17 | ${CMAKE_CURRENT_LIST_DIR}/sdkconfig.board 18 | ${CMAKE_CURRENT_LIST_DIR}/sdkconfig.partitions 19 | ) 20 | 21 | set(MICROPY_FROZEN_MANIFEST ${CMAKE_CURRENT_LIST_DIR}/manifest.py) 22 | 23 | set(EXTMOD_LCD 1) 24 | set(EXTMOD_FRAMEBUF_PLUS 1) 25 | -------------------------------------------------------------------------------- /target/esp32s3/boards/LILYGO_T-DisplayS3-AMOLED/mpconfigboard.h: -------------------------------------------------------------------------------- 1 | #define MICROPY_HW_BOARD_NAME "T-DisplayS3-AMOLED (OPI RAM)" 2 | #define MICROPY_HW_MCU_NAME "ESP32S3" 3 | 4 | #define MICROPY_PY_MACHINE_DAC (0) 5 | 6 | // Enable UART REPL for modules that have an external USB-UART and don't use native USB. 7 | #define MICROPY_HW_ENABLE_UART_REPL (1) 8 | -------------------------------------------------------------------------------- /target/esp32s3/boards/LILYGO_T-DisplayS3-AMOLED/partitions.csv: -------------------------------------------------------------------------------- 1 | # Notes: the offset of the partition table itself is set in 2 | # $IDF_PATH/components/partition_table/Kconfig.projbuild. 3 | # Name, Type, SubType, Offset, Size, Flags 4 | nvs, data, nvs, 0x9000, 0x6000, 5 | phy_init, data, phy, 0xf000, 0x1000, 6 | factory, app, factory, 0x10000, 0x3F0000, 7 | vfs, data, fat, 0x400000, 0xc00000, 8 | -------------------------------------------------------------------------------- /target/esp32s3/boards/LILYGO_T-DisplayS3-AMOLED/sdkconfig.board: -------------------------------------------------------------------------------- 1 | CONFIG_FLASHMODE_QIO=y 2 | CONFIG_ESPTOOLPY_FLASHFREQ_80M=y 3 | CONFIG_ESPTOOLPY_FLASHSIZE_DETECT=y 4 | CONFIG_ESPTOOLPY_AFTER_NORESET=y 5 | 6 | CONFIG_SPIRAM_MEMTEST= 7 | 8 | CONFIG_ESP32S3_SPIRAM_SUPPORT=y 9 | CONFIG_SPIRAM_MODE_OCT=y 10 | CONFIG_SPIRAM_TYPE_AUTO=y 11 | CONFIG_SPIRAM_SIZE=-1 12 | CONFIG_SPIRAM_SPEED_80M=y 13 | CONFIG_SPIRAM=y 14 | CONFIG_SPIRAM_BOOT_INIT=y 15 | CONFIG_SPIRAM_IGNORE_NOTFOUND=y 16 | CONFIG_SPIRAM_USE_MEMMAP=y 17 | CONFIG_SPIRAM_MEMTEST=y 18 | CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=16384 19 | CONFIG_SPIRAM_MALLOC_RESERVE_INTERNAL=32768 20 | 21 | # 22 | # Bootloader log verbosity 23 | # 24 | # CONFIG_BOOTLOADER_LOG_LEVEL_NONE=y 25 | # CONFIG_BOOTLOADER_LOG_LEVEL_ERROR=y 26 | CONFIG_BOOTLOADER_LOG_LEVEL_WARN=y 27 | # CONFIG_BOOTLOADER_LOG_LEVEL_INFO=y 28 | # CONFIG_BOOTLOADER_LOG_LEVEL_DEBUG=y 29 | # CONFIG_BOOTLOADER_LOG_LEVEL_VERBOSE=y 30 | 31 | # 32 | # Default log verbosity 33 | # 34 | # CONFIG_LOG_DEFAULT_LEVEL_NONE=y 35 | # CONFIG_LOG_DEFAULT_LEVEL_ERROR=y 36 | CONFIG_LOG_DEFAULT_LEVEL_WARN=y 37 | # CONFIG_LOG_DEFAULT_LEVEL_INFO=y 38 | # CONFIG_LOG_DEFAULT_LEVEL_DEBUG=y 39 | # CONFIG_LOG_DEFAULT_LEVEL_VERBOSE=y 40 | -------------------------------------------------------------------------------- /target/esp32s3/boards/LILYGO_T-DisplayS3/.gitignore: -------------------------------------------------------------------------------- 1 | sdkconfig.partitions 2 | -------------------------------------------------------------------------------- /target/esp32s3/boards/LILYGO_T-DisplayS3/board.json: -------------------------------------------------------------------------------- 1 | { 2 | "deploy": [ 3 | "../deploy.md" 4 | ], 5 | "docs": "", 6 | "features": [ 7 | "BLE", 8 | "WiFi" 9 | ], 10 | "images": [ 11 | "generic_s3.jpg" 12 | ], 13 | "mcu": "esp32s3", 14 | "product": "T-DisplayS3 (SPIRAM)", 15 | "thumbnail": "", 16 | "url": "https://www.aliexpress.com/item/3256804310228562.html", 17 | "vendor": "LILYGO" 18 | } 19 | -------------------------------------------------------------------------------- /target/esp32s3/boards/LILYGO_T-DisplayS3/manifest.py: -------------------------------------------------------------------------------- 1 | freeze("$(PORT_DIR)/modules", ("_boot.py", "apa106.py", "flashbdev.py")) 2 | freeze("$(MPY_DIR)/tools", ("upip.py", "upip_utarfile.py")) 3 | freeze("$(MPY_DIR)/ports/esp8266/modules", "ntptime.py") 4 | freeze("$(MPY_DIR)/drivers/dht", "dht.py") 5 | freeze("$(MPY_DIR)/drivers/onewire") 6 | include("$(MPY_DIR)/extmod/uasyncio/manifest.py") 7 | include("$(MPY_DIR)/extmod/webrepl/manifest.py") 8 | include("$(MPY_DIR)/drivers/neopixel/manifest.py") 9 | freeze("modules") 10 | -------------------------------------------------------------------------------- /target/esp32s3/boards/LILYGO_T-DisplayS3/modules/inisetup.py: -------------------------------------------------------------------------------- 1 | import uos 2 | from flashbdev import bdev 3 | 4 | 5 | def check_bootsec(): 6 | buf = bytearray(bdev.ioctl(5, 0)) # 5 is SEC_SIZE 7 | bdev.readblocks(0, buf) 8 | empty = True 9 | for b in buf: 10 | if b != 0xFF: 11 | empty = False 12 | break 13 | if empty: 14 | return True 15 | fs_corrupted() 16 | 17 | 18 | def fs_corrupted(): 19 | import time 20 | 21 | while 1: 22 | print( 23 | """\ 24 | The filesystem appears to be corrupted. If you had important data there, you 25 | may want to make a flash snapshot to try to recover it. Otherwise, perform 26 | factory reprogramming of MicroPython firmware (completely erase flash, followed 27 | by firmware programming). 28 | """ 29 | ) 30 | time.sleep(3) 31 | 32 | 33 | def setup(): 34 | check_bootsec() 35 | print("Performing initial setup") 36 | uos.VfsLfs2.mkfs(bdev) 37 | vfs = uos.VfsLfs2(bdev) 38 | uos.mount(vfs, "/") 39 | with open("boot.py", "w") as f: 40 | f.write( 41 | """\ 42 | import lcd 43 | from machine import Pin 44 | import logo 45 | import gc 46 | import time 47 | 48 | gc.enable() 49 | 50 | i8080 = lcd.I8080(data=(Pin(39), Pin(40), Pin(41), Pin(42), Pin(45), Pin(46), Pin(47), Pin(48)), 51 | command=Pin(7), 52 | write=Pin(8), 53 | read=Pin(9), 54 | cs=Pin(6), 55 | pclk=2 * 1000 * 1000, 56 | width=320, 57 | height=170, 58 | swap_color_bytes=False, 59 | cmd_bits=8, 60 | param_bits=8) 61 | 62 | st = lcd.ST7789(i8080, reset=Pin(5), backlight=Pin(38)) 63 | 64 | st.reset() 65 | st.init() 66 | st.invert_color(True) 67 | st.swap_xy(True) 68 | st.mirror(False, True) 69 | st.set_gap(0, 35) 70 | st.backlight_on() 71 | 72 | st.bitmap(0, 0, logo.WIDTH, logo.HEIGHT, logo.BITMAP) 73 | 74 | time.sleep(0.1) 75 | del st 76 | i8080.deinit() 77 | gc.collect() 78 | """ 79 | ) 80 | return vfs 81 | -------------------------------------------------------------------------------- /target/esp32s3/boards/LILYGO_T-DisplayS3/mpconfigboard.cmake: -------------------------------------------------------------------------------- 1 | set(IDF_TARGET esp32s3) 2 | 3 | # 4 | # Generate sdkconfig.partitions file 5 | # 6 | file(WRITE ${CMAKE_CURRENT_LIST_DIR}/sdkconfig.partitions 7 | "CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y\n") 8 | file(APPEND ${CMAKE_CURRENT_LIST_DIR}/sdkconfig.partitions 9 | "CONFIG_PARTITION_TABLE_CUSTOM=y\n") 10 | file(APPEND ${CMAKE_CURRENT_LIST_DIR}/sdkconfig.partitions 11 | "CONFIG_PARTITION_TABLE_CUSTOM_FILENAME=\"${CMAKE_CURRENT_LIST_DIR}/partitions.csv\"\n") 12 | 13 | set(SDKCONFIG_DEFAULTS boards/sdkconfig.base 14 | boards/sdkconfig.usb 15 | boards/sdkconfig.ble 16 | boards/sdkconfig.240mhz 17 | ${CMAKE_CURRENT_LIST_DIR}/sdkconfig.board 18 | ${CMAKE_CURRENT_LIST_DIR}/sdkconfig.partitions 19 | ) 20 | 21 | set(MICROPY_FROZEN_MANIFEST ${CMAKE_CURRENT_LIST_DIR}/manifest.py) 22 | 23 | set(EXTMOD_LCD 1) 24 | -------------------------------------------------------------------------------- /target/esp32s3/boards/LILYGO_T-DisplayS3/mpconfigboard.h: -------------------------------------------------------------------------------- 1 | #define MICROPY_HW_BOARD_NAME "LILYGO T-DisplayS3" 2 | #define MICROPY_HW_MCU_NAME "ESP32S3" 3 | 4 | #define MICROPY_PY_MACHINE_DAC (0) 5 | 6 | // Enable UART REPL for modules that have an external USB-UART and don't use native USB. 7 | #define MICROPY_HW_ENABLE_UART_REPL (1) 8 | -------------------------------------------------------------------------------- /target/esp32s3/boards/LILYGO_T-DisplayS3/partitions.csv: -------------------------------------------------------------------------------- 1 | # Notes: the offset of the partition table itself is set in 2 | # $IDF_PATH/components/partition_table/Kconfig.projbuild. 3 | # Name, Type, SubType, Offset, Size, Flags 4 | nvs, data, nvs, 0x9000, 0x6000, 5 | phy_init, data, phy, 0xf000, 0x1000, 6 | factory, app, factory, 0x10000, 0x3F0000, 7 | vfs, data, fat, 0x400000, 0xc00000, 8 | -------------------------------------------------------------------------------- /target/esp32s3/boards/LILYGO_T-DisplayS3/sdkconfig.board: -------------------------------------------------------------------------------- 1 | CONFIG_FLASHMODE_QIO=y 2 | CONFIG_ESPTOOLPY_FLASHFREQ_80M=y 3 | CONFIG_ESPTOOLPY_FLASHSIZE_DETECT=y 4 | CONFIG_ESPTOOLPY_AFTER_NORESET=y 5 | 6 | CONFIG_SPIRAM_MEMTEST= 7 | 8 | CONFIG_ESP32S3_SPIRAM_SUPPORT=y 9 | CONFIG_SPIRAM_MODE_OCT=y 10 | CONFIG_SPIRAM_TYPE_AUTO=y 11 | CONFIG_SPIRAM_SIZE=-1 12 | CONFIG_SPIRAM_SPEED_80M=y 13 | CONFIG_SPIRAM=y 14 | CONFIG_SPIRAM_BOOT_INIT=y 15 | CONFIG_SPIRAM_IGNORE_NOTFOUND=y 16 | CONFIG_SPIRAM_USE_MEMMAP=y 17 | CONFIG_SPIRAM_MEMTEST=y 18 | CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=16384 19 | CONFIG_SPIRAM_MALLOC_RESERVE_INTERNAL=32768 20 | 21 | # 22 | # Bootloader log verbosity 23 | # 24 | # CONFIG_BOOTLOADER_LOG_LEVEL_NONE=y 25 | # CONFIG_BOOTLOADER_LOG_LEVEL_ERROR=y 26 | CONFIG_BOOTLOADER_LOG_LEVEL_WARN=y 27 | # CONFIG_BOOTLOADER_LOG_LEVEL_INFO=y 28 | # CONFIG_BOOTLOADER_LOG_LEVEL_DEBUG=y 29 | # CONFIG_BOOTLOADER_LOG_LEVEL_VERBOSE=y 30 | 31 | # 32 | # Default log verbosity 33 | # 34 | # CONFIG_LOG_DEFAULT_LEVEL_NONE=y 35 | # CONFIG_LOG_DEFAULT_LEVEL_ERROR=y 36 | CONFIG_LOG_DEFAULT_LEVEL_WARN=y 37 | # CONFIG_LOG_DEFAULT_LEVEL_INFO=y 38 | # CONFIG_LOG_DEFAULT_LEVEL_DEBUG=y 39 | # CONFIG_LOG_DEFAULT_LEVEL_VERBOSE=y 40 | -------------------------------------------------------------------------------- /target/esp32s3/boards/LILYGO_T-RGB/.gitignore: -------------------------------------------------------------------------------- 1 | sdkconfig.partitions 2 | -------------------------------------------------------------------------------- /target/esp32s3/boards/LILYGO_T-RGB/board.json: -------------------------------------------------------------------------------- 1 | { 2 | "deploy": [ 3 | "../deploy.md" 4 | ], 5 | "docs": "", 6 | "features": [ 7 | "BLE", 8 | "WiFi" 9 | ], 10 | "images": [ 11 | "generic_s3.jpg" 12 | ], 13 | "mcu": "esp32s3", 14 | "product": "T-RGB (SPIRAM)", 15 | "thumbnail": "", 16 | "url": "https://www.aliexpress.us/item/3256804592227662.html", 17 | "vendor": "LILYGO" 18 | } 19 | -------------------------------------------------------------------------------- /target/esp32s3/boards/LILYGO_T-RGB/manifest.py: -------------------------------------------------------------------------------- 1 | freeze("$(PORT_DIR)/modules", ("_boot.py", "apa106.py", "flashbdev.py")) 2 | freeze("$(MPY_DIR)/tools", ("upip.py", "upip_utarfile.py")) 3 | freeze("$(MPY_DIR)/ports/esp8266/modules", "ntptime.py") 4 | freeze("$(MPY_DIR)/drivers/dht", "dht.py") 5 | freeze("$(MPY_DIR)/drivers/onewire") 6 | include("$(MPY_DIR)/extmod/uasyncio/manifest.py") 7 | include("$(MPY_DIR)/extmod/webrepl/manifest.py") 8 | include("$(MPY_DIR)/drivers/neopixel/manifest.py") 9 | freeze("modules") 10 | -------------------------------------------------------------------------------- /target/esp32s3/boards/LILYGO_T-RGB/modules/inisetup.py: -------------------------------------------------------------------------------- 1 | import uos 2 | from flashbdev import bdev 3 | 4 | 5 | def check_bootsec(): 6 | buf = bytearray(bdev.ioctl(5, 0)) # 5 is SEC_SIZE 7 | bdev.readblocks(0, buf) 8 | empty = True 9 | for b in buf: 10 | if b != 0xFF: 11 | empty = False 12 | break 13 | if empty: 14 | return True 15 | fs_corrupted() 16 | 17 | 18 | def fs_corrupted(): 19 | import time 20 | 21 | while 1: 22 | print( 23 | """\ 24 | The filesystem appears to be corrupted. If you had important data there, you 25 | may want to make a flash snapshot to try to recover it. Otherwise, perform 26 | factory reprogramming of MicroPython firmware (completely erase flash, followed 27 | by firmware programming). 28 | """ 29 | ) 30 | time.sleep(3) 31 | 32 | 33 | def setup(): 34 | check_bootsec() 35 | print("Performing initial setup") 36 | uos.VfsLfs2.mkfs(bdev) 37 | vfs = uos.VfsLfs2(bdev) 38 | uos.mount(vfs, "/") 39 | with open("boot.py", "w") as f: 40 | f.write( 41 | """\ 42 | import logo 43 | import tft_config 44 | import gc 45 | import time 46 | 47 | rgb = tft_config.config() 48 | rgb.backlight_on() 49 | rgb.bitmap(0, 0, logo.WIDTH, logo.HEIGHT, logo.BITMAP) 50 | 51 | time.sleep(2) 52 | rgb.backlight_off() 53 | rgb.deinit() 54 | gc.collect() 55 | """ 56 | ) 57 | return vfs 58 | -------------------------------------------------------------------------------- /target/esp32s3/boards/LILYGO_T-RGB/modules/tft_config.py: -------------------------------------------------------------------------------- 1 | import machine 2 | import xl9535 3 | import time 4 | from collections import namedtuple 5 | import lcd 6 | import gc 7 | 8 | __TP_RES_PIN = const(1) 9 | __PWR_EN_PIN = const(2) 10 | __LCD_CS_PIN = const(3) 11 | __LCD_SDA_PIN = const(4) 12 | __LCD_CLK_PIN = const(5) 13 | __LCD_RST_PIN = const(6) 14 | __SD_CS_PIN = const(7) 15 | 16 | InitData = namedtuple("InitData", ["cmd", "data", "delay"]) 17 | 18 | st_init_cmds = [ 19 | InitData(cmd=0xFF, data=b'\x77\x01\x00\x00\x10', delay=0), 20 | InitData(cmd=0xC0, data=b'\x3b\x00', delay=0), 21 | InitData(cmd=0xC1, data=b'\x0b\x02', delay=0), 22 | InitData(cmd=0xC2, data=b'\x07\x02', delay=0), 23 | InitData(cmd=0xCC, data=b'\x10', delay=0), 24 | InitData(cmd=0xCD, data=b'\x08', delay=0), # 用565时屏蔽 666打开 25 | InitData(cmd=0xb0, data=b'\x00\x11\x16\x0e\x11\x06\x05\x09\x08\x21\x06\x13\x10\x29\x31\x18', delay=0), 26 | InitData(cmd=0xb1, data=b'\x00\x11\x16\x0e\x11\x07\x05\x09\x09\x21\x05\x13\x11\x2a\x31\x18', delay=0), 27 | InitData(cmd=0xFF, data=b'\x77\x01\x00\x00\x11', delay=0), 28 | InitData(cmd=0xb0, data=b'\x6d', delay=0), 29 | InitData(cmd=0xb1, data=b'\x37', delay=0), 30 | InitData(cmd=0xb2, data=b'\x81', delay=0), 31 | InitData(cmd=0xb3, data=b'\x80', delay=0), 32 | InitData(cmd=0xb5, data=b'\x43', delay=0), 33 | InitData(cmd=0xb7, data=b'\x85', delay=0), 34 | InitData(cmd=0xb8, data=b'\x20', delay=0), 35 | InitData(cmd=0xc1, data=b'\x78', delay=0), 36 | InitData(cmd=0xc2, data=b'\x78', delay=0), 37 | InitData(cmd=0xc3, data=b'\x8c', delay=0), 38 | InitData(cmd=0xd0, data=b'\x88', delay=0), 39 | InitData(cmd=0xe0, data=b'\x00\x00\x02', delay=0), 40 | InitData(cmd=0xe1, data=b'\x03\xa0\x00\x00\x04\xa0\x00\x00\x00\x20\x20', delay=0), 41 | InitData(cmd=0xe2, data=b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', delay=0), 42 | InitData(cmd=0xe3, data=b'\x00\x00\x11\x00', delay=0), 43 | InitData(cmd=0xe4, data=b'\x22\x00', delay=0), 44 | InitData(cmd=0xe5, data=b'\x05\xec\xa0\xa0\x07\xee\xa0\xa0\x00\x00\x00\x00\x00\x00\x00\x00', delay=0), 45 | InitData(cmd=0xe6, data=b'\x00\x00\x11\x00', delay=0), 46 | InitData(cmd=0xe7, data=b'\x22\x00', delay=0), 47 | InitData(cmd=0xe8, data=b'\x06\xed\xa0\xa0\x08\xef\xa0\xa0\x00\x00\x00\x00\x00\x00\x00\x00', delay=0), 48 | InitData(cmd=0xeb, data=b'\x00\x00\x40\x40\x00\x00\x00', delay=0), 49 | InitData(cmd=0xed, data=b'\xff\xff\xff\xba\x0a\xbf\x45\xff\xff\x54\xfb\xa0\xab\xff\xff\xff', delay=0), 50 | InitData(cmd=0xef, data=b'\x10\x0d\x04\x08\x3f\x1f', delay=0), 51 | InitData(cmd=0xFF, data=b'\x77\x01\x00\x00\x13', delay=0), 52 | InitData(cmd=0xef, data=b'\x08', delay=0), 53 | InitData(cmd=0xFF, data=b'\x77\x01\x00\x00\x00', delay=0), 54 | InitData(cmd=0x36, data=b'\x08', delay=0), 55 | InitData(cmd=0x3a, data=b'\x66', delay=0), 56 | InitData(cmd=0x11, data=b'\x00', delay=100), 57 | # InitData(cmd=0xFF, data=b'\x77\x01\x00\x00\x12', delay=0), 58 | # InitData(cmd=0xd1, data=b'\x81', delay=0), 59 | # InitData(cmd=0xd2, data=b'\x06', delay=0), 60 | InitData(cmd=0x29, data=b'\x00', delay=100) 61 | ] 62 | 63 | 64 | def __lcd_send_data(xl, data): 65 | for _ in range(8): 66 | if (data & 0x80): 67 | xl.digitalWrite(__LCD_SDA_PIN, 1); 68 | else: 69 | xl.digitalWrite(__LCD_SDA_PIN, 0); 70 | data <<= 1; 71 | xl.digitalWrite(__LCD_CLK_PIN, 0); 72 | xl.digitalWrite(__LCD_CLK_PIN, 1); 73 | 74 | def __lcd_cmd(xl, cmd): 75 | xl.digitalWrite(__LCD_CS_PIN, 0) 76 | xl.digitalWrite(__LCD_SDA_PIN, 0) 77 | xl.digitalWrite(__LCD_CLK_PIN, 0) 78 | xl.digitalWrite(__LCD_CLK_PIN, 1) 79 | __lcd_send_data(xl, cmd) 80 | xl.digitalWrite(__LCD_CS_PIN, 1) 81 | 82 | def __lcd_data(xl, data): 83 | for i in range(len(data)): 84 | xl.digitalWrite(__LCD_CS_PIN, 0) 85 | xl.digitalWrite(__LCD_SDA_PIN, 1) 86 | xl.digitalWrite(__LCD_CLK_PIN, 0) 87 | xl.digitalWrite(__LCD_CLK_PIN, 1) 88 | __lcd_send_data(xl, data[i]) 89 | xl.digitalWrite(__LCD_CS_PIN, 1) 90 | 91 | def tft_init(xl): 92 | xl.digitalWrite(__LCD_CS_PIN, 1) 93 | xl.digitalWrite(__LCD_SDA_PIN, 1) 94 | xl.digitalWrite(__LCD_CLK_PIN, 1) 95 | 96 | # Reset the display 97 | xl.digitalWrite(__LCD_RST_PIN, 1) 98 | time.sleep(0.2) 99 | xl.digitalWrite(__LCD_RST_PIN, 0) 100 | time.sleep(0.2) 101 | xl.digitalWrite(__LCD_RST_PIN, 1) 102 | time.sleep(0.2) 103 | for i in st_init_cmds: 104 | __lcd_cmd(xl, i.cmd) 105 | __lcd_data(xl, i.data) 106 | if i.delay != 0: 107 | time.sleep(0.1) 108 | # print("Register setup complete") 109 | 110 | def config(): 111 | i2c = machine.I2C(0, scl=machine.Pin(48), sda=machine.Pin(8)) 112 | xl = xl9535.XL9535(i2c) 113 | pin = (1 << __PWR_EN_PIN) | \ 114 | (1 << __LCD_CS_PIN) | \ 115 | (1 << __TP_RES_PIN) | \ 116 | (1 << __LCD_SDA_PIN) | \ 117 | (1 << __LCD_CLK_PIN) | \ 118 | (1 << __LCD_RST_PIN) | \ 119 | (1 << __SD_CS_PIN) 120 | xl.pinMode8(0, pin, xl.OUT) 121 | xl.digitalWrite(__PWR_EN_PIN, 1) 122 | tft_init(xl) 123 | del i2c 124 | del xl 125 | gc.collect() 126 | return lcd.DPI(data = (machine.Pin(7), \ 127 | machine.Pin(6), \ 128 | machine.Pin(5), \ 129 | machine.Pin(3), \ 130 | machine.Pin(2), \ 131 | machine.Pin(14), \ 132 | machine.Pin(13), \ 133 | machine.Pin(12), \ 134 | machine.Pin(11), \ 135 | machine.Pin(10), \ 136 | machine.Pin(9), \ 137 | machine.Pin(21), \ 138 | machine.Pin(18), \ 139 | machine.Pin(17), \ 140 | machine.Pin(16), \ 141 | machine.Pin(15)), \ 142 | hsync = machine.Pin(47), \ 143 | vsync = machine.Pin(41), \ 144 | de = machine.Pin(45), \ 145 | pclk_pin = machine.Pin(42), \ 146 | timings = (1, 30, 50, 1, 30, 20), \ 147 | backlight = machine.Pin(46), \ 148 | pclk = 10 * 1000 * 1000, \ 149 | width = 480, \ 150 | height = 480) 151 | -------------------------------------------------------------------------------- /target/esp32s3/boards/LILYGO_T-RGB/modules/xl9535.py: -------------------------------------------------------------------------------- 1 | 2 | 3 | __XL9535_IIC_ADDRESS = const(0X20) 4 | 5 | __XL9535_INPUT_PORT_0_REG = const(0X00) 6 | __XL9535_INPUT_PORT_1_REG = const(0X01) 7 | __XL9535_OUTPUT_PORT_0_REG = const(0X02) 8 | __XL9535_OUTPUT_PORT_1_REG = const(0X03) 9 | __XL9535_INVERSION_PORT_0_REG = const(0X04) 10 | __XL9535_INVERSION_PORT_1_REG = const(0X05) 11 | __XL9535_CONFIG_PORT_0_REG = const(0X06) 12 | __XL9535_CONFIG_PORT_1_REG = const(0X07) 13 | 14 | 15 | class XL9535(): 16 | OUT = const(3) 17 | IN = const(1) 18 | def __init__(self, bus: I2C, a0: bool = False, a1: bool = False, a2: bool = False): 19 | self.__bus = bus 20 | self.__address = __XL9535_IIC_ADDRESS | \ 21 | (int(a2) << 3) | \ 22 | (int(a1) << 2) | \ 23 | (int(a0) << 1) 24 | self.__buf = bytearray(1) 25 | try: 26 | self.__bus.scan().index(self.__address) 27 | except: 28 | raise Exception("XL9535 not found") 29 | 30 | def pinMode(self, pin, mode): 31 | if pin > 7: 32 | self.__bus.readfrom_mem_into(self.__address, 33 | __XL9535_CONFIG_PORT_1_REG, 34 | self.__buf) 35 | if mode == self.OUT: 36 | self.__buf[0] = self.__buf[0] & (~(1 << (pin - 10))) 37 | else: 38 | self.__buf[0] = self.__buf[0] | (1 << (pin - 10)) 39 | self.__bus.writeto_mem(self.__address, 40 | __XL9535_CONFIG_PORT_1_REG, 41 | self.__buf) 42 | else: 43 | self.__bus.readfrom_mem_into(self.__address, 44 | __XL9535_CONFIG_PORT_0_REG, 45 | self.__buf) 46 | if mode == self.OUT: 47 | self.__buf[0] = self.__buf[0] & (~(1 << pin)) 48 | else: 49 | self.__buf[0] = self.__buf[0] | (1 << pin) 50 | self.__bus.writeto_mem(self.__address, 51 | __XL9535_CONFIG_PORT_0_REG, 52 | self.__buf) 53 | 54 | def pinMode8(self, port, pin, mode): 55 | self.__buf[0] = pin if mode != self.OUT else ~pin 56 | if port: 57 | self.__bus.writeto_mem(self.__address, 58 | __XL9535_CONFIG_PORT_1_REG, 59 | self.__buf) 60 | else: 61 | self.__bus.writeto_mem(self.__address, 62 | __XL9535_CONFIG_PORT_0_REG, 63 | self.__buf) 64 | 65 | def digitalWrite(self, pin, val): 66 | if pin > 7: 67 | self.__bus.readfrom_mem_into(self.__address, 68 | __XL9535_CONFIG_PORT_1_REG, 69 | self.__buf) 70 | self.__buf[0] = self.__buf[0] & (~(1 << (pin - 10))) 71 | self.__buf[0] = self.__buf[0] | val << (pin - 10) 72 | self.__bus.writeto_mem(self.__address, 73 | __XL9535_CONFIG_PORT_1_REG, 74 | bytes(self.__buf)) 75 | else: 76 | self.__bus.readfrom_mem_into(self.__address, 77 | __XL9535_OUTPUT_PORT_0_REG, 78 | self.__buf) 79 | self.__buf[0] = self.__buf[0] & (~(1 << pin)) 80 | self.__buf[0] = self.__buf[0] | val << pin 81 | self.__bus.writeto_mem(self.__address, 82 | __XL9535_OUTPUT_PORT_0_REG, 83 | self.__buf) 84 | -------------------------------------------------------------------------------- /target/esp32s3/boards/LILYGO_T-RGB/mpconfigboard.cmake: -------------------------------------------------------------------------------- 1 | set(IDF_TARGET esp32s3) 2 | 3 | # 4 | # Generate sdkconfig.partitions file 5 | # 6 | file(WRITE ${CMAKE_CURRENT_LIST_DIR}/sdkconfig.partitions 7 | "CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y\n") 8 | file(APPEND ${CMAKE_CURRENT_LIST_DIR}/sdkconfig.partitions 9 | "CONFIG_PARTITION_TABLE_CUSTOM=y\n") 10 | file(APPEND ${CMAKE_CURRENT_LIST_DIR}/sdkconfig.partitions 11 | "CONFIG_PARTITION_TABLE_CUSTOM_FILENAME=\"${CMAKE_CURRENT_LIST_DIR}/partitions.csv\"\n") 12 | 13 | set(SDKCONFIG_DEFAULTS boards/sdkconfig.base 14 | boards/sdkconfig.usb 15 | boards/sdkconfig.ble 16 | boards/sdkconfig.240mhz 17 | ${CMAKE_CURRENT_LIST_DIR}/sdkconfig.board 18 | ${CMAKE_CURRENT_LIST_DIR}/sdkconfig.partitions 19 | ) 20 | 21 | set(MICROPY_FROZEN_MANIFEST ${CMAKE_CURRENT_LIST_DIR}/manifest.py) 22 | 23 | set(EXTMOD_LCD 1) 24 | -------------------------------------------------------------------------------- /target/esp32s3/boards/LILYGO_T-RGB/mpconfigboard.h: -------------------------------------------------------------------------------- 1 | #define MICROPY_HW_BOARD_NAME "LILYGO T-RGB" 2 | #define MICROPY_HW_MCU_NAME "ESP32S3" 3 | 4 | #define MICROPY_PY_MACHINE_DAC (0) 5 | 6 | // Enable UART REPL for modules that have an external USB-UART and don't use native USB. 7 | #define MICROPY_HW_ENABLE_UART_REPL (1) 8 | -------------------------------------------------------------------------------- /target/esp32s3/boards/LILYGO_T-RGB/partitions.csv: -------------------------------------------------------------------------------- 1 | # Notes: the offset of the partition table itself is set in 2 | # $IDF_PATH/components/partition_table/Kconfig.projbuild. 3 | # Name, Type, SubType, Offset, Size, Flags 4 | nvs, data, nvs, 0x9000, 0x6000, 5 | phy_init, data, phy, 0xf000, 0x1000, 6 | factory, app, factory, 0x10000, 0x3F0000, 7 | vfs, data, fat, 0x400000, 0xc00000, 8 | -------------------------------------------------------------------------------- /target/esp32s3/boards/LILYGO_T-RGB/sdkconfig.board: -------------------------------------------------------------------------------- 1 | CONFIG_FLASHMODE_QIO=y 2 | CONFIG_ESPTOOLPY_FLASHFREQ_80M=y 3 | CONFIG_ESPTOOLPY_FLASHSIZE_DETECT=y 4 | CONFIG_ESPTOOLPY_AFTER_NORESET=y 5 | 6 | CONFIG_ESP32S3_SPIRAM_SUPPORT=y 7 | CONFIG_SPIRAM_MODE_OCT=y 8 | CONFIG_SPIRAM_TYPE_AUTO=y 9 | CONFIG_SPIRAM_SIZE=-1 10 | CONFIG_SPIRAM_SPEED_80M=y 11 | CONFIG_SPIRAM=y 12 | CONFIG_SPIRAM_BOOT_INIT=y 13 | # CONFIG_SPIRAM_IGNORE_NOTFOUND=y 14 | # CONFIG_SPIRAM_USE_MEMMAP=y 15 | # CONFIG_SPIRAM_USE_CAPS_ALLOC=y 16 | CONFIG_SPIRAM_USE_MALLOC=y 17 | CONFIG_SPIRAM_MEMTEST=y 18 | CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=16384 19 | CONFIG_SPIRAM_MALLOC_RESERVE_INTERNAL=32768 20 | 21 | # 22 | # Bootloader log verbosity 23 | # 24 | # CONFIG_BOOTLOADER_LOG_LEVEL_NONE=y 25 | # CONFIG_BOOTLOADER_LOG_LEVEL_ERROR=y 26 | CONFIG_BOOTLOADER_LOG_LEVEL_WARN=y 27 | # CONFIG_BOOTLOADER_LOG_LEVEL_INFO=y 28 | # CONFIG_BOOTLOADER_LOG_LEVEL_DEBUG=y 29 | # CONFIG_BOOTLOADER_LOG_LEVEL_VERBOSE=y 30 | 31 | # 32 | # Default log verbosity 33 | # 34 | # CONFIG_LOG_DEFAULT_LEVEL_NONE=y 35 | # CONFIG_LOG_DEFAULT_LEVEL_ERROR=y 36 | CONFIG_LOG_DEFAULT_LEVEL_WARN=y 37 | # CONFIG_LOG_DEFAULT_LEVEL_INFO=y 38 | # CONFIG_LOG_DEFAULT_LEVEL_DEBUG=y 39 | # CONFIG_LOG_DEFAULT_LEVEL_VERBOSE=y 40 | -------------------------------------------------------------------------------- /target/esp32s3/boards/LILYGO_T5-4.7-PLUS/.gitignore: -------------------------------------------------------------------------------- 1 | sdkconfig.partitions 2 | -------------------------------------------------------------------------------- /target/esp32s3/boards/LILYGO_T5-4.7-PLUS/board.json: -------------------------------------------------------------------------------- 1 | { 2 | "deploy": [ 3 | "../deploy.md" 4 | ], 5 | "docs": "", 6 | "features": [ 7 | "BLE", 8 | "WiFi" 9 | ], 10 | "images": [ 11 | "generic_s3.jpg" 12 | ], 13 | "mcu": "esp32s3", 14 | "product": "T5-4.7 Plus (SPIRAM)", 15 | "thumbnail": "", 16 | "url": "https://www.espressif.com/en/products/modules", 17 | "vendor": "LilyGo" 18 | } 19 | -------------------------------------------------------------------------------- /target/esp32s3/boards/LILYGO_T5-4.7-PLUS/mpconfigboard.cmake: -------------------------------------------------------------------------------- 1 | set(IDF_TARGET esp32s3) 2 | 3 | # 4 | # Generate sdkconfig.partitions file 5 | # 6 | file(WRITE ${CMAKE_CURRENT_LIST_DIR}/sdkconfig.partitions 7 | "CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y\n") 8 | file(APPEND ${CMAKE_CURRENT_LIST_DIR}/sdkconfig.partitions 9 | "CONFIG_PARTITION_TABLE_CUSTOM=y\n") 10 | file(APPEND ${CMAKE_CURRENT_LIST_DIR}/sdkconfig.partitions 11 | "CONFIG_PARTITION_TABLE_CUSTOM_FILENAME=\"${CMAKE_CURRENT_LIST_DIR}/partitions.csv\"\n") 12 | 13 | set(SDKCONFIG_DEFAULTS boards/sdkconfig.base 14 | boards/sdkconfig.usb 15 | boards/sdkconfig.ble 16 | boards/sdkconfig.240mhz 17 | ${MICROPY_BOARD_DIR}/sdkconfig.board 18 | ${CMAKE_CURRENT_LIST_DIR}/sdkconfig.partitions 19 | ) 20 | 21 | if(NOT MICROPY_FROZEN_MANIFEST) 22 | set(MICROPY_FROZEN_MANIFEST ${MICROPY_PORT_DIR}/boards/manifest.py 23 | ${EXTMOD_FROZEN_DIR}/touch/manifest.py 24 | ${EXTMOD_FROZEN_DIR}/display/framebuf1/manifest.py) 25 | endif() 26 | 27 | set(EXTMOD_EPD 1) 28 | -------------------------------------------------------------------------------- /target/esp32s3/boards/LILYGO_T5-4.7-PLUS/mpconfigboard.h: -------------------------------------------------------------------------------- 1 | #define MICROPY_HW_BOARD_NAME "T5-4.7 Plus (spiram)" 2 | #define MICROPY_HW_MCU_NAME "ESP32S3" 3 | 4 | #define MICROPY_PY_MACHINE_DAC (0) 5 | 6 | // Enable UART REPL for modules that have an external USB-UART and don't use native USB. 7 | #define MICROPY_HW_ENABLE_UART_REPL (1) 8 | -------------------------------------------------------------------------------- /target/esp32s3/boards/LILYGO_T5-4.7-PLUS/partitions.csv: -------------------------------------------------------------------------------- 1 | # Notes: the offset of the partition table itself is set in 2 | # $IDF_PATH/components/partition_table/Kconfig.projbuild. 3 | # Name, Type, SubType, Offset, Size, Flags 4 | nvs, data, nvs, 0x9000, 0x6000, 5 | phy_init, data, phy, 0xf000, 0x1000, 6 | factory, app, factory, 0x10000, 0x3F0000, 7 | vfs, data, fat, 0x400000, 0xc00000, 8 | -------------------------------------------------------------------------------- /target/esp32s3/boards/LILYGO_T5-4.7-PLUS/sdkconfig.board: -------------------------------------------------------------------------------- 1 | CONFIG_FLASHMODE_QIO=y 2 | CONFIG_ESPTOOLPY_FLASHFREQ_80M=y 3 | CONFIG_ESPTOOLPY_FLASHSIZE_DETECT=y 4 | CONFIG_ESPTOOLPY_AFTER_NORESET=y 5 | 6 | CONFIG_SPIRAM_MEMTEST= 7 | 8 | CONFIG_ESP32S3_SPIRAM_SUPPORT=y 9 | CONFIG_SPIRAM_MODE_OCT=y 10 | CONFIG_SPIRAM_TYPE_AUTO=y 11 | CONFIG_SPIRAM_SIZE=-1 12 | CONFIG_SPIRAM_SPEED_80M=y 13 | CONFIG_SPIRAM=y 14 | CONFIG_SPIRAM_BOOT_INIT=y 15 | CONFIG_SPIRAM_IGNORE_NOTFOUND=y 16 | CONFIG_SPIRAM_USE_MEMMAP=y 17 | CONFIG_SPIRAM_MEMTEST=y 18 | CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=16384 19 | CONFIG_SPIRAM_MALLOC_RESERVE_INTERNAL=32768 20 | 21 | # 22 | # Bootloader log verbosity 23 | # 24 | # CONFIG_BOOTLOADER_LOG_LEVEL_NONE=y 25 | # CONFIG_BOOTLOADER_LOG_LEVEL_ERROR=y 26 | CONFIG_BOOTLOADER_LOG_LEVEL_WARN=y 27 | # CONFIG_BOOTLOADER_LOG_LEVEL_INFO=y 28 | # CONFIG_BOOTLOADER_LOG_LEVEL_DEBUG=y 29 | # CONFIG_BOOTLOADER_LOG_LEVEL_VERBOSE=y 30 | 31 | # 32 | # Default log verbosity 33 | # 34 | # CONFIG_LOG_DEFAULT_LEVEL_NONE=y 35 | # CONFIG_LOG_DEFAULT_LEVEL_ERROR=y 36 | CONFIG_LOG_DEFAULT_LEVEL_WARN=y 37 | # CONFIG_LOG_DEFAULT_LEVEL_INFO=y 38 | # CONFIG_LOG_DEFAULT_LEVEL_DEBUG=y 39 | # CONFIG_LOG_DEFAULT_LEVEL_VERBOSE=y 40 | -------------------------------------------------------------------------------- /target/esp32s3/boards/LILYGO_T7-S3/.gitignore: -------------------------------------------------------------------------------- 1 | sdkconfig.partitions 2 | -------------------------------------------------------------------------------- /target/esp32s3/boards/LILYGO_T7-S3/board.json: -------------------------------------------------------------------------------- 1 | { 2 | "deploy": [ 3 | "../deploy.md" 4 | ], 5 | "docs": "", 6 | "features": [ 7 | "BLE", 8 | "WiFi" 9 | ], 10 | "images": [ 11 | "generic_s3.jpg" 12 | ], 13 | "mcu": "esp32s3", 14 | "product": "T7-S3 (SPIRAM)", 15 | "thumbnail": "", 16 | "url": "https://www.aliexpress.us/item/3256804591247074.html", 17 | "vendor": "LILYGO" 18 | } 19 | -------------------------------------------------------------------------------- /target/esp32s3/boards/LILYGO_T7-S3/mpconfigboard.cmake: -------------------------------------------------------------------------------- 1 | set(IDF_TARGET esp32s3) 2 | 3 | # 4 | # Generate sdkconfig.partitions file 5 | # 6 | file(WRITE ${CMAKE_CURRENT_LIST_DIR}/sdkconfig.partitions 7 | "CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y\n") 8 | file(APPEND ${CMAKE_CURRENT_LIST_DIR}/sdkconfig.partitions 9 | "CONFIG_PARTITION_TABLE_CUSTOM=y\n") 10 | file(APPEND ${CMAKE_CURRENT_LIST_DIR}/sdkconfig.partitions 11 | "CONFIG_PARTITION_TABLE_CUSTOM_FILENAME=\"${CMAKE_CURRENT_LIST_DIR}/partitions.csv\"\n") 12 | 13 | set(SDKCONFIG_DEFAULTS boards/sdkconfig.base 14 | boards/sdkconfig.usb 15 | boards/sdkconfig.ble 16 | boards/sdkconfig.240mhz 17 | ${CMAKE_CURRENT_LIST_DIR}/sdkconfig.board 18 | ${CMAKE_CURRENT_LIST_DIR}/sdkconfig.partitions 19 | ) 20 | -------------------------------------------------------------------------------- /target/esp32s3/boards/LILYGO_T7-S3/mpconfigboard.h: -------------------------------------------------------------------------------- 1 | #define MICROPY_HW_BOARD_NAME "LILYGO T-DisplayS3" 2 | #define MICROPY_HW_MCU_NAME "ESP32S3" 3 | 4 | #define MICROPY_PY_MACHINE_DAC (0) 5 | 6 | // Enable UART REPL for modules that have an external USB-UART and don't use native USB. 7 | #define MICROPY_HW_ENABLE_UART_REPL (1) 8 | -------------------------------------------------------------------------------- /target/esp32s3/boards/LILYGO_T7-S3/partitions.csv: -------------------------------------------------------------------------------- 1 | # Notes: the offset of the partition table itself is set in 2 | # $IDF_PATH/components/partition_table/Kconfig.projbuild. 3 | # Name, Type, SubType, Offset, Size, Flags 4 | nvs, data, nvs, 0x9000, 0x6000, 5 | phy_init, data, phy, 0xf000, 0x1000, 6 | factory, app, factory, 0x10000, 0x3F0000, 7 | vfs, data, fat, 0x400000, 0xc00000, 8 | -------------------------------------------------------------------------------- /target/esp32s3/boards/LILYGO_T7-S3/sdkconfig.board: -------------------------------------------------------------------------------- 1 | CONFIG_FLASHMODE_QIO=y 2 | CONFIG_ESPTOOLPY_FLASHFREQ_80M=y 3 | CONFIG_ESPTOOLPY_FLASHSIZE_DETECT=y 4 | CONFIG_ESPTOOLPY_AFTER_NORESET=y 5 | 6 | CONFIG_SPIRAM_MEMTEST= 7 | 8 | CONFIG_ESP32S3_SPIRAM_SUPPORT=y 9 | CONFIG_SPIRAM_MODE_OCT=y 10 | CONFIG_SPIRAM_TYPE_AUTO=y 11 | CONFIG_SPIRAM_SIZE=-1 12 | CONFIG_SPIRAM_SPEED_80M=y 13 | CONFIG_SPIRAM=y 14 | CONFIG_SPIRAM_BOOT_INIT=y 15 | CONFIG_SPIRAM_IGNORE_NOTFOUND=y 16 | CONFIG_SPIRAM_USE_MEMMAP=y 17 | CONFIG_SPIRAM_MEMTEST=y 18 | CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=16384 19 | CONFIG_SPIRAM_MALLOC_RESERVE_INTERNAL=32768 20 | 21 | # 22 | # Bootloader log verbosity 23 | # 24 | # CONFIG_BOOTLOADER_LOG_LEVEL_NONE=y 25 | # CONFIG_BOOTLOADER_LOG_LEVEL_ERROR=y 26 | CONFIG_BOOTLOADER_LOG_LEVEL_WARN=y 27 | # CONFIG_BOOTLOADER_LOG_LEVEL_INFO=y 28 | # CONFIG_BOOTLOADER_LOG_LEVEL_DEBUG=y 29 | # CONFIG_BOOTLOADER_LOG_LEVEL_VERBOSE=y 30 | 31 | # 32 | # Default log verbosity 33 | # 34 | # CONFIG_LOG_DEFAULT_LEVEL_NONE=y 35 | # CONFIG_LOG_DEFAULT_LEVEL_ERROR=y 36 | CONFIG_LOG_DEFAULT_LEVEL_WARN=y 37 | # CONFIG_LOG_DEFAULT_LEVEL_INFO=y 38 | # CONFIG_LOG_DEFAULT_LEVEL_DEBUG=y 39 | # CONFIG_LOG_DEFAULT_LEVEL_VERBOSE=y 40 | -------------------------------------------------------------------------------- /target/esp32s3/esp32s3.mk: -------------------------------------------------------------------------------- 1 | 2 | include $(INCLUDE_DIR)/download.mk 3 | include $(INCLUDE_DIR)/package.mk 4 | 5 | define esp32s3/info 6 | PKG_NAME:=esp-idf 7 | PKG_SOURCE_URL:=https://github.com/espressif/esp-idf.git 8 | PKG_SOURCE_PROTO:=git 9 | PKG_SOURCE_VERSION:=v4.4.4 10 | PKG_SOURCE_MD5:=9416da50831df089fcf60db5fc2750f0 11 | PKG_SOURCE_OPT:=--recurse-submodules 12 | endef 13 | 14 | # $(call DownloadMethod/git,$(PKG_NAME),$(PKG_SOURCE_URL),$(PKG_SOURCE_VERSION)) ; 15 | define esp32s3/prereq 16 | $(eval $(esp32s3/info)) 17 | $(call Package/prereq,$(TARGET_BUILD_DIR)) 18 | endef 19 | 20 | ## 21 | ## $(1) MODULES 22 | ## 23 | define esp32s3/compile 24 | $(TARGET_BUILD_DIR)/esp-idf/install.sh 25 | . $(TARGET_BUILD_DIR)/esp-idf/export.sh && \ 26 | make -C $(TARGET_BUILD_DIR)/micropython/ports/esp32 \ 27 | MICROPY_BOARD_DIR=$(TOP_DIR)/target/$(TARGET)/boards/$(BOARD) \ 28 | BOARD=$(BOARD) BUILD=$(TARGET_BUILD_DIR)/build-$(BOARD) \ 29 | USER_C_MODULES=$(TOP_DIR)/extmod/micropython.cmake \ 30 | EXTMOD_FROZEN_DIR=$(TOP_DIR)/extmod 31 | endef 32 | 33 | 34 | define esp32s3/install 35 | @[ -d $(BIN_DIR) ] && mkdir -p $(BIN_DIR)/esp32s3/$(BOARD) 36 | @img_name=LilyGo-MicroPython_$(TARGET)_$(BOARD) && \ 37 | cd $(TARGET_BUILD_DIR)/micropython && \ 38 | micropython_version=`git show -s --pretty=format:%h` && \ 39 | img_name=$${img_name}_MPY-$${micropython_version} && \ 40 | cd $(TARGET_BUILD_DIR)/$(PKG_NAME) && \ 41 | idf_version=`git show -s --pretty=format:%h` && \ 42 | img_name=$${img_name}_IDF-$${idf_version} && \ 43 | time=`date +"%Y%m%d"` && \ 44 | img_name=$${img_name}_B$${time} && \ 45 | md5=`md5sum $(TARGET_BUILD_DIR)/build-$(BOARD)/firmware.bin | awk '{print $$1}'` && \ 46 | img_name=$${img_name}_$${md5:0:10} && \ 47 | cp $(TARGET_BUILD_DIR)/build-$(BOARD)/firmware.bin $(BIN_DIR)/esp32s3/$(BOARD)/$${img_name}.bin 48 | endef 49 | 50 | -------------------------------------------------------------------------------- /target/nrf/boards/LILYGO_T-Echo-circuitpython/board.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the MicroPython project, http://micropython.org/ 3 | * 4 | * The MIT License (MIT) 5 | * 6 | * Copyright (c) 2017 Scott Shawcroft for Adafruit Industries 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | #include "supervisor/board.h" 28 | 29 | void board_init(void) { 30 | } 31 | 32 | bool board_requests_safe_mode(void) { 33 | return false; 34 | } 35 | 36 | void reset_board(void) { 37 | 38 | } -------------------------------------------------------------------------------- /target/nrf/boards/LILYGO_T-Echo-circuitpython/mpconfigboard.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the MicroPython project, http://micropython.org/ 3 | * 4 | * The MIT License (MIT) 5 | * 6 | * Copyright (c) 2016 Glenn Ruben Bakke 7 | * 8 | * 9 | * Permission is hereby granted, free of charge, to any person obtaining a copy 10 | * of this software and associated documentation files (the "Software"), to deal 11 | * in the Software without restriction, including without limitation the rights 12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | * copies of the Software, and to permit persons to whom the Software is 14 | * furnished to do so, subject to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be included in 17 | * all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | * THE SOFTWARE. 26 | */ 27 | 28 | #include "nrfx/hal/nrf_gpio.h" 29 | 30 | #define MICROPY_HW_BOARD_NAME "LilyGO T-Echo" 31 | #define MICROPY_HW_MCU_NAME "nRF52840" 32 | 33 | #define BOARD_HAS_CRYSTAL 1 34 | 35 | //#define MICROPY_HW_LED_STATUS (&pin_P0_14) 36 | 37 | #define DEFAULT_I2C_BUS_SCL (&pin_P0_27) 38 | #define DEFAULT_I2C_BUS_SDA (&pin_P0_26) 39 | 40 | #define DEFAULT_SPI_BUS_SCK (&pin_P0_19) 41 | #define DEFAULT_SPI_BUS_MOSI (&pin_P0_22) 42 | #define DEFAULT_SPI_BUS_MISO (&pin_P0_23) 43 | 44 | #define DEFAULT_UART_BUS_RX (&pin_P0_08) 45 | #define DEFAULT_UART_BUS_TX (&pin_P0_06) 46 | 47 | // Flash operation mode is determined by MICROPY_QSPI_DATAn pin configuration. 48 | // A pin config is valid if it is defined and its value is not 0xFF. 49 | // Quad mode: If all DATA0 --> DATA3 are valid 50 | // Dual mode: If DATA0 and DATA1 are valid while either DATA2 and/or DATA3 are invalid 51 | // Single mode: If only DATA0 is valid 52 | #if QSPI_FLASH_FILESYSTEM 53 | #define MICROPY_QSPI_DATA0 NRF_GPIO_PIN_MAP(1, 12) 54 | #define MICROPY_QSPI_DATA1 NRF_GPIO_PIN_MAP(1, 13) 55 | #define MICROPY_QSPI_DATA2 NRF_GPIO_PIN_MAP(0, 7) 56 | #define MICROPY_QSPI_DATA3 NRF_GPIO_PIN_MAP(0, 5) 57 | #define MICROPY_QSPI_SCK NRF_GPIO_PIN_MAP(1, 14) 58 | #define MICROPY_QSPI_CS NRF_GPIO_PIN_MAP(1, 15) 59 | #endif 60 | 61 | #if SPI_FLASH_FILESYSTEM 62 | #define SPI_FLASH_MOSI_PIN &pin_P1_12 63 | #define SPI_FLASH_MISO_PIN &pin_P1_13 64 | #define SPI_FLASH_SCK_PIN &pin_P1_14 65 | #define SPI_FLASH_CS_PIN &pin_P1_15 66 | #endif -------------------------------------------------------------------------------- /target/nrf/boards/LILYGO_T-Echo-circuitpython/mpconfigboard.mk: -------------------------------------------------------------------------------- 1 | USB_VID = 0x239A 2 | USB_PID = 0x0029 3 | USB_PRODUCT = "T-Echo" 4 | USB_MANUFACTURER = "LILYGO" 5 | 6 | MCU_CHIP = nrf52840 7 | 8 | # INTERNAL_FLASH_FILESYSTEM = 1 9 | 10 | QSPI_FLASH_FILESYSTEM = 1 11 | EXTERNAL_FLASH_DEVICE_COUNT = 1 12 | EXTERNAL_FLASH_DEVICES = "MX25R1635F,ZD25WQ16B" 13 | 14 | CIRCUITPY_ALARM = 1 15 | 16 | FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_datetime 17 | FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_GPS 18 | FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_BME280 19 | FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_framebuf 20 | FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_EPD 21 | FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_RFM9x 22 | -------------------------------------------------------------------------------- /target/nrf/boards/LILYGO_T-Echo-circuitpython/pins.c: -------------------------------------------------------------------------------- 1 | #include "shared-bindings/board/__init__.h" 2 | 3 | STATIC const mp_rom_map_elem_t board_module_globals_table[] = { 4 | { MP_ROM_QSTR(MP_QSTR_P0_00), MP_ROM_PTR(&pin_P0_00) }, 5 | { MP_ROM_QSTR(MP_QSTR_P0_01), MP_ROM_PTR(&pin_P0_01) }, 6 | { MP_ROM_QSTR(MP_QSTR_P0_02), MP_ROM_PTR(&pin_P0_02) }, 7 | 8 | { MP_ROM_QSTR(MP_QSTR_P0_03), MP_ROM_PTR(&pin_P0_03) }, 9 | { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_P0_03) }, 10 | 11 | { MP_ROM_QSTR(MP_QSTR_P0_04), MP_ROM_PTR(&pin_P0_04) }, 12 | { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_P0_04) }, 13 | 14 | { MP_ROM_QSTR(MP_QSTR_P0_05), MP_ROM_PTR(&pin_P0_05) }, 15 | { MP_ROM_QSTR(MP_QSTR_P0_06), MP_ROM_PTR(&pin_P0_06) }, 16 | { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_P0_06) }, 17 | 18 | { MP_ROM_QSTR(MP_QSTR_P0_07), MP_ROM_PTR(&pin_P0_07) }, 19 | { MP_ROM_QSTR(MP_QSTR_P0_08), MP_ROM_PTR(&pin_P0_08) }, 20 | { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_P0_08) }, 21 | 22 | { MP_ROM_QSTR(MP_QSTR_P0_09), MP_ROM_PTR(&pin_P0_09) }, 23 | { MP_ROM_QSTR(MP_QSTR_P0_10), MP_ROM_PTR(&pin_P0_10) }, 24 | 25 | { MP_ROM_QSTR(MP_QSTR_P0_11), MP_ROM_PTR(&pin_P0_11) }, 26 | { MP_ROM_QSTR(MP_QSTR_BUTTON2), MP_ROM_PTR(&pin_P0_11) }, 27 | 28 | { MP_ROM_QSTR(MP_QSTR_P0_12), MP_ROM_PTR(&pin_P0_12) }, 29 | 30 | { MP_ROM_QSTR(MP_QSTR_P0_13), MP_ROM_PTR(&pin_P0_13) }, 31 | // { MP_ROM_QSTR(MP_QSTR_LED1), MP_ROM_PTR(&pin_P0_13) }, 32 | 33 | { MP_ROM_QSTR(MP_QSTR_P0_14), MP_ROM_PTR(&pin_P0_14) }, 34 | { MP_ROM_QSTR(MP_QSTR_LED3), MP_ROM_PTR(&pin_P0_14) }, 35 | 36 | { MP_ROM_QSTR(MP_QSTR_P0_15), MP_ROM_PTR(&pin_P0_15) }, 37 | // { MP_ROM_QSTR(MP_QSTR_LED2), MP_ROM_PTR(&pin_P0_15) }, 38 | 39 | { MP_ROM_QSTR(MP_QSTR_P0_16), MP_ROM_PTR(&pin_P0_16) }, 40 | { MP_ROM_QSTR(MP_QSTR_P0_17), MP_ROM_PTR(&pin_P0_17) }, 41 | 42 | // RESET { MP_ROM_QSTR(MP_QSTR_P0_18), MP_ROM_PTR(&pin_P0_18) }, 43 | 44 | { MP_ROM_QSTR(MP_QSTR_P0_19), MP_ROM_PTR(&pin_P0_19) }, 45 | { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_P0_19) }, 46 | 47 | { MP_ROM_QSTR(MP_QSTR_P0_20), MP_ROM_PTR(&pin_P0_20) }, 48 | { MP_ROM_QSTR(MP_QSTR_P0_21), MP_ROM_PTR(&pin_P0_21) }, 49 | { MP_ROM_QSTR(MP_QSTR_P0_22), MP_ROM_PTR(&pin_P0_22) }, 50 | { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_P0_22) }, 51 | 52 | { MP_ROM_QSTR(MP_QSTR_P0_23), MP_ROM_PTR(&pin_P0_23) }, 53 | { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_P0_23) }, 54 | 55 | { MP_ROM_QSTR(MP_QSTR_P0_24), MP_ROM_PTR(&pin_P0_24) }, 56 | { MP_ROM_QSTR(MP_QSTR_P0_25), MP_ROM_PTR(&pin_P0_25) }, 57 | { MP_ROM_QSTR(MP_QSTR_P0_26), MP_ROM_PTR(&pin_P0_26) }, 58 | { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_P0_26) }, 59 | 60 | { MP_ROM_QSTR(MP_QSTR_P0_27), MP_ROM_PTR(&pin_P0_27) }, 61 | { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_P0_27) }, 62 | 63 | { MP_ROM_QSTR(MP_QSTR_P0_28), MP_ROM_PTR(&pin_P0_28) }, 64 | { MP_ROM_QSTR(MP_QSTR_P0_29), MP_ROM_PTR(&pin_P0_29) }, 65 | { MP_ROM_QSTR(MP_QSTR_P0_30), MP_ROM_PTR(&pin_P0_30) }, 66 | { MP_ROM_QSTR(MP_QSTR_P0_31), MP_ROM_PTR(&pin_P0_31) }, 67 | { MP_ROM_QSTR(MP_QSTR_P1_00), MP_ROM_PTR(&pin_P1_00) }, 68 | 69 | { MP_ROM_QSTR(MP_QSTR_P1_01), MP_ROM_PTR(&pin_P1_01) }, 70 | { MP_ROM_QSTR(MP_QSTR_LED1), MP_ROM_PTR(&pin_P1_01) }, 71 | 72 | { MP_ROM_QSTR(MP_QSTR_P1_02), MP_ROM_PTR(&pin_P1_02) }, 73 | 74 | { MP_ROM_QSTR(MP_QSTR_P1_03), MP_ROM_PTR(&pin_P1_03) }, 75 | { MP_ROM_QSTR(MP_QSTR_LED2), MP_ROM_PTR(&pin_P1_03) }, 76 | 77 | { MP_ROM_QSTR(MP_QSTR_P1_04), MP_ROM_PTR(&pin_P1_04) }, 78 | { MP_ROM_QSTR(MP_QSTR_P1_05), MP_ROM_PTR(&pin_P1_05) }, 79 | { MP_ROM_QSTR(MP_QSTR_P1_06), MP_ROM_PTR(&pin_P1_06) }, 80 | { MP_ROM_QSTR(MP_QSTR_P1_07), MP_ROM_PTR(&pin_P1_07) }, 81 | { MP_ROM_QSTR(MP_QSTR_P1_08), MP_ROM_PTR(&pin_P1_08) }, 82 | { MP_ROM_QSTR(MP_QSTR_P1_09), MP_ROM_PTR(&pin_P1_09) }, 83 | { MP_ROM_QSTR(MP_QSTR_P1_10), MP_ROM_PTR(&pin_P1_10) }, 84 | { MP_ROM_QSTR(MP_QSTR_BUTTON1), MP_ROM_PTR(&pin_P1_10) }, 85 | 86 | { MP_ROM_QSTR(MP_QSTR_P1_11), MP_ROM_PTR(&pin_P1_11) }, 87 | { MP_ROM_QSTR(MP_QSTR_P1_12), MP_ROM_PTR(&pin_P1_12) }, 88 | { MP_ROM_QSTR(MP_QSTR_P1_13), MP_ROM_PTR(&pin_P1_13) }, 89 | { MP_ROM_QSTR(MP_QSTR_P1_14), MP_ROM_PTR(&pin_P1_14) }, 90 | { MP_ROM_QSTR(MP_QSTR_P1_15), MP_ROM_PTR(&pin_P1_15) }, 91 | 92 | { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, 93 | }; 94 | 95 | MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); -------------------------------------------------------------------------------- /target/nrf/boards/LILYGO_T-Echo-micropython/board.json: -------------------------------------------------------------------------------- 1 | { 2 | "deploy": [ 3 | "../deploy.md" 4 | ], 5 | "docs": "", 6 | "features": [], 7 | "images": [ 8 | "pca10059.jpg" 9 | ], 10 | "mcu": "nrf52", 11 | "product": "pca10059", 12 | "thumbnail": "", 13 | "url": "https://www.nordicsemi.com/Products/Development-hardware/nRF52840-Dongle", 14 | "vendor": "Nordic Semiconductor" 15 | } 16 | -------------------------------------------------------------------------------- /target/nrf/boards/LILYGO_T-Echo-micropython/modules/boardmodules.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the MicroPython project, http://micropython.org/ 3 | * 4 | * The MIT License (MIT) 5 | * 6 | * Copyright (c) 2019 Glenn Ruben Bakke 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | #ifndef MICROPY_INCLUDED_NRF_BOARD_PCA10059_BOARD_MODULES_H 28 | #define MICROPY_INCLUDED_NRF_BOARD_PCA10059_BOARD_MODULES_H 29 | 30 | #define BOARD_MODULES 31 | 32 | void board_modules_init0(void); 33 | 34 | #endif // MICROPY_INCLUDED_NRF_BOARD_PCA10059_BOARD_MODULES_H 35 | -------------------------------------------------------------------------------- /target/nrf/boards/LILYGO_T-Echo-micropython/modules/boardmodules.mk: -------------------------------------------------------------------------------- 1 | BOARD_PCA10059_DIR = $(BOARD_DIR)/modules 2 | 3 | INC += -I$(BOARD_PCA10059_DIR) 4 | CFLAGS += -DBOARD_SPECIFIC_MODULES 5 | 6 | SRC_BOARD_MODULES = $(addprefix $(BOARD_PCA10059_DIR)/,\ 7 | recover_uicr_regout0.c \ 8 | ) 9 | 10 | # OBJ += $(addprefix $(BUILD)/, $(SRC_BOARD_MODULES:.c=.o)) 11 | OBJ += $(addprefix $(BUILD)/, boards/$(BOARD)/modules/$(notdir $(SRC_BOARD_MODULES:.c=.o))) 12 | 13 | -------------------------------------------------------------------------------- /target/nrf/boards/LILYGO_T-Echo-micropython/modules/recover_uicr_regout0.c: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the MicroPython project, http://micropython.org/ 3 | * 4 | * The MIT License (MIT) 5 | * 6 | * Copyright (c) 2019 Glenn Ruben Bakke 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | #include 28 | 29 | #include "nrf.h" 30 | #include "nrf52840_bitfields.h" 31 | 32 | bool uicr_REGOUT0_erased() { 33 | if (NRF_UICR->REGOUT0 == 0xFFFFFFFFUL) { 34 | return true; 35 | } 36 | return false; 37 | } 38 | 39 | void board_modules_init0(void) 40 | { 41 | if (uicr_REGOUT0_erased()) { 42 | 43 | // Wait for pending NVMC operations to finish. 44 | while (NRF_NVMC->READY != NVMC_READY_READY_Ready); 45 | 46 | // Enable write mode in NVMC. 47 | NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Wen; 48 | while (NRF_NVMC->READY != NVMC_READY_READY_Ready); 49 | 50 | // Write 3v3 value to UICR->REGOUT0. 51 | NRF_UICR->REGOUT0 = (UICR_REGOUT0_VOUT_3V3 & UICR_REGOUT0_VOUT_Msk) << UICR_REGOUT0_VOUT_Pos; 52 | while (NRF_NVMC->READY != NVMC_READY_READY_Ready); 53 | 54 | // Enable read mode in NVMC. 55 | NRF_NVMC->CONFIG = NVMC_CONFIG_WEN_Ren; 56 | while (NRF_NVMC->READY != NVMC_READY_READY_Ready); 57 | 58 | // Reset to apply the update. 59 | NVIC_SystemReset(); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /target/nrf/boards/LILYGO_T-Echo-micropython/mpconfigboard.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the MicroPython project, http://micropython.org/ 3 | * 4 | * The MIT License (MIT) 5 | * 6 | * Copyright (c) 2019 Glenn Ruben Bakke 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining a copy 9 | * of this software and associated documentation files (the "Software"), to deal 10 | * in the Software without restriction, including without limitation the rights 11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | * copies of the Software, and to permit persons to whom the Software is 13 | * furnished to do so, subject to the following conditions: 14 | * 15 | * The above copyright notice and this permission notice shall be included in 16 | * all copies or substantial portions of the Software. 17 | * 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | * THE SOFTWARE. 25 | */ 26 | 27 | #define MICROPY_HW_BOARD_NAME "T-Echo" 28 | #define MICROPY_HW_MCU_NAME "NRF52840" 29 | #define MICROPY_PY_SYS_PLATFORM "nrf52840" 30 | 31 | #define MICROPY_PY_MACHINE_UART (1) 32 | #define MICROPY_PY_MACHINE_HW_PWM (1) 33 | #define MICROPY_PY_MACHINE_HW_SPI (1) 34 | #define MICROPY_PY_MACHINE_TIMER (1) 35 | #define MICROPY_PY_MACHINE_RTCOUNTER (1) 36 | #define MICROPY_PY_MACHINE_I2C (1) 37 | #define MICROPY_PY_MACHINE_ADC (1) 38 | #define MICROPY_PY_MACHINE_TEMP (1) 39 | 40 | // #define BLUETOOTH_SD (140) 41 | 42 | // Python standard libraries and micro-libraries 43 | #define MICROPY_PY_UASYNCIO (1) 44 | 45 | // #define MICROPY_PY_IO (1) 46 | // #define MICROPY_PY_IO_IOBASE (1) 47 | // #define MICROPY_PY_IO_FILEIO (1) 48 | // #define MICROPY_PY_IO_BYTESIO (1) 49 | // #define MICROPY_PY_IO_BUFFEREDWRITER (1) 50 | 51 | #define MICROPY_HW_ENABLE_RNG (1) 52 | 53 | #define MICROPY_HW_USB_CDC (1) 54 | 55 | #define MICROPY_HW_HAS_LED (1) 56 | #define MICROPY_HW_LED_COUNT (4) 57 | #define MICROPY_HW_LED_PULLUP (1) 58 | 59 | #define MICROPY_HW_LED1 (6) // LED1 GREEN 60 | #define MICROPY_HW_LED2 (8) // LED2 RED (RGB) 61 | #define MICROPY_HW_LED3 (41) // LED2 GREEN (RGB) 62 | #define MICROPY_HW_LED4 (12) // LED2 BLUE (RGB) 63 | 64 | // UART config 65 | #define MICROPY_HW_UART1_RX (13) 66 | #define MICROPY_HW_UART1_TX (15) 67 | #define MICROPY_HW_UART1_CTS (17) 68 | #define MICROPY_HW_UART1_RTS (20) 69 | #define MICROPY_HW_UART1_HWFC (1) 70 | 71 | // SPI0 config 72 | #define MICROPY_HW_SPI0_NAME "SPI0" 73 | 74 | #define MICROPY_HW_SPI0_SCK (22) 75 | #define MICROPY_HW_SPI0_MOSI (32) 76 | #define MICROPY_HW_SPI0_MISO (24) 77 | 78 | #define MICROPY_HW_PWM0_NAME "PWM0" 79 | #define MICROPY_HW_PWM1_NAME "PWM1" 80 | #define MICROPY_HW_PWM2_NAME "PWM2" 81 | #if 0 82 | #define MICROPY_HW_PWM3_NAME "PWM3" 83 | #endif 84 | 85 | #define HELP_TEXT_BOARD_LED "1,2,3,4" 86 | -------------------------------------------------------------------------------- /target/nrf/boards/LILYGO_T-Echo-micropython/mpconfigboard.mk: -------------------------------------------------------------------------------- 1 | MCU_SERIES = m4 2 | MCU_VARIANT = nrf52 3 | MCU_SUB_VARIANT = nrf52840 4 | SOFTDEV_VERSION = 6.1.1 5 | 6 | DFU ?= 1 7 | 8 | ifeq ($(DFU),1) 9 | BOOTLOADER=open_bootloader 10 | BOOTLOADER_VERSION_MAJOR=1 11 | BOOTLOADER_VERSION_MINOR=2 12 | FLASHER=nrfutil 13 | else 14 | FLASHER=segger 15 | endif 16 | 17 | LD_FILES += boards/nrf52840_1M_256k.ld 18 | 19 | NRF_DEFINES += -DNRF52840_XXAA 20 | 21 | MICROPY_VFS_LFS2 = 1 22 | -------------------------------------------------------------------------------- /target/nrf/boards/LILYGO_T-Echo-micropython/pins.csv: -------------------------------------------------------------------------------- 1 | P2,P2,ADC0_IN0 2 | P4,P4,ADC0_IN2 3 | LED1_GREEN,P6 4 | LED2_RED,P8 5 | P9,P9 6 | P10,P10 7 | P11,P11 8 | LED2_BLUE,P12 9 | UART1_RX,P13 10 | P14,P14 11 | UART1_TX,P15 12 | P16,P16 13 | UART1_CTS,P17 14 | SWITCH2_NRESET,P18 15 | UART1_RTS,P20 16 | SPI0_SCK,P22,P22 17 | SPI0_MISO,P24 18 | P26,P26 19 | P29,P29,ADC0_IN5 20 | P31,P31,ADC0_IN7 21 | SPI0_MOSI,P32 22 | P33,P33 23 | P34,P34 24 | P36,P36 25 | SWITCH1,P38,P38 26 | P39,P39 27 | LED2_GREEN,P41 28 | P42,P42 29 | P43,P43 30 | P45,P45 31 | P47,P47 32 | -------------------------------------------------------------------------------- /target/nrf/nrf.mk: -------------------------------------------------------------------------------- 1 | 2 | include $(INCLUDE_DIR)/download.mk 3 | include $(INCLUDE_DIR)/package.mk 4 | 5 | define nrf/info 6 | PKG_NAME:= 7 | PKG_SOURCE_URL:= 8 | PKG_SOURCE_PROTO:= 9 | PKG_SOURCE_VERSION:= 10 | PKG_SOURCE_MD5:= 11 | endef 12 | 13 | 14 | define nrf/prereq 15 | # sudo apt install gcc-arm-none-eabi libnewlib-arm-none-eabi build-essential 16 | @echo "Please pre-install gcc-arm-none-eabi libnewlib-arm-none-eabi build-essential" 17 | @cp $(TOP_DIR)/target/$(TARGET)/boards/$(BOARD)-$(MICROPYTHON_CORE) $(TARGET_BUILD_DIR)/$(MICROPYTHON_CORE)/ports/nrf/boards/ -rf 18 | #@mv $(TARGET_BUILD_DIR)/$(MICROPYTHON_CORE)/ports/nrf/boards/$(BOARD)-$(MICROPYTHON_CORE) $(TARGET_BUILD_DIR)/$(MICROPYTHON_CORE)/ports/nrf/boards/$(BOARD) 19 | @if [ $(MICROPYTHON_CORE) = circuitpython ]; then \ 20 | cd $(TARGET_BUILD_DIR)/$(MICROPYTHON_CORE) && make fetch-submodules && pip3 install -r requirements-dev.txt ; \ 21 | fi 22 | endef 23 | 24 | 25 | define nrf/compile 26 | make -C $(TARGET_BUILD_DIR)/$(MICROPYTHON_CORE)/mpy-cross 27 | cd $(TARGET_BUILD_DIR)/$(MICROPYTHON_CORE)/ports/nrf && \ 28 | make BOARD=$(BOARD)-$(MICROPYTHON_CORE) \ 29 | BUILD=$(TARGET_BUILD_DIR)/$(BOARD)-$(MICROPYTHON_CORE) \ 30 | USER_C_MODULES=$(TOP_DIR)/extmod/micropython.cmake \ 31 | EXTMOD_FROZEN_DIR=$(TOP_DIR)/extmod SD=s140 32 | endef 33 | 34 | 35 | define nrf/install 36 | @echo "Installing firmware to $(BIN_DIR)/nrf/$(BOARD)" 37 | @[ -d $(BIN_DIR) ] && mkdir -p $(BIN_DIR)/nrf/$(BOARD) 38 | @img_name=LilyGo-MicroPython_$(TARGET)_$(BOARD) && \ 39 | cd $(TARGET_BUILD_DIR)/$(MICROPYTHON_CORE) && \ 40 | micropython_version=`git show -s --pretty=format:%h` && \ 41 | if [ $(MICROPYTHON_CORE) = circuitpython ]; then \ 42 | img_name=CPY-$${micropython_version} ; \ 43 | fi && \ 44 | if [ $(MICROPYTHON_CORE) = micropython ]; then \ 45 | img_name=$${img_name}_MPY-$${micropython_version} ; \ 46 | fi && \ 47 | time=`date +"%Y%m%d"` && \ 48 | img_name=$${img_name}_B$${time} && \ 49 | md5=`md5sum $(TARGET_BUILD_DIR)/$(BOARD)-$(MICROPYTHON_CORE)/firmware.bin | awk '{print $$1}'` && \ 50 | img_name=$${img_name}_$${md5:0:10} && \ 51 | if [ $(MICROPYTHON_CORE) = circuitpython ]; then \ 52 | cp $(TARGET_BUILD_DIR)/$(BOARD)-$(MICROPYTHON_CORE)/firmware.uf2 $(BIN_DIR)/nrf/$(BOARD)/$${img_name}.uf2 ; \ 53 | fi && \ 54 | cp $(TARGET_BUILD_DIR)/$(BOARD)-$(MICROPYTHON_CORE)/firmware.hex $(BIN_DIR)/nrf/$(BOARD)/$${img_name}.hex && \ 55 | cp $(TARGET_BUILD_DIR)/$(BOARD)-$(MICROPYTHON_CORE)/firmware.bin $(BIN_DIR)/nrf/$(BOARD)/$${img_name}.bin 56 | endef 57 | -------------------------------------------------------------------------------- /target/rp2/boards/LILYGO_T_PicoC3/board.json: -------------------------------------------------------------------------------- 1 | { 2 | "deploy": [ 3 | "../deploy.md" 4 | ], 5 | "docs": "", 6 | "features": [ 7 | "WiFi ESP32-C3", 8 | "Bluetooth ESP32-C3", 9 | "LCD ST7789", 10 | "SPI Flash 4MB", 11 | "Battery", 12 | "USB TYPE-C" 13 | ], 14 | "id": "rp2-pico", 15 | "images": [ 16 | "rp2-pico.jpg" 17 | ], 18 | "mcu": "rp2040", 19 | "product": "Pico", 20 | "thumbnail": "", 21 | "url": "https://pt.aliexpress.com/item/3256803977826910.html", 22 | "vendor": "Raspberry Pi" 23 | } 24 | -------------------------------------------------------------------------------- /target/rp2/boards/LILYGO_T_PicoC3/mpconfigboard.cmake: -------------------------------------------------------------------------------- 1 | # cmake file for Raspberry Pi Pico 2 | set(EXTMOD_ST7789 1) -------------------------------------------------------------------------------- /target/rp2/boards/LILYGO_T_PicoC3/mpconfigboard.h: -------------------------------------------------------------------------------- 1 | // Board and hardware specific configuration 2 | #define MICROPY_HW_BOARD_NAME "T-PicoC3" 3 | #define MICROPY_HW_FLASH_STORAGE_BYTES (1408 * 1024) 4 | -------------------------------------------------------------------------------- /target/rp2/rp2.mk: -------------------------------------------------------------------------------- 1 | 2 | include $(INCLUDE_DIR)/download.mk 3 | include $(INCLUDE_DIR)/package.mk 4 | 5 | define rp2/info 6 | PKG_NAME:= 7 | PKG_SOURCE_URL:= 8 | PKG_SOURCE_PROTO:= 9 | PKG_SOURCE_VERSION:= 10 | PKG_SOURCE_MD5:= 11 | endef 12 | 13 | # $(call DownloadMethod/git,$(PKG_NAME),$(PKG_SOURCE_URL),$(PKG_SOURCE_VERSION)) ; 14 | define rp2/prereq 15 | # sudo apt install gcc-arm-none-eabi libnewlib-arm-none-eabi build-essential 16 | @echo "Please pre-install gcc-arm-none-eabi libnewlib-arm-none-eabi build-essential" 17 | endef 18 | 19 | ## 20 | ## $(1) MODULES 21 | ## 22 | define rp2/compile 23 | make -C $(TARGET_BUILD_DIR)/micropython/mpy-cross && \ 24 | cd $(TARGET_BUILD_DIR)/micropython/ports/rp2 && \ 25 | make MICROPY_BOARD_DIR=$(TOP_DIR)/target/$(TARGET)/boards/$(BOARD) \ 26 | BOARD=$(BOARD) \ 27 | BUILD=$(TARGET_BUILD_DIR)/build-$(BOARD) \ 28 | USER_C_MODULES=$(TOP_DIR)/extmod/micropython.cmake \ 29 | EXTMOD_FROZEN_DIR=$(TOP_DIR)/extmod && \ 30 | cd - 31 | endef 32 | 33 | 34 | define rp2/install 35 | [ -d $(BIN_DIR) ] && mkdir -p $(BIN_DIR)/rp2/$(BOARD) 36 | img_name=LilyGo-MicroPython_$(TARGET)_$(BOARD) && \ 37 | cd $(TARGET_BUILD_DIR)/micropython && \ 38 | micropython_version=`git show -s --pretty=format:%h` && \ 39 | img_name=$${img_name}_MPY-$${micropython_version} && \ 40 | time=`date +"%Y%m%d"` && \ 41 | img_name=$${img_name}_B$${time} && \ 42 | md5=`md5sum $(TARGET_BUILD_DIR)/build-$(BOARD)/firmware.bin | awk '{print $$1}'` && \ 43 | img_name=$${img_name}_$${md5:0:10} && \ 44 | cp $(TARGET_BUILD_DIR)/build-$(BOARD)/firmware.uf2 $(BIN_DIR)/rp2/$(BOARD)/$${img_name}.uf2 45 | endef 46 | --------------------------------------------------------------------------------