Esempio n. 1
0
int main(void)
{
	lcd_backlight(0);
	lcd_init();
	lcd_rect(0, 0, LCD_WIDTH, LCD_HEIGHT, COLOR_BLACK);
	lcd_backlight(1);

	while(1)
	{
		switch(DEMO_MODE())
		{
		case DEMO_COLORBAR:
			demo_colorbar();
			break;
		case DEMO_BOARDNAME:
			demo_boardname();
			break;
		case DEMO_SHOWINPUTS:
			demo_showinputs();
			break;
		case DEMO_MANDELBROT:
			demo_mandelbrot();
			break;
		default:
			lcd_rect(0, 0, LCD_WIDTH, LCD_HEIGHT, COLOR_BLACK);
			lcd_puts("NOT IMPLEMENTED. CHANGE DIP-SW!", 10, 10, COLOR_WHITE, COLOR_RED);
			while(DEMO_MODE() >= DEMO_MAXNUMBER);
			break;
		}
	}

	while(1);
}
Esempio n. 2
0
int main()
{
	lcd_init(LCD_DISP_ON_CURSOR_BLINK);	
	lcd_backlight(1);
	lcd_puts("this is a test message\nHow are you");	
	lcd_backlight(1);
	return 0;
}
Esempio n. 3
0
int main(){
	printf("Get display\n");

	display = get_display();

	if (display == NULL) {
		printf("Failed to get display\n");
		return -1;
	}

	//lcd_load_bmp("blani.bmp", display);
	lcd_load_bmp("blani.bmp", display);
	getc(stdin);
	lcd_set_bmp(0,0,display);
	getc(stdin);

	lcd_backlight(LCD_OFF, display);
	getc(stdin);
	lcd_backlight(LCD_ON, display);
	getc(stdin);
	lcd_sleep(LCD_ON, display);
	getc(stdin);
	lcd_sleep(LCD_OFF, display);
	getc(stdin);
	lcd_onoff(LCD_OFF, display);
	getc(stdin);
	lcd_onoff(LCD_ON, display);
	getc(stdin);

	printf("Lcd rect\n");
	lcd_set_rect(20, 20, 50, 50, NOFILL, WHITE, display);
	getc(stdin);
	lcd_set_rect(20, 60, 50, 90, NOFILL, RED, display);
	getc(stdin);
	lcd_set_rect(60, 20, 90, 50, NOFILL, BLUE, display);
	getc(stdin);
	lcd_set_rect(60, 60, 90, 90, NOFILL, ORANGE, display);
	getc(stdin);
//	printf("Lcd pixel\n");
//	lcd_set_pixel(100, 100, WHITE, display);

	lcd_set_line(2,0, 20, 78, RED, display);
	getc(stdin);
	lcd_set_line(30,19, 98, 34, BLUE, display);
	getc(stdin);
	lcd_set_line(129,129, 20, 60, GREEN, display);
	getc(stdin);
	lcd_put_str("Test str 1\n", 10, 10, SMALL, YELLOW, display);
	getc(stdin);
	lcd_put_str("Test str 2\n", 30, 10, MEDIUM, GREEN, display);
	getc(stdin);
	lcd_put_str("Test str 3\n", 50, 10, LARGE, ORANGE, display);
	getc(stdin);

	printf("Release display\n");
	release_display(display);
}
Esempio n. 4
0
void demo_backlight() {
	clear_screen();
	lcd_set_rect(0, 0, 129, 64, FILL, WHITE, display);

	if (get_key() == QUIT)
		return;

	lcd_backlight(LCD_OFF, display);

	if (get_key() == QUIT)
		return;

	lcd_backlight(LCD_ON, display);

	if (get_key() == QUIT)
		return;
}
Esempio n. 5
0
void reset_display (void)
{
	switch (ui_state)
	{
		case STATE_NORM:
			lcd_power(1);
			lcd_backlight(1);
			lcd_write_string_XY(0, 0, "    e.quinox    ");
			
			if(local_ee_data.full_unlock == EE_FULL_UNLOCK_CODE){
				lcd_write_string_XY(0, 1, "        Unlocked");
				lcd_batt_level( get_soc(), get_charging_rate() );
			}
			else{
				lcd_write_string_XY(0, 1, "            days");
				lcd_write_int_XY(10, 1, get_unlock_days() );
				lcd_batt_level( get_soc(), get_charging_rate() );
			}
			break;
		case STATE_AWAIT_PAYMENT:
			//lcd_power(1);
			//lcd_backlight(1);
			lcd_write_string_XY(0, 0, "Enter:__________");
			lcd_write_string_XY(0, 1, "          Locked");
			lcd_write_string_XY(6, 0, display_str);
			lcd_batt_level( get_soc(), get_charging_rate() );
			break;
		case STATE_LVDC:
			lcd_clear();
			lcd_write_string_XY(0, 0, "  Battery Low   ");
			//if( get_charging_rate() > 0)
			//{
				lcd_batt_level( get_soc(), get_charging_rate() );
			//}
			break;
		case STATE_SETUP:
			//display_str [0] = '\0';
			//utoa_b(display_str, local_ee_data.box_id, 10, digit_count);
			lcd_write_string_XY(0, 0, "Box ID:         ");
			lcd_write_string_XY(8, 0, display_str);
			lcd_write_string_XY(0, 1, "   Setup Mode   ");
			break;
		case STATE_OFF:
			lcd_clear();
			lcd_power(0);
			break;
		default:
			lcd_clear();
			break;
	}
}
Esempio n. 6
0
//initialize the display
void lcd_init()
{
  printf("initialize lcd...");

  i2c_enable();
  const char init_commands[] = {0x38, 0x39, 0x14, 0x74, 0x54, 0x6f, 0x0c, 0x01};
  i2c_transmitinit(LCD_ADDR,8,init_commands);
  wait_for_transfer();
  cursor = 0x0f;
  line = 0x00;
  
  // turn backlight on
  lcd_backlight(1);

  lcd_print("hello boss :)");
  lcd_set_cursor(1,0);
  lcd_print("contiki booted!");

  printf("[OK]\n\r");
}
Esempio n. 7
0
int main(void) {

 int test;
 unsigned char byte;
// PCF_ADRESS = 0;	// Adresse des PCF'S 
 
 printf("*** i²c-LCD Test (c) Ingo Gerlach 10/2000 *** \n");
 COM  = 0; 			// Vorbelegung Ser - Port, 0 Automatisch suchen
 set_port_delay(15);		// Portdelay 0-255 
 test = init_iic(COM);		// Init ii2c 
 printf("Suche i2c-Interface...");
 if (test) 
 {
  printf(" gefunden an Port 0x%03xh! \n",test);
 } else {
    printf("Interface nicht gefunden.\n");
    exit (0);
  }
/*
 set_strobe(1);			// Für den Seriellen Port nur dummy
 io_disable(0);
*/
 sda_high();
 scl_high();
 printf("read_sda %d \n",read_sda());
 printf("read_scl %d \n",read_scl());
 iic_start();
 byte =getchar();
 iic_stop();
 sda_low();
 scl_low();
 printf("read_sda %d \n",read_sda());
printf("read_scl %d \n",read_scl());    
lcd_backlight(0); 
byte = getchar();
 printf("deinit %d\n",deinit_iic()); 
 return 0;
}
Esempio n. 8
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. 9
0
/**
  * @brief  Task which handles all UI including keypad, LCD and all user power outputs.
	* 				Responds to events caused by other tasks and ISRs
  * @param  None
  * @retval Should never exit
  */
__task void ui (void)
{
	uint16_t event_flag = 0;
	uint8_t key;
	int i;
	uint64_t entry_code = 0;
	
	lcd_init();
	keypad_init();
	
	lcd_backlight(1);
	
	buzzer_init();
	
	pwr_sw_init();
	
	usb_outputs_init();
	dc_outputs_init();

	
	lcd_clear();
	lcd_write_string("    e.quinox    ");
	lcd_goto_XY(0,1);
	lcd_write_string("    izuba.box   ");
	

	//2 second timeout
	os_dly_wait(200);
	
	if ( get_unlock_days () >= 0 )
	{
		ui_state = STATE_NORM;
	}
	
	if( local_ee_data.lvdc_flag == 1 )
	{
		ui_state = STATE_LVDC;
	}
	
	reset_display();
	reset_outputs();
	
	while(1)
	{
		//Wait for any task event or timeout after 1 second
		if ( os_evt_wait_or(0xFFFF, 100) == OS_R_EVT )
		{
			//Find which event 
			event_flag = os_evt_get();
			
			if ( event_flag & UI_BOX_SETUP )
			{
				ui_state = STATE_SETUP;
				lcd_clear();
				reset_display();
				reset_outputs();
			}
			
			if ( (event_flag & UI_LVDC) )
			{
				if ( (ui_state != STATE_LVDC) && (ui_state != STATE_OFF) )
				{
					ui_state = STATE_LVDC;
					local_ee_data.lvdc_flag = 1;
					update_lvdc(1);
					//Turn off outputs
					reset_outputs();
					lcd_power(1);
					lcd_clear();
					lcd_write_string_XY(0, 0, "  Battery Empty ");
					lcd_write_string_XY(0, 1, "  Turning Off   ");

					//Delay and Buzz
					//20 Seconds
					for ( i = 0; i < 5; i++)
					{
						buzz(1);
						//4 second wait
						os_dly_wait(400);
					}
					
					//Turn off Screen
					lcd_power(0);
					
				}
				
			}
			
			if ( event_flag & UI_PWR_SW )
			{
				if ( ui_state != STATE_OFF)
				{
					//Turn off all outputs and UI devices
					//Wait only for UI_PWR_SW tasks
					lcd_power(0);
								
					ui_state = STATE_OFF;
					reset_outputs();
				}
				else
				{
					//Re-init LCD
					lcd_clear();
					lcd_power(1);
					
					check_display_debug();
					
					lcd_splash_screen(2);
					
					if(get_soc() >= CHARGED)
					{
						local_ee_data.lvdc_flag = 0;
						update_lvdc(0);
					}

					if(local_ee_data.lvdc_flag == 1)
					{
						ui_state = STATE_LVDC;
					}
					
					if(ui_state != STATE_LVDC)
					{
						if (get_unlock_days () >= 0 )
							ui_state = STATE_NORM;
						else
							ui_state = STATE_AWAIT_PAYMENT;
					}
					
					reset_outputs();
					reset_display();
				}
				
				//1 second delay
				os_dly_wait(100);
				EXTI_ClearITPendingBit(EXTI_Line0);
			}
			
			if ( event_flag & UI_EVT_USB_OC )
			{
				os_dly_wait(100);
                           
				if(EXTI_GetITStatus(EXTI_Line5) != RESET || EXTI_GetITStatus(EXTI_Line6) != RESET)
				{

					if(EXTI_GetITStatus(EXTI_Line5) != RESET)
						USB1_DISABLE();

					if(EXTI_GetITStatus(EXTI_Line6) != RESET)
						USB2_DISABLE();

					lcd_clear();
					lcd_write_string_XY(0, 0, "       USB      ");
					lcd_write_string_XY(0, 1, "      error!    ");
					//2s wait
					os_dly_wait(200);
					reset_display();
				}
			}

		
			if ( event_flag & (UI_EVT_KEYPAD_1 | UI_EVT_KEYPAD_2 | UI_EVT_KEYPAD_3) )
			{
				if ( (ui_state == STATE_AWAIT_PAYMENT) || (ui_state == STATE_NORM) || (ui_state == STATE_SETUP) )
				{
					//Read which key is pressed
					i = 0;
					do
					{
						key = keypad_get_key();		
						i++;
						os_dly_wait(1);
						if ( i > 20)
							break;
					} while (key == KEY_NONE);
					
					if (key != KEY_NONE)
					{					
						lcd_backlight(1);
						buzz(1);
					}
					
					if (ui_state == STATE_SETUP)
					{
						//If 5 digits and tick then set box_id
						if (key == KEY_CROSS) {
							//'X' Pressed
							//LCDWriteString("x");
							display_str[0] = '\0';
							digit_count = 0;
							local_ee_data.box_id = 0;
							reset_display();
						} else if (key == KEY_NONE) {
							//Do nothing
						} else if ( key == KEY_TICK ) {
							if(digit_count == 5){
								os_dly_wait(50);
								
								//Send message to payment control task
								os_evt_set(PC_SET_BOX_ID, payment_control_t);
								
								ui_state = STATE_AWAIT_PAYMENT;
								display_str[0] = '\0';
								digit_count = 0;
								reset_display();
								reset_outputs();
							}
							}else{
								if(digit_count <5){
									//Add the keypad value to the box id
									display_str[0] = '\0';
									local_ee_data.box_id = (local_ee_data.box_id * 10) + key;
									utoa_b(display_str, local_ee_data.box_id, 10, digit_count);
									lcd_write_string_XY(7, 0, display_str);
									lcd_goto_XY((8 + digit_count), 0);
									reset_display();
								}
								else { // do nothing
								}
								digit_count++;
						}
					}
					else if (ui_state == STATE_AWAIT_PAYMENT)
					{
						if (key == KEY_CROSS) {
							//'X' Pressed
							//LCDWriteString("x");
							display_str[0] = '\0';
							digit_count = 0;
							entry_code = 0;
							lcd_write_string_XY(6, 0, "__________");
							lcd_goto_XY(6, 0);
							//key = KEY_NONE;
							
						} else if (key == KEY_TICK) {
							//Tick Pressed
							//LCDWriteString("./");
						} else if (key == KEY_NONE) {
							//Tick Pressed
							//LCDWriteString("./");
						} else {
							//Add the keypad to the entry code
							entry_code = (entry_code * 10) + key;
							
							//Make the 
							display_str[0] = '\0';
							utoa_b(display_str, entry_code, 10, digit_count);
							lcd_write_string_XY(6, 0, display_str);
							lcd_goto_XY((7 + digit_count), 0);

							if (digit_count++ == 9) {
								os_dly_wait(50);
								
								//Send code to payment control task
								// but send (uint32_t)entry_code							
								if ( check_unlock_code((uint32_t)entry_code))
								{
									TRACE_INFO("2,1,%s\n", display_str);
									ui_state = STATE_NORM;
									// Edited Code
									lcd_clear();
									lcd_write_string_XY(0, 0, "      Valid      ");
									lcd_write_string_XY(0, 1, "      code!    ");
									entry_code = 0;
									digit_count = 0;
									display_str[0] = '\0';
									//2s wait
									os_dly_wait(200);
									// End of Edit
									reset_display();
									reset_outputs();
								}
								else
								{							
									TRACE_INFO("2,0,%s\n", display_str);
									// Edited Code
									lcd_clear();
									lcd_write_string_XY(0, 0, "      Wrong      ");
									lcd_write_string_XY(0, 1, "      code!    ");
									//2s wait
									os_dly_wait(200);
									// End of Edit
									
									entry_code = 0;
									digit_count = 0;
									display_str[0] = '\0';
									reset_display();
									reset_outputs();
								}
							}
						}
					}
					else
					{											
						switch (key)
						{
							case KEY_NONE:
								//No Action
								break;
							//Special Key Cases
							case KEY_TICK:
								TRACE_DEBUG("Key: ./ \n");
								break;
							case KEY_CROSS:
								TRACE_DEBUG("Key: X \n");
								break;
							default:
								//Print the key number
								TRACE_DEBUG("Key: %i \n", key);			
						}
					}
					
					//Wait for release of key (with time-out)
					i = 0;
					while( keypad_get_key() != KEY_NONE )
					{
						i++;
						os_dly_wait(1);
						if ( i > 20)
							break;
					}			
				}					
			}
			
			if(local_ee_data.lvdc_flag == 0)
			{
				if ( event_flag & UI_PAYMENT_INVALID )
				{
					ui_state = STATE_AWAIT_PAYMENT;
					lcd_clear();
					reset_display();
					reset_outputs();
				}
			}
			
			if(local_ee_data.lvdc_flag == 1)
			{
				lcd_clear();
				lcd_write_string_XY(0, 0, "  Battery Low   ");
				lcd_batt_level( get_soc(), get_charging_rate() );
				
				if(get_soc() >= CHARGED)
				{
					local_ee_data.lvdc_flag = 0;
					update_lvdc(0);
				}
			}
			//clear event flags
			os_evt_clr(event_flag, ui_t);
			
		}
		
		/* Debugging Info on LCD
	  sprintf(str, "P=%.2f", get_adc_voltage(ADC_SOL_V)*get_adc_voltage(ADC_SOL_I));
 		lcd_goto_XY(0,0);
 		lcd_write_string(str);
 		
 		str[0] = NULL;
 		
 		sprintf(str, "T=%.2f", get_adc_voltage(ADC_TEMP));
 		lcd_goto_XY(8,0);
 		lcd_write_string(str);
 		
 		str[0] = NULL;
 		
 		sprintf(str, "V=%.2f", get_adc_voltage(ADC_BATT_V));
 		lcd_goto_XY(0,1);
 		lcd_write_string(str);
		
 		str[0] = NULL;
 		
 		sprintf(str, "I=%.2f", get_adc_voltage(ADC_BATT_I));
 		lcd_goto_XY(8,1);
 		lcd_write_string(str);
 		
 		str[0] = NULL;
*/
		//Update battery levels, days remaining and if normal state then time/date
		
		if(local_ee_data.lvdc_flag == 1)
		{
			lcd_write_string_XY(0, 0, "  Battery Low   ");
			lcd_batt_level( get_soc(), get_charging_rate() );
				
			if(get_soc() >= CHARGED)
			{
				local_ee_data.lvdc_flag = 0;
				update_lvdc(0);
				
				if(get_unlock_days () >= 0 )
				{
					ui_state = STATE_NORM;
				}
				else
				{
					ui_state = STATE_AWAIT_PAYMENT;
				}
				
				reset_display();
				reset_outputs();
				
			}
		}
		
		if ( (ui_state == STATE_NORM) || (ui_state == STATE_AWAIT_PAYMENT) )
		{
			lcd_batt_level( get_soc(), get_charging_rate() );
		}
		
		if (ui_state == STATE_NORM)
		{
			//Update remaining days
			if(local_ee_data.full_unlock == EE_FULL_UNLOCK_CODE){
				lcd_write_string_XY(0, 1, "        Unlocked");
				lcd_batt_level( get_soc(), get_charging_rate() );
			}
			else{
				lcd_write_string_XY(0, 1, "            days");
				lcd_write_int_XY(10, 1, get_unlock_days() );
				lcd_batt_level( get_soc(), get_charging_rate() );
			}			
		}

	}
}
Esempio n. 10
0
//
//
// System setup menu
//
//
void misc_setup(u08 force_menu)
{
#ifdef MENU_CODE
u08 bl;
u08 sound;
u08 invert;
u08 clock;

   // load backlight value in EEPROM
   bl = eeprom_read_byte((uint8_t *) EE_BACKLIGHT);

   // validate the sound value in EEPROM
   sound = eeprom_read_byte((uint8_t *) EE_SOUND);
   if(sound == 'N') sound = 1;
   else if(sound == 'F') sound = 0;
   else {
      force_menu = 1;
      sound = 1;
   }

   // validate the time value in EEPROM
   clock = eeprom_read_byte((uint8_t *) EE_SET_TIME);
   if(clock == 'N') clock = 1;
   else if(clock == 'F') clock = 0;
   else {
      force_menu = 1;
      clock = 0;
   }

   // validate the button color value in EEPROM
   invert = eeprom_read_byte((uint8_t *) EE_INVERT_BUT);
   if((invert != 0x00) && (invert != 0xFF)) {
      force_menu = 1;
      invert = 0xFF;
   }


   time_not_set = 1;
   if(force_menu == 0) goto use_params;

   MENU_INIT

   do {
      MENU_CONTROLS


      if((COLS < 160) || (ROWS < 80)) {
         menu_label    (0,0,   PS("Misc Setup")); 
         menu_checkbox (1*CHAR_WIDTH-4,  (CHAR_HEIGHT+CHAR_HEIGHT/2)*1, PS("Backlight"),  bl, 1);
         menu_checkbox (1*CHAR_WIDTH-4,  (CHAR_HEIGHT+CHAR_HEIGHT/2)*2, PS("Beeper"),  sound, 2);
         menu_checkbox (1*CHAR_WIDTH-4,  (CHAR_HEIGHT+CHAR_HEIGHT/2)*3, PS("Invert buttons"), invert, 3);
         #ifdef TIME_CLOCK
            menu_checkbox (1*CHAR_WIDTH-4,  (CHAR_HEIGHT+CHAR_HEIGHT/2)*4, PS("Set clock"), clock, 4);
         #endif
         menu_exitbutton();
      }
      else {
         menu_label    (0,0,   PS("Misc Setup Menu")); 
         menu_checkbox (4*CHAR_WIDTH,  CHAR_HEIGHT*2, PS("Backlight"),  bl, 1);
         menu_checkbox (4*CHAR_WIDTH,  CHAR_HEIGHT*4, PS("Beeper"),  sound, 2);
         menu_checkbox (4*CHAR_WIDTH,  CHAR_HEIGHT*6, PS("Invert buttons"), invert, 3);
         #ifdef TIME_CLOCK
            menu_checkbox (4*CHAR_WIDTH,  CHAR_HEIGHT*8, PS("Set clock"), clock, 4);
         #endif
         menu_exitbutton();
      }

      MENU_COMMANDS

      // menu button/control responses

      switch(menu_cmd()) {
         case 1: 
            break;

         case 2: 
            break;

         case 3: 
            break;

         case 4: 
            #ifdef TIME_CLOCK
               if(clock) {
                  menu_call(set_time);
                  time_not_set = 0;
               }
            #endif
            break;
      }
   } while(menu_cmd() != MENU_EXITCODE) ;  // repeat until exit command

   wait_while_touched();

   if(bl) bl = 0xFF;  //!!!  
   eeprom_write_byte((uint8_t *) EE_BACKLIGHT,  bl);

   if(sound)  eeprom_write_byte((uint8_t *) EE_SOUND,  (uint8_t) 'N');
   else       eeprom_write_byte((uint8_t *) EE_SOUND,  (uint8_t) 'F');

   if(invert)  eeprom_write_byte((uint8_t *) EE_INVERT_BUT,  (uint8_t) 0xFF);
   else        eeprom_write_byte((uint8_t *) EE_INVERT_BUT,  (uint8_t) 0x00);

   if(clock)   eeprom_write_byte((uint8_t *) EE_SET_TIME,  (uint8_t) 'N');
   else        eeprom_write_byte((uint8_t *) EE_SET_TIME,  (uint8_t) 'F');

   

   use_params:
   lcd_backlight(bl);

   #ifdef TIME_CLOCK
      if(eeprom_read_byte((uint8_t *) EE_SET_TIME) == 'N') {
         if(time_not_set) set_time();
      }
   #endif

   if(sound) beep_disabled = 0;
   else      beep_disabled = 1;

   if(invert) invert_buttons = WHITE;
   else       invert_buttons = 0x00;
#endif
}
Esempio n. 11
0
void md_init_no_logo(void)
{
u08 force_setup;

    cli();    // disable interrupts
    hw_init();

#ifdef MOUSE_UART3
sbi(PORTD, 7); cbi(DDRD, 7);   //!!!! mouse uart
sbi(PORTD, 6); sbi(DDRD, 6);   //!!!! mouse uart
#endif

    sei();    // enable interrupts - the Donkey is off and running

    #ifdef TIME_CLOCK
       if(1) {   //!!! for time clock maximum wrap test
          time.hours= 23;
          time.mins = 59;
          time.secs = 00;
          time.month = 12;
          time.day  = 31;
          time.year = 2007;
          time.weekday = 6;
          time.adjust = 0;
       } 
    #endif

#ifdef PANEL_CODE
    lcd_init();          // initialize LCD hardware
    lcd_set_stdout();    // make printf() use bitmapped chars
#endif

#ifdef VCHAR_CODE
//  vchar_init();        // initialize vector characters
//  vchar_set_stdout();  // make printf use vector chars
#endif

    lcd_backlight(0xFF);

    force_setup = 0;
    user_input_init();

#ifdef CKSUM_CODE
    check_flash(DELAY_FLAG);   // verify FLASH checksum - can also add HALT_FLAG
#endif

#ifdef CKPT_CODE
    check_point(0);   // see if last run produced a system RAM checkpoint dump to eeprom
#endif

void contrast_demo(void);
//contrast_demo();

//zadc_demo(2);
//sketch_a_etch();

//void gps_demo(void);
//gps_demo();

//fill_screen(BLACK);
//arc(80,40, 20, 30,170, 10);
//arc(80,40, 10, 40,160, 1);
//wait_until_touched();
//wait_while_touched();


#ifdef USER_INPUT
    delay_ms(10);  // allow some time to pass
	               // might be needed for first get_touch?

    if(get_touch(1) || MouseRB || MouseLB) {   // if screen touched on powerup,  force setup menus
       lcd_clear();
       force_setup = 1;
       set_charsize(3);
       lcd_textPS(0, 0, "Setup");
       set_charsize(1);
//     wait_while_touched();        // not a good idea.  touch cal could be off
       delay_ms(2000);
    }

    calibrate_touch(force_setup);   // calibrate touch screen if not already done 

    misc_setup(force_setup);        // setup backlight, etc, if not already done

    #ifdef UART0   // do com0 setup menu, if not already done or forced setup
       com_setup(0, force_setup);     
    #endif

    #ifdef UART1   // do com1 setup menu, if not already done or forced setup
       com_setup(1, force_setup);
    #endif
#endif   // no user input device: set default com port parameters


// if library build then do donkey splash screen for 2.5 seconds

#ifdef LIBRARY_BUILD
  lcd_clear();
#endif

#ifdef MENU_CODE
 MenuBeep = 1; 
#endif


}
Esempio n. 12
0
//------------------------------------------------------------------------------
//	Initialize Life pattern seed -----------------------------------------------
void init_life(enum SEED seed)
{
	int i;
	lcd_clear();						// clear LCD
	memset(life, 0, sizeof(life));		// clear life array
	lcd_backlight(ON);					// turn on LCD backlight
	lcd_rectangle(0, 0, NUM_COLS*2, NUM_ROWS*2, 1);
	switch(seed)
	{
		case LIFE:
		{
			draw_rle_pattern(65, 30, gosper_glider_gun);
			draw_rle_pattern(60, 5, pulsar);
			draw_rle_pattern(4, 7, beacon_maker);
			draw_rle_pattern(4, 30, hexapole);
			draw_rle_pattern(4, 40, hexapole);
			draw_rle_pattern(4, 50, hexapole);
			draw_rle_pattern(4, 60, hexapole);
			draw_rle_pattern(15, 65, loafer);
			break;
		}

		case BIRD:
		{
			draw_rle_pattern(60, 5, pulsar);		// sun
			draw_rle_pattern(31, 2, bird);			// bird
			draw_rle_pattern(40, 20, hwss);			// bigger bird
			draw_rle_pattern(11, 29, glider);		// blows bird apart
			draw_rle_pattern(65, 65, loafer);

			for (i = 2; i <= 78; i += 3)			// draw ground
			{
				draw_rle_pattern(7, i, block);		// block
			}
			break;
		}

		case BOMB:
		{
			draw_rle_pattern(65, 10, gosper_glider_gun);
			draw_rle_pattern(40, 10, lwss);			// LWSS
			draw_rle_pattern(20, 10, pulsar);		// pulsar
			draw_rle_pattern(20, 35, pulsar);		// pulsar
			draw_rle_pattern(20, 60, pulsar);		// pulsar
			draw_rle_pattern(10, 10, block);		// block
			draw_rle_pattern(10, 18, beehive);		// beehive
			draw_rle_pattern(10, 26, loaf);			// loaf
			draw_rle_pattern(10, 34, boat);			// boat
			draw_rle_pattern(10, 42, toad);			// toad
			draw_rle_pattern(10, 50, beacon);		// beacon
			draw_rle_pattern(10, 58, blinker);		// blinker
			draw_rle_pattern(10, 66, by_flop);		// by_flop
			break;
		}

		default:
		{
			draw_rle_pattern(4, 2, jon_arbuckle);	// pattern of choice
			break;
		}
	}
	return;
} // end init_life
Esempio n. 13
0
File: life.c Progetto: rellify/CS
//------------------------------------------------------------------------------
// main ------------------------------------------------------------------------
void main(void)
{
	RBX430_init(_16MHZ);				// init board
	ERROR2(lcd_init());					// init LCD

	// configure Watchdog
	WDTCTL = WDT_CTL;					// Set Watchdog interval
	WDT_Sec_Cnt = WDT_1SEC_CNT;			// set WD 1 second counter
	IE1 |= WDTIE;						// enable WDT interrupt

	lcd_clear();						// clear LCD
	lcd_backlight(ON);					// turn on LCD backlight
	lcd_rectangle(0, 0, NUM_COLS*2, NUM_ROWS*2, 1);	// draw border

	__bis_SR_register(GIE);				// enable interrupts

	// output splash screen & wait for switch
	lcd_wordImage(life_image, (159-126)/2, 50, 1);
	lcd_mode(LCD_PROPORTIONAL | LCD_2X_FONT);
	lcd_cursor(10, 20);
	printf("Press Any Key");
	lcd_mode(0);
	while (1) if ((P1IN & 0x0f) ^ 0x0f) break;

	while (1)
	{
		uint16 row, col;
		// for each live row (78 down to 1)
		for (row = NUM_ROWS-2; row; --row)
		{
			// for each live column (78 down to 1)
			for (col = NUM_COLS-2; col; --col)
			{

					cell_death(row, col);
			}
		}

		char str[] = "x = 2, y = 2, rule = B3/S23\n2o$2o!";
		char* ptr;
		int x_number = 0;
		int y_number = 0;
		const uint8 pttrn;
		for (ptr = str; *ptr; ptr++);
		{
				if (*ptr != 'x') continue;
				if ((*ptr < '0') && (*ptr > '9')) continue;
				while ((*ptr >= '0') && (*ptr <= '9'))
				{
					x_number = x_number * 10 + (*ptr++ - '0');
				}

				if (*ptr != 'y') continue;
				if ((*ptr < '0') && (*ptr > '9')) continue;
				while ((*ptr >= '0') && (*ptr <= '9'))
				{
					y_number = y_number * 10 + (*ptr++ - '0');
				}

				if (*ptr != 'n') continue;

		}




	}

	while (1)							// new pattern seed
	{
		// load initial seed patterns
		uint16 generation = 0;			// generation counter
		uint8 pen  = BIRTH;				// temp variable
		WDT_Sec_Cnt = WDT_1SEC_CNT;		// set WD 1 second counter
		seconds = 0;					// clear second counter


		while (1)
		{
			uint16 row, col;
			// for each live row (78 down to 1)
			for (row = NUM_ROWS-2; row; --row)
			{
				// for each live column (78 down to 1)
				for (col = NUM_COLS-2; col; --col)
				{
					if (pen == BIRTH)
					{
						cell_birth(row, col);
					}
					else
					{
						cell_death(row, col);
					}
				}
			}
			lcd_wordImage(life_image, (159-126)/2, 50, (BIRTH == pen) ? 3 : 1);
			lcd_cursor(4, 1);			// output life generation
			printf("%d/%d", ++generation, seconds);
			if (seconds == 100) while (1);
			pen = (pen == BIRTH) ? DEATH : BIRTH;
		}
	}
} // end main()
Esempio n. 14
0
//------------------------------------------------------------------------------
// main ------------------------------------------------------------------------
void main(void)
{
	RBX430_init(_16MHZ);				// init board
	ERROR2(lcd_init());					// init LCD
	//lcd_volume(376);					// increase LCD brightness
	watchdog_init();					// init watchdog
	port1_init();						// init P1.0-3 switches
	__bis_SR_register(GIE);				// enable interrupts

	lcd_clear();
	memset(life, 0, sizeof(life));		// clear life array
	lcd_backlight(ON);
	lcd_wordImage(life_image, (HD_X_MAX - 126) / 2, 50, 1);
	lcd_cursor(10, 20);
	printf("\b\tPress Any Key");
	switches = 0;						// clear switches flag

	life_pr = life_prev;
	life_cr = life_cur;
	life_nr = life_nex;

	while (!switches);					// wait for any switch

	while (1)							// new pattern seed
	{

		uint16 generation;				// generation counter
		uint16 row, col;

		WDT_Sec_Cnt = WDT_1SEC_CNT;		// reset WD 1 second counter
		seconds = 0;					// clear second counter
		generation = 0;					// start generation counter
		int loop;
		int neighbors;
		int left;
		int middle;
		int current;
		int right;
		loop = 1;
		memset(life, 0, sizeof(life));				// clear life array
		memset(life_pr, 0, 10 * sizeof(uint8));		// clear slider
		memset(life_cr, 0, 10 * sizeof(uint8));		// clear slider
		memset(life_nr, 0, 10 * sizeof(uint8));		// clear slider
		init_life(switches);						// load seed based on switch
		switches = 0;								// reset switches



		while (loop)								// next generation
		{
			RED_TOGGLE;
			memcpy(life_pr, life[79], 10 * sizeof(uint8));
			memcpy(life_cr, life[78], 10 * sizeof(uint8));
			memcpy(life_nr, life[77], 10 * sizeof(uint8));
			// for each life row (78 down to 1)
			for (row = NUM_ROWS-2; row > 0; row--)
			{
				left = 0;
				neighbors = 0;
				current = TEST_CELL(life_cr, 1);
				right = TEST_CELL(life_pr, 2) + TEST_CELL(life_cr, 2) + TEST_CELL(life_nr, 2);
				middle = TEST_CELL(life_pr, 1) + current + TEST_CELL(life_nr, 1);

				// for each life column (78 down to 1)
				for (col = 1; col < 79; col++)
				{
					neighbors = left + (middle - current) + right;

					//neighbors += (TEST_CELL(life_pr, (col - 1)) + TEST_CELL(life_pr, col) + TEST_CELL(life_pr, (col + 1)));		// add number of neighbors on row above
					//neighbors += (TEST_CELL(life_cr, (col - 1)) + TEST_CELL(life_cr, (col + 1)));												// add number of neighbors on current row
					//neighbors += (TEST_CELL(life_nr, (col - 1)) + TEST_CELL(life_nr, col) + TEST_CELL(life_nr, (col + 1)));		// add number of neighbors on row below

					if(current == 1)												// if the cell is currently alive
					{
						if(neighbors == 2 || neighbors == 3)							// the cell has 2 or 3 neighbors
						{
																						// do nothing, the cell remains alive
						}

						else															// the cell doesn't have necessary neighbors
						{
							CELL_DEATH(row, col);										// clear cell bit in life array
							CELL_DELETE(row, col);										// clear LCD 2x2 pixel point
						}
					}

					else																// the cell is currently dead
					{
						if(neighbors == 3)												// the cell has 3 live neighbors
						{
							CELL_BIRTH(row, col);										// set cell bit in life array
							CELL_DRAW(row, col);										// set LCD 2x2 pixel point
						}
					}

					neighbors = 0;														// reset neighbors
					left = middle;
					current = TEST_CELL(life_cr, col + 1);
					middle = right;
					right = TEST_CELL(life_pr, col + 2) + TEST_CELL(life_cr, col + 2) + TEST_CELL(life_nr, col + 2);
				}

				temp = life_pr;
				life_pr = life_cr;
				life_cr = life_nr;
				life_nr = temp;
				//memcpy(life_pr, life_cr, 10 * sizeof(uint8));			// sets next row
				//memcpy(life_cr, life_nr, 10 * sizeof(uint8));			// sets next row
				memcpy(life_nr, life[row - 2], 10 * sizeof(uint8));			// sets next row


			}

			// display life generation and generations/second on LCD
			if (display_results(++generation)) break;
			if(switches)
			{
				loop = 0;					// when a switch is pressed, exit the while loop
			}
		}

	}
} // end main()
Esempio n. 15
0
void lcd_setup() {
  lcd_begin(LCD_I2C_ADDR, MAX_LCD_LINE_LEN, LCD_NUM_LINES, LCD_5x8DOTS);
  lcd_backlight();
  // can't define this as the zeroth character as zero is null in sprintf! :)
  lcd_createChar(1, backslashChar);
}