void setFilter4thOrder(float fc) { // 4阶巴特沃斯: 两个2阶级联 // Stage1: Q=0.541 // Stage2: Q=1.306 float C = 10e-9; // Stage1 计算 float R1 = calcResistor(fc, 0.541, C); uint8_t pot1 = (uint8_t)((R1/10000.0)*256); // Stage2 计算 float R2 = calcResistor(fc, 1.306, C); uint8_t pot2 = (uint8_t)((R2/10000.0)*256); // 更新数字电位器 MCP41010_Write(CS1_PIN, pot1); MCP41010_Write(CS2_PIN, pot2); // OLED显示 OLED_ShowString(0, 0, "fc:"); OLED_ShowNum(30, 0, (uint16_t)fc, 5); OLED_ShowString(80, 0, "Hz"); }