コード例 #1
0
ファイル: main.c プロジェクト: bgbock/rdmp
 int main (void)
  {
  init_hw();
  LCD_init();
  SR_DAT_IN;
  while (1)
  	{
	uart_sendchar('A');
	uart_sendstr("0123456789abcdef");
 // 	dly_ms(40);
  	if (rcvd_flag)
  		{
  		rcvd_flag=0;
  		uart_sendstr("R:");
  		if (f_gsm_ok)
  			{
  			f_gsm_ok=0;
  			uart_sendstr("G_OK");
  			}
  		if (f_gsm_nc)
  			{
  			f_gsm_nc=0;
  			uart_sendstr("G_NC");
  			}
  		if (f_gsm_cr)
  			{
  			f_gsm_cr=0;
  			uart_sendstr("G_CR");
  			}
  		if (f_gsm_ring)
  			{
  			f_gsm_ring=0;
  			uart_sendstr("G_RI");
  			}
  		uart_sendstr("\r\n");
  		}


  	keys = read_keys();

  	if (keys==0x01) 		update_lcd("K1");
  	else if (keys==0x02) 	update_lcd("K2");
  	else if (keys==0x04) 	update_lcd("K3");
  	else if (keys==0x08) 	update_lcd("K4");
  	else if (keys==0x10) 	update_lcd("K5");
  	else if (keys==0x20) 	update_lcd("K6");
  	else if (keys==0x40) 	update_lcd("K7");
  	else if (keys==0x00) 	update_lcd("0123456789ABCDEF");
  	else update_lcd("Kx");
/*
	if (keys_handling(&key))
		{
		keys = key;
		}
*/
  	}
  }
コード例 #2
0
ファイル: main.c プロジェクト: mbuesch/morse
/** \brief	Maschinenzustand initialisieren. */
static void machine_state_init(void)
{
	clear_output_text();
	set_words_per_minute(10);
	reset_capture_context();
	update_lcd();
}
コード例 #3
0
/*****
 * DoTest_Track() - Perform the Tracking test
 * 
 * This function uses the global "pwm_freq" and "pwm_duty" values to adjust the PWM
 * duty cycle and thus the intensity of the LED.  The function displays
 * the light detector reading as it tracks changes in the
 * LED intensity.  This test runs continuously until a different test is selected.
 * Returns XST_SUCCESS since this test can't fail.  Returns approximate sample interval
 * in the global variable "frq_sample_interval"
 *****/ 
XStatus DoTest_Track(void)
{
	static int		old_pwm_freq = 0;			// old pwm_frequency and duty cycle
	static int		old_pwm_duty = 200;			// these values will force the initial display	
	volatile u16	frq_cnt;					// light detector counts to display
	XStatus			Status;						// Xilinx return status
	unsigned		tss;						// starting timestamp			

	if ((pwm_freq != old_pwm_freq) || (pwm_duty != old_pwm_duty))
	{	
		// set the new PWM parameters - PWM_SetParams stops the timer
		Status = PWM_SetParams(&PWMTimerInst, pwm_freq, pwm_duty);
		if (Status == XST_SUCCESS)
		{							
			PWM_Start(&PWMTimerInst);
		}

		tss = timestamp;	
		
		//ECE544 Students:
        //make the light sensor measurement
		frq_cnt = LIGHTSENSOR_Capture(LIGHTSENSOR_BASEADDR, slope, offset, is_scaled);

		delay_msecs(1);
		frq_smple_interval = timestamp - tss;
				
		// update the display and save the frequency and duty
		// cycle for next time
		update_lcd(pwm_duty, frq_cnt);
		old_pwm_freq = pwm_freq;
		old_pwm_duty = pwm_duty;
	}
	return XST_SUCCESS;
}
コード例 #4
0
ファイル: microvsn.cpp プロジェクト: Fulg/mame
/*
control is signals LCD5 LCD4
  LCD5 = -Data Clk on 0488
  LCD4 = Latch pulse on 0488
  LCD3 = Data 0
  LCD2 = Data 1
  LCD1 = Data 2
  LCD0 = Data 3
data is signals LCD3 LCD2 LCD1 LCD0
*/
void microvision_state::lcd_write(UINT8 control, UINT8 data)
{
	// Latch pulse, when high, resets the %8 latch address counter
	if ( control & 0x01 ) {
		m_lcd_latch_index = 0;
	}

	// The addressed latches load when -Data Clk is low
	if ( ! ( control & 0x02 ) ) {
		m_lcd_latch[ m_lcd_latch_index & 0x07 ] = data & 0x0f;
	}

	// The latch address counter is incremented on rising edges of -Data Clk
	if ( ( ! ( m_lcd_control_old & 0x02 ) ) && ( control & 0x02 ) ) {
		// Check if Latch pule is low
		if ( ! ( control & 0x01 ) ) {
			m_lcd_latch_index++;
		}
	}

	// A parallel transfer of data from the addressed latches to the holding latches occurs
	// whenever Latch Pulse is high and -Data Clk is high
	if ( control == 3 ) {
		for ( int i = 0; i < 8; i++ ) {
			m_lcd_holding_latch[i] = m_lcd_latch[i];
		}
		update_lcd();
	}

	m_lcd_control_old = control;
}
コード例 #5
0
ファイル: tsc.c プロジェクト: hericz/atinom_banyu
static void setting_fma(int argc, char **argv)
{
	int c;
	
	/* suspend task haliza utama dulu */
	vTaskSuspend( hdl_tampilan );
	xSerialGetChar(1, &c, 20 );

	/* disable interrupt touchpad */
	//*pFIO_MASKA_S = 0;
	//ssync();
	
	while( 1 )
	{
		if (xSerialGetChar(1, &c, 20 ) == pdTRUE) break;
		cls_layar();
		read_key();
		update_lcd();
	}
	
	//cls_layar();	
	//*pFIO_MASKA_S = PORT_INT_KEYPAD;
	//ssync();
	vTaskResume( hdl_tampilan );

}
コード例 #6
0
ファイル: debug_layar.c プロジェクト: Hendryputra/atinomba
void debug_out(const char *fmt, ...)
{
	va_list args;
   	uint i;

	if (enable_log == 1)
	{
   		va_start (args, fmt);

	   	/* For this to work, printbuffer must be larger than
		* anything we ever want to print.
		*/
	   	i = vsprintf ( tek , fmt, args);
	   	va_end (args);

	   	/* Print the string */
	   	debug_line++;
	   	
	   	if (debug_line > 25)
	   	{
	   		cls_layar();
	   		debug_line = 0;
	   		update_lcd();
	   	}
	   	
	   	teks_layar( pinggir , (debug_line*8) + 9, tek);
   	}
   	return;
}
コード例 #7
0
int ComThread::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QThread::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: switch_led((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< bool(*)>(_a[2]))); break;
        case 1: update_lcd((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< float(*)>(_a[2]))); break;
        case 2: update_mbrtu((*reinterpret_cast< char*(*)>(_a[1]))); break;
        default: ;
        }
        _id -= 3;
    }
    return _id;
}
コード例 #8
0
ファイル: microvsn.cpp プロジェクト: Fulg/mame
void microvision_state::screen_vblank(screen_device &screen, bool state)
{
	if ( state )
	{
		for (auto & elem : m_lcd)
		{
			for ( int j= 0; j < 16; j++ )
			{
				if ( elem[j] )
				{
					elem[j]--;
				}
			}
		}
		update_lcd();
	}
}
コード例 #9
0
ファイル: main.c プロジェクト: huayuliang/digital-toy
int main()
{
	timer0_init();
	enable_timer0();
	lcd1602_init();
	adc_init();

	io_init();
	
	lcd_puts("Tool gear V0");
    sti();

	while(1){
		update_lcd();
		iron_loop();
	}

}
コード例 #10
0
ファイル: main.c プロジェクト: mbuesch/morse
/** \brief	Ereignisse mit niedriger Prioritaet abarbeiten. */
static void handle_events(void)
{
	morse_sym_t captured[CAPTURE_BUF_SIZE];
	uint8_t nr_captured = 0, nr_decoded;
	bool capture_error;
	bool had_async_lcd_update;

	/* Cleartaster abfragen. */
	handle_clear_button();

	/* Empfangene Symbole in temporaeren lokalen Puffer kopieren
	 * und Interrupts so schnell wie moeglich wieder freigeben. */
	irq_disable();
	if (capture.nr_captured) {
		nr_captured = capture.nr_captured;
		capture.nr_captured = 0;
		memcpy(captured, capture.captured,
		       nr_captured * sizeof(captured[0]));
	}
	capture_error = capture.capture_error;
	capture.capture_error = 0;
	irq_enable();

	/* Empfangene Symbole dekodieren und in LCD Puffer uebertragen. */
	nr_decoded = decode_symbols(captured, nr_captured,
				    capture_error);

	/* Asynchrones LCD-update Flag abfragen und ruecksetzen. */
	irq_disable();
	had_async_lcd_update = machine.async_lcd_update;
	machine.async_lcd_update = 0;
	irq_enable();

	/* LCD auffrischen, wenn neue Symbole decodiert wurden,
	 * oder ein asynchrones LCD Update angefordert wurde. */
	if (nr_decoded || had_async_lcd_update)
		update_lcd();
}
コード例 #11
0
ファイル: main.c プロジェクト: mbuesch/morse
/** \brief	Cleartaster-Ereignisse abarbeiten. */
static void handle_clear_button(void)
{
	enum edge_detect_result edge;

	irq_disable();
	if (machine.clear_button_pause) {
		irq_enable();
		/* Entprellpause ist aktiv.
		 * Keine Erkennung durchfuehren. */
		return;
	}
	irq_enable();

	/* Flankenerkennung des Cleartasters aufrufen. */
	edge = get_clear_button_edge();

	if (edge == EDGE_POS) {
		/* Positive Flanke: Cleartaster wurde gedrueckt.
		 * Morsestring im LCD loeschen. */
		if (memcmp(&out.text[OUT_TEXT_LEN - 5], " BNT ", 5) == 0) {
			irq_disable();
			buzzer_play(buzzer_elise);
			irq_enable();
		}
		clear_output_text();
		reset_capture_context();
		update_lcd();
	}
	if (edge != EDGE_NONE) {
		/* Es gab eine positive oder negative Flanke.
		 * Entprellzeit einstellen. */
		irq_disable();
		machine.clear_button_pause = DEBOUNCE_TICKS;
		irq_enable();
	}
}
コード例 #12
0
ファイル: tampilan.c プロジェクト: Hendryputra/atinomba
portTASK_FUNCTION( tampilan_task, pvParameters )	{
	unsigned char key_press;

	int i;
	int loop;
	unsigned char jum_OK;
	char loop_key;
	int loop_per_menit=0;
	unsigned char dipencetdeh=0;
	
	// set PF14 & PF10 sebagai input interrupt keypad
	#ifdef TAMPILAN_LPC
	FIO1DIR = FIO1DIR  & ~(PF10 | PF14 | KEY_DAT);
	#endif
	
	#ifdef TAMPILAN_LPC_43
	FIO2DIR = FIO2DIR  & ~PF14;
	
	/* masking dengan 0 supaya bisa dibaca */
	FIO1DIR  = FIO1DIR  & ~(KEY_DAT);
	FIO1MASK = FIO1MASK & ~(KEY_DAT);
	
	/* masking dengan 0 supaya bisa dibaca */
	FIO2MASK = FIO2MASK & ~(PF14);	
	#endif
	
	
	// kasih delay dulu, supaya skeduler jalan
	vTaskDelay(100);
	printf("Starting Tampilan\n");
	teks_h(14, 20, "Daun Biru Engineering");
	teks_h(14, 29, "FreeRTOS 5.1.1 by Richard Barry");
	teks_h(14, 38, "uIP TCP/IP by Adam Dunkels");
	teks_h(14, 47, "NXP LPC2387, 60 MHz");
	
	sprintf(tek, "ARM-GCC %s : %s : %s", __VERSION__, __DATE__, __TIME__);
	teks_h(14, 56, tek);
	
	teks_arial(22, 70, "Monita");
	
	#if (PAKAI_FONT_KOMIK == 1)
	teks_komik(18, 87, "Online Monitoring System");
	#else
	teks_arial(18, 87, "Performance Monitoring");
	#endif
	
	update_lcd();
	vTaskDelay(100);
	teks_h(14, 110, "Loading setting ...");
	
	//set_awal_mesin();
	//set_awal_sumber();
	//set_awal_titik();
	
	#if 0
	for (;;)
	{
		vTaskDelay(201);
		
		cls_layar();
		
		
		loop++;
		//sprintf(tek, "loop tampilan = %d", loop);
		//teks_layar(10, 20, tek);
		
		update_lcd();	
	}
	#endif
	
	
	read_sumber();
	//read_mesin();
	//read_titik();
	
	cls_layar();
	vTaskDelay(500);
	update_lcd();
	vTaskDelay(100);
	update_lcd_layer2();
	vTaskDelay(10);
/*	
	teks_h(14, 20, "Data Mesin :");
	for (i=0; i<10; i++)
	{
		sprintf(tek, "%2d     %s", (i+1), mesin[i].nama);
		teks_h(20, 30 + (i*9), tek);
	}

	cls_layar();
	vTaskDelay(800);
	update_lcd();
	vTaskDelay(100);
	update_lcd_layer2();
	vTaskDelay(10);
//*/	
	/*
	teks_h(14, 20, "Data Sumber Data :");
	for (i=0; i<JML_SUMBER; i++)
	{
		sprintf(tek, "%2d   %s", (i+1), sumber[i].nama);
		teks_h(20, 30 + (i*9), tek);
		
		// print out IP
		sprintf(tek,"%d.%d.%d.%d", sumber[i].IP0, sumber[i].IP1, sumber[i].IP2, sumber[i].IP3);
		teks_h(120, 30 + (i*9), tek);
		
		// status
		if (sumber[i].status == 0)
			teks_h(220, 30 + (i*9), "Tdk Aktif");
		if (sumber[i].status == 1)
			teks_h(220, 30 + (i*9), "Normal");
		if (sumber[i].status == 2)
			teks_h(220, 30 + (i*9), "TimeOut");
		if (sumber[i].status == 5)
			teks_h(220, 30 + (i*9), "Daytime");	
		// init data float
		for(loop = 0; loop < 20; loop++)
		{
			s_data[i].data[loop] = 0.00;	
		}	
	}
	*/
	
	cls_layar();
	// test depth
	//fill_layar(0x0F);
	vTaskDelay(100);		// 800
	update_lcd_layer2();
	
	//cls_layar();
	//kotak(10, 10, 300, 220);
	//update_lcd_layer3();
	
	loop = 0;
	#if 0
	for (;;)
	{
		vTaskDelay(201);
		
		cls_layar();
		
		
		loop++;
		//sprintf(tek, "loop tampilan = %d", loop);
		//teks_layar(10, 20, tek);
		
		update_lcd();	
	}
	#endif
	
	#if 1	
	
	key_index = 0;
	mesin_index = 0;
	cls_layar();
	menu_monita();
	menu_pilih(key_index, mesin_index, 0);
	update_lcd();	
	loop = 0;
	jum_OK = 0;
	i = loop_key = 0;
	/*
	vSemaphoreCreateBinary( keypad_sem );
    xSemaphoreTake( keypad_sem, 0 );		
	*/
	for (;;)
	{
		#ifdef PAKAI_TSC
		if (key_press = baca_tsc())
		#else
		if (cek_keypad())
		#endif
		/* jika 1 detik tidak ada keypad, maka force untuk update lcd */
		//if ( xSemaphoreTake( keypad_sem, 1000 ) == pdTRUE )
		{	
			loop_key++;
			
			//if (loop_key > 1)
			{
				loop_key = 0;
			
				cls_layar();
				// cek tombol apa yang ditekan
				#ifndef PAKAI_TSC 
				key_press = (FIO1PIN & KEY_DAT);
				#else
				switch (key_press) {
					case 1:
						key_press = CANCEL;
						break;
					case 2:
						key_press = OK;
						break;
					#ifdef PAKAI_TSC
					case 4:
						key_press = TANYA;
						break;
					case 8:
						key_press = KIRI;
						break;
					#endif
					case 16:
						key_press = ATAS;
						break;
					case 32:
						key_press = KANAN;
						break;
					case 64:
						key_press = BAWAH;
						break;
				}
				#endif
				//printf("tombol ditekan = %d\n", key_press);	
			
				if (key_press == ATAS)
				{
					if (dipencetdeh>0)	{
						key_index--;
						dipencetdeh=5;
					}
					if (key_index == 255) {
						key_index = kursor_vert()-1;
						//key_index = 10;	// 9
					}
				}
				else if ( key_press == BAWAH )
				{
					if (dipencetdeh>0)	{
						key_index++;
						dipencetdeh=5;
					}
					if (key_index > kursor_vert()) 
						key_index = 0;		// 9
				}
				else if ( key_press == KANAN )
				{
					mesin_index++;
					if (mesin_index > 9) mesin_index = 0;
				}
				#ifdef PAKAI_TSC
				else if ( key_press == KIRI )
				{
					mesin_index--;
					if (mesin_index == 255) mesin_index = 9;
				}
				else if ( key_press == TANYA )
				{
					#ifdef PAKAI_ALARM
					ACK = 0;
					#endif
				}
				#endif
				else if ( key_press == OK)
				{
					jum_OK++;
					#ifdef PAKAI_ALARM
					//printf("m: %d, k: %d\r\n", mesin_index, key_index);
					ack_invert(mesin_index, key_index);
					#endif
				}
				else if ( key_press == CANCEL)
				{
					if (dipencetdeh==0) {
						dipencetdeh = lama_kursor;
					} else {
						//dipencetdeh = 0;
					}
					//printf("dipencet deh: %d\r\n", dipencetdeh);
					//vTaskDelay(300);
				}
				//menu_OK(key_index, mesin_index, jum_OK);
				jum_OK = 0;

				//printf("key index: %d, mesin_index: %d\r\n", key_index, mesin_index);
				
				//menu_monita(key_index);
				cls_layar();
				menu_pilih(key_index, mesin_index, 0);
				menu_group(key_index, mesin_index);		
				menu_tunjuk(key_index, dipencetdeh);
				
				update_lcd();
				loop = 0;
			}	
		}	
		else
		{
			loop_key = 0;	
			if (dipencetdeh>0) {
				dipencetdeh--;
				if (dipencetdeh==0)
					key_index = 0;
			}
		}
		
		if (loop > 2)
		{
			
			if (key_index != 10)
			{
				/* force untuk update layar */
				cls_layar();
				//menu_monita(key_index);		
				menu_pilih(key_index, mesin_index, 0);
				menu_group(key_index, mesin_index);
				menu_tunjuk(key_index, dipencetdeh);
				//menu_OK(key_index, mesin_index);
							
				update_lcd();
			}
			
			loop = 0;
			
			loop_per_menit++;
			if (loop_per_menit > 20)
			{
				//printf("hitung \r\n");
				loop_per_menit = 0;
				//hitung_data_hitung();
			}	
		}
		vTaskDelay(300);
		loop++;	
	}
	#endif
}
コード例 #13
0
ファイル: main.c プロジェクト: Andy1978/needler
/*
 *      //~ uart_puts_P("G21\n");
        //~ get_grbl_response();
        //~ uart_puts_P("G90\n");
        //~ get_grbl_response();
        //~ uart_puts_P("G94\n");
        //~ get_grbl_response();
        //~ uart_puts_P("G17\n");
        //~ get_grbl_response();
        //~ uart_puts_P("M3 S1000\n");
        //~ get_grbl_response();
        //~ uart_puts_P("F800.00\n");
        //~ get_grbl_response();
        //~ uart_puts_P("G0 Z1.00\n");
        //~ get_grbl_response();
        //~ uart_puts_P("G0 X15 Y15\n");
        //~ get_grbl_response();
        //~ uart_puts_P("G1 Z-1\n");
        //~ get_grbl_response();
        //~ uart_puts_P("G2 X25 Y25 I10\n");
        //~ get_grbl_response();
        //~ uart_puts_P("G0 Z1\n");
        //~ get_grbl_response();
        //~ uart_puts_P("G0 X35 Y15\n");
        //~ get_grbl_response();
        //~ uart_puts_P("G1 Z-1\n");
        //~ get_grbl_response();
        //~ uart_puts_P("G2 X25 Y5 I-10\n");
        //~ get_grbl_response();
        //~ uart_puts_P("G0 Z1\n");
        //~ get_grbl_response();
        //~ uart_puts_P("G0 X15 Y15\n");
        //~ get_grbl_response();
        //~ uart_puts_P("M5\n");
        //~ get_grbl_response();
        //~ uart_puts_P("M30\n");
*/
int main(void)
{
  stdout = &mystdout;
  //uart_init(UART_BAUD_SELECT_DOUBLE_SPEED(UART_BAUD_RATE,F_CPU));
  uart_init(UART_BAUD_SELECT(UART_BAUD_RATE,F_CPU));
  lcd_init(LCD_DISP_ON_CURSOR);
  lcd_clrscr();
  lcd_gotoxy(0,0);
  lcd_puts_P("Needler v0.7\n");
  lcd_gotoxy(0,1);
  lcd_puts_P(__DATE__" aw");

  //Delay for Splash
  for(uint8_t i=0;i<160;++i)
    _delay_ms(15);

  //PD2: IN : Z_DIR
  //PD3: IN : Enable/FEED HOLD. 0=betätigt
  //PD6: OUT: Relais Pneumatikventil. 1=EIN
  DDRD  |= _BV(PD6);
  PORTD |= _BV(PD2) | _BV(PD3) | _BV(PD4) | _BV(PD5) | _BV(PD7);

  //PB1: IN: Z_STEP
  PORTB |= _BV(PB1);

  lcd_clrscr();
  clr_text_buffer();
  strncpy(font_name,"rowmans",10);

  /*** TIMER0 ***/
  OCR0=250;
  //CTC = Clear Timer on Compare match S.80
  //Normal port operation, OC0 disconnected
  //Prescaler=64 -> clk=250kHz
  TCCR0 = _BV(WGM01) | _BV(CS01) | _BV(CS00);
  //On Compare match Interrupt Enable for timer 0
  TIMSK |= _BV(OCIE0);

  /** TIMER1 **/
  //PWM Phase correct 10bit
  //Set OC1A+OC1B on match when upcounting (page 108)
  //TCCR1A = _BV(COM1A1) | _BV(COM1B1) | _BV(COM1A0) | _BV(COM1B0) | _BV(WGM11) | _BV(WGM10);
  //Prescaler = 1 (page 110)
  //TCCR1B = _BV(CS10);

  /** TIMER1 **/
  //External clock source on T1 pin. Clock on rising edge.
  TCCR1B = _BV(CS12) | _BV(CS11) | _BV(CS10);
  //OCR1x=5;

  /** External Interrupt INT0 PD2 **/
  //Any logical change on INT0 generates an interrupt request.
  MCUCR = _BV(ISC00);
  GICR = _BV (INT0);

  //enable global interrupts
  sei();
  uint8_t debounce_key=0, last_key=0;
  uint8_t key, event=0;
  for (;;)    /* main event loop */
    {
      key=key_get();
      if(key==last_key)
        debounce_key++;
      else
        debounce_key=0;
      if(debounce_key>50)
      {
        event=process_menu(key);
        debounce_key=0;
      }
      last_key=key;

      if(do_update_lcd || event)
      {
        update_lcd();
        do_update_lcd=0;
      }

      if (bit_is_clear(PIND,3) && !running)
      {
        grbl_num_err=0;
        grbl_num_ok=0;
        //empty read
        while(uart_getc()!=UART_NO_DATA);
        running=1;
        update_status_lcd();
        uart_puts_P("$X\n");
        get_grbl_response();
        strncpy(grbl_error_msg, "$H:Referenzfahrt",17);
        update_status_lcd();
        uart_puts_P("$H\n");
        get_grbl_response();
        strncpy(grbl_error_msg, "Gravur laeuft...",17);
        update_status_lcd();

       //int init_get_gcode_line ( char *font, char *text, double X0, double Y0, double Z_up, double Z_down, double yinc, double scale,
       //double feed, int precision, char verbose, char align, char use_inch);

        //int r = init_get_gcode_line("rowmans", "Hello world!", 1, 1, 1, -1, 7, 0.3, 1100, 3, 0, 'l', 0);
        uint8_t line_nr;
        double scale=font_size*0.047619;
        double x0, y0;
        char line[BUFFER_WIDTH];
        for(line_nr=0; line_nr<BUFFER_HEIGHT; line_nr++)
        {
          strncpy(line, get_text_buffer(line_nr), BUFFER_WIDTH);
          //Leerzeichen am Ende mit 0 füllen
          int8_t len = BUFFER_WIDTH-1;
          while(len>=0 && line[len]==' ') line[len--]=0;

          //Positionsberechnung
          //Die Alukärtchen haben 85x54mm
          x0 = 7; //10mm vorerst fix, wie einstellbar?
          y0 = 50 - (line_nr+1) * (font_size*1.7);  //70% der Zeichenhöhe als Zeilenabstand

          //~ uart_puts_P("-");
          //~ uart_puts(line);
          //~ uart_puts_P("-");
          //~ char xtemp[5];
          //~ itoa(len,xtemp,10);
          //~ uart_puts(xtemp);
          //~ uart_puts_P("----");

          if(len>=0)
          {
            init_get_gcode_line(font_name, line, x0, y0, 1, -1, 0, scale, 1300, 2, 0, 'l', 0);
            char buf[200];
            while((g_line = get_gcode_line (buf, 200))!=-1)
            {
              uart_puts(buf);
              uart_putc('\n');
              get_grbl_response();
            }
          }
        }
        strncpy(grbl_error_msg, "*** BEENDET  ***",17);
        update_status_lcd();
        PORTD &= (uint8_t) ~_BV(PD6);
        uart_puts_P("G0X1Y1\n");
        uart_puts_P("M30\n");
        //empty read
        while(uart_getc()!=UART_NO_DATA);
        //BEENDET etwas stehen lassen
        for(uint8_t i=0;i<200;++i)
          _delay_ms(10);
        grbl_error_msg[0]=0;
        do_update_lcd=1;
        running=0;
      }
    }
    return 0;
}
コード例 #14
0
ファイル: menu_popup.c プロジェクト: Hendryputra/atinomba
void menu_OK(unsigned char p, unsigned char mesin, unsigned char jok)
{
	unsigned int key_press;
	unsigned char key_index=0;
	unsigned char mesin_index=0;
	int i;
	int jum_aktif=0;
	int loop;
	unsigned char terus;
	
	//menu_pilih(p, mesin);
	if (p == 7 && jok == 1)
	{	
		// cari jumlah sumber aktif
		for (i=0; i<JML_SUMBER; i++)
		{
			if (sumber[i].status == 1) jum_aktif++;
		}
		
		key_index = 0;
		
		for (;;)
		{
			if(cek_keypad())
			{
				cls_layar();
				// cek tombol apa yang ditekan
				key_press = (FIO1PIN & KEY_DAT);
				
				if (key_press == ATAS)
				{
					key_index--;

					if (key_index == 255) key_index = (jum_aktif-1);
				}
				else if ( key_press == BAWAH )
				{
					key_index++;	
					if (key_index > (jum_aktif-1)) key_index = 0;
				}
				else if ( key_press == OK)
				{
					//jum_OK++;	
				}
				else if ( key_press == CANCEL)
				{
					//jum_OK--;
					return;	
				}
				
				menu_monita(7);
				menu_pilih(7, mesin, 0);
				//kotak(68, 25+(9*key_index), 300, 35+(9*key_index));
				data_sumber(1, key_index);
				update_lcd();
				loop = 0;
			}
			vTaskDelay(100);
			
			loop++;
			if (loop > 5)
			{
				loop = 0;
				cls_layar();
				menu_monita(7);
				menu_pilih(7, mesin, 0);
				data_sumber(1, key_index);
				update_lcd();	
			}
		}
	}
	
	/* menu titik */
	else if (p == 8 && jok == 1)
	{
		key_index = 0;
		terus = 0;
		jum_aktif = 15;
		
		for (;;)
		{
			if(cek_keypad())
			{
				cls_layar();
				// cek tombol apa yang ditekan
				key_press = (FIO1PIN & KEY_DAT);
				
				if (key_press == ATAS)
				{
					if (terus < 15)
						key_index--;
					
					terus--;
					if (terus == 255)
					{
						terus = TIAP_MESIN-1;	
						key_index = (jum_aktif-1);
					}
					
					//if (key_index == 255) key_index = (jum_aktif-1);
				}
				else if ( key_press == BAWAH )
				{
					key_index++;	
					terus++;
					
					if (terus > (TIAP_MESIN -1))
					{
						terus = 0;
						key_index = 0;	
					}
					//if (key_index > (jum_aktif-1)) key_index = 0;
					if (key_index > (jum_aktif-1)) key_index--;
				}
				else if ( key_press == OK)
				{
					//jum_OK++;	
				}
				else if ( key_press == CANCEL)
				{
					//jum_OK--;
					return;	
				}
				
				menu_monita(8);
				menu_pilih(8, mesin, terus);
				kotak(68, 36+(9*key_index), 312, 46+(9*key_index));
				//data_sumber(1, key_index);
				update_lcd();
				loop = 0;
			}
			vTaskDelay(100);
		}	
	}
}
コード例 #15
0
ファイル: lcdgps.c プロジェクト: elfchief/gpsd
int main(int argc, char *argv[])
{
    int option, rc;
    struct sockaddr_in localAddr, servAddr;
    struct hostent *h;

    int n;
    for(n=0;n<CLIMB;n++) climb[n]=0.0;

    switch (gpsd_units())
    {
    case imperial:
	altfactor = METERS_TO_FEET;
	altunits = "ft";
	speedfactor = MPS_TO_MPH;
	speedunits = "mph";
	break;
    case nautical:
	altfactor = METERS_TO_FEET;
	altunits = "ft";
	speedfactor = MPS_TO_KNOTS;
	speedunits = "knots";
	break;
    case metric:
	altfactor = 1;
	altunits = "m";
	speedfactor = MPS_TO_KPH;
	speedunits = "kph";
	break;
    default:
	/* leave the default alone */
	break;
    }

    /* Process the options.  Print help if requested. */
    while ((option = getopt(argc, argv, "Vhl:su:")) != -1) {
	switch (option) {
	case 'V':
	    (void)fprintf(stderr, "lcdgs revision " REVISION "\n");
	    exit(EXIT_SUCCESS);
	case 'h':
	default:
	    usage(argv[0]);
	    break;
	case 'l':
	    switch ( optarg[0] ) {
	    case 'd':
		deg_type = deg_dd;
		continue;
	    case 'm':
		deg_type = deg_ddmm;
		continue;
	    case 's':
		deg_type = deg_ddmmss;
		continue;
	    default:
		(void)fprintf(stderr, "Unknown -l argument: %s\n", optarg);
	    }
	    break;
	case 's':
	    sleep(10);
	    continue;
	case 'u':
	    switch ( optarg[0] ) {
	    case 'i':
		altfactor = METERS_TO_FEET;
		altunits = "ft";
		speedfactor = MPS_TO_MPH;
		speedunits = "mph";
		continue;
	    case 'n':
		altfactor = METERS_TO_FEET;
		altunits = "ft";
		speedfactor = MPS_TO_KNOTS;
		speedunits = "knots";
		continue;
	    case 'm':
		altfactor = 1;
		altunits = "m";
		speedfactor = MPS_TO_KPH;
		speedunits = "kph";
		continue;
	    default:
		(void)fprintf(stderr, "Unknown -u argument: %s\n", optarg);
	    }
	}
    }

    /* Grok the server, port, and device. */
  if (optind < argc) {
      gpsd_source_spec(argv[optind], &source);
  } else
      gpsd_source_spec(NULL, &source);

    /* Daemonize... */
  if (daemon(0, 0) != 0)
      (void)fprintf(stderr,
		    "lcdgps: demonization failed: %s\n",
		    strerror(errno));

    /* Open the stream to gpsd. */
    if (gps_open(source.server, source.port, &gpsdata) != 0) {
	(void)fprintf( stderr,
		       "lcdgps: no gpsd running or network error: %d, %s\n",
		       errno, gps_errstr(errno));
	exit(EXIT_FAILURE);
    }

    /* Connect to LCDd */
    h = gethostbyname(LCDDHOST);
    if (h==NULL) {
	printf("%s: unknown host '%s'\n",argv[0],LCDDHOST);
	exit(EXIT_FAILURE);
    }

    servAddr.sin_family = h->h_addrtype;
    memcpy((char *) &servAddr.sin_addr.s_addr, h->h_addr_list[0], h->h_length);
    servAddr.sin_port = htons(LCDDPORT);

    /* create socket */
    sd = socket(AF_INET, SOCK_STREAM, 0);
    if (BAD_SOCKET(sd)) {
	perror("cannot open socket ");
	exit(EXIT_FAILURE);
    }

    /* bind any port number */
    localAddr.sin_family = AF_INET;
    localAddr.sin_addr.s_addr = htonl(INADDR_ANY);
    localAddr.sin_port = htons(0);

    /* coverity[uninit_use_in_call] */
    rc = bind(sd, (struct sockaddr *) &localAddr, sizeof(localAddr));
    if (rc == -1) {
	printf("%s: cannot bind port TCP %u\n",argv[0],LCDDPORT);
	perror("error ");
	exit(EXIT_FAILURE);
    }

    /* connect to server */
    /* coverity[uninit_use_in_call] */
    rc = connect(sd, (struct sockaddr *) &servAddr, sizeof(servAddr));
    if (rc == -1) {
	perror("cannot connect ");
	exit(EXIT_FAILURE);
    }

    /* Do the initial field label setup. */
    reset_lcd();

    /* Here's where updates go. */
    unsigned int flags = WATCH_ENABLE;
    if (source.device != NULL)
	flags |= WATCH_DEVICE;
    (void)gps_stream(&gpsdata, flags, source.device);

    for (;;) { /* heart of the client */
	if (!gps_waiting(&gpsdata, 50000000)) {
	    fprintf( stderr, "lcdgps: error while waiting\n");
	    exit(EXIT_FAILURE);
	} else {
	    (void)gps_read(&gpsdata);
	    update_lcd(&gpsdata);
	}

    }
}
コード例 #16
0
ファイル: testpwm.c プロジェクト: rsi7/ECE_544_project1
int main() {

	XStatus 		status;
	u16				sw, oldSw =0xFFFF;				// 0xFFFF is invalid --> makes sure the PWM freq is updated 1st time
	int				rotcnt, oldRotcnt = 0x1000;	
	bool			done = false;
	bool 			hw_switch = 0;
	
	init_platform();

	// initialize devices and set up interrupts, etc.

	status = do_init();
	
	if (status != XST_SUCCESS) 	{

		PMDIO_LCD_setcursor(1,0);
		PMDIO_LCD_wrstring("****** ERROR *******");
		PMDIO_LCD_setcursor(2,0);
		PMDIO_LCD_wrstring("INIT FAILED- EXITING");
		exit(XST_FAILURE);
	}
	
	// initialize the global variables

	timestamp = 0;							
	pwm_freq = INITIAL_FREQUENCY;
	pwm_duty = INITIAL_DUTY_CYCLE;
	clkfit = 0;
	new_perduty = false;
	
	// start the PWM timer and kick of the processing by enabling the Microblaze interrupt

	PWM_SetParams(&PWMTimerInst, pwm_freq, pwm_duty);	
	PWM_Start(&PWMTimerInst);
	microblaze_enable_interrupts();
	
	// display the greeting   

	PMDIO_LCD_setcursor(1,0);
	PMDIO_LCD_wrstring("ECE544 Project 1");
	PMDIO_LCD_setcursor(2,0);
	PMDIO_LCD_wrstring(" by Rehan Iqbal ");
	NX4IO_setLEDs(0x0000FFFF);
	delay_msecs(2000);
	NX4IO_setLEDs(0x00000000);
		
   // write the static text to the display

	PMDIO_LCD_clrd();
	PMDIO_LCD_setcursor(1,0);
	PMDIO_LCD_wrstring("G|FR:    DCY:  %");
	PMDIO_LCD_setcursor(2,0);
	PMDIO_LCD_wrstring("D|FR:    DCY:  %");

	// turn off the LEDs and clear the seven segment display

	NX4IO_setLEDs(0x00000000);
	NX410_SSEG_setAllDigits(SSEGLO, CC_BLANK, CC_BLANK, CC_BLANK, CC_BLANK, DP_NONE);
	NX410_SSEG_setAllDigits(SSEGHI, CC_BLANK, CC_BLANK, CC_BLANK, CC_BLANK, DP_NONE);
	  
	// main loop

	do	{ 
		
		// check rotary encoder pushbutton to see if it's time to quit
		
		if (PMDIO_ROT_isBtnPressed()) {
			done = true;
		}

		else {
			
			new_perduty = false;
			
			// get the switches and mask out all but the switches that determine the PWM timer frequency
			
			sw &= PWM_FREQ_MSK;
			sw = NX4IO_getSwitches();
			
			if (sw != oldSw) {	 
				
				// check the status of sw[2:0] and assign appropriate PWM output frequency

				switch (sw & 0x07) {
					
					case 0x00:	pwm_freq = PWM_FREQ_100HZ;	break;
					case 0x01:	pwm_freq = PWM_FREQ_1KHZ;	break;
					case 0x02:	pwm_freq = PWM_FREQ_10KHZ;	break;
					case 0x03:	pwm_freq = PWM_FREQ_50KHZ;	break;
					case 0x04:	pwm_freq = PWM_FREQ_100KHZ;	break;
					case 0x05:	pwm_freq = PWM_FREQ_500KHZ;	break;
					case 0x06:	pwm_freq = PWM_FREQ_1MHZ;	break;
					case 0x07:	pwm_freq = PWM_FREQ_5MHZ;	break;

				}
				
				// check the status of sw[3] and assign to global variable

				hw_switch = (sw & 0x08);

				// update global variable indicating there are new changes

				oldSw = sw;
				new_perduty = true;
			}
		
			// read rotary count and handle duty cycle changes
			// limit duty cycle to 0% to 99%
			
			PMDIO_ROT_readRotcnt(&rotcnt);

			if (rotcnt != oldRotcnt) {
				
				// show the rotary count in hex on the seven segment display
				
				NX4IO_SSEG_putU16Hex(SSEGLO, rotcnt);

				// change the duty cycle
				
				pwm_duty = MAX(1, MIN(rotcnt, 99));
				oldRotcnt = rotcnt;
				new_perduty = true;
			}

			// update generated frequency and duty cycle	
			
			if (new_perduty) {
				
				u32 			freq, 
								dutycycle;

				unsigned int 	detect_freq = 0x00;
				unsigned int 	detect_duty = 0x00;
			
				// set the new PWM parameters - PWM_SetParams stops the timer
				
				status = PWM_SetParams(&PWMTimerInst, pwm_freq, pwm_duty);
				
				if (status == XST_SUCCESS) {
					
					PWM_GetParams(&PWMTimerInst, &freq, &dutycycle);

					update_lcd(freq, dutycycle, 1);

					// check if sw[3] is high or low (HWDET / SWDET)
					// pass functions different args depending on which mode is selected

					if (hw_switch) {

						detect_freq = calc_freq(hw_high_count, hw_low_count, hw_switch);
						detect_duty = calc_duty(hw_high_count, hw_low_count);
					}

					else {

						detect_freq = calc_freq(sw_high_count, sw_low_count, hw_switch);
						detect_duty = calc_duty(sw_high_count, sw_low_count);
					}

					// update the LCD display with detected frequency & duty cycle

					update_lcd(detect_freq, detect_duty, 2);
										
					PWM_Start(&PWMTimerInst);
				}
			}
		}

	} while (!done);
	
	// wait until rotary encoder button is released	

	do {
		delay_msecs(10);
	} while (PMDIO_ROT_isBtnPressed());

	// we're done,  say goodbye

	xil_printf("\nThat's All Folks!\n\n");
	
	PMDIO_LCD_setcursor(1,0);
	PMDIO_LCD_wrstring("That's All Folks");
	PMDIO_LCD_setcursor(2,0);
	PMDIO_LCD_wrstring("                ");
	
	NX410_SSEG_setAllDigits(SSEGHI, CC_BLANK, CC_B, CC_LCY, CC_E, DP_NONE);
	NX410_SSEG_setAllDigits(SSEGLO, CC_B, CC_LCY, CC_E, CC_BLANK, DP_NONE);

	delay_msecs(5000);

	// turn the lights out

	PMDIO_LCD_clrd();
	NX410_SSEG_setAllDigits(SSEGHI, CC_BLANK, CC_BLANK, CC_BLANK, CC_BLANK, DP_NONE);
	NX410_SSEG_setAllDigits(SSEGLO, CC_BLANK, CC_BLANK, CC_BLANK, CC_BLANK, DP_NONE);

	NX4IO_RGBLED_setDutyCycle(RGB1, 0, 0, 0);
	NX4IO_RGBLED_setChnlEn(RGB1, false, false, false);

	// exit gracefully

	cleanup_platform();

	exit(0);
}
コード例 #17
0
ファイル: testpwm.c プロジェクト: rhodeser/cockroach-sunset
int main()
{
	XStatus 	Status;
	u32			btnsw, old_btnsw = 0x000000FF;
	int			rotcnt, old_rotcnt = 0x1000;	
	bool		done = false;
	
	// initialize devices and set up interrupts, etc.
 	Status = do_init();
 	if (Status != XST_SUCCESS)
 	{
 		LCD_setcursor(1,0);
 		LCD_wrstring("****** ERROR *******");
 		LCD_setcursor(2,0);
 		LCD_wrstring("INIT FAILED- EXITING");
 		exit(XST_FAILURE);
 	}
 	
	// initialize the global variables
	timestamp = 0;							
	pwm_freq = INITIAL_FREQUENCY;
	pwm_duty = INITIAL_DUTY_CYCLE;
	clkfit = 0;
	new_perduty = false;
    
	// start the PWM timer and kick of the processing by enabling the Microblaze interrupt
	PWM_SetParams(&PWMTimerInst, pwm_freq, pwm_duty);	
	PWM_Start(&PWMTimerInst);
    microblaze_enable_interrupts();
    
	// display the greeting   
    LCD_setcursor(1,0);
    LCD_wrstring(" PWM LIB TEST R0");
	LCD_setcursor(2,0);
	LCD_wrstring(" by Roy Kravitz ");
	NX3_writeleds(0x000000FF);
	delay_msecs(2000);
	NX3_writeleds(0x00000000);
		
   // write the static text to the display
    LCD_clrd();
    LCD_setcursor(1,0);
    LCD_wrstring("G|FR:    DCY:  %");
    LCD_setcursor(2,0);
    LCD_wrstring("Vavg:           ");
      
    // main loop
	do
	{ 
		// check rotary encoder pushbutton to see if it's time to quit
		NX3_readBtnSw(&btnsw);
		if (btnsw & msk_BTN_ROT)
		{
			done = true;
		}
		else
		{
			new_perduty = false;				
			if (btnsw != old_btnsw)
			{	 
				switch (btnsw & PWM_FREQ_MSK)
				{
					case 0x00:	pwm_freq = PWM_FREQ_10HZ;	break;
					case 0x01:	pwm_freq = PWM_FREQ_100HZ;	break;
					case 0x02:	pwm_freq = PWM_FREQ_1KHZ;	break;
					case 0x03:	pwm_freq = PWM_FREQ_10KHZ;	break;
                                        case 0x04: 	pwm_freq = PWM_FREQ_50KHZ;	break;
                                        case 0x05: 	pwm_freq = PWM_FREQ_100KHZ;	break;
                                        case 0x06: 	pwm_freq = PWM_FREQ_150KHZ;	break;
                                        case 0x07: 	pwm_freq = PWM_FREQ_200KHZ;	break;
				}
				old_btnsw = btnsw;
				new_perduty = true;
			}
		
			// read rotary count and handle duty cycle changes
			// limit duty cycle to 0% to 99%
			ROT_readRotcnt(&rotcnt);
			if (rotcnt != old_rotcnt)
			{
				pwm_duty = MAX(0, MIN(rotcnt, 99));
				old_rotcnt = rotcnt;
				new_perduty = true;
			}

			// update generated frequency and duty cycle	
			if (new_perduty)
			{
				u32 freq, dutycycle;
				float vavg;
				char	s[10];
			
				// set the new PWM parameters - PWM_SetParams stops the timer
				Status = PWM_SetParams(&PWMTimerInst, pwm_freq, pwm_duty);
				if (Status == XST_SUCCESS)
				{
					PWM_GetParams(&PWMTimerInst, &freq, &dutycycle);
					update_lcd(freq, dutycycle, 1);
					vavg = dutycycle * .01 * 3.3;
					voltstostrng(vavg, s);
					LCD_setcursor(2,5);
					LCD_wrstring(s); 
										
					PWM_Start(&PWMTimerInst);
				}
			}
		}			
	} while (!done);
	
	// wait until rotary encoder button is released		
	do
	{
		NX3_readBtnSw(&btnsw);
		delay_msecs(10);
	} while ((btnsw & msk_BTN_ROT) == 0x80);

	// and say goodbye
	LCD_clrd();
	LCD_wrstring("That's all folks");
	delay_msecs(2000);
	LCD_clrd();
	exit(XST_SUCCESS);
 }
コード例 #18
0
void kotak_pesan(void)
{
kotak3d(0, 198, 318, 238);
update_lcd();
}
コード例 #19
0
ファイル: main.c プロジェクト: bgbock/rdmp
  int main (void)
  {
  init_hw();
  LCD_init();
  keys_init();
  number_pointer = 0;
  number[number_pointer] = 0;
  main_substate = 0;
  //main_state = STATE_IDLE;
  main_state = STATE_INIT;
  //main_substate = 2;
  while (1)
  	{
//  	dly_ms(NORMAL_CYCLE_MS);
  	if (main_state==STATE_INIT)
  		{
  		f_gsm_ok = 0;
  		if (main_substate==0)
  			{
  	  		update_lcd("Init...");
  			uart_sendstr("AT\r\nAT\r\n");
  			main_state=STATE_INIT_W;
  			}
  		if (main_substate==1)
  			{
  	  		if (number_pointer>0)
  	  			update_lcd(number);
  	  		else
  	  			update_lcd("PIN?");
			if (keys_handling(&key))
				{
				if (key<10)
					{
					number[number_pointer++] = key + '0';
					number[number_pointer]=0;
					}
				if (key==KEY_YES)
					{
					f_gsm_ok = 0;
					main_state=STATE_WFCALL;
					uart_sendstr("AT+CPIN=");
					uart_sendstr(number);
					uart_sendstr("\r\n");
					main_state=STATE_INIT_W;
					update_lcd("PIN...");
					number_pointer = 0;
					number[number_pointer] = 0;
					}
				if (key==KEY_NO)
					{
					number_pointer = 0;
					number[number_pointer] = 0;
					}
				}
  			}
  		if (main_substate==2)
  			{
  			update_lcd("PIN OK");
  			uart_sendstr("AT+CLVL=100\r\n");
  			main_state=STATE_INIT_W;
  			}
  		if (main_substate==3)
  			{
  			update_lcd("S1 OK");
  			uart_sendstr("AT+CALM=0\r\n");
  			main_state=STATE_INIT_W;
  			}
  		if (main_substate==4)
  			{
  			update_lcd("S2 OK");
  			uart_sendstr("AT+IPR=38400\r\n");
  			main_state=STATE_INIT_W;
  			}
  		if (main_substate==5)
  			{
  			update_lcd("Network...");
  			if (f_gsm_cr)
  				main_state = STATE_IDLE;
  			}
  		}

  	if (main_state==STATE_INIT_W)
  		{
  		if (f_gsm_ok==1)
  			{
  			f_gsm_ok = 0;
  			main_state=STATE_INIT;
  			main_substate++;
  			}
  		}

  	if (main_state==STATE_IDLE)
  		{
  		if (f_gsm_ring)
  			{
  			f_gsm_ring=0;
  			main_state=STATE_WFINCALL;
  			}
  		if (number_pointer>0)
  			update_lcd(number);
  		else
  			update_lcd("Ready");
  		if (keys_handling(&key))
  			{
  			if (key<10)
  				{
  				number[number_pointer++] = key + '0';
  				number[number_pointer]=0;
  				}
  			if (key==KEY_YES)
  				{
  				f_gsm_ok = 0;
  				main_state=STATE_WFCALL;
  				uart_sendstr("ATD");
  				uart_sendstr(number);
  				uart_sendstr(";\r\n");
  				}
  			if (key==KEY_NO)
  				{
  				number_pointer = 0;
  				number[number_pointer] = 0;
  				}
  			}
  		}

  	if (main_state==STATE_WFCALL)
  		{
  		update_lcd("Wait");
		if (f_gsm_ok==1)
  			{
  			f_gsm_ok = 0;
  			main_state=STATE_CALLING;
  			}
  		}

  	if (main_state==STATE_CALLING)
  		{
  		update_lcd("Calling");
  		if (f_gsm_nc)
  			{
  			f_gsm_nc = 0;
  			main_state=STATE_IDLE;
  			}
  		if (keys_handling(&key))
  			{
  			if (key==KEY_YES)
  				{
  				}
  			if (key==KEY_NO)
  				{
  				f_gsm_ok = 0;
  				uart_sendstr("ATH\r\n");
  				main_state=STATE_WFECALL;
  				}
  			}
  		}
  	if (main_state==STATE_WFECALL)
  		{
  		update_lcd("Ending");
  		if (f_gsm_ok==1)
  			{
  			f_gsm_ok = 0;
  			main_state=STATE_IDLE;
  			}
  		}

  	if (main_state==STATE_WFINCALL)
  		{
  		update_lcd("RING");
  		if (f_gsm_nc)
  			{
  			f_gsm_nc = 0;
                          f_gsm_ring = 0;
  			main_state=STATE_IDLE;
  			}
  		if (keys_handling(&key))
  			{
  			if (key==KEY_YES)
  				{
  				f_gsm_ok = 0;
  				uart_sendstr("ATA\r\n");
  				main_state=STATE_WFAINCALL;
  				}
  			if (key==KEY_NO)
  				{
  				f_gsm_ok = 0;
  				uart_sendstr("ATH\r\n");
  				main_state=STATE_WFEINCALL;
  				}
  			}
  		}

  	if (main_state==STATE_WFEINCALL)
  		{
  		update_lcd("Ending");
  		if (f_gsm_ok==1)
  			{
  			f_gsm_ok = 0;
  			main_state=STATE_IDLE;
  			}
  		}

  	if (main_state==STATE_WFAINCALL)
  		{
  		update_lcd("Wait");
  		if (f_gsm_ok==1)
  			{
  			f_gsm_ok = 0;
  			main_state=STATE_INCALL;
  			}
  		}

  	if (main_state==STATE_INCALL)
  		{
  		update_lcd("Incall");
  		if (f_gsm_nc)
  			{
  			f_gsm_nc = 0;
  			main_state=STATE_IDLE;
  			}
  		if (keys_handling(&key))
  			{
  			if (key==KEY_NO)
  				{
  				f_gsm_ok = 0;
                                  f_gsm_ring = 0;
  				uart_sendstr("ATH\r\n");
  				main_state=STATE_WFEINCALL;
  				}
  			}
  		}
  	}
  }
コード例 #20
0
ファイル: proj2.c プロジェクト: hngryhllw/proj2
int main () {
   XStatus status;
   // VARS : to hold user input stuff
   int      encoderCurn = 0x0000;
   int      encoderPrev = 0x1000;   
   int      PWMDutyGen = 50;
   bool     PWMGenUpdateFlag = false;
   u32      PWMFreqGenRead;
   u32      PWMDutyGenRead;

   /*u32      tsl235rHiTimePrev = 0;*/
   /*int      PWMCycTime;*/
   /*int      PWMFreqMeas;*/

   int      tsl235rFreqPrev = 0;


   // Initializations
   init_platform();
   status = init_axi_devices();
   if (status != XST_SUCCESS) errorExit();
   init_welcom();


   // SET : PWM generator begin, enable microblaze interrupts
   /*PWM_SetParams(&instPWMTimer, PWM_FREQ_005KHZ, PWMDutyGen);   */
   PWM_Start(&instPWMTimer);
   microblaze_enable_interrupts();

   init_feedback_system();
   
   while(1) {
      PWMGenUpdateFlag = false;

      // CHECK : Updates on ENCODER
      PMDIO_ROT_readRotcnt(&encoderCurn);
      if (encoderCurn != encoderPrev) {

         // SET seven-seg with encoder value
         NX4IO_SSEG_putU16Hex(SSEGLO, encoderCurn);

         PWMDutyGen = MAX(0, MIN(encoderCurn, 99));
         encoderPrev = encoderCurn;
         PWMGenUpdateFlag = true;
      }

      // SET : Update PWM Generator
      if (PWMGenUpdateFlag) {

         // set the new PWM parameters - PWM_SetParams stops the timer
         status = PWM_SetParams(&instPWMTimer, PWM_FREQ_005KHZ, PWMDutyGen);
         if (status != XST_SUCCESS) errorExit();

         // GET : read the PWM parameters back from the PWM generator
         PWM_GetParams(&instPWMTimer, &PWMFreqGenRead, &PWMDutyGenRead);
         update_lcd(PWMFreqGenRead, PWMDutyGenRead, 1);
         PWM_Start(&instPWMTimer);
      }

      /*if (tsl235rHiTimePrev != tsl235rHiTime) {*/
         /*PWMCycTime = (int) tsl235rHiTime * 2;*/
         /*PWMFreqMeas = 100000000 / PWMCycTime;*/
         /*update_lcd(PWMFreqMeas, 0, 2);*/

         /*tsl235rHiTimePrev = tsl235rHiTime;*/
      /*}*/
      if (tsl235rFreqPrev != tsl235rFreq) {
         update_lcd(tsl235rFreq, 50, 2);

         tsl235rFreq = tsl235rFreqPrev;
      }

   }
   
}