コード例 #1
0
ファイル: init.c プロジェクト: dmitryshagin/dynamic_blender
static void init_adc()
{
    LCDclr();
    LCDGotoXY(3,0); 
    LCDstring((uint8_t *)"Initing...",10);
    AD7793_Reset();

    if(!AD7793_Init())
    {
        LCDclr();
        LCDGotoXY(2,0);
        LCDstring((uint8_t *)"ADC Error!",10);     
        return;
    }
    
    LCDGotoXY(0,1); 
    LCDstring((uint8_t *)"S1...",5);
    adc_init_channel(AD7793_CH_AIN1P_AIN1M);
    LCDstring((uint8_t *)"OK  S2...",9);
    adc_init_channel(AD7793_CH_AIN2P_AIN2M);    
    LCDstring((uint8_t *)"OK",2);
    adc_current_channel = AD7793_CH_AIN1P_AIN1M;
    adc_change_channel_and_trigger_delay(adc_current_channel);
    LCDclr();
}
コード例 #2
0
ファイル: SousVide.c プロジェクト: HarrisonW/ECE4760
//Display the Temperature on the LCD
void displayTemp(void* args) 
{	
	//String constants
	const uint8_t LCDTemp[5] = "TEMP\0";
	
	//LCD locations
	const uint8_t T_FOOD_REF_LOC = 0;
	const uint8_t T_FOOD = 5;
	
	uint8_t tempRefLen;
	uint8_t tempLen;
	float localTemp;
	float localTempRef;
	
	//String buffers
	uint8_t LCDTempRef[4];
	uint8_t LCDTempMeas[5];
	
	//flags indicating whether a variable needs to be updated
	uint8_t updateTempRefRef;
	
	//make local copies of the system parametes
	trtWait(SEM_T_REF);
	localTempRef = waterTempRef;
	trtSignal(SEM_T_REF);
	
	trtWait(SEM_T);
	localTemp = waterTemp;
	trtSignal(SEM_T);
	
	trtWait(SEM_THICKNESS);
	float localThickness = thickness;
	trtSignal(SEM_THICKNESS);
	
	trtWait(SEM_MAT_PROP);
	float localK = k;
	trtSignal(SEM_MAT_PROP);
	
	LCDGotoXY(0,0);
	LCDstring(LCDTemp, 4);
	
	uint32_t rel, dead;
	while(1){
		//trtWait(SEM_T_WATER);
		//trtSignal(SEM_T_WATER);

		
		sprintf(LCDTempMeas, "%f", localTemp);
		LCDGotoXY(0, 0);
		LCDstring(LCDTempMeas, 5);
		
		rel = trtCurrentTime() + SECONDS2TICKS(0.2);
		dead = trtCurrentTime() + SECONDS2TICKS(0.225);
		trtSleepUntil(rel, dead);
	}
}
コード例 #3
0
ファイル: avr.c プロジェクト: olcai/sommar
void lcd_init(void)
{
  /* setup LCD on portB and display greeting */
  LCDinit(); 
  LCDclr();
  LCDGotoXY(0,0);
  LCDcursorOFF(); 

  LCDstring((uint8_t*)"System online", 13);
  LCDGotoXY(0,1);
  if(config.flags.mode == CONFIG_MODE_BASE)
    LCDstring((uint8_t*)"base", 4);
  else
    LCDstring((uint8_t*)"node", 4);
}
コード例 #4
0
ファイル: RoboticArm.c プロジェクト: chinex-eze/RoboticArm
void init() 
{
	TCCR1A |= (1 << WGM11); 
	TCCR1B |= (1 << WGM12) | (1 << WGM13); 

	TCCR3A |= (1 << WGM31); 
	TCCR3B |= (1 <<WGM32) | (1 <<WGM33); 

	TCCR1A |= (1 << COM1A1) | (1 <<COM1A0) | (1 <<COM1B1) | (1 <<COM1B0) | (1 << COM1C1) | (1 <<COM1C0);  
	TCCR3A |= (1 << COM3A1) | (1 << COM3A0) | (1 << COM3B1) | (1 << COM3B0); 

	TCCR1B |= (1 << CS11); 
	TCCR3B |= (1 << CS31); 
	
	ICR3 = 40000; 
	ICR1 = 40000; 

	//set PWM pins as output 
	DDRB |= (1 << 5) | (1 << 6) | (1 << 7);  
	DDRE |= (1 << 3) | (1 << 4); 

	LCDinit(); 
	LCDclr();  
	LCDcursorOFF(); 
	LCDstring("GRIP MODE", 9); 
} 
コード例 #5
0
ファイル: CharMenu.c プロジェクト: firdanas/tombol
///Clears block with whitespace replacing
void LcdDelete(uint8_t xawal, uint8_t xakhir, uint8_t _Y)
{
	LCDGotoXY(xawal,_Y);
	for (uint8_t i=xawal;i<=xakhir;i++)
	{
		LCDstring((uint8_t*)" ",1);
	}
}
コード例 #6
0
ファイル: CharMenu.c プロジェクト: firdanas/tombol
void DrawNumberCPos(uint16_t bil, uint8_t _c)
{
	uint8_t pjg;
	char lcdchar[30];
	if (_c!=0)
	{
		
		for (uint8_t i=1; i<=_c; i++)
		{
			LCDstring((uint8_t*)" ",1);
		}
	}
	snprintf(lcdchar,15, "%d",bil);
	pjg = strlen(lcdchar);
	LCDstring((uint8_t*)lcdchar,pjg);
	
}
コード例 #7
0
ファイル: USARTTest.c プロジェクト: HarrisonW/ECE4760
int main (void){
	usartInit();
	initLCD();
	while (1){
	LCDGotoXY(0,0);
	LCDstring(LCDBuffer, 1);
	}
	return 0;
}
コード例 #8
0
ファイル: CharMenu.c プロジェクト: firdanas/tombol
void PrintScroll(uint8_t sNum, uint8_t sMax)
{
	uint8_t mulai = 0;
	uint8_t nScroll = 1;
	LcdDelete(0,15,1);
	mulai = 8-(sMax/2);
	LCDGotoXY(mulai,1);
	for (nScroll = 1; nScroll<=sMax; nScroll++)
	{
		if (nScroll == sNum)
		{
			LCDstring((uint8_t*)"#",1);
		}
		else
		{
			LCDstring((uint8_t*)"-",1);
		}
	}
}
コード例 #9
0
ファイル: LCD_projekt.c プロジェクト: OscarJL/ims_project
//----------------------Funktioner------------------------
void init_LCD()
{
	const char lcd_text[] = "ADC value:";
	LCDinit();
	_delay_ms(1000);
	LCDclr();
	_delay_ms(1000);
	LCDhome();
	_delay_ms(1000);
	LCDstring((uint8_t*) lcd_text, (uint8_t) strlen(lcd_text));
	_delay_ms(1000);
	LCDvisible();
}
コード例 #10
0
ファイル: RoboticArm.c プロジェクト: chinex-eze/RoboticArm
void change_mode()
{
	LCDclr(); 
	if(currentMode == GRIP_MODE)
	{
		currentMode = SHOULDER_MODE; 
		LCDstring("SHOULDER MODE", 13); 
		PORTA |= (1 << PA6); //light on for lift mode
	} 
	else if(currentMode == SHOULDER_MODE)
	{
		currentMode = ELBOW_MODE; 
		LCDstring("ELBOW MODE", 10); 
		PORTA |= (1 << PA6); 	//light off for grip mode
	} 
	else if(currentMode == ELBOW_MODE) 
	{
		currentMode = GRIP_MODE; 
		LCDstring("GRIP MODE", 9); 
		PORTA &= ~(1 << PA6);
	} 
	else {/*just empty*/}
}
コード例 #11
0
ファイル: system.c プロジェクト: olcai/sommar
void panic(const char* msg)
{
    unsigned char panic_msg[] = "KERNEL PANIC!";
    cli();
    PORTC=0xFF;
    LCDinit(); 
    LCDclr();
    LCDGotoXY(0,0);
    LCDcursorOFF(); 
    LCDstring(panic_msg, sizeof(panic_msg)-1);
    LCDGotoXY(0,1);
    while(*msg)
	LCDsendChar(*(msg++));
    while(1)
    {
        PORTC = ~PORTC;
        _delay_ms(500);
    }
}
コード例 #12
0
ファイル: LCD_projekt.c プロジェクト: OscarJL/ims_project
int main(void)
{
	/* Variables */
	uint16_t ad_value = 0;
    char ad_value_text[8];
	
	init_LCD();
	init_ADC();
	
	DDRD = 0xFF;
	PORTD = 0;
	
    while(1)
    {
		ad_value = read_ADC();
		itoa(ad_value,ad_value_text,10);
		LCDGotoXY(0,1);
		LCDstring((uint8_t*) ad_value_text, (uint8_t) strlen(ad_value_text));
		
    }
}
コード例 #13
0
ファイル: ReactionTimer.c プロジェクト: HarrisonW/ECE4760
//**********************************************************
//Entry point and task scheduler loop
int main(void){
   initialize();
  // Check if R (for ReactionMaster) is written. Write default score if not
  if (eeprom_read_byte((uint8_t*)EEPROM_TRUE_ADDR) != 'R'){
    eeprom_write_word((uint16_t*)EEPROM_DATA_ADDR,DEFAULT_SCORE);
    eeprom_write_byte((uint8_t*)EEPROM_TRUE_ADDR,'R');
  }

  // main task scheduler loop
  // set LEDs corresponding to state
  // LED7 is used as reaction timer LED
  while(1){
    switch (gameState){
      case INITIAL:
        PORTB = ~0x01; //led0
        break;

      case READY:
        if (!readyDisplayed){
          pressedAndReleased = 0;
          scoreDisplayed = 0;
          PORTB = ~0x02; //led1
          LCDclr();
          LCDGotoXY(0,0);
          CopyStringtoLCD(LCDReady, 0, 0);
          readyDisplayed = 1;
        }
        break;

      case WAITING:
        if (!randomTimeChosen){
          pressedAndReleased = 0;
          readyDisplayed = 0;
          cheatDisplayed = 0;
          cheatState = 0;
          PORTB = ~0x04; //led2
          LCDclr();
          //assign a random time to waitTime
          waitTime = rand() % (RND_MAX - RND_MIN + 1) + 1000;
          randomTimeChosen = 1;
        }
        break;

      case LED_ON:
        if (!ledTurnedOn){
          randomTimeChosen = 0;
          rxnCount = 0;
          PORTB = ~(0x08 | 0x80); //led7 and led3
          // PORTB = ~0x80; // led7
          // turn the buzzer on
          buzzer = 1;
          ledTurnedOn = 1;
        }
        break;

      case DISPLAY:
        if (!scoreDisplayed){
          PORTB = ~0x10; //led4
          // PORTB = ~0x00; // All off

          buzzer = 0;
          pressedAndReleased = 0;
          ledTurnedOn = 0;

          if(rxnCount == 1000) {
            CopyStringtoLCD(LCDTooSlow, 0, 0);
          } else {
            CopyStringtoLCD(LCDScore, 0, 0);
            //Display the player's score
            //eeprom_write_word((uint16_t*)EEPROM_DATA_ADDR,rxnCount);
            sprintf(LCDBuffer, "%i", rxnCount);
            LCDGotoXY(7, 0);
            LCDstring(LCDBuffer, strlen(LCDBuffer));
          }
          CopyStringtoLCD(LCDHighScore, 0, 1);
          //Display the high score
          uint16_t highScore = eeprom_read_word((uint16_t*)EEPROM_DATA_ADDR);
          sprintf(LCDBuffer, "%i", highScore);
          LCDGotoXY(11, 1);
          LCDstring(LCDBuffer, strlen(LCDBuffer));
          scoreDisplayed = 1;

          //Store the player's score if it is larger than the current high score
          if (rxnCount < highScore){
            eeprom_write_word((uint16_t*)EEPROM_DATA_ADDR,rxnCount);
          }

        }
        break;

      case CHEAT:
        if (!cheatDisplayed){
          PORTB = ~0x20; //led5
          // PORTB = ~0x00; // All off
          randomTimeChosen = 0;
          cheatState = 0;
          buzzer = 0;
          LCDGotoXY(0, 0);
          CopyStringtoLCD(LCDCheat, 0, 0);
          cheatDisplayed = 1;
        }
        break;
    }
  }
}
コード例 #14
0
ファイル: CharMenu.c プロジェクト: firdanas/tombol
void CharMenuDraw()
{
	if (MenuMain[gState].actFunction!=0)
	{
		MenuMain[gState].actFunction();
		_delay_ms(500);
		while (!ButtonBack());
		gCursor = MenuMain[gState].cursorNum;
		gState = MenuMain[gState].parentIndex;
		return;
	}
	uint8_t x=0;
	///Catch the current menu and cursor, x start from 1 (not main menu)
	for (x=1;x<TOTAL_MENU;x++)
	{
		///current state is gState, find children of MenuMain[gState]
		if ((MenuMain[x].parentIndex == gState) && ((MenuMain[x].cursorNum) == gCursor))
		{
			///Draw the current menu at current cursor
			LCDGotoXY(0,0);
			LCDstring((uint8_t*)(MenuMain[x].menuText),16);
			PrintScroll(gCursor,MenuMain[MenuMain[x].parentIndex].numOfChildren);
			
			///wait signal
			uint8_t action = ButtonRead();
			if (action == BUTTON_ENTER_DOWN)
			{
				gState = x;
				gCursor = 1;
				//~ DrawNumber(gState,0,1,3);
				//~ uint8_t ii;
				//~ for (ii=1;ii<TOTAL_MENU;ii++)
				//~ {
					//~ if ((MenuMain[ii].parentIndex==x) && (MenuMain[ii].cursorNum==1))
					//~ {
						//~ gCursor = 1;
						//~ gState = ii;
						//~ break;
					//~ }
				//~ }
				//~ _delay_ms(1000);
			}
			else if (action == BUTTON_NEXT_DOWN)
			{
				gCursor++;
				if (gCursor>MenuMain[MenuMain[x].parentIndex].numOfChildren)
					gCursor = 1;
			}
			else if (action == BUTTON_PREV_DOWN)
			{
				gCursor--;
				if (gCursor<1)
					gCursor = MenuMain[MenuMain[x].parentIndex].numOfChildren;
			}
			else if (action == BUTTON_BACK_DOWN)
			{
				gCursor = MenuMain[gState].cursorNum;
				gState = MenuMain[gState].parentIndex;
				//~ DrawNumber(MenuMain[gState].cursorNum,3,1,2);
				//~ gCursor = 1;
				//~ return;
			}
			return;
		}
	}
}
コード例 #15
0
ファイル: serial40x4.firmware.c プロジェクト: UIKit0/picogui
void main(void) {
  char ch;
  
  asm {
    clrf	PORTA
    clrf	PORTB
    bsf         STATUS,RP0
    movlw	0x0C
    movwf	TRISA
    clrf	TRISB
    bcf	        STATUS,RP0
  }

  // Init both LCDs at the same time
  emask = E1 | E2;
  LCDinit();
  
  // Say hi until the serial port says otherwise
  emask = E1;
  LCDstring("LCD interface ready");
  emask = E2;
  LCDstring("Micah Dowty, July 2000");
  emask = E1;

  // Wait for input
  while (1) {
    ch = getchar();

    // Process escape chars
    if (ch == '\\') {
      ch = getchar();
      switch (ch) {

      case '\\':
	LCDchar('\\');
	break;

      case '1':    // First display
	emask = E1;
	break;

      case '2':    // Second display
	emask = E2;
	break;

      case '*':    // All displays
	emask = E1 | E2;
	break;

      case 'c':    // Next char is an LCD command
	ch = getchar();
	LCDcmd(ch);
	break;

      case 's':    // Clear screen
	LCDcmd(clear_lcd);
	break;

      case 'g':    // Go to the beginning of CGRAM
	LCDcmd(set_cg_ram);
	break;

      case 'd':    // Go to the beginning of DDRAM
	LCDcmd(set_dd_ram);
	break;

      case 'b':    // Beep
	output_high_port_a(BEEPER);
	delay_ms(250);
	output_low_port_a(BEEPER);
	break;

      case 'f':    // Flash
	output_high_port_a(LED);
	delay_ms(250);
	output_low_port_a(LED);
	break;

      case 'n':    // Go to line 2
	LCDcmd(set_dd_ram + 40);
	break;

      }
    }
    else {
      LCDchar(ch);
    }
  }
}