-
Notifications
You must be signed in to change notification settings - Fork 2
/
terminal.py
72 lines (51 loc) · 1.61 KB
/
terminal.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# This file is part of the octopusLAB project
# The MIT License (MIT)
# Copyright (c) 2016-2020 Jan Copak, Petr Kracik, Vasek Chalupnicek
# from shell.terminal import printTitle
SEPARATOR_WIDTH = 50
def terminal_color(txt,col=33): # default yellow
# 30 black / 31 red / 32 green / 33 yellow / 34 blue / 35 violet / 36 cyan
# 21 underline
# print("\033[32mgreen\033[m")
return "\033[" + str(col) + "m" + str(txt) + "\033[m"
def runningEffect(num = 16):
from time import sleep_ms
for ii in range(num):
print(".",end="")
sleep_ms(20)
print()
def printBar(num1,num2,char="|",col1=32,col2=33):
print("[",end="")
print((("\033[" + str(col1) + "m" + str(char) + "\033[m")*num1),end="")
print((("\033[" + str(col2) + "m" + str(char) + "\033[m")*num2),end="")
print("] ",end="")
# ---------------
def printHead(s):
print()
print('-' * SEPARATOR_WIDTH)
print("[--- " + s + " ---] ")
def printTitle(t,w=SEPARATOR_WIDTH):
print()
print('=' * w)
print("|",end="")
print(t.center(w-2),end="")
print("|")
print('=' * w)
def printLog(i,s=""):
print()
print('-' * SEPARATOR_WIDTH)
print("[--- " + str(i) + " ---] " + s)
def getUid(short = False): # full or short (5 chars: first 2 + last 3)
import machine, ubinascii
id = ubinascii.hexlify(machine.unique_id()).decode()
if short:
return id[:2]+id[-3:]
else:
return id
def printInfo():
import gc #mem_free
print("> mem_free: "+str(gc.mem_free()))
df()
def printMachineInfo():
import machine
print("> machine.freq: "+str(machine.freq()))