-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinfo-screen.py
More file actions
990 lines (802 loc) · 37.9 KB
/
info-screen.py
File metadata and controls
990 lines (802 loc) · 37.9 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
import time
import board
import busio
import adafruit_ssd1306
from PIL import Image, ImageDraw, ImageFont
import subprocess
import datetime
import psutil
import signal
import sys
import logging
logging.basicConfig(level=logging.INFO)
# Initialize I2C
i2c = busio.I2C(board.SCL, board.SDA)
# Initialize OLED
oled = adafruit_ssd1306.SSD1306_I2C(128, 32, i2c)
# Reduce brightness by 20%
oled.contrast(int(255 * 0.8)) # 80% of full brightness
# Clear display
oled.fill(0)
oled.show()
# Create blank image for drawing.
image = Image.new("1", (oled.width, oled.height))
# Get drawing object to draw on image.
draw = ImageDraw.Draw(image)
# Load a font.
try:
font = ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf", 8)
except IOError:
font = ImageFont.load_default()
def clear_and_exit(signum, frame):
"""Clear display and exit the program."""
oled.fill(0)
oled.show()
sys.exit(0)
# Register signal handlers for graceful shutdown
signal.signal(signal.SIGTERM, clear_and_exit)
signal.signal(signal.SIGINT, clear_and_exit)
def get_ip_address():
"""Get local IP address."""
cmd = "/usr/bin/hostname -I | /usr/bin/cut -d' ' -f1"
try:
return subprocess.check_output(cmd, shell=True).decode("utf-8").strip()
except subprocess.CalledProcessError as e:
logging.error(f"Failed to get IP address: {e}")
return "No IP"
def get_cpu_temperature():
"""Get CPU temperature."""
cmd = "/usr/bin/cat /sys/class/thermal/thermal_zone0/temp"
try:
temp_str = subprocess.check_output(cmd, shell=True).decode("utf-8")
return f"{float(temp_str) / 1000.0:.1f}°C"
except (subprocess.CalledProcessError, ValueError) as e:
logging.error(f"Failed to get CPU temperature: {e}")
return "N/A"
def get_ram_usage():
"""Get RAM usage percentage."""
ram = psutil.virtual_memory()
return ram.percent
def get_cpu_usage():
"""Get CPU usage percentage."""
return psutil.cpu_percent(interval=None)
def matrix_rain_animation():
"""Cool Matrix-style falling characters animation."""
import random
chars = "01ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
for frame in range(80): # Longer duration
draw.rectangle((0, 0, oled.width, oled.height), outline=0, fill=0)
# Create multiple columns of falling characters
for col in range(0, oled.width, 8):
for row in range(0, oled.height, 8):
if random.random() < 0.3: # 30% chance to show character
char = random.choice(chars)
# Make characters fade by using different positions
y_pos = (row + frame * 2) % (oled.height + 16)
if y_pos < oled.height:
draw.text((col, y_pos), char, font=font, fill=1)
oled.image(image)
oled.show()
time.sleep(0.1)
def bouncing_ball_animation():
"""Fun bouncing ball animation."""
ball_x, ball_y = 10, 10
dx, dy = 2, 1
ball_size = 3
for frame in range(150): # Longer duration
draw.rectangle((0, 0, oled.width, oled.height), outline=0, fill=0)
# Update ball position
ball_x += dx
ball_y += dy
# Bounce off edges
if ball_x <= 0 or ball_x >= oled.width - ball_size:
dx = -dx
if ball_y <= 0 or ball_y >= oled.height - ball_size:
dy = -dy
# Draw ball
draw.ellipse([ball_x, ball_y, ball_x + ball_size, ball_y + ball_size], fill=1)
# Add trail effect
if frame > 5:
trail_x = ball_x - dx * 2
trail_y = ball_y - dy * 2
if 0 <= trail_x < oled.width and 0 <= trail_y < oled.height:
draw.point((trail_x, trail_y), fill=1)
oled.image(image)
oled.show()
time.sleep(0.05)
def sine_wave_animation():
"""Smooth sine wave animation."""
import math
for frame in range(120): # Longer duration
draw.rectangle((0, 0, oled.width, oled.height), outline=0, fill=0)
# Draw sine wave
prev_y = None
for x in range(oled.width):
y = int(oled.height/2 + 10 * math.sin((x + frame * 2) * 0.1))
if prev_y is not None:
draw.line([(x-1, prev_y), (x, y)], fill=1)
prev_y = y
# Add a second wave
prev_y = None
for x in range(oled.width):
y = int(oled.height/2 + 8 * math.sin((x + frame * 3) * 0.15 + math.pi/2))
if prev_y is not None:
draw.line([(x-1, prev_y), (x, y)], fill=1)
prev_y = y
oled.image(image)
oled.show()
time.sleep(0.08)
def starfield_animation():
"""Cool starfield effect like traveling through space."""
import random
stars = []
# Initialize stars
for _ in range(20):
stars.append({
'x': random.randint(0, oled.width),
'y': random.randint(0, oled.height),
'speed': random.uniform(0.5, 2.0)
})
for frame in range(100): # Longer duration
draw.rectangle((0, 0, oled.width, oled.height), outline=0, fill=0)
# Update and draw stars
for star in stars:
# Move star towards viewer
star['x'] = (star['x'] - oled.width/2) * 1.02 + oled.width/2
star['y'] = (star['y'] - oled.height/2) * 1.02 + oled.height/2
# Reset star if it goes off screen
if (star['x'] < 0 or star['x'] > oled.width or
star['y'] < 0 or star['y'] > oled.height):
star['x'] = random.randint(oled.width//3, 2*oled.width//3)
star['y'] = random.randint(oled.height//3, 2*oled.height//3)
# Draw star
if 0 <= star['x'] < oled.width and 0 <= star['y'] < oled.height:
draw.point((int(star['x']), int(star['y'])), fill=1)
oled.image(image)
oled.show()
time.sleep(0.1)
def anime_heart_animation():
"""Cute anime-style floating hearts."""
import random
import math
hearts = []
# Initialize floating hearts
for _ in range(8):
hearts.append({
'x': random.randint(0, oled.width),
'y': random.randint(oled.height, oled.height + 20),
'speed': random.uniform(0.3, 0.8),
'wobble': random.uniform(0, 6.28) # Random phase for wobble
})
for frame in range(120): # Longer duration
draw.rectangle((0, 0, oled.width, oled.height), outline=0, fill=0)
# Update and draw hearts
for heart in hearts:
# Move heart upward with wobble
heart['y'] -= heart['speed']
heart['wobble'] += 0.1
wobble_x = int(2 * math.sin(heart['wobble']))
# Reset heart if it goes off screen
if heart['y'] < -10:
heart['y'] = oled.height + 5
heart['x'] = random.randint(0, oled.width - 8)
# Draw cute heart shape (simplified)
x, y = int(heart['x']) + wobble_x, int(heart['y'])
if 0 <= x < oled.width - 5 and 0 <= y < oled.height - 3:
# Heart shape using pixels
draw.point((x + 1, y), fill=1)
draw.point((x + 3, y), fill=1)
draw.point((x, y + 1), fill=1)
draw.point((x + 2, y + 1), fill=1)
draw.point((x + 4, y + 1), fill=1)
draw.point((x + 1, y + 2), fill=1)
draw.point((x + 3, y + 2), fill=1)
draw.point((x + 2, y + 3), fill=1)
# Add sparkles
if frame % 5 == 0:
for _ in range(3):
sx = random.randint(0, oled.width - 1)
sy = random.randint(0, oled.height - 1)
draw.point((sx, sy), fill=1)
oled.image(image)
oled.show()
time.sleep(0.08)
def kawaii_face_animation():
"""Cute kawaii face animation."""
import math
for frame in range(100): # Longer duration
draw.rectangle((0, 0, oled.width, oled.height), outline=0, fill=0)
center_x, center_y = oled.width // 2, oled.height // 2
# Face outline (circle)
radius = 12
draw.ellipse([center_x - radius, center_y - radius,
center_x + radius, center_y + radius], outline=1)
# Blinking eyes
blink = math.sin(frame * 0.1) > 0.7
if not blink:
# Normal eyes
draw.ellipse([center_x - 6, center_y - 4, center_x - 4, center_y - 2], fill=1)
draw.ellipse([center_x + 4, center_y - 4, center_x + 6, center_y - 2], fill=1)
else:
# Closed eyes (lines)
draw.line([(center_x - 6, center_y - 3), (center_x - 4, center_y - 3)], fill=1)
draw.line([(center_x + 4, center_y - 3), (center_x + 6, center_y - 3)], fill=1)
# Mouth (changes expression)
mouth_type = (frame // 20) % 3
if mouth_type == 0:
# Happy smile
draw.arc([center_x - 4, center_y + 1, center_x + 4, center_y + 6], 0, 180, fill=1)
elif mouth_type == 1:
# Surprised "o"
draw.ellipse([center_x - 2, center_y + 2, center_x + 2, center_y + 5], outline=1)
else:
# Cat mouth "w"
draw.point((center_x - 2, center_y + 3), fill=1)
draw.point((center_x, center_y + 2), fill=1)
draw.point((center_x + 2, center_y + 3), fill=1)
# Blush marks
if frame % 40 < 20:
draw.point((center_x - 9, center_y + 1), fill=1)
draw.point((center_x + 9, center_y + 1), fill=1)
oled.image(image)
oled.show()
time.sleep(0.1)
def neko_ears_animation():
"""Cute cat ears and tail animation."""
import math
for frame in range(90): # Longer duration
draw.rectangle((0, 0, oled.width, oled.height), outline=0, fill=0)
center_x, center_y = oled.width // 2, oled.height // 2
# Cat ears (triangles that twitch)
ear_twitch = int(2 * math.sin(frame * 0.3))
# Left ear
ear1_points = [
(center_x - 8, center_y - 8),
(center_x - 4 + ear_twitch, center_y - 12),
(center_x - 2, center_y - 8)
]
# Right ear
ear2_points = [
(center_x + 2, center_y - 8),
(center_x + 4 - ear_twitch, center_y - 12),
(center_x + 8, center_y - 8)
]
# Draw ears (simple triangles using lines)
for i in range(len(ear1_points)):
start = ear1_points[i]
end = ear1_points[(i + 1) % len(ear1_points)]
draw.line([start, end], fill=1)
for i in range(len(ear2_points)):
start = ear2_points[i]
end = ear2_points[(i + 1) % len(ear2_points)]
draw.line([start, end], fill=1)
# Cat face
draw.ellipse([center_x - 6, center_y - 6, center_x + 6, center_y + 6], outline=1)
# Eyes
draw.point((center_x - 3, center_y - 2), fill=1)
draw.point((center_x + 3, center_y - 2), fill=1)
# Nose
draw.point((center_x, center_y), fill=1)
# Whiskers
draw.line([(center_x - 8, center_y), (center_x - 6, center_y)], fill=1)
draw.line([(center_x + 6, center_y), (center_x + 8, center_y)], fill=1)
# Tail (wagging)
tail_swing = int(5 * math.sin(frame * 0.2))
tail_x = center_x + 10 + tail_swing
draw.line([(center_x + 6, center_y + 4), (tail_x, center_y - 2)], fill=1)
draw.line([(tail_x, center_y - 2), (tail_x + 2, center_y - 5)], fill=1)
oled.image(image)
oled.show()
time.sleep(0.1)
def digital_clock_animation():
"""Analog clock face animation."""
import math
for frame in range(40):
draw.rectangle((0, 0, oled.width, oled.height), outline=0, fill=0)
center_x, center_y = oled.width // 2, oled.height // 2
radius = min(center_x, center_y) - 2
# Draw clock circle
draw.ellipse([center_x - radius, center_y - radius,
center_x + radius, center_y + radius], outline=1)
# Get current time
now = datetime.datetime.now()
# Draw hour hand
hour_angle = math.radians((now.hour % 12) * 30 - 90)
hour_x = center_x + (radius * 0.5) * math.cos(hour_angle)
hour_y = center_y + (radius * 0.5) * math.sin(hour_angle)
draw.line([(center_x, center_y), (hour_x, hour_y)], fill=1)
# Draw minute hand
minute_angle = math.radians(now.minute * 6 - 90)
minute_x = center_x + (radius * 0.8) * math.cos(minute_angle)
minute_y = center_y + (radius * 0.8) * math.sin(minute_angle)
draw.line([(center_x, center_y), (minute_x, minute_y)], fill=1)
# Draw second hand (animated)
second_angle = math.radians((now.second + frame * 0.25) * 6 - 90)
second_x = center_x + (radius * 0.9) * math.cos(second_angle)
second_y = center_y + (radius * 0.9) * math.sin(second_angle)
draw.line([(center_x, center_y), (second_x, second_y)], fill=1)
# Draw center dot
draw.ellipse([center_x - 1, center_y - 1, center_x + 1, center_y + 1], fill=1)
oled.image(image)
oled.show()
time.sleep(0.1)
def progress_bars_animation():
"""Animated progress bars showing system stats."""
for frame in range(50):
draw.rectangle((0, 0, oled.width, oled.height), outline=0, fill=0)
# Get current stats
cpu = get_cpu_usage()
ram = get_ram_usage()
# Animate the bars growing
cpu_width = int((cpu / 100) * (oled.width - 20) * min(frame / 15, 1))
ram_width = int((ram / 100) * (oled.width - 20) * min(frame / 15, 1))
# CPU bar
draw.text((0, 2), "CPU", font=font, fill=1)
draw.rectangle([20, 4, oled.width - 1, 10], outline=1, fill=0)
if cpu_width > 0:
draw.rectangle([20, 4, 20 + cpu_width, 10], fill=1)
draw.text((oled.width - 15, 2), f"{cpu:.0f}%", font=font, fill=1)
# RAM bar
draw.text((0, 14), "RAM", font=font, fill=1)
draw.rectangle([20, 16, oled.width - 1, 22], outline=1, fill=0)
if ram_width > 0:
draw.rectangle([20, 16, 20 + ram_width, 22], fill=1)
draw.text((oled.width - 15, 14), f"{ram:.0f}%", font=font, fill=1)
# Add some sparkle effects when bars are full
if frame > 20:
import random
for _ in range(3):
x = random.randint(0, oled.width - 1)
y = random.randint(24, oled.height - 1)
draw.point((x, y), fill=1)
oled.image(image)
oled.show()
time.sleep(0.1)
def github_signature_animation():
"""Special animation showing GitHub creator credit."""
import math
# GitHub username
github_name = "TheInfamousToTo"
for frame in range(80):
draw.rectangle((0, 0, oled.width, oled.height), outline=0, fill=0)
# Animated border
for i in range(oled.width):
if (i + frame) % 8 < 4:
draw.point((i, 0), fill=1)
draw.point((i, oled.height - 1), fill=1)
for i in range(oled.height):
if (i + frame) % 8 < 4:
draw.point((0, i), fill=1)
draw.point((oled.width - 1, i), fill=1)
# Pulsing effect for the text
if frame < 60:
alpha = abs(math.sin(frame * 0.2))
if alpha > 0.5: # Show text when pulse is strong
# "Created by" text
draw.text((center_x(oled.width, "Created by"), 4), "Created by", font=font, fill=1)
# GitHub name with special effects
name_x = center_x(oled.width, github_name)
draw.text((name_x, 16), github_name, font=font, fill=1)
# Add some stars around the name
star_positions = [
(name_x - 8, 14), (name_x + len(github_name) * 6 + 2, 14),
(name_x - 4, 20), (name_x + len(github_name) * 6 - 2, 20)
]
for star_x, star_y in star_positions:
if 0 <= star_x < oled.width and 0 <= star_y < oled.height:
# Animated star
if (frame + star_x + star_y) % 10 < 5:
draw.point((star_x, star_y), fill=1)
oled.image(image)
oled.show()
time.sleep(0.1)
def center_x(screen_width, text):
"""Helper function to center text horizontally."""
return (screen_width - len(text) * 6) // 2
def wave_interference_animation():
"""Cool wave interference pattern."""
import math
for frame in range(60):
draw.rectangle((0, 0, oled.width, oled.height), outline=0, fill=0)
# Two wave sources
source1_x, source1_y = oled.width // 3, oled.height // 2
source2_x, source2_y = 2 * oled.width // 3, oled.height // 2
for x in range(0, oled.width, 2):
for y in range(0, oled.height, 2):
# Distance from each source
dist1 = math.sqrt((x - source1_x)**2 + (y - source1_y)**2)
dist2 = math.sqrt((x - source2_x)**2 + (y - source2_y)**2)
# Wave interference
wave1 = math.sin((dist1 + frame * 2) * 0.3)
wave2 = math.sin((dist2 + frame * 2) * 0.3)
# Show interference pattern
if wave1 + wave2 > 0.8:
draw.point((x, y), fill=1)
oled.image(image)
oled.show()
time.sleep(0.08)
def seductive_eyes_animation():
"""Seductive winking eyes animation."""
import math
for frame in range(100): # Longer duration
draw.rectangle((0, 0, oled.width, oled.height), outline=0, fill=0)
center_x, center_y = oled.width // 2, oled.height // 2
# Slow seductive wink pattern
wink_cycle = frame % 60
# Left eye
if wink_cycle < 40:
# Normal eye
draw.ellipse([center_x - 10, center_y - 3, center_x - 6, center_y + 1], outline=1)
draw.point((center_x - 8, center_y - 1), fill=1) # Pupil
else:
# Winking (closed)
draw.line([(center_x - 10, center_y - 1), (center_x - 6, center_y - 1)], fill=1)
# Right eye
if wink_cycle < 20 or wink_cycle > 50:
# Normal eye
draw.ellipse([center_x + 6, center_y - 3, center_x + 10, center_y + 1], outline=1)
draw.point((center_x + 8, center_y - 1), fill=1) # Pupil
else:
# Winking (closed)
draw.line([(center_x + 6, center_y - 1), (center_x + 10, center_y - 1)], fill=1)
# Seductive smile
smile_curve = int(2 * math.sin(frame * 0.1))
draw.arc([center_x - 6, center_y + 3 + smile_curve,
center_x + 6, center_y + 8 + smile_curve], 0, 180, fill=1)
# Long eyelashes
if frame % 20 > 10:
# Left eyelashes
draw.line([(center_x - 9, center_y - 4), (center_x - 9, center_y - 6)], fill=1)
draw.line([(center_x - 7, center_y - 4), (center_x - 7, center_y - 6)], fill=1)
# Right eyelashes
draw.line([(center_x + 7, center_y - 4), (center_x + 7, center_y - 6)], fill=1)
draw.line([(center_x + 9, center_y - 4), (center_x + 9, center_y - 6)], fill=1)
oled.image(image)
oled.show()
time.sleep(0.1)
def bouncing_curves_animation():
"""Provocative bouncing curves animation."""
import math
for frame in range(120): # Longer duration
draw.rectangle((0, 0, oled.width, oled.height), outline=0, fill=0)
center_x, center_y = oled.width // 2, oled.height // 2
# Bouncing effect
bounce = int(3 * abs(math.sin(frame * 0.15)))
# Left curve (representing feminine form)
left_center_x = center_x - 15
left_center_y = center_y - bounce
# Right curve
right_center_x = center_x + 15
right_center_y = center_y - bounce
# Draw curved shapes that bounce
radius = 8 + int(2 * math.sin(frame * 0.1))
# Left shape
if left_center_x > 0 and left_center_y > 0:
draw.ellipse([left_center_x - radius//2, left_center_y - radius//2,
left_center_x + radius//2, left_center_y + radius//2], outline=1)
# Add highlight
draw.point((left_center_x - 2, left_center_y - 2), fill=1)
# Right shape
if right_center_x < oled.width and right_center_y > 0:
draw.ellipse([right_center_x - radius//2, right_center_y - radius//2,
right_center_x + radius//2, right_center_y + radius//2], outline=1)
# Add highlight
draw.point((right_center_x - 2, right_center_y - 2), fill=1)
# Add some decorative elements
if frame % 30 < 15:
# Sparkle effects
import random
for _ in range(2):
sx = random.randint(0, oled.width - 1)
sy = random.randint(0, oled.height - 1)
draw.point((sx, sy), fill=1)
# Add curves connecting them
if frame % 40 > 20:
curve_y = center_y + 5 + bounce
if curve_y < oled.height:
draw.arc([center_x - 20, curve_y - 5, center_x + 20, curve_y + 5], 0, 180, fill=1)
oled.image(image)
oled.show()
time.sleep(0.08)
def one_piece_luffy_fight_animation():
"""One Piece Luffy fighting animation with Gomu Gomu powers."""
import math
import random
for frame in range(150): # Longer duration for epic fight
draw.rectangle((0, 0, oled.width, oled.height), outline=0, fill=0)
# Luffy's position (left side)
luffy_x = 20 + int(3 * math.sin(frame * 0.1)) # Slight movement
luffy_y = oled.height // 2
# Enemy position (right side)
enemy_x = oled.width - 25 + int(2 * math.sin(frame * 0.15))
enemy_y = oled.height // 2
# Animation phases
phase = (frame // 30) % 5 # 5 different attack phases
if phase == 0: # Luffy preparing attack
# Luffy's head
draw.ellipse([luffy_x - 3, luffy_y - 8, luffy_x + 3, luffy_y - 2], outline=1)
# Straw hat
draw.line([(luffy_x - 4, luffy_y - 8), (luffy_x + 4, luffy_y - 8)], fill=1)
# Body
draw.line([(luffy_x, luffy_y - 2), (luffy_x, luffy_y + 6)], fill=1)
# Arms preparing
draw.line([(luffy_x, luffy_y), (luffy_x - 6, luffy_y - 2)], fill=1)
draw.line([(luffy_x, luffy_y), (luffy_x - 6, luffy_y + 2)], fill=1)
# Enemy (simple figure)
draw.ellipse([enemy_x - 2, enemy_y - 6, enemy_x + 2, enemy_y - 2], outline=1)
draw.line([(enemy_x, enemy_y - 2), (enemy_x, enemy_y + 4)], fill=1)
elif phase == 1: # Gomu Gomu no Pistol!
# Luffy's head
draw.ellipse([luffy_x - 3, luffy_y - 8, luffy_x + 3, luffy_y - 2], outline=1)
draw.line([(luffy_x - 4, luffy_y - 8), (luffy_x + 4, luffy_y - 8)], fill=1)
# Body
draw.line([(luffy_x, luffy_y - 2), (luffy_x, luffy_y + 6)], fill=1)
# Stretchy arm attack!
stretch_length = int(20 + 15 * math.sin(frame * 0.5))
for i in range(0, stretch_length, 3):
draw.point((luffy_x + i, luffy_y + int(2 * math.sin(i * 0.3))), fill=1)
# Fist at the end
fist_x = luffy_x + stretch_length
draw.ellipse([fist_x - 2, luffy_y - 2, fist_x + 2, luffy_y + 2], fill=1)
# Enemy getting hit
if stretch_length > 15:
enemy_x += random.randint(-2, 2) # Shake from impact
draw.ellipse([enemy_x - 2, enemy_y - 6, enemy_x + 2, enemy_y - 2], outline=1)
draw.line([(enemy_x, enemy_y - 2), (enemy_x, enemy_y + 4)], fill=1)
elif phase == 2: # Gomu Gomu no Gatling!
# Luffy's head
draw.ellipse([luffy_x - 3, luffy_y - 8, luffy_x + 3, luffy_y - 2], outline=1)
draw.line([(luffy_x - 4, luffy_y - 8), (luffy_x + 4, luffy_y - 8)], fill=1)
# Body
draw.line([(luffy_x, luffy_y - 2), (luffy_x, luffy_y + 6)], fill=1)
# Multiple rapid punches
for i in range(5):
punch_x = luffy_x + 8 + i * 3
punch_y = luffy_y + int(3 * math.sin(frame * 0.8 + i))
draw.point((punch_x, punch_y), fill=1)
# Punch lines for speed effect
if frame % 3 == 0:
draw.line([(punch_x - 2, punch_y), (punch_x + 2, punch_y)], fill=1)
# Enemy taking multiple hits
draw.ellipse([enemy_x - 2, enemy_y - 6, enemy_x + 2, enemy_y - 2], outline=1)
draw.line([(enemy_x, enemy_y - 2), (enemy_x, enemy_y + 4)], fill=1)
# Impact effects
for _ in range(3):
ex = enemy_x + random.randint(-3, 3)
ey = enemy_y + random.randint(-3, 3)
draw.point((ex, ey), fill=1)
elif phase == 3: # Gomu Gomu no Bazooka!
# Luffy's head
draw.ellipse([luffy_x - 3, luffy_y - 8, luffy_x + 3, luffy_y - 2], outline=1)
draw.line([(luffy_x - 4, luffy_y - 8), (luffy_x + 4, luffy_y - 8)], fill=1)
# Body leaning back
draw.line([(luffy_x - 2, luffy_y - 2), (luffy_x - 2, luffy_y + 6)], fill=1)
# Both hands pulled back then thrust forward
thrust = int(10 * abs(math.sin(frame * 0.3)))
draw.ellipse([luffy_x + thrust - 1, luffy_y - 3, luffy_x + thrust + 1, luffy_y - 1], fill=1)
draw.ellipse([luffy_x + thrust - 1, luffy_y + 1, luffy_x + thrust + 1, luffy_y + 3], fill=1)
# Impact waves
if thrust > 7:
for wave in range(3):
wave_x = luffy_x + thrust + wave * 5
if wave_x < oled.width:
draw.line([(wave_x, luffy_y - 4), (wave_x, luffy_y + 4)], fill=1)
# Enemy being pushed back
enemy_push = max(0, thrust - 5)
draw.ellipse([enemy_x + enemy_push - 2, enemy_y - 6, enemy_x + enemy_push + 2, enemy_y - 2], outline=1)
draw.line([(enemy_x + enemy_push, enemy_y - 2), (enemy_x + enemy_push, enemy_y + 4)], fill=1)
else: # Victory pose and "Yatta!" moment
# Luffy celebrating
draw.ellipse([luffy_x - 3, luffy_y - 8, luffy_x + 3, luffy_y - 2], outline=1)
draw.line([(luffy_x - 4, luffy_y - 8), (luffy_x + 4, luffy_y - 8)], fill=1)
# Body
draw.line([(luffy_x, luffy_y - 2), (luffy_x, luffy_y + 6)], fill=1)
# Arms raised in victory
draw.line([(luffy_x, luffy_y), (luffy_x - 5, luffy_y - 5)], fill=1)
draw.line([(luffy_x, luffy_y), (luffy_x + 5, luffy_y - 5)], fill=1)
# Enemy defeated (on ground)
draw.ellipse([enemy_x - 2, enemy_y + 2, enemy_x + 2, enemy_y + 4], outline=1)
draw.line([(enemy_x - 3, enemy_y + 3), (enemy_x + 3, enemy_y + 3)], fill=1)
# Victory sparkles
if frame % 8 < 4:
for _ in range(4):
sx = random.randint(0, oled.width - 1)
sy = random.randint(0, oled.height - 1)
draw.point((sx, sy), fill=1)
# "Yatta!" text effect
if frame % 20 > 10:
draw.text((oled.width // 2 - 12, 2), "YATTA!", font=font, fill=1)
# Add "One Piece" atmosphere with occasional treasure chest
if frame % 40 == 0:
chest_x = random.randint(5, oled.width - 10)
draw.rectangle([chest_x, oled.height - 6, chest_x + 4, oled.height - 2], outline=1)
draw.point((chest_x + 2, oled.height - 4), fill=1) # Treasure sparkle
oled.image(image)
oled.show()
time.sleep(0.1)
def super_sonico_animation():
"""Super Sonico anime character animation with music and headphones."""
import math
import random
for frame in range(100): # Smooth animation
draw.rectangle((0, 0, oled.width, oled.height), outline=0, fill=0)
center_x, center_y = oled.width // 2, oled.height // 2
# Sonico's head (round face)
head_bounce = int(1 * math.sin(frame * 0.1)) # Gentle head bounce
head_y = center_y - 6 + head_bounce
draw.ellipse([center_x - 5, head_y - 4, center_x + 5, head_y + 2], outline=1)
# Her signature pink hair (twin tails)
hair_sway = int(2 * math.sin(frame * 0.15))
# Left twin tail
draw.line([(center_x - 6, head_y - 2), (center_x - 8 + hair_sway, head_y - 6)], fill=1)
draw.line([(center_x - 8 + hair_sway, head_y - 6), (center_x - 10 + hair_sway, head_y - 4)], fill=1)
# Right twin tail
draw.line([(center_x + 6, head_y - 2), (center_x + 8 - hair_sway, head_y - 6)], fill=1)
draw.line([(center_x + 8 - hair_sway, head_y - 6), (center_x + 10 - hair_sway, head_y - 4)], fill=1)
# Hair bands/decorations
draw.point((center_x - 6, head_y - 3), fill=1)
draw.point((center_x + 6, head_y - 3), fill=1)
# Sonico's headphones (her signature accessory)
headphone_glow = frame % 20 < 10 # Blinking LED effect
# Left headphone
draw.ellipse([center_x - 7, head_y - 2, center_x - 4, head_y + 1], outline=1)
if headphone_glow:
draw.point((center_x - 5, head_y - 1), fill=1) # LED light
# Right headphone
draw.ellipse([center_x + 4, head_y - 2, center_x + 7, head_y + 1], outline=1)
if headphone_glow:
draw.point((center_x + 5, head_y - 1), fill=1) # LED light
# Headphone band
draw.arc([center_x - 6, head_y - 6, center_x + 6, head_y - 2], 0, 180, fill=1)
# Eyes (cute anime style)
blink = math.sin(frame * 0.05) > 0.9
if not blink:
# Normal eyes
draw.point((center_x - 2, head_y - 1), fill=1)
draw.point((center_x + 2, head_y - 1), fill=1)
else:
# Blinking (small lines)
draw.line([(center_x - 3, head_y - 1), (center_x - 1, head_y - 1)], fill=1)
draw.line([(center_x + 1, head_y - 1), (center_x + 3, head_y - 1)], fill=1)
# Cute smile
draw.point((center_x - 1, head_y + 1), fill=1)
draw.point((center_x, head_y + 1), fill=1)
draw.point((center_x + 1, head_y + 1), fill=1)
# Body (simple anime style)
body_sway = int(1 * math.sin(frame * 0.12))
draw.line([(center_x + body_sway, head_y + 2), (center_x + body_sway, center_y + 8)], fill=1)
# Arms (holding something - maybe guitar pick or microphone)
arm_move = int(2 * math.sin(frame * 0.2))
draw.line([(center_x + body_sway, center_y + 2), (center_x - 6 + arm_move, center_y + 4)], fill=1)
draw.line([(center_x + body_sway, center_y + 2), (center_x + 6 - arm_move, center_y + 4)], fill=1)
# Music notes floating around (her musical theme)
note_positions = [
(center_x - 15, center_y - 8),
(center_x + 12, center_y - 5),
(center_x - 10, center_y + 6),
(center_x + 8, center_y + 8)
]
for i, (note_x, note_y) in enumerate(note_positions):
float_offset = int(3 * math.sin(frame * 0.1 + i))
final_y = note_y + float_offset
if 0 <= note_x < oled.width and 0 <= final_y < oled.height:
# Music note shape
draw.ellipse([note_x, final_y, note_x + 2, final_y + 2], fill=1)
draw.line([(note_x + 2, final_y), (note_x + 2, final_y - 3)], fill=1)
# Add flag to some notes
if i % 2 == 0:
draw.line([(note_x + 2, final_y - 3), (note_x + 4, final_y - 2)], fill=1)
# Sound waves/music visualization
if frame % 10 < 5:
for wave in range(3):
wave_x = center_x + 15 + wave * 8
if wave_x < oled.width:
wave_height = 2 + int(2 * math.sin(frame * 0.3 + wave))
draw.line([(wave_x, center_y - wave_height), (wave_x, center_y + wave_height)], fill=1)
# Sparkles/stars around her (idol theme)
if frame % 15 < 8:
sparkle_positions = [
(center_x - 12, head_y - 8),
(center_x + 14, head_y - 6),
(center_x - 8, center_y + 10),
(center_x + 10, center_y + 12)
]
for spark_x, spark_y in sparkle_positions:
if 0 <= spark_x < oled.width and 0 <= spark_y < oled.height:
# Star sparkle
draw.point((spark_x, spark_y), fill=1)
draw.point((spark_x - 1, spark_y), fill=1)
draw.point((spark_x + 1, spark_y), fill=1)
draw.point((spark_x, spark_y - 1), fill=1)
draw.point((spark_x, spark_y + 1), fill=1)
# Occasionally show "♪ SONICO ♪" text
if 30 <= frame < 40:
draw.text((center_x(oled.width, "SONICO"), 2), "SONICO", font=font, fill=1)
# Musical symbols
draw.point((center_x - 25, 4), fill=1)
draw.point((center_x + 20, 4), fill=1)
oled.image(image)
oled.show()
time.sleep(0.1)
def run_random_animation():
"""Run a random animation to prevent burn-in."""
import random
animations = [
matrix_rain_animation,
bouncing_ball_animation,
sine_wave_animation,
starfield_animation,
digital_clock_animation,
progress_bars_animation,
github_signature_animation,
wave_interference_animation,
anime_heart_animation,
kawaii_face_animation,
neko_ears_animation,
seductive_eyes_animation,
bouncing_curves_animation,
one_piece_luffy_fight_animation,
super_sonico_animation
]
# Show GitHub signature occasionally (15% chance, reduced since we have more animations)
if random.random() < 0.15:
animation = github_signature_animation
else:
# Pick a random animation from the others
other_animations = [a for a in animations if a != github_signature_animation]
animation = random.choice(other_animations)
logging.info(f"Running burn-in prevention animation: {animation.__name__}")
try:
animation()
except Exception as e:
logging.error(f"Animation error: {e}")
# Clear screen after animation
draw.rectangle((0, 0, oled.width, oled.height), outline=0, fill=0)
oled.image(image)
oled.show()
def main():
last_animation_time = time.time()
animation_interval = 180 # Run animation every 3 minutes
text_offset = 0 # For moving text effect
while True:
# Check if it's time for a burn-in prevention animation
current_time_sec = time.time()
if current_time_sec - last_animation_time > animation_interval:
run_random_animation()
last_animation_time = current_time_sec
# Clear the image for the new drawing
draw.rectangle((0, 0, oled.width, oled.height), outline=0, fill=0)
# Get the information
ip_address = get_ip_address()
cpu_temp = get_cpu_temperature()
ram_usage = get_ram_usage()
cpu_usage = get_cpu_usage()
current_time = datetime.datetime.now().strftime("%H:%M")
# Create scrolling text effect
text1 = f"IP:{ip_address} CPU:{cpu_usage:.0f}%"
text2 = f"Tmp:{cpu_temp} Tm:{current_time} R:{ram_usage:.0f}%"
# Calculate scrolling positions - moderate speed for comfortable reading
scroll_speed = 3 # Reduced from 6 to 3 for more comfortable scrolling
# Use a fixed scroll cycle to keep both lines perfectly synchronized
scroll_cycle = oled.width + 150 # Fixed cycle length regardless of text length
scroll_x = (text_offset * scroll_speed) % scroll_cycle
# Make text scroll from right to left - both lines perfectly synchronized
text1_pos = oled.width - scroll_x
text2_pos = oled.width - scroll_x # Exactly the same position
text_offset += 1
# Draw the scrolling text - both lines perfectly synchronized
# Line 1: IP Address and CPU Usage
draw.text((text1_pos, 0), text1, font=font, fill=1)
if text1_pos < -len(text1) * 6: # If text scrolled off, show it on right side too
draw.text((text1_pos + scroll_cycle, 0), text1, font=font, fill=1)
# Line 2: Temperature, Current Time, and RAM Usage
draw.text((text2_pos, 16), text2, font=font, fill=1)
if text2_pos < -len(text2) * 6: # If text scrolled off, show it on right side too
draw.text((text2_pos + scroll_cycle, 16), text2, font=font, fill=1)
# Display the image on the OLED
oled.image(image)
oled.show()
# Smooth scrolling with comfortable speed
time.sleep(0.15) # Slightly slower refresh for more comfortable reading
if __name__ == "__main__":
main()