-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathprint.py
More file actions
85 lines (54 loc) · 1.79 KB
/
print.py
File metadata and controls
85 lines (54 loc) · 1.79 KB
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
73
74
75
76
77
78
79
80
81
82
from PiicoDev_SSD1306 import *
from PiicoDev_Unified import sleep_ms
import utime
display = create_PiicoDev_SSD1306()
delay = 3000
# Basic print statements
example_number = 210.2
display.print('Hello world')
display.print()
display.print(example_number) # Emulating printing sensor values
display.print()
display.print("Number: {}".format(example_number))
# Clear screen and internal lists
sleep_ms(delay)
for _ in range(8):
display.print()
# Demonstrate printing text at specific lines (with background boxes)
display.print('Line 2 text',line_num=2)
display.print('Line 4 text',line_num=4)
display.fill_rect(0,40,128,8,1)
display.print('Spooky line', line_num=6,c=0,blanking=False)
display.show()
# Clear screen and internal lists
sleep_ms(delay)
for _ in range(8):
display.print()
display.print('Show overflowing lines')
sleep_ms(int(delay/2))
# Clear screen and internal lists
sleep_ms(delay)
for _ in range(8):
display.print()
# Demonstrating the delimiting text functionality
show_delim = True
show_no_delim = False
if show_delim:
display.print('this string should overflow a couple of times into the next line on the OLED',delim=True) # Default
if show_no_delim:
display.print('this string should overflow a couple of times into the next line on the OLED',delim=False) # Raggedy
# Clear screen and internal lists
sleep_ms(delay)
for _ in range(8):
display.print()
# Running a benchmark for printing lines
display.print('show how fast it takes to print lots of lines')
sleep_ms(int(delay/2))
start = utime.ticks_us()
for i in range(100):
display.print('some text' + str(i))
display.print()
display.print()
outcome_str = str(round(utime.ticks_diff(utime.ticks_us(), start)/(100000000),2)) + ' seconds/print'
display.print(outcome_str)
print(outcome_str)