BOOL CPageSpiNandflash::OnInitDialog() 
{
    CPropertyPage::OnInitDialog();

	SetupDisplay();
	
	ListView_SetExtendedListViewStyle(m_spi_nandflash_param_list.m_hWnd, LVS_EX_GRIDLINES | LVS_EX_FULLROWSELECT); 
	
	m_spi_nandflash_param_list.InsertColumn(0, _T("N.O."), LVCFMT_LEFT, 40);//序号
	m_spi_nandflash_param_list.InsertColumn(1, _T("ChipID"), LVCFMT_LEFT, 90);//chip id
	m_spi_nandflash_param_list.InsertColumn(2, _T("Page Size"), LVCFMT_LEFT, 90);//页大小
	m_spi_nandflash_param_list.InsertColumn(3, _T("Page per block"), LVCFMT_LEFT, 90);//每个块有多少个页
	m_spi_nandflash_param_list.InsertColumn(4, _T("Total block number"), LVCFMT_LEFT, 90);//块数
	//m_spi_nandflash_param_list.InsertColumn(5, _T("Group block number"), LVCFMT_LEFT, 90);//Group block number
	m_spi_nandflash_param_list.InsertColumn(5, _T("Plane block number"), LVCFMT_LEFT, 90);//Plane block number
	m_spi_nandflash_param_list.InsertColumn(6, _T("Spare size"), LVCFMT_LEFT, 90);//Spare size
	//m_spi_nandflash_param_list.InsertColumn(8, _T("Column address cycle"), LVCFMT_LEFT, 90);//Column address cycle
	//m_spi_nandflash_param_list.InsertColumn(9, _T("Last column addrress cycle mask bit"), LVCFMT_LEFT, 90);//Last column addrress cycle mask bit
	//m_spi_nandflash_param_list.InsertColumn(10, _T("Row address cycle"), LVCFMT_LEFT, 90);//Row address cycle
	//m_spi_nandflash_param_list.InsertColumn(11, _T("Last row address cycle mask bit"), LVCFMT_LEFT, 90);//Last row address cycle mask bit
	m_spi_nandflash_param_list.InsertColumn(7, _T("Custom nandflash"), LVCFMT_LEFT, 90);//Custom
	m_spi_nandflash_param_list.InsertColumn(8, _T("Flag"), LVCFMT_LEFT, 90);//Flag
	//m_spi_nandflash_param_list.InsertColumn(14, _T("Command length"), LVCFMT_LEFT, 90);//Command length
	m_spi_nandflash_param_list.InsertColumn(9, _T("clock"), LVCFMT_LEFT, 90);//Data length
	m_spi_nandflash_param_list.InsertColumn(10, _T("Descriptor string"), LVCFMT_LEFT, 130);//Descriptor
	
	set_config_item(theConfig);//附值
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
Exemple #2
0
void TopLevel::newPage(){

  if(!display_is_setup)
    SetupDisplay();

  XDefineCursor(qtdisplay, Win, WorkCursor);
  XFlush(qtdisplay);

  freeImages();

  int k = -1;

  if(!thispage) {
    XDefineCursor(qtdisplay, Win, ReadyCursor);
    return;
  }

  if (Pimage(thispage) == NULL){

    while((k != 0) && (k != 3) && (k !=1))
      k = GetImage(thispage);

  }

  if (k == 3 ){

    XDefineCursor(qtdisplay, Win, ReadyCursor);
    FreeFax();
    /*    KMessageBox::sorry(i18n("Bad fax file k=3"));*/
    return;
  }

  if (k == 0 ){

    XDefineCursor(qtdisplay, Win, ReadyCursor);
    FreeFax();
    /*    KMessageBox::sorry(i18n("Bad fax file k=0"));*/
    return;
 }

  Image =  Images[0] = Pimage(thispage);

  setCaption(QFile::decodeName(thispage->name));

  Image = generateZoomImages(oz);
  
  PaneWidth = Image->width;
  PaneHeight = Image->height;
  Refresh = 1;

  XDefineCursor(qtdisplay, Win, ReadyCursor);
  uiUpdate();

}
Exemple #3
0
int he_main(int argc, char *argv[])
#endif
{
	time_t seed;

	my_argv = argv;

	if (!strcmp(program_path, "") && argv) MakeProgramPath(argv[0]);

	/* Seed the random number generator */
#if !defined (RANDOM)
	srand((unsigned int)time((time_t *)&seed));
#else
	SRANDOM((unsigned int)time((time_t *)&seed));
#endif

#if !defined (GLK)	/* no command line under Glk */
	ParseCommandLine(argc, argv);
#endif

	hugo_init_screen();

#if defined (DEBUGGER)
	debug_getinvocationpath(argv[0]);
	SwitchtoGame();
#endif
	SetupDisplay();

	strcpy(pbuffer, "");

	gameseg = 0;

	LoadGame();

#if defined (DEBUGGER)
	LoadDebuggableFile();
	StartDebugger();
#endif

	RunGame();

	hugo_cleanup_screen();

	hugo_blockfree(mem);
	mem = NULL;
	hugo_closefiles();

	return 0;
}
Exemple #4
0
/*****************************************************************************
** Procedure:  CDSPhone::Init
**
** Arguments:  'pDev'				-	Device object this phone belongs to
**             'dwPhoneDeviceID'	-	Unique phone identifier within the TSP
**             'dwPos'				-	Index position of phone within device array
**             'dwItemData'		-   Used when line was dynamically created (P&P).
**
** Returns:    void
**
** Description:  This function is called by the device owner to initialize
**               the phone object.
**
*****************************************************************************/
VOID CDSPhone::Init (CTSPIDevice* pDev, DWORD dwPhoneDeviceID, DWORD dwPos, DWORD /*dwItemData*/)
{
	// Let the base class initialize first.
	CTSPIPhoneConnection::Init (pDev, dwPhoneDeviceID, dwPos);

    // Grab the settings from the emulator.
    EMSETTINGS Settings;
    if (!GetDeviceInfo()->DRV_GetSwitchSettings (&Settings))
		return;
    
    // Add the handset device to our hookswitch list.
    AddHookSwitchDevice(PHONEHOOKSWITCHDEV_HANDSET,				// Hookswitch device
						(PHONEHOOKSWITCHMODE_ONHOOK |			// Modes available to hookswitch
						 PHONEHOOKSWITCHMODE_MIC | 
						 PHONEHOOKSWITCHMODE_SPEAKER |
						 PHONEHOOKSWITCHMODE_MICSPEAKER | 
						 PHONEHOOKSWITCHMODE_UNKNOWN),
						 g_hsStates[Settings.wHandsetHookswitch],	// States supported by hookswitch
						 Settings.wVolHandset,						// Current Volume level of hookswitch (0-0xffff)
						 Settings.wGainHandset,						// Current Gain level of hookswitch (0-0xffff)
						 0xffffffff, 0xffffffff, true, true);		// Monitored/Set modes
                
    // Setup the display buffer for the phone.  It uses a standard line feed so don't
    // change the default line break character.
    SetupDisplay(DISPLAY_COLS, DISPLAY_ROWS);

    // Add all the buttons to our phone.
    for (int i = 0; i < BUTTON_COUNT; i++)
    {   
		// If the button is one of our STANDARD buttons (0-9,A-D,#,*), then it is a keypad
		// button.
		if (i < TOTAL_STD_BUTTONS)
        {
            AddButton (PHONEBUTTONFUNCTION_NONE,		// Button function
					   PHONEBUTTONMODE_KEYPAD,			// Button mode
                       PHONELAMPMODE_DUMMY,				// Available Lamp states (Dummy = None)
					   PHONELAMPMODE_DUMMY,				// Current Lamp state (Dummy = None)
					   CString(g_szKeypad[i],1));		// Text name of button
        }                               

		// Otherwise the button is a "soft" button, the mode and function are determined
		// by how the user sets up the emulator.  The emulator reports the button functions
		// through the EMSETTINGS structure.
        else
        {   
			// Determine the available lamp states based on the reported mode of the
			// button from the emulator.
            DWORD dwAvailLampStates = 0;
            if (Settings.wButtonModes[i] == BUTTONFUNCTION_CALL)
                dwAvailLampStates = (PHONELAMPMODE_OFF | PHONELAMPMODE_STEADY | PHONELAMPMODE_WINK | PHONELAMPMODE_FLASH);
            else if (Settings.wLampStates[i] == LAMPSTATE_NONE)
                dwAvailLampStates = PHONELAMPMODE_DUMMY;
            else
                dwAvailLampStates = (PHONELAMPMODE_OFF | PHONELAMPMODE_STEADY | PHONELAMPMODE_WINK);

			// Add the button
            AddButton (g_ButtonFunctions[Settings.wButtonModes[i]].dwFunction,
                       g_ButtonFunctions[Settings.wButtonModes[i]].dwMode,  
                       dwAvailLampStates,
                       g_LampStates[Settings.wLampStates[i]],
                       g_ButtonFunctions[Settings.wButtonModes[i]].pszText);                            
        }                               
    }

    // Setup the initial state of the display.
	USES_CONVERSION;
    SetDisplay (A2T(Settings.szDisplay));

    // Setup the ringer modes
    LPPHONECAPS pPhoneCaps = GetPhoneCaps();
    LPPHONESTATUS pPhoneStatus = GetPhoneStatus();
    pPhoneCaps->dwNumRingModes = 4;
    pPhoneStatus->dwRingMode = (DWORD) Settings.wRingMode;

	// Add the WAV devices which will be our handset I/O
	if (waveInGetNumDevs() > 0)
		AddDeviceClass(_T("wave/in"), (DWORD)0);
	if (waveOutGetNumDevs() > 0)
		AddDeviceClass(_T("wave/out"), (DWORD)0);

}// CDSPhone::Init
Exemple #5
0
int main(void)
{
	extern int mazeIdRequest;			// requested maze Id
	extern int seedRequest;				// requested random seed
	extern int quickModeRequest;		// whether quick mode is requested
	
	ActualTile maze[MAZE_DIMENSION][MAZE_DIMENSION];
	Coordinate playerLocation = { -1, -1 };

	SetupDisplay();
	// GenerateMazes("hundred.h",0,100); // HEHE, you can't do this!

	int mazeToUse = mazeIdRequest;
	int seedToUse = seedRequest;
	bool useQuickMode = quickModeRequest;
	int numMazes = 1;
	if (mazeToUse == 7) {
		numMazes = 100;		// scoring mode...
		useQuickMode = TRUE;
	}

	int totalTurns = 0;
	
	int metaTurn;
	for (metaTurn = 0; metaTurn < numMazes; metaTurn++) {
		// setup maze
		Coordinate dispDimension = SetupMaze(maze, mazeToUse, seedToUse, &playerLocation);
		int maxTurns = (dispDimension.x - 2)*(dispDimension.y - 2);   // approximately twice of walking space...
		
		// main loop
		Direction lastMoveDir = NO_MOVEMENT;
		bool lastMoveSucceed = FALSE;
		bool finishedMaze = FALSE;
		bool timeout = FALSE;
		
		int turn;
		for (turn = 0; turn <= maxTurns; turn++) {
			_turn = turn;
			// check winning/losing condition
			if (maze[playerLocation.y][playerLocation.x] == EXIT) {
				finishedMaze = TRUE;
			}
			else if (turn == maxTurns) {
				timeout = TRUE;    // last turn is an ending turn
			}

			// for every turn, display what we have if not in quick mode or not timeout/finished ...
			// (we also won't display when number of mazes is > 1)
			if (numMazes == 1 && (useQuickMode == FALSE || timeout || finishedMaze)) {
				ClearScreen();
				printf("CSC1140 Fall 2015 - The Dark Forest v.1.0\n\n");
				printf("Maze: #%d Seed: %d - Turn : %d/%d ", mazeIdRequest, seedRequest, turn, maxTurns);
				if (lastMoveDir != NO_MOVEMENT) {
					printf("| You just moved ");
					if (lastMoveDir == NORTH) printf("north ");
					else if (lastMoveDir == EAST) printf("east ");
					else if (lastMoveDir == SOUTH) printf("south ");
					else if (lastMoveDir == WEST) printf("west ");
					if (lastMoveSucceed == FALSE) printf("but failed!\n\n");
					else printf("\n\n");
				}
				else {
					printf("\n\n");
				}
				DisplayMaze(maze, dispDimension, playerLocation, timeout);

			}

			// break way if done
			if (timeout || finishedMaze) {
				break;
			}

			// if a normal turn, we ask for a step...
			static Tile vision[VISION_DIMENSION][VISION_DIMENSION];
			int i, j;
			for (i = 0; i < VISION_DIMENSION; i++) {
				for (j = 0; j < VISION_DIMENSION; j++) {

					int mapX = (playerLocation.x - VISION_RANGE + j + dispDimension.x) % dispDimension.x;
					int mapY = (playerLocation.y - VISION_RANGE + i + dispDimension.y) % dispDimension.y;
					if (mapX >= 0 && mapX < MAZE_DIMENSION
						&& mapY >= 0 && mapY < MAZE_DIMENSION) {
						vision[i][j] = maze[mapY][mapX] % TILE_CYCLE;
					}
				}
			}
			Direction playerMoveDir = Solve(playerLocation.x, playerLocation.y, vision);

			// really move it - but not on display yet...
			lastMoveSucceed = MovePlayer(maze, dispDimension, &playerLocation, playerMoveDir);
			lastMoveDir = playerMoveDir;


			// get key now so player debug messages can be seen
			if (useQuickMode == FALSE) {
				printf("\nPress Enter to continue (ctrl+C to terminate)...\n");
				getchar();
			}



		}
		
		// aftermath for each maze
		totalTurns += turn;
		if (numMazes == 1) {
			// normal single maze mode ending
			if (finishedMaze) {
				printf("\n       ******** And you escaped the maze in %d turns! ******** \n", turn);
				printf("       ******** Press q to quit                       ******** \n");

			}
			else {
				printf("\n       ******** You run out of energy and died in the maze...     ******** \n");
				printf("       ******** You will be missed by your CSCI1140 classmates... ******** \n");
			#if defined(_WIN32) || defined(_WIN64)
				printf("       ******** Press q to quit                                   ******** \n");
			#else
				printf("       ******** Press q then Enter to quit                        ******** \n");
			#endif

			}
			char c;
			do {
				c = GetKey();
			} while (c != 'q');

		}
		else {
			// multi-maze scoring mode
			if (finishedMaze) {
				printf("You escaped area %d in %d turns...\n", metaTurn, turn);
			}
			else {
				printf("You run out of energy in area %d and wake up at exit (%d turns counted)...\n", metaTurn, turn);
			}
		}

	}

	if (numMazes > 1) {
		printf("\n\n    ***                                               ***\n");
		printf("    *** Turns used to escape the Dark Forest: %6d  ***\n", totalTurns);
		printf("    ***                                               ***\n\n");
	}
	
	return 0;
}
Exemple #6
0
greet_user_rtn GreetUser(struct display * d, Display ** dpy, struct verify_info * verify, struct greet_info * greet)
{
	int flag;
	int pid;
	int code;

	Save_d = d;					/* hopefully, this is OK */

	*dpy = XOpenDisplay(d->name);	/* make sure we have the display */
	/*
	 * Run the setup script - note this usually will not work when
	 * the server is grabbed, so we don't even bother trying.
	 */
	if (!d->grabServer)
		SetupDisplay(d);
	if (!*dpy) {
		WDMError("Cannot reopen display %s for greet window\n", d->name);
		exit(RESERVER_DISPLAY);
	}

	pid = InitGreet(d);			/* fork and exec the external program */

	for (;;) {
		/*
		 * Greet user, requesting name/password
		 */
		code = Greet(d, greet);
		WDMDebug("Greet greet done: %s, pwlen=%i\n", name, strlen(password));

		if (code != 0) {
			WDMDebug("Greet: exit code=%i, %s\n", code, exitArg);
			if (wdmVerify || wdmRoot) {
				flag = False;
				if (Verify(d, greet, verify))
					flag = True;
				if (wdmRoot && (strcmp(greet->name, "root") != 0))
					flag = False;
			} else
				flag = True;
			if (flag == True) {
				switch (code) {
				case 2:		/* reboot */
					CloseGreet(pid);
					WDMInfo("reboot(%s) by %s\n", exitArg, name);
					system(wdmReboot);
					SessionExit(d, UNMANAGE_DISPLAY, FALSE);
					break;
				case 3:		/* halt */
					CloseGreet(pid);
					WDMInfo("halt(%s) by %s\n", exitArg, name);
					system(wdmHalt);
					SessionExit(d, UNMANAGE_DISPLAY, FALSE);
					break;
				case 4:		/* exit */
					CloseGreet(pid);
					WDMDebug("UNMANAGE_DISPLAY\n");
					WDMInfo("%s exit(%s) by %s\n", PACKAGE_NAME, exitArg, name);
#if 0
					SessionExit(d, UNMANAGE_DISPLAY, FALSE);
#else
					WDMDebug("Killing parent process %d\n", getppid());
					kill(getppid(), SIGINT);
#endif
					break;
				}
			} else {
				kill(pid, SIGUSR1);	/* Verify failed */
			}
		} else {
			/*
			 * Verify user
			 */
			if ((!*greet->name) && *wdmDefaultUser) {
				greet->name = wdmDefaultUser;
				greet->password = wdmDefaultPasswd;
			}
			if (Verify(d, greet, verify))
				break;
			else
				kill(pid, SIGUSR1);	/* Verify failed */
		}
	}
	DeleteXloginResources(d, *dpy);
	CloseGreet(pid);
	WDMDebug("Greet loop finished\n");
	/*
	 * Run system-wide initialization file
	 */
	if (source(verify->systemEnviron, d->startup) != 0) {
		WDMDebug("Startup program %s exited with non-zero status\n", d->startup);
		SessionExit(d, OBEYSESS_DISPLAY, FALSE);
	}

	return Greet_Success;
}