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

知识点:什么是掌控板?
掌控板是一块普及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,0xff,0xff,0xff,0xe0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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,0x0,0x1,0xff,0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0,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 图形编程
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

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

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

win10日程怎么同步到安卓手机?电脑日程同步到手机方法

在如今快节奏的生活中&#xff0c;高效地管理时间变得至关重要。而对于那些经常在电脑上安排日程的人来说&#xff0c;将这些重要的事务同步到手机上成为了一个迫切的需求。因为目前国内使用win10系统电脑、安卓手机的用户较多&#xff0c;所以越来越多的职场人士想要知道&…

macos下安装john the ripper并配置zip2john+破解加密zip文件

为了破解加密的zip文件&#xff0c;需要用到john进行爆破密码。 1、首先使用homebrew安装john&#xff0c;可以安装它的增强版john-jumbo: brew install john-jumbo 2、安装后可以使用 john 命令验证&#xff1a; john 3、配置zip2john的环境——.zshrc下&#xff0c;&#x…

HashMap查找

文章目录 1 哈希表的基本概念1.1 两个例子1.2 如何查找1.3 若干术语 2 哈希函数的构造方法2.1 直接定址法2.2 除留余数法 3 处理冲突的方法3.1 开放地址法3.1.1 线性探测法3.1.2 二次探测法3.1.3 伪随机探测法 3.2 链地址法&#xff08;拉链法&#xff09;3.2.1 创建步骤3.2.2 …

C#..上位机软件的未来是什么?

C#是一种流行的编程语言&#xff0c;广泛应用于桌面应用程序和上位机软件开发。未来&#xff0c;C#上位机软件将继续不断发展和创新&#xff0c;以满足用户日益增长的需求。以下是我认为C#上位机软件未来可能会涉及的一些方向&#xff1a; 更加智能化&#xff1a;随着人工智能…

idea连接远程服务器上传war包文件

idea连接远程服务器&上传war包 文章目录 idea连接远程服务器&上传war包1. 连接服务器2.上传war包 1. 连接服务器 选择Tools -> Start SSH Session 添加配置 连接成功 2.上传war包 Tools -> Deployment -> Browse Remote Host 点击右侧标签&#xff0c;点击&…

Manjaro KDE 22.1.3vmware无法复制文件

Wayland 是 X11 的现代替代品&#xff0c;几十年来 X11 一直是 Linux 上的默认窗口系统。 Wayland 是一种通信协议&#xff0c;定义 X Window 显示服务器和客户端应用程序之间的消息传递。 软件还不兼容 使用X11即可

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

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

java static修饰的静态成员

静态成员 特点&#xff1a; 1.静态成员可以被本类所有对象共享2.静态成员可以通过类名调用也可以推荐对象调用&#xff0c;但是推荐使用类名调用&#xff01;3.静态成员随着类的加载而加载&#xff0c;优先于对象存在的静态方法的注意事项&#xff1a; 1.非静态方法可以访问任…

大数据Flink(四十九):框架版本介绍和编程语言选择

文章目录 框架版本介绍和编程语言选择 一、框架版本介绍 二、编程语言选择 框架版本介绍和编程语言选择

1-Linux的目录结构

Linux的目录结构是规定好的&#xff0c;不可以随意进行更改&#xff01; Linux的文件系统是采用级层式的树状目录结构&#xff0c;最上层是根目录–/&#xff0c;然后再在根目录下创建其它的目录。 各个目录中主要负责的功能和作用如下&#xff1a;&#xff08;主体的结构一定…

Cisco 路由器配置管理

大多数网络中断的最常见原因是错误的配置更改。对网络设备配置的每一次更改都伴随着造成网络中断、安全问题甚至性能下降的风险。计划外更改使网络容易受到意外中断的影响。 Network Configuration Manager 网络更改和配置管理 &#xff08;NCCM&#xff09;解决方案&#xff…

springboot编写mp4视频播放接口

简单粗暴方式 直接读取指定文件&#xff0c;用文件流读取视频文件&#xff0c;输出到响应中 GetMapping("/display1/{fileName}")public void displayMp41(HttpServletRequest request, HttpServletResponse response,PathVariable("fileName") String fi…

掌握文件锁:使用flock实现多个进程之间的无缝文件同步

使用flock实现多个进程之间的无缝文件同步&#xff1f; 博主简介一、引言二、文件锁的概述2.1、定义文件锁2.2、文件锁的种类2.3、文件锁的作用 三、使用flock实现文件锁3.1、flock的简介3.2、flock的使用方法3.3、flock文件锁命令3.4、flock对文件同步的帮助 四、实现多个进程…

GRE TAP的工作原理与5G工业物联网中的应用

随着互联网新技术的发展以及智能化水平的提高&#xff0c;各企业对实时数据传输的需求也在不断提升&#xff0c;企业愈发重视数据中心的建设&#xff0c;以保障企业内网数据安全。 GRE&#xff08;Generic Routing Encapsulation&#xff0c;通用路由封装&#xff09;协议属于…

物理机安装ESXI时遇到No Network Adapters

前不久在虚拟机下安装完成了ESXI&#xff0c;果断地使用了&#xff0c;确实很不错了&#xff0c; 配合我上次发的密匙&#xff08;https://www.cnntt.com/archives/5556&#xff09;妥妥爽。 虚拟机中试玩了一下&#xff0c;就开始布置到我的物理机上了&#xff0c;毕竟我以后…

【LeetCode】142.环形链表Ⅱ

题目 给定一个链表的头节点 head &#xff0c;返回链表开始入环的第一个节点。 如果链表无环&#xff0c;则返回 null。 如果链表中有某个节点&#xff0c;可以通过连续跟踪 next 指针再次到达&#xff0c;则链表中存在环。 为了表示给定链表中的环&#xff0c;评测系统内部…

无涯教程-jQuery - Highlight方法函数

Highlight 效果可以与effect()方法一起使用。这将以特定的颜色突出显示元素的背景&#xff0c;默认为黄色(yellow)。 Highlight - 语法 selector.effect( "highlight", {arguments}, speed ); 这是所有参数的描述- color - 高亮显示颜色。默认值为"#fff…

(八九)如何与InfluxDB交互InfluxDB HTTP API

以下内容来自 尚硅谷&#xff0c;写这一系列的文章&#xff0c;主要是为了方便后续自己的查看&#xff0c;不用带着个PDF找来找去的&#xff0c;太麻烦&#xff01; 第 8 章 前言&#xff1a;如何与InfluxDB交互 1、InfluxDB启动后&#xff0c;会向外提供一套HTTP API。外部程…

【Rust教程 | 基础系列 | Cargo工具】Cargo介绍及使用

文章目录 前言一&#xff0c;Cargo介绍1&#xff0c;Cargo安装2&#xff0c;创建Rust项目2&#xff0c;编译项目&#xff1a;3&#xff0c;运行项目&#xff1a;4&#xff0c;测试项目&#xff1a;5&#xff0c;更新项目的依赖&#xff1a;6&#xff0c;生成项目的文档&#xf…

Nacos的搭建及服务调用

文章目录 一、搭建Nacos服务1、Nacos2、安装Nacos3、Docker安装Nacos 二、OpenFeign和Dubbo远程调用Nacos的服务1、搭建SpringCloudAlibaba的开发环境1.1 构建微服务聚合父工程1.2 创建子模块cloud-provider-payment80011.3 创建子模块cloud-consumer-order80 2、远程服务调用O…