调整微网配置的加载方式

This commit is contained in:
nnhy 2015-10-31 07:30:41 +00:00
parent e31e6709b7
commit ce47d44bf4
3 changed files with 15 additions and 38 deletions

View File

@ -111,16 +111,10 @@ void* InitConfig(void* data, uint size)
((byte*)data)[0] = size; ((byte*)data)[0] = size;
} }
// 默认出厂设置 TinyConfig* tc = TinyConfig::Init();
static TinyConfig tc;
TinyConfig::Current = &tc;
tc.LoadDefault();
tc.Channel = 120;
tc.Speed = 250;
//tc.HardVer = 0x08;
// 尝试加载配置区设置 // 尝试加载配置区设置
tc.Load(); tc->Load();
return data; return data;
} }

View File

@ -3,36 +3,6 @@
TinyConfig* TinyConfig::Current = NULL; TinyConfig* TinyConfig::Current = NULL;
// 初始化
/*TinyConfig::TinyConfig()
{
// 实际内存大小,减去头部大小
uint len = sizeof(this) - ((int)&Length - (int)this);
//memset(&Length, 0, len);
Length = len;
}*/
/*const TinyConfig& Default()
{
const TinyConfig tc =
{
sizeof(TinyConfig),
1,
1,
10,
60,
5,
120,
250,
60,
};
return tc;
}*/
void TinyConfig::LoadDefault() void TinyConfig::LoadDefault()
{ {
// 实际内存大小,减去头部大小 // 实际内存大小,减去头部大小
@ -87,3 +57,15 @@ void TinyConfig::Read(Stream& ms)
{ {
memcpy((byte *)this, ms.GetBuffer(), sizeof(this[0])); memcpy((byte *)this, ms.GetBuffer(), sizeof(this[0]));
} }
TinyConfig* TinyConfig::Init()
{
// 默认出厂设置
static TinyConfig tc;
TinyConfig::Current = &tc;
tc.LoadDefault();
tc.Channel = 120;
tc.Speed = 250;
return &tc;
}

View File

@ -43,6 +43,7 @@ struct TinyConfig
void Read(Stream& ms); void Read(Stream& ms);
static TinyConfig* Current; static TinyConfig* Current;
static TinyConfig* Init();
}; };
#pragma pack(pop) // 恢复对齐状态 #pragma pack(pop) // 恢复对齐状态