#ifndef GLOBAL_H
#define GLOBAL_H

#include <string>

// ── 参数文件名 ──
const std::string kp_file = "./kp";
const std::string ki_file = "./ki";
const std::string kd_file = "./kd";

const std::string start_file = "./start";
const std::string showImg_file = "./showImg";
const std::string destfps_file = "./destfps";
const std::string foresee_file = "./foresee";
const std::string zebrasee_file = "./zebrasee";
const std::string saveImg_file = "./saveImg";
const std::string speed_file = "./speed";
const std::string deadband_file = "./deadband";
const std::string steer_gain_file = "./steer_gain";
const std::string center_bias_file = "./center_bias";
const std::string debug_file = "./debug";

double readDoubleFromFile(const std::string &filename);
bool   readFlag(const std::string &filename);
void   cfg_load_all();

// ── 启动时缓存的运行参数 ──
struct CfgCache {
    double speed       = 60;     // 目标速度(占空比 %)
    double foresee     = 80;     // 前瞻行
    double zebrasee    = 60;     // 斑马线触发距离阈值
    double deadband    = 5;      // 舵机死区
    double steer_gain  = 1.0;    // 舵机增益
    double center_bias = 0;      // 中线偏移修正
    int    start       = 0;      // 1=启动 0=停止
    int    showImg     = 0;      // LCD 预览开关
    int    debug       = 0;      // debug 模式
};
extern CfgCache g_cfg;

extern double target_speed;

#endif
