admin 发布的文章

VR

微信图片_20210907162613.jpg


红外热成像测试

ir (3).jpg
微信图片_20210718135025.jpg
微信图片_20210718135017.jpg

  # SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
# SPDX-License-Identifier: MIT

"""This example is for Raspberry Pi (Linux) only!
   It will not work on microcontrollers running CircuitPython!"""

import math
from PIL import Image
import board
import adafruit_mlx90640

FILENAME = "mlx.jpg"

MINTEMP = 25.0  # low range of the sensor (deg C)
MAXTEMP = 45.0  # high range of the sensor (deg C)
COLORDEPTH = 1000  # how many color values we can have
INTERPOLATE = 10  # scale factor for final image

mlx = adafruit_mlx90640.MLX90640(board.I2C())

# the list of colors we can choose from
heatmap = (
    (0.0, (0, 0, 0)),
    (0.20, (0, 0, 0.5)),
    (0.40, (0, 0.5, 0)),
    (0.60, (0.5, 0, 0)),
    (0.80, (0.75, 0.75, 0)),
    (0.90, (1.0, 0.75, 0)),
    (1.00, (1.0, 1.0, 1.0)),
)

colormap = [0] * COLORDEPTH

# some utility functions
def constrain(val, min_val, max_val):
    return min(max_val, max(min_val, val))


def map_value(x, in_min, in_max, out_min, out_max):
    return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min


def gaussian(x, a, b, c, d=0):
    return a * math.exp(-((x - b) ** 2) / (2 * c ** 2)) + d


def gradient(x, width, cmap, spread=1):
    width = float(width)
    r = sum(
        [gaussian(x, p[1][0], p[0] * width, width / (spread * len(cmap))) for p in cmap]
    )
    g = sum(
        [gaussian(x, p[1][1], p[0] * width, width / (spread * len(cmap))) for p in cmap]
    )
    b = sum(
        [gaussian(x, p[1][2], p[0] * width, width / (spread * len(cmap))) for p in cmap]
    )
    r = int(constrain(r * 255, 0, 255))
    g = int(constrain(g * 255, 0, 255))
    b = int(constrain(b * 255, 0, 255))
    return r, g, b


for i in range(COLORDEPTH):
    colormap[i] = gradient(i, COLORDEPTH, heatmap)

# get sensor data
frame = [0] * 768
success = False
while not success:
    try:
        mlx.getFrame(frame)
        success = True
    except ValueError:
        continue

# create the image
pixels = [0] * 768
for i, pixel in enumerate(frame):
    coloridx = map_value(pixel, MINTEMP, MAXTEMP, 0, COLORDEPTH - 1)
    coloridx = int(constrain(coloridx, 0, COLORDEPTH - 1))
    pixels[i] = colormap[coloridx]
    print(pixels[i])

# save to file
img = Image.new("RGB", (32, 24))
img.putdata(pixels)
img = img.transpose(Image.FLIP_TOP_BOTTOM)
img = img.resize((32 * INTERPOLATE, 24 * INTERPOLATE), Image.BICUBIC)
img.save("ir.jpg")

利用玄学解决液压履带式起重机力矩算法及古法锻造青铜剑

玄学与科学的区别在于科学在乎过程而玄学却可以忽略过程。就拿数据函数y=f(x)做个比方,玄学并不在乎f是什么,他只需要不断的穷举x的值获得y的值从而建立一张表,下次可以直接通过y的值查出x的值,中医和炼丹术皆用此种方法,从神农尝百草就可以片面看出。
履带式起重机的力矩算法相当让人头疼,第一臂长是可伸缩的,也并不是均匀,越往远端越细,关节间也不是耦合紧密 可能存在松动,在吊取物体时臂杆还存在挠性,吊得越重弯的越厉害,第二臂杆在起落的过程与地面形成的夹角也在变化,这个变化单独拿来当做理想情况下算都好算,最终的目的是需要根据臂杆的支撑轴安装的液压传感器的压力值来计算出当前吊重,如果都是在理想情况下都好计算,但实际情况不可能理想,连起重机的使用年限都会影响计算结果,当然 如果这些用科学来计算法也不是无解,只是花的时间和精力会比较大,而且也不是一般学渣能够完成。
针对此种情况,用玄学来解决这个问题似乎是完美的,首先实时采集吊取物体的重量和液压的压力值和臂杆的夹角,并把臂杆慢慢伸缩一遍,抬起放下一遍,吊装物体的重量从小到大从大到小过一遍,并且实时记录这些值经过简单分析入库,正常工作时就可以通过查询当前压力夹角和臂长就可以查询到当前起吊的重量。
几千年前的青铜剑的锻造技术,现在人都不一定能复制出完全一模一样,是现在人技术不行吗,不是的,只是现在人缺乏那种多代人甚至很多个多代人经过无数次的尝试才造出来。
针对三体问题也是一样,宇宙中的两个天体之间的作用力很好计算,下一时刻的姿态也很好计算,当第三个天体加入的时候兴许也能计算,但当第四个五个....参入时,是不是差不多无解了,是不是玄学也也无法解决这个问题呢,当然不是src=http___www.tlang.com_images_store_611703_item_XGC120T.jpg_m.jpg&refer=http___www.tlang.jpg

婴儿睡眠监护器&最小巧的温湿度记录仪

通过监测宝宝包被内温湿度来判断是否冷 热 捂 避免湿疹
主图.jpg
1.jpg
2.jpg
3.jpg
4.jpg
5.jpg

微信图片_20210610101827.jpg

微信图片_20210606183358.jpg

97b07c8617fffdcffdff23d4001f9dc5.mp4
89aadd2250fad9f183ff586d1655d201.mp4


使用esp8266 连接 见登iot 远程控制继电器

微信截图_20210131131922.png

 #include <ESP8266WiFi.h>
    #include <PubSubClient.h>
    #include <ArduinoJson.h>
     
    const char* ssid = "Sanby";
    const char* password = "1234567890";
    const char* mqtt_server = "182.92.223.22";
    const char* mqtt_id = "v1/devices/me/telemetry";
    const char* mqtt_subid = "v1/devices/me/rpc/request/+";
    const int mqttPort = 1883;
    
     
    WiFiClient espClient;
    PubSubClient client(espClient);
    int switch1=0;
    int tempture=0;
    void setup() {
    
      Serial.begin(115200);
     
      WiFi.begin(ssid, password);
     
      while (WiFi.status() != WL_CONNECTED) {
        delay(500);
        Serial.println("Connecting to WiFi..");
      }
      Serial.println("Connected to the WiFi network");
     
      client.setServer(mqtt_server, mqttPort);
      client.setCallback(callback);
     
      while (!client.connected()) {
        Serial.println("Connecting to MQTT...");
     
        if (client.connect("93834a00-2631-11eb-af1a-37260a6003e5","DHT11_DEMO_TOKEN","")) {
          Serial.println("connected");  
     
        } else {
     
          Serial.print("failed with state ");
          Serial.print(client.state());
          delay(2000);
     
        }
      }
     
      client.publish(mqtt_id, "{'value':10.0}");
      client.subscribe(mqtt_subid);
     
    }
     
    void callback(char* topic, byte* payload, unsigned int length) {
      DynamicJsonDocument doc(1024);
      Serial.print("Message arrived in topic: ");
      Serial.println(topic);
      Serial.print("Message:");
      Serial.println((char *)payload);
      DeserializationError error = deserializeJson(doc, payload);
      if(error)return;
      String method_=doc["method"];
      String params_=doc["params"];
      if(!method_.compareTo("setLight1SwitchStatus"))
      {
        
         if(!params_.compareTo("on")){digitalWrite(0,HIGH);pinMode(0,OUTPUT);}
         if(!params_.compareTo("off")){digitalWrite(0,LOW);pinMode(0,OUTPUT);};
      }
      if(!method_.compareTo("setLight2SwitchStatus"))
      {
         if(!params_.compareTo("on")){digitalWrite(0,HIGH);pinMode(0,OUTPUT);}
         if(!params_.compareTo("off")){digitalWrite(0,LOW);pinMode(0,OUTPUT);}
      }
      Serial.println(doc["method"].as<String>());
      Serial.println(doc["params"].as<String>());
    }
    
    void loop() {
      client.loop();
      
      tempture++;
      if(tempture%100000==0)
      {
        String bbbb= "{\"tongjinlv\":"+String(tempture)+"}";
        client.publish(mqtt_id, bbbb.c_str());
        Serial.println(bbbb.c_str());
      }
      if(!client.connected())setup();
      if(WiFi.status() != WL_CONNECTED)ESP.reset();
    }