Skip to content

Commit 3ca45ba

Browse files
committed
All the updates
1 parent 8b97e19 commit 3ca45ba

File tree

14 files changed

+874
-1101
lines changed

14 files changed

+874
-1101
lines changed

LICENSE

Lines changed: 0 additions & 674 deletions
This file was deleted.

README.md

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

5-
<h3> </h3>
6-
7-
MicroPython for bare ESP32 IOT Web System
5+
MicroPython for the LilyGo TTGO
86
=======================
9-
<h2>w/ FTP updates</h2>
7+
<h2>w/ ST7789 C driver</h2>
108
<p align="center">
11-
<img src='image/wroom.png/'>
9+
<img src='image/TTGO.png/'>
1210
</p>
1311
<h3> </h3>
12+
<h3>
13+
<A HREF="https://github.com/SilverLogix/MicroPython-TTGO/releases/tag/v1.1.1">Latest Update</a>
14+
</h3>

board.py

Lines changed: 0 additions & 57 deletions
This file was deleted.

boot.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1-
import micropython
1+
22
import machine
3-
# noinspection PyUnresolvedReferences
4-
from machine import Pin
3+
import debug
4+
import gfx
5+
6+
7+
machine.freq(80_000000) # 240_
8+
9+
gfx.init()
10+
gfx.boot(gfx.RED)
511

6-
# noinspection PyArgumentList
7-
machine.freq(240000000)
8-
micropython.alloc_emergency_exception_buf(100)
12+
debug.bug_boot()
913

10-
print(str('Booting...'))
11-
btn = Pin(35, Pin.IN) # Gpio 35 as button
14+
del debug

debug.py

Lines changed: 67 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,86 +1,87 @@
1+
import micropython
12

2-
def space_free(): # Display remaining free space
3-
from os import statvfs
4-
5-
bits = statvfs('/flash')
6-
# print(str(bits))
7-
blksize = bits[0] # 4096
8-
blkfree = bits[3] # 12
9-
freesize = blksize * blkfree # 49152
10-
mbcalc = 1024 * 1024 # 1048576
11-
mbfree = freesize / mbcalc # 0.046875
12-
print("Free space:" + str(mbfree))
13-
14-
15-
def m_freq(): # Get current machine Freq
16-
import machine
17-
18-
gfr = str(machine.freq())
19-
20-
print("Mhz: " + gfr)
21-
22-
return gfr
23-
24-
25-
def raw_temp(): # Get current CPU temp
26-
import esp32
27-
28-
raw = str(esp32.raw_temperature())
29-
rtemp = ("CPU Temp: " + raw + "F")
30-
print(rtemp)
31-
rrr = rtemp
32-
return rrr
33-
34-
35-
def showVoltage(): # Show current(pun intended) used Voltage
36-
# noinspection PyUnresolvedReferences
37-
from machine import ADC, Pin
38-
39-
adc = ADC(Pin(32))
40-
41-
vref = int(1100)
42-
43-
v = adc.read()
44-
battery_voltage = (float(v) / 4095.0) * 2.0 * 3.3 * (vref / 1000.0)
45-
voltage = ("Voltage: {0:0.2f}v".format(battery_voltage))
46-
print(voltage)
473

48-
ddd = voltage
49-
return ddd
50-
51-
52-
def getmac(): # Get and display chip MAC address
4+
def bug_boot():
535
import network
546
import ubinascii
55-
mac = ubinascii.hexlify(network.WLAN(1).config('mac'), ':').decode()
56-
print(str(mac))
57-
58-
59-
def pprint(): # Put it all together and PRINT
7+
import machine
8+
from os import statvfs
9+
import os
6010
import gc
11+
import time
6112

13+
bits = statvfs('/flash')
14+
mbfree = bits[0] * bits[3] / (1024 * 1024)
15+
mac = ubinascii.hexlify(network.WLAN(1).config('mac'), ':').decode()
16+
dirr = str(os.listdir())
17+
time.sleep_ms(100)
18+
19+
print("")
20+
print(f"MAC: {mac}")
21+
print(f"Mhz: {machine.freq() / 1e6:.0f}")
22+
print(f"Flash: {mbfree:.2f} MB")
6223
print("")
63-
print("-------------------")
64-
getmac()
65-
space_free()
66-
m_freq()
67-
raw_temp()
68-
showVoltage()
69-
print("--------------------")
24+
print(f"Files: {dirr}")
7025
print("")
7126

27+
del statvfs, network, ubinascii, machine, os
7228
gc.collect()
7329

7430

75-
'''
76-
N = 200_000
7731
def time_it(f, n):
32+
import utime
7833
t0 = utime.ticks_us()
7934
f(n)
8035
t1 = utime.ticks_us()
8136
dt = utime.ticks_diff(t1, t0)
8237
fmt = '{:5.3f} sec, {:6.3f} usec/read : {:8.2f} kreads/sec'
8338
print(fmt.format(dt * 1e-6, dt / n, n / dt * 1e3))
8439

85-
time_it(showVoltage, N)
86-
'''
40+
# time_it(showVoltage, N)
41+
42+
43+
def serial_mem(mp: bool):
44+
import micropython
45+
46+
micropython.mem_info(mp)
47+
del micropython
48+
49+
50+
@micropython.native
51+
def crash_esp32():
52+
import machine
53+
"""
54+
Crash the ESP32 by writing to an invalid memory address.
55+
This will trigger a panic and reset the device.
56+
"""
57+
# Define an invalid memory address (aligned to 4 bytes)
58+
address = 0x00000000 # Using address 0, which is typically unmapped
59+
60+
try:
61+
# Attempt to read from the invalid address
62+
machine.mem32[address]
63+
except Exception as e:
64+
print(f"Crash attempt triggered an exception: {e}")
65+
print("ESP32 should reset now.")
66+
67+
68+
def inf_recurs(depth=0):
69+
import utime
70+
"""Crash by stack overflow due to infinite recursion."""
71+
print(f"Recursion depth: {depth}")
72+
utime.sleep_ms(1) # Small delay to allow for print
73+
return inf_recurs(depth + 1)
74+
75+
76+
def watchout():
77+
"""Crash by triggering the watchdog timer."""
78+
# Disable the software WDT if it's running
79+
try:
80+
import machine
81+
machine.WDT(timeout=1000) # 1 second timeout
82+
except:
83+
pass # Hardware WDT might still be active
84+
85+
print("Waiting for watchdog timer...")
86+
while True:
87+
pass # Busy loop to prevent feeding the watchdog

font.py

Lines changed: 263 additions & 6 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)