Ejemplo n.º 1
0
///////////////////////////////////////////////////////////////////////////////////////
//
//  模型参数调节菜单处理过程
//
u32 PageDeltaSet(u8 event)
{
	static MENUSTAT ms;
			
	if(event==PV_INIT)
	{
		LcdClear(0);
		if(!ms.Init)
		{
			ms.iFocus=ms.iStart=0;
			ms.Init=1;
		}
		ms.Param=0xff;
		ms.Total=MenuDeltaSet[0].Max;
		ms.DrawMask=PD_ALL;	
		return 1;
	}
	
	//根据使能开关确定菜单数
	if(Model.Delta.Enable)	ms.Total=MenuDeltaSet[0].Max;
	else					ms.Total=1;
	
	//菜单数变化重绘
	if(ms.Param!=ms.Total)
	{
		LcdClear(0);
		ms.Param=ms.Total;
		ms.DrawMask=PD_ALL;	
	}
	
	if(event==PV_REDRAW)
	{
		ms.DrawMask=PD_ALL;	
	}
	
	//菜单通用处理过程
	PageMenuProc(MenuDeltaSet,&ms);
		
	//返回键处理
	if(KeyTstDown(KEY_EXT))
	{
		//V尾混控和三角翼/襟副翼混控互斥
		if(Model.Delta.Enable) 
		{
			Model.Vtail.Enable=0;
			Model.FlpAil.Enable=0;
		}
		PageReturn(PV_REDRAW);
	}
	
	KeyClearDown(KEY_MENUALL);
	
	return 0;
}
Ejemplo n.º 2
0
void setup() {
  Serial.begin(9600);
  Serial.println("$CLS#Setup()");
  pinMode(RED, OUTPUT);
  pinMode(GREEN, OUTPUT);
  pinMode(BLUE, OUTPUT);
  LcdInit();

  WiFi.begin(ssid, pass);
  while (WiFi.status() != WL_CONNECTED) {
    PulseLed(RED, 2, 10, 10);
    PulseLed(BLUE, 2, 10, 10);
    PulseLed(GREEN, 2, 10, 10);

    Serial.print(".");
    LcdPrint(".");
  }
  Udp.begin(localPort);
  setSyncInterval(300);
  setSyncProvider(getNtpTime);

  // Turn on the backlight.
  LcdClear();
  LcdnoBacklight();
  delay(2000);
  LcdBacklight();
}
Ejemplo n.º 3
0
void LcdInit ( void )	//инициализация SPI и дисплея
        {
        LCD_PORT.LCD_RST_PIN = 1;       //настроили порты ввода/вывода
        LCD_DDR.LCD_RST_PIN = LCD_DDR.LCD_DC_PIN = LCD_DDR.LCD_CE_PIN = LCD_DDR.SPI_MOSI_PIN = LCD_DDR.SPI_CLK_PIN = 1;
        delay_ms(1);
        SPCR = 0x50;
        LCD_PORT.LCD_RST_PIN = 0;       //дернули ресет
        delay_ms(10);
        LCD_PORT.LCD_RST_PIN = 1;
                            //Enable SPI port: No interrupt, MSBit first, Master mode, CPOL->0, CPHA->0, Clk/4

        LCD_PORT.LCD_CE_PIN = 1;        //Disable LCD controller

        LcdSend( 0b00100001, LCD_CMD ); 						//LCD Extended Commands
        LcdSend( 0b00000100+temp_control, LCD_CMD ); 					//Set Temp coefficent
        	#ifdef china
        LcdSend( 0b00001000|SPI_invert<<3, LCD_CMD ); 					//порядок битов в SPI
		#endif
        LcdSend( 0b00010000+bias, LCD_CMD ); 						//LCD bias mode 1:48
        	#ifdef china
        LcdSend( 0b01000000+shift, LCD_CMD ); 						//первая строка выше экрана, отображаем со второй
		#endif
	LcdSend( 0b10000000+Vop, LCD_CMD ); 						//Set LCD Vop (Contrast)
	
		#ifdef china
	LcdSend( 0x20|x_mirror<<5|y_mirror<<4|power_down<<3, LCD_CMD );			//LCD Standard Commands
        	#endif
                #ifndef china
        LcdSend( 0x20|power_down<<3|addressing<<2, LCD_CMD );				//LCD Standard Commands
                #endif
        LcdSend( 0b00001000|((disp_config<<1|disp_config)&0b00000101), LCD_CMD ); 	//LCD mode
        LcdClear();
        }
Ejemplo n.º 4
0
///////////////////////////////////////////////////////////////////////////////////////
//
//  陀螺仪菜单处理
//
u32 PageGyroSet(u8 event)
{
	static MENUSTAT ms;
			
	if(event==PV_INIT)
	{
		LcdClear(0);
		if(!ms.Init)
		{
			ms.iFocus=ms.iStart=0;
			ms.Init=1;
		}
		ms.Total=MenuGyroSet[0].Max;
		ms.DrawMask=PD_ALL;	
		return 1;
	}
	
	if(event==PV_REDRAW)
	{
		ms.DrawMask=PD_ALL;	
	}
	
	//菜单通用处理过程
	PageMenuProc(MenuGyroSet,&ms);
		
	//返回键处理
	if(KeyTstDown(KEY_EXT))
	{
		PageReturn(PV_REDRAW);
	}
	
	KeyClearDown(KEY_MENUALL);
	
	return 0;
}
Ejemplo n.º 5
0
Archivo: menu.c Proyecto: patlas/piwko
void enter_graphic_menu(uint8_t menu_no, uint8_t submenu_no)
{
	char s[20];
	LcdFillLine(1);
	slide_down();										// animacja
	LcdClear();
	if(menu_no==0 && submenu_no==2)						// Menu 1.2
	{
		LcdRectangle(0, 0, 83, 47,TRANSPARENT);			// ramka
		rez=enter_integer(rez,-10,100,2,3, "WART." , "s");	// funkcja obslugi danej pozycji menu
	}
	LcdRectangle(0, 0, 83, 47,TRANSPARENT);				// przykladowy kod po powrocie z funkcji obslugi menu
	LcdClearArea(3,2,13);
	LcdGotoXY(2,3);
	sprintf(s,"MENU %1u.%1u:%d",menu_no + 1, submenu_no, rez);
	LcdStr(FONT_1X, FONT_POSITIVE, (unsigned char*)s);
	delay_ms(1000);

	LcdFillLine(1);										// powrot do menu
	LcdGotoXY(2,1);
	slide_up();											// animacja
	LcdStr(FONT_1X,FONT_NEGATIVE,"MENU");
	slide_down();										// animacja
	show_graphic_menu(menu_item,submenu_item);			// pokazanie menu
}
Ejemplo n.º 6
0
///////////////////////////////////////////////////////////////////////////////////////
//
//  模型参数调节菜单处理过程
//
u32 PageAeroSet(u8 event)
{
	static MENUSTAT ms;
			
	if(event==PV_INIT)
	{
		LcdClear(0);
		if(!ms.Init)
		{
			ms.iFocus=ms.iStart=0;
			ms.Init=1;
		}
		ms.Total=MenuAeroSet[0].Max;
		ms.DrawMask=PD_ALL;	
		return 1;
	}
	
	if(event==PV_REDRAW)
	{
		ms.DrawMask=PD_ALL;	
	}
	
	//菜单通用处理过程
	PageMenuProc(MenuAeroSet,&ms);
		
	//回车键处理
	if(KeyTstDown(KEY_ENT))
	{
		//如果有子菜单或子功能,进入
		if(MenuAeroSet[ms.iFocus+1].SubItem)
		{
			if(MenuAeroSet[ms.iFocus+1].SubItem==PageCurveSet)
			{
				PageCurveCnt	=MenuAeroSet[ms.iFocus+1].Max;
				if(MenuAeroSet[ms.iFocus+1].Min==1)
				{
					PageCurveTitle	=PageStkCurveTitle;
					PageCurveValue	=&Model.StkCurve[0][0][0];
				}
				else
				{
					PageCurveTitle	=PageThrCurveTitle;
					PageCurveValue	=&Model.ThrCurve[0][0];
				}
			}
			BeepMusic(MusicEnter);			
			PageEnter((PAGEPROC)MenuAeroSet[ms.iFocus+1].SubItem,PV_INIT);
		}				
	}	
	
	//返回键处理
	if(KeyTstDown(KEY_EXT))
	{
		PageReturn(PV_REDRAW);
	}
	
	KeyClearDown(KEY_MENUALL);
	
	return 0;
}
Ejemplo n.º 7
0
void PCD8544::begin() 
{
  pinMode(pin_sce, OUTPUT);
  pinMode(pin_rst, OUTPUT);
  pinMode(pin_dc, OUTPUT);
  pinMode(pin_sdin, OUTPUT);
  pinMode(pin_sclk, OUTPUT);
  //reset display
  digitalWrite(pin_rst, LOW);
  digitalWrite(pin_rst, HIGH);
  //Init
  LcdWrite( LCD_CMD, 0x21 );  // LCD Extended Commands.
  LcdWrite( LCD_CMD, 0xB0 );  // Set LCD Vop (Contrast). //B1
  LcdWrite( LCD_CMD, 0x04 );  // Set Temp coefficent. //0x04
  LcdWrite( LCD_CMD, 0x14 );  // LCD bias mode 1:48. //0x13
  //We must send 0x20 before modifying the display control mode
  LcdWrite( LCD_CMD, 0x20 );  
  LcdWrite( LCD_CMD, 0x0C );  // LCD in normal mode 0x0c. 0x0d for inverse
  
  //backlight
  pinMode(pin_blight, OUTPUT);
  analogWrite(pin_blight, 255);
  
  LcdClear();
}
Ejemplo n.º 8
0
//inicjalizacja sterownika
void LcdInit(void)
{
	int i;

	HAL_GPIO_WritePin(PORT_DISP_NOKIA,LCD_PWR,GPIO_PIN_RESET);
	HAL_GPIO_WritePin(PORT_DISP_NOKIA,LCD_BKLT,GPIO_PIN_RESET);
	delay_ms(500);
	HAL_GPIO_WritePin(PORT_DISP_NOKIA,LCD_BKLT,GPIO_PIN_SET);
	HAL_GPIO_WritePin(PORT_DISP_NOKIA,LCD_PWR,GPIO_PIN_SET);
	HAL_GPIO_WritePin(PORT_DISP_NOKIA,RES,GPIO_PIN_RESET);
	delay_ms(2);
	HAL_GPIO_WritePin(PORT_DISP_NOKIA,RES,GPIO_PIN_SET);
	WriteCmd(0x21);//komendy rozszerzone
	WriteCmd(0x05);//komenda „przelaczajaca” sterownik w tryb pracy zgodny PCD8544
	WriteCmd(0xd5);//ustawienie Vop
	Delay(2);
	//WriteCmd(0x13);//bias
	WriteCmd(0x06);//korekcja temperatury dla PCD8544
	WriteCmd(0x14);//wspólczynnik multipleksowania

	WriteCmd(0x20);//komendy standardowe - adresowanie poziome
	Delay(2);
	WriteCmd(0x0c);//tryb wyœwietlania Standard Mode
	WriteCmd(0x40);//zerowanie licznika wierszy
	WriteCmd(0x80);//zerowanie licznika kolumn
	Delay(2);
//	for(i=0;i<(48*84);i++)//612
//		WriteData(0x00);//zerowanie pamieci RAM wyswietlacza
	LoWaterMark = LCD_CACHE_SIZE;
	HiWaterMark = 0;
	LcdClear();
	LcdUpdate();

}
Ejemplo n.º 9
0
/*****************************************************
* INITIALIZE DISPLAY
* DESCRIPTION: Setup all ports and initialize the LCD
* for usage.
*****************************************************/
void InitializeNokia5110(void)
{
   P2DIR |= 0x10;                           //Set LCD power port
   P2OUT |= 0x10;                           //Power up LCD
   P2DIR |= PIN_SCE;
   P2DIR |= PIN_RESET;
   P1DIR |= PIN_DC;
   P1DIR |= PIN_LED;
   P1OUT&= ~PIN_LED;                         //Enable the backlight by default
   P1SEL = BIT1 + BIT2 + BIT4;
   P1SEL2 = BIT1 + BIT2 + BIT4;
   UCA0CTL0 |= UCCKPL + UCMSB + UCMST + UCSYNC;  // 3-pin, 8-bit SPI master
   UCA0CTL1 |= UCSSEL_2;                     // SMCLK
   UCA0BR0 |= 2;                          // /2
   UCA0BR1 = 0;                              //
   UCA0MCTL = 0;                             // No modulation
   UCA0CTL1 &= ~UCSWRST;                     // **Initialize USCI state machine**
   digitalWrite(PIN_RESET, 0);
   digitalWrite(PIN_RESET, 1);

   //Send LCD init instructions
   LcdCommand(0x21 );  // LCD Extended Commands.
   LcdCommand(0xB6 );  // Set LCD Vop (Contrast).0xB0
   LcdCommand(0x04 );  // Set Temp coefficent. //0x04
   LcdCommand(0x15 );  // LCD bias mode 1:48. //0x13
   LcdCommand(0x0C );  // LCD in normal mode.
   LcdCommand(0x20 );
   LcdCommand(0x0C );
   LcdClear();
}
Ejemplo n.º 10
0
int main(){

	int i,j;

	LcdInitialise();
	LcdClear();
	LcdString("Hola");
while (1);

}
Ejemplo n.º 11
0
int main()
{

        LcdInit();	//initialize  LCD
        LcdContrast(0x7F);	 //display image
        _delay_ms(1000);
        LcdClear();
       
        LcdContrast(0x3F);	//adjust contrast
        _delay_ms(1000);
        LcdClear();
        
        LcdImage(waitImage);	//wait image
        LcdUpdate();
        _delay_ms(4000);
		
		ADCSRA |= (1<<ADEN)|(1<<ADPS0)|(1<<ADPS1)|(1<<ADPS2);   //enable ADC and select clk/128
		ADMUX |= (1<<REFS0)|(1<<ADLAR);							//Vref, ADC0 as input
		DDRC = 0x00;
		
		uint16_t temp, temp1, temp2, temp3;

        while (1)
        {
				ADCSRA |= (1<<ADSC);	//begin conversion
				while(!(ADCSRA &(1<<ADSC))==0);		//wait for end of conversion
				temp=(ADCH<<8)|ADCL;
				//calculation for temperature
                temp1 = temp%10;
                temp2 = temp%100/10;
                temp3 = temp%1000/100;
                char digit[4];
                sprintf(digit, "%d%d.%d ", temp1, temp2, temp3); //display temperature
                LcdClear();
                LcdGotoXYFont(1,1);
                LcdFStr(FONT_1X,(unsigned char*)digit);
                LcdGotoXYFont(1,2);
                LcdFStr(FONT_1X,(unsigned char*)PSTR ("Fahrenheit"));
                LcdUpdate();
                _delay_ms(1000);
        }
        return 0;
}
Ejemplo n.º 12
0
Archivo: menu.c Proyecto: patlas/piwko
void exit_from_menu(void)
{
	LcdClear();
	LcdFillLine(1);
	LcdGotoXY(1,1);
	LcdStr(FONT_1X,FONT_NEGATIVE,"   LCD DEMO   ");

	LcdFillLine(6);
	LcdGotoXY(1,6);
	LcdStr(FONT_1X,FONT_NEGATIVE,"   LCD DEMO   ");}
Ejemplo n.º 13
0
int main(void)
{
  RCC->CFGR |= (RCC_CFGR_HPRE_1|RCC_CFGR_HPRE_3); /* div 8 */
  LcdInit();
  LcdClear();
  LcdChr ( Y_POSITION*1+X_POSITION*1+13, "Hello world" );
  LcdChr ( Y_POSITION*2+X_POSITION*1+13+INVERSE+X_OFFSET*3, "Hello world" );
  LcdChr ( Y_POSITION*4+X_POSITION*0+2+BIG_UP, "15" );  
  LcdChr ( Y_POSITION*5+X_POSITION*0+2+BIG_DOWN, "15" );  
  return 0;
}
Ejemplo n.º 14
0
static void lcdPrint(char *line){
	int i;
	/*
	* Show welcome message in LCD-display
	*/
	LcdSetCursor(0);
	LcdClear();
	for (i = 0; i < strlen(line); i++) {
		LcdSetCursor(i);
		LcdWriteData(line[i]);
	}
}
void setup() {
	// set up the encoder interrupt to detect falling edge on digital pin 2
	attachInterrupt(0, encoder_interrupt, FALLING);
	Serial.begin(115200);
	Serial.write("<h>time\tspeed\tcurrent\tcurrent_sense\tvoltage\tvoltage_sense</h>\n");
	Serial.write("<u>ms\trpm\tmA\tcounts\tvolts\tcts</u>\n");
  pinMode(LED_PWM_PIN, OUTPUT);
  pinMode(VOLT_PIN, INPUT);
  pinMode(INTERRUPTER_PIN, INPUT);
  pinMode(LED_PIN, OUTPUT);
  pinMode(BTN_PIN, INPUT);

  LcdInitialize();
  gotoXY(0,0);
  LcdClear();
  LcdString((char*)"Current:");

  gotoXY(0,2);
  LcdString((char*)"Speed:");

  gotoXY(0,4);
  LcdString((char*)"Voltage:");

  blink_clock = millis();

  tach_enc.min_hertz = 5;
  tach_enc.max_period = 5000;
  tach_enc.pin_num = INTERRUPTER_PIN;
  tach_enc.debounce_min = 5;
  tach_enc.alpha = 800;
  tach_enc.cts_per_rev = 1;
  tach_enc.hertz = 0;

  button.button_pin = BTN_PIN;
  button.button_state = btnDown;

//  pulser.carrier_clock = 0;
//  pulser.carrier_period = 5000;
//  pulser.step_clock = 0;
//  pulser.pulse_up_period = 1000;
//  pulser.pulse_down_period = 3500;
//  pulser.step_period_up = pulser.pulse_up_period / impulse_num_samples;
//  pulser.step_period_down = pulser.pulse_down_period / impulse_num_samples;
//  pulser.index = 0;
//  pulser.offset_time = 0; // start pulse at beginning of each carrier period

  volt_sensor.max_volts = 68000; // mV at sensor saturation (depends on pot adj)

//  init_impulse(impulse_array, impulse_num_samples, 255);


}
Ejemplo n.º 16
0
//
// Send all the required initialization commands to the display
//
void LcdInit(void) {
  LcdSend(LCD_C, 0xE2);  // Software Reset
  delay(1);
  LcdSend(LCD_C, 0x3D);  // Charge pump ON
  LcdSend(LCD_C, 0x01);  // Charge pump=4
  LcdSend(LCD_C, 0xA4);  // Display all points = OFF
  LcdSend(LCD_C, 0x2F);  // Booster=ON, Voltage Reg=ON, Voltage Follower=ON
  LcdSend(LCD_C, 0xAF);  // Display ON
  LcdSend(LCD_C, 0xA6);  // Normal display
  LcdSend(LCD_C, 0xC0);  // Normal screen up/down
  LcdSend(LCD_C, 0xA0);  // Normal screen left/right
  LcdClear();
}
Ejemplo n.º 17
0
/***********************************************************
* SHOW JET SCORE
* DESCRIPTION: Shows the current stats of the game.
***********************************************************/
void showPongScore(unsigned int player, unsigned int computer, unsigned int highScore)
{
    LcdClear();
    printf_5Words("Plyr: ", "Cmp: ", "High: ", "", "", 10);
    set_LCD_Cursor(30, 0);
    printf_int(player);
    set_LCD_Cursor(30, 1);
    printf_int(computer);
    set_LCD_Cursor(30, 2);
    printf_int(highScore);

    WaitUserInput();
}
Ejemplo n.º 18
0
Archivo: menu.c Proyecto: patlas/piwko
void exit_from_graphic_menu()
{
	uint8_t i;

	slide_up();											// animacja
	LcdClear();											// powrot do trybu normalnego
	LcdFillLine(1);
	LcdGotoXY(1,1);
	LcdStr(FONT_1X,FONT_NEGATIVE,"   LCD DEMO   ");
	LcdFillLine(6);
	LcdGotoXY(1,6);
	LcdStr(FONT_1X,FONT_NEGATIVE,"   LCD DEMO   ");
}
Ejemplo n.º 19
0
///////////////////////////////////////////////////////////////////////////////////////
//
//  混控菜单处理过程
//
u32 PageMixerSet(u8 event)
{
	static MENUSTAT ms;
			
	if(event==PV_INIT)
	{
		LcdClear(0);
		if(!ms.Init)
		{
			ms.iFocus=ms.iStart=0;
			ms.Init=1;
		}
		ms.Total=MenuMixerSet[0].Max;
		ms.DrawMask=PD_ALL;	
		return 1;
	}
	
	if(event==PV_REDRAW)
	{
		ms.DrawMask=PD_ALL;	
	}
	
	//设置各混控状态
	strcpy(MenuMixerVtailStat,PageOptionOnOff[Model.Vtail.Enable]);
	strcpy(MenuMixerDeltaStat,PageOptionOnOff[Model.Delta.Enable]);
	strcpy(MenuMixerFlpAilStat,PageOptionOnOff[Model.FlpAil.Enable]);
	
	//菜单通用处理过程
	PageMenuProc(MenuMixerSet,&ms);
		
	//回车键处理
	if(KeyTstDown(KEY_ENT))
	{
		//如果有子菜单或子功能,进入
		if(MenuMixerSet[ms.iFocus+1].SubItem)
		{
			BeepMusic(MusicEnter);			
			PageEnter((PAGEPROC)MenuMixerSet[ms.iFocus+1].SubItem,PV_INIT);
		}				
	}	
	
	//返回键处理
	if(KeyTstDown(KEY_EXT))
	{
		PageReturn(PV_REDRAW);
	}
	
	KeyClearDown(KEY_MENUALL);
	
	return 0;
}
void LcdInitialise(void)
{
	DATAPORT &= NOT_PIN_RESET; //digitalWrite(PIN_RESET, LOW);
	DATAPORT |= PIN_RESET; //digitalWrite(PIN_RESET, HIGH);
	LcdWriteInit(0x21);  // LCD Extended Commands.
	LcdWriteInit(0xB1);  // Set LCD Vop (Contrast).
	LcdWriteInit(0x04);  // Set Temp coefficent. //0x04
	LcdWriteInit(0x14);  // LCD bias mode 1:48. //0x13
	LcdWriteInit(0x20);  // LCD Basic Commands
	LcdWriteInit(0x0C);  // LCD in normal mode.

	LcdInitBuffer();
	LcdClear();
}
Ejemplo n.º 21
0
/***********************************************************
* SHOW JET SCORE
* DESCRIPTION: Shows the current stats of the game.
***********************************************************/
void showJetScore(unsigned int ballsDestroyed, unsigned int health, unsigned int highScore)
{
    LcdClear();
    printf_5Words("Hit: ", "Hlth: ", "High: ", "", "", 10);
    set_LCD_Cursor(30, 0);
    printf_int(ballsDestroyed);
    set_LCD_Cursor(30, 1);
    printf_int(health);
    set_LCD_Cursor(30, 2);
    printf_int(highScore);
    StartTimer(0, 200);

    WaitUserInput();
}
Ejemplo n.º 22
0
void setDisplay(){
  if (modechanged){
    gotoXY(0,0);
    sprintf(cha, " Ustaw. wysw.");LcdString(cha, true);
    gotoXY(0,1);
    sprintf(cha, EMPTY_LINE);LcdString(cha, false);
  }
  gotoXY(0,1);
  sprintf(cha, "kontrast:");LcdString(cha,false);
  gotoXY(60,1);
  sprintf(cha, "%02i", contrast_val);LcdString(cha, (pos_setDisp==0));
  gotoXY(0,2);
  sprintf(cha, "jasnosc:");LcdString(cha,false);
  gotoXY(60,2);
  sprintf(cha, "%02i", jasnosc_val);LcdString(cha, (pos_setDisp==1));
  gotoXY(0,3);
  sprintf(cha, "OK");LcdString(cha,(pos_setDisp==2));  
  if (modechanged){
    gotoXY(0,4);
    sprintf(cha, "<> poprz/nast");LcdString(cha);
    gotoXY(0,5);
    sprintf(cha, "^v wart +/-");LcdString(cha);

    modechanged=false;
  }
  
  if (pos_setDisp==0){
    if (isUp())  { contrast_val=obetnij(contrast_val+1, 10, true); LcdInitialise(); }
    if (isDown()) { contrast_val=obetnij(contrast_val-1, 10, true); LcdInitialise(); }
  }
  else if (pos_setDisp==1){
    if (isUp())   { jasnosc_val=obetnij(jasnosc_val+1, 50); analogWrite(11, jasnosc_val); }
    if (isDown()) { jasnosc_val=obetnij(jasnosc_val-1, 50); analogWrite(11, jasnosc_val); }
  }
  if (pos_setDisp==2){
    if (isPressed()) {
      mode=1;
      modechanged=true;
      LcdClear();
      return;
    }
  }
  
  if (isRight())  pos_setDisp++;
  if (isLeft()) pos_setDisp--;
  if (pos_setDisp>2) pos_setDisp=0;
  if (pos_setDisp<0) pos_setDisp=2;
}
Ejemplo n.º 23
0
void SysInit(void)
{
    WDTCTL = WDTPW | WDTHOLD;	  // Stop watchdog timer
	Board_init();                 // Basic GPIO initialization
	SetVCore(3);                  // Set Vcore to accomodate for max. allowed system speed
	LFXT_Start(XT1DRIVE_0);       // Use 32.768kHz XTAL as reference, ACLK: SELA = 000, DIVA = 000
	Init_FLL_Settle(25000, 762);  // Set system clock to max (25MHz)

    LcdInit();
    LcdClear();
    //display_rect();
    AD9954Init();

    P4SEL = 0x00;
    P4DIR = 0x00;
    P4REN = 0xff;
}
Ejemplo n.º 24
0
void MainMenu()
{
  if ( Event == 0 )
    return;

  if ( Event == EV_FUNC_FIRST )
  {
    MenuCounter = 0;
    LcdClear();
    goto RedrawMenu;
  }

  if ( (Event & EV_MASK) == EV_KEY_PRESSED )
  {
    switch (Event & KEY_MASK)
    {
      case KEY_UP:
        if ( MenuCounter == 0 )
          MenuCounter = 6;
        else
          MenuCounter = MenuCounter - 1;
        break;
      case KEY_DOWN:
        if ( MenuCounter == 6 )
          MenuCounter = 0;
        else
          MenuCounter = MenuCounter + 1;
        break;
      case KEY_ENTER:
        switch(MenuCounter)
        {
          case 4: // Установка контрастности
            CurrentFunc(Contrast);
            break;
          case 5:
//            GPIO_TOGGLE(LCD_LED);
            break;
          case 6:
//            GPIO_RESET(PWR_ON);
            break;
          default:
            CurrentFunc(MenuSelected;)
            return;
        }
    }
  }
Ejemplo n.º 25
0
static int LcdInit(NUTDEVICE * dev)
{
	LCD_RS_CLR();			
	LCD_RW_CLR();			
	LcdClrBits(LCD_DATA);	
	NutMicroDelay(30);
	LCD_EN_CLR();
	NutMicroDelay(30);
	NutSleep(18);

    /* This initialization will make sure, that the LCD is switched
     * to 8-bit mode, no matter which mode we start from or we finally
     * need.
     */
	LcdWriteCmd(_BV(LCD_FUNCTION) | _BV(LCD_FUNCTION_8BIT));
    NutSleep(16);
	LcdWriteCmd(_BV(LCD_FUNCTION) | _BV(LCD_FUNCTION_8BIT));
    NutSleep(4);
	LcdWriteCmd(_BV(LCD_FUNCTION) | _BV(LCD_FUNCTION_8BIT));
    NutSleep(2);
    LcdWriteInstruction((_BV(LCD_FUNCTION)) |  (_BV(LCD_FUNCTION_8BIT)) |  (_BV(LCD_EXT)) , LCD_SHORT_DELAY);

	/* Switch display and cursor off. */
    LcdWriteNibble(_BV(LCD_ON_CTRL) >> 4);
    LcdWriteNibble(_BV(LCD_ON_CTRL));
    NutSleep(2);

	/* Clear display. */
    LcdClear();
	
    /* Set entry mode. */
    LcdWriteCmd(_BV(LCD_ENTRY_MODE) | _BV(LCD_ENTRY_INC));
	
   /* Switch display on. */
    LcdWriteCmd(_BV(LCD_ON_CTRL) | _BV(LCD_ON_DISPLAY));

    /* Move cursor home. */
    LcdCursorHome();

	/* Set data address to zero. */
    LcdWriteCmd(_BV(LCD_DDRAM));

	return 0;
}
Ejemplo n.º 26
0
void LcdInit() {
  
  ClockMilliSecondsDelay(16); // >15 ms
  
  lcdIwr=0x38 ;
  ClockMilliSecondsDelay(5); // >4.1 ms
  
  lcdIwr=0x38;
  ClockMicroSecondsDelay(101); // >100 us
  
  lcdIwr=0x38;
  ClockMicroSecondsDelay(101); // >100 us
  
  lcdIwr=0x38; // interface 8 bit
  ClockMicroSecondsDelay(41); // >40 us
  
  lcdIwr=0x0c; // display on
  ClockMicroSecondsDelay(41); // >40 us

  LcdClear();
}
Ejemplo n.º 27
0
void Init_SmartNavi()
{

	HardwareSetup();
	R_TMR_CreateOneShot(PDL_TMR_UNIT0,PDL_TMR_OUTPUT_OFF,1,tick_flag,4);
    R_INTC_CreateExtInterrupt(PDL_INTC_IRQ5,PDL_INTC_LOW ,Pen_flag,1); 		
		
	
	//	sendtoRTC();
	    Init_ADS7843();
		#ifdef GpsOn
	    getPos();
		#endif
		tone(1);
    	font_index();
    	font_index1();
    	LcdInit();
		LcdClear();
	    Gsm_State();		//initialize variable
		Init_Sim900();

}
Ejemplo n.º 28
0
void showMenu(){
  if (isPressed()) {
    mode=pos_menu+2;
    modechanged=true;
    if (mode==5) mode=0; 
    LcdClear();
    return;  
  }

  gotoXY(0,0);
  sprintf(cha, " Menu glowne ");LcdString(cha, true);
  gotoXY(0,1);
  sprintf(cha, "    "); LcdString(cha, false);
  gotoXY(20,1);
  sprintf(cha, "budzik"); LcdString(cha, (pos_menu==0));
  gotoXY(0,2);
  sprintf(cha, "ust."); LcdString(cha, (pos_menu==1));
  gotoXY(30,2);
  sprintf(cha, " ^  "); LcdString(cha, false);
  gotoXY(50,2);
  sprintf(cha, "ust."); LcdString(cha, (pos_menu==2));
  gotoXY(0,3);
  sprintf(cha, "czas"); LcdString(cha, (pos_menu==1));
  gotoXY(30,3);
  sprintf(cha, "< > "); LcdString(cha, false);
  gotoXY(50,3);
  sprintf(cha, "wysw"); LcdString(cha, (pos_menu==2));
  gotoXY(0,4);
  sprintf(cha, "     v"); LcdString(cha, false);
  gotoXY(0,5);
  sprintf(cha, "    "); LcdString(cha, false);
  gotoXY(20,5);
  sprintf(cha, "powrot"); LcdString(cha, (pos_menu==3));
  
  if (isUp()) pos_menu=0;
  if (isDown()) pos_menu=3;
  if (isRight()) pos_menu=2;
  if (isLeft()) pos_menu=1;
}
Ejemplo n.º 29
0
/*
 * Name         :  LcdInit
 * Description  :  Performs MCU SPI & LCD controller initialization.
 * Argument(s)  :  None.
 * Return value :  None.
 */
void LcdInit ( void )
{
    /* Pull-up on reset pin. */
    LCD_PORT |= _BV ( LCD_RST_PIN );

    /* Set output bits on LCD Port. */
    LCD_DDR |= _BV( LCD_RST_PIN ) | _BV( LCD_DC_PIN ) | _BV( LCD_CE_PIN ) | _BV( SPI_MOSI_PIN ) | _BV( SPI_CLK_PIN );

    Delay();

    /* Toggle display reset pin. */
    LCD_PORT &= ~( _BV( LCD_RST_PIN ) );
    Delay();
    LCD_PORT |= _BV ( LCD_RST_PIN );

    /* Enable SPI port:
    * No interrupt, MSBit first, Master mode, CPOL->0, CPHA->0, Clk/4
    */
    SPCR = 0x50;

    /* Disable LCD controller */
    LCD_PORT |= _BV( LCD_CE_PIN );

    LcdSend( 0x21, LCD_CMD ); /* LCD Extended Commands. */
    LcdSend( 0xC8, LCD_CMD ); /* Set LCD Vop (Contrast).*/
    LcdSend( 0x06, LCD_CMD ); /* Set Temp coefficent. */
    LcdSend( 0x13, LCD_CMD ); /* LCD bias mode 1:48. */
    LcdSend( 0x20, LCD_CMD ); /* LCD Standard Commands,Horizontal addressing mode */
    LcdSend( 0x0C, LCD_CMD ); /* LCD in normal mode. */

    /* Reset watermark pointers to empty */
    LoWaterMark = LCD_CACHE_SIZE;
    HiWaterMark = 0;

    /* Clear display on first time use */
    LcdClear();
    LcdUpdate();
}
Ejemplo n.º 30
0
u32 PageCurveSet(u8 event)
{
	static u8 DrawMask;
	static u8 iStk;
	static u8 iFocus,Total,iStart;
	
	if(event==PV_INIT)
	{
		LcdClear(0);
		iStk=0;
		iFocus=CURVE_NUM;
		iStart=0;
		Total=CURVE_NUM+CURVE_FUNC;
		DrawMask=PD_ALL;	
		return 1;
	}
		
	if(event==PV_USER)
	{
		LcdClear(0);
		DrawMask=PD_ALL;
	}
	
	//开始绘图
	if(DrawMask)    
	{
		LcdDrawStart(0, 0,LCD_W-1, LCD_H-1, DRAW_NWSE);  
	
		//标题绘制
		if(DrawMask&PD_TITLE)
		{
			LcdDrawRect(0, 0,127,13,0);
			LcdDrawText(2,0,(char*)PageCurveTitle[iStk]);
			if(PageCurveCnt>1)	LcdDrawText(96,0,"\1ENT\x2");
			LcdDrawHLine(0,LCD_CV_X-2,14,1);
			LcdDrawHLine(0,LCD_CV_X-2,15,1);
		}
		
		//曲线点列表
		if(DrawMask&(PD_LIST|PD_VALUE))
		{			
			u16 i,x,y,idx;
			for(i=0,y=18;i<LCD_CURVE_LINES ;i++,y+=7)
			{
				idx=iStart+i;
				LcdBw=(idx==iFocus);
				
				LcdDrawRect(LCD_CV_IX,y,LCD_CV_IX+31,y+7,LcdBw);				//绘制选中框
				LcdDrawMiniInt(LCD_CV_IX+3,y+1,idx+1,1,0,0xff,0);				//绘制曲线序号
				LcdDrawMiniNum(LCD_CV_IX+7,y+1,LCD_MN_COL);						//绘制分隔点
				LcdDrawMiniInt(LCD_CV_IX+30,y+1,PageCurveValue[iStk*CURVE_DS+idx],0,1,0,1);	//绘制曲线值
				LcdBw=0;
			}
			
			//绘制EXP EPA菜单
			LcdBw=(iFocus==CURVE_NUM);
			LcdDrawRect(3,20,LCD_CV_IX-4,26,LcdBw);	
			LcdDrawMiniEng(5,21,"EPA\x12");
			LcdDrawMiniInt(40,21,PageCurveValue[iStk*CURVE_DS+CURVE_NUM],0,0,1,1);	//绘制EPA
			
			LcdBw=(iFocus==CURVE_NUM+1);
			LcdDrawRect(3,30,LCD_CV_IX-4,36,LcdBw);	
			LcdDrawMiniEng(5,31,"EXP\x12");
			LcdDrawMiniInt(40,31,PageCurveValue[iStk*CURVE_DS+CURVE_NUM+1],0,0,1,1);//绘制EXP

			LcdBw=(iFocus==CURVE_NUM+2);
			LcdDrawRect(3,40,LCD_CV_IX-4,46,LcdBw);	
			LcdDrawMiniEng(5,41,"LEVEL");
			
			LcdBw=(iFocus==CURVE_NUM+3);
			LcdDrawRect(3,50,LCD_CV_IX-4,56,LcdBw);	
			LcdDrawMiniEng(5,51,"RESET");
			
			LcdBw=0;
			
			//绘制曲线
			LcdDrawRect(LCD_CV_X,LCD_CV_Y,LCD_CV_X+LCD_CV_W,LCD_CV_Y+LCD_CV_H,1);
			LcdDrawRect(LCD_CV_X+1,LCD_CV_Y+1,LCD_CV_X+LCD_CV_W-1,LCD_CV_Y+LCD_CV_H-1,0);
			LcdDrawHLine(LCD_CV_X,LCD_CV_X+LCD_CV_W,LCD_CV_Y+LCD_CV_H/2,1);
			LcdDrawVLine(LCD_CV_X+LCD_CV_W/2,LCD_CV_Y,LCD_CV_Y+LCD_CV_H,1);
			u16 x0,y0;
			for(i=0,x0=y0=0;i<CURVE_NUM;i++)
			{
				x=i*LCD_CV_W/(CURVE_NUM-1);
				y=LCD_CV_H-(s32)PageCurveValue[iStk*CURVE_DS+i]*LCD_CV_H/CURVE_TRV;
				if(y>LCD_CV_H) y=LCD_CV_H;
				LcdDrawLine(LCD_CV_X+x0,LCD_CV_Y+y0,LCD_CV_X+x,LCD_CV_Y+y,1);
				if(i==iFocus) LcdDrawVLine(LCD_CV_X+x,LCD_CV_Y,LCD_CV_Y+LCD_CV_H,1);
				x0=x;
				y0=y;
			}
		}
		//完成绘图		
		LcdDrawStop();
		DrawMask=0;
	}
			
	//加减按键处理
	s16 v=PageCurveValue[iStk*CURVE_DS+iFocus];
	///////////////////////////////////////////////////////////////
	if(iFocus<CURVE_NUM)//曲线值
	{
		if(KeyTstHold(KEY_R))
		{
			v=(v/10+1)*10;
			if(v>CURVE_TRV)	v=CURVE_TRV;
			DrawMask=PD_LIST;
		}
		else if(KeyTstDown(KEY_R))
		{
			if(v<CURVE_TRV)	v++;		
			DrawMask=PD_LIST;
		}
		if(KeyTstHold(KEY_L))
		{
			v=(v/10-1)*10;
			if(v<0)	v=0;
			DrawMask=PD_LIST;
		}
		else if(KeyTstDown(KEY_L))
		{
			if(v>0)	v--;		
			DrawMask=PD_LIST;
		}
	}
	///////////////////////////////////////////////////////////////
	else//EXP EPA等
	{
		////////////////////////////////////////
		if(iFocus==CURVE_NUM+3)//RESET
		{
			if(KeyTstDown(KEY_R) || KeyTstDown(KEY_L))
			{
				u32 i;
				for(i=0;i<CURVE_NUM;i++)	PageCurveValue[iStk*CURVE_DS+i]=i*125;
				PageCurveValue[iStk*CURVE_DS+CURVE_NUM  ]=100;		//epa
				PageCurveValue[iStk*CURVE_DS+CURVE_NUM+1]=0;		//exp
				PageAlert("曲线参数已复位!",500,PV_USER);
			}
		}
		////////////////////////////////////////
		if(iFocus==CURVE_NUM+2)//LEVEL
		{
			s16 delta=0;
			if(KeyTstHold(KEY_R))		delta=10;
			else if(KeyTstDown(KEY_R))	delta=1;
			
			if(KeyTstHold(KEY_L))		delta=-10;
			else if(KeyTstDown(KEY_L))	delta=-1;
			
			if(delta)
			{
				for(u32 i=0;i<CURVE_NUM;i++)	
				{
					s16 v=PageCurveValue[iStk*CURVE_DS+i];
					v+=delta;
					if(v>1000)	v=1000;
					if(v<0)		v=0;
					PageCurveValue[iStk*CURVE_DS+i]=v;
				}
				DrawMask=PD_LIST;
			}
		}
		////////////////////////////////////////
		if(iFocus==CURVE_NUM+1)//EXP
		{
			if(KeyTstDown(KEY_R))		if(v<50) 	v++;
			if(KeyTstDown(KEY_L))		if(v>0) 	v--;
			if(PageCurveValue[iStk*CURVE_DS+CURVE_NUM+1]!=v)
			{
				CurveMake(&PageCurveValue[iStk*CURVE_DS],PageCurveValue[iStk*CURVE_DS+CURVE_NUM],v);
				DrawMask=PD_LIST;
			}
		}
		////////////////////////////////////////
		if(iFocus==CURVE_NUM)//EPA
		{
			if(KeyTstDown(KEY_R))		if(v<100) 	v++;
			if(KeyTstDown(KEY_L))		if(v>-100) 	v--;
			if(PageCurveValue[iStk*CURVE_DS+CURVE_NUM]!=v)
			{
				CurveMake(&PageCurveValue[iStk*CURVE_DS],v,PageCurveValue[iStk*CURVE_DS+CURVE_NUM+1]);
				DrawMask=PD_LIST;
			}
		}
	}
	PageCurveValue[iStk*CURVE_DS+iFocus]=v;
	
	///////////////////////////////////////////////////////////////
	//上下按键处理
	if(KeyTstDown(KEY_UP))
	{
		if(iFocus>0) iFocus--;
		else		 iFocus=Total-1;
		DrawMask=PD_LIST|PD_IDX;
	}
	if(KeyTstDown(KEY_DW))
	{
		if(iFocus<Total-1) iFocus++;
		else		 		iFocus=0;
		DrawMask=PD_LIST|PD_IDX;
	}
	if(iFocus>=Total)							iFocus=Total-1;
	if(iFocus>=CURVE_NUM)						iStart=0;
	else if(iFocus<iStart) 						iStart=iFocus;
	else if(iFocus>iStart+LCD_CURVE_LINES-1) 	iStart=iFocus-LCD_CURVE_LINES+1;	
	
	///////////////////////////////////////////////////////////////
	//回车键切换曲线		
	if(KeyTstDown(KEY_ENT) )
	{
		iStk++;
		if(iStk>=PageCurveCnt) iStk=0;
		DrawMask|=PD_ALL;
	}
	
	///////////////////////////////////////////////////////////////
	//返回键处理
	if(KeyTstDown(KEY_EXT) )
	{
		PageReturn(PV_REDRAW);
	}
	
	KeyClearDown(KEY_MENUALL);	
	
	return 0;
}