Esempio n. 1
0
uint8_t menu_edit_month(uint8_t m) {
  for (;;) {
    lcd_locate(3, 0);
    menu_print_month(m);
    lcd_locate(3, 0);
    set_busy_led(true);
    lcd_cursor(true);
    for (;;) {
      if (get_key_autorepeat(KEY_PREV)) {
        if (m == 0) m = 11;
        else --m;
        break;
      }
      if (get_key_autorepeat(KEY_NEXT)) {
        if (m == 11) m = 0;
        else ++m;
        break;
      }
      if (get_key_press(KEY_SEL)) {
        set_busy_led(false);
        lcd_cursor(false);
        return m;
      }
    }
  }
}
Esempio n. 2
0
void lcd_draw_screen(uint16_t screen) {
  extern const char PROGMEM versionstr[];

  lcd_current_screen = screen;
  lcd_clear();

  switch (screen) {
  case SCRN_SPLASH:
    lcd_puts_P(versionstr);
    lcd_locate(0,3); lcd_puts_P(PSTR(HWNAME));
    // TODO: if available, print serial number here
    break;

  case SCRN_STATUS:
    lcd_locate(16, 0);
    if (active_bus == IEC)     lcd_puts_P(PSTR(" IEC"));
    if (active_bus == IEEE488) lcd_puts_P(PSTR("IEEE"));
    lcd_update_device_addr();
    lcd_update_disk_status();
    break;

  default:
    break;
  }
}
Esempio n. 3
0
uint8_t menu_edit_value(uint8_t v, uint8_t min, uint8_t max) {
  uint8_t x = lcd_x;
  uint8_t y = lcd_y;

  lcd_locate(x, y);
  lcd_cursor(true);
  set_busy_led(true);
  for (;;) {
    lcd_printf("%02d", v);
    lcd_locate(x, y);
    for (;;) {
      if (get_key_autorepeat(KEY_PREV)) {
        if (v <= min) v = max;
        else --v;
        break;
      }
      if (get_key_autorepeat(KEY_NEXT)) {
        if (v >= max) v = min;
        else ++v;
        break;
      }
      if (get_key_press(KEY_SEL)) {
        lcd_cursor(false);
        set_busy_led(false);
        return v;
      }
    }
  }
}
Esempio n. 4
0
void main(){
	//Init LCD
	__C30_UART=1;	
	lcd_initialize();
	lcd_clear();
        touch_init();

        CLEARBIT(T1CONbits.TON); // Disable Timer
        CLEARBIT(T1CONbits.TCS); // Select internal instruction cycle clock
        CLEARBIT(T1CONbits.TGATE); // Disable Gated Timer mode
        TMR1 = 0x00; // Clear timer register
        T1CONbits.TCKPS = 0b10; // Select 1:64 Prescaler
        PR1 = 2000; // Load the period value
        IPC0bits.T1IP = 0x01; // Set Timer1 Interrupt Priority Level
        CLEARBIT(IFS0bits.T1IF); // Clear Timer1 Interrupt Flag
        SETBIT(IEC0bits.T1IE); // Enable Timer1 interrupt



        while(1) {
            int i = 0;

            
            
            touch_select_dim(0);
            lock = 1;
            TMR1 = 0x00;
            SETBIT(T1CONbits.TON); // Start Timer
            while(lock);
            
            for (i = 0; i < 5; i++) {
                xs[i] = touch_adc();
            }

            // read y
            touch_select_dim(1);
            lock = 1;
            TMR1 = 0x00;
            SETBIT(T1CONbits.TON); // Start Timer
            while(lock);
            for (i = 0; i < 5; i++) {
                ys[i] = touch_adc();
            }

            

            qsort(xs, 5, sizeof(uint16_t), cmpfunc);
            qsort(ys, 5, sizeof(uint16_t), cmpfunc);

            lcd_locate(0,0);
            lcd_printf("x position:             ");
            lcd_locate(0,0);
            lcd_printf("x position: %d", xs[2]);
            lcd_locate(0,1);
            lcd_printf("y position:             ");
            lcd_locate(0,1);
            lcd_printf("y position: %d", ys[2]);
        }
}
Esempio n. 5
0
File: main.c Progetto: lysy1033/sfp
void lcd_start_screen()
{
	lcd_cls();
	lcd_locate(0,0);
	lcd_str(" SFP PROGRAMMER ");
	lcd_locate(1,0);
	lcd_str(" ALPHA 0.1 2014 ");
}
Esempio n. 6
0
void StatusMode_print(char *str){
    int i;
    lcd_locate(0, WindowHeight - 1);
    for(i=0;i<WindowWidth;i++)
        lcd_puts(" ");
    lcd_locate(0, WindowHeight - 1);
    lcd_puts(str);
}
Esempio n. 7
0
static void draw_stats(void)
{
	lcd_locate(0, 0);
	lcd_put5digit(g_level);
	lcd_locate(28, 0);
	lcd_put5digit(g_hp);
	/*lcd_locate(59, 0);
	lcd_put5digit(g_seed);*/
}
Esempio n. 8
0
void DisplayRefresh(uint8_t Refresh) {
	if ( (Refresh == 1) && (_FLAG.LCDExist == _Set) ) {

		lcd_locate(0,0);
		lcd_str(FirstLine);

		//lcd_locate(1,0);
		lcd_locate( 1, (8-(length(SecondLine)/2)) );
		lcd_str(SecondLine);
	}
}
void M1_func_ustawienia(char *str)
{
	if(Flagi.flaga_lcd)
	{
		lcd_locate(0, 0);
		lcd_str(str);
		EI2C_read_buf(ADDR_EEMEM_24C64, offsetof(EXT_EEPROM_var, empty), SIZEOF (EXT_EEPROM_var, empty), (uint8_t *)str);
		lcd_locate(1, 0);
		lcd_str(str);
		Flagi.flaga_lcd=0;
	}
}
void motor_set_duty(uint8_t chan, double duty){

    if (chan == 0){ // x
        lcd_locate(0,5);
        lcd_printf("x wid: %0.2f", duty);//_us);
        //lcd_printf("x wid: %3d", (uint16_t)duty_ms*200.0);//_us);
        OC8RS = (20.0-duty)*200.0; /* Load OCRS: next pwm duty cycle */
    }else{
        lcd_locate(0,6);
        lcd_printf("y wid: %0.2f", duty);//_us);
        //lcd_printf("y wid: %3d", (uint16_t)duty_ms*200.0);//_us);
        OC7RS = (20.0-duty)*200.0; /* Load OCRS: next pwm duty cycle */
    }
}
Esempio n. 11
0
static void draw_game(void)
{
#if SDL
	SDL_Rect r;
	r.x = r.y = 0;
	r.w = screen->w;
	r.h = screen->h;
	uint32_t c = SDL_MapRGB(screen->format, 128, 255, 128);
	SDL_FillRect(screen, &r, c);
#endif

	uint8_t i=0;
	for(uint8_t y=0; y<MAP_H; y++){
		lcd_locate(2, y+1);
		for(uint8_t x=0; x<MAP_W; x++){
			if(get_pos(x, y) == g_player_position_i){
				lcd_print_sprite(12);
			} else {
				uint8_t t = g_map[i];
				lcd_print_sprite(t);
			}
			i++;
		}
	}
	draw_stats();

#if SDL
	SDL_Flip(screen);
#endif
}
void lcd_cursor (
	uint8_t stat	/* 0:off, 1:blinking block, 2:under-line */
)
{
	Csr = stat & 3;
	lcd_locate(Row, Column);
}
Esempio n. 13
0
int Cursor_move_left(Cursor *cur){
    int ret;
    if(cur->absolute.x == 0){
        ret = Cursor_move_previous_line(cur);
        if(ret) return 1;

        Cursor_move_pos(cur, cur->str->num);
    }else{
        cur->absolute.x--;
    }

    cur->relative.x--;
    if(cur->relative.x < 0){
        cur->relative.x = cur->absolute.x % WindowWidth;
        cur->relative.y--;
        if(cur->relative.y < 0){
            cur->relative.y = 0;
            lcd_vscroll(-1, 1);
            lcd_locate(0,0);
            String_print_line(cur->str, cur->absolute.x / WindowWidth);
        }
    }

    return 0;
}
Esempio n. 14
0
int Cursor_move_right(Cursor *cur){
    int ret;
    if(cur->absolute.x >= cur->str->num){
        ret = Cursor_move_next_line(cur);
        if(ret) return 1;
        
        Cursor_move_pos(cur, 0);
    }else{
        cur->absolute.x++;
    }

    cur->relative.x++;
    if(cur->relative.x == WindowWidth || cur->absolute.x == 0){
        cur->relative.x = cur->absolute.x % WindowWidth;
        cur->relative.y++;
        if(cur->relative.y == WindowHeight){
            cur->relative.y = WindowHeight - 1;
            lcd_vscroll(1, 1);
            lcd_locate(0, WindowHeight - 1);
            String_print_line(cur->str, cur->absolute.x / WindowWidth);
        }
    }

    return 0;
}
Esempio n. 15
0
/*ISR(ADC_vect)
{
	if(i%5==0)
	{
		PORTB^=(1<<PB1);
		wynik=(ADCH<<8)|ADCL;
		i=0;
	}


	i++;
	ADCSRA |= 1<<ADSC;
	//ADCSRA&=~(1<<ADIF);
}
*/
int main()
{
	DDRC&=~(1<<PC5); //Input
	DDRB |=(1<<PB1);
	lcd_init();
	/*TCNT0=0;
	TCCR0A |= (1<<WGM01);
	TCCR0B |= (1<<CS02);		//preskaler = 256
	OCR0A = 10;*/						//podzial przez 10

	/*ADMUX |= (1<<REFS1)|(1<<REFS0)|(1<<MUX2)|(1<<MUX0); //1,1V REF || Chan ADC5
	ADCSRB|=(1<<ADTS1)|(1<<ADTS0); //Trigger: Timer0 CpMA
	ADCSRA |= (1<<ADEN)|(1<<ADATE)|(1<<ADIE)|(1<<ADPS2)|(1<<ADPS1)|(1<<ADPS0); //ADC Enable | Start Conv ||| Prescaler 128
	*/
	//ADMUX |= (1<<REFS1)|(1<<REFS0)|(1<<MUX2)|(1<<MUX0); //1,1V REF || Chan ADC5
	//ADCSRA |= (1<<ADEN)|(1<<ADIE)|(1<<ADPS2)|(1<<ADPS1)|(1<<ADPS0); //ADC Enable | Start Conv ||| Prescaler 128
	//ADCSRA |= 1<<ADSC; //ADC On

	ADMUX |=(3<<6)|(5<<0);
	ADCSRA |=(1<<7)|(6<<0);
	ADCSRA |= 1<<ADSC; //Start Meas

	//sei();
	while(1)
	{
		while(ADCSRA &(1<<ADSC));
		wynik=(ADCH<<8)|ADCL;
		lcd_locate(0,0);
		lcd_int(wynik);
		_delay_ms(500);
		ADCSRA |= 1<<ADSC; //Start Meas
	}

}
Esempio n. 16
0
int emin_backspace(){
    if( cursor.absolute.x == 0 && cursor.absolute.y == 0) return 1;
    int i;
    int current_line;
    int ret;

    if( cursor.absolute.x > 0 ){
        String_delete_pos(cursor.str, cursor.absolute.x - 1);

        if( ((cursor.str->num + 1) % WindowWidth) == 0 ){
            View_redraw(&cursor);
        }
        Cursor_move_left(&cursor);
        current_line = cursor.absolute.x / WindowWidth;

        for(i=0; i < cursor.str->line_num - current_line; i++){
            lcd_locate(0, cursor.relative.y + i);
            String_print_line(cursor.str, i + current_line);
        }
    }else{
        Cursor_move_left(&cursor);
        ret = String_merge(cursor.str, cursor.str->next);
        if(ret){
            Cursor_move_right(&cursor);
            return 1;
        }
        View_redraw(&cursor);
    }

    return 0;
}
Esempio n. 17
0
// Display
void DisplayItemInfo(void){
    int k=0;
    for(k=0;k<Ndata;k++){
        lcd_locate(k,0);
        lcd_set_str((unsigned char*)RxName[t_id[k]]);
    }
    
}
Esempio n. 18
0
void Cursor_off(Cursor *cur){
    char c = cur->str->string[cur->absolute.x];

    lcd_locate(cur->relative.x, cur->relative.y);
    lcd_setcolor(COL_WHITE);
    if(c == 0) c = ' ';
    lcd_printf("%c", c);
}
Esempio n. 19
0
void StatusMode_out(){
    lcd_setforeground(COL_WHITE);
    lcd_setbackground(COL_BLACK);

    lcd_locate(status_x, status_y);
    lcd_setshowpage(2);
    lcd_setdrawpage(2);
}
Esempio n. 20
0
void menu_adjust_brightness(void) {
  uint8_t i;
  uint8_t min = 0;
  uint8_t max = 255;
  uint8_t res;
  uint8_t step;

  lcd_clear();
  lcd_puts_P(PSTR("Adjust brightness"));
  lcd_locate(0, 1);

  lcd_cursor(false);
  set_busy_led(true);
  for (;;) {
    lcd_locate(0, 1);
    lcd_putc('[');
    for (i = 0; i < 18; i++) {
      lcd_putc(i >= (lcd_brightness / 14) ? ' ' : 0xFF);
    }
    lcd_putc(']');
    res = lcd_set_brightness(lcd_brightness);
    if (res) break;
    for (;;) {
      step = 10;
      if (lcd_brightness < 20 || lcd_brightness > 235) step = 1;
      if (get_key_autorepeat(KEY_PREV)) {
        if (lcd_brightness <= min) lcd_brightness = max;
        else lcd_brightness -= step;
        break;
      }
      if (get_key_autorepeat(KEY_NEXT)) {
        if (lcd_brightness >= max) lcd_brightness = min;
        else lcd_brightness += step;
        break;
      }
      if (get_key_press(KEY_SEL)) {
        lcd_cursor(false);
        set_busy_led(false);
        menu_ask_store_settings();
        return;
      }
    }
  }
  pwm_error();
}
int main (void)
{
	board_init();
	
	// Insert application code here, after the board has been initialized.
	lcd_init();
	lcd_cls();
	lcd_locate(0,0);
	lcd_set_font(Lcd_Font_5x7);
	lcd_write_s(c_GreetingMsg);

	/* Initialize the PWM driver and set proper frequency */
	pwm_init();
	pwm_set_duty(0);
	pwm_set_frequency(Pwm_31250Hz);

	/* Initialize the encoder and register a callback function */
	encoder_init();
	encoder_register_event(OnEncoderEvent);
	
	while(1)
	{
		encoder_cyclic();
		
		switch(CurrentState)
		{
			case State_Info:
			//				info_cyclic(&CurrentEventMask);
			CurrentState = State_MainMenu;
			break;
			
			case State_MainMenu:
			CurrentState = main_menu_cyclic(MainMessagePump);
			break;
			
			case State_Reflow:
			//				refow_cyclic();
			CurrentState = State_MainMenu;
			break;
			
			case State_Learn:
			//				learn_cyclic();
			CurrentState = State_MainMenu;
			break;
			
			case State_Parameterize:
			//				parameterize_cyclic();
			CurrentState = State_MainMenu;
			break;
			
			default:
			CurrentState = State_MainMenu;
			break;
		}
	}
}
/* wyœwietlanie temperatury na pozycji X w pierwszej linii LCD */
void display_temp(uint8_t x) {
	lcd_locate(0,x);
	if(subzero) lcd_str("-");	/* jeœli subzero==1 wyœwietla znak minus (temp. ujemna) */
	else lcd_str(" ");	/* jeœli subzero==0 wyœwietl spacjê zamiast znaku minus (temp. dodatnia) */
	lcd_int(cel);	/* wyœwietl dziesiêtne czêœci temperatury  */
	lcd_str(".");	/* wyœwietl kropkê */
	lcd_int(cel_fract_bits); /* wyœwietl dziesiêtne czêœci stopnia */
	lcd_str(" C"); /* wyœwietl znak jednostek (C - stopnie Celsiusza) */
	lcd_char(0xDF);
}
Esempio n. 23
0
void menu_adjust_contrast(void) {
  uint8_t i;
  uint8_t min = 0;
  uint8_t max = LCD_COLS - 2;
  uint8_t res;

  lcd_clear();
  lcd_puts_P(PSTR("Adjust LCD contrast"));
  lcd_locate(0, 1);

  lcd_cursor(false);
  set_busy_led(true);
  for (;;) {
    lcd_locate(0, 1);
    lcd_putc('[');
    for (i = 0; i < LCD_COLS - 2; i++) {
      lcd_putc(i >= lcd_contrast ? ' ' : 0xFF);
    }
    lcd_putc(']');
    res = lcd_set_contrast(lcd_contrast);
    if (res) break;
    for (;;) {
      if (get_key_autorepeat(KEY_PREV)) {
        if (lcd_contrast <= min) lcd_contrast = max;
        else --lcd_contrast;
        break;
      }
      if (get_key_autorepeat(KEY_NEXT)) {
        if (lcd_contrast >= max) lcd_contrast = min;
        else ++lcd_contrast;
        break;
      }
      if (get_key_press(KEY_SEL)) {
        lcd_cursor(false);
        set_busy_led(false);
        menu_ask_store_settings();
        return;
      }
    }
  }
  pwm_error();
}
void lcd_putc (
	uint8_t chr
)
{
	if (chr == '\f') {		/* Clear Screen and Return Home */
		lcd_write(0, 0x01);
		DELAY_US(LCD_DT1);
		lcd_locate(0, 0);
		return;
	}

	if (Row >= _LCD_ROWS) return;

	if (chr == '\r') {	/* Cursor return */
		lcd_locate(Row, 0);
		return;
	}
	if (chr == '\n') {	/* Next row */
		lcd_locate(Row + 1, 0);
		return;
	}
	if (chr == '\b') {	/* Cursor back */
		if (Column)
			lcd_locate(Row, Column - 1);
		return;
	}

	if (Column >= _LCD_COLS) return;

	lcd_write((LCD_IF_DUAL && Row >= 2) ? 3 : 5, chr);
	Column++;

	if (LCD_IF_SPLIT && Column == _LCD_COLS / 2)
		lcd_write(0, 0x40);

	if (Column >= _LCD_COLS)
		lcd_locate(Row + 1, 0);
}
void lcd_setcg (
	uint8_t chr,		/* Character code to be registered (0..7) */
	uint8_t n,			/* Number of characters to register */
	const uint8_t* p	/* Pointer to the character pattern (8 * n bytes) */
)
{
	lcd_write(0, 0x40 | chr * 8);
	n *= 8;
	do
		lcd_write(1, *p++);
	while (--n);

	lcd_locate(Row, Column);
}
Esempio n. 26
0
int main(void)
{
	lcd_init();
	init_adc();
	while(1)
	{
		if(czujnik_dymu_ON)
		{
			lcd_locate(0,0);
			lcd_str("WYKRYTO DYM");
		}
		else
		{
			lcd_locate(0,0);
			lcd_str("BRAK DYMU  ");
		}
		wartosc_pomiaru = pomiar(czujnik_dymu_ktory);
		lcd_locate(1,0);
		lcd_int(wartosc_pomiaru);
		lcd_str("   ");
		_delay_ms(500);
	}
}
Esempio n. 27
0
void StatusMode_in(){
    int i;
    lcd_copypage(2, 1);
    lcd_setshowpage(1);
    lcd_setdrawpage(1);
    status_x = lcd_getcurx();
    status_y = lcd_getcury();
    lcd_setforeground(COL_BLACK);
    lcd_setbackground(COL_WHITE);

    lcd_locate(0, WindowHeight - 1);
    for(i=0;i<WindowWidth;i++)
        lcd_puts(" ");
}
Esempio n. 28
0
File: main.c Progetto: lysy1033/sfp
int main(void) {


	// LCD INIT
	lcd_init();
	lcd_start_screen();

	_delay_ms(500);

	while(1)
	{
		lcd_backlight(1);
		//sfp_read_vendor_name(sfp_vendor_name);
		EI2C_read_buf(0xa0,0x14,15,sfp_vendor_name);
		EI2C_read_buf(0xa0,56,4,sfp_vendor_rev);
		lcd_cls();
		lcd_locate(0,0);
		lcd_str((char*)sfp_vendor_name);
		lcd_locate(1,0);
		lcd_str((char*)sfp_vendor_rev);
		_delay_ms(1000);

	}
}
Esempio n. 29
0
void lcd_update_disk_status(void) {
  bool visible = true;

  if (lcd_current_screen == SCRN_STATUS) {
    lcd_locate(0, 1);
    lcd_puts_P(PSTR("Status: "));
    for (uint8_t i = 0;
         i < min(CONFIG_ERROR_BUFFER_SIZE, LCD_COLS * (LCD_LINES > 3 ? 3:
             1) - 8);
         i++)
    {
      if (error_buffer[i] == 13) visible = false;
      lcd_putc(visible ? error_buffer[i] : ' ');
    }
  }
}
Esempio n. 30
0
void init(char *name){

    WindowWidth = lcd_getwidth()/8;
    WindowHeight = lcd_getheight()/16;

    cursor.relative.x = 0;
    cursor.relative.y = 0;
    cursor.absolute.x = 0;
    cursor.absolute.y = 0;

    File_open(name);
    cursor.str = head;

    View_redraw(&cursor);
    lcd_locate(0, 0);
}