【雕爷学编程】MicroPython动手做(15)——掌控板之AB按键3

news2024/11/17 9:39:01

知识点:什么是掌控板?
掌控板是一块普及STEAM创客教育、人工智能教育、机器人编程教育的开源智能硬件。它集成ESP-32高性能双核芯片,支持WiFi和蓝牙双模通信,可作为物联网节点,实现物联网应用。同时掌控板上集成了OLED显示屏、RGB灯、加速度计、麦克风、光线传感器、蜂鸣器、按键开关、触摸开关、金手指外部拓展接口,支持图形化及MicroPython代码编程,可实现智能机器人、创客智造作品等智能控制类应用。

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

掌控板硬件特性:
ESP-32主控
处理器:Tensilica LX6双核处理器(一核处理高速连接;一核独立应用开发)
主频:高达240MHz的时钟频率
SRAM:520KB
Flash:8MB
Wi-Fi标准:FCC/CE/TELEC/KCC
Wi-Fi协议:802.11 b/g/n/d/e/i/k/r (802.11n,速度高达150 Mbps),A-MPDU和A-MSDU聚合,支持0.4us防护间隔
频率范围:2.4~2.5 GHz
蓝牙协议:符合蓝牙v4.2 BR/EDR和BLE标准
蓝牙音频:CVSD和SBC音频低功耗:10uA
供电方式:Micro USB供电
工作电压:3.3V
最大工作电流:200mA
最大负载电流:1000mA
掌控板载
三轴加速度计MSA300,测量范围:±2/4/8/16G
地磁传感器MMC5983MA,测量范围:±8 Gauss;精度0.4mGz,电子罗盘误差±0.5°
光线传感器
麦克风
3 颗全彩ws2812灯珠
1.3英寸OLED显示屏,支持16*16字符显示,分辨率128x64
无源蜂鸣器
支持2个物理按键(A/B)、6个触摸按键
支持1路鳄鱼夹接口,可方便接入各种阻性传感器
拓展接口
20通道数字I/O, (其中支持12路PWM,6路触摸输入)
5通道12bit模拟输入ADC,P0~P4
1路的外部输入鳄鱼夹接口:EXT/GND
支持I2C、UART、SPI通讯协议

在这里插入图片描述
在这里插入图片描述
1、按键开关
主要是指轻触式按键开关,也称之为轻触开关。按键开关是一种电子开关,属于电子元器件类,最早出现在日本[称之为:敏感型开关],使用时以满足操作力的条件向开关操作方向施压开关功能闭合接通,当撤销压力时开关即断开,其内部结构是靠金属弹片受力变化来实现通断的。按键开关由嵌件、基座、弹片、按钮、盖板组成,其中防水类轻触开关在弹片上加一层聚酰亚胺薄膜。

按键开关有接触电阻荷小、精确的操作力误差、规格多样化等方面的优势,在电子设备及白色家电等方面得到广泛的应用如:影音产品、数码产品、遥控器、通讯产品、家用电器、安防产品、玩具、电脑产品、健身器材、医疗器材、验钞笔、雷射笔按键等等。因为按键开关对环境的条件(施压力小于2倍的弹力/环境温湿度条件以及电气性能)大型设备及高负荷的按钮都使用导电橡胶或锅仔开关五金弹片直接来代替,比如医疗器材、电视机遥控器等。

关于五脚按键开关的脚位问题:两个引脚为一组,向开关体正确施压时四个引脚相导通,第五个引脚为接地作用。

按键开关是随着电子技术发展的要求而开发的第四代开关产品,最早的体积为12mm12mm,8mm8mm两种,现在为6mm6mm。产品结构有立式、卧式和卧式带地端三种,现在又有组合式(3M、4M、SM、6M、SM)和电位器按键开关组合两类,满足国内各种电子产品要求。安装尺寸有6.5mm4.5mm,5.5mm4mm和6mm4mm三种。国外已有4.5mm*4.5mm小型按键开关和片式按键开关,片式按键开关适合于表面组装。

现在已有第五代开关—薄膜开关,功能与按键开关相同,主要用于电子仪器和数控机床,但电阻大、手感差。为了克服手感差的现象,也有在薄膜开关内不是用银层做接触点,而是装上接触簧片。

按键开关分成两大类:利用金属簧片作为开关接触片的称按键开关,接触电阻小,手感好,有“滴答”清脆声。利用导电橡胶作为接触通路的开关习惯称为导电橡胶开关。开关手感好,但接触电阻大,一般在100一300n。按键开关的结构是靠按键向下移动,使接触簧片或导电橡胶块接触焊片,形成通路。

按键开关的操作力与簧片所处的状态有关。开始力与簧片的压缩的距离成正比当簧片压缩到5%一70%时操作力突然减少,并伴有“滴答”声。导龟橡胶开关一般有两种结构。操作力曲线随橡胶块的几何形状不同而有很大的差异。

相对湿度:<95%
额定电压:12V
额定电流:50mA
温度:-25~70℃

按键开关的主要用途有彩色电视机、黑白电视机、音响设备、录像机、摄像机、计算机、游戏机、传真机、对讲机、警棍、机床控制装置、复印、打印机、电子仪器、仪表和其它家用电器。

在这里插入图片描述

2、在掌控板上部边沿有按压式A、B两个按键

当按下按键时为低电平,否则高电平。在掌控板A,B按键按下的过程如下述,当按下时,电平从高变低,在高电平(1)变为低电平(0)的那一瞬间叫作下降沿。当按键松开时,电平从低变高,在低电平(0)变为高电平(1)的那一瞬间叫作上升沿。 我们可以通过获取电平变化来获取,当前按键状态。
P5、P11是掌控板的按键A、B的IO引脚,为避免冲突,限定拓展板的P5、P11引脚只能用于数字电平输入,且拓展板会对输入电平进行翻转。

在这里插入图片描述

在这里插入图片描述
11、A、B键控制图片转换显示

#MicroPython动手做(15)——掌控板之AB按键
#A、B键控制图片转换显示

from mpython import *
import music

def callback_button_a_pressed():
  oled.fill(0)
  bmp_wZZv = bytearray([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,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,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfb,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xe3,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x89,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x19,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x39,0xff,0xff,0xff,0xff,0xff,0xff,0xf8,0x0,0x3f,0xff,0xff,0xff,0xff,0xff,0xfe,0x79,0xff,0xff,0xff,0x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,0x0,0x3f,0xff,0xfc,0xf9,0xff,0xff,0xff,0xbf,0xff,0xff,0xc1,0xff,0x87,0xff,0xff,0xff,0xff,0xff,0xfc,0xf9,0xff,0xff,0xff,0xff,0xff,0xff,0xf0,0x0,0x1f,0xff,0xff,0xff,0xff,0xff,0xfc,0xf9,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xe7,0xff,0xff,0xff,0xff,0xff,0xff,0xfe,0xf9,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfe,0x79,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x39,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x99,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xc1,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xe3,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfb,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,0xff,0xff,0xff,0xff,0xff,0xff,0xff])
  oled.Bitmap(0, 0, bmp_wZZv, 128, 64, 1)
  oled.show()


def callback_button_b_pressed():
  oled.fill(0)
  bmp_h61P = bytearray([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,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xdf,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xc7,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x83,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x99,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x9c,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x9e,0x7f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x9f,0x7f,0xff,0xff,0xff,0xff,0xff,0xff,0xe7,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x9f,0x3f,0xff,0xff,0xff,0xff,0xff,0xf8,0x0,0xf,0xff,0xff,0xff,0xff,0xff,0xff,0x9f,0x3f,0xff,0xff,0xff,0xff,0xff,0xe1,0xff,0x83,0xff,0xff,0xfd,0xff,0xff,0xff,0x9f,0x3f,0xff,0xfc,0x0,0x0,0x0,0x7,0xff,0xc0,0xff,0xff,0xf0,0x7f,0xff,0xff,0x9f,0x3f,0xff,0xfc,0x0,0x0,0x0,0x1f,0xfc,0x0,0x7f,0xff,0xe6,0x0,0x1f,0xff,0x9f,0x3f,0xff,0xf9,0xff,0xcf,0xfe,0x3f,0xf0,0xff,0x1f,0xff,0xc0,0x0,0x7,0xff,0x9f,0x7f,0xf0,0x1,0xff,0xcf,0xfc,0x7f,0xe7,0xff,0x9f,0xc0,0x0,0x0,0x3,0xff,0x9e,0x60,0x0,0x1,0xff,0xcf,0xfc,0xff,0x8f,0xff,0xce,0x3,0xff,0xf0,0x1,0xff,0x9f,0x0,0x0,0x1,0xff,0xcf,0xf9,0xff,0x9f,0xff,0xe0,0x7f,0xff,0xf8,0x0,0xff,0x9f,0x0,0x0,0x1,0xff,0xcf,0xf1,0xff,0x3f,0xff,0xe3,0xff,0xff,0xf8,0x0,0x7f,0x9f,0x0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xff,0x0,0xf,0xe0,0xff,0xff,0xf0,0x0,0x7,0x9f,0x7e,0x0,0x1,0xff,0xcf,0xf9,0xff,0x83,0xff,0xce,0x3,0xff,0xe0,0x0,0x7f,0x9f,0x7f,0xfc,0x1,0xff,0xcf,0xfc,0xff,0xc3,0xff,0xcf,0xc0,0x0,0x0,0x1,0xff,0x9f,0x3f,0xff,0xf9,0xff,0xcf,0xfe,0x7f,0xe3,0xff,0x9f,0xff,0x80,0x0,0x7,0xff,0x9f,0x3f,0xff,0xfd,0xff,0xcf,0xff,0x3f,0xf0,0x7e,0x3f,0xff,0xe7,0x0,0x1f,0xff,0x9f,0x3f,0xff,0xfc,0x0,0x0,0x0,0xf,0xfe,0x0,0x7f,0xff,0xf0,0x3f,0xff,0xff,0x9f,0x3f,0xff,0xfe,0x0,0x0,0x0,0x7,0xff,0xc1,0xff,0xff,0xfc,0xff,0xff,0xff,0x9f,0x7f,0xff,0xff,0xff,0xff,0xff,0xf0,0x58,0x7,0xff,0xff,0xff,0xff,0xff,0xff,0x9e,0x7f,0xff,0xff,0xff,0xff,0xff,0xfc,0x0,0x1f,0xff,0xff,0xff,0xff,0xff,0xff,0x9c,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x98,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x91,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xc7,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xdf,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,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,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff])
  oled.Bitmap(0, 0, bmp_h61P, 128, 64, 1)
  oled.show()


def on_button_a_pressed():
  while True:
    if button_a.value() == 0:
      yield callback_button_a_pressed()
    else:
      yield

def on_button_b_pressed():
  while True:
    if button_b.value() == 0:
      yield callback_button_b_pressed()
    else:
      yield

func_button_a_pressed = on_button_a_pressed()
func_button_b_pressed = on_button_b_pressed()
while True:
  next(func_button_a_pressed)
  next(func_button_b_pressed)

Mind+ 图形编程
在这里插入图片描述
在这里插入图片描述

12、AB按键切换声光值与三轴数值

#MicroPython动手做(15)——掌控板之AB按键
#AB按键切换声光值与三轴数值

#MicroPython动手做(15)——掌控板之AB按键
#AB按键切换显示声光值与三轴数值

from mpython import *
import time

def on_button_a_down(_):
    global sensor, switch
    time.sleep_ms(10)
    if button_a.value() == 1: return
    switch = switch + -1
    if switch < 0:
        switch = 2

def on_button_b_down(_):
    global sensor, switch
    time.sleep_ms(10)
    if button_b.value() == 1: return
    switch = switch + 1
    if switch > 2:
        switch = 0

button_a.irq(trigger=Pin.IRQ_FALLING, handler=on_button_a_down)

button_b.irq(trigger=Pin.IRQ_FALLING, handler=on_button_b_down)


switch = 0
oled.fill(0)
oled.DispChar("上一个", 0, 0, 1)
oled.DispChar("下一个", 91, 0, 1)
while True:
    oled.fill_rect(0, 16, 128, 48, 0)
    if switch == 1:
        oled.DispChar((str("声音值:") + str(sound.read())), 30, 28, 1)
    elif switch == 2:
        oled.DispChar((str(" 光线值:") + str(light.read())), 25, 28, 1)
    else:
        oled.DispChar((str("X 轴:") + str(accelerometer.get_x())), 15, 15, 1)
        oled.DispChar((str("Y 轴:") + str(accelerometer.get_y())), 15, 30, 1)
        oled.DispChar((str("Z 轴:") + str(accelerometer.get_z())), 15, 45, 1)
    oled.show()

mPython X 图形编程

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

13、AB按键秒表计时器

秒表主要是用来统计秒数的。它有一般有两个按键。A键和B键。
第一次按下A键时,开始计时。
第二次按下A键时,暂停计时。
再按下A键时,继续上一步暂停的计时。
按下B键,归零。

#MicroPython动手做(15)——掌控板之AB按键
#AB按键秒表计时器

#MicroPython动手做(15)——掌控板之AB按键
#AB按键秒表计时器from mpython import *

import framebuf

import font.digiface_44

import time

from machine import Timer

def timer1_tick(_):
    global aaa, ttt
    ttt = ttt + 1
    oled.fill(0)
    display_font(font.digiface_44, (''.join([str(x) for x in [ttt // 60, ':', ttt % 60]])), 2, 8, False, 2)
    oled.show()

tim1 = Timer(1)

def on_button_a_down(_):
    global aaa, ttt
    time.sleep_ms(10)
    if button_a.value() == 1: return
    if aaa == 1:
        aaa = 0
        tim1.init(period=1000, mode=Timer.PERIODIC, callback=timer1_tick)
    else:
        aaa = 1
        tim1.deinit()

def on_button_b_down(_):
    global aaa, ttt
    time.sleep_ms(10)
    if button_b.value() == 1: return
    ttt = 0
    oled.fill(0)
    display_font(font.digiface_44, '00:00', 2, 8, False, 2)
    oled.show()
    aaa = 1
    tim1.deinit()

def display_font(_font, _str, _x, _y, _wrap, _z=0):
    _start = _x
    for _c in _str:
        _d = _font.get_ch(_c)
        if _wrap and _x > 128 - _d[2]: _x = _start; _y += _d[1]
        if _c == '1' and _z > 0: oled.fill_rect(_x, _y, _d[2], _d[1], 0)
        oled.blit(framebuf.FrameBuffer(bytearray(_d[0]), _d[2], _d[1],
        framebuf.MONO_HLSB), (_x+int(_d[2]/_z)) if _c=='1' and _z>0 else _x, _y)
        _x += _d[2]

button_a.irq(trigger=Pin.IRQ_FALLING, handler=on_button_a_down)

button_b.irq(trigger=Pin.IRQ_FALLING, handler=on_button_b_down)
oled.fill(0)
display_font(font.digiface_44, '00:00', 2, 8, False, 2)
oled.show()
ttt = 0
aaa = 1

mPython 图形编程
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

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

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

相关文章

IDEA将本地项目上传到码云

一、创建本地仓库并关联 用IDEA打开项目&#xff0c;在菜单栏点击vcs->create git repository创建本地仓库&#xff0c; 选择当前项目所在的文件夹当作仓库目录。 二、将项目提交本地仓库 项目名右键就会出现“GIT”这个选项->Add->Commit Directory, 先将项目add…

ORCA优化器浅析——QueryToDXL(CDXLLogical+CDXLScalar)主流程

Orca是Pivotal数据管理产品的新查询优化器&#xff0c;包括GPDB和HAWQ。Orca是一个基于Cascades操作时序框架的现代自上而下的查询优化器。虽然许多Cascades优化器与其主机系统紧密耦合&#xff0c;但Orca的一个独特功能是它能够作为独立的优化器在数据库系统之外运行。这种能力…

C++代码格式化工具clang-format详细介绍

文章目录 clang-format思考代码风格指南生成您的配置运行 clang-format禁用一段代码的格式设置clang-format的设置预览 clang-format 我曾在许多编程团队工作过&#xff0c;这些团队名义上都有“编程风格指南”。该指南经常被写下来并放置在开发人员很少查看的地方。几乎在每种…

ios 查看模拟器沙盒的路径

打一个断点运行程序&#xff0c;在xcode consol底部控制台输入&#xff1a; po NSHomeDirectory() 复制路径粘帖到前往文件夹打开沙盒缓存文件夹

Dig the way

前言 什么时候才能乱杀比赛的题啊,给了两个文件第一个是师傅使用ida反编译的数据库文件&#xff0c;有提示但不多&#xff0c;主要还是看程序吧 分析 程序从文件读取输入值&#xff0c;虽然结果和输入无关但是要用到输入时产生的一些触发条件&#xff0c;所以动态强行输出fl…

AI帮你制作海报

介绍 Microsoft Designer是由微软推出的图像处理软件&#xff0c;能够通过套用模板等方式快速完成设计加工&#xff0c;生成能够在社交媒体使用的图片。Designer的使用更为简单便捷&#xff0c;用户能够通过套用模板等方式快速完成设计加工&#xff0c;生成能够在社交媒体使用…

LLaMA模型论文《LLaMA: Open and Efficient Foundation Language Models》阅读笔记

文章目录 1. 简介2.方法2.1 预训练数据2.2 网络架构2.3 优化器2.4 高效的实现 3.论文其余部分4. 参考资料 1. 简介 LLaMA是meta在2023年2月开源的大模型&#xff0c;在这之后&#xff0c;很多开源模型都是基于LLaMA的&#xff0c;比如斯坦福大学的羊驼模型。 LLaMA的重点是比…

Vue如何实现编程式导航声明方法,前进和后退导航

编程式导航声明方法&#xff0c;前进和后退导航 在router中设置路由导航跳转函数 只要发生跳转 导航的声明函数 访问控制系统如何形成 就这三种 导航守卫的案例&#xff0c;写一个Main.Vue 和login .Vue 后台主页 如果想要展示后台主页&#xff0c;就用这种方法 想实现路由跳转…

linux查看服务器系统版本命令

有时我们需要在linux服务器上安装DB、Middleware等&#xff0c;为了保证兼容性&#xff0c;我们需要知晓被提供的linux服务器版本是否满足需求&#xff0c;下面就说一说linux查看服务器系统版本命令。 1.cat /etc/redhat-release 适用于&#xff1a;rhel/centos等 2.cat /etc…

基于minio的dababend部署总结

Databend 是一款开源、弹性、低成本&#xff0c;基于对象存储也可以做实时分析的新式数仓。期待您的关注&#xff0c;一起探索云原生数仓解决方案&#xff0c;打造新一代开源 Data Cloud。 Minio搭建 minio 192.168.10.159 cd /data mkdir minio cd minio wget https://dl…

vue3+vite——打测试包+正式包+本地预览打包后的文件——基础积累

最近在学习vue3vite的内容&#xff0c;发现vite和webpack类似&#xff0c;下面将区别及使用方法做一下记录&#xff1a; 1.vite添加环境配置文件 ... ├── src ... ├── .env # 通用环境变量配置 ├── .env.development …

基于Open3D的点云处理0-测试所用数据下载

地址&#xff1a;github 20220201-data 20220301-data

C. Binary String Copying - 思维

分析&#xff1a; 赛时我是直接模拟的&#xff0c;tle然后mle&#xff0c;补提&#xff0c;发现规律&#xff0c;每一个改变的字符串都只会对应一个需要改变的区间&#xff0c;例如第一个样例前两个101100 -> 011100和101100 -> 011100&#xff0c;对应区间在确定改变的范…

[个人笔记] Windows配置NTP时间同步

Windows - 运维篇 第六章 Windows配置NTP时间同步 Windows - 运维篇系列文章回顾Windows配置NTP时间同步域控环境的NTP配置工作组环境的NTP配置Windows的CMD部分命令集 参考来源 系列文章回顾 第一章 迁移WinSrv系统到虚拟机 第二章 本地安全策略xcopy实现实时备份文件夹内容 …

【Docker 学习笔记】Windows Docker Desktop 安装

文章目录 一、前言二、Windows Docker 安装1. 基于Hyper-V后端和Windows容器的安装2. 基于WSL2后端的安装&#xff08;推荐&#xff09;3. 安装Docker Desktop on Windows4. 启动并验证Docker Desktop 一、前言 Docker并非是一个通用的容器工具&#xff0c;它依赖于已存在并运…

Linux C语言实践eBPF

手动编译了解过程 通过对关键步骤make Msamples/bpf的实践&#xff0c;我们已经可以编译出内核源码中提供的ebpf样例。但这还不够我们充分地理解这个编译过程&#xff0c;我们将这编译过程拆解一下&#xff0c;拆解成可以一步步执行的那种&#xff0c;首先是环境准备&#xff…

算法通关村第二关——两两交换链表中的节点的问题解析

题目类型 链表反转 题目描述 给你一个链表&#xff0c;两两交换其中相邻的节点&#xff0c;并返回交换后链表的头节点&#xff0c;且必须在不修改节点内部的值的情况下完成本题&#xff0c;即&#xff1a;只能进行节点交换 效果图 题目分析 如果原始顺序是 dummy(虚拟头节点) …

JavaSE复盘2

Collection接口的接口对象集合&#xff08;单列集合&#xff09; List接口&#xff1a;元素按照先后有序保存&#xff0c;可重复 LinkList接口实现类&#xff0c;链表&#xff0c;随机访问&#xff0c;没有同步&#xff0c;线程不安全ArrayList接口实现类&#xff0c;数组&…

❤️创意网页:打造炫酷网页 - 旋转彩虹背景中的星星动画

✨博主&#xff1a;命运之光 &#x1f338;专栏&#xff1a;Python星辰秘典 &#x1f433;专栏&#xff1a;web开发&#xff08;简单好用又好看&#xff09; ❤️专栏&#xff1a;Java经典程序设计 ☀️博主的其他文章&#xff1a;点击进入博主的主页 前言&#xff1a;欢迎踏入…

iOS - 检测项目中无用类和无用图片

一、无引用图片检测 LSUnusedResources 安装插件 LSUnusedResources &#xff0c;用【My Mac】模拟器运行,如下图&#xff1a; Project Path 就是项目所在的路径&#xff0c;然后点击右下角 Search按钮&#xff0c;就可以看到被搜索出来的图片资源。 注意&#xff1a;这里被搜…