esp32c3 micropython oled实时天气信息

news2024/10/5 16:21:23

目录

简介

效果展示

代码

main.py

ssd1306.py

font.py

实现思路


简介

合宙esp32c3 micropython框架,只支持128*64 I2C oled

ssd1306驱动我优化过的,与其他的不一样,为避免出错,使用我的驱动

把下面两个py文件放入单片机内,

搜索心知天气,注册账号,获得免费的key

效果展示

代码

main.py

import network
import urequests
from ssd1306 import SSD1306_I2C
from machine import Pin, I2C
import ujson
from font import textc

i2c = I2C(0, scl=Pin(5), sda=Pin(4))
oled = SSD1306_I2C(i2c)

url = 'https://api.seniverse.com/v3/weather/now.json?key=你的密钥&location=guangzhou&language=zh-Hans&unit=c'


class Weather():
    def __init__(self, ssid, password):
        
        wifi=network.WLAN(network.STA_IF)
        wifi.active(True)
        #连接wifi,有一定几率连接失败
        while not wifi.isconnected():
            wifi.connect(ssid,password)
            oled.fill(0)
            oled.text('connecting...',0,0)
            oled.show()
        #更新显示连接wifi信息   
        oled.fill(0)
        oled.text('connect to szsb',0,0)
        oled.show()

        response = urequests.get(url)
        parsed = ujson.loads(response.text)
        weather_info = parsed['results'][0]['now']
        temperature = weather_info['temperature']
        weather_state = weather_info['text']
        #下面两条语句的作用是一样的,二选一,把unicode编码转为中文字符
        # x=eval('u"%s"' % weather_state)
        x = ujson.loads('"%s"' % weather_state)
        oled.text(temperature + '`c', 80, 48)
        textc(oled, '广', 80, 16)
        textc(oled, '州', 96, 16)
        oled.vline(60, 0, 64)
        if len(weather_state) == 2:
            textc(oled, x[0], 16, 48)
            textc(oled, x[1], 32, 48)
            if x[1] == '雨':
                if weather_state == '大雨':
                    max_rainy = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                                 0x00, 0x00,
                                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                                 0x00, 0x00,
                                 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x0C, 0x10, 0x10, 0x08, 0x08, 0x10, 0x60, 0x80,
                                 0x80, 0x80,
                                 0x80, 0x60, 0x20, 0x10, 0x10, 0x08, 0x08, 0x06, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00,
                                 0x00, 0x00,
                                 0x00, 0x00, 0x00, 0x60, 0x91, 0x8A, 0x09, 0x08, 0x08, 0x08, 0x08, 0x09, 0x0A, 0x09,
                                 0x08, 0x08,
                                 0x08, 0x08, 0x09, 0x0A, 0x09, 0x08, 0x08, 0x08, 0x08, 0x09, 0x92, 0x61, 0x00, 0x00,
                                 0x00, 0x00,
                                 0x00, 0x00, 0x00, 0xC0, 0x20, 0x20, 0x26, 0xC9, 0x11, 0x09, 0xC6, 0x20, 0x20, 0x26,
                                 0xC9, 0x11,
                                 0x09, 0xC6, 0x20, 0x20, 0x26, 0xC9, 0x11, 0x09, 0xC6, 0x20, 0x20, 0x20, 0xC0, 0x00,
                                 0x00, 0x00
                                 ]
                    oled.p32(max_rainy, 16, 8)
                elif weather_state == '中雨':
                    mid_rainy = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01,
                                 0x01, 0x00,
                                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                                 0x00, 0x00,
                                 0x00, 0x00, 0x00, 0x00, 0x01, 0x06, 0x08, 0x08, 0x30, 0x40, 0x40, 0x80, 0x00, 0x00,
                                 0x00, 0x80,
                                 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x30, 0x08, 0x08, 0x08, 0x06, 0x01, 0x01, 0x00,
                                 0x00, 0x00,
                                 0x00, 0x00, 0x60, 0x90, 0x11, 0x12, 0x14, 0x12, 0x11, 0x10, 0x10, 0x10, 0x11, 0x12,
                                 0x14, 0x12,
                                 0x11, 0x10, 0x10, 0x10, 0x11, 0x12, 0x14, 0x12, 0x11, 0x10, 0x10, 0x10, 0x20, 0xC0,
                                 0x00, 0x00,
                                 0x00, 0x00, 0x00, 0x00, 0x80, 0x40, 0x40, 0x40, 0x80, 0x00, 0x00, 0x00, 0x80, 0x40,
                                 0x40, 0x40,
                                 0x80, 0x00, 0x00, 0x00, 0x80, 0x40, 0x40, 0x40, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00,
                                 0x00, 0x00
                                 ]
                    oled.p32(mid_rainy, 16, 8)
                elif weather_state == '小雨':
                    min_rainy = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01,
                                 0x01, 0x00,
                                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                                 0x00, 0x00,
                                 0x00, 0x00, 0x00, 0x00, 0x01, 0x06, 0x08, 0x08, 0x30, 0x40, 0x40, 0x80, 0x00, 0x00,
                                 0x00, 0x80,
                                 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x30, 0x08, 0x08, 0x08, 0x06, 0x01, 0x01, 0x00,
                                 0x00, 0x00,
                                 0x00, 0x00, 0x60, 0x90, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x11, 0x12,
                                 0x14, 0x12,
                                 0x11, 0x10, 0x10, 0x10, 0x11, 0x12, 0x14, 0x12, 0x11, 0x10, 0x10, 0x10, 0x20, 0xC0,
                                 0x00, 0x00,
                                 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x40,
                                 0x40, 0x40,
                                 0x80, 0x00, 0x00, 0x00, 0x80, 0x40, 0x40, 0x40, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00,
                                 0x00, 0x00
                                 ]
                    oled(min_rainy, 16, 8)
            else:
                cloud = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x06,
                         0x03, 0x01, 0x00, 0x00, 0x00, 0x0C, 0x06, 0x02, 0x00, 0x00, 0x0E, 0x0E, 0x00, 0x00, 0x00, 0x00,
                         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8C, 0xC4, 0x44, 0x00, 0x00,
                         0x00, 0x7F, 0x40, 0x40, 0x40, 0x47, 0x47, 0x40, 0x40, 0x40, 0x7F, 0x00, 0x23, 0x63, 0xC3, 0x00,
                         0x00, 0x00, 0x00, 0x00, 0x03, 0x07, 0x07, 0x1F, 0x3F, 0x3F, 0x3F, 0x3F, 0x7F, 0xFF, 0xFF, 0xFF,
                         0x7F, 0xFF, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x1F, 0x07, 0x07, 0xFF, 0x00, 0x30, 0x18, 0x08, 0x00,
                         0x00, 0x00, 0x00, 0xE0, 0xF0, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8,
                         0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF0, 0xE0, 0x00, 0x00, 0x00, 0x00
                         ]
                oled.p32(cloud, 16, 8)
        else:
            textc(oled, x, 24, 48)
            if x == '晴':
                sunny = [
                    0x00, 0x00, 0x00, 0x18, 0x1C, 0x0E, 0x07, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8,
                    0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x07, 0x0E, 0x1C, 0x18, 0x00, 0x00, 0x00,
                    0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x3F, 0x40, 0x80, 0x80, 0x80, 0x80, 0x83, 0x83,
                    0x83, 0x83, 0x80, 0x80, 0x80, 0x80, 0x40, 0x3F, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01,
                    0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0xFC, 0x02, 0x01, 0x01, 0x01, 0x01, 0xC1, 0xC1,
                    0xC1, 0xC1, 0x01, 0x01, 0x01, 0x01, 0x02, 0xFC, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x80,
                    0x00, 0x00, 0x00, 0x18, 0x38, 0x70, 0xE0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F,
                    0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xE0, 0x70, 0x38, 0x18, 0x00, 0x00, 0x00
                ]
                oled.p32(sunny, 16, 8)
            elif x == '阴':
                shadow = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                          0x00,
                          0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                          0x00,
                          0x00, 0x00, 0x01, 0x03, 0x0F, 0x1F, 0x1F, 0x3F, 0x3F, 0x7F, 0x7F, 0x3F, 0x3F, 0x1F, 0x1F,
                          0x0F,
                          0x0F, 0x1F, 0x1F, 0x1F, 0x1F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x07, 0x03, 0x01, 0x00,
                          0x00,
                          0x18, 0x7C, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
                          0xFF,
                          0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFE, 0x7C,
                          0x18,
                          0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                          0x00,
                          0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                          0x00]
                oled.p32(shadow, 16, 8)
        oled.show()


w = Weather('szsb', '55555555')

ssd1306.py

import framebuf
# 寄存器定义
SET_CONTRAST        = const(0x81)
SET_ENTIRE_ON       = const(0xa4)
SET_NORM_INV        = const(0xa6)
SET_MEM_ADDR        = const(0x20)
SET_COL_ADDR        = const(0x21)
SET_PAGE_ADDR       = const(0x22)
SET_DISP_START_LINE = const(0x40)
SET_DISP            = const(0xae)
SET_SEG_REMAP       = const(0xa0)
SET_MUX_RATIO       = const(0xa8)
SET_COM_OUT_DIR     = const(0xc0)
SET_DISP_OFFSET     = const(0xd3)
SET_COM_PIN_CFG     = const(0xda)
SET_DISP_CLK_DIV    = const(0xd5)
SET_PRECHARGE       = const(0xd9)
SET_VCOM_DESEL      = const(0xdb)
SET_CHARGE_PUMP     = const(0x8d)


class SSD1306:
    def __init__(self,external_vcc):
        self.width = 128
        self.height = 64
        self.external_vcc = external_vcc
        self.pages = 8
        self.init_display()

    def init_display(self):
        for cmd in (
            SET_DISP | 0x00, #熄屏
            SET_MEM_ADDR, 0x00, #水平寻址
            SET_DISP_START_LINE | 0x00,#显示起始行地址
            SET_SEG_REMAP | 0x01, # column addr 127 mapped to SEG0
            SET_MUX_RATIO, 63,
            SET_COM_OUT_DIR | 0x08, # scan from COM[N] to COM0
            SET_DISP_OFFSET, 0x00,
            SET_COM_PIN_CFG, 0x12,
            # timing and driving scheme
            SET_DISP_CLK_DIV, 0x80,
            SET_PRECHARGE, 0x22 if self.external_vcc else 0xf1,
            SET_VCOM_DESEL, 0x30, # 0.83*Vcc
            # display
            SET_CONTRAST, 0xff, # maximum
            SET_ENTIRE_ON, # output follows RAM contents
            SET_NORM_INV, # not inverted
            # charge pump
            SET_CHARGE_PUMP, 0x10 if self.external_vcc else 0x14,
            0x2e, # 禁止滚动
            0xae | 0x01): #开屏
            self.write_cmd(cmd)
        self.fill(0)
        self.show()
        
    def v_scroll(self, d=1): 
        self.write_cmd(0x2e) # 关闭滚动
        if d:
            self.write_cmd(0x26) # 向左
            self.write_cmd(0x00)
            self.write_cmd(0x07) # 起始页
            self.write_cmd(0x00) # 滚动帧率
            self.write_cmd(0x00) # 结束页
        else:
            self.write_cmd(0x27) # 向左
            self.write_cmd(0x00)
            self.write_cmd(0x00) # 起始页
            self.write_cmd(0x00) # 滚动帧率
            self.write_cmd(0x07) # 结束页
            
        self.write_cmd(0x00)
        self.write_cmd(0xff)
        self.write_cmd(0x2f) # 开启滚动
    
    def poweroff(self):
        self.write_cmd(const(0xae) | 0x00)#熄屏

    def contrast(self, contrast):
        self.write_cmd(SET_CONTRAST)
        self.write_cmd(contrast)

    def invert(self, invert):
        self.write_cmd(SET_NORM_INV | (invert & 1))

    def show(self):
        self.write_cmd(SET_COL_ADDR)
        self.write_cmd(0)
        self.write_cmd(127)
        self.write_cmd(SET_PAGE_ADDR)
        self.write_cmd(0)
        self.write_cmd(63)
        self.write_framebuf()

    def fill(self, c):
        self.framebuf.fill(c)

    def pixel(self, x, y, c):
        self.framebuf.pixel(x, y, c)

    def text(self, string, x, y, c=1):
        self.framebuf.text(string, x, y, c)

    def hline(self,x,y,w,c=1):
        self.framebuf.hline(x,y,w,c)
    
    def vline(self,x,y,h,c=1):
        self.framebuf.vline(x,y,h,c)
        
    def line(self,x1,y1,x2,y2,c=1):
        self.framebuf.line(x1,y1,x2,y2,c)
        
    def rect(self,x,y,w,h,c=1,f=False):
        self.framebuf.rect(x,y,w,h,c,f)
        
    def ellipse(self,x,y,xr,yr,c,f=False,m=15):
        self.framebuf.ellipse(x,y,xr,yr,c,f,m)
        
    def cube(self,x,y,l):
        self.rect(x,y,l,l)
        self.rect(x+int(0.5*l),int(y-0.5*l),l,l)
        self.line(x,y,int(x+0.5*l),int(y-0.5*l),1)
        self.line(x+l,y,int(x+1.5*l),int(y-0.5*l),1)
        self.line(x,y+l,int(x+0.5*l),int(y+0.5*l),1)
        self.line(x+l,y+l,int(x+1.5*l),int(y+0.5*l),1)
    
    def p8(self,page,x,y):
        for e in range(8):
            byte=bin(page[e]).replace('0b','')
            while len(byte)<8:
                byte='0'+byte
            for i in range(8):
                if byte[i]=='1':
                    self.pixel(x+e,y+i,int(byte[i]))
    
    def p16(self,page,x,y):
        for e in range(32):
            byte=bin(page[e]).replace('0b','')
            while len(byte)<8:
                byte='0'+byte
            for i in range(8):
                if byte[i] and e<16:
                    self.pixel(x+e,y+i,int(byte[i]))
                elif byte[i] and e>=16:
                    self.pixel(x-16+e,y+8+i,int(byte[i]))

    def p32(self,page,x,y):
        for e in range(128):
            byte=bin(page[e]).replace('0b','')
            while len(byte)<8:
                byte='0'+byte
            for i in range(8):
                if byte[i] and e<32:
                    self.pixel(x+e,y+i,int(byte[i]))
                elif byte[i] and 32<=e<64:
                    self.pixel(x+e-32,y+8+i,int(byte[i]))
                elif byte[i] and 64<=e<96:
                    self.pixel(x+e-64,y+16+i,int(byte[i]))
                elif byte[i] and 96<=e<128:
                    self.pixel(x+e-96,y+24+i,int(byte[i]))

class SSD1306_I2C(SSD1306):
    def __init__(self,i2c, addr=0x3c, external_vcc=False):
        self.i2c = i2c
        self.addr = addr
        self.temp = bytearray(2)
        # buffer需要8 * 128的显示字节加1字节命令
        self.buffer = bytearray(8 * 128 + 1)
        self.buffer[0] = 0x40  # Co=0, D/C=1
        self.framebuf = framebuf.FrameBuffer1(memoryview(self.buffer)[1:], 128, 64)
        super().__init__(external_vcc)
    def write_cmd(self, cmd):
        self.temp[0] = 0x80 # Co=1, D/C#=0
        self.temp[1] = cmd
        self.i2c.writeto(self.addr, self.temp)

    def write_framebuf(self):
        self.i2c.writeto(self.addr, self.buffer)

        

font.py

def u6674(oled,x,y):     
    oled.rect(x+1,y+2,4,11)
    oled.hline(x+2,y+7,2)
    oled.hline(x+6,y+2,9)
    oled.hline(x+7,y+4,7)
    oled.hline(x+6,y+6,9)
    oled.vline(x+10,y,7)
    oled.rect(x+7,y+8,7,8)
    oled.rect(x+7,y+10,7,3)
    oled.hline(x+8,y+15,4,0)
def u591a(oled,x,y):
    def duo1(x,y):
        oled.line(x+3,y+4,x+7,y)
        oled.hline(x+6,y+2,6)
        oled.line(x+4,y+3,x+6,y+5)
        oled.line(x+11,y+2,x+4,y+9)
    duo1(x,y)
    x+=3
    y+=6
    duo1(x,y)
def u9634(oled,x,y):
    oled.hline(x+2,y+1,11)
    oled.hline(x,y+6,15)
    oled.line(x+7,y+7,x+1,y+13)
    oled.hline(x+2,y+13,10)
    oled.line(x+9,y+10,x+13,y+14)
def u4e91(oled,x,y):
    oled.rect(x+2,y+4,11,7)
    oled.vline(x+7,y,16)
def u5927(oled,x,y):
    oled.hline(x+1,y+5,14)
    oled.vline(x+7,y+1,9)
    oled.line(x+6,y+10,x+1,y+15)
    oled.line(x+8,y+10,x+13,y+15)
    oled.pixel(x+14,y+15,1)
def u5c0f(oled,x,y):
    oled.vline(x+7,y+1,13)
    oled.line(x+5,y+6,x+1,y+10)
    oled.line(x+9,y+4,x+13,y+8)
    oled.line(x+6,y+14,x+5,y+13)
def u96e8(oled,x,y):
    oled.hline(x+1,y+1,14)
    oled.vline(x+7,y+2,13)
    oled.rect(x+1,y+5,13,11)
    oled.hline(x+2,y+15,9,0)
    oled.line(x+4,y+8,x+5,y+9)
    oled.line(x+4,y+11,x+5,y+12)
    oled.line(x+9,y+8,x+10,y+9)
    oled.line(x+9,y+11,x+10,y+12)
def u9634(oled,x,y):
    oled.vline(x+1,y+1,15)
    oled.hline(x+2,y+1,4)
    oled.line(x+5,y+2,x+2,y+5)
    oled.line(x+5,y+8,x+2,y+5)
    oled.hline(x+2,y+9,4)
    oled.vline(x+7,y+1,12)
    oled.line(x+6,y+12,x+4,y+15)
    oled.hline(x+8,y+1,5)
    oled.vline(x+13,y+1,14)
    oled.line(x+12,y+15,x+11,y+14)
    oled.rect(x+7,y+5,7,4)
def u5e7f(oled,x,y):
    oled.line(x+7,y+1,x+8,y+2)
    oled.line(x+1,y+14,x,y+15)
    oled.hline(x+2,y+3,12)
    oled.vline(x+2,y+4,10)
def u5dde(oled,x,y):
    oled.vline(x+1,y+5,3)
    oled.vline(x+3,y+1,12)
    oled.vline(x+6,y+5,3)
    oled.vline(x+8,y+2,12)
    oled.vline(x+10,y+5,3)
    oled.vline(x+12,y+1,14)
    oled.line(x+2,y+13,x+1,y+14)
def u4e0a(oled,x,y):
    oled.vline(x+6,y+1,14)
    oled.hline(x+7,y+6,6)
    oled.hline(x+1,y+14,14)
def u6d77(oled,x,y):
    oled.line(x+2,y+1,x+3,y+2)
    oled.line(x+1,y+5,x+2,y+6)
    oled.line(x+2,y+13,x+4,y+11)
    oled.line(x+9,y,x+5,y+4)
    oled.hline(x+7,y+2,7)
    oled.rect(x+7,y+4,6,9,1,True)
    oled.hline(x+5,y+8,10)
    oled.rect(x+8,y+5,4,3,0)
    oled.rect(x+8,y+9,4,3,0)
    oled.pixel(x+13,y+12,1)
    oled.vline(x+12,y+13,2)
#该字典存储着一些中文的函数指针
cc_dict={'6674':u6674,'591a':u591a,'u9634':u9634,'4e91':u4e91,'5927':u5927,'u5c0f':u5c0f,'96e8':u96e8,'9634':u9634,'5e7f':u5e7f,'5dde':u5dde,'4e0a':u4e0a,'6d77':u6d77}
#显示中文的函数,接受oled对象,要显示的中文,位置
def textc(oled,c,x,y):
    c=hex(ord(c)).replace('0x','')
    cc_dict[c](oled,x,y)
   

实现思路

从网站获取天气数据,根据文本的字典结构,为了方便,转成json进行有效信息的提取。

获取的天气状态一共有小雨,中雨,大雨,阴,晴,多云

按照天气状态分为两组,两个字的和一个字的

设置了一个查找树,对两个字的进行快速查找,优化if结构

如果选择好了天气状态,就在特定位置显示中文(16*16)和天气状态对应的图(32*32)

剩下的就是显示城市和温度了

我的代码默认是广州,你也可以更改其他城市

在font.py中,我以笔画的方式存储了天气状态对应的中文,还有‘广州’对应的中文,相当于自己建立了一个小字库,当然也可以更改为其他方式显示中文,如取模,烧写特殊固件

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/899360.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

什么是单例模式

什么是单例模式 文章目录 什么是单例模式1. 单例(单个的实例)2. 单例模式应用实例3. 饿汉式 VS 懒汉式 1. 单例(单个的实例) 所谓类的单例设计模式&#xff0c;就是采取一定的方法保证在整个的软件系统中&#xff0c;对某个类只能存在一个对象实例&#xff0c;并且该类只提供一…

STM32 定时器复习

12MHz晶振的机器周期是1us&#xff0c;因为单片机的一个机器周期由6个状态周期组成&#xff0c;1个机器周期6个状态周期12个时钟周期&#xff0c;因此机器周期为1us。 51单片机常用 for(){__nop(); //执行一个机器周期&#xff0c;若想循环n us&#xff0c;则循环n次。 }软件…

WebGL和OpenGL之间的差异

推荐&#xff1a;使用 NSDT场景编辑器助你快速搭建可二次编辑的3D应用场景 WebGL和OpenGL是与图形处理有关的技术标准&#xff0c;它们在计算机图形中扮演着重要的角色。本文将介绍WebGL和OpenGL的区别&#xff0c;并重点介绍"WebGL"和"OpenGL"的特点。 一…

系统报错mfc100u.dll丢失的解决方法(完美解决dll问题)

系统文件mfc100u.dll丢失和出错&#xff0c;极有可能是盗号木马、流氓软件等恶意程序所导致&#xff0c;其感染相关文件并加载起来&#xff0c;一旦杀毒软件删除被感染的文件&#xff0c;就会导致相关组件缺失&#xff0c;游戏等常用软件运行不起来&#xff0c;且提示“无法启动…

Log4net在.Net Winform项目中的使用

引言&#xff1a; Log4net是一个流行的日志记录工具&#xff0c;可以帮助开发人员在应用程序中实现高效的日志记录。本文将提供一个详细的分步骤示例&#xff0c;来帮助您在.Net Winform项目中使用Log4net。 目录 一、安装Log4net二、配置Log4net三、在项目中使用Log4net四、初…

外包干了2个月测试,技术退步明显...

先说一下自己的情况&#xff0c;大专生&#xff0c;18年通过校招进入湖南某软件公司&#xff0c;干了接近4年的功能测试&#xff0c;今年年初&#xff0c;感觉自己不能够在这样下去了&#xff0c;长时间呆在一个舒适的环境会让一个人堕落!而我已经在一个企业干了四年的功能测试…

9. 实现业务功能--用户登录

目录 1. 顺序图 2. 参数要求 3. 创建 Service 接口 4. 实现 Service 接口 5. 单体测试 6. 实现 Controller 7. 实现前端 在用户登录部分特别注意的是需要进行密码校验&#xff1a; 1. MD5(MD5(用户提交的原密码&#xff09;数据库查出来的用户的盐&#xff09; 密码的…

【python办公自动化】PysimpleGUI中更新Listbox组件选定元素的格式

pysimplegui中更新Listbox组件选定元素的格式 背景问题解决创建窗口布局创建窗口背景 在进行打分时候,由于打分的指标较多,因此为了辨别已经打完分数的指标,可以考虑对打过分的指标进行标记,故可以采用格式修改的方法调整,比如添加一些特殊标记 问题解决 import PySim…

K8S应用笔记 —— 部署Dolphinscheduler及简单应用(一)

一、Dolphinscheduler简介 Apache DolphinScheduler 是一个分布式易扩展的可视化DAG工作流任务调度开源系统。适用于企业级场景&#xff0c;提供了一个可视化操作任务、工作流和全生命周期数据处理过程的解决方案。 Apache DolphinScheduler 旨在解决复杂的大数据任务依赖关系…

SpringBoot 基础篇

SpringBooot基本配置 Web容器基本配置 学习了SpringBoot框架之后&#xff0c;我们了解到SpringBoot内嵌了 Tomcat、Jetty、Undertow 三种容器&#xff0c;其默认嵌入的容器是 Tomcat&#xff0c;这个在我们启动 Spring Boot 项目的时候&#xff0c;在控制台上就能看到&#x…

使用 EasyExcel 实现 百万级数据导入导出

前言 在项目开发中往往需要使用到数据的导入和导出&#xff0c;导入就是从Excel中导入到DB中&#xff0c;而导出就是从DB中查询数据然后使用POI写到Excel上。 大数据的导入和导出&#xff0c;相信大家在日常的开发、面试中都会遇到。 很多问题只要这一次解决了&#xff0c;总…

调整数组使奇数全部都位于偶数前面

题目内容&#xff1a; 输入一个整数数组&#xff0c;实现一个函数&#xff0c; 来调整该数组中数字的顺序使得数组中所有的奇数位于数组的前半部分&#xff0c; 所有偶数位于数组的后半部分。 题目思路&#xff1a; 将奇数部分放在前半部分&#xff0c;偶数部分放在后半部分&am…

PySpark-核心编程

2. PySpark——RDD编程入门 文章目录 2. PySpark——RDD编程入门2.1 程序执行入口SparkContext对象2.2 RDD的创建2.2.1 并行化创建2.2.2 获取RDD分区数2.2.3 读取文件创建 2.3 RDD算子2.4 常用Transformation算子2.4.1 map算子2.4.2 flatMap算子2.4.3 reduceByKey算子2.4.4 Wor…

手把手教你制作印刷包装小程序商城

印刷包装行业越来越受到人们的重视&#xff0c;为了更好地满足消费者的需求&#xff0c;搭建一个专属的小程序商城是一种不错的选择。那么&#xff0c;接下来就让我们一起来学习如何搭建印刷包装小程序商城吧&#xff01; 第一步&#xff1a;登录【乔拓云】网后台&#xff0c;进…

学习笔记230818---对于promise失败状态处理的重要性

问题描述&#xff1a; 在项目中经常会出现如上的问题&#xff0c;这是因为&#xff0c;用promise封装的接口或第三方组件方法&#xff0c;如果只对成功的状态做处理&#xff0c;就会造成页面出错&#xff0c;报error。 解决方法 then()的末尾加上.catch(()>{})对失败的状态…

3.小程序的通信模型

通信主体 小程序中通信的主体是渲染层和逻辑层&#xff0c;其中&#xff1a; xxx.scss和xxx.wxml是渲染层 xxx.ts是逻辑层 通信模型 小程序的通信模型发为两部分&#xff1a; 渲染层和逻辑层之间的通信由微信客户端进行转发 逻辑层和第三方服务器之前的通信由微信客户端进行…

Maven介绍_下载_安装_使用_原理

文章目录 1 Maven介绍1.1 Maven是介绍1.2 Maven的作用 2 Maven下载与安装2.1 官网下载2.2 文件目录2.3 环境配置 3 Maven基础概念3.1 仓库分类3.2 依赖坐标3.3 坐标组成 4 Maven配置4.1 本地仓库配置4.2 远程仓库的设置4.3 镜像仓库配置4.4 IDEA配置Maven 5 Maven项目创建5.1 M…

robotframework如何做接口测试?

robotframework(后续简称为robot)是一款自动化测试框架&#xff0c;可能做各种类型的自动化测试。 本文介绍通过robotframework来做接口测试。 在robot当中&#xff0c;python语言的接口测试库名称为RequestsLibrary 安装语法如下&#xff1a; pip install -U requests pip …

AP5414 DC-DC升压恒流 升降压电源驱动IC

产品简介 AP5414 是一种输入电压范围宽&#xff08;0.8~5.5V&#xff09;&#xff0c;可调恒定电流和限定电流两种模式来 驱动白光 LED 而设计的升压型 DC/DC 变换器。该器件能利用单节或双节干电池驱动单 颗大功率白光 LED&#xff0c;同样可以利用一节锂电池驱动两颗、三颗…

基于Opencv的虚拟拖拽项目

预备知识 勾股定理 跟随移动算法 手势识别图解 项目源代码 """ 演示一个简单的虚拟拖拽 步骤&#xff1a; 1、opencv 读取视频流 2、在视频图像上画一个方块 3、通过mediapipe库获取手指关节坐标 4、判断手指是否在方块上 5、是&#xff0c;方块跟着移动 6、…