Ejemplo n.º 1
0
/***********************************************************
* 
* updateLCD
* 
***********************************************************/
void TTUI::updateLCD()
{
	
	//only update LCD every 300ms
	int now = millis()/100; //100 ms 
	int elapsed = now - activeRefreshTime;

	if(elapsed > 3)  //300ms
	{
		activeRefreshTime = now;
	
	
		if(trapActive_ == true)
		{
			if(batteryPower() == false) //USB connected
			{
				clear();
				printMode(0);

				char printBuffer[9];
				triggers[currentTrigger]->getActiveMessage(printBuffer);
				setCursor(0,1);
				print(printBuffer);
					
			}
		}
		else if(trapActive_ == false) //waiting for UI input
		{
			if(activeMenu == UP_MENU || activeMenu == DOWN_MENU)
			{
				clear();
				printSelect(0);
				printInc(1,0);
			}
			else if(activeMenu == MODE_MENU || activeMenu == OPTION_MENU)
			{
				clear();
			 	printMode(0);
			 	printSelect(1);
			}
			else if(activeMenu == START_MESSAGE)
			{
				clear();
				print("TrigTrap");
				setCursor(0,1);
				print("v");
				print(FIRMWARE_VERSION);
			}
		}
	}
	
}
Ejemplo n.º 2
0
/***********************************************************
* 
* bttnMode
* 
***********************************************************/
  void TTUI::bttnMode()  
  {

	if(activeMenu == MODE_MENU || activeMenu == OPTION_MENU) //only increment when its the second+ time pressed for this bttn
	{
    	currentTrigger+=1; //mode button has been pressed, advance the mode option to next
		currentTrigger = currentTrigger % (NUM_OF_SENSORS+1); //plus 1 for system menu
	}
	
	activeMenu = MODE_MENU;
	
	clear();
	printMode(0);
	printSelect(1);

  }
Ejemplo n.º 3
0
/***********************************************************
* 
* initStart
* 
***********************************************************/
void TTUI::initStart(unsigned long startTime)
{
    if(currentTrigger < NUM_OF_SENSORS) //only start if you are on a sensor menu, not system menu!
    {
		trapActive_ = !trapActive_; //flip boolean status

		if(trapActive_ == true)
		{
			#ifdef SERIAL_DEBUG
			Serial.println("Active");
			#endif
		
			activeRefreshTime = startTime/100; //100ms
			triggers[currentTrigger]->saveState(); //save the values of active trigger to eeprom
			triggers[0]->saveSystem(); //save system menu settings, to trigger 0. 
			triggers[currentTrigger]->start(startTime); //set start time for the active trigger 
			uiPowerOff();
		
		}
		else if(trapActive_ == false) 
		{
			#ifdef SERIAL_DEBUG
			Serial.println("Inactive");
			#endif
			
			triggers[currentTrigger]->resetFocus(true);
			triggers[currentTrigger]->resetShutter(true); //don't want to leave the shutter high forever
			triggers[currentTrigger]->stop(); //set abortTrigger to true
			uiPowerOn();
			//restore screen to so current select menu and value, better to show mode+select?
			//set the value title in line 1
			clear();
			printSelect(0);
			printInc(1,0); //inc 0 so just display, don't actually increment
			

		}
	}
	

			
}
Ejemplo n.º 4
0
// User selects move based off of available cards
// Regame.turns damage of chosen move
 int selectCard(GlobalState* globalData) {
	globalData->keyStatus = 0;
	printSelect(globalData);
	
	// Waits till valid keypad input
	globalData->keyStatus = 1;
	while(0 != globalData->keyStatus) {
		// Invalid keypad input
		if(0 == globalData->keyPress || globalData->keypress > 5) {
			globalData->keyStatus = 1;
			printSelectMenu(globalData);
		// No card available
		} else if (0 == globalData->cardSelect[globalData->keypress-1]) {
			globalData->keyStatus = 2;
			printSelectMenu(globalData);
		// Selected card is available
		} else {
			globalData->keyStatus = 0;
		}
	}
	return (globalData->keypress - 1);
}
Ejemplo n.º 5
0
/***********************************************************
* 
* bttnUp
* 
***********************************************************/
void TTUI::bttnDown(boolean hold)
{
	int decVal = 0; 
	
	if(activeMenu == DOWN_MENU || activeMenu == UP_MENU) //only increment when its the second+ time pressed for this bttn
	{
		decVal = 1; 
	 
		if(hold == true)
		{
			//speed up increment if held down for a long time
			unsigned long holdTime = millis() - touch.getStartTime();
			if(holdTime > 10000) { decVal = 5; } //increase after 10sec
		}
	}
	
	activeMenu = DOWN_MENU;	

	clear();
	printSelect(0);
	printDec(1,decVal); //don't print just dec
}
Ejemplo n.º 6
0
void selectCard(GlobalState* globalData) {
    static int displayed = 0;
    static int gotStuff = 0;

    // Beep off
    TRISBbits.RB5 = 1;
    if (displayed == 0) {
        displayed = 1;
    }

    if (gotStuff == 0) {
        gotStuff = printSelect(globalData);
    } else {

        if ((0 == globalData->keyPress || globalData->keyPress > 5)) {
            globalData->keyStatus = 1;
            prints(0, 5, WHITE, RED, "                                                 ", 1);
            prints(0, 5, WHITE, RED, "Invalid input. Please enter a key between 1 to 4:", 1);
            // No card available
        } else if (NULL == &myMonsterList[globalData->keyPress - 1]) {
            globalData->keyStatus = 2;
            prints(0, 5, WHITE, RED, "                                ", 1);
            prints(0, 5, WHITE, RED, "No card found. Please try again:", 1);
            // Selected card is available
        } else {
            if (globalData->keyPress == 0x04) {
                game.myMonster = &customMoster;
            } else {
                game.myMonster = &myMonsterList[globalData->keyPress - 1];
            }
            game.monSel = 1;
            displayed = 0;
            gotStuff = 0;
        }
    }
}
Ejemplo n.º 7
0
/***********************************************************
* 
* bttnOption
* 
***********************************************************/
  void TTUI::bttnOption()
  {
	char printBuffer[9];
	
	if(activeMenu == MODE_MENU || activeMenu == OPTION_MENU) //only increment when its the second+ time pressed for this bttn
	{	
		if(currentTrigger < NUM_OF_SENSORS)
		{
			triggers[currentTrigger]->incSelect(); //set sensor to next select mode
		}
		else //system Menu
		{
			incSystemOption++;
			incSystemOption = incSystemOption % 3;
		}
	}
	
	activeMenu = OPTION_MENU;
	
	clear();
	printMode(0);
	printSelect(1);
	
  }
Ejemplo n.º 8
0
void writeRoot(char *fileName)
{
	SELECTIONS *selections;
	SELECTSET *thisSet;
	RASTER *rasters;
	PAGE *thisPage;
	LABEL *thisLabel;
	CELL *thisCell;
	PLOT *thisPlot;
	GRAPH *thisGraph;
	SIGNAL *thisSignal;
	ECODEMARK *thisMark;
	FILE *outFile;
	int i, j, k;
	char xlabel[64];
	char ylabel[64];
	
	/* open the file for writing */
	if((outFile = fopen(fileName, "w")) == NULL) {
		sprintf(errmsg, "can't open file %s", fileName);
		rxerr(errmsg);
		return;
	}

	selections = getSelections();
	rasters = getRasters();

	/* write comments to file */
	fprintf(outFile, "# Lines beginning with C list the start code\n");
	fprintf(outFile, "# Lines beginning with S list numbers of select sets\n");
	fprintf(outFile, "# Lines beginning with s list select set parameters\n");
	fprintf(outFile, "# Lines beginning with a list allOf codes\n");
	fprintf(outFile, "# Lines beginning with n list nonOf codes\n");
	fprintf(outFile, "# Lines beginning with y list anyOf codes\n");
	fprintf(outFile, "# \n");
	fprintf(outFile, "# Lines beginning with R list numbers of raster pages\n");
	fprintf(outFile, "# Lines beginning with r list raster page parameters\n");
	fprintf(outFile, "# Lines beginning with L list page label parameters\n");
	fprintf(outFile, "# \n");
	fprintf(outFile, "# Lines beginning with c list cell parameters\n");
	fprintf(outFile, "# Lines beginning with i list signal parameters\n");
	fprintf(outFile, "# Lines beginning with e list ecode mark parameters\n");
	fprintf(outFile, "# Lines beginning with l list cell label parameters\n");
	fprintf(outFile, "# Lines beginning with g list graph parameters\n");
	fprintf(outFile, "# Lines beginning with X list graph X axis parameters\n");
	fprintf(outFile, "# Lines beginning with Y list graph Y axis parameters\n");
	fprintf(outFile, "\n");

	/* write selections to file */
	fprintf(outFile, "# SELECTIONS START\n");
	/* C */
	fprintf(outFile, "C %d\n", selections->startCode);
	/* S */
	fprintf(outFile, "S %d\n", selections->nSelectSets);
	for(i = 0; i < selections->nSelectSets; i++) {
		thisSet = &selections->selectSets[i];
		/* s first */
		fprintf(outFile, "s %d ALIGNCODE %d ALIGNOFFSET %d ALLOFS %d NONOFS %d ANYOFS %d\n", i,
				thisSet->alignCode, thisSet->alignOffsetTime, thisSet->select.nAllOf,
				thisSet->select.nNonOf, thisSet->select.nAnyOf);

		printSelect(&thisSet->select, outFile);
	}
	fprintf(outFile, "# SELECTIONS END\n");
	fprintf(outFile, "\n");

	/* write rasters to file */
	fprintf(outFile, "# RASTERS START\n");

	/* write page specifications to file */
	/* R */
	fprintf(outFile, "R %d\n", rasters->nPages);
	for(i = 0; i < rasters->nPages; i++) {
		thisPage = getRasterPage(i);
		/* r first */
		fprintf(outFile, "r %d ROWS %2d COLUMNS %2d LABEL %2d NCELLS %d\n",
				i, thisPage->nRows, thisPage->nCols, thisPage->labelFlag, thisPage->nDefCells);
		thisLabel = &thisPage->pageLabel;
		if(strlen(thisLabel->label)) strcpy(xlabel, thisLabel->label);
		else strcpy(xlabel, "(null)");
		/* L first */
		fprintf(outFile, "L %d PAGE %d FONT %d SIZE %d X %.3f Y %.3f TEXT %s\n",
				thisPage->labelFlag, i, thisLabel->font, thisLabel->sz, thisLabel->x,
				thisLabel->y, xlabel);

		/* write cell specifications to file */
		for(j = 0; j < thisPage->nDefCells; j++) {
			thisCell = getRasterCell(thisPage->cellsInfo, j);
			if(thisCell->rowN < 0) continue; /* don't write out deleted rows */

			thisPlot = &thisCell->plotInfo;
			
			/* the cell description is split into two printfs to make the code a little neater */
			/* c first */
			fprintf(outFile, "c %d PAGE %d COL %2d ROW %2d INDEX %2d SET %d CODE %d",
					j, i, thisCell->colN, thisCell->rowN, thisCell->RCindex, thisPlot->setNum, thisPlot->cCode);
			fprintf(outFile, " SIGNALS %d TRIALS %d MEANS %d SIGMA %.2f MARKS %d\n",
					thisPlot->nSignals, thisPlot->trialFlag, thisPlot->meanFlag, thisPlot->sigma, thisPlot->markFlag);
				
			/* write the signal specifications to file */
			for(k = 0; k < thisPlot->nSignals; k++) {
				thisSignal = getRasterSignal(thisPlot->sigInfo, k);
				/* i first */
				fprintf(outFile, "i %d CELL %d PAGE %d SIGNAME %s\n",
						k, j, i, thisSignal->sigName);
			}

			/* write the graph specifications to file */
			thisGraph = &thisPlot->graph;
			/* g first */
			fprintf(outFile, "g 1 CELL %d PAGE %d START %4d INTERVAL %4d MAXFREQ %3d TICKMARK %3d YAXES %d NUMBER_AXES %d",
					j, i, thisGraph->start, thisGraph->interval, thisGraph->maxFreq, thisGraph->timeMark, thisGraph->yAxes,
					thisGraph->numberAxes);
			fprintf(outFile, " NFORMAT %d NFONT %d NSIZE %d LFONT %d LSIZE %d\n",
					thisGraph->Nformat, thisGraph->Nfont, thisGraph->Nsz, thisGraph->Lfont,
					thisGraph->Lsz);
			if(strlen(thisGraph->XaxisLabel)) strcpy(xlabel, thisGraph->XaxisLabel);
			else strcpy(xlabel, "(null)");
			/* X first */
			fprintf(outFile, "X 1 CELL %d PAGE %d TEXT %s\n", j, i, xlabel);
			if(strlen(thisGraph->YaxisLabel)) strcpy(ylabel, thisGraph->YaxisLabel);
			else strcpy(ylabel, "(null)");
			/* Y first */
			fprintf(outFile, "Y 1 CELL %d PAGE %d TEXT %s\n", j, i, ylabel);

			/* write the ecode mark specifications to file */
			if(thisPlot->markFlag) {
				thisMark = &thisPlot->ecodeMark;
				/* e first */
				fprintf(outFile, "e %d CELL %d PAGE %d MARK %d SIZE %d SYMBOL %s\n",
						thisPlot->markFlag, j, i, thisMark->rMark, thisMark->sz, thisMark->symbolString);
			}

			/* write the label specifications to file */
			thisLabel = &thisPlot->plotLabel;
			if(strlen(thisLabel->label)) strcpy(xlabel, thisLabel->label);
			else strcpy(xlabel, "(null)");
			/* l first */
			fprintf(outFile, "l %d CELL %d PAGE %d FONT %d SIZE %d X %.3f Y %.3f TEXT %s\n",
					thisPlot->labelFlag, j, i, thisLabel->font, thisLabel->sz, thisLabel->x, thisLabel->y,
					xlabel);
			fprintf(outFile, "\n");
		}
	}
	fprintf(outFile, "# RASTERS END\n");

	fflush(outFile);
	fclose(outFile);

	return;
}