Python脚本为美术馆安装的间歇锁,去掉热敏相机的传感器读取功能似乎能工作吗?

2024-06-01 01:43:23 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个在艺术博物馆安装的python脚本,可以连续播放声音,驱动LED矩阵,通过OpennCV和热敏相机感知人。你知道吗

脚本的每一部分都可以工作,所有部分都可以一起工作,但是脚本会随机锁定,我需要重新启动它。我想脚本不锁定,所以没有人必须重置它在展览期间。你知道吗

我有一个备用的树莓圆周率和备用LED矩阵上运行的代码,它继续通过罚款周期。我所做的唯一更改是注释掉一个线程的开始,以检查红外传感器,并调用一个函数从传感器获取最高温度。你知道吗

要清楚的是,如果我在脚本中保留这些代码位,它可以正常运行1-3次,有时甚至10次。但当IRcount = 0时,它似乎锁定在第一个“状态”

我卡住了。非常感谢您的帮助。你知道吗

```
#!/usr/bin/python
import glob
import queue
import sys
import pygame
import cv2
import random
import math
import colorsys
import time
from rpi_ws281x import *
from PIL import Image
import numpy as np
import threading
global thresh

sys.path.insert(0, "/home/pi/irpython/build/lib.linux-armv7l-3.5")
import MLX90640 as mlx

currentTime = int(round(time.time() * 1000))
InflateWait = int(round(time.time() * 1000))
minTime = 6000
maxTime = 12000
lineHeight1 = 0
lineHue1 = float(random.randrange(1,360))/255

# IR Functions

# Function to just grab the Max Temp detected. If over threshold then start
# the sequence, if not stay in state 0
def maxTemp():
  mlx.setup(8) #set frame rate of MLX90640

  f = mlx.get_frame()

  mlx.cleanup()

  # get max and min temps from sensor
  # v_min = min(f)
  v_max = int(max(f))
  return v_max

# Function to detect individual people's heat blob group of pixels
# run in a thread only at the end of the script
def irCounter():
    img = Image.new( 'L', (24,32), "black") # make IR image

    mlx.setup(8) #set frame rate of MLX90640

    f = mlx.get_frame()

    mlx.cleanup()

    for x in range(24):
        row = []
        for y in range(32):
            val = f[32 * (23-x) + y]
            row.append(val)
            img.putpixel((x, y), (int(val)))

    # convert raw temp data to numpy array
    imgIR = np.array(img)

    # increase the 24x32 px image to 240x320px for ease of seeing
    bigIR = cv2.resize(depth_uint8, dsize=(240,320), interpolation=cv2.INTER_CUBIC)

    # Use a bilateral filter to blur while hopefully retaining edges
    brightBlurIR = cv2.bilateralFilter(bigIR,9,150,150)

    # Threshold the image to black and white 
    retval, threshIR = cv2.threshold(brightBlurIR, 26, 255, cv2.THRESH_BINARY)

    # Define kernal for erosion and dilation and closing operations
    kernel = np.ones((5,5),np.uint8)

    erosionIR = cv2.erode(threshIR,kernel,iterations = 1)

    dilationIR = cv2.dilate(erosionIR,kernel,iterations = 1)

    closingIR = cv2.morphologyEx(dilationIR, cv2.MORPH_CLOSE, kernel)

    # Detect countours
    contours, hierarchy = cv2.findContours(closingIR, cv2.RETR_TREE, cv2.CHAIN_APPROX_NONE)

    # Get the number of contours ( contours count when touching edge of image while blobs don't)
    ncontours = str(len(contours))

    # Show images in window during testing
    cv2.imshow("Combined", closingIR)

    cv2.waitKey(1)

#initialize pygame
pygame.init()
pygame.mixer.init()
pygame.mixer.set_num_channels(30)
print("pygame initialized")

# assign sound chennels for pygame
channel0 = pygame.mixer.Channel(0)
channel1 = pygame.mixer.Channel(1)
channel2 = pygame.mixer.Channel(2)
channel3 = pygame.mixer.Channel(3)
channel4 = pygame.mixer.Channel(4)
channel5 = pygame.mixer.Channel(5)
channel6 = pygame.mixer.Channel(6)
channel7 = pygame.mixer.Channel(7)
channel8 = pygame.mixer.Channel(8)
channel9 = pygame.mixer.Channel(9)
channel10 = pygame.mixer.Channel(10)
channel11 = pygame.mixer.Channel(11)
channel12 = pygame.mixer.Channel(12)
channel13 = pygame.mixer.Channel(13)
channel14 = pygame.mixer.Channel(14)
channel15 = pygame.mixer.Channel(15)
channel16 = pygame.mixer.Channel(16)
channel17 = pygame.mixer.Channel(17)
channel18 = pygame.mixer.Channel(18)
channel19 = pygame.mixer.Channel(19)
channel20 = pygame.mixer.Channel(20)
channel21 = pygame.mixer.Channel(21)
channel22 = pygame.mixer.Channel(22)
channel23 = pygame.mixer.Channel(23)
channel24 = pygame.mixer.Channel(24)
channel25 = pygame.mixer.Channel(25)
channel26 = pygame.mixer.Channel(26)
channel27 = pygame.mixer.Channel(27)
channel28 = pygame.mixer.Channel(28)


# load soundfiles
echoballs = pygame.mixer.Sound("/home/pi/ruff-wavs/sounds/echo balls FIX.ogg")
organbounce = pygame.mixer.Sound("/home/pi/ruff-wavs/sounds/ORGAN BOUNCE fix.ogg")
jar = pygame.mixer.Sound("/home/pi/ruff-wavs/sounds/jar whoop fix.ogg")
garland = pygame.mixer.Sound("/home/pi/ruff-wavs/sounds/GARLAND_fix.ogg")
dribble= pygame.mixer.Sound("/home/pi/ruff-wavs/sounds/dribble.ogg")
cowbell = pygame.mixer.Sound("/home/pi/ruff-wavs/sounds/cowbell fix.ogg")
clackyballs = pygame.mixer.Sound("/home/pi/ruff-wavs/sounds/clacky balls boucne.ogg")
burpees = pygame.mixer.Sound("/home/pi/ruff-wavs/sounds/burpees_fix.ogg")
brokensynth = pygame.mixer.Sound("/home/pi/ruff-wavs/sounds/broken synth bounce.ogg")
woolballs = pygame.mixer.Sound("/home/pi/ruff-wavs/sounds/wool balls in jar FIX.ogg")
wiimoye = pygame.mixer.Sound("/home/pi/ruff-wavs/sounds/wiimoye_fix.ogg")
warpyorgan = pygame.mixer.Sound("/home/pi/ruff-wavs/sounds/warpy organ bounce#.2.ogg")
vibrate = pygame.mixer.Sound("/home/pi/ruff-wavs/sounds/vibrate fix.ogg")
turtlesbounce = pygame.mixer.Sound("/home/pi/ruff-wavs/sounds/turtles fix.ogg")
timer = pygame.mixer.Sound("/home/pi/ruff-wavs/sounds/timer.ogg")
tape = pygame.mixer.Sound("/home/pi/ruff-wavs/sounds/tape fix.ogg")
tambourine = pygame.mixer.Sound("/home/pi/ruff-wavs/sounds/TAMBOURINE.ogg")
springybounce = pygame.mixer.Sound("/home/pi/ruff-wavs/sounds/springy bounce.ogg")
smash3 = pygame.mixer.Sound("/home/pi/ruff-wavs/sounds/smash fix.ogg")
bristle2 = pygame.mixer.Sound("/home/pi/ruff-wavs/sounds/BRISTLE FIX.ogg")
blackkeys = pygame.mixer.Sound("/home/pi/ruff-wavs/sounds/black keys FIX.ogg")
zipper = pygame.mixer.Sound("/home/pi/ruff-wavs/sounds/zipper.ogg")

presatisfactionsweep = pygame.mixer.Sound("/home/pi/ruff-wavs/sounds/pre-satisfaction sweep .ogg")
satisfaction = pygame.mixer.Sound("/home/pi/ruff-wavs/sounds/SATISFACTION.ogg")
altsatisfaction = pygame.mixer.Sound("/home/pi/ruff-wavs/sounds/alt_satisfaction_trimmed.ogg")
solosatisfaction = pygame.mixer.Sound("/home/pi/ruff-wavs/sounds/SOLO_SATISFACTION.ogg")
print("sound files loaded")

# initializing sounds list  
soundsList = [echoballs, organbounce, zipper, jar, garland, dribble, cowbell, clackyballs, burpees, brokensynth, woolballs,
       wiimoye, warpyorgan, vibrate, turtlesbounce, timer, tambourine, springybounce, smash3, bristle2, blackkeys, zipper       ] 

IRcount = 0 # define initial state for main loop
pygame.display.set_mode((32, 8))
print("pygame dispaly open")

# LED strip configuration:
LED_COUNT      = 256      # Number of LED pixels.
LED_PIN        = 18      # GPIO pin connected to the pixels (18 uses PWM!).
#LED_PIN        = 10     # GPIO pin connected to the pixels (10 uses SPI /dev/spidev0.0).
LED_FREQ_HZ    = 800000  # LED signal frequency in hertz (usually 800khz)
LED_DMA        = 10      # DMA channel to use for generating signal (try 10)
LED_BRIGHTNESS = 100     # Set to 0 for darkest and 255 for brightest
LED_INVERT     = False   # True to invert the signal (when using NPN transistor level shift)
LED_CHANNEL    = 0       # set to '1' for GPIOs 13, 19, 41, 45 or 53

# Define functions which animate LEDs in various ways.

# PNG to LED function used to shuffle througfh folders of numbered PNGs exported
# from animations created
def pngToLED (strip, pngfile):
    RGBimage = Image.open(pngfile).convert('RGB')
    np_image = np.array(RGBimage)
    colours = [Color(x[0],x[1],x[2]) for rows in np_image for x in rows]
    colours2d = np.reshape(colours, (32, 8), order='F')
    colours2d[1::2, :] = colours2d[1::2, ::-1]
    pic = colours2d.flatten('C')
    for i in range( 0, strip.numPixels(), 1 ):# iterate over all LEDs - range(start_value, end_value, step)
        strip.setPixelColor(i, int(pic[ i ]))
    strip.show()

def colorWipe(strip, color,wait_ms=10):
    """Wipe color across display a pixel at a time."""
    for i in range(strip.numPixels()):
        strip.setPixelColor(i, color)
    strip.show()
    time.sleep(1)

def theaterChase(strip, color, wait_ms, iterations=10):
    """Movie theater light style chaser animation."""
    for j in range(iterations):
        for q in range(3):
            for i in range(0, strip.numPixels(), 3):
                strip.setPixelColor(i+q, color)
            strip.show()
            time.sleep(wait_ms/1000.0)
            for i in range(0, strip.numPixels(), 3):
                strip.setPixelColor(i+q, 0)

def wheel(pos):
    """Generate rainbow colors across 0-255 positions."""
    if pos < 85:
        return Color(pos * 3, 255 - pos * 3, 0)
    elif pos < 170:
        pos -= 85
        return Color(255 - pos * 3, 0, pos * 3)
    else:
        pos -= 170
        return Color(0, pos * 3, 255 - pos * 3)

def rainbow(strip, wait_ms=20, iterations=1):
    """Draw rainbow that fades across all pixels at once."""
    for j in range(256*iterations):
        for i in range(strip.numPixels()):
            strip.setPixelColor(i, wheel((i+j) & 255))
        strip.show()
        time.sleep(wait_ms/1000.0)

def rainbowCycle(strip, wait_ms=20, iterations=5):
    """Draw rainbow that uniformly distributes itself across all pixels."""  
    for j in range(256*iterations):

        for i in range(strip.numPixels()):
            strip.setPixelColor(i, wheel((int(i * 256 / strip.numPixels()) + j) & 255))
        strip.show()
        time.sleep(wait_ms/1000.0)

def theaterChaseRainbow(strip, wait_ms=90):
    """Rainbow movie theater light style chaser animation."""
    for j in range(256):
        for q in range(3):
            for i in range(0, strip.numPixels(), 3):
                strip.setPixelColor(i+q, wheel((i+j) % 255))
            strip.show()
            time.sleep(wait_ms/1000.0)
            for i in range(0, strip.numPixels(), 3):
                strip.setPixelColor(i+q, 0)

# Plasma LED Function from Root 42
def plasmaLED (plasmaTime):
    h = 8
    w = 32
    out = [ Color( 0, 0, 0 ) for x in range( h * w ) ]
    plasmaBright = 100.0
    for x in range( h ):
        for y in range( w ):
            hue = (4.0 + math.sin( plasmaTime + x ) + math.sin( plasmaTime + y / 4.5 ) \
                + math.sin( x + y + plasmaTime ) + math.sin( math.sqrt( ( x + plasmaTime ) ** 2.0 + ( y + 1.5 * plasmaTime ) ** 2.0 ) / 4.0 ))/8
            hsv = colorsys.hsv_to_rgb( hue , 1, 1 )
            if y % 2 == 0: #even
                out[ x + (h * y)] = Color( *[ int( round( c * plasmaBright ) ) for c in hsv ] )
            else: #odd
                out[ (y * h) + (h -1 -x) ] = Color( *[ int( round( c * plasmaBright ) ) for c in hsv ] )
    for i in range( 0, strip.numPixels(), 1 ):# iterate over all LEDs - range(start_value, end_value, step)
        strip.setPixelColor(i, out[ i ]) # set pixel to color in picture
    strip.show()

# variables for plasma
plasmaTime = 5.0 # time
plasmaSpeed = 0.05 # speed of time

# thread for IRcounter function
class TempTask:

    def __init__(self):
        self.ir_temp = 0
        self.lock = threading.Lock() #control concurrent access for safe multi thread access
        self.thread = threading.Thread(target=self.update_temp)

    def update_temp(self):
        while True:
            with self.lock:
                self.ir_temp = irCounter()
            time.sleep(0.1)

    def start(self):
        self.thread.start()

# Millis timer count function
def CheckTime( lastTime,  wait):
  if currentTime - lastTime >= wait:
    lastTime += wait
    return True
  return False


# Main program logic follows:
if __name__ == '__main__':

    # not currently starting the trhead because program is locking up without it
    # want to figure out initial problem first
    #start thread
    #task = TempTask()
    #task.start()

    # Create NeoPixel object with appropriate configuration.
    strip = Adafruit_NeoPixel(LED_COUNT, LED_PIN, LED_FREQ_HZ, LED_DMA, LED_INVERT, LED_BRIGHTNESS, LED_CHANNEL)
    # Intialize the library (must be called once before other functions).
    strip.begin()

    print ('Press Ctrl-C to quit.')

    try:
        while True:
            currentTime = int(round(time.time() * 1000))

            if IRcount == 0:         

                #random solid color
                colorWipe(strip, Color(random.randint(60,255), random.randint(60,255), random.randint(60,255)))

                # use random.sample() to shuffle sounds list 
                shuffledSounds = random.sample(soundsList, len(soundsList))
                if pygame.mixer.Channel(0).get_busy() == False: channel0.play(shuffledSounds[0],loops = -1)
                thresh = 0
                '''
                # the threshold check below is the only thing I have taken out of
                # Program on my test Raspberry Pi.  It seems to not lock up without it
                # not sure why this would be a problem.

                thresh = int(maxTemp())
                print (thresh)
                if thresh >= 27:
                  InflateWait = int(round(time.time() * 1000))
                  print (thresh)
                  IRcount = 1
                  print("Threshold Temp Detected: Begin Sound Sequence")
                else:
                  IRcount = 0
                  '''
                if CheckTime(InflateWait,random.randint(minTime, maxTime)):
                  InflateWait = int(round(time.time() * 1000))
                  IRcount += 1
                  print(IRcount)

            elif IRcount == 1:
                LEDimages = glob.glob("/home/pi/ruff-wavs/Crystal_Mirror/*.png")
                for LEDimage in sorted(LEDimages):
                  pngToLED (strip, LEDimage)
                if pygame.mixer.Channel(1).get_busy() == False:
                  channel1.play(shuffledSounds[1],loops = -1)
                  waitTime = random.randint(minTime, maxTime)
                if CheckTime(InflateWait,waitTime):
                  InflateWait = int(round(time.time() * 1000))
                  IRcount += 1
                  print(IRcount)

            elif IRcount == 2:
                LEDimages = glob.glob("/home/pi/ruff-wavs/Mercury_Loop/*.png")
                for LEDimage in sorted(LEDimages):
                  pngToLED (strip, LEDimage)
                if pygame.mixer.Channel(2).get_busy() == False:
                  channel2.play(shuffledSounds[2],loops = -1)
                  waitTime = random.randint(minTime, maxTime)
                if CheckTime(InflateWait,waitTime):
                  InflateWait = int(round(time.time() * 1000))
                  IRcount += 1
                  print(IRcount)

            elif IRcount == 3:
                LEDimages = glob.glob("/home/pi/ruff-wavs/Pink_Lava/*.png")
                for LEDimage in sorted(LEDimages):
                  pngToLED (strip, LEDimage)            
                if pygame.mixer.Channel(3).get_busy() == False:
                  channel3.play(shuffledSounds[3],loops = -1)
                  waitTime = random.randint(minTime, maxTime)
                if CheckTime(InflateWait,waitTime):
                  InflateWait = int(round(time.time() * 1000))
                  IRcount += 1
                  print(IRcount)

            elif IRcount == 4:
                LEDimages = glob.glob("/home/pi/ruff-wavs/Horiz_Mosaic/*.png")
                for LEDimage in sorted(LEDimages):
                  pngToLED (strip, LEDimage)
                if pygame.mixer.Channel(4).get_busy() == False:
                  channel4.play(shuffledSounds[4],loops = -1)
                  waitTime = random.randint(minTime, maxTime)
                if CheckTime(InflateWait,waitTime):
                  InflateWait = int(round(time.time() * 1000))
                  IRcount += 1
                  print(IRcount)


            elif IRcount == 5:
                plasmaLED()
                plasmaTime = plasmaTime + plasmaSpeed  # increment plasma time
                if pygame.mixer.Channel(5).get_busy() == False:
                  channel5.play(shuffledSounds[5],loops = -1)
                  waitTime = random.randint(minTime, maxTime)
                if CheckTime(InflateWait,waitTime):
                  InflateWait = int(round(time.time() * 1000))
                  IRcount += 1
                  print(IRcount)


            elif IRcount == 6:
                LEDimages = glob.glob("/home/pi/ruff-wavs/Radio_Loop/*.png")
                for LEDimage in sorted(LEDimages):
                  pngToLED (strip, LEDimage)
                if pygame.mixer.Channel(6).get_busy() == False:
                  channel6.play(shuffledSounds[6],loops = -1)
                  waitTime = random.randint(minTime, maxTime)
                if CheckTime(InflateWait,waitTime):
                  InflateWait = int(round(time.time() * 1000))
                  IRcount += 1
                  print(IRcount)


            elif IRcount == 7:
                LEDimages = glob.glob("/home/pi/ruff-wavs/Star_Loop/*.png")
                for LEDimage in sorted(LEDimages):
                  pngToLED (strip, LEDimage)
                if pygame.mixer.Channel(7).get_busy() == False:
                  channel7.play(shuffledSounds[7],loops = -1)
                  waitTime = random.randint(minTime, maxTime)
                if CheckTime(InflateWait,waitTime):
                  InflateWait = int(round(time.time() * 1000))
                  IRcount += 1




            elif IRcount == 14:
                plasmaLED()
                plasmaTime = plasmaTime + plasmaSpeed  # increment plasma time
                if pygame.mixer.Channel(14).get_busy() == False:
                  channel14.play(shuffledSounds[14],loops = -1)
                  waitTime = random.randint(minTime, maxTime)
                if CheckTime(InflateWait,waitTime):
                  InflateWait = int(round(time.time() * 1000))
                  IRcount += 1
                  print(IRcount)
                  print (thresh)

            elif IRcount == 15:
                plasmaLED()
                plasmaTime = plasmaTime + plasmaSpeed  # increment plasma time
                if pygame.mixer.Channel(15).get_busy() == False:
                  channel15.play(shuffledSounds[15],loops = -1)
                  waitTime = random.randint(minTime, maxTime)
                if CheckTime(InflateWait,waitTime):
                  InflateWait = int(round(time.time() * 1000))
                  IRcount += 1
                  print(IRcount)




            elif IRcount == 16:
                # random color theater chase increment random ms to speed up with sounds
                theaterChase(strip, Color(random.randint(1,255), random.randint(1,255), random.randint(1,255)), random.randint(40,50))
                pygame.mixer.fadeout(45000)
                if pygame.mixer.Channel(22).get_busy() == False:
                  channel22.play(presatisfactionsweep)
                IRcount = 17
                print(IRcount)
                print("sweep end start")


            elif IRcount == 18:
                 # random color theater chase increment random ms to speed up with sounds
                theaterChase(strip, Color(random.randint(1,255), random.randint(1,255), random.randint(1,255)), random.randint(30,40))
                if pygame.mixer.Channel(22).get_busy() == False:
                    pygame.mixer.stop()
                    channel23.play(satisfaction)
                    IRcount = 19
                    print(IRcount)
                    print("Play Satisfaction Sount")

            elif IRcount == 19:
                rainbowCycle(strip, 5)
                if pygame.mixer.Channel(23).get_busy() == False: IRcount = 0

    except KeyboardInterrupt:
       colorWipe(strip, Color(0,0,0), 1)
       pygame.mixer.stop()
       pygame.quit()
```

更新1-可疑功能

当我让脚本连夜运行并在早上来到展览时,它将被困在第一个状态IRcount = 0在该状态下唯一发生的事情是maxTemp()函数来获取最高温度,LED颜色擦除函数来循环颜色。你知道吗

当我早上进来的时候,它会被卡住,像应该的那样,只播放一个pygame的声音,但不会是循环的颜色。我从我的测试Pi中删除了maxTemp(),它工作得很好。你知道吗

    def maxTemp():
          mlx.setup(8) #set frame rate of MLX90640

          f = mlx.get_frame()

          mlx.cleanup()

          # get max and min temps from sensor
          # v_min = min(f)
          v_max = int(max(f))
          return v_max

更新#2

我认为线程可能是问题所在,所以我注释掉了线程开始调用。这就是为什么我做了一个更简单的maxTemp()函数来看看它是否比线程工作得更好。所以当我使用max temp时,线程没有被调用。你知道吗

我不太懂线。是否可以连续更新max temp变量,并连续运行简单的OpenCV numPy操作?那将是理想的。当我最初添加线程时,它似乎在几个周期后停止。你知道吗

我的线没有连接。我知道线程不会“重启”,但是当状态机再次启动时,我需要再次调用它吗?你知道吗

    # not currently starting the thread because program is locking up without it
        # want to figure out initial problem first
        #start thread
        #task = TempTask()
        #task.start()

更新#3

我上传了消除重复函数的新代码。现在一切都在线程temp.task中处理。这似乎很管用。我还提出了github的建议,即如果图像是重复的,则轮询热传感器,但这并没有发生。你知道吗

我让程序运行了一夜,当我早上进来的时候,它被锁起来了。SD卡设置为只读模式。我进入了pi。我的自动启动python脚本在/etc/profile 每次我登录ssh时似乎都会启动脚本。当我今早登录查看pi是否还在运行时,它显示了一个内存不足的错误。你知道吗

```
Traceback (most recent call last):
  File "/home/pi/ruff-wavs/shufflewavdemo.py", line 210, in <module>
    altsatisfaction = pygame.mixer.Sound("/home/pi/ruff-wavs/sounds/alt_satisfaction_trimmed.ogg")
pygame.error: Unable to open file '/home/pi/ruff-wavs/sounds/alt_satisfaction_trimmed.ogg'
OSError: [Errno 28] No space left on device

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.5/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.5/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/usr/local/lib/python3.5/dist-packages/virtualenvwrapper/hook_loader.py", line 223, in <module>
    main()
  File "/usr/local/lib/python3.5/dist-packages/virtualenvwrapper/hook_loader.py", line 145, in main
    output.close()
OSError: [Errno 28] No space left on device
-bash: cannot create temp file for here-document: No space left on device
Could that be because it is in read only mode?

I used this script to switch from writable to read only and back.
[https://github.com/JasperE84/root-ro][1]


  [1]: https://github.com/JasperE84/root-ro

Tags: inhomeforiftimechannelpirandom
1条回答
网友
1楼 · 发布于 2024-06-01 01:43:23

我怀疑问题是您正在通过maxTemp()访问主线程中的mlx设备以及irCounter()线程中的设备。它在执行maxTemp调用时工作,并且该调用发生在if IRcount == 0:状态支持这一点。你知道吗

我会将maxTemp功能添加到irCounter线程,以便仅从单个线程访问它;如果需要保留此功能,则使用maxTemp结果更新全局变量(受锁保护)。你知道吗

相关问题 更多 >