?? frontpanel.c
字號:
/***************************************** Copyright 2001-2003 Sigma Designs, Inc. All Rights Reserved Proprietary and Confidential *****************************************//** @file frontpanel.c @brief Front panel library @date 2004-01-06*/#define ALLOW_OS_CODE 1//#include "common.h"#include "fip.h"#include "frontpanel.h"#include <stdio.h>#include <fcntl.h>#include <stdlib.h>#include <unistd.h>#include <signal.h>#include <sys/ioctl.h>#include <sys/select.h>#define DEFAULT_FIP_DEVICE "/dev/fip"RMint32 fipInit(RMint32 block_mode, const RMnonAscii *devname){ const char *dev = (((const char*)devname != (const char*)NULL) ? (const char*)devname : DEFAULT_FIP_DEVICE); int flags = O_RDWR | ((block_mode != 0) ? 0 : O_NONBLOCK); int res; printf("Opening Fip \n"); res = open((char*)dev, flags); if(res < 0) perror("Error opening FIP : "); return (RMint32)res;}/* Release FIP device */RMstatus fipRelease(RMint32 *fno){ if (*fno >= 0) close(*fno); *fno = 0; return RM_OK;}/* Show symbol (defined in fip.h) */RMstatus fipShowSymbol(RMint32 fno, RMint32 symbol, RMbool on){ unsigned long arg = (unsigned long)symbol; int res; if (on != 0) arg |= 0x80000000;#ifdef GUI_REFID_2 if(symbol <= 206 || symbol >= 1000){ //printf("Symbol: %ld\n", symbol); res = ioctl(fno, FIP_IOCSHOWSYMBOL, arg); return (res > 0)?RM_OK:RM_ERROR; } else return RM_ERROR;#else res = ioctl(fno, FIP_IOCSHOWSYMBOL, arg); return (res > 0)?RM_OK:RM_ERROR;#endif}/* Show Hour:Minute:Second */RMstatus fipShowHMS(RMint32 fno, RMint32 hour, RMint32 minute, RMint32 second){ unsigned long arg; int res; arg = (hour << 16) | (minute << 8) | (second); res = ioctl((int)fno, FIP_IOCSHOWHMS, arg); return(res > 0)?RM_OK:RM_ERROR;;}/* Write a text (center aligned) */RMstatus fipWriteText(RMint32 fno, const RMascii *text){ int res = write((int)fno, (char*)text, strlen((char*)text) + 1); return(res == (int)strlen(text))?RM_OK:RM_ERROR;}/* Write a text with more control */RMstatus fipShowText(RMint32 pos, RMint32 flags, const RMascii *text){// int res = 0; /* Not yet implemented */ return RM_ERROR;}/* Show raw form */RMstatus fipShowRaw(RMint32 fno, RMint32 byte, RMint32 bit, RMint32 on){ unsigned long arg; int res; arg = (byte << 8) | (bit); if (on != 0) arg |= 0x80000000; res = ioctl((int)fno, FIP_IOCSHOWHMS, arg); return (res > 0)?RM_OK:RM_ERROR;}/* Show a character */RMstatus fipShowChar(RMint32 fno, RMint32 pos, const RMascii ch){ unsigned long arg; int res; arg = (pos << 8) | (ch); res = ioctl((int)fno, FIP_IOCDISPCHAR, arg); return (res > 0)?RM_OK:RM_ERROR;}/* Clear FIP display */RMstatus fipClear(RMint32 fno){ int res; res = ioctl((int)fno, FIP_IOCCLEAR); return (res > 0)?RM_OK:RM_ERROR;;}/* Get key press from FIP, 0 = no key */RMuint32 fipGetKey(RMint32 fno){#ifdef GUI_REFID_2 unsigned long key; // printf("Calling front panel : %lu\n", fno); if (read((int)fno, &key, sizeof(unsigned long)) > 0) { return(RMuint32)(key); } // perror("Frontpanel : "); return(0);#else unsigned long key; fd_set rfds; int ret; struct timeval tv; FD_ZERO(&rfds); FD_SET((int)fno,&rfds); tv.tv_sec=0; tv.tv_usec=0; if ((ret = select((int)fno+1, &rfds, NULL, NULL, &tv))) { if(ret < 0) perror("Error select fip :"); if ((ret = read((int)fno, &key, sizeof(unsigned long))) > 0) { return(RMuint32)(key); }/* if(ret < 0) perror("Error read fip : ");*/ } return 0;#endif}RMremoteKey convertFipKeyToRemoteKey(RMuint32 key){ RMremoteKey remote_key; printf("convertFipKeyToRemoteKey : Key from panel : %lu\n", key); switch(key) { case FIP_KEY_EJECT: remote_key = RM_HW_EJECT; break; case FIP_KEY_PLAYPAUSE: remote_key = RM_HW_PLAY_PAUSE; break; case FIP_KEY_PREV: remote_key = RM_HW_PREV_TRACK; break; case FIP_KEY_NEXT: remote_key = RM_HW_NEXT_TRACK; break; case FIP_KEY_FBWD: remote_key = RM_HW_FAST_REWIND; break; case FIP_KEY_FFWD: remote_key = RM_HW_FAST_FORWARD; break;#ifdef GUI_REFID_2 case FIP_KEY_STOP: remote_key = RM_HW_STOP; break; case FIP_KEY_MENU: remote_key = RM_HW_SETUP; break;#endif default: remote_key = RM_HW_TIMEOUT; break; } return remote_key;}RMremoteKey GetFrontPanelKey(RMuint32 fno){ RMuint32 key; key = fipGetKey(fno); if(key > 0) { return convertFipKeyToRemoteKey(key); } return RM_HW_TIMEOUT;}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -