zhaohe 9 months ago
parent
commit
1ddd247237
  1. 58
      .cproject
  2. 3
      uappbase/apphal/apphal.cpp
  3. 15
      uappbase/zhdb/zhdb.cpp
  4. 1
      uappbase/zhdb/zhdb.hpp
  5. 29
      ucomponents/eeprom/m24m02_i2c_eeprom.cpp
  6. 3
      usrc/apphardware/apphardware.cpp
  7. 11
      usrc/db/dao/acid_ch_cfg_dao.cpp
  8. 8
      usrc/db/dao/acid_name_dao.cpp
  9. 13
      usrc/db/dao/device_setting_dao.cpp
  10. 9
      usrc/db/dao/user_dao.cpp
  11. 69
      usrc/service/app_core.cpp
  12. 8
      usrc/service/remote_controler_event_processer.cpp
  13. 1
      usrc/uicontroler/base/page_processer.hpp
  14. 4
      usrc/uicontroler/front_end_controler.hpp
  15. 50
      usrc/uicontroler/page/login/page_login.cpp
  16. 8
      usrc/uicontroler/page/page.hpp
  17. 36
      usrc/uicontroler/pagerouter/page_bak_router.cpp

58
.cproject

@ -134,34 +134,34 @@
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.symbolsrec.319958895" name="MCU Output Converter Motorola S-rec with symbols" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.symbolsrec"/>
</toolChain>
</folderInfo>
<folderInfo id="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.debug.1853947771.945870572" name="/" resourcePath="usrc/uicontroler/page.bak">
<toolChain id="com.st.stm32cube.ide.mcu.gnu.managedbuild.toolchain.exe.debug.1118303581" name="MCU ARM GCC" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.toolchain.exe.debug" unusedChildren="">
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_mcu.801178797.1246644808" name="MCU" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_mcu.801178797"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_cpuid.777915677.1532226338" name="CPU" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_cpuid.777915677"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_coreid.1126839807.1689744322" name="Core" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_coreid.1126839807"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.fpu.2045742466.1051535744" name="Floating-point unit" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.fpu.2045742466"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.floatabi.2108401733.550657620" name="Floating-point ABI" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.floatabi.2108401733"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_board.1574925555.1541095845" name="Board" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_board.1574925555"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.defaults.244221814.1436449244" name="Defaults" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.defaults.244221814"/>
<option id="com.st.stm32cube.ide.mcu.debug.option.cpuclock.764397174.2055951780" name="Cpu clock frequence" superClass="com.st.stm32cube.ide.mcu.debug.option.cpuclock.764397174"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.convertbinary.992660821.1432891400" name="Convert to binary file (-O binary)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.convertbinary.992660821"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.converthex.494792904.854588611" name="Convert to Intel Hex file (-O ihex)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.converthex.494792904"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.nanoscanffloat.176411214.1962083033" name="Use float with scanf from newlib-nano (-u _scanf_float)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.nanoscanffloat.176411214"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.nanoprintffloat.164943344.775498157" name="Use float with printf from newlib-nano (-u _printf_float)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.nanoprintffloat.164943344"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.toolchain.386899990.1277772283" name="Toolchain" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.toolchain.386899990"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.598323033" name="MCU GCC Assembler" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.1243726437"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.1286288365" name="MCU GCC Compiler" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.782799112"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.501895334" name="MCU G++ Compiler" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.344817877"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.2017949490" name="MCU GCC Linker" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.163881313"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.linker.1136579863" name="MCU G++ Linker" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.linker.13625971"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.archiver.670568324" name="MCU GCC Archiver" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.archiver.251758949"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.size.1206699770" name="MCU Size" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.size.1663377731"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objdump.listfile.490759253" name="MCU Output Converter list file" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objdump.listfile.1054983767"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.hex.1430840383" name="MCU Output Converter Hex" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.hex.959331179"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.binary.445793683" name="MCU Output Converter Binary" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.binary.673967072"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.verilog.519937944" name="MCU Output Converter Verilog" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.verilog.468761296"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.srec.1942260341" name="MCU Output Converter Motorola S-rec" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.srec.1968696221"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.symbolsrec.1107673949" name="MCU Output Converter Motorola S-rec with symbols" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.symbolsrec.319958895"/>
<folderInfo id="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.debug.1853947771.256072517" name="/" resourcePath="usrc/uicontroler/page">
<toolChain id="com.st.stm32cube.ide.mcu.gnu.managedbuild.toolchain.exe.debug.491694471" name="MCU ARM GCC" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.toolchain.exe.debug" unusedChildren="">
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_mcu.801178797.413757787" name="MCU" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_mcu.801178797"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_cpuid.777915677.1128828774" name="CPU" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_cpuid.777915677"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_coreid.1126839807.1544882588" name="Core" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_coreid.1126839807"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.fpu.2045742466.2143889879" name="Floating-point unit" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.fpu.2045742466"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.floatabi.2108401733.922458448" name="Floating-point ABI" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.floatabi.2108401733"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_board.1574925555.1963979311" name="Board" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_board.1574925555"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.defaults.244221814.534851607" name="Defaults" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.defaults.244221814"/>
<option id="com.st.stm32cube.ide.mcu.debug.option.cpuclock.764397174.1262549247" name="Cpu clock frequence" superClass="com.st.stm32cube.ide.mcu.debug.option.cpuclock.764397174"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.convertbinary.992660821.517370878" name="Convert to binary file (-O binary)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.convertbinary.992660821"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.converthex.494792904.1165820831" name="Convert to Intel Hex file (-O ihex)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.converthex.494792904"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.nanoscanffloat.176411214.854480565" name="Use float with scanf from newlib-nano (-u _scanf_float)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.nanoscanffloat.176411214"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.nanoprintffloat.164943344.920114011" name="Use float with printf from newlib-nano (-u _printf_float)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.nanoprintffloat.164943344"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.toolchain.386899990.926107084" name="Toolchain" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.toolchain.386899990"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.1632255751" name="MCU GCC Assembler" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.1243726437"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.1768689655" name="MCU GCC Compiler" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.782799112"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.1649365873" name="MCU G++ Compiler" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.344817877"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.655672310" name="MCU GCC Linker" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.163881313"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.linker.1042212218" name="MCU G++ Linker" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.linker.13625971"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.archiver.1406636191" name="MCU GCC Archiver" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.archiver.251758949"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.size.686313239" name="MCU Size" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.size.1663377731"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objdump.listfile.2004824788" name="MCU Output Converter list file" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objdump.listfile.1054983767"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.hex.1431424075" name="MCU Output Converter Hex" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.hex.959331179"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.binary.1949386257" name="MCU Output Converter Binary" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.binary.673967072"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.verilog.1494766544" name="MCU Output Converter Verilog" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.verilog.468761296"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.srec.235362573" name="MCU Output Converter Motorola S-rec" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.srec.1968696221"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.symbolsrec.498555001" name="MCU Output Converter Motorola S-rec with symbols" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.objcopy.symbolsrec.319958895"/>
</toolChain>
</folderInfo>
<fileInfo id="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.debug.1853947771.1288276238" name="zcanreceiver.hpp" rcbsApplicability="disable" resourcePath="stm32components/zcanreceiver/zcanreceiver.hpp" toolsToInvoke=""/>
@ -177,7 +177,7 @@
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="stm32halport"/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="uappbase"/>
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="ucomponents"/>
<entry excluding="uicontroler/page.bak|uicontroler/page" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="usrc"/>
<entry excluding="uicontroler/page.bak" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="usrc"/>
</sourceEntries>
</configuration>
</storageModule>

3
uappbase/apphal/apphal.cpp

@ -291,8 +291,9 @@ void AppHal::MX_I2C1_Init(void) {
__HAL_RCC_GPIOB_CLK_ENABLE();
__HAL_RCC_I2C1_CLK_ENABLE();
hi2c1.Instance = I2C1;
hi2c1.Instance = I2C1;
hi2c1.Init.ClockSpeed = 400000;
// hi2c1.Init.ClockSpeed = 1000000;
hi2c1.Init.DutyCycle = I2C_DUTYCYCLE_2;
hi2c1.Init.OwnAddress1 = 0;
hi2c1.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;

15
uappbase/zhdb/zhdb.cpp

@ -6,10 +6,11 @@
#include "ucomponents\eeprom\m24m02_i2c_eeprom.hpp"
uint8_t cache[50 * 1024] __attribute__((section(".ccmram")));
// uint8_t cache[40 * 1024] ;
using namespace iflytop;
static zhdb_table_t table[MAX_TABLE_NUM];
static zhdb_table_t tablecache[MAX_TABLE_NUM];
static uint32_t table_num = 0;
static uint32_t table_add_off = 0;
static zmutex lock("ZHDB");
@ -17,12 +18,19 @@ static zmutex lock("ZHDB");
static void read_from_eeprom(uint32_t add, uint8_t* data, size_t size) { //
for (size_t i = 0; i < size; i += 256) {
AppHardware::ins()->eeprom.read(add + i, data + i, 256);
// static uint8_t buf[256];
// AppHardware::ins()->eeprom.read(add + i, buf, 256);
// memcpy(data + i, buf, 256);
}
}
static void write_to_eeprom(uint32_t add, uint8_t* data, size_t size) { //
for (size_t i = 0; i < size; i += 256) {
AppHardware::ins()->eeprom.write(add + i, data + i, 256);
// static uint8_t buf[256];
// memcpy(buf, data + i, 256);
// AppHardware::ins()->eeprom.write(add + i, buf, 256);
}
}
@ -38,8 +46,7 @@ zhdb_table_t* ZHDB::allocTable(const char* name, size_t size) {
}
//
zhdb_table_t* table = &table[table_num];
uint32_t add = table_add_off;
zhdb_table_t* table = &tablecache[table_num];
table->add = &cache[table_add_off];
table->size = size;
@ -60,7 +67,7 @@ void ZHDB::storageData(uint8_t* data, size_t size) {
//
uint32_t off = data - cache;
uint32_t align_off = (off / 256) * 256;
uint32_t real_size = (size / 256 + 1) * 256;
uint32_t real_size = (size / 256 + 1) * 256;
write_to_eeprom(align_off, &cache[align_off], real_size);
}

1
uappbase/zhdb/zhdb.hpp

@ -6,6 +6,7 @@
#include "uappbase/appdep.hpp"
#define MAX_TABLE_NUM 10
#define TABLE_BASE_VERSION 0xAABBCCDE
namespace iflytop {

29
ucomponents/eeprom/m24m02_i2c_eeprom.cpp

@ -38,11 +38,18 @@ int32_t M24M02_I2C_EEPROM::write(int32_t add, uint8_t* val, int32_t len) {
ZASSERT(len % 4 == 0);
ZASSERT(add % 4 == 0);
int32_t ecode = 0;
for (int32_t i = 0; i < len; i += 4) {
ecode = write32(add + i, *(uint32_t*)&val[i]);
if (ecode != 0) return ecode;
uint16_t deviceadd = DATA_ADD + (add >> 16);
uint16_t regadd = add & 0xffff;
// ZLOGI(TAG, "write add:%x, len:%d", add, len);
HAL_StatusTypeDef status = HAL_I2C_Mem_Write(m_i2c_handle, deviceadd << 1, regadd, I2C_MEMADD_SIZE_16BIT, (uint8_t*)val, len, 1000);
if (status != HAL_OK) {
ZLOGE(TAG, "!!! write fail:%d !!!", status);
}
return ecode;
osDelay(12);
return halstatustoerr(status);
}
int32_t M24M02_I2C_EEPROM::read(int32_t add, uint8_t* val, int32_t len) {
zlock_guard lg(m_lock);
@ -50,11 +57,17 @@ int32_t M24M02_I2C_EEPROM::read(int32_t add, uint8_t* val, int32_t len) {
ZASSERT(len % 4 == 0);
ZASSERT(add % 4 == 0);
int32_t ecode = 0;
for (int32_t i = 0; i < len; i += 4) {
ecode = read32(add + i, (uint32_t*)&val[i]);
if (ecode != 0) return ecode;
uint16_t deviceadd = DATA_ADD + (add >> 16);
uint16_t regadd = add & 0xffff;
// ZLOGI(TAG, "read add:%x, len:%d", add, len);
HAL_StatusTypeDef status = HAL_I2C_Mem_Read(m_i2c_handle, deviceadd << 1, regadd, I2C_MEMADD_SIZE_16BIT, (uint8_t*)val, len, 1000);
if (status != HAL_OK) {
ZLOGE(TAG, "!!! read fail:%d !!!", status);
}
return ecode;
return halstatustoerr(status);
}
int32_t M24M02_I2C_EEPROM::readCfgReg(int32_t add, uint32_t* val) {

3
usrc/apphardware/apphardware.cpp

@ -1,4 +1,5 @@
#include "apphardware.hpp"
#include "ucomponents/zcan/zcan.hpp"
using namespace iflytop;
@ -12,7 +13,6 @@ void AppHardware::setTJCScreenInDownloadMode() {
void AppHardware::initialize() {
ZCAN1::ins()->zcaninit(CAN1_TX_PIN, CAN1_RX_PIN);
AppHal::MX_I2C1_Init();
AppHal::tmc_spi_init();
// TJC SCREEN UART INIT
@ -103,6 +103,7 @@ void AppHardware::initialize() {
IO_OUT1.setState(false);
IO_OUT2.setState(false);
AppHal::MX_I2C1_Init();
eeprom.initialize(&hi2c1);
if (!eeprom.isOnline()) {
ZLOGE(TAG, "eeprom is not online");

11
usrc/db/dao/acid_ch_cfg_dao.cpp

@ -9,7 +9,7 @@ using namespace iflytop;
/***********************************************************************************************************************
* MARCO *
***********************************************************************************************************************/
#define TABLE_VERSION 0xAABBCCDD
#define TABLE_VERSION TABLE_BASE_VERSION
#define TABLE_NAME "acid_ch_cfg_table"
/***********************************************************************************************************************
@ -22,6 +22,7 @@ static struct {
uint32_t version;
uint32_t maxid;
AcidChannelCfg_t item[4];
uint32_t end;
}* tabledata;
static void storgeTableData() { ZHDB::storageData((uint8_t*)tabledata, sizeof(*tabledata)); }
@ -31,9 +32,13 @@ void AcidChCfgDao::init() {
ASSERT(table != NULL, "alloc table failed");
tabledata = (decltype(tabledata))table->add;
if (TABLE_VERSION != tabledata->version) {
if (TABLE_VERSION != tabledata->version || TABLE_VERSION != tabledata->end) {
ZLOGI(TAG, "%s table version not match, reset table", TABLE_NAME);
tabledata->version = TABLE_VERSION;
tabledata->maxid = 0;
tabledata->end = TABLE_VERSION;
tabledata->maxid = 0;
for (int i = 0; i < 4; i++) {
tabledata->item[i].id = tabledata->maxid++; // ËáҺͨµÀid (0->3)

8
usrc/db/dao/acid_name_dao.cpp

@ -9,7 +9,7 @@ using namespace iflytop;
/***********************************************************************************************************************
* MARCO *
***********************************************************************************************************************/
#define TABLE_VERSION 0xAABBCCDD
#define TABLE_VERSION TABLE_BASE_VERSION
#define TABLE_NAME "acid_name_table"
/***********************************************************************************************************************
@ -22,6 +22,7 @@ static struct {
uint32_t version;
uint32_t maxid;
acid_name_t acidName[1];
uint32_t end;
}* tabledata;
static const char* defaultAcidName[MAX_ACID_NUM] = {
@ -52,8 +53,11 @@ void AcidNameDao::init() {
ASSERT(table != NULL, "alloc table failed");
tabledata = (decltype(tabledata))table->add;
if (TABLE_VERSION != tabledata->version) {
if (TABLE_VERSION != tabledata->version || TABLE_VERSION != tabledata->end) {
ZLOGI(TAG, "%s table version not match, reset table", TABLE_NAME);
tabledata->version = TABLE_VERSION;
tabledata->end = TABLE_VERSION;
tabledata->maxid = 0;
// ³õʼ»¯ËáÒºÃû³Æ

13
usrc/db/dao/device_setting_dao.cpp

@ -9,7 +9,7 @@ using namespace iflytop;
/***********************************************************************************************************************
* MARCO *
***********************************************************************************************************************/
#define TABLE_VERSION 0xAABBCCDD
#define TABLE_VERSION TABLE_BASE_VERSION
#define TABLE_NAME "device_setting_dao"
/***********************************************************************************************************************
@ -22,6 +22,7 @@ static struct {
uint32_t version;
uint32_t maxid;
device_setting_t item[1];
uint32_t end;
}* tabledata;
/***********************************************************************************************************************
@ -34,13 +35,15 @@ void DeviceSettingDao::init() {
ASSERT(table != NULL, "alloc table failed");
tabledata = (decltype(tabledata))table->add;
if (TABLE_VERSION != tabledata->version) {
if (TABLE_VERSION != tabledata->version || TABLE_VERSION != tabledata->end) {
ZLOGI(TAG, "%s table version not match, reset table", TABLE_NAME);
tabledata->version = TABLE_VERSION;
tabledata->maxid = 0;
tabledata->end = TABLE_VERSION;
// ³õʼ»¯ËáÒºÃû³Æ
tabledata->item[0].id = tabledata->maxid++;
tabledata->item[0].echDitrUpLimit = 99;
tabledata->item[0].id = tabledata->maxid++;
tabledata->item[0].echDitrUpLimit = 99;
tabledata->item[0].distrIntervalS = 1.5;
strncpy(tabledata->item[0].bleClientName, "", sizeof(tabledata->item[0].bleClientName));
}

9
usrc/db/dao/user_dao.cpp

@ -9,7 +9,7 @@ using namespace iflytop;
/***********************************************************************************************************************
* MARCO *
***********************************************************************************************************************/
#define TABLE_VERSION 0xAABBCCDD
#define TABLE_VERSION TABLE_BASE_VERSION
#define MAX_USR_NUM 10
#define TABLE_NAME "user_table"
@ -23,6 +23,7 @@ static struct {
uint32_t version;
uint32_t maxid;
user_t user[MAX_USR_NUM];
uint32_t end;
}* tabledata;
/***********************************************************************************************************************
@ -50,8 +51,12 @@ void UserDao::init() { //
ASSERT(table != NULL, "alloc table failed");
tabledata = (decltype(tabledata))table->add;
if (TABLE_VERSION != tabledata->version) {
if (TABLE_VERSION != tabledata->version || TABLE_VERSION != tabledata->end) {
ZLOGI(TAG, "%s table version not match, reset table", TABLE_NAME);
tabledata->version = TABLE_VERSION;
tabledata->end = TABLE_VERSION;
tabledata->maxid = 0;
for (int i = 0; i < MAX_USR_NUM; i++) {
tabledata->user[i].effective = false;

69
usrc/service/app_core.cpp

@ -12,10 +12,20 @@
#include "ucomponents/zcan/zcan.hpp"
//
#include "uicontroler/front_end_controler.hpp"
#include "uicontroler/page/page.hpp"
// #include "uicontroler/page/page.hpp"
//
#include "uappbase/zhdb/zhdb.hpp"
//
#include "db/dao/acid_ch_cfg_dao.hpp"
#include "db/dao/acid_name_dao.hpp"
#include "db/dao/device_setting_dao.hpp"
#include "db/dao/user_dao.hpp"
#define TAG "main"
using namespace iflytop;
static ZThread ledthread;
static const char* zhex2str(uint8_t* data, size_t len) {
static char buf[256];
@ -26,31 +36,10 @@ static const char* zhex2str(uint8_t* data, size_t len) {
return buf;
}
extern "C" {
void umain() { AppCore::ins()->initialize(); }
}
static ZThread ledthread;
void AppCore::initialize() {
AppHal::MX_TIM6_Init();
AppHal::MX_TIM7_Init();
AppHal::DEBUG_UART_INIT(DEBUG_TX_PIN, DEBUG_RX_PIN, DEBUG_UART_BAUDRATE);
zlog_init(&DEBUG_UART_INS);
ZLOGI(TAG, "======================= boardinfo ==================== ");
ZLOGI(TAG, "project : %s ", PROJECT);
ZLOGI(TAG, "version : %s ", APP_VERSION);
ZLOGI(TAG, "sn : %s", sn_get_str());
ZLOGI(TAG, "=");
SysMgr::ins()->initedFinished();
SysMgr::ins()->dumpSysInfo();
static void debuglegInit() {
// 启动调试指示灯功能
ledthread.init("led", 1024, osPriorityNormal);
ledthread.start([this]() {
ledthread.start([]() {
static iflytop::ZGPIO debuglight;
debuglight.initAsOutput(DEBUG_LIGHT_IO, kxs_gpio_nopull, false, false);
while (true) {
@ -74,8 +63,27 @@ void AppCore::initialize() {
osDelay(30);
}
});
}
extern "C" {
void umain() { AppCore::ins()->initialize(); }
}
void AppCore::initialize() {
AppHal::MX_TIM6_Init();
AppHal::MX_TIM7_Init();
AppHal::DEBUG_UART_INIT(DEBUG_TX_PIN, DEBUG_RX_PIN, DEBUG_UART_BAUDRATE);
zlog_init(&DEBUG_UART_INS);
ZLOGI(TAG, "======================= boardinfo ==================== ");
ZLOGI(TAG, "project : %s ", PROJECT);
ZLOGI(TAG, "version : %s ", APP_VERSION);
ZLOGI(TAG, "sn : %s", sn_get_str());
ZLOGI(TAG, "=");
osDelay(1000);
SysMgr::ins()->initedFinished();
SysMgr::ins()->dumpSysInfo();
// 硬件无关组件初始化
GStateMgr::ins()->initialize();
@ -83,11 +91,18 @@ void AppCore::initialize() {
// 硬件初始化
AppHardware::ins()->initialize(); // 基础硬件初始化
FrontEndControler::ins()->initialize();
// FrontEndControler::ins()->chpage(pg_main);
ZLOGI(TAG, "load zhdb");
ZHDB::init();
UserDao::init();
AcidNameDao::init();
AcidChCfgDao::init();
DeviceSettingDao::init();
ZLOGI(TAG, "load zhdb end");
FrontEndControler::ins()->initialize();
PageInit();
FrontEndControler::ins()->chpage(pg_login);
while (true) osDelay(30);
}

8
usrc/service/remote_controler_event_processer.cpp

@ -103,11 +103,11 @@ void RemoteControlerEventProcesser::processKeyEventFromRemoter(hand_acid_remoter
}
/**
* @brief
* @brief ,TODO
*/
if (UIS->getNowPage() == pg_login || UIS->getNowPage() == pg_pStart || UIS->getNowPage() == pg_muBleHandSett || UIS->getNowPage() == pg_muPumpTest) {
return;
}
// if (UIS->getNowPage() == pg_login || UIS->getNowPage() == pg_pStart || UIS->getNowPage() == pg_muBleHandSett || UIS->getNowPage() == pg_muPumpTest) {
// return;
// }
/**
* @brief

1
usrc/uicontroler/base/page_processer.hpp

@ -17,6 +17,7 @@ class OnPageLoadContext {
class IPageProcesser {
private:
/* data */
protected:
uint32_t pageId = 0;
public:

4
usrc/uicontroler/front_end_controler.hpp

@ -58,10 +58,10 @@ class FrontEndControler {
bool echo(uint8_t tx, uint8_t* rx);
bool setTxt(uint8_t pid, uint8_t bid, const char* txt, ...);
bool setTxt(uint8_t bid, const char* txt) { return setTxt(m_nowPage, bid, txt); }
// bool setTxt(uint8_t bid, const char* txt) { return setTxt(m_nowPage, bid, txt); }
bool setVal(uint8_t pid, uint8_t bid, int32_t val);
bool setVal(uint8_t bid, int32_t val) { return setVal(m_nowPage, bid, val); }
// bool setVal(uint8_t bid, int32_t val) { return setVal(m_nowPage, bid, val); }
bool vis(uint16_t bid, int32_t val); // ²»Ö§³Ö¿çÒ³ÃæÒþ²Ø
// vis b0,0

50
usrc/uicontroler/page/login/page_login.cpp

@ -1,8 +1,10 @@
#pragma once
#include "db/dao/user_dao.hpp"
#include "ui/ui.h"
#include "uicontroler/base/page_processer.hpp"
namespace iflytop {
using namespace std;
#define TAG "PageLogin"
class PageLogin : public IPageProcesser {
private:
@ -10,23 +12,61 @@ class PageLogin : public IPageProcesser {
PageLogin() : IPageProcesser(pg_login) {}
char userName[20] = {0};
char passwd[20] = {0};
public:
static PageLogin* ins() {
static PageLogin instance;
return &instance;
}
virtual void initialize() override {
IPageProcesser::initialize();
UIS->setTxt(pageId, ob_login_uName, ""); // 用户名
UIS->setTxt(pageId, ob_login_uNameEMsg, ""); // 用户名错误信息
UIS->setTxt(pageId, ob_login_pwd, ""); // 密码
UIS->setTxt(pageId, ob_login_pwdEMsg, ""); // 密码错误信息
}
private:
virtual void OnPageLoad(OnPageLoadContext* cxt) override {}
virtual void OnBackKey(OnPageLoadContext* cxt) override {}
virtual void OnInputFieldContentChange(uint8_t bid, const char* text) override {}
virtual void OnButton(uint8_t bid, uint8_t val) override {}
virtual void OnDoubleStateButton(uint8_t bid, uint8_t val) override {}
virtual void OnAppEvent(AppEvent_t* event) override {}
};
virtual void OnInputFieldContentChange(uint8_t bid, const char* text) override {
if (bid == ob_login_uName) {
UIS->setTxt(pageId, ob_login_uName, text); //
strcpy(userName, text); //
UIS->setTxt(pageId, ob_login_pwdEMsg, ""); //
UIS->setTxt(pageId, ob_login_uNameEMsg, ""); //
} else if (bid == ob_login_pwd) {
UIS->setTxt(pageId, ob_login_pwd, text); //
strcpy(passwd, text); //
UIS->setTxt(pageId, ob_login_pwdEMsg, ""); //
UIS->setTxt(pageId, ob_login_pwdEMsg, ""); //
}
}
virtual void OnButton(uint8_t bid, uint8_t val) override {
if (bid == ob_login_blogin) {
user_t* user = UserDao::getUserByName(userName);
if (user == nullptr) {
UIS->setTxt(pageId, ob_login_uNameEMsg, "用户名不存在");
return;
}
if (strcmp(user->passwd, passwd) != 0) {
UIS->setTxt(pageId, ob_login_pwdEMsg, "密码错误");
return;
}
ZLOGI(TAG, "login %s success", userName);
}
}
virtual void OnDoubleStateButton(uint8_t bid, uint8_t val) override {}
virtual void OnAppEvent(AppEvent_t* event) override {}
private:
};
void PageLoginInit() { PageLogin::ins()->initialize(); }

8
usrc/uicontroler/page/page.hpp

@ -0,0 +1,8 @@
#pragma once
namespace iflytop {
void PageLoginInit();
static inline void PageInit() { PageLoginInit(); }
} // namespace iflytop

36
usrc/uicontroler/pagerouter/page_bak_router.cpp

@ -3,26 +3,26 @@ using namespace iflytop;
namespace iflytop {
int getBakPage(int nowPage) {
if (
// if (
nowPage == pg_muInterval || //
nowPage == pg_muUsrMgr || //
nowPage == pg_muTmrMgr || //
nowPage == pg_muAcidType || //
nowPage == pg_muDeviceInfo || //
nowPage == pg_muSettings || //
nowPage == pg_muAudit //
) {
return GSM->getMenuPage();
}
// nowPage == pg_muInterval || //
// nowPage == pg_muUsrMgr || //
// nowPage == pg_muTmrMgr || //
// nowPage == pg_muAcidType || //
// nowPage == pg_muDeviceInfo || //
// nowPage == pg_muSettings || //
// nowPage == pg_muAudit //
// ) {
// return GSM->getMenuPage();
// }
if (nowPage == pg_muPumpTest || //
nowPage == pg_muBleHandSett || //
nowPage == pg_muMotorSett || //
nowPage == pg_muPumpSett //
) {
return pg_muSettings;
}
// if (nowPage == pg_muPumpTest || //
// nowPage == pg_muBleHandSett || //
// nowPage == pg_muMotorSett || //
// nowPage == pg_muPumpSett //
// ) {
// return pg_muSettings;
// }
return pg_main;
}

Loading…
Cancel
Save