Skip to content

Commit

Permalink
All the updates
Browse files Browse the repository at this point in the history
  • Loading branch information
SilverLogix committed Sep 28, 2024
1 parent 8b97e19 commit 3ca45ba
Show file tree
Hide file tree
Showing 14 changed files with 874 additions and 1,101 deletions.
674 changes: 0 additions & 674 deletions LICENSE

This file was deleted.

17 changes: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
![CI badge](https://img.shields.io/badge/%E2%80%8E-micropython-green?style=flat-square&logo=micropython)
![CI badge](https://img.shields.io/github/languages/code-size/silverlogix/ESP32-Web-System?style=flat-square)
![CI badge](https://img.shields.io/tokei/lines/github/silverlogix/ESP32-Web-System?style=flat-square)
![CI badge](https://img.shields.io/badge/%E2%80%8E-micropython-success?style=flat-square&logo=micropython)
![CI badge](https://img.shields.io/github/languages/code-size/silverlogix/MicroPython-TTGO?style=flat-square)
![CI badge](https://img.shields.io/tokei/lines/github/silverlogix/MicroPython-TTGO?style=flat-square)

<h3> </h3>

MicroPython for bare ESP32 IOT Web System
MicroPython for the LilyGo TTGO
=======================
<h2>w/ FTP updates</h2>
<h2>w/ ST7789 C driver</h2>
<p align="center">
<img src='image/wroom.png/'>
<img src='image/TTGO.png/'>
</p>
<h3> </h3>
<h3>
<A HREF="https://github.com/SilverLogix/MicroPython-TTGO/releases/tag/v1.1.1">Latest Update</a>
</h3>
57 changes: 0 additions & 57 deletions board.py

This file was deleted.

19 changes: 11 additions & 8 deletions boot.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import micropython

import machine
# noinspection PyUnresolvedReferences
from machine import Pin
import debug
import gfx


machine.freq(80_000000) # 240_

gfx.init()
gfx.boot(gfx.RED)

# noinspection PyArgumentList
machine.freq(240000000)
micropython.alloc_emergency_exception_buf(100)
debug.bug_boot()

print(str('Booting...'))
btn = Pin(35, Pin.IN) # Gpio 35 as button
del debug
133 changes: 67 additions & 66 deletions debug.py
Original file line number Diff line number Diff line change
@@ -1,86 +1,87 @@
import micropython

def space_free(): # Display remaining free space
from os import statvfs

bits = statvfs('/flash')
# print(str(bits))
blksize = bits[0] # 4096
blkfree = bits[3] # 12
freesize = blksize * blkfree # 49152
mbcalc = 1024 * 1024 # 1048576
mbfree = freesize / mbcalc # 0.046875
print("Free space:" + str(mbfree))


def m_freq(): # Get current machine Freq
import machine

gfr = str(machine.freq())

print("Mhz: " + gfr)

return gfr


def raw_temp(): # Get current CPU temp
import esp32

raw = str(esp32.raw_temperature())
rtemp = ("CPU Temp: " + raw + "F")
print(rtemp)
rrr = rtemp
return rrr


def showVoltage(): # Show current(pun intended) used Voltage
# noinspection PyUnresolvedReferences
from machine import ADC, Pin

adc = ADC(Pin(32))

vref = int(1100)

v = adc.read()
battery_voltage = (float(v) / 4095.0) * 2.0 * 3.3 * (vref / 1000.0)
voltage = ("Voltage: {0:0.2f}v".format(battery_voltage))
print(voltage)

ddd = voltage
return ddd


def getmac(): # Get and display chip MAC address
def bug_boot():
import network
import ubinascii
mac = ubinascii.hexlify(network.WLAN(1).config('mac'), ':').decode()
print(str(mac))


def pprint(): # Put it all together and PRINT
import machine
from os import statvfs
import os
import gc
import time

bits = statvfs('/flash')
mbfree = bits[0] * bits[3] / (1024 * 1024)
mac = ubinascii.hexlify(network.WLAN(1).config('mac'), ':').decode()
dirr = str(os.listdir())
time.sleep_ms(100)

print("")
print(f"MAC: {mac}")
print(f"Mhz: {machine.freq() / 1e6:.0f}")
print(f"Flash: {mbfree:.2f} MB")
print("")
print("-------------------")
getmac()
space_free()
m_freq()
raw_temp()
showVoltage()
print("--------------------")
print(f"Files: {dirr}")
print("")

del statvfs, network, ubinascii, machine, os
gc.collect()


'''
N = 200_000
def time_it(f, n):
import utime
t0 = utime.ticks_us()
f(n)
t1 = utime.ticks_us()
dt = utime.ticks_diff(t1, t0)
fmt = '{:5.3f} sec, {:6.3f} usec/read : {:8.2f} kreads/sec'
print(fmt.format(dt * 1e-6, dt / n, n / dt * 1e3))

time_it(showVoltage, N)
'''
# time_it(showVoltage, N)


def serial_mem(mp: bool):
import micropython

micropython.mem_info(mp)
del micropython


@micropython.native
def crash_esp32():
import machine
"""
Crash the ESP32 by writing to an invalid memory address.
This will trigger a panic and reset the device.
"""
# Define an invalid memory address (aligned to 4 bytes)
address = 0x00000000 # Using address 0, which is typically unmapped

try:
# Attempt to read from the invalid address
machine.mem32[address]
except Exception as e:
print(f"Crash attempt triggered an exception: {e}")
print("ESP32 should reset now.")


def inf_recurs(depth=0):
import utime
"""Crash by stack overflow due to infinite recursion."""
print(f"Recursion depth: {depth}")
utime.sleep_ms(1) # Small delay to allow for print
return inf_recurs(depth + 1)


def watchout():
"""Crash by triggering the watchdog timer."""
# Disable the software WDT if it's running
try:
import machine
machine.WDT(timeout=1000) # 1 second timeout
except:
pass # Hardware WDT might still be active

print("Waiting for watchdog timer...")
while True:
pass # Busy loop to prevent feeding the watchdog
269 changes: 263 additions & 6 deletions font.py

Large diffs are not rendered by default.

Loading

0 comments on commit 3ca45ba

Please sign in to comment.