Exemplo n.º 1
0
//=============================================================================
void lcd_option(void)
{
  unsigned char h, m, s;
  unsigned char d, ms, y, dw;
  LCD_goto(0, 0);
  LCD_puts(optionmenu[o_menu]);
  if (o_menu == OM_SETTIME) {
    RTC_get_time(&h, &m, &s);
    LCD_goto(0, 1);
    print_dec(h,2,'0'); LCD_dat(':'); print_dec(m,2,'0'); LCD_dat(':'); print_dec(s,2,'0'); 
    LCD_puts("          ");
  } else if (o_menu == OM_SETDATE) {
    RTC_get_date(&dw, &d, &ms, &y);
    dw = RTC_day_of_week(d, ms, y);
    LCD_goto(0, 1);
    print_dec(d,2,'0'); LCD_dat('-'); print_dec(ms,2,'0'); LCD_dat('-'); print_dec(2000 + y,4,'0'); 
    LCD_dat(' '); LCD_dat('['); LCD_puts(den_dw[dw]); LCD_dat(']'); LCD_dat(' ');
  } else if (o_menu == OM_SETALARM) {
    LCD_goto(0, 1);
    print_dec(a_hour,2,'0'); LCD_dat(':'); print_dec(a_min,2,'0'); LCD_dat(':'); print_dec(a_sec,2,'0');
    LCD_dat(' '); LCD_dat('-'); LCD_dat(' '); LCD_dat('[');
    if (a_onoff == 1) LCD_puts(" ON"); else LCD_puts("OFF");
	LCD_dat(']');
  } else if (o_menu == OM_SETFM) {
  }
}
Exemplo n.º 2
0
int
main(int argc, char *argv[])
{
	int		 i, c, done;
	int		 offset;
	char	 buf[128], str[64];
	short	 temp;

	i = 0;
	offset = 0;
	init_board();

read_input:
	if (IS_PRESSED(BUTTON1)) {
		UART0_puts("_BALANCE:1_", 64);
		UART0_gets(str, sizeof(str));
		LCD_command(1);
		LCD_puts(str, sizeof(str));
		LCD_putchar('\n');
		temp = read_temp();
		show_temperature(temp);
	} else if (IS_PRESSED(BUTTON2)) {
		UART0_puts("_RECHARGE:1:", 64);
		escrevenum(leds_state);
		UART0_puts("_", 64);
		UART0_gets(str, sizeof(str));
		LCD_command(1);
		LCD_puts(str, sizeof(str));
		LCD_putchar('\n');
		temp = read_temp();
		show_temperature(temp);
	} else if (IS_PRESSED(BUTTON3)) {
		UART0_puts("_DISCHARGE:1:", 64);
		escrevenum(leds_state);
		UART0_puts("_", 64);
		UART0_gets(str, sizeof(str));
		LCD_command(1);
		LCD_puts(str, sizeof(str));
		LCD_putchar('\n');
		temp = read_temp();
		show_temperature(temp);
	} else if (IS_PRESSED(BUTTON4)) {
		leds_state++;
		UPDATE_LED();
		uwait(1000);
	} else if (IS_PRESSED(BUTTON5)) {
		leds_state--;
		UPDATE_LED();
		uwait(1000);
	}
	goto read_input;

	/* NOTREACHED */
	return (0);
}
Exemplo n.º 3
0
//=============================================================================
int main(void)
{
  LIGHT_init();
  LCD_init();
  LIGHT_on();
  LCD_clear();
  BEEP_init();
  RTC_init();
  RTOS_init();
  RC5_Init();
  RC5_Reset();
  ENC_init();
  KBD_init();
  bmp180Init();
  dht22Init();
  rda5807Init();
  rda5807PowerOn();
  rda5807SetMute(1);
  ds18x20SearchDevices();
  LCD_goto(0, 0);
  LCD_puts("POGODNAY STATION");
  LCD_goto(0, 1);
  LCD_puts("  VERSION 1.0   ");
  _delay_ms(1000);
  LCD_clear();
  LCD_load_bignum();
  ds18x20Process();
  if (bmp180HaveSensor()) bmp180Convert();
  dht22Read();
#if (DEBUG == 1)
  if ((BUT_1_PINX & (1<<(BUT_1_PIN))) == 0) {
    _delay_ms(100);
    if ((BUT_1_PINX & (1<<(BUT_1_PIN))) == 0) {
      RTOS_setTask(EVENT_SET_STATE_OPTION, 0, 0);
      BEEP_beep();
	  while (((BUT_1_PINX & (1<<(BUT_1_PIN))) == 0)) { }
      BEEP_beep();
    }
  }
#else
  RTOS_setTask(EVENT_SET_STATE_OPTION, 0, 0);
  BEEP_beep();
#endif
  RTOS_setTaskFunc(set_blink, 0, 1000);      // моргание
  RTOS_setTaskFunc(KBD_scan, 0, 5);          // запускаем опрос кнопок
  RTOS_setTaskFunc(ENC_poll, 0, 1);          // запускаем опрос енкодера
  RTOS_setTaskFunc(RC5_scan, 0, 5);          // запускаем опрос RC5
  RTOS_setTask(EVENT_SET_SHOW, 0, 0);		 // запуск шоу
  sei(); 				        			 // Разрешили прерывания
  while(1) {
    RTOS_dispatchTask();    			     // Вызываем диспетчер в цикле.    
  }
}
Exemplo n.º 4
0
int main(void) {
    
    char buffer[8];

    cli();
    LCD_Init();
    DDRB = DDRB | ( 1 << PB5);
    PORTB = PORTB & ( ~ ( 1 << PB5 ) );
    sei();

    uint8_t loop8;
    uint16_t byteIndex;
    uint16_t numBytes = 3431;//HARDCODED
    sprintf(buffer, "difference encoding");
    LCD_puts(buffer,1);
    for(byteIndex = 0 ; byteIndex < numBytes ; byteIndex ++){
	uint8_t currByte = pgm_read_byte(&(mywavdata[byteIndex]));
	for(loop8 = 1 ; loop8 > 0 ; loop8*=2){
                if (loop8 & currByte) 
			PORTB = PORTB | (1 << PB5);
		else
			PORTB = PORTB & ~(1 << PB5);
        	_delay_us(120);
	}
    }
    
    return 0;   /* never reached */
}
Exemplo n.º 5
0
//	PUTS,string
//	Load the string and point pStr to it.
//	Call LCD_puts(*pStr, scrollmode); 
//	Send "Called LCD_puts with 'string'" to the PC where string is the string sent.
void OnPUTS(char *pStr)
{
	sendFString(PUTS_msg);
	sendString(pStr);
	
	LCD_puts(&pStr[4],0); //Overlook the PUTS part of the string

}
Exemplo n.º 6
0
main(){

TRISC = 0xfff0;
TRISD = 0x0000;
LCD_init();
//*Test for LCD*/
/*-----------------
LCD_puts(startStr1);
LCD_goto(0x40);
LCD_puts(startStr2);
while (1) {}
//*/
///*-----------------
initADC();
while(1) {
AD1CON1SET=0x0002;
DelayMsec(2);
AD1CON1CLR=0x0002;
while (!(AD1CON1 & 0x0001));
ADCValue = ADC1BUF0;
double Vtg=3.3*ADCValue/1024;
int x=100*Vtg;
int x1=x/100; x-=x1*100;
int x2=x/10;  x-=x2*10;
int x3=x;
uchar startStr4[14];
startStr4[0]=x1+48;
startStr4[1]='.';
startStr4[2]=x2+48;
startStr4[3]=x3+48;
startStr4[4]='V';
startStr4[5]=' ';
startStr4[6]=' ';
startStr4[7]=' ';
startStr4[8]=' ';
startStr4[9]=' ';
startStr4[10]=' ';
startStr4[11]=' ';
startStr4[12]=' ';
startStr4[13]=' ';
LCD_puts(startStr1);
LCD_goto(0x40);
LCD_puts(startStr4);
}//while
//*/
}//main
Exemplo n.º 7
0
/*!
 *      M       A       I       N
 *
 */
int main(void) {
        Hw_init();                              /* Initialize LCD */
        LCD_puts(&text[0]);                     /* Display string on both part of display */
        while (1) {                              /* wait forever */
			delay_ms(100);
			LCD_shift_content_right();
		}
        return(0);
}
Exemplo n.º 8
0
//=============================================================================
void show_bigpressure(void)
{
  uint8_t display[4];
  int16_t p;
  if (bmp180HaveSensor())  {
    bmp180Convert();
    p = bmp180GetPressure();
    display[0] = (p / 1000) % 10;
    display[1] = (p / 100) % 10;
    display[2] = (p / 10) % 10;
    display[3] = (p / 1) % 10;
    lcd_bigchar(0, display[0]);
    lcd_bigchar(4, display[1]);
    lcd_bigchar(8, display[2]);
    LCD_goto(13, 0); LCD_puts("MM");
    LCD_goto(13, 1); LCD_puts("RS");
  }
}
Exemplo n.º 9
0
int main(void) {

	// Inicializace displeje
	LCD_initialize();

	GPIO_Initialize();

	// Pocatecni stav uctu
	BankaOperace(10000);
	nVyberu = nVkladu = 0;

	LCD_puts("Spoustim procesy...");



	// Vytvoreni ulohy 1 - obsluha prikazu
	xTaskCreate(prikazy, /* ukazatel na task */
			"GUI", /* jmeno tasku pro ladeni - kernel awareness debugging */
			configMINIMAL_STACK_SIZE, /* velikost zasobniku = task stack size */
			(void*)NULL, /* pripadny parametr pro task = optional task startup argument */
			tskIDLE_PRIORITY + 1, /* priorita tasku, nizsi nez ostatnich */
			(xTaskHandle*)NULL /* pripadne handle na task, pokud ma byt vytvoreno */
		);

	// Vytvoreni ulohy 2 - vklad
	xTaskCreate(vklad, /* ukazatel na task */
			"vklad", /* jmeno tasku pro ladeni - kernel awareness debugging */
			configMINIMAL_STACK_SIZE, /* velikost zasobniku = task stack size */
			(void*)NULL, /* pripadny parametr pro task = optional task startup argument */
			tskIDLE_PRIORITY + 2, /* priorita tasku, vyssi nez u tasku 1 */
			&TaskVklad /* pripadne handle na task, pokud ma byt vytvoreno */
		);

	// Vytvoreni ulohy 2 - vyber
	xTaskCreate(vyber, /* ukazatel na task */
				"vyber", /* jmeno tasku pro ladeni - kernel awareness debugging */
				configMINIMAL_STACK_SIZE, /* velikost zasobniku = task stack size */
				(void*)NULL, /* pripadny parametr pro task = optional task startup argument */
				tskIDLE_PRIORITY + 3, /* priorita tasku, vyssi nez u tasku 1 */
				&TaskVyber /* pripadne handle na task, pokud ma byt vytvoreno */
			);

	// Pozastavime tasky
	vTaskSuspend(TaskVklad);
	vTaskSuspend(TaskVyber);

	// Spusteni jadra FreeRTOS
	vTaskStartScheduler(); /* does not return */

	// Sem bychom se nikdy nemeli dostat
	while (1)
		;

	/* Never leave main */
	return 0;
}
Exemplo n.º 10
0
void VypisVysledek(void) {
 	LCD_clear();
	LCD_puts("zustatek=");
	sprintf(buff, "%d", BankaOperace(0) );
	LCD_puts(buff);
	LCD_set_cursor(2,1);
	if ( BankaOperace(0)  != 12500 )
	{
		if ( BankaOperace(0) < 12500 )
			LCD_puts("Zaknik podveden!");
			//Reditel banky vas mozna pochvali ale jen nez si zakaznik bude stezovat...
		else
			LCD_puts("Banka ztratila $");
			//dostal jste vypoved...;
	}
	else
		LCD_puts("GRATULACE, ok!");

}
Exemplo n.º 11
0
/*
 NAME:      | LCD_puts
 PURPOSE:   | Displays a string from flash onto the Butterfly's LCD
 ARGUMENTS: | Pointer to the start of the flash string
 RETURNS:   | None
*/
void LCD_puts_f(const char *FlashData)
{
   /* Rather than create a new buffer here (wasting RAM), the TextBuffer global
      is re-used as a temp buffer. Once the ASCII data is loaded in to TextBuffer,
      LCD_puts is called with it to post-process it into the correct format for the
      LCD interrupt.                                                                */

   strcpy_P((char*)&TextBuffer[0], FlashData);
   LCD_puts((char*)&TextBuffer[0]);
}
Exemplo n.º 12
0
//=============================================================================
void lcd_edit_time(void)
{
  LCD_goto(0, 0);
  LCD_puts(optionmenu[o_menu]);
  if (n_edit_time == 0)
  {
    LCD_goto(9, 0);
    LCD_puts(" [HOUR]");
    LCD_goto(0, 1);
	if (blinks == 1) print_dec(hour, 2, '0'); else { LCD_dat(' '); LCD_dat(' '); }
    LCD_dat(':'); print_dec(min, 2, '0'); LCD_dat(':'); print_dec(0, 2, '0');
  } else if (n_edit_time == 1) {
    LCD_goto(9, 0);
    LCD_puts(" [MIN] ");
    LCD_goto(0, 1); print_dec(hour, 2, '0'); LCD_dat(':');
	if (blinks == 1) print_dec(min, 2, '0'); else { LCD_dat(' '); LCD_dat(' '); }
    LCD_dat(':'); print_dec(0, 2, '0');
  }
}
Exemplo n.º 13
0
//=============================================================================
void show_bigchanel(void)
{
  uint8_t display[2];
  uint8_t v = chanel + 1;
  display[0] = (v / 10) % 10;
  display[1] = (v / 1) % 10;
  LCD_goto(0, 0); LCD_puts("CHANEL:");
  lcd_bigchar(8, display[0]);
  lcd_bigchar(12, display[1]);
}
Exemplo n.º 14
0
//=============================================================================
void show_himedity(void)
{
  uint8_t display[4];
  int16_t p;
  dht22Read();
  if (dht22HaveSensor()) {
  	p = dht22GetHumidity();
    display[0] = (p / 1000) % 10;
    display[1] = (p / 100) % 10;
    display[2] = (p / 10) % 10;
    display[3] = (p / 1) % 10;
    lcd_bigchar(0, display[1]);
    lcd_bigchar(4, display[2]);
    LCD_dat(4);
    lcd_bigchar(9, display[3]);
    LCD_goto(14, 0); LCD_puts("HM");
    LCD_goto(14, 1); LCD_puts("%%");
  }
}
Exemplo n.º 15
0
//=============================================================================
void show_bigvolume(void)
{
  uint8_t display[2];
  uint8_t v = rda5807GetVolume();
  display[0] = (v / 10) % 10;
  display[1] = (v / 1) % 10;
  LCD_goto(0, 0); LCD_puts("VOLUME:");
  lcd_bigchar(8, display[0]);
  lcd_bigchar(12, display[1]);
}
Exemplo n.º 16
0
// proces zajistujici zpracovani prikazu od uzivatele
// Bezi v nekonecne smycce a testuje zda bylo stisknuto tlacitko.
// Pokud ano, provede prislusnou akci.
void prikazy(void * pvParameters)
{
	int n = 0;
	(void) pvParameters; /* parameter not used */

	while (1) {

		LCD_clear();
		LCD_puts("Na uctu:");
		sprintf(buff, "%d", BankaOperace(0));
		LCD_puts(buff);
		LCD_set_cursor(2, 1);
		LCD_puts("SW1=START");

		// cekani na tlacitko
		while (pinRead(SW1) != 0) {
			;
		}

		VkladBezi = 1;
		VyberBezi = 1;

		// Spustime procesy simulujici vklad a vyber...
		vTaskResume(TaskVklad);
		vTaskResume(TaskVyber);

		while (VkladBezi || VyberBezi) {
			;
		}

		// Po zastaveni procesu vkladu i vyberu pokracujeme zde..
		// a umoznime opakovat simulaci
		VypisVysledek();
		ZapisUcet(10000);   // nastavit konto na pocatecni castku
		nVyberu = 0;
		nVkladu = 0;
		// cekani na tlacitko
		while (pinRead(SW1) != 0) {
			;
		}
	}
}
Exemplo n.º 17
0
static void
write_card(int off, char *buf)
{
	LCD_command(1);
	LCD_puts(INSCAR, sizeof(INSCAR));
	DPRINTF(INSCAR);
	while (FIO0PIN & (1 << 21));

	buf[0] = off;
	escreve_i2c(0xa0, buf, 17);
}
Exemplo n.º 18
0
void main()
{
	init();
	unsigned char string;
	while(1)
	{
		string = TerimaChar();
		LCD_command(0x80);
		LCD_puts(string);
	}
}
Exemplo n.º 19
0
Arquivo: temp.c Projeto: altanis/AVR
void temp_show() {
    LCD_clear();
    LCD_puts("    SET TEMP    ");
    LCD_gotoxy(1, 2);

    LCD_puts("<");
    if (m_dayTemp != 0) {
        if (m_dayTemp >= 10) {
            LCD_putint(m_dayTemp, 10);
        } else {
            LCD_puts("0");
            LCD_putint(m_dayTemp, 10);
        }
    } else {
        LCD_puts("00");
    }

    LCD_puts(" / ");

    if (m_nightTemp != 0) {
        if (m_nightTemp >= 10) {
            LCD_putint(m_nightTemp, 10);
        } else {
            LCD_puts("0");
            LCD_putint(m_nightTemp, 10);
        }
    } else {
        LCD_puts("00");
    }

    LCD_puts(" +- ");

    if (m_offsetTemp != 0) {
        LCD_putint(m_offsetTemp, 10);
    } else {
        LCD_puts("0");
    }

    LCD_puts(" C>");
//	LCD_puts("<00 / 00 +- 0 C>");
}
Exemplo n.º 20
0
void print_at(uint8_t x, uint8_t y, uint8_t channel){
	char buff[17];
	buff[16]=0;

	uint64_t threshold=1000000ULL; //1s

	LCD_goto(x,y);
	LCD_putc(time_us()-last_updated_at[channel]<threshold ? 'v' : 'x');
	LCD_puts(itoa((int)channels[channel],buff,10));
	LCD_putc(' ');
	LCD_putc(' ');
}
Exemplo n.º 21
0
void vLCDTask( void *pvParameters )
{
xLCDMessage xMessage;

	/* Initialise the LCD and display a startup message. */
	LCD_init();
	LCD_cur_off();
    LCD_cls();
    LCD_gotoxy( 1, 1 );
    LCD_puts( ( signed char * ) "www.FreeRTOS.org" );

	for( ;; )
	{
		/* Wait for a message to arrive that requires displaying. */
		while( xQueueReceive( xLCDQueue, &xMessage, portMAX_DELAY ) != pdPASS );

		/* Display the message.  Print each message to a different position. */
		LCD_cls();
		LCD_gotoxy( ( xMessage.xColumn & 0x07 ) + 1, ( xMessage.xColumn & 0x01 ) + 1 );
		LCD_puts( xMessage.pcMessage );
	}

}
Exemplo n.º 22
0
void DisplayTMR4() {
echo_time4=TMR4;
uchar str1[10];
int i=0;
int p=1;
for (i=0;i<9;i++) 
{
int temp=echo_time4/10;
int digit=echo_time4-temp*10;
str1[8-i]=digit+48;
echo_time4-=digit;
echo_time4/=10;
}
str1[9]=NULL;
LCD_goto(0x40);
LCD_puts(str1);
}
Exemplo n.º 23
0
Arquivo: main.c Projeto: Bst666/MyUsb
int main (void)
{
    //-- initialize the LPC-Stick, enable UART0, UART2 and CAN
    //--
    BaseStickConfig();

    printf("Hallo TI_Labor\n");

#ifdef LCD_SUPPORT
    LCD_puts ( "Hallo TI_Labor" );
#endif

    //-- your code goes here
    //--

    while (1)
    {
        menue();
    }
}
Exemplo n.º 24
0
void vyber( void * pvParameters )
{
	(void) pvParameters; /* parameter not used */
	for ( ;; ) {

		LCD_clear();
		LCD_puts("VYBER: 500");
		BankaOperace(-500);

		nVyberu++;
		// Po 5-ti probìhnutích se ukonèíme
		if (nVyberu >= 5) {
			VkladBezi = 0;
			vTaskSuspend(TaskVyber);
		}

		// Akce se provadi kazdych 900 ms
		vTaskDelay(900 / portTICK_RATE_MS);
	}

}
Exemplo n.º 25
0
//=============================================================================
void lcd_edit_date(void)
{
  LCD_goto(0, 0);
  LCD_puts(optionmenu[o_menu]);
  if (n_edit_date == 0)
  {
    LCD_goto(9, 0);
    LCD_puts(" [DAY]");
    LCD_goto(0, 1);
	if (blinks == 1) print_dec(day, 2, '0'); else { LCD_dat(' '); LCD_dat(' '); }
    LCD_dat('-');
    print_dec(mes, 2, '0');
    LCD_dat('-');
    print_dec(2000 + year, 4, '0');
    LCD_dat(' '); LCD_dat('['); LCD_puts(den_dw[wday]); LCD_dat(']');
  } else if (n_edit_date == 1) {
    LCD_goto(9, 0);
    LCD_puts(" [MES] ");
    LCD_goto(0, 1);
    print_dec(day, 2, '0');
    LCD_dat('-');
	if (blinks == 1) print_dec(mes, 2, '0'); else { LCD_dat(' '); LCD_dat(' '); }
    LCD_dat('-');
    print_dec(2000 + year, 4, '0');
    LCD_dat(' '); LCD_dat('['); LCD_puts(den_dw[wday]); LCD_dat(']');
  } else if (n_edit_date == 2) {
    LCD_goto(9, 0);
    LCD_puts(" [YEAH]");
    LCD_goto(0, 1);
    print_dec(day, 2, '0');
    LCD_dat('-');
    print_dec(mes, 2, '0');
    LCD_dat('-');
	if (blinks == 1) { print_dec(2000 + year, 4, '0'); } else { LCD_puts("    "); }
    LCD_dat(' '); LCD_dat('['); LCD_puts(den_dw[wday]); LCD_dat(']');
  }
}
Exemplo n.º 26
0
/* Toto je uloha (task, proces) s nazvem TaskReader (funkce TaskReader)
 Simuluje zpracovani namerenych dat z ulohy TaskWriter
*/
void vklad( void * pvParameters )
{
	(void) pvParameters; /* parameter not used */
	for ( ;; ) {

		LCD_clear();
		LCD_puts("VKLAD: 1000");
		BankaOperace(+1000);

		// Po 5-ti probìhnutích se ukonèíme
		nVkladu++;
		if ( nVkladu >= 5 )
		{
			VyberBezi = 0;
			vTaskSuspend(TaskVklad);
		}

		// Akce se provadi kazdych 600 ms
		vTaskDelay(800 / portTICK_RATE_MS);
	}

}
Exemplo n.º 27
0
/*****************************************************************************
*
*   Function name : vCard
*
*   Returns :       char ST_state (to the state-machine)
*
*   Parameters :    char input (from joystick)
*
*   Purpose :       Puts the name in EEPROM on the LCD
*
*****************************************************************************/
char vCard(char input)
{
    static char enter = 1;

    if (enter)
    {
        enter = 0;

        __EEGET(index, EEPROM_START);           // Load the length if the name
        
        if((index < 1) | (index > STRLENGHT))   // if illegal length     
        {
            index = 0;
            Name[0] = 'A';
            
            enter = 1;
            return ST_VCARD_ENTER_NAME;               //enter new name
        }
        else
        {
            LoadEEPROM(Name, index, EEPROM_START + 1);  // Load name 
            LCD_puts(Name, 1);
        }
    }

    else if (input == KEY_NEXT)
    {
        enter = 1;
        return ST_VCARD_ENTER_NAME;
    }
    else if (input == KEY_PREV)
    {
        enter = 1;
        return ST_VCARD;
    }
    
    return ST_VCARD_FUNC;
}
Exemplo n.º 28
0
static void
read_card(int off, char *buf)
{
	LCD_command(1);
	LCD_puts(INSCAR, sizeof(INSCAR));
	DPRINTF(INSCAR);
	while (FIO0PIN & (1 << 21));

	DPRINTF("AQUI1\n");
	/* Depois de qualquer operacao efetua uma leitura */
	buf[0] = off;
	/* Escreve o offset (endereco no smcard) */
	escreve_i2c(0xa0, buf, 1);
	DPRINTF("AQUI2\n");

	/* Le 16 bytes a partir do offset */
	le_i2c(0xa0, buf, 16);
	buf[16] = '\0';
	DPRINTF("AQUI3\n");
	
	for (x = 0; x < 16; x++)
		PrByte(buf[x]);
}
Exemplo n.º 29
0
void drawTest(int type){
  uint8_t i,j;
  
  uint8_t menuStrings[5][8] = {"Menu1\0","Menu2\0","Menu3\0","Menu4\0","Menu5\0"};
  
  switch (type){

  case 0: //simple text on screen
    LCD_clr();
    LCD_setCursorXY(15,0);
    LCD_puts ((uint8_t*)"Hello AVR world!\0");
    LCD_putsp((uint8_t*)"This LCD uses KS0107\0",3,3);
    LCD_putsp((uint8_t*)"Too long paged text is wrapped automatically\0",5,3);
    wait_100x_ms(30);
    break;

  case 1: //some of the drawing functions
    LCD_clr();
    LCD_drawLine(0,0,127,63);
    LCD_drawLine(0,63,127,0);
    LCD_drawRect(10,10,117,53);
    LCD_fillCirc(63,31,15);
    wait_100x_ms(20);

    break;

  case 2: //write on screen byte by byte
     for(j=0;j<8;j++){
	LCD_setCursorXY(0,j*8);
	for(i=0;i<LCD_LINE_LENGTH/4;i++){	  
	  LCD_writeByte(0b00110011);
	  LCD_writeByte(0b00110011);
	  LCD_writeByte(0b11001100);
	  LCD_writeByte(0b11001100);
	}
     }
    wait_100x_ms(20);
    break;

  case 3: //scrolling text up->down
    LCD_clr();
    LCD_setCursorXY(0,0);
    LCD_puts((uint8_t*)"Scrolling text\n goes here..!\0");      
    i=63;
    j=110;
    while(j>0){
      _delay_ms(30);      
      LCD_selectLeftChip();
      LCD_setInitialLineAddress(i);
      LCD_selectRightChip();
      LCD_setInitialLineAddress(i);
      if (i==0) i=63;
      else i--;
      j--;
    }
    LCD_clr();
    LCD_selectLeftChip();
    LCD_setInitialLineAddress(0);
    LCD_selectRightChip();
    LCD_setInitialLineAddress(0);
    break;

  case 4:  //using invert for menus
    
    for(i=0;i<5;i++){
      LCD_putsp(menuStrings[i],i+1,25);
    }
    j=2;
    while(j--){
      LCD_invertPage(1,20,58);
      wait_100x_ms(3);
      for(i=0;i<5;i++){      
	wait_100x_ms(3);
	LCD_invertPage(i+1,20,58);
	if(i<4)
	  LCD_invertPage(i+2,20,58);
	wait_100x_ms(3);
      }
    }
    break;

  case 5: //read status (on /off)
    j=4;
    while(j--){
      LCD_clr();
      if(!LCD_isOff()){
	LCD_putsp((uint8_t*)"LCD is On\0",1,10);
	wait_100x_ms(5);
	LCD_off();
      }
      else {
	wait_100x_ms(5);
	LCD_on();
	LCD_putsp((uint8_t*)"LCD was Off\0",1,10);
	wait_100x_ms(5);
      }
    }
    break;

  case 6: //"progress bar"
    LCD_clr();
    LCD_drawRect(5,5,122,58);
    LCD_putsp((uint8_t*)"Prosessing...\0",2,16);
    LCD_drawRect(10,30,113,41);

    for(j=0;j<100;j++){     
      LCD_setCursorXY(12+j,32);
      LCD_writeByte(0xff);
      wait_100x_ms(1); 
    }
    LCD_putsp((uint8_t*)"Done!        \0",2,16);
    wait_100x_ms(10);
    break;

  case 7:
    LCD_clr();
    LCD_drawFullBMP(girl_1_glcd_bmp);
    wait_100x_ms(20);
    break;

  case 8:
    i=0b10101010;
    LCD_clr();
    LCD_drawBMP((uint8_t*)atmel_glcd_bmp, 12, 12, 
		  ATMEL_GLCD_WIDTH,ATMEL_GLCD_HEIGHT);

    wait_100x_ms(20);
    break;

  case 9:
    LCD_clr();
    
    LCD_putgstr((uint8_t*)"Corsiva 12 test", Corsiva_12,10,10);
    LCD_putgstr((uint8_t*)"qwertyhjkl12345", Corsiva_12,12,30);
    
    //    LCD_putgstr((uint8_t*)"putgstr() test",Arial_Bold_14,10,10);
    //LCD_putgstr((uint8_t*)"1q2w3e4r5t6y8u9i0l",Arial_Bold_14,10,30);

    wait_100x_ms(20);
  }
}
Exemplo n.º 30
0
Arquivo: temp.c Projeto: altanis/AVR
void set_temp_init(void) {
    u16 value;
    u08 step = 0, empty, tmp[2];
    u08 day[3], month[3], year[5];
    u08 temp1[3], temp2[3];
    u08 skipLoop = 0;

    LCD_write_command(0x0f);
    waitms(20);
    do {
        empty = 0;
        LCD_gotoxy((2 + step), 2);
        value = decode_rc5();
        switch (value) {
            case KEY_0: {
                LCD_puts("0");
                strcpy(tmp, "0");
                break;
            }

            case KEY_1: {
                LCD_puts("1");
                strcpy(tmp, "1");
                break;
            }

            case KEY_2: {
                LCD_puts("2");
                strcpy(tmp, "2");
                break;
            }

            case KEY_3: {
                LCD_puts("3");
                strcpy(tmp, "3");
                break;
            }
            case KEY_4: {
                LCD_puts("4");
                strcpy(tmp, "4");
                break;
            }
            case KEY_5: {
                LCD_puts("5");
                strcpy(tmp, "5");
                break;
            }

            case KEY_6: {
                LCD_puts("6");
                strcpy(tmp, "6");
                break;
            }

            case KEY_7: {
                LCD_puts("7");
                strcpy(tmp, "7");
                break;
            }

            case KEY_8: {
                LCD_puts("8");
                strcpy(tmp, "8");
                break;
            }

            case KEY_9: {
                LCD_puts("9");
                strcpy(tmp, "9");
                break;
            }

            case KEY_LEFT: {
                if (step == 5) {
                    step -= 4;
                } else if (step == 11) {
                    step -= 5;
                } else {
                    step--;
                }
                skipLoop = 1;
                break;
            }

            case KEY_RIGHT: {
                empty = 1;
                break;
            }

            default: {
                step--;
                empty = 1;
                break;
            }
        }

        if(skipLoop) {
            skipLoop = 0;
            continue;
        }

        if (!empty) {
            switch (step) {

                case 0:
                    strcpy(temp1, tmp);
                    break;
                case 1:
                    strcat(temp1, tmp);
                    break;

                case 5:
                    strcpy(temp2, tmp);
                    break;
                case 6:
                    strcat(temp2, tmp);
                    break;
                default:
                    break;
            }
        }
        step++;
        if (step == 2)
            step += 3;
        if (step == 7)
            step += 4;
    } while (step <= 11);
    LCD_write_command(0x0C);

    if (m_dayTemp >= 0 && m_nightTemp >= 0) {
        m_requiresSettings |= SETTING_TEMP;
    }

    m_dayTemp = (atoi(temp1) % 90);
    m_nightTemp = (atoi(temp2) % 90);
    m_offsetTemp = (atoi(tmp) % 90);
}