Exemplo n.º 1
0
int UI::courseSelect(){
	int course = -1;

	display_goto_xy(4, 1);

	while(1){
		if(ecrobot_is_RUN_button_pressed()){
			course = course * (-1);

			if(course == 1){
				display_string(" IN COURSE");
				display_goto_xy(4, 1);
			}
			else{
				display_string("OUT COURSE");
				display_goto_xy(4, 1);
			}
		}		

		if(ecrobot_is_ENTER_button_pressed()){
			display_goto_xy(6, 3);
			display_string("READY");
			break;
		}
		
		display_update();
		
		// 500msecウェイトする
		systick_wait_ms(500); 	
	}

	display_update();

	return course;
}
Exemplo n.º 2
0
int main() {
	bool newreadings;
	bool buttonschanged;

	load_init();
	initsystem();
	watchdog_init();
	initserial();
	timer_init();
	display_init();
	initfan();
	adc_init();

	buttons_init();

	enableInterrupts();

	protocol_onbooted();

	while (1) {
		watchdog_kick();
		newreadings = adc_updatereadings();
		if (newreadings) {
			checkstate();
		}
		buttonschanged = buttons_check();
		if (newreadings || buttonschanged) {
			protocol_sendstate();
			display_update();
		}

		protocol_checkcommand();
	}
}
Exemplo n.º 3
0
// *************************************************************************************************
// @fn          main
// @brief       Main routine
// @param       none
// @return      none
// *************************************************************************************************
int main(void)
{
#ifdef EMU
	emu_init();
#endif
	// Init MCU 
	init_application();

	// Assign initial value to global variables
	init_global_variables();

#ifdef CONFIG_TEST
	// Branch to welcome screen
	test_mode();
#else
	display_all_off();
#endif
	
	// Main control loop: wait in low power mode until some event needs to be processed
	while(1)
	{
		// When idle go to LPM3
    	idle_loop();

    	// Process wake-up events
    	if (button.all_flags || sys.all_flags) wakeup_event();
    	
    	// Process actions requested by logic modules
    	if (request.all_flags) process_requests();
    	
    	// Before going to LPM3, update display
    	if (display.all_flags) display_update();	
 	}	
}
Exemplo n.º 4
0
/* This function is called repetitively from the main program */
void labwork( void )
{
  delay( 1000 );

  time2string( textstring, mytime );
  display_string( 3, textstring );
  display_update();

  getbtns();

  if (getbtns() == 1)
    mytime += (getsw() << 4);
  
  if (getbtns() == 2)
    mytime += (getsw() << 8);

  if (getbtns() == 4)
    mytime += (getsw() << 12);


  volatile int* porte = (volatile int*) 0xbf886110;
  tick( &mytime );
  *porte += 1;
  display_image(96, icon);
}
Exemplo n.º 5
0
int main(void) {
	/* Set up peripheral bus clock */
        /* OSCCONbits.PBDIV = 1; */
        OSCCONCLR = 0x100000; /* clear PBDIV bit 1 */
	OSCCONSET = 0x080000; /* set PBDIV bit 0 */
	
	/* Set up output pins */
	AD1PCFG = 0xFFFF;
	ODCE = 0x0;
	TRISECLR = 0xFF;
	PORTE = 0x0;
	
	/* Output pins for display signals */
	PORTF = 0xFFFF;
	PORTG = (1 << 9);
	ODCF = 0x0;
	ODCG = 0x0;
	TRISFCLR = 0x70;
	TRISGCLR = 0x200;
	
	/* Set up input pins */
	TRISDSET = (1 << 8);
	TRISFSET = (1 << 1);
	
	/* Set up SPI as master */
	SPI2CON = 0;
	SPI2BRG = 4;
	/* SPI2STAT bit SPIROV = 0; */
	SPI2STATCLR = 0x40;
	/* SPI2CON bit CKP = 1; */
        SPI2CONSET = 0x40;
	/* SPI2CON bit MSTEN = 1; */
	SPI2CONSET = 0x20;
	/* SPI2CON bit ON = 1; */
	SPI2CONSET = 0x8000;
	int i,c,k;
	display_init();
	display_update();
	for(i = 0;i<3;i++){
		display_frommatrix(disco);
		
		for(c = 0;c<1000;c++){
		quicksleep(10000);
		}
		display_frommatrixinv(tetris);
		for(k = 0;k<1000;k++){
		quicksleep(10000);
		}
	}
	
	
	
	labinit(); /* Do any lab-specific initialization */
	
	while(1)
	{
	  labwork(); /* Do lab-specific things again and again */
	}
	return 0;
}
Exemplo n.º 6
0
/* Interrupt Service Routine */
void user_isr( void )
{
	/*T2IF = IFS0 8
	T2IE = IEC0 8
	T2IP = IPC2 26-28
	T2IS = IPC2 24/25
	*/
	//if interrupt clear T2IF and timer counter
	if(IFS(0) & 0x100){
	IFSCLR(0) = 0x100;
	TMR2 = 0;
	if(timeoutcount < 9){
		timeoutcount++;
	}else{
		//print on screen once a second
		timeoutcount = 0;
		time2string(textstring, mytime);
		display_string(3, textstring);
		display_update();
		tick(&mytime);
		//*portE += 1;
		//display_image(96, icon);
	}
}

	if(IFS(0) & 0x8000){
		IFSCLR(0) = 0x8000;
		*portE += 1;
	}
}
Exemplo n.º 7
0
void display_refresh(display_t *d, frame_geometry_t *g)
{
  if ( d == NULL )
    return;
  display_update(d, g);
  display_redraw(d, g->x, g->y, g->width, g->height);
}
Exemplo n.º 8
0
void __nxtAssert(const char *file, int line, const char *exp)
{
	display_clear(0);
	display_goto_xy(0, 0);
	display_string("assert");
	display_goto_xy(0, 1);
	display_string("File: ");
	display_string(file);
	display_goto_xy(0, 2);
	display_string("Line: ");
	display_int(line,0);
	display_goto_xy(0, 3);
	display_string(exp);
	display_update();

#ifdef NXT_WARN_ASSERT
	display_goto_xy(0, 3);
	display_string("Press ENTER");
#endif
	while(true)
	{
#ifdef NXT_WARN_ASSERT
		if(ecrobot_is_ENTER_button_pressed())
		{
			display_clear(0);
			display_goto_xy(0, 0);
			return;
		}
#endif
	}
}
Exemplo n.º 9
0
int main(void)
{
  uart_init();
  shift_init();
  timer_init();
  display_init();
  keypad_init();
  serial_init();
  edit_init();
  clock_init();
  watchdog_init(WDTO_15MS, &oops);

  sei();  // enable interrupts

  printf("\r\n*** BOOTED ***\r\nSpaceTime, yay!\r\n");

  timer_beep(10);

  while(1)
  {
    display_update();

    serial_update();

    edit_update();

    clock_update();
  }
}
Exemplo n.º 10
0
/* This function is called repetitively from the main program */
void labwork( void )
{
  
  prime = nextprime ( prime );
  display_string ( 0, itoaconv( prime ));
  display_update();
}
void display_show_string(char* string,int x,int y){

	display_goto_xy(x, y);
	display_string(string);
	display_update();
	
}
/* Interrupt Service Routine */
void user_isr( void ) {

  // check flag
  if(IFS(0) & 0x100){
    // clearing flag
    IFS(0) = 0;
    timeoutcount++;

    if (timeoutcount == 10){
      time2string( textstring, mytime );
      display_string( 3, textstring );
      display_update();
      tick( &mytime );
      timeoutcount = 0;
    }
  }
    
  // code for counting LED
  if(IFS(0) & 0x80){
    // clearing flag
    IFS(0) = 0;
    // for LEDs ticking
    * portE =  * portE + 0x1;
    // only for the last 8 bits
    * E = * E & 0xFF00;
  }

  return;
}
Exemplo n.º 13
0
static int solve_sudoku_algorithm_1(void)
{
  int x, y, solution, found;

  /* Go through all cells in the table and find a possible "only" solution. */
  /* Do this multiple times, until no more solutions are found or table full. */
  do {
    found = 0; /* Will be overwritten if something is found. */
    for (y = 0; y < 9; y++) {
      for (x = 0; x < 9; x++) {
        if (sudoku[y][x] > 0)
          continue;
        solution = find_only_solution(y, x);
        if (solution > 0) {
          sudoku[y][x] = solution;
          display_update("Solving...");
          usleep(10000);
          found++;
        }
      }
    }
    if (table_full())
      break;
  } while (found > 0);

  if (! table_full()) 
    return -1;

  return 0;
}
Exemplo n.º 14
0
// 入力を待つ
void UI::waitStart(float angle){
	while(1){
		tail->control(angle);
		if(touchSensor->isPressed()){
			display_goto_xy(6, 5);
			display_string("GO !!");
			display_update();
			break;
		}
		if(blueTooth->isReceived() == 1){
			display_goto_xy(6, 5);
			display_string("GO !!");
			display_update();
			break;
		}
	}
}
Exemplo n.º 15
0
void show(int distance)
{
	display_goto_xy(0, 0);
	display_string("DISTANCE :");
	display_goto_xy(0, 1);
	display_unsigned(distance,10);
	display_update();
}
Exemplo n.º 16
0
void disp(int row, char *str, int val)
{ 
	if (row == 0) display_clear(0);
	display_goto_xy(0, row);
	display_string(str);
	display_int(val, 0);
	if (row == 7) display_update();
}
Exemplo n.º 17
0
void display_set(int x, int y, bool value)
{
	if (!display_inited)
		return;
	
	display_screen[x][y] = value;
	display_update(x, y);
}
Exemplo n.º 18
0
void display_toggle(int x, int y)
{
	if (!display_inited)
		return;
	
	display_screen[x][y] ^= 1;
	display_update(x, y);
}
Exemplo n.º 19
0
void update_devices(struct memory* m, uint64_t cycles) {
  if (m->devices[DEVICE_DISPLAY])
    display_update(m->devices[DEVICE_DISPLAY], cycles);
  if (m->devices[DEVICE_TIMER])
    timer_update(m->devices[DEVICE_TIMER], cycles);
  if (m->devices[DEVICE_INPUT])
    input_update(m->devices[DEVICE_INPUT], cycles);
}
Exemplo n.º 20
0
void myPrintln(const char *s)
{
	static int y = 0;
	display_goto_xy(0,y);
	display_string(s);
	display_update();
y++;
}
Exemplo n.º 21
0
// -----------------------------------------------------------------------
void startup_anim()
{
	uint8_t v = 0b11110000;
	
	for (int8_t i=7 ; i>=0 ; i--) {
		display_col(0, (v>>i) & 0x0f);
		display_update();
		_delay_ms(40);
	}
}
Exemplo n.º 22
0
int recieveint_rs485(int *value)
{
	totalBytesRead += ecrobot_read_rs485(raw, totalBytesRead, (INT_SIZE+1) - totalBytesRead);
	if (totalBytesRead != (INT_SIZE+1))
		return 0;

	crc_t crcRecieved = (crc_t)raw[0];

	U8 rawInt[INT_SIZE];
	rawInt[0] = raw[1];
	rawInt[1] = raw[2];
	rawInt[2] = raw[3];
	rawInt[3] = raw[4];

	crc_t crc;
    crc = crc_init();
    crc = crc_update(crc, (unsigned char *)rawInt, INT_SIZE);
    crc = crc_finalize(crc);

    if (crc != crcRecieved)
    {
    	print_str(0,0,"CRC errors = ");
    	display_int(++crc_errors, 0);
    	display_update();

    	//We reboot the network interface
    	ecrobot_term_rs485();
    	ecrobot_init_rs485(NETWORK_SPEED);

    	totalBytesRead = 0;
    	return 0;
    }

    // We convert the raw bytes to an int
    *value = 0;
    for (int i = INT_SIZE-1; i > -1 ; i--)
    {
       int temp = 0;
       temp += rawInt[i];
       temp <<= (8 * i);

       *value += temp;
    }


	totalBytesRead = 0;

//	print_clear_line(5);
//	display_update();
//	display_goto_xy(0,5);
//	display_int(*value, 0);
//	display_update();

	return 1;
}
Exemplo n.º 23
0
//*****************************************************************************
// 関数名 : calibration
// 引数 : *black (黒、最小値),*white(白、最大値)
// 返り値 : 無し
// 概要 : 光センサの手動キャリブレーション
//        黒白の順でタッチする。
//*****************************************************************************
void calibration(int *black,int *white,int angle)
{
	while(1) {
		tail_control(angle);

		if (ecrobot_get_touch_sensor(NXT_PORT_S4) == 1) {
			ecrobot_sound_tone(440, 170, 100);
			*black = ecrobot_get_light_sensor(NXT_PORT_S3);
			display_clear(0);		/* 画面表示 */
			display_goto_xy(0, 1);
			display_string("BLACK:");
			display_int(*black, 4);
			break;
		}//if
		systick_wait_ms(100); /* 10msecウェイト */
	}//while
	display_update();
	while(ecrobot_get_touch_sensor(NXT_PORT_S4));
	ecrobot_sound_tone(880, 170, 100);

	while(1) {
		tail_control(angle);
		if (ecrobot_get_touch_sensor(NXT_PORT_S4) == 1) {
			ecrobot_sound_tone(880, 170, 100);
			*white = ecrobot_get_light_sensor(NXT_PORT_S3);
			//display_clear(0);		/* 画面表示 */
			display_goto_xy(0, 2);
			display_string("WHITE:");
			display_int(*white, 4);
			break;
		}//if
		systick_wait_ms(100); /* 10msecウェイト */
	}//while

	//display_clear(0);		/* 画面表示 */
	display_goto_xy(0,4);
	display_string("TH:");
	display_int(TH(*black,*white), 3);
	display_update();
	while(ecrobot_get_touch_sensor(NXT_PORT_S4));
	ecrobot_sound_tone(440, 170, 100);
}
Exemplo n.º 24
0
int main(void) {
	/* Set up peripheral bus clock */
        /* OSCCONbits.PBDIV = 1; */
  /*OSCCONCLR = 0x100000; /* clear PBDIV bit 1 */
	OSCCONSET = 0x080000; /* set PBDIV bit 0 */

	/* Set up output pins */
	AD1PCFG = 0xFFFF;
	ODCE = 0x0;
	TRISECLR = 0xFF;
	PORTE = 0x0;

	/* Output pins for display signals */
	PORTF = 0xFFFF;
	PORTG = (1 << 9);
	ODCF = 0x0;
	ODCG = 0x0;
	TRISFCLR = 0x70;
	TRISGCLR = 0x200;

	/* Set up input pins */
	TRISDSET = (1 << 8);
	TRISFSET = (1 << 1);

	/* Set up SPI as master */
	SPI2CON = 0;
	SPI2BRG = 4;
	/* SPI2STAT bit SPIROV = 0; */
	SPI2STATCLR = 0x40;
	/* SPI2CON bit CKP = 1; */
        SPI2CONSET = 0x40;
	/* SPI2CON bit MSTEN = 1; */
	SPI2CONSET = 0x20;
	/* SPI2CON bit ON = 1; */
	SPI2CONSET = 0x8000;

	display_init();
	display_string(0, "Vi är så bra!!!");
	display_string(1, "Det löser sig!");
	display_string(2, ":)");
	display_string(3, "Kämpa!");
	display_update();

	display_image(96, icon);

	labinit(); /* Do any lab-specific initialization */

	while( 1 )
	{
	  labwork(); /* Do lab-specific things again and again */
	}
	return 0;
}
Exemplo n.º 25
0
void display_currentNode(){
	//display_clear(1);
	display_goto_xy(5,6);
	display_int((int)previousNode[0],1);
	display_goto_xy(8,6);
	display_int((int)previousNode[1],1);
	display_goto_xy(6,5);
	display_int(directionOffset,1);
	display_goto_xy(6,7);
	display_int((int)mazeStorage[previousNode[0]][previousNode[1]],1);
	display_update();
}
Exemplo n.º 26
0
/* Interrupt Service Routine */
void user_isr( void ) {

    timeoutcounter++;
    IFS(0) = 0;
    if(timeoutcounter % 10 == 0) {
        time2string( textstring, mytime );
        display_string( 3, textstring );
        display_update();
        tick( &mytime );
    }

}
Exemplo n.º 27
0
int main(void)
{
    WDTCTL = WDTPW | WDTHOLD;

    /* configure P2.6 and P2.7 as XIN/XOUT function pins */
    P2DIR &= ~BIT6;
    P2DIR |= BIT7;
    P2SEL |= BIT7 | BIT6;

    /* 32kHz external crystal, XCAP = 12.5pF, clear LFXT1 osc fault */
    BCSCTL3 |= XCAP0 | XCAP1;
    BCSCTL3 &= ~(LFXT1S0 | LFXT1S1);

    /* enable ACLK function of P1.0 (32KHz clock output) */
    P1DIR |= BIT0;
    P1SEL |= BIT0;

    spi_init();

    /* to save space, since we do it in the interrupt anyway */
    P1DIR |= DISPLAY_SUPPLY;
    P1OUT |= DISPLAY_SUPPLY;

#if 0
    display_puts("MSP430", 0);
    display_puts("123456", 1);
#endif

    display_init(1);
    delay_ms(100);
    display_update(1);

    /* enable falling edge interrupt for BUSY1 of the display, which
     * becomes low when the display content has been updated */
    P1IE |= DISPLAY_BUSY1;
    P1IES |= DISPLAY_BUSY1;

    /* Timer A: input divider /8, ACLK clock source, UP mode */
    TACTL = ID_3 | TASSEL_1 | MC_3;

    /* enable the TACCR0 compare interrupt */
    TACCTL0 = CCIE;

    /* load TACCR0, starts timer. (32768Hz / 8) * 15 = 61440, so the
     * timer interrupt fires every 15 seconds */
    TACCR0 = 61440 - 1;

    /* enable global interrupts and enter LPM3 */
    _BIS_SR(LPM3_bits + GIE);

    while (1) { };
}
void print(const char* intern_message)
{
    static int y = 0;
	if(y == 8)
	{
		y = 0;
		display_clear(0);
	}
	display_goto_xy(0,y);
	display_string(intern_message);
	display_update();
	y++;	
}
Exemplo n.º 29
0
void display_prev_view()
{
    if (display_view == DISPLAY_VIEW_MAIN)
        display_view = _DISPLAY_VIEW_END;

    byte prev_view = static_cast<byte>(display_view) - 1;
    display_view = static_cast<display_view_type>(prev_view);

#ifdef SUPPORT_DISPLAY_BACKLIGHT
    enable_backlight();
#endif

    display_update();
}
Exemplo n.º 30
0
void display_next_view()
{
    // enums can't be incremented directly
    byte next_view = static_cast<byte>(display_view) + 1;
    display_view = static_cast<display_view_type>(next_view);

    if (display_view == _DISPLAY_VIEW_END)
        display_view = DISPLAY_VIEW_MAIN;

#ifdef SUPPORT_DISPLAY_BACKLIGHT
    enable_backlight();
#endif

    display_update();
}