Merge remote-tracking branch 'm5stack/master' into micropython

This commit is contained in:
sakabin
2019-05-29 16:08:04 +08:00
2 changed files with 54 additions and 0 deletions
+2
View File
@@ -317,6 +317,8 @@ If *debug=True* the information about compiled font will be printed.
You can create the **c** source file from any **tft** font using the included [ttf2c_vc2003.exe](https://github.com/loboris/MicroPython_ESP32_psRAM_LoBo/tree/master/MicroPython_BUILD/components/micropython/esp32/modules_examples/tft/font_tool/) program.
See [README](https://github.com/loboris/MicroPython_ESP32_psRAM_LoBo/tree/master/MicroPython_BUILD/components/micropython/esp32/modules_examples/tft/font_tool/README.md) for instructions.
You can create **c** source file or **.fon** file from **tft** font using [online converter](https://loboris.eu/ttf2fon/).
## **Button**
---
+52
View File
@@ -0,0 +1,52 @@
#!/usr/bin/env python
# -*- Coding: utf-8 -*-
from __future__ import print_function
import os, sys
import json
import subprocess
port = '/dev/cu.SLAB_USBtoUART'
baud = 921600
PYTHON_VERSION = os.sys.version_info[0]
# ----- read firmware.json -----
working_dir = os.getcwd()
sub_dir = 'firmwares'
json_file = os.path.join(working_dir,sub_dir,'firmware.json')
with open(json_file, 'r') as f:
fw_list = json.loads(f.read())
# ----- select firmware to write -----
fw_names = [x['name'] for x in fw_list]
for i,x in enumerate(fw_names):
print(i, x)
try:
num = int(input('Select No = '))
if not ( 0 <= num < len(fw_list) ):
print('Error !')
exit()
except ValueError:
print('Error !')
exit()
path = os.path.join(working_dir, sub_dir, fw_list[num]['path'])
table = {'%port':port, '%baud':str(baud), '%PATH':path, '\\':'/'}
cmds = ['./tools/esptool.py --chip esp32 --port %port --baud %baud erase_flash']
cmds += ['./tools/esptool.py ' + x for x in fw_list[num]['commands']]
cmd = '\n'.join(cmds)
for k,v in table.items():
cmd = cmd.replace(k,v)
# ----- write firmware -----
if PYTHON_VERSION == 3:
q = input('Write firmware: {0} (y/n) '.format(fw_list[num]['name'])).lower()
elif PYTHON_VERSION == 2:
q = raw_input('Write firmware: {0} (y/n) '.format(fw_list[num]['name'])).lower()
cmd = cmd.encode('ascii').replace('\\','/')
cmds = cmd.split('\n')
if q == 'y':
for cmd in cmds:
subprocess.call(cmd.split())
exit()