更新 青春喇叭频率播放,指针显示

This commit is contained in:
dahanzimin
2025-03-26 12:22:13 +08:00
parent 07566c890c
commit be0c41cfb7
3 changed files with 33 additions and 19 deletions

View File

@@ -14,3 +14,5 @@ Stop_2=b'P4\n89 64\n\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x7f\x00\x00\x00
Thumbs_down=b'P4\n89 64\n\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x7f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x7f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x7f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x7f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x7f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x7f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x7f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x7f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x7f\x00\x00\x07\xff\xc0\x00\x00\x00\x00\x00\x00\x7f\x00\x00\x0f\xff\xc0\x00\x00\x00\x00\x00\x00\x7f\x00\x00\x0c\x00\xc7\xff\xff\xff\x00\x00\x00\x7f\x00\x00\x0e\xaa\xff\xff\xff\xff\xc0\x00\x00\x7f\x00\x00\rT\xff\xff\xff\xff\xc0\x00\x00\x7f\x00\x00\x0c\xaa\xff\xff\xff\xff\xc0\x00\x00\x7f\x00\x00\r\xfe\xff\xff\xff\xff\xc0\x00\x00\x7f\x00\x00\x0f\xff\xff\xff\xff\xff\xe0\x00\x00\x7f\x00\x00\r\xff\xff\xff\xff\xff\xf0\x00\x00\x7f\x00\x00\x0f\xff\xff\xff\xff\xff\xf8\x00\x00\x7f\x00\x00\r\xff\xff\xff\xff\xff\xf8\x00\x00\x7f\x00\x00\x0f\xff\xff\xff\xff\xff\xf8\x00\x00\x7f\x00\x00\r\xff\xff\xff\xff\xff\xf0\x00\x00\x7f\x00\x00\x0f\xff\xff\xff\xff\xea\xa0\x00\x00\x7f\x00\x00\r\xff\xff\xff\xff\xff\xf8\x00\x00\x7f\x00\x00\x0f\xff\xff\xff\xff\xff\xf8\x00\x00\x7f\x00\x00\r\xff\xff\xff\xff\xff\xf8\x00\x00\x7f\x00\x00\x0f\xff\xff\xff\xff\xff\xf8\x00\x00\x7f\x00\x00\r\xff\xff\xff\xff\xff\xf8\x00\x00\x7f\x00\x00\x0f\xff\xff\xff\xff\xff\xf0\x00\x00\x7f\x00\x00\r\xff\xff\xff\xff\xd5@\x00\x00\x7f\x00\x00\x0f\xff\xff\xff\xff\xff\xf0\x00\x00\x7f\x00\x00\r\xff\xff\xff\xff\xff\xf0\x00\x00\x7f\x00\x00\x0f\xff\xff\xff\xff\xff\xf0\x00\x00\x7f\x00\x00\r\xff\xc1\xff\xff\xff\xf0\x00\x00\x7f\x00\x00\x0e\xaa\xc0\x7f\xff\xff\xe0\x00\x00\x7f\x00\x00\x0f\xff\xc0?\xff\xff\xe0\x00\x00\x7f\x00\x00\x07\xff\x80?\xff\xff\x80\x00\x00\x7f\x00\x00\x00\x00\x00\x1f\xff\xc0\x00\x00\x00\x7f\x00\x00\x00\x00\x00\x0f\xfc\x00\x00\x00\x00\x7f\x00\x00\x00\x00\x00\x07\xfc\x00\x00\x00\x00\x7f\x00\x00\x00\x00\x00\x03\xfc\x00\x00\x00\x00\x7f\x00\x00\x00\x00\x00\x01\xfc\x00\x00\x00\x00\x7f\x00\x00\x00\x00\x00\x01\xfe\x00\x00\x00\x00\x7f\x00\x00\x00\x00\x00\x00\xfe\x00\x00\x00\x00\x7f\x00\x00\x00\x00\x00\x00\xff\x00\x00\x00\x00\x7f\x00\x00\x00\x00\x00\x00\x7f\x00\x00\x00\x00\x7f\x00\x00\x00\x00\x00\x00?\x00\x00\x00\x00\x7f\x00\x00\x00\x00\x00\x00?\x80\x00\x00\x00\x7f\x00\x00\x00\x00\x00\x00\x1f\x80\x00\x00\x00\x7f\x00\x00\x00\x00\x00\x00\x1f\x80\x00\x00\x00\x7f\x00\x00\x00\x00\x00\x00\x1f\x80\x00\x00\x00\x7f\x00\x00\x00\x00\x00\x00\x1f\x80\x00\x00\x00\x7f\x00\x00\x00\x00\x00\x00\x0f\x80\x00\x00\x00\x7f\x00\x00\x00\x00\x00\x00\x0f\x80\x00\x00\x00\x7f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x7f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x7f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x7f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x7f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x7f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x7f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x7f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x7f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x7f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x7f'
Thumbs_up=b'P4\n89 64\n\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x7f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x7f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x7f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x7f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x7f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x7f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x7f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x7f\x00\x00\x00\x00\x00\x00\x0f\x80\x00\x00\x00\x7f\x00\x00\x00\x00\x00\x00\x0f\x80\x00\x00\x00\x7f\x00\x00\x00\x00\x00\x00\x1f\x80\x00\x00\x00\x7f\x00\x00\x00\x00\x00\x00\x1f\x80\x00\x00\x00\x7f\x00\x00\x00\x00\x00\x00\x1f\x80\x00\x00\x00\x7f\x00\x00\x00\x00\x00\x00\x1f\x80\x00\x00\x00\x7f\x00\x00\x00\x00\x00\x00?\x80\x00\x00\x00\x7f\x00\x00\x00\x00\x00\x00?\x00\x00\x00\x00\x7f\x00\x00\x00\x00\x00\x00\x7f\x00\x00\x00\x00\x7f\x00\x00\x00\x00\x00\x00\xff\x00\x00\x00\x00\x7f\x00\x00\x00\x00\x00\x00\xfe\x00\x00\x00\x00\x7f\x00\x00\x00\x00\x00\x01\xfe\x00\x00\x00\x00\x7f\x00\x00\x00\x00\x00\x01\xfc\x00\x00\x00\x00\x7f\x00\x00\x00\x00\x00\x03\xfc\x00\x00\x00\x00\x7f\x00\x00\x00\x00\x00\x07\xfc\x00\x00\x00\x00\x7f\x00\x00\x00\x00\x00\x0f\xfc\x00\x00\x00\x00\x7f\x00\x00\x00\x00\x00\x1f\xff\xc0\x00\x00\x00\x7f\x00\x00\x00\x00\x00?\xff\xff\x80\x00\x00\x7f\x00\x00\x07\xff\xc0?\xff\xff\xe0\x00\x00\x7f\x00\x00\x0f\xff\xc0\x7f\xff\xff\xe0\x00\x00\x7f\x00\x00\x0c\x00\xc1\xff\xff\xff\xf0\x00\x00\x7f\x00\x00\rT\xff\xff\xff\xff\xf0\x00\x00\x7f\x00\x00\x0c\xaa\xff\xff\xff\xff\xf0\x00\x00\x7f\x00\x00\rT\xff\xff\xff\xff\xf0\x00\x00\x7f\x00\x00\r\xfe\xff\xff\xff\xea\xa0\x00\x00\x7f\x00\x00\x0f\xff\xff\xff\xff\xff\xf0\x00\x00\x7f\x00\x00\r\xff\xff\xff\xff\xff\xf8\x00\x00\x7f\x00\x00\x0f\xff\xff\xff\xff\xff\xf8\x00\x00\x7f\x00\x00\r\xff\xff\xff\xff\xff\xf8\x00\x00\x7f\x00\x00\x0f\xff\xff\xff\xff\xff\xf8\x00\x00\x7f\x00\x00\r\xff\xff\xff\xff\xff\xf8\x00\x00\x7f\x00\x00\x0f\xff\xff\xff\xff\xea\xa0\x00\x00\x7f\x00\x00\r\xff\xff\xff\xff\xff\xf0\x00\x00\x7f\x00\x00\x0f\xff\xff\xff\xff\xff\xf8\x00\x00\x7f\x00\x00\r\xff\xff\xff\xff\xff\xf8\x00\x00\x7f\x00\x00\x0f\xff\xff\xff\xff\xff\xf8\x00\x00\x7f\x00\x00\r\xff\xff\xff\xff\xff\xf0\x00\x00\x7f\x00\x00\x0f\xff\xff\xff\xff\xff\xe0\x00\x00\x7f\x00\x00\r\xff\xff\xff\xff\xff\xc0\x00\x00\x7f\x00\x00\x0f\xff\xff\xff\xff\xff\xc0\x00\x00\x7f\x00\x00\r\xff\xff\xff\xff\xff\xc0\x00\x00\x7f\x00\x00\x0f\xff\xff\xff\xff\xff\xc0\x00\x00\x7f\x00\x00\r\xff\xc7\xff\xff\xff\x00\x00\x00\x7f\x00\x00\rT\xc0\x00\x00\x00\x00\x00\x00\x7f\x00\x00\x0f\xff\xc0\x00\x00\x00\x00\x00\x00\x7f\x00\x00\x07\xff\x80\x00\x00\x00\x00\x00\x00\x7f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x7f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x7f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x7f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x7f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x7f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x7f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x7f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x7f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x7f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x7f'
Warning=b'P4\n89 64\n\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x7f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x7f\x00\x00\x00\x00\x00\x1e\x00\x00\x00\x00\x00\x7f\x00\x00\x00\x00\x00\x1e\x00\x00\x00\x00\x00\x7f\x00\x00\x00\x00\x00=\x00\x00\x00\x00\x00\x7f\x00\x00\x00\x00\x00?\x00\x00\x00\x00\x00\x7f\x00\x00\x00\x00\x00\x7f\x80\x00\x00\x00\x00\x7f\x00\x00\x00\x00\x00\xff@\x00\x00\x00\x00\x7f\x00\x00\x00\x00\x00\xf3\xc0\x00\x00\x00\x00\x7f\x00\x00\x00\x00\x01\xf3\xa0\x00\x00\x00\x00\x7f\x00\x00\x00\x00\x01\xe1\xf0\x00\x00\x00\x00\x7f\x00\x00\x00\x00\x03\xe1\xd0\x00\x00\x00\x00\x7f\x00\x00\x00\x00\x03\xc0\xf0\x00\x00\x00\x00\x7f\x00\x00\x00\x00\x07\xc0\xe8\x00\x00\x00\x00\x7f\x00\x00\x00\x00\x0f\x80|\x00\x00\x00\x00\x7f\x00\x00\x00\x00\x0f\x80|\x00\x00\x00\x00\x7f\x00\x00\x00\x00\x1f\x00:\x00\x00\x00\x00\x7f\x00\x00\x00\x00\x1f\x00>\x00\x00\x00\x00\x7f\x00\x00\x00\x00>>\x1d\x00\x00\x00\x00\x7f\x00\x00\x00\x00<{\x0f\x00\x00\x00\x00\x7f\x00\x00\x00\x00|y\x0e\x80\x00\x00\x00\x7f\x00\x00\x00\x00\xf8\xfe\x87\xc0\x00\x00\x00\x7f\x00\x00\x00\x00\xf8\xfe\x87\xc0\x00\x00\x00\x7f\x00\x00\x00\x01\xf0\xff\x83\xa0\x00\x00\x00\x7f\x00\x00\x00\x01\xf0\xfe\x83\xe0\x00\x00\x00\x7f\x00\x00\x00\x03\xe0\xff\x81\xd0\x00\x00\x00\x7f\x00\x00\x00\x03\xc0\xff\x80\xf0\x00\x00\x00\x7f\x00\x00\x00\x07\xc0\x7f\x00\xe8\x00\x00\x00\x7f\x00\x00\x00\x0f\x80\x7f\x00|\x00\x00\x00\x7f\x00\x00\x00\x0f\x80\x7f\x00t\x00\x00\x00\x7f\x00\x00\x00\x1f\x00\x7f\x00>\x00\x00\x00\x7f\x00\x00\x00\x1f\x00\x7f\x00>\x00\x00\x00\x7f\x00\x00\x00>\x00\x7f\x00\x1d\x00\x00\x00\x7f\x00\x00\x00>\x00\x7f\x00\x1f\x00\x00\x00\x7f\x00\x00\x00|\x00\x7f\x00\x0e\x80\x00\x00\x7f\x00\x00\x00\xf8\x00\x7f\x00\x07\xc0\x00\x00\x7f\x00\x00\x00\xf8\x00\x7f\x00\x07@\x00\x00\x7f\x00\x00\x01\xf0\x00\x7f\x00\x03\xe0\x00\x00\x7f\x00\x00\x01\xf0\x00\x7f\x00\x03\xe0\x00\x00\x7f\x00\x00\x03\xe0\x00>\x00\x01\xd0\x00\x00\x7f\x00\x00\x03\xe0\x00>\x00\x01\xf0\x00\x00\x7f\x00\x00\x07\xc0\x00>\x00\x00\xe8\x00\x00\x7f\x00\x00\x0f\xc0\x00>\x00\x00\xfc\x00\x00\x7f\x00\x00\x0f\x80\x00\x1c\x00\x00t\x00\x00\x7f\x00\x00\x1f\x00\x00\x00\x00\x00>\x00\x00\x7f\x00\x00\x1f\x00\x00\x00\x00\x00:\x00\x00\x7f\x00\x00>\x00\x00\x00\x00\x00\x1f\x00\x00\x7f\x00\x00>\x00\x00>\x00\x00\x1f\x00\x00\x7f\x00\x00|\x00\x00}\x00\x00\x0e\x80\x00\x7f\x00\x00\xfc\x00\x00~\x80\x00\x0f\xc0\x00\x7f\x00\x00\xf8\x00\x00\x7f\x80\x00\x07@\x00\x7f\x00\x01\xf8\x00\x00\x7f\x80\x00\x07\xe0\x00\x7f\x00\x01\xf0\x00\x00\x7f\x00\x00\x03\xa0\x00\x7f\x00\x03\xe0\x00\x00?\x00\x00\x01\xf0\x00\x7f\x00\x03\xe0\x00\x00\x1e\x00\x00\x01\xf0\x00\x7f\x00\x07\xc0\x00\x00\x00\x00\x00\x00\xe8\x00\x7f\x00\x0f\xc0\x00\x00\x00\x00\x00\x00\xfc\x00\x7f\x00\x0f\x80\x00\x00\x00\x00\x00\x00\xf4\x00\x7f\x00\x1f\xff\xff\xff\xff\xff\xff\xff\xfe\x00\x7f\x00\x1f\xff\xff\xff\xff\xff\xff\xff\xfe\x00\x7f\x00\x1f\xff\xff\xff\xff\xff\xff\xff\xfe\x00\x7f\x00\x07\xff\xff\xff\xff\xff\xff\xff\xf8\x00\x7f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x7f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x7f'
YES=Accept
NO=Decline

View File

@@ -3,13 +3,10 @@ framebuf-extend
Micropython library for the framebuf-extend
=======================================================
#Preliminary composition 20230412
@dahanzimin From the Mixly Team
"""
import esp, time, gc
import esp, time, gc, math
from framebuf import *
class Font_Ascall:
@@ -262,6 +259,15 @@ class FrameBuffer_Base(FrameBuffer):
def get_buffer(self):
return self._buffer
def pointern(self, x=None, y=None, l=None, angle=0, color=0xffff, bg_color=0x0):
x = self.width // 2 if x is None else x
y = self.height // 2 if y is None else y
l = min(self.height // 2 , self.width // 2) if l is None else l
radian = math.radians(angle)
if self.auto_show: self.fill(bg_color)
self.line(x, y, round(x + l * math.sin(radian)), round(y - l * math.cos(radian)), color)
if self.auto_show: self.show()
class FrameBuffer_Ascall(FrameBuffer_Base):
'''FrameBuffer for Ascall'''
def font(self, font):
@@ -382,7 +388,7 @@ class FrameBuffer_Uincode(FrameBuffer_Base):
yy = y
if size is None:
font_len, font_buffer = self._take_buffer(str(data), space, 1)
size = min(self.width // font_len, self.height // self._font.height)
size = min((self.width // font_len) if font_len > 0 else 1, self.height // self._font.height)
size = max(round(size), 1)
font_len, font_buffer = self._take_buffer(str(data), space, size)
x = (self.width - font_len + space) // 2 if center else x

View File

@@ -13,7 +13,7 @@ dahanzimin From the Mixly Team
import time
import math
import array,struct
import struct
normal_tone = {
'A1': 55, 'B1': 62, 'C1': 33, 'D1': 37, 'E1': 41, 'F1': 44, 'G1': 49,
@@ -34,19 +34,25 @@ class MIDI():
self._rate = rate
self.i2s_bus = i2s_bus
def _tone(self, frequency, run_ms=1000):
# create a buffer containing the pure tone samples
samples_per_cycle = self._rate // frequency
sample_size_in_bytes = 16 // 8
samples = bytearray(samples_per_cycle * sample_size_in_bytes)
_range = 32768
for i in range(samples_per_cycle):
sample = _range + int((_range - 1) * math.sin(2 * math.pi * i / samples_per_cycle))
struct.pack_into("<h", samples, i * sample_size_in_bytes, sample)
star = time.ticks_ms()
while time.ticks_diff(time.ticks_ms(), star) <= run_ms:
self.i2s_bus.write(samples)
def _wave(self, frequency):
_period = self._rate // frequency
_samples = bytearray()
for i in range(_period):
sample = 32768 + int((32767) * math.sin(2 * math.pi * i / _period))
_samples.extend(struct.pack("<h", sample))
return bytes(_samples)
def _tone(self, frequency, duration_ms=1000):
_wave = self._wave(frequency)
_samples = self._rate * duration_ms // 1000
_data = _wave * (_samples // (len(_wave) // 2) + 1)
_data = _data[:_samples * 2]
_wbytes = 0
while _wbytes < len(_data):
send_size = min(512, len(_data) - _wbytes)
self.i2s_bus.write(_data[_wbytes : _wbytes + send_size])
_wbytes += send_size
def set_tempo(self, ticks=4, bpm=120):
self.ticks = ticks