網路找到的資料:
GP2Y1010AU0F 灰塵感測器檢測PM2.5
https://atceiling.blogspot.com/2019/10/arduino73-gp2y1010au0f-pm25.html
https://sites.google.com/site/csjhmaker/e0/gp2y1010au0f-hui-chen-gan-ce
網路找到的資料:
How to change title bar image in WPF Window?
選取某列 ==>dataGridView1.Rows[i].Selected=true;
不錯的文章
C# Development | 煩人的跨執行緒作業無效 : 如何跨執行緒控制 UI 元件
學一下......
C# 从控件 sender 操作当前控件study 中...
不錯的文章
STM32—cubeMX+HAL庫的SPI介面使用timer1 polling:
HAL_TIM_Base_Start(&htim1);timer1 isr:
HAL_TIM_Base_Start_IT(&htim1); => enable 方式不同
Getting Started with STM32 - Timers and Timer Interrupts
https://www.digikey.com/en/maker/projects/getting-started-with-stm32-timers-and-timer-interrupts/d08e6493cefa486fb1e79c43c0b08cc6
試著了解一下 I2C DMA.......
最後才知要呼叫
HAL_StatusTypeDef HAL_I2C_Mem_Read_DMA ( I2C_HandleTypeDef * hi2c, uint16_t DevAddress, uint16_t MemAddress, uint16_t MemAddSize, uint8_t * pData, uint16_t Size ) 在實作中,有發現如果是HAL_BUSY 好像I2C就當掉了,無法復原: STM32: Busy flag is set after I2C initialization https://electronics.stackexchange.com/questions/272427/stm32-busy-flag-is-set-after-i2c-initialization |
一開始 clock sources要選對,之前選 Bypass 好像有問題
在MX_I2C1_Init(0 --> HAL_I2C_Init(&hi2c1) 內會有問題
照著書本key,練習一下
using System;
using System.IO;
using System.Security.Cryptography;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
using(FileStream fsin=File.Create("ver1.smp"))
{
byte[] buffer = new byte[256];
Random rand = new Random();
for(int x=0;x<150;x++)
{
rand.NextBytes(buffer);
fsin.Write(buffer);
}
}
File.Copy("ver1.smp", "ver2.smp", true);
string curdir = Directory.GetCurrentDirectory();
string[] files = Directory.GetFiles(curdir, "*.smp");
SHA1 sha = SHA1.Create();
foreach(string f in files)
{
using(FileStream fs=File.OpenRead(f))
{
byte[] result = sha.ComputeHash(fs);
Console.WriteLine("file {0} Hash:", Path.GetFileName(f));
StringBuilder bd = new StringBuilder();
foreach(byte b in result)
{
bd.AppendFormat("{0:X2} ", b);
}
Console.Write(bd + "\n\n");
}
}
sha.Dispose();
}
}
}
照著網路文章打:
import numpy as np
import pylab as pl
sampling_rate=8000
fft_size=512
t=np.arange(0,1,1.0/sampling_rate)
x=np.sin(2*np.pi*156.25*t)+2*np.sin(2*np.pi*234.375*t)
xs=x[:fft_size]
xf=np.fft.rfft(xs)/fft_size
freqs=np.linspace(0,sampling_rate/2,fft_size/2+1)
xfp=20*np.log10(np.clip(np.abs(xf),1e-20,1e1000))
pl.figure(figsize=(8,4))
pl.subplot(211)
pl.plot(t[:fft_size],xs)
pl.xlabel(u"time(sec)")
pl.title(u"The Wave and Spectrum 156.25Hz 234.375Hz")
pl.subplot(212)
pl.plot(freqs,xfp)
pl.xlabel(u"Hz")
pl.subplots_adjust(hspace=0.4)
pl.show()
不錯的文章:
理解頻域、時域、FFT和加窗 加深對信號的認識
https://kknews.cc/news/q5b83a8.html
照著課本練習
using System;
using System.IO;
using System.IO.Pipes;
namespace pipe_1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World! pipe 1");
using (NamedPipeServerStream server=new NamedPipeServerStream("demo"))
{
server.WaitForConnection();
try
{
using(StreamReader reader=new StreamReader(server))
{
string msg = null;
while((msg=reader.ReadLine())!=null)
{
Console.WriteLine($"client:{msg}");
}
}
}
catch
{
Console.WriteLine("error");
}
// Console.WriteLine(" wait exit");
// Console.Read();
}
}
}
}
照著課本練習key in
using System;
using System.IO;
using System.IO.Compression;
using System.IO.MemoryMappedFiles;
using System.Net.Http.Headers;
using System.Numerics;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
MemoryMappedFile file = MemoryMappedFile.CreateNew("test", 200L);
using(var mvstream=file.CreateViewStream())
{
using(StreamWriter writer=new StreamWriter(mvstream))
{
writer.WriteLine("hello 1st");
writer.WriteLine("hello 2th");
}
}
using(MemoryMappedFile mfile=MemoryMappedFile.OpenExisting("test"))
{
using (var vstream=mfile.CreateViewStream())
{
using (StreamReader resder = new StreamReader(vstream))
{
string str = resder.ReadToEnd();
Console.WriteLine(str);
}
}
}
using (MemoryMappedFile mmfile = MemoryMappedFile.CreateFromFile("map.data", FileMode.OpenOrCreate, "udemo", 100L))
{
using (var vstream = mmfile.CreateViewStream())
{
using (BinaryWriter writer = new BinaryWriter(vstream))
{
writer.Write(150);
writer.Write(1.17f);
writer.Write(96000L);
writer.Write(13.965d);
}
}
}
using(FileStream stream=File.OpenRead("map.data"))
{
Console.WriteLine($"file size:{stream.Length}");
using(BinaryReader reader=new BinaryReader(stream))
{
int v1 = reader.ReadInt32();
float v2 = reader.ReadSingle();
long v3 = reader.ReadInt64();
double v4 = reader.ReadDouble();
Console.WriteLine($"AAA:{v1} {v2} {v3} {v4}");
}
}
}
}
}
照著課本,練習Key:
using System;
using System.IO;
using System.IO.Compression;
using System.Net.Http.Headers;
using System.Numerics;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
//DeflateStream
using(FileStream instream=new FileStream("doc1.txt",FileMode.Open))
using(FileStream outstream=new FileStream("out.def",FileMode.Create))
using (DeflateStream defstream=new DeflateStream(outstream,CompressionLevel.Optimal))
{
instream.CopyTo(defstream);
}
FileInfo info1 = new FileInfo("doc1.txt");
FileInfo info2 = new FileInfo("out.def");
Console.WriteLine($"Before Compress:{info1.Length}");
Console.WriteLine($"After Comoress:{info2.Length}");
//zip
string zipFile = "demo.zip";
using (FileStream outfs =File.Create(zipFile))
{
using (ZipArchive zip = new ZipArchive(outfs, ZipArchiveMode.Create))
{
ZipArchiveEntry etl = zip.CreateEntry("doc1.txt");
using (Stream stream = etl.Open())
{
using (StreamWriter writer = new StreamWriter(stream))
{
writer.Write("範例文件 A");
}
}
ZipArchiveEntry et2 = zip.CreateEntry("doc2.txt");
using (Stream stream=et2.Open())
{
using(StreamWriter writer =new StreamWriter(stream))
{
writer.Write("範例文件 B");
}
}
}
}
using (FileStream instream = File.OpenRead(zipFile))
{
using(ZipArchive zip=new ZipArchive(instream))
{
foreach(ZipArchiveEntry et in zip.Entries)
{
using(Stream stream=et.Open())
{
using(FileStream fsout=File.Create(et.Name))
{
stream.CopyTo(fsout);
}
}
}
}
}
//GZipStream
string outFileName = "demo.gz";
using (FileStream fsIn = File.OpenRead("doc1.txt"))
using (FileStream fsOut = File.Create(outFileName))
using (GZipStream gz = new GZipStream(fsOut, CompressionMode.Compress))
{
fsIn.CopyTo(gz);
}
FileInfo info3 = new FileInfo("doc1.txt");
FileInfo info4 = new FileInfo(outFileName);
Console.WriteLine($"Before Compress:{info3.Length}");
Console.WriteLine($"After Comoress:{info4.Length}");
}
}
}