/********************************************************************************************************* ** Function name: saveDetailTradeInfo ** Descriptions: 保存详细交易记录 ** input parameters: 无 ** output parameters: 无 ** Returned value: 无 *********************************************************************************************************/ void saveDetailTradeInfo(void) { unsigned short addr = 0; unsigned short len,crc; unsigned char buf[ADD_TRADE_PAGE_LEN] = {0}; //确定交易页号 if(stTotalTrade.tradePageNo < TRADE_MAX_PAGE) stTotalTrade.tradePageNo++; else stTotalTrade.tradePageNo = 1; RTCReadTime(&stDetailTradeInfo.tradeTime); addr = ADD_TRADE_INFO + stTotalTrade.tradePageNo * ADD_TRADE_PAGE_LEN; len = sizeof(stDetailTradeInfo); memcpy(buf,(void *)&stDetailTradeInfo,len); crc = CrcCheck(buf,len); buf[len + 0] = HUINT16(crc); buf[len + 1] = LUINT16(crc); saveFlash(addr,buf,ADD_TRADE_PAGE_LEN); //清本次交易数据信息 memset((void *)&stDetailTradeInfo,0,sizeof(stDetailTradeInfo)); }
/********************************************************************************************************* ** Function name: save_data ** Descriptions: 保存信息 ** input parameters: ptr:写入flash的数据指针, len 写入长度 最大长度不超过240字节 addr写入的起始地址 ** output parameters: 无 ** Returned value: 0 失败 1成功 *********************************************************************************************************/ static unsigned char save_data(void *ptr,unsigned short len,unsigned short addr) { unsigned short crc; unsigned char buf[256] = {0};//256字节 分8次存储 if(!ptr || !len || (len > 240)) return 0; memcpy(buf,ptr,len); crc = CrcCheck(buf,len); buf[len + 0] = HUINT16(crc); buf[len + 1] = LUINT16(crc); len += 2; saveFlash(addr,buf,256); return 1; }
/********************************************************************************************************* ** Function name: saveSystemParaFromFlash ** Descriptions: 将系统参数保存到flash中 4个字节存 ** input parameters: ** output parameters: 无 ** Returned value: 无 *********************************************************************************************************/ unsigned char saveSystemParaFromFlash() { unsigned char buf[256] = {0}; unsigned short len = 0,crc; memcpy(&buf[len],stDevValue.BillValue,8 * 4);//纸币器通道面值 len += 8 * 4; memcpy(&buf[len],stDevValue.CoinValue,8 * 4);//硬币器通道面值 len += 8 * 4; memcpy(&buf[len],stDevValue.HpValue,HOPPER_NUMS * 4);//hopper通道面值 len += HOPPER_NUMS * 4; memcpy(&buf[len],(unsigned char *)&SYSPara,sizeof(SYSPara)); len += sizeof(SYSPara); crc = CrcCheck(buf,len); buf[len + 0] = HUINT16(crc); buf[len + 1] = LUINT16(crc); return saveFlash(ADD_SYSTEM_PARA,buf,len + 2); }
void save() { saveFlash(data, LEN_DATA); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); // Register QtKeypadBridge for the virtual keyboard functionality ui->keypadWidget->installEventFilter(&qt_keypad_bridge); ui->lcdView->installEventFilter(&qt_keypad_bridge); //Emu -> GUI (QueuedConnection as they're different threads) connect(&emu, SIGNAL(serialChar(char)), this, SLOT(serialChar(char)), Qt::QueuedConnection); connect(&emu, SIGNAL(debugStr(QString)), this, SLOT(debugStr(QString))); //Not queued connection as it may cause a hang connect(&emu, SIGNAL(speedChanged(double)), this, SLOT(showSpeed(double)), Qt::QueuedConnection); connect(&emu, SIGNAL(statusMsg(QString)), ui->statusbar, SLOT(showMessage(QString)), Qt::QueuedConnection); connect(&emu, SIGNAL(turboModeChanged(bool)), ui->buttonSpeed, SLOT(setChecked(bool)), Qt::QueuedConnection); connect(&emu, SIGNAL(usblinkChanged(bool)), this, SLOT(usblinkChanged(bool)), Qt::QueuedConnection); //Menu "Emulator" connect(ui->buttonReset, SIGNAL(clicked(bool)), &emu, SLOT(reset())); connect(ui->actionReset, SIGNAL(triggered()), &emu, SLOT(reset())); connect(ui->actionRestart, SIGNAL(triggered()), this, SLOT(restart())); connect(ui->actionDebugger, SIGNAL(triggered()), &emu, SLOT(enterDebugger())); connect(ui->buttonPause, SIGNAL(clicked(bool)), &emu, SLOT(setPaused(bool))); connect(ui->buttonPause, SIGNAL(clicked(bool)), ui->actionPause, SLOT(setChecked(bool))); connect(ui->actionPause, SIGNAL(toggled(bool)), &emu, SLOT(setPaused(bool))); connect(ui->actionPause, SIGNAL(toggled(bool)), ui->buttonPause, SLOT(setChecked(bool))); connect(ui->buttonSpeed, SIGNAL(clicked(bool)), &emu, SLOT(setTurboMode(bool))); QShortcut *shortcut = new QShortcut(QKeySequence(Qt::Key_F11), this); shortcut->setAutoRepeat(false); connect(shortcut, SIGNAL(activated()), &emu, SLOT(toggleTurbo())); //Menu "Tools" connect(ui->buttonScreenshot, SIGNAL(clicked()), this, SLOT(screenshot())); connect(ui->actionScreenshot, SIGNAL(triggered()), this, SLOT(screenshot())); connect(ui->actionConnect, SIGNAL(triggered()), this, SLOT(connectUSB())); connect(ui->buttonUSB, SIGNAL(clicked(bool)), this, SLOT(connectUSB())); connect(ui->actionXModem, SIGNAL(triggered()), this, SLOT(xmodemSend())); ui->actionConnect->setShortcut(QKeySequence(Qt::Key_F10)); ui->actionConnect->setAutoRepeat(false); //Menu "Flash" connect(ui->actionSave, SIGNAL(triggered()), this, SLOT(saveFlash())); connect(ui->actionCreate_flash, SIGNAL(triggered()), this, SLOT(createFlash())); //Debugging connect(ui->lineEdit, SIGNAL(returnPressed()), this, SLOT(debugCommand())); //File transfer connect(ui->refreshButton, SIGNAL(clicked(bool)), this, SLOT(reload_filebrowser())); connect(this, SIGNAL(usblink_progress_changed(int)), this, SLOT(changeProgress(int)), Qt::QueuedConnection); //Settings connect(ui->checkDebugger, SIGNAL(toggled(bool)), this, SLOT(setDebuggerOnStartup(bool))); connect(ui->checkWarning, SIGNAL(toggled(bool)), this, SLOT(setDebuggerOnWarning(bool))); connect(ui->uiDocks, SIGNAL(toggled(bool)), this, SLOT(setUIMode(bool))); connect(ui->checkAutostart, SIGNAL(toggled(bool)), this, SLOT(setAutostart(bool))); connect(ui->fileBoot1, SIGNAL(pressed()), this, SLOT(selectBoot1())); connect(ui->fileFlash, SIGNAL(pressed()), this, SLOT(selectFlash())); connect(ui->pathTransfer, SIGNAL(textEdited(QString)), this, SLOT(setUSBPath(QString))); connect(ui->spinGDB, SIGNAL(valueChanged(int)), this, SLOT(setGDBPort(int))); connect(ui->spinRDBG, SIGNAL(valueChanged(int)), this, SLOT(setRDBGPort(int))); connect(ui->orderDiags, SIGNAL(toggled(bool)), this, SLOT(setBootOrder(bool))); //Set up monospace fonts QFont monospace = QFontDatabase::systemFont(QFontDatabase::FixedFont); ui->debugConsole->setFont(monospace); ui->serialConsole->setFont(monospace); qRegisterMetaType<QVector<int>>(); #ifdef Q_OS_ANDROID //On android the settings file is deleted everytime you update or uninstall, //so choose a better, safer, location QString path = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation); settings = new QSettings(path + "/nspire_emu.ini", QSettings::IniFormat); #else settings = new QSettings(); #endif //Load settings setUIMode(settings->value("docksEnabled", true).toBool()); restoreGeometry(settings->value("windowGeometry").toByteArray()); restoreState(settings->value("windowState").toByteArray(), WindowStateVersion); selectBoot1(settings->value("boot1", "").toString()); selectFlash(settings->value("flash", "").toString()); setDebuggerOnStartup(settings->value("debugOnStart", false).toBool()); setDebuggerOnWarning(settings->value("debugOnWarn", false).toBool()); setUSBPath(settings->value("usbdir", QString("ndless")).toString()); setGDBPort(settings->value("gdbPort", 3333).toUInt()); setRDBGPort(settings->value("rdbgPort", 3334).toUInt()); setBootOrder(false); bool autostart = settings->value("emuAutostart", false).toBool(); setAutostart(autostart); if(emu.boot1 != "" && emu.flash != "" && autostart) emu.start(); else ui->statusbar->showMessage(trUtf8("Start the emulation via Emulation->Restart.")); #ifdef Q_OS_MAC QTimer::singleShot(50, [&] {dockVisibilityChanged(false);}); // Trigger dock update (after UI was shown) #endif }