bool QPMCache::insert(const QString& key, const QPixmap &pixmap, int cost) { QPixmapCache::Key cacheKey; QPixmapCache::Key oldCacheKey = cacheKeys.value(key); //If for the same key we add already a pixmap we should delete it if (oldCacheKey.d) { QCache<QPixmapCache::Key, QPixmapCacheEntry>::remove(oldCacheKey); cacheKeys.remove(key); } //we create a new key the old one has been removed cacheKey = createKey(); bool success = QCache<QPixmapCache::Key, QPixmapCacheEntry>::insert(cacheKey, new QPixmapCacheEntry(cacheKey, pixmap), cost); if (success) { cacheKeys.insert(key, cacheKey); if (!theid) { theid = startTimer(flush_time); t = false; } } else { //Insertion failed we released the new allocated key releaseKey(cacheKey); } return success; }
/********************************** 功能说明 *********************************** * 主菜单 -> 维护菜单 *******************************************************************************/ void menu_Maintenance( void ) { extern void menu_ConfigureEx( void ); static struct uMenu const menu[] = { { 0x0202u, "维护" }, { 0x0C07u, "配置" }, { 0x0C19u, "标定" }, { 0x1807u, "记录" }, { 0x1819u, "版本" } }; uint8_t item = 1u; uint32_t password = InputPassword(); if (( Configure.Password != password ) && ( SysPassword1a != password )) { return; } do { cls(); Menu_Redraw( menu ); item = Menu_Select( menu, item, NULL ); switch( item ) { case 1: if ( ! Sampler_isRunning( Q_ALL )) { menu_Configure(); } break; case 2: if ( ! Sampler_isRunning( Q_ALL )) { menu_Calibrate(); } break; case 3: PowerLog_Query(); break; case 4: ShowEdition(); if ( K_RIGHT == getKey()) { if ( ! releaseKey( K_RIGHT, 100u )) { beep(); menu_ConfigureEx(); } } break; default: break; } } while( enumSelectESC != item ); }
/* This is supposed to cut the cache size down by about 25% in a minute once the application becomes idle, to let any inserted pixmap remain in the cache for some time before it becomes a candidate for cleaning-up, and to not cut down the size of the cache while the cache is in active use. When the last pixmap has been deleted from the cache, kill the timer so Qt won't keep the CPU from going into sleep mode. */ void QPMCache::timerEvent(QTimerEvent *) { int mc = maxCost(); bool nt = totalCost() == ps; setMaxCost(nt ? totalCost() * 3 / 4 : totalCost() -1); setMaxCost(mc); ps = totalCost(); QHash<QString, QPixmapCache::Key>::iterator it = cacheKeys.begin(); while (it != cacheKeys.end()) { if (!contains(it.value())) { releaseKey(it.value()); it = cacheKeys.erase(it); } else { ++it; } } if (!size()) { killTimer(theid); theid = 0; } else if (nt != t) { killTimer(theid); theid = startTimer(nt ? 10000 : 30000); t = nt; } }
void menu_UserMaintenance( void ) { static struct uMenu const menu[] = { { 0x0302u, "仪器维护" }, { 0x0802u, "仪器设置" }, { 0x0814u, "采样设定" }, { 0x1002u, "采样累计" }, { 0x1014u, "仪器标定" }, { 0x1802u, "运行记录" }, { 0x1814u, "型号版本" } }; uint8_t item = 1u; do { cls(); Menu_Redraw( menu ); item = Menu_Select( menu, item, NULL ); switch( item ) { case 1: Instrument_Set(); break; case 2: menu_SampleConfigure(); break; case 3: menu_SamplerSum(); break; case 4: menu_Calibrate(); break; case 5: PowerLog_Query(); break; case 6: ShowEdition(); if ( K_RIGHT == getKey()) { if ( ! releaseKey( K_RIGHT, 100u )) { beep(); menu_ConfigureEx(); } } break; default: break; } } while( enumSelectESC != item ); }
void keyMouse::applyKeys(){ INPUT eventPress = {0}; INPUT eventRelease = {0}; bool send = false; //Check if there is anything new to press for(std::vector<std::string>::size_type i = 0; i != buttons.size(); i++) { //if in buttons and not in buttonsOld press it if(!(std::find(buttonsOld.begin(), buttonsOld.end(), buttons[i]) != buttonsOld.end())){ // buttonsOld does not contain buttons[i] so press the button if(buttons[i].find("KEY") != std::string::npos){ pressKey(eventPress, bmap[buttons[i]]); send = true; }else if(buttons[i].find("MOUSE") != std::string::npos){ pressMouse(eventPress, bmap[buttons[i]]); send = true; }else if(buttons[i].find("MOTION") != std::string::npos){ send = false; processMotionPress(buttons[i]); } if(send == true){ SendInput( 1, &eventPress, sizeof( eventPress ) ); } } } //Check if anything that was pressed last time is now unpressed for(std::vector<std::string>::size_type i = 0; i != buttonsOld.size(); i++) { //if in buttonsOld and not in buttons release it if( !(std::find(buttons.begin(), buttons.end(), buttonsOld[i]) != buttons.end())) { // buttons does not contain buttonsOld[i] so release the button press if(buttonsOld[i].find("KEY") != std::string::npos){ releaseKey(eventRelease, bmap[buttonsOld[i]]); send = true; // std::cout << " ReleaseKey: " << buttonsOld[i] << "\n"; }else if(buttonsOld[i].find("MOUSE") != std::string::npos){ releaseMouse(eventRelease, bmap[buttonsOld[i]]); send = true; //std::cout << " ReleaseMouse: " << buttonsOld[i] << "\n"; }else if(buttonsOld[i].find("MOTION") != std::string::npos){ send = false; processMotionRelease(buttonsOld[i]); } if(send == true){ SendInput( 1, &eventRelease, sizeof( eventRelease ) ); } } } buttonsOld = buttons; //clear the vector buttons.clear(); }
void Keyboard::onEvent(const SDL_Event& event) { if (event.type == SDL_KEYDOWN) { if (!event.key.repeat) { pressKey(event.key.keysym.scancode); } } if (event.type == SDL_KEYUP) { releaseKey(event.key.keysym.scancode); } }
QPixmapCache::Key QPMCache::insert(const QPixmap &pixmap, int cost) { QPixmapCache::Key cacheKey = createKey(); bool success = QCache<QPixmapCache::Key, QPixmapCacheEntry>::insert(cacheKey, new QPixmapCacheEntry(cacheKey, pixmap), cost); if (success) { if (!theid) { theid = startTimer(flush_time); t = false; } } else { //Insertion failed we released the key and return an invalid one releaseKey(cacheKey); } return cacheKey; }
void KeyTracker::keyEvent(QKeyEvent *event) { switch (event->type()) { case QEvent::KeyPress: pressKey(event->key()); setModifiers(event->modifiers()); break; case QEvent::KeyRelease: releaseKey(event->key()); break; default: break; } }
bool QPMCache::replace(const QPixmapCache::Key &key, const QPixmap &pixmap, int cost) { Q_ASSERT(key.d->isValid); //If for the same key we had already an entry so we should delete the pixmap and use the new one QCache<QPixmapCache::Key, QPixmapCacheEntry>::remove(key); QPixmapCache::Key cacheKey = createKey(); bool success = QCache<QPixmapCache::Key, QPixmapCacheEntry>::insert(cacheKey, new QPixmapCacheEntry(cacheKey, pixmap), cost); if (success) { if(!theid) { theid = startTimer(flush_time); t = false; } const_cast<QPixmapCache::Key&>(key) = cacheKey; } else { //Insertion failed we released the key releaseKey(cacheKey); } return success; }
/* This is supposed to cut the cache size down by about 25% in a minute once the application becomes idle, to let any inserted pixmap remain in the cache for some time before it becomes a candidate for cleaning-up, and to not cut down the size of the cache while the cache is in active use. When the last detached pixmap has been deleted from the cache, kill the timer so Qt won't keep the CPU from going into sleep mode. Currently the timer is not restarted when the pixmap becomes unused, but it does restart once something else is added (i.e. the cache space is actually needed). Returns \c true if any were removed. */ bool QPMCache::flushDetachedPixmaps(bool nt) { int mc = maxCost(); setMaxCost(nt ? totalCost() * 3 / 4 : totalCost() -1); setMaxCost(mc); ps = totalCost(); bool any = false; QHash<QString, QPixmapCache::Key>::iterator it = cacheKeys.begin(); while (it != cacheKeys.end()) { if (!contains(it.value())) { releaseKey(it.value()); it = cacheKeys.erase(it); any = true; } else { ++it; } } return any; }
/********************************** 功能说明 *********************************** * 扩展配置 -> 泵累计运行时间 *******************************************************************************/ static void menu_Clean_SumTime( void ) { BOOL Done = FALSE; do{ cls(); // Lputs( 0x0000u, "运行时间(小时)" ); Lputs( 0x0000u, "粉尘:" ); ShowFP32( 0x0005u, PumpSumTimeLoad( PP_TSP ) / 60.0f, 0x0601u, "h" ); Lputs( 0x0200u, "A:" ); ShowFP32( 0x0202u, PumpSumTimeLoad( PP_R24_A ) / 60.0f, 0x0601u, NULL ); Lputs( 0x0208u, "B:" ); ShowFP32( 0x020Au, PumpSumTimeLoad( PP_R24_B ) / 60.0f, 0x0601u, NULL ); Lputs( 0x0400u, "C:" ); ShowFP32( 0x0402u, PumpSumTimeLoad( PP_SHI_C ) / 60.0f, 0x0601u, NULL ); Lputs( 0x0408u, "D:" ); ShowFP32( 0x040Au, PumpSumTimeLoad( PP_SHI_D ) / 60.0f, 0x0601u, NULL ); Lputs( 0x0600u, "大气:" ); ShowFP32( 0x0605u, PumpSumTimeLoad( PP_AIR ) / 60.0f, 0x0601u, NULL ); switch ( getKey() ) { case K_OK : if ( ! releaseKey( K_OK, 100u )) { beep(); if ( vbYes == MsgBox( "清除累计时间 ?", vbYesNo | vbDefaultButton2 )) { PumpSumTimeSave( PP_TSP, 0u ); PumpSumTimeSave( PP_R24_A, 0u ); PumpSumTimeSave( PP_R24_B, 0u ); PumpSumTimeSave( PP_SHI_C, 0u ); PumpSumTimeSave( PP_SHI_D, 0u ); PumpSumTimeSave( PP_AIR, 0u ); } } break; case K_ESC : Done = TRUE; break; default : break; } }while( !Done ); }
/********************************** 功能说明 *********************************** * 系统配置 -> 文件号 *******************************************************************************/ static void menu_Clean_FileNum( void ) { BOOL Done = FALSE; do{ cls(); // Lputs( 0x0000u, "文件号" ); Lputs( 0x0000u, "粉尘:" ); ShowI16U( 0x0009u, SampleSet[Q_TSP].FileNum, 0x0300u, NULL ); Lputs( 0x0200u, "日均:" ); ShowI16U( 0x0209u, SampleSet[Q_R24].FileNum, 0x0300u, NULL ); Lputs( 0x0400u, "时均:" ); ShowI16U( 0x0409u, SampleSet[Q_SHI].FileNum, 0x0300u, NULL ); Lputs( 0x0600u, "大气:" ); ShowI16U( 0x0609u, SampleSet[Q_AIR].FileNum, 0x0300u, NULL ); switch ( getKey() ) { case K_OK : if ( ! releaseKey( K_OK, 100u )) { beep(); if ( vbYes == MsgBox( "清除所有文件 ?", vbYesNo | vbDefaultButton2 ) ) { File_Clean(); SampleSet[Q_TSP].FileNum = SampleSet[Q_R24].FileNum = SampleSet[Q_SHI].FileNum = SampleSet[Q_AIR].FileNum = 0u; SampleSetSave(); } } break; case K_ESC : Done = TRUE; break; default : break; } }while( !Done ); }
BOOL EditI32U( uint16_t yx, uint32_t * pNUM, uint16_t fmt ) { uint32_t PowN; uint32_t Num = *pNUM; uint8_t M, N, choice = 0u; CHAR sbuffer[20]; uint16_t gray = Configure.DisplayGray; BOOL graychanged = FALSE; N = fmt % 0x100u; // 小数点后的有效位数 M = ( N == 0 ) ? ( fmt / 0x100 ) : ( fmt / 0x100 - 1 ); // 有效位数, 即choice 变化范围 Num = Num % tbl_pow10_I32U[M]; // 保留低位, 清零高位 for (;;) { sprintf( sbuffer, "%0*.*f", ( fmt / 0x100 ), ( fmt % 0x100 ), Num / tbl_pow10_FP32[N] ); Lputs( yx, sbuffer ); if ( choice < ( M - N )) { LcmMask( yx + choice, 1 ); // 输入位置在小数点之前 } else { LcmMask( yx + choice + 1, 1 ); // 输入位置在小数点之后 } if ( M >= ( choice + 1u )) { PowN = tbl_pow10_I32U[ M - ( choice + 1u )]; } else { PowN = 1u; } switch ( getKey() ) { case K_INC: if( Num / PowN % 10 == 9 ) { Num -= PowN * 9; } else { Num += PowN; } break; case K_DEC: if( Num / PowN % 10 == 0 ) { Num += PowN * 9; } else { Num -= PowN; } break; case K_RIGHT: //case K_XCH: choice = ( choice + 1 ) % M; break; case K_LEFT: choice = ( choice + M - 1 ) % M; break; case K_OK: *pNUM = Num; return TRUE; case K_ESC: return FALSE; case K_OK_UP: if ( gray < 2050u ) { ++gray; } if( ! releaseKey( K_OK_UP,100 )) { while( ! releaseKey( K_OK_UP, 3 )) { ++gray; DisplaySetGrayVolt( gray * 0.01f ); } } graychanged = true; break; case K_OK_DOWN: if ( gray > 200u ) { --gray; } if( ! releaseKey( K_OK_DOWN,100 )) { while( ! releaseKey( K_OK_DOWN, 1 )) { --gray; DisplaySetGrayVolt( gray * 0.01f ); } } graychanged = true; break; case K_OK_RIGHT: if ( gray < ( 2000u - 50u )) { gray += 100u; } graychanged = true; break; case K_OK_LEFT: if ( gray > ( 200 + 20u )) { gray -= 20u; } graychanged = true; break; default: break; } if( graychanged == true ) { DisplaySetGrayVolt( gray * 0.01f ); Configure.DisplayGray = gray; ConfigureSave(); graychanged = FALSE; } } }
bool KeyController::handleEvent(Event *evt) { bool retVal=true; if (evt->Type==MM_MOUSEMOVE || evt->Type==MM_LBUTTONDOWN) // Keine MouseEvents durchlassen! { retVal=false; evt->Type=MM_NO_EVENT; } if (evt->Type==HEX_MOUSE_CHANGE) { evt->Type=MM_MOUSEMOVE; evt->lData=(iMouseY<<16) + iMouseX; evt->wData=0; } if (evt->Type==MM_KEYDOWN) { if (evt->wData==iUp) pushKey(0); if (evt->wData==iDown) pushKey(1); if (evt->wData==iLeft) pushKey(2); if (evt->wData==iRight) pushKey(3); if (evt->wData==iFire) { evt->Type=MM_LBUTTONDOWN; evt->lData=(iMouseY<<16) + iMouseX; evt->wData=0; } evt=processKeyMove(evt); } if (evt->Type==MM_KEYUP) { if (evt->wData==iUp) { evt->Type=MM_MOUSEMOVE; releaseKey(0); } if (evt->wData==iDown) { evt->Type=MM_MOUSEMOVE; releaseKey(1); } if (evt->wData==iLeft) { evt->Type=MM_MOUSEMOVE; releaseKey(2); } if (evt->wData==iRight) { evt->Type=MM_MOUSEMOVE; releaseKey(3); } if (evt->wData==iFire) { evt->Type=MM_LBUTTONUP; } if (evt->Type==MM_MOUSEMOVE || evt->Type==MM_LBUTTONUP) { evt->lData=(iMouseY<<16) + iMouseX; evt->wData=0; } } return retVal; }
uint8_t Menu_SelectOnlyEx ( const struct uMenu * menu, uint8_t item, void ( *pHook ) ( void ),BOOL Direction ) { //TRUE 改纵向 FALSE 改横向 uint8_t mlen, mlen_row, mlen_col; uint16_t gray = Configure.DisplayGray; BOOL graychanged = FALSE; BOOL Flag = FALSE; mlen_row = HIBYTE ( menu[0].yx ); mlen_col = LOBYTE ( menu[0].yx ); if ( 0u == mlen_row ) { mlen = mlen_col; } else { mlen = mlen_row * mlen_col; } if ( ( item < 1u ) || ( item > mlen ) ) { item = 1u; } for ( ; ; ) { LcmMask ( menu[item].yx, strlen ( menu[item].sz ), menu[item].sz ); do { if ( NULL != pHook ) { pHook(); } } while ( ! hitKey ( 50u ) ); Lputs ( menu[item].yx, menu[item].sz ); switch ( getKey() ) { case K_RIGHT: if((!Direction) && (!Flag)) { item += mlen_col; if ( item > mlen ) { item -= mlen; } } else { if ( 0 == ( item % mlen_col ) ) { item -= mlen_col; } ++item; } break; case K_LEFT: if((!Direction) && (!Flag)) { if ( item <= mlen_col ) { item += mlen; } item -= mlen_col; } else { --item; if ( 0 == ( item % mlen_col ) ) { item += mlen_col; } } break; case K_DOWN: if( Direction && (!Flag) ) { if ( 0 == ( item % mlen_col ) ) { item -= mlen_col; } ++item; } else { item += mlen_col; if ( item > mlen ) { item -= mlen; } } break; case K_UP: if( Direction && (!Flag) ) { --item; if ( 0 == ( item % mlen_col ) ) { item += mlen_col; } } else { if ( item <= mlen_col ) { item += mlen; } item -= mlen_col; } break; case K_OK: Flag = TRUE; return item; case K_ESC: Flag = FALSE; return enumSelectESC; case K_SHIFT: return enumSelectXCH; case K_OK_UP: if ( gray < 999 ) { ++gray; } if( ! releaseKey( K_OK_UP,100 )) { while( ! releaseKey( K_OK_UP, 1 )) { ++gray; DisplaySetGrayVolt( gray * 0.022f ); } } graychanged = true; break; case K_OK_DOWN: if ( gray > 10u ) { --gray; } if( ! releaseKey( K_OK_DOWN, 100 )) { while( ! releaseKey( K_OK_DOWN, 1 )) { --gray; DisplaySetGrayVolt( gray * 0.022f ); } } graychanged = true; break; case K_OK_RIGHT: if ( gray < ( 1000u - 50u )) { gray += 50u; } graychanged = true; break; case K_OK_LEFT: if ( gray > ( 10 + 50u )) { gray -= 50u; } graychanged = true; break; case K_ESC_SHIFT: if ( ! releaseKey( K_ESC_SHIFT, 200 )) { item = enumSelectESC; beep(); delay( 100u ); beep(); cls(); Lputs( 0x0608u, "请输入出厂编号:" ); ConfigureLoad(); if( EditI32U( 0x0C0Cu, &Configure.ExNum, 0x0700u )) { if( vbYes == MsgBox("是否保存编号?",vbYesNo) ) ConfigureSave(); else ConfigureLoad(); } return enumSelectESC; } default: break; } if( graychanged == true ) { DisplaySetGrayVolt( gray * 0.022f ); Configure.DisplayGray = gray; ConfigureSave(); graychanged = FALSE; } } }
/********************************** 功能说明 *********************************** * 传感器标定->大气压力 *******************************************************************************/ static void menu_Calibrate_Ba( void ) { struct uMenu const menu[] = { { 0x0201u, "标定大气压" }, { 0x1000u, "零点" }, { 0x1800u, "倍率" } }; enum { opt_exit, opt_origin, opt_slope, opt_max, opt_min = opt_origin }; uint8_t option = opt_min; uint16_t gray = Configure.DisplayGray; BOOL graychanged = FALSE; BOOL changed = FALSE; cls(); Menu_Redraw( menu ); do { ShowI16U( 0x100Cu, CalibrateLocal.origin_Ba, 0x0502u, NULL ); ShowI16U( 0x180Cu, CalibrateLocal. slope_Ba, 0x0503u, NULL ); Menu_Item_Mask( menu, option ); do{ Lputs( 0x0800u, "大气压:" ); ShowFP32( 0x0811u, _sys_get_Ba(), 0x0602u, "kPa" ); } while( ! hitKey( 25u )); Menu_Item_Mask( menu, option ); switch( getKey()) { case K_DOWN: ++option; if ( option >= opt_max ) { option = opt_min; } break; case K_UP: if( option <= opt_min ) { option = opt_max; } --option; break; case K_OK: switch( option ) { case opt_origin: if ( EditI16U( 0x100Cu, &CalibrateLocal.origin_Ba, 0x0502u )) { changed = TRUE; } break; case opt_slope: if ( EditI16U( 0x180Cu, &CalibrateLocal. slope_Ba, 0x0503u )) { changed = TRUE; } break; default: break; } break; case K_ESC: if( ! changed ) { option = opt_exit; } else { switch( MsgBox( "保存标定数据 ?", vbYesNoCancel + vbDefaultButton3 )) { case vbYes: CalibrateSave(); option = opt_exit; break; case vbNo: CalibrateLoad(); option = opt_exit; break; case vbCancel: cls(); Menu_Redraw( menu ); break; default: break; } } break; case K_OK_UP: if ( gray < 2200u ) { ++gray; } if( ! releaseKey( K_OK_UP,100 )) { while( ! releaseKey( K_OK_UP, 1 )) { ++gray; DisplaySetGrayVolt( gray * 0.01f ); } } graychanged = true; break; case K_OK_DOWN: if ( gray > 200u ) { --gray; } if( ! releaseKey( K_OK_DOWN, 100 )) { while( ! releaseKey( K_OK_DOWN, 1 )) { --gray; DisplaySetGrayVolt( gray * 0.01f ); } } graychanged = true; break; case K_OK_RIGHT: if ( gray < ( 2000u - 50u )) { gray += 100u; } graychanged = true; break; case K_OK_LEFT: if ( gray > ( 200 + 20u )) { gray -= 20u; } graychanged = true; break; default: break; } if( graychanged == true ) { DisplaySetGrayVolt( gray * 0.01f ); Configure.DisplayGray = gray; ConfigureSave(); graychanged = FALSE;; } } while( opt_exit != option ); }
void menu_Calibrate_Battery( void ) { struct uMenu const menu[] = { { 0x0301u, NULL }, // "电池" }, { 0x0800u, "电压" }, { 0x1000u, "电流" }, { 0x1800u, "门限" }, }; enum { opt_exit, opt_voltage, opt_current, opt_threshold, opt_max, opt_min = opt_voltage }; uint8_t option = opt_min; BOOL changed = FALSE; uint16_t gray = Configure.DisplayGray; BOOL graychanged = FALSE; cls(); Menu_Redraw( menu ); do { ShowI16U( 0x080Cu, Configure.slope_Bat_Voltage, 0x0503u, NULL ); ShowI16U( 0x100Cu, Configure.slope_Bat_Current, 0x0503u, NULL ); ShowI16U( 0x180Cu, Configure.threshold_Current, 0x0503u, NULL ); Menu_Item_Mask( menu, option ); do{ ShowFP32( 0x0000u, get_Bat_Voltage(), 0x0603u, "V," ); ShowFP32( 0x0014u, get_Bat_Current(), 0x0603u, "A " ); } while( ! hitKey( 25u )); Menu_Item_Mask( menu, option ); switch( getKey()) { case K_DOWN: ++option; if ( option >= opt_max ) { option = opt_min; } break; case K_UP: if( option <= opt_min ) { option = opt_max; } --option; break; case K_OK: switch( option ) { case opt_voltage: if ( EditI16U( 0x080Cu, &Configure.slope_Bat_Voltage, 0x0503u )) { changed = TRUE; } break; case opt_current: if ( EditI16U( 0x100Cu, &Configure.slope_Bat_Current, 0x0503u )) { changed = TRUE; } break; case opt_threshold: if ( EditI16U( 0x180Cu, &Configure.threshold_Current, 0x0503u )) { changed = true; } break; default: break; } break; case K_ESC: if( ! changed ) { option = opt_exit; } else { switch( MsgBox( "保存标定数据 ?", vbYesNoCancel + vbDefaultButton3 )) { case vbYes: ConfigureSave(); // CalibrateSave(); option = opt_exit; break; case vbNo: ConfigureLoad(); // CalibrateLoad(); option = opt_exit; break; case vbCancel: cls(); Menu_Redraw( menu ); break; } } break; case K_OK_UP: if ( gray < 2200u ) { ++gray; } if( ! releaseKey( K_OK_UP,100 )) { while( ! releaseKey( K_OK_UP, 1 )) { ++gray; DisplaySetGrayVolt( gray * 0.01f ); } } graychanged = true; break; case K_OK_DOWN: if ( gray > 200u ) { --gray; } if( ! releaseKey( K_OK_DOWN, 100 )) { while( ! releaseKey( K_OK_DOWN, 1 )) { --gray; DisplaySetGrayVolt( gray * 0.01f ); } } graychanged = true; break; case K_OK_RIGHT: if ( gray < ( 2000u - 50u )) { gray += 100u; } graychanged = true; break; case K_OK_LEFT: if ( gray > ( 200 + 20u )) { gray -= 20u; } graychanged = true; break; default: break; } if( graychanged == true ) { DisplaySetGrayVolt( gray * 0.01f ); Configure.DisplayGray = gray; ConfigureSave(); graychanged = FALSE;; } } while( opt_exit != option ); }
BOOL CalibrateFlow_1_Point_DEBUG( enum enumPumpSelect PumpSelect, uint16_t * const p_FlowK ) { BOOL done = FALSE; BOOL changed = FALSE; uint16_t gray = Configure.DisplayGray; BOOL graychanged = FALSE; uint32_t Flow32 = 0; FP32 Flown,Flow = 0.0f; uint16_t fmt = 0x0000u; const CHAR * szUnit = NULL; switch ( PumpSelect ) { case PP_TSP : fmt = 0x0501u; szUnit = "L/m"; break; case PP_R24_A: fmt = 0x0503u; szUnit = "L/m"; break; case PP_R24_B: fmt = 0x0503u; szUnit = "L/m"; break; default: break; } cls(); Pump_OutCmd( PumpSelect, TRUE ); while ( ! done ) { do { // 实时显示流量 FP32 fstd = get_fstd( PumpSelect ); if( PumpSelect == PP_TSP ) { FP32 Ba = get_Ba(); FP32 Te = get_Te();// PumpSelect ); FP32 flow = Calc_flow( fstd, Te, 0.0f, Ba, Q_TSP ); // Calc_flow( fstd, Tr, Pr, Ba ); Flow = flow; Lputs ( 0x0000u, "流量倍率:" ); ShowI16U( 0x0019u, * p_FlowK, 0x0503u, NULL ); Lputs ( 0x0800u, "工况:" ); ShowFP32( 0x080Cu, flow, fmt, szUnit ); Lputs ( 0x1000u, "标况:" ); ShowFP32( 0x100Cu, fstd, fmt, szUnit ); Lputs ( 0x1800u, "输出:" ); ShowPercent( 0x180Cu, Pump_GetOutput( PumpSelect )); } else { Flow = fstd; Lputs( 0x0000u, "流量倍率:" ); ShowI16U( 0x0019u, * p_FlowK, 0x0503u, NULL ); // Lputs ( 0x0800u, "工况:" ); ShowFP32( 0x080Cu, flow, fmt, szUnit ); Lputs ( 0x0C00u, "标况:" ); ShowFP32( 0x0C0Cu, fstd, fmt, szUnit ); Lputs ( 0x1800u, "输出:" ); ShowPercent( 0x180Cu, Pump_GetOutput( PumpSelect )); } } while ( ! hitKey( 100u )); switch ( getKey()) { case K_UP: if ( * p_FlowK < 9999u ) { ++ * p_FlowK; } changed = TRUE; break; case K_DOWN: if ( * p_FlowK > 99u ) { -- * p_FlowK; } changed = TRUE; break; case K_OK: Flow32 = Configure.SetFlow[PumpSelect]; if( PumpSelect == PP_TSP ) { LcmMask( 0x0800u, 3u, CHARsz ); if ( EditI32U( 0x080Cu, &Flow32, fmt ) ) { changed = TRUE; Flown = ( FP32 ) Flow32; if( * p_FlowK != 0 ) Flow = Flow / ( * p_FlowK * 0.001 ); else Flow = Flown; if(Flow != 0) * p_FlowK =(uint16_t) ( Flown * 100 / Flow ) ; else * p_FlowK = 1000; } } else { LcmMask( 0x0C00u, 3u, CHARsz ); if ( EditI32U( 0x0C0Cu, &Flow32, fmt ) ) { changed = TRUE; Flown = ( FP32 ) Flow32; if( * p_FlowK != 0 ) Flow = Flow / ( * p_FlowK * 0.001 ); else Flow = Flown; if(Flow != 0) * p_FlowK =(uint16_t) ( Flown / Flow ) ; else * p_FlowK = 1000; } } break; case K_ESC: done = TRUE; break; case K_OK_UP: if ( gray < 2200u ) { ++gray; } if( ! releaseKey( K_OK_UP,100 )) { while( ! releaseKey( K_OK_UP, 1 )) { ++gray; DisplaySetGrayVolt( gray * 0.01f ); } } graychanged = true; break; case K_OK_DOWN: if ( gray > 200u ) { --gray; } if( ! releaseKey( K_OK_DOWN, 100 )) { while( ! releaseKey( K_OK_DOWN, 1 )) { --gray; DisplaySetGrayVolt( gray * 0.01f ); } } graychanged = true; break; case K_OK_RIGHT: if ( gray < ( 2000u - 50u )) { gray += 100u; } graychanged = true; break; case K_OK_LEFT: if ( gray > ( 200 + 20u )) { gray -= 20u; } graychanged = true; break; default: break; } if( graychanged == true ) { DisplaySetGrayVolt( gray * 0.01f ); Configure.DisplayGray = gray; ConfigureSave(); graychanged = FALSE;; } } Pump_OutCmd( PumpSelect, FALSE ); return changed; }
void InputManager::updateKeys() { if (glfwGetKey(m_window, GLFW_KEY_0) == GLFW_PRESS) { pressKey(KEYS::NUM_0); } else { releaseKey(KEYS::NUM_1); } if (glfwGetKey(m_window, GLFW_KEY_1) == GLFW_PRESS) { pressKey(KEYS::NUM_1); } else { releaseKey(KEYS::NUM_1); } if (glfwGetKey(m_window, GLFW_KEY_2) == GLFW_PRESS) { pressKey(KEYS::NUM_2); } else { releaseKey(KEYS::NUM_2); } if (glfwGetKey(m_window, GLFW_KEY_3) == GLFW_PRESS) { pressKey(KEYS::NUM_3); } else { releaseKey(KEYS::NUM_3); } if (glfwGetKey(m_window, GLFW_KEY_4) == GLFW_PRESS) { pressKey(KEYS::NUM_4); } else { releaseKey(KEYS::NUM_4); } if (glfwGetKey(m_window, GLFW_KEY_5) == GLFW_PRESS) { pressKey(KEYS::NUM_5); } else { releaseKey(KEYS::NUM_5); } if (glfwGetKey(m_window, GLFW_KEY_6) == GLFW_PRESS) { pressKey(KEYS::NUM_6); } else { releaseKey(KEYS::NUM_6); } if (glfwGetKey(m_window, GLFW_KEY_7) == GLFW_PRESS) { pressKey(KEYS::NUM_7); } else { releaseKey(KEYS::NUM_7); } if (glfwGetKey(m_window, GLFW_KEY_8) == GLFW_PRESS) { pressKey(KEYS::NUM_8); } else { releaseKey(KEYS::NUM_8); } if (glfwGetKey(m_window, GLFW_KEY_9) == GLFW_PRESS) { pressKey(KEYS::NUM_9); } else { releaseKey(KEYS::NUM_9); } if (glfwGetKey(m_window, GLFW_KEY_A) == GLFW_PRESS) { pressKey(KEYS::A); } else { releaseKey(KEYS::A); } if (glfwGetKey(m_window, GLFW_KEY_B) == GLFW_PRESS) { pressKey(KEYS::B); } else { releaseKey(KEYS::B); } if (glfwGetKey(m_window, GLFW_KEY_C) == GLFW_PRESS) { pressKey(KEYS::C); } else { releaseKey(KEYS::C); } if (glfwGetKey(m_window, GLFW_KEY_D) == GLFW_PRESS) { pressKey(KEYS::D); } else { releaseKey(KEYS::D); } if (glfwGetKey(m_window, GLFW_KEY_E) == GLFW_PRESS) { pressKey(KEYS::E); } else { releaseKey(KEYS::E); } if (glfwGetKey(m_window, GLFW_KEY_F) == GLFW_PRESS) { pressKey(KEYS::F); } else { releaseKey(KEYS::F); } if (glfwGetKey(m_window, GLFW_KEY_G) == GLFW_PRESS) { pressKey(KEYS::G); } else { releaseKey(KEYS::G); } if (glfwGetKey(m_window, GLFW_KEY_H) == GLFW_PRESS) { pressKey(KEYS::H); } else { releaseKey(KEYS::H); } if (glfwGetKey(m_window, GLFW_KEY_I) == GLFW_PRESS) { pressKey(KEYS::I); } else { releaseKey(KEYS::I); } if (glfwGetKey(m_window, GLFW_KEY_J) == GLFW_PRESS) { pressKey(KEYS::J); } else { releaseKey(KEYS::J); } if (glfwGetKey(m_window, GLFW_KEY_K) == GLFW_PRESS) { pressKey(KEYS::K); } else { releaseKey(KEYS::K); } if (glfwGetKey(m_window, GLFW_KEY_L) == GLFW_PRESS) { pressKey(KEYS::L); } else { releaseKey(KEYS::L); } if (glfwGetKey(m_window, GLFW_KEY_M) == GLFW_PRESS) { pressKey(KEYS::M); } else { releaseKey(KEYS::M); } if (glfwGetKey(m_window, GLFW_KEY_N) == GLFW_PRESS) { pressKey(KEYS::N); } else { releaseKey(KEYS::N); } if (glfwGetKey(m_window, GLFW_KEY_O) == GLFW_PRESS) { pressKey(KEYS::O); } else { releaseKey(KEYS::O); } if (glfwGetKey(m_window, GLFW_KEY_P) == GLFW_PRESS) { pressKey(KEYS::P); } else { releaseKey(KEYS::P); } if (glfwGetKey(m_window, GLFW_KEY_Q) == GLFW_PRESS) { pressKey(KEYS::Q); } else { releaseKey(KEYS::Q); } if (glfwGetKey(m_window, GLFW_KEY_R) == GLFW_PRESS) { pressKey(KEYS::R); } else { releaseKey(KEYS::R); } if (glfwGetKey(m_window, GLFW_KEY_S) == GLFW_PRESS) { pressKey(KEYS::S); } else { releaseKey(KEYS::S); } if (glfwGetKey(m_window, GLFW_KEY_T) == GLFW_PRESS) { pressKey(KEYS::T); } else { releaseKey(KEYS::T); } if (glfwGetKey(m_window, GLFW_KEY_U) == GLFW_PRESS) { pressKey(KEYS::U); } else { releaseKey(KEYS::U); } if (glfwGetKey(m_window, GLFW_KEY_V) == GLFW_PRESS) { pressKey(KEYS::V); } else { releaseKey(KEYS::V); } if (glfwGetKey(m_window, GLFW_KEY_W) == GLFW_PRESS) { pressKey(KEYS::W); } else { releaseKey(KEYS::W); } if (glfwGetKey(m_window, GLFW_KEY_X) == GLFW_PRESS) { pressKey(KEYS::X); } else { releaseKey(KEYS::X); } if (glfwGetKey(m_window, GLFW_KEY_Y) == GLFW_PRESS) { pressKey(KEYS::Y); } else { releaseKey(KEYS::Y); } if (glfwGetKey(m_window, GLFW_KEY_Z) == GLFW_PRESS) { pressKey(KEYS::Z); } else { releaseKey(KEYS::Z); } if (glfwGetKey(m_window, GLFW_KEY_ESCAPE) == GLFW_PRESS) { pressKey(KEYS::ESC); } else { releaseKey(KEYS::ESC); } if (glfwGetKey(m_window, GLFW_KEY_TAB) == GLFW_PRESS) { pressKey(KEYS::TAB); } else { releaseKey(KEYS::TAB); } if (glfwGetKey(m_window, GLFW_KEY_LEFT_SHIFT) == GLFW_PRESS) { pressKey(KEYS::LFET_SHIFT); } else { releaseKey(KEYS::LFET_SHIFT); } if (glfwGetKey(m_window, GLFW_KEY_LEFT_CONTROL) == GLFW_PRESS) { pressKey(KEYS::LEFT_COTROL); } else { releaseKey(KEYS::LEFT_COTROL); } if (glfwGetKey(m_window, GLFW_KEY_LEFT_ALT) == GLFW_PRESS) { pressKey(KEYS::LEFT_ALT); } else { releaseKey(KEYS::LEFT_ALT); } if (glfwGetKey(m_window, GLFW_KEY_SPACE) == GLFW_PRESS) { pressKey(KEYS::SPACE); } else { releaseKey(KEYS::SPACE); } if (glfwGetKey(m_window, GLFW_KEY_RIGHT_ALT) == GLFW_PRESS) { pressKey(KEYS::RIGHT_ALT); } else { releaseKey(KEYS::RIGHT_ALT); } if (glfwGetKey(m_window, GLFW_KEY_RIGHT_CONTROL) == GLFW_PRESS) { pressKey(KEYS::RIGHT_CONTROL); } else { releaseKey(KEYS::RIGHT_CONTROL); } if (glfwGetKey(m_window, GLFW_KEY_RIGHT_SHIFT) == GLFW_PRESS) { pressKey(KEYS::RIGHT_SHIFT); } else { releaseKey(KEYS::RIGHT_SHIFT); } if (glfwGetKey(m_window, GLFW_KEY_ENTER) == GLFW_PRESS) { pressKey(KEYS::ENTER); } else { releaseKey(KEYS::ENTER); } if (glfwGetKey(m_window, GLFW_KEY_BACKSPACE) == GLFW_PRESS) { pressKey(KEYS::BACKSPACE); } else { releaseKey(KEYS::BACKSPACE); } if (glfwGetKey(m_window, GLFW_KEY_UP) == GLFW_PRESS) { pressKey(KEYS::UP); } else { releaseKey(KEYS::UP); } if (glfwGetKey(m_window, GLFW_KEY_DOWN) == GLFW_PRESS) { pressKey(KEYS::DOWN); } else { releaseKey(KEYS::DOWN); } if (glfwGetKey(m_window, GLFW_KEY_LEFT) == GLFW_PRESS) { pressKey(KEYS::LEFT); } else { releaseKey(KEYS::LEFT); } if (glfwGetKey(m_window, GLFW_KEY_RIGHT) == GLFW_PRESS) { pressKey(KEYS::RIGHT); } else { releaseKey(KEYS::RIGHT); } if (glfwGetKey(m_window, GLFW_KEY_F1) == GLFW_PRESS) { pressKey(KEYS::F1); } else { releaseKey(KEYS::F1); } if (glfwGetKey(m_window, GLFW_KEY_F2) == GLFW_PRESS) { pressKey(KEYS::F2); } else { releaseKey(KEYS::F2); } if (glfwGetKey(m_window, GLFW_KEY_F3) == GLFW_PRESS) { pressKey(KEYS::F3); } else { releaseKey(KEYS::F3); } if (glfwGetMouseButton(m_window, GLFW_MOUSE_BUTTON_LEFT) == GLFW_PRESS) { pressKey(KEYS::MOUSE_LEFT); } else { releaseKey(KEYS::MOUSE_LEFT); } if (glfwGetMouseButton(m_window, GLFW_MOUSE_BUTTON_MIDDLE) == GLFW_PRESS) { pressKey(KEYS::MOUSE_MIDDLE); } else { releaseKey(KEYS::MOUSE_MIDDLE); } if (glfwGetMouseButton(m_window, GLFW_MOUSE_BUTTON_RIGHT) == GLFW_PRESS) { pressKey(KEYS::MOUSE_RIGHT); } else { releaseKey(KEYS::MOUSE_RIGHT); } }
/* if( ! releaseKey( K_OK_DOWN, 100 )) { // cls(); while( ! releaseKey( K_OK_DOWN, 1 )) { --gray; DisplaySetGrayVolt( gray * 0.022f ); // ShowPercent( 0x080B, (FP32) gray / 2200 ); } // while ( ! hitKey ( 50u )); // cls(); } graychanged = true;*/ uint8_t Menu_Select_Ex ( const struct uMenu * menu, uint8_t item, void ( *pHook ) ( void ) ) { uint8_t mlen, mlen_row, mlen_col; uint16_t gray = Configure.DisplayGray; BOOL graychanged = FALSE; mlen_row = HIBYTE ( menu[0].yx ); mlen_col = LOBYTE ( menu[0].yx ); if ( 0u == mlen_row ) { mlen = mlen_col; } else { mlen = mlen_row * mlen_col; } if ( ( item < 1u ) || ( item > mlen ) ) { item = 1u; } for ( ; ; ) { LcmMask ( menu[item].yx, strlen ( menu[item].sz ), menu[item].sz ); do { if ( NULL != pHook ) { pHook(); } } while ( ! hitKey ( 50u ) ); Lputs ( menu[item].yx, menu[item].sz ); switch ( getKey() ) { case K_RIGHT: if ( 0 == ( item % mlen_col ) ) { item -= mlen_col; } ++item; break; case K_LEFT: --item; if ( 0 == ( item % mlen_col ) ) { item += mlen_col; } break; case K_DOWN: item += mlen_col; if ( item > mlen ) { item -= mlen; } break; case K_UP: if ( item <= mlen_col ) { item += mlen; } item -= mlen_col; break; case K_OK: return item; case K_ESC: return enumSelectESC; case K_SHIFT: return enumSelectXCH; case K_OK_UP: if ( gray < 999 ) { ++gray; } if( ! releaseKey( K_OK_UP,100 )) { while( ! releaseKey( K_OK_UP, 1 )) { ++gray; DisplaySetGrayVolt( gray * 0.022f ); } } graychanged = true; break; case K_OK_DOWN: if ( gray > 10u ) { --gray; } if( ! releaseKey( K_OK_DOWN, 100 )) { while( ! releaseKey( K_OK_DOWN, 1 )) { --gray; DisplaySetGrayVolt( gray * 0.022f ); } } graychanged = true; break; case K_OK_RIGHT: if ( gray < ( 1000u - 50u )) { gray += 50u; } graychanged = true; break; case K_OK_LEFT: if ( gray > ( 10 + 50u )) { gray -= 50u; } graychanged = true; break; default: break; } if( graychanged == true ) { DisplaySetGrayVolt( gray * 0.022f ); Configure.DisplayGray = gray; ConfigureSave(); graychanged = FALSE; } } }
/********************************** 功能说明 *********************************** * 传感器标定->计前压力 *******************************************************************************/ static void Calibrate_Pr( enum enumPumpSelect PumpSelect ) { struct uMenu const menu[] = { { 0x0201u, "标定计前压力" }, { 0x1000u, "零点" }, { 0x1800u, "倍率" } }; enum { opt_exit, opt_origin, opt_slope, opt_max, opt_min = 1 }; uint8_t option = opt_min; BOOL need_redraw = TRUE; uint16_t gray = Configure.DisplayGray; BOOL graychanged = FALSE; uint16_t *p_origin = &CalibrateRemote.origin[esid_pr][PumpSelect]; uint16_t *p_slope = &CalibrateRemote.slope [esid_pr][PumpSelect]; BOOL changed = FALSE; do { if ( need_redraw ) { cls(); Menu_Redraw( menu ); ShowPumpSelect( 0x0115u, PumpSelect ); need_redraw = FALSE; } ShowI16U( 0x100Cu, *p_origin, 0x0500u, NULL ); ShowI16U( 0x180Cu, *p_slope, 0x0503u, NULL ); Menu_Item_Mask( menu, option ); do{ Lputs( 0x0800u, "计压:" ); ShowFP32( 0x080C, get_Pr( PumpSelect ), 0x0602, "kPa" ); } while( ! hitKey( 25u )); Menu_Item_Mask( menu, option ); switch( getKey()) { case K_DOWN: ++option; if ( option >= opt_max ) { option = opt_min; } break; case K_UP: if( option <= opt_min ) { option = opt_max; } --option; break; case K_OK: switch( option ) { case opt_origin: if ( EditI16U( 0x100Cu, p_origin, 0x0500u )) { changed = TRUE; } break; case opt_slope: if ( EditI16U( 0x180Cu, p_slope, 0x0503u )) { changed = TRUE; } break; default: break; } break; case K_ESC: if( ! changed ) { option = opt_exit; } else { switch( MsgBox( "保存标定数据 ?", vbYesNoCancel + vbDefaultButton3 )) { case vbYes: CalibrateSave(); option = opt_exit; break; case vbNo: CalibrateSave(); option = opt_exit; break; default: break; } need_redraw = TRUE; } break; case K_OK_UP: if ( gray < 2200u ) { ++gray; } if( ! releaseKey( K_OK_UP,100 )) { while( ! releaseKey( K_OK_UP, 1 )) { ++gray; DisplaySetGrayVolt( gray * 0.01f ); } } graychanged = true; break; case K_OK_DOWN: if ( gray > 200u ) { --gray; } if( ! releaseKey( K_OK_DOWN, 100 )) { while( ! releaseKey( K_OK_DOWN, 1 )) { --gray; DisplaySetGrayVolt( gray * 0.01f ); } } graychanged = true; break; case K_OK_RIGHT: if ( gray < ( 2000u - 50u )) { gray += 100u; } graychanged = true; break; case K_OK_LEFT: if ( gray > ( 200 + 20u )) { gray -= 20u; } graychanged = true; break; default: break; } if( graychanged == true ) { DisplaySetGrayVolt( gray * 0.01f ); Configure.DisplayGray = gray; ConfigureSave(); graychanged = FALSE;; } } while( opt_exit != option ); }
/********************************** 功能说明 *********************************** * 流量调校程序 *******************************************************************************/ BOOL CalibrateFLOW_4_Point_DEBUG( enum enumPumpSelect PumpSelect, uint16_t FlowKSet[], FP32 const PointSet[], uint8_t PointSelect ) { enum { opt_exit, opt_standard, }; uint8_t option = opt_standard; BOOL changed = FALSE; BOOL need_redraw = TRUE; uint16_t gray = Configure.DisplayGray; BOOL graychanged = FALSE; uint16_t FlowKSave[4]; uint16_t slope; uint32_t Flow32; FP32 Flown,Flow = 0.0f; // 暂存原始数据,包括所有点的倍率、设定流量。 slope = FlowKSet[PointSelect]; FlowKSave[0] = FlowKSet[0]; FlowKSave[1] = FlowKSet[1]; FlowKSave[2] = FlowKSet[2]; FlowKSave[3] = FlowKSet[3]; // 设置流量 Configure.SetFlow[PumpSelect] = ( uint16_t)( PointSet[PointSelect] * 1.0e+1f + 0.5f ); // 开启泵流量控制 Pump_OutCmd( PumpSelect, TRUE ); // Motor_OutCmd( MotorSelect, TRUE ); do { if ( need_redraw ) { cls(); Lputs( 0x0000u, "调试流量"); need_redraw = FALSE; } // 将所有点的倍率调整到当前倍率 FlowKSet[0] = FlowKSet[1] = FlowKSet[2] = FlowKSet[3] = slope; // 显示倍率 do { // 实时显示流量 Lputs( 0x0000u, "流量倍率:" ); ShowI16U( 0x0019u, slope, 0x0503u, NULL ); Lputs( 0x0C00u, "流量:" ); ShowFP32( 0x0C0Cu, get_fstd( PumpSelect ), 0x0603u, "L/m" ); Lputs( 0x1800u, "输出:" ); ShowPercent( 0x180Cu, Pump_GetOutput( PumpSelect )); } while ( ! hitKey( 100u )); switch ( getKey()) { case K_UP: if ( slope < 9999u ) { ++slope; } changed = TRUE; break; case K_DOWN: if ( slope > 99u ) { --slope; } changed = TRUE; break; case K_OK: Flow32 = Configure.SetFlow[PumpSelect] * 100; LcmMask( 0x0C00u, 3u, CHARsz ); if ( EditI32U( 0x0C0Cu, &Flow32, 0x0603u )) { changed = TRUE; Flown = ( FP32 ) Flow32; if( slope != 0 ) Flow = Flow / ( slope *0.001); else Flow = Flown / 1000; if( Flow != 0 ) slope =(uint16_t) ( Flown / Flow ) ; else slope = 1000; } break; case K_ESC: option = opt_exit; break; case K_OK_UP: if ( gray < 2200u ) { ++gray; } if( ! releaseKey( K_OK_UP,100 )) { while( ! releaseKey( K_OK_UP, 1 )) { ++gray; DisplaySetGrayVolt( gray * 0.01f ); } } graychanged = true; break; case K_OK_DOWN: if ( gray > 200u ) { --gray; } if( ! releaseKey( K_OK_DOWN, 100 )) { while( ! releaseKey( K_OK_DOWN, 1 )) { --gray; DisplaySetGrayVolt( gray * 0.01f ); } } graychanged = true; break; case K_OK_RIGHT: if ( gray < ( 2000u - 50u )) { gray += 100u; } graychanged = true; break; case K_OK_LEFT: if ( gray > ( 200 + 20u )) { gray -= 20u; } graychanged = true; break; default: break; } if( graychanged == true ) { DisplaySetGrayVolt( gray * 0.01f ); Configure.DisplayGray = gray; ConfigureSave(); graychanged = FALSE;; } } while ( opt_exit != option ); Pump_OutCmd( PumpSelect, FALSE ); // 恢复除当前点之外的其他校准点的倍率。 FlowKSet[0] = FlowKSave[0]; FlowKSet[1] = FlowKSave[1]; FlowKSet[2] = FlowKSave[2]; FlowKSet[3] = FlowKSave[3]; FlowKSet[PointSelect] = slope; return changed; }
static void PumpConfigure( void ) { enum { opt_exit, opt_tsp_1, opt_tsp_2, opt_tsp_3, opt_max, opt_min = opt_tsp_1 }; uint16_t gray = Configure.DisplayGray; BOOL graychanged = FALSE; uint8_t opt_m; uint8_t option = opt_min; uint16_t dispchar [6] ={ 0x0602u, 0x0A02u, 0x0E02u, 0x1202u, 0x1602u, 0x1A02u }; uint16_t dispchar2[6] ={ 0x060Bu, 0x0A0Bu, 0x0E0Bu, 0x120Bu, 0x160Bu, 0x1A0Bu }; uint8_t i,imax; do { imax = i = 0; ConfigureLoad(); if( Configure.PumpType[PP_TSP] != enumPumpNone ) { switch ( Configure.PumpType[PP_TSP] ) { case enumOrifice_1: TypeC[i] = 0;break; case enumOrifice_2: TypeC[i] = 1;break; } PumpC[i++] = 0; } if( Configure.PumpType[PP_R24_A] != enumPumpNone ) { switch (Configure.PumpType[PP_R24_A] ) { case enumOrifice_1:TypeC[i] = 2;break; case enumOrifice_2:TypeC[i] = 3;break; } PumpC[i++] = 1; } if( Configure.PumpType[PP_R24_B] != enumPumpNone ) { switch ( Configure.PumpType[PP_R24_B] ) { case enumOrifice_1:TypeC[i] = 2;break; case enumOrifice_2:TypeC[i] = 3;break; } PumpC[i++] = 2; } if( Configure.PumpType[PP_SHI_C] != enumPumpNone ) { switch ( Configure.PumpType[PP_SHI_C] ) { case enumOrifice_1:TypeC[i] = 2;break; case enumOrifice_2:TypeC[i] = 3;break; } PumpC[i++] = 3; } if( Configure.PumpType[PP_SHI_D] != enumPumpNone ) { switch ( Configure.PumpType[PP_SHI_D] ) { case enumOrifice_1:TypeC[i] = 2;break; case enumOrifice_2:TypeC[i] = 3;break; } PumpC[i++] = 4; } if( Configure.PumpType[PP_AIR] != enumPumpNone ) { switch ( Configure.PumpType[PP_AIR] ) { case enumOrifice_1:TypeC[i] = 4;break; case enumOrifice_2:TypeC[i] = 5;break; } PumpC[i++] = 5; } if( Configure.HeaterType != enumPumpNone ) { switch ( Configure.HeaterType ) { case enumHeaterOnly: TypeC[i] = 6;break; case enumHCBoxOnly : TypeC[i] = 7;break; case enumHCBoxHeater: TypeC[i] = 8;break; } PumpC[i++] = 6; } imax = i; cls(); WBMP( 0x0290,0x0502, STROCK); //显示横线 WBMP( 0x0290,0x0514, STROCK); //显示横线 switch ( option ) { default: case opt_tsp_1: for( i = 0; i < 6; i++) { if( i < imax) { if( imax <= 6 ) Lputs(0x0102, "泵安装情况 "); else Lputs(0x0102, "泵安装情况 1"); Lputs( dispchar[i%6], Pump[PumpC[i]] ); Lputs( dispchar2[i%6], Type[TypeC[i]]); } } break; case opt_tsp_2: for( i = 6; i < 12; i++) { Lputs(0x0102, "泵安装情况 2"); if( i < imax ) { Lputs( dispchar[i%6], Pump[PumpC[i]] ); Lputs( dispchar2[i%6], Type[TypeC[i]]); } } break; case opt_tsp_3: for( i = 12; i < 18; i++) { Lputs(0x0102, "泵安装情况 3"); if( i < imax) { Lputs( dispchar[i%6], Pump[PumpC[i]] ); Lputs( dispchar2[i%6], Type[TypeC[i]]); } } break; } opt_m = ( imax + 5 ) / 6 ; switch ( getKey() ) { case K_UP: // 向前(时间较早的文件)查找 --option; if ( option < opt_min ) { option = opt_m; } break; case K_DOWN: // 向后(时间较新的文件)查找 ++option; if ( option > opt_m ) { option = opt_min; } break; case K_RIGHT: ++option; if ( option > opt_m ) { option = opt_min; } break; case K_LEFT: --option; if ( option < opt_min ) { option = opt_m; } break; case K_OK: option = opt_exit; break; case K_SHIFT: break; case K_ESC: option = opt_exit; break; case K_OK_UP: if ( gray < 2200u ) { ++gray; } if( ! releaseKey( K_OK_UP,100 )) { while( ! releaseKey( K_OK_UP, 1 )) { ++gray; DisplaySetGrayVolt( gray * 0.01f ); } } graychanged = true; break; case K_OK_DOWN: if ( gray > 200u ) { --gray; } if( ! releaseKey( K_OK_DOWN, 100 )) { while( ! releaseKey( K_OK_DOWN, 1 )) { --gray; DisplaySetGrayVolt( gray * 0.01f ); } } graychanged = true; break; case K_OK_RIGHT: if ( gray < ( 2000u - 50u )) { gray += 100u; } graychanged = true; break; case K_OK_LEFT: if ( gray > ( 200 + 20u )) { gray -= 20u; } graychanged = true; break; default: break; } if( graychanged == true ) { DisplaySetGrayVolt( gray * 0.01f ); Configure.DisplayGray = gray; ConfigureSave(); graychanged = FALSE;; } } while ( opt_exit != option ); }
/********************************** 功能说明 *********************************** * 设置时间、日期 *******************************************************************************/ static void menu_SetupClock( void ) { static struct uMenu const menu[] = { { 0x0102u, "设置时间" }, { 0x0C00u, "日期" }, { 0x1400u, "时间" }, }; enum { opt_exit, opt_date, opt_time, opt_max, opt_min = 1 }; uint8_t option = opt_min; uint16_t gray = Configure.DisplayGray; BOOL graychanged = FALSE; uClock standard; cls(); Menu_Redraw( menu ); do { Menu_Item_Mask( menu, option ); do { RTC_Load( &standard ); ShowClockDate(0x0C0Cu, &standard ); ShowClockTime(0x140Cu, &standard ); } while ( ! hitKey( 25u )); Menu_Item_Mask( menu, option ); switch( getKey() ) { case K_RIGHT: break; case K_LEFT: break; case K_DOWN: ++option; if ( option >= opt_max ) { option = opt_min; } break; case K_UP: if ( option <= opt_min ) { option = opt_max; } --option; break; case K_ESC: option = opt_exit; break; case K_OK: switch( option ) { case opt_date: if ( EditClockDate(0x0C0Cu, &standard )) { RTC_Save( &standard ); } break; case opt_time: if ( EditClockTime(0x140Cu, &standard )) { RTC_Save( &standard ); } break; default: break; } break; case K_OK_UP: if ( gray < 2200u ) { ++gray; } if( ! releaseKey( K_OK_UP,100 )) { while( ! releaseKey( K_OK_UP, 1 )) { ++gray; DisplaySetGrayVolt( gray * 0.01f ); } } graychanged = true; break; case K_OK_DOWN: if ( gray > 200u ) { --gray; } if( ! releaseKey( K_OK_DOWN, 100 )) { while( ! releaseKey( K_OK_DOWN, 1 )) { --gray; DisplaySetGrayVolt( gray * 0.01f ); } } graychanged = true; break; case K_OK_RIGHT: if ( gray < ( 2000u - 50u )) { gray += 100u; } graychanged = true; break; case K_OK_LEFT: if ( gray > ( 200 + 20u )) { gray -= 20u; } graychanged = true; break; default: break; } if( graychanged == true ) { DisplaySetGrayVolt( gray * 0.01f ); Configure.DisplayGray = gray; ConfigureSave(); graychanged = FALSE;; } } while( opt_exit != option ); }
void EIOS_ReleaseKey(Target t, int key) { releaseKey(key); }
void KeyMap::PCtoX(BYTE virtKey, DWORD keyData, ClientConnection* clientCon) { bool down = ((keyData & 0x80000000) == 0); bool extended = ((keyData & 0x1000000) != 0); bool repeated = ((keyData & 0xc0000000) == 0x40000000); UINT extVkey = virtKey + (extended ? 256 : 0); // exclude winkey when not scroll-lock if (virtKey==91 || virtKey==92) return; vnclog.Print(8, _T("\nPCtoX: %svirtKey 0x%02x%s%s, keyData 0x%08x\n"), (extended ? _T("extended ") : _T("")), virtKey, (repeated ? _T(" repeated") : _T("")), (down ? _T(" down") : _T(" up")), keyData); // If this is a key release then just send the associated sent KeySym when // this key was pressed if (!down) { vnclog.Print(8, _T("Release the associated KeySym when this VirtKey was pressed\n")); if (downUnicode[extVkey]) { vnclog.Print(8, _T(" 0x%04x (%c): "), downUnicode[extVkey], downUnicode[extVkey]); downUnicode[extVkey] = NULL; } else { vnclog.Print(8, _T(" Control character: ")); } releaseKey(clientCon, extVkey); vnclog.Print(8, _T("\n")); GetKeyboardState(KBKeysState); if (!((KBKeysState[VK_MENU] & 0x80) && (KBKeysState[VK_CONTROL] & 0x80))) { if (storedDeadChar && reset) { reset=false; keybd_event(VK_SPACE, 0, 0, 0); keybd_event(VK_SPACE, 0, KEYEVENTF_KEYUP, 0); } } return; } // We try to look it up in our key table // Look up the desired code in the keyMap table try to find the exact match according to // the extended flag, then try the opposite of the extended flag CARD32 foundXCode = XK_VoidSymbol; bool exactMatched = false; vnclog.Print(8, _T("Looking in key table ")); for (UINT i = 0; i < (sizeof(keyMap) / sizeof(vncKeyMapping_t)); i++) { if (keyMap[i].WinCode == virtKey) { foundXCode = keyMap[i].XCode; if (extended == keyMap[i].extVK) { exactMatched = true; break; } } } if (foundXCode != XK_VoidSymbol) { vnclog.Print(8, _T("-> keyMap gives (from %s extended flag) KeySym %u (0x%08x)\n"), (exactMatched ? _T("matched") : _T("opposite")), foundXCode, foundXCode); pressKey(clientCon, extVkey, foundXCode); vnclog.Print(8, _T("\n")); return; } else { vnclog.Print(8, _T("-> not in special keyMap\n")); } // Under CE, we're not so concerned about this bit because we handle a WM_CHAR message later #ifndef UNDER_CE GetKeyboardState(KBKeysState); ModifierKeyReleaser lctrl(clientCon, VK_CONTROL, 0); ModifierKeyReleaser lalt(clientCon, VK_MENU, 0); ModifierKeyReleaser ralt(clientCon, VK_MENU, 1); if ((KBKeysState[VK_MENU] & 0x80) && (KBKeysState[VK_CONTROL] & 0x80)) { // This is a Ctrl-Alt (AltGr) key on international keyboards (= LCtrl-RAlt) // Ex. Ctrl-Alt-Q gives '@' on German keyboards vnclog.Print(8, _T("Ctrl-Alt pressed:\n")); // We must release Control and Alt (AltGr) if they were both pressed, so the character // is seen without them by the VNC server // We don't release the Right Control; this allows German users // to use it for doing Ctrl-AltGr-x, e.g. Ctl-@, etc lctrl.release(downKeysym); lalt.release(downKeysym); ralt.release(downKeysym); } else { // This is not a Ctrl-Alt (AltGr) key vnclog.Print(8, _T("Ctrl-Alt not pressed, fake release any Ctrl key\n")); // There are no KeySym corresponding to control characters, e.g. Ctrl-F // The server has already known whether the Ctrl key is pressed from the previouse key event // So we are interested in the key that would be there if the Ctrl key were not pressed KBKeysState[VK_CONTROL] = KBKeysState[VK_LCONTROL] = KBKeysState[VK_RCONTROL] = 0; } int ret; if (storedDeadChar) { SHORT virtDeadKey; BYTE prevModifierState = 0; vnclog.Print(8, _T("[Storing base character modifier(s)]\n")); StoreModifier(&prevModifierState, KBKeysState); virtDeadKey = VkKeyScanW(storedDeadChar); vnclog.Print(8, _T("[A dead key was stored, restoring the dead key state:") _T(" 0x%02x (%c) using virtDeadKey 0x%02x] "), storedDeadChar, storedDeadChar, virtDeadKey); SetModifier(HIBYTE(virtDeadKey), KBKeysState); vnclog.Print(8, _T("\n")); ToUnicode((virtDeadKey & 0xff), 0, KBKeysState, ucsChar, (sizeof(ucsChar) / sizeof(WCHAR)), 0); vnclog.Print(8, _T("[Restoring base character modifier(s)] ")); SetModifier(prevModifierState, KBKeysState); vnclog.Print(8, _T("\n")); storedDeadChar = 0; ret = ToUnicode(virtKey, 0, KBKeysState, ucsChar, (sizeof(ucsChar) / sizeof(WCHAR)), 0); } else ret = ToUnicode(virtKey, 0, KBKeysState, ucsChar, (sizeof(ucsChar) / sizeof(WCHAR)), 0); if (ucsChar[0]==8364) { //euro // return; } if (ret < 0 || ret==2) { // It is a dead key vnclog.Print(8, _T("ToUnicode returns dead key: 0x%02x (%c) "), *ucsChar, *ucsChar); if (sendDeadKey) { // We try to look it up in our dead key table // Look up the desired code in the deadKeyMap table foundXCode = XK_VoidSymbol; for (UINT i = 0; i < (sizeof(deadKeyMap) / sizeof(vncDeadKeyMapping_t)); i++) { if (deadKeyMap[i].deadKeyChar == *ucsChar) { foundXCode = deadKeyMap[i].XCode; break; } } if (foundXCode != XK_VoidSymbol) { vnclog.Print(8, _T("-> deadKeyMap gives KeySym %u (0x%08x)\n"), foundXCode, foundXCode); pressKey(clientCon, extVkey, foundXCode); } else { vnclog.Print(8, _T("-> not in deadKeyMap\n")); } } else { storedDeadChar = *ucsChar; reset=true; vnclog.Print(8, _T("-> Store the dead key state, wait for next key-stroke\n")); } FlushDeadKey(KBKeysState); } else if (ret > 0) { vnclog.Print(8, _T("ToUnicode returns %d character(s):\n"), ret); for (int i = 0; i < ret; i++) { CARD32 xChar = UCS2X(*(ucsChar+i)); if (xChar != XK_VoidSymbol) { downUnicode[extVkey] = *(ucsChar+i); pressKey(clientCon, extVkey, xChar); } } } else { vnclog.Print(8, _T("No character is generated by this key event\n")); } #endif vnclog.Print(8, _T("\n")); };