/*lint -save  -e970 Disable MISRA rule (6.3) checking. */
int main(void)
/*lint -restore Enable MISRA rule (6.3) checking. */
{
	/* Write your local variable definition here */

	/*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/
 	PE_low_level_init();
	/*** End of Processor Expert internal initialization.                    ***/

	/* Write your code here */
	/* For example: for(;;) { } */

	Boot_Check();
	AD1_Calibrate(TRUE);
	OLED_Init();
	unsigned char buffer[64*4];
	ClearScr(buffer,0);
	OLED_Display(buffer);
	DecoderInit();
	int T = 0;
	for(;;) {
		T++;
		ClearScr(buffer,0);
		for (int x = 0;x<64;x++)
		{
			buffer[Reader.Sync * 64 + x] = 255;
		}

		if (Reader.Sync == AUDIOREADER_SYNCED)
		{
			for (int i =0;i<theprogress/8;i++)
			{
				buffer[i] = 0xff;
			}

		}
		//else
		{
			for(int i =0 ;i<64;i++)
			{
				int y =  16 + (((History[i]-32768) * 15)/400);
				if (y>= 0 && y< 32) SetPixel(buffer, i, y);
			}
		}
		OLED_Display(buffer);

	}
	/*** Don't write any code pass this line, or it will be deleted during code generation. ***/
  /*** RTOS startup code. Macro PEX_RTOS_START is defined by the RTOS component. DON'T MODIFY THIS CODE!!! ***/
  #ifdef PEX_RTOS_START
    PEX_RTOS_START();                  /* Startup of the selected RTOS. Macro is defined by the RTOS component. */
  #endif
  /*** End of RTOS startup code.  ***/
  /*** Processor Expert end of main routine. DON'T MODIFY THIS CODE!!! ***/
  for(;;){}
  /*** Processor Expert end of main routine. DON'T WRITE CODE BELOW!!! ***/
} /*** End of main routine. DO NOT MODIFY THIS TEXT!!! ***/
Exemple #2
0
void DrawScreen( void ) {
	u8 fontWidth;
	ClearScr();
	
	DrawFillRectangle( 0,57, 128, 64, LCD_PIXEL_ON);
	DrawText(1,58, "GPS v0.1 - joaquim.org", LCD_CHAR_INV);
}
Exemple #3
0
void DrawScreen( void ) {

	ClearScr();
	
	DrawRectangle( 0,8, DISPLAY_WIDTH - 1, DISPLAY_HEIGHT - 1, LCD_PIXEL_ON );
	DrawText(1,1, "STM8S Terminal - joaquim.org", LCD_PIXEL_ON);
	//curX = 2;
	//curY = 10;
}
/* 
 * 以240x320,8bpp的显示模式测试TFT LCD
 */
void Test_Lcd_Tft_8Bit_240320(void)
{
    Lcd_Port_Init();                     // 设置LCD引脚
    Tft_Lcd_Init(MODE_TFT_8BIT_240320);  // 初始化LCD控制器
    Lcd_PowerEnable(0, 1);               // 设置LCD_PWREN有效,它用于打开LCD的电源
    Lcd_EnvidOnOff(1);                   // 使能LCD控制器输出信号

    Lcd_Palette8Bit_Init();     // 初始化调色板
    ClearScr(0x0);              // 清屏
    printf("[TFT 64K COLOR(16bpp) LCD TEST]\n");

    printf("1. Press any key to draw line\n");
    getc();
    DrawLine(0  , 0  , 239, 0  , 0);    // 颜色为DEMO256pal[0]
    DrawLine(0  , 0  , 0  , 319, 1);    // 颜色为DEMO256pal[1]
    DrawLine(239, 0  , 239, 319, 2);    // ……
    DrawLine(0  , 319, 239, 319, 4);
    DrawLine(0  , 0  , 239, 319, 8);
    DrawLine(239, 0  , 0  , 319, 16);
    DrawLine(120, 0  , 120, 319, 32);
    DrawLine(0  , 160, 239, 160, 64);

    printf("2. Press any key to draw circles\n");
    getc();
    Mire();

    printf("3. Press any key to fill the screem with one color\n");
    getc();
    ClearScr(128);  //  输出单色图像,颜色为DEMO256pal[128]

    printf("4. Press any key to fill the screem by temporary palette\n");
    getc(); 
    ClearScrWithTmpPlt(0x0000ff);       //  输出单色图像,颜色为蓝色

    printf("5. Press any key to fill the screem by palette\n");
    getc();
    DisableTmpPlt();            // 关闭临时调色板寄存器
    ChangePalette(0xffff00);    // 改变整个调色板为黄色,输出单色图像
    
    printf("6. Press any key stop the testing\n");
    getc();
    Lcd_EnvidOnOff(0);
}
Exemple #5
0
int main()
{
	int parent_x, parent_y;
START:
	head = (psnakeHead)malloc(sizeof(snakeHead));
	head -> length = 0;
	head -> row = 14;
	head -> col = 14;
	head -> pbody = NULL;
	head -> headdirection = RIGHT;
	InitSnake(head);

    initscr();  
    raw();                  /* close row buffer */
    cbreak();               /* put termial to CBREAK mode */  
    noecho();  
    curs_set(FALSE);            /* set cursor invisible */  
    keypad(stdscr,TRUE);    /* recognise user's function key,F1,F2,...
							   display some message about title and wall */  
    signal(SIGALRM, StartAlarm);  
	getmaxyx(stdscr, parent_y, parent_x);
	WINDOW *welwin = newwin(29, parent_x, 0, 0);
	WINDOW *lelwin = newwin(7, parent_x, 30, 0);
	if (!welwin || !lelwin) {
		Die("Unable to allocate window memory\n");
	}
	Welcome(welwin, 29, parent_x);
	int speed = Choice(lelwin);
    Set_ticker(speed);  
	DrawWalls();
    StartAlarm();
    foodpos = DisplayFood(head);
    while(!isfailed && chinput !='q') {
        chinput = getch();
		ControlSnake(chinput, head);
    }
    if(isfailed) {
		ClearScr(LEFT_EDGE+1, RIGHT_EDGE-1, TOP_ROW+1, BUT_ROW-1);		//mark
		free(head -> pbody);
		free(head);
		head = NULL;
    }
    if(isrestart) {
        isfailed = 0;
        isrestart = 0;      // clear the flag
        goto START;    		// go to the START statement
    }
	endwin();
	return 0;
}
/* 
 * 以240x320,16bpp的显示模式测试TFT LCD
 */
void Test_Lcd_Tft_16Bit_240320(void)
{
    Lcd_Port_Init();                     // 设置LCD引脚
    Tft_Lcd_Init(MODE_TFT_16BIT_240320); // 初始化LCD控制器
    Lcd_PowerEnable(0, 1);               // 设置LCD_PWREN有效,它用于打开LCD的电源
    Lcd_EnvidOnOff(1);                   // 使能LCD控制器输出信号

    ClearScr(0x0);  // 清屏,黑色
    printf("[TFT 64K COLOR(16bpp) LCD TEST]\n");

    printf("1. Press any key to draw line\n");
    getc();
    DrawLine(0  , 0  , 239, 0  , 0xff0000);     // 红色
    DrawLine(0  , 0  , 0  , 319, 0x00ff00);     // 绿色
    DrawLine(239, 0  , 239, 319, 0x0000ff);     // 蓝色
    DrawLine(0  , 319, 239, 319, 0xffffff);     // 白色
    DrawLine(0  , 0  , 239, 319, 0xffff00);     // 黄色
    DrawLine(239, 0  , 0  , 319, 0x8000ff);     // 紫色
    DrawLine(120, 0  , 120, 319, 0xe6e8fa);     // 银色
    DrawLine(0  , 160, 239, 160, 0xcd7f32);     // 金色

    printf("2. Press any key to draw circles\n");
    getc();
    Mire();

    printf("3. Press any key to fill the screem with one color\n");
    getc();
    ClearScr(0xff0000);             // 红色

    printf("4. Press any key to fill the screem by temporary palette\n");
    getc();
    ClearScrWithTmpPlt(0x0000ff);   // 蓝色

    printf("5. Press any key stop the testing\n");
    getc();
    Lcd_EnvidOnOff(0);
}
Exemple #7
0
int DoMainMenu()
{
    int rtval = -1;
    char *pa = (char*) GraphicsDF->get("palette");

    PlayMusic("solution.s3m");
    
    DoneInteract();
    ClearScr();
    SetPalette(pa);
    MenuSnd = LoadSample("menu", FALSE);
    FlashSnd = LoadSample("flash", FALSE);

    while (rtval == -1) {
        rtval = ProcessMenu("mmnu0", "mmnu1");
        if (rtval == 0) /*new game*/ {
            rtval = ProcessMenu("mmnu2", "mmnu3"); // dificulty
            if (rtval == 3) {rtval = -1; continue;}
            switch (rtval) {
                case 0 : ActualDifficulty = 'e'; break;
                case 1 : ActualDifficulty = 'n'; break;
                case 2 : ActualDifficulty = 'h'; break;                
            }
            rtval = 0;
            break;
        }
    }

    FreeSample(MenuSnd);
    FreeSample(FlashSnd);
    ClearScr();
    SetPalette(Palette);
    InitInteract();
    memfree(pa);
    return rtval;
}
Exemple #8
0
void InitScr( void )
{
   int i; 

   CursorOff();

   ClearScr();

   for ( i = 1; i <= MAX_ROW; i++ ) {
      PutChar( i, MAX_COL + 1, '|' ); // write right side of grid
   }

   for ( i = 1; i < MAX_COL + 1; i++ ) {
      PutChar( MAX_ROW + 1, i, '-' ); // write bottom side of grid
   }
}
Exemple #9
0
void main(void)
{
    WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
    while(1)
    {
    InitializeLcm();
    _delay_cycles(1000);


    PrintStr("Hello World");
    SetCursorPos(1,0);    //Go to second line start
    _delay_cycles(100000);
    PrintNum(42);
    _delay_cycles(1000000);
    ClearScr();
    }

}
int main()
{
	char data[100];
	uart0_init(); 

    	uart0_init();   // 波特率115200,8N1(8个数据位,无校验位,1个停止位)
    	Lcd_Port_Init();                     // 设置LCD引脚
    	Tft_Lcd_Init(); // 初始化LCD控制器
    	Lcd_PowerEnable(0, 1);               // 设置LCD_PWREN有效,它用于打开LCD的电源
    	Lcd_EnvidOnOff(1);                   // 使能LCD控制器输出信号

    	ClearScr(50);  // 清屏,黑色ssssssssssssssssssssssssssssssssssssssss
    	VideoInit();	//setting font color and windwos size
    	printf_k("\n\rhao are you\n\r");
    	while (1) {
		memset(data, 0, sizeof(data));
		gets(data);
		puts(data);
		printf_k("%s\n\r", data);
	}
    
    return 0;
}
Exemple #11
0
static int ProcessMenu(const char *mask1, const char *mask2)
{
    void *bg = GraphicsDF->get("mmnulogo");
    byte *pt1 = (byte*) GraphicsI18nDF->get(mask1);
    byte *pt2 = (byte*) GraphicsI18nDF->get(mask2);
    int oldsel, sel = 0;
    TEvent e;


    DrawMN(pt1, pt2, bg, sel);
    while (TRUE) {
        GetEvent(&e);
        if (e.What == evMouseMove) {
            oldsel = sel;
            sel = (e.Mouse.Where.y - 290) / 60;
            if (sel < 0) sel = 0;
            if (sel > 3) sel = 3;
            if (sel != oldsel) {
                PlaySample(MenuSnd, 8, 32, 128);
                DrawMN(pt1, pt2, bg, sel);
            }
        }
        if (e.What == evMouseDown) {
            FlashPos = 130 + 180 * sel;
            Flash1st = TRUE;
            Flash();
            break;
        }
        if ((e.What == evKeyDown) && (e.Key.KeyCode == kbEsc)) {sel = 3; break;}
    }
    
    memfree(pt1);
    memfree(pt2);
    memfree(bg);
    ClearScr();
    return sel;
}
Exemple #12
0
int main( int argc, char* argv[] )
{

    char character;              // current character
    char str[40];                // general purpose string
    pid_t pids[26];              // child alphabet pids
    info_t *info_c;              // info_t for client
    info_t *info_c_m;            // info_t for client monitor
    info_t* infos[26];           // info_t for all alphabets
    sem_t *sem_video;            // video semaphore
    int finishing_place = 1;     // starting finish place
    char termination_cond = '<'; // the termination condition

    sprintf( video_key_str, "%d", getpid() );

    // create video semaphore
    sem_video = sem_open( video_key_str, O_CREAT, 0666, 1 );
    if ( sem_video == SEM_FAILED ) {
        perror( "server semaphore" );
        exit(1);
    }

    // request/allocate shared memory for client
    if( ( shmid_c = shmget( getpid()+32766, 
                sizeof( info_t ), IPC_CREAT|0666 ) ) < 0 ) {
        perror( "server shmget" );
        exit(1);
    }
    if( ( shmid_c_m = shmget( getpid()+32767, 
                sizeof( info_t ), IPC_CREAT|0666 ) ) < 0 ) {
        perror( "server shmget" );
        exit(1);
    }

    // attach to shared memory for client
    if( ( info_c = (info_t *)shmat( shmid_c, 0, 0 ) ) == (info_t *) -1 ) {
        perror( "server shmat" );
        exit(1);
    }
    if( ( info_c_m = (info_t *)shmat( shmid_c_m, 0, 0 ) ) == (info_t *) -1 ) {
        perror( "server shmat" );
        exit(1);
    }

    // set default alphabet character in client shared memory
    //   we'll use this to notice a change, signaling the client
    //   has made their choice and is ready to race
    info_c->alphabet = '*';
    info_c->row = shmid_c_m; // give the client the monitoring shmid num
    info_c->col = -1;
    info_c->o_col = -1;
    info_c->start = 0;
    info_c->finishing_place = -1;
    info_c->points = -1;
    strcpy( info_c->sem_video_str, video_key_str );

    // more defaults
    info_c_m->alphabet = '*';
    info_c_m->row = -1;
    info_c_m->col = -1;
    info_c_m->o_col = -1;
    info_c_m->start = 0;
    info_c_m->finishing_place = -1;
    info_c_m->points = -1;
    strcpy( info_c_m->sem_video_str, video_key_str );

    ClearScr( sem_video );

    // display client shared memory id so user can
    //   attach to the server
    printf( "From another shell, run client and pick winner.\n" );
    printf( "Syntax: './client %d'\n", shmid_c );

    // now setup the children alphabet process while waiting for client
    int i = 0;
    for ( character = 'A'; character <= 'Z'; character++ ) {
        if( ( shmids[i] = shmget( getpid()+32767+i, 
                sizeof( info_t ), IPC_CREAT|0666 ) ) < 0 ) {
            perror( "server shmget alphabet" );
            exit(1);
        }
 
        // attach to shared memory
        if ( ( infos[i] = (info_t *)shmat( shmids[i], 0, 0 ) ) 
                                == (info_t *) -1 ) {
            perror( "server shmat alphabet" );
            exit(1);
        }
        // set defaults
        infos[i]->alphabet = character;
        infos[i]->row = ((int)character - 64);
        infos[i]->col = 1; // default starting column
        infos[i]->o_col = -1; // there is no old column yet
        infos[i]->start = 0;  // don't start the race yet
        infos[i]->finishing_place = -1; // race has not started yet
        infos[i]->points = -1; // no points yet
        strcpy( infos[i]->sem_video_str, video_key_str );

        i++;
    }
    for ( i = 0; i < 26; i++ ) {
        sprintf( str, "%d", shmids[i] );
        pids[i] = fork();
        if ( pids[i] == -1 ) {
            perror( "server fork alphabet" );
            exit(1);
        }
        else if ( pids[i] == 0 ) { // in child process
            execl( "./alphabet", "alphabet", str, NULL );
        }
        i++;
        usleep( USEC );
    }

    // ensure we always cleanup
    atexit( exit_handler );

    while( info_c->alphabet == '*' ) {
        usleep( USEC );
    }

    printf( "\n    >>>>>> Client picked '%c' <<<<<<\n", info_c->alphabet );

    usleep( USEC * 6 );

    ClearScr( sem_video );
    InitScr( sem_video );

    // On your marks!
    usleep( USEC * 3 );
    // Get Set!
    usleep( USEC * 3 );
    // Go!
    for ( i = 0; i < 26; i++ ) {
        infos[i]->start = 1;
    }
    info_c->start = 1;

    // loop and display children updates
    //   also update client with new positions
    while ( 1 ) {
        int i;
        for ( i = 0; i < 26; i++ ) {
            PutChar( infos[i]->row, infos[i]->o_col, ' ', sem_video );
            PutChar( infos[i]->row, infos[i]->col, 
                            infos[i]->alphabet, sem_video );
            
            // update client monitor
            info_c_m->alphabet = infos[i]->alphabet;
            info_c_m->row = infos[i]->row;
            info_c_m->col = infos[i]->col;
            info_c_m->o_col = infos[i]->o_col;

            if ( infos[i]->col == MAX_COL ) {
                sem_wait( sem_video );
                sprintf( str, "\033[%d;%dH", infos[i]->alphabet - 64, 62 );
                write( OUT, str, strlen(str) );
                sprintf( str, "<-- %d", finishing_place );
                write( OUT, str, strlen(str) );
                if ( finishing_place <= 5 ) {
                    sprintf( str, "\033[%d;%dH", infos[i]->alphabet - 64, 68 );
                    write( OUT, str, strlen(str) );
                    sprintf( str, "%s", "***" );
                    write( OUT, str, strlen(str) );
                }
                sem_post( sem_video );
                infos[i]->finishing_place = finishing_place;
                infos[i]->points = 26 - finishing_place;
                // update client monitor
                info_c_m->finishing_place = infos[i]->finishing_place;
                info_c_m->points = infos[i]->points;
                finishing_place++;
            }
        }
        if ( finishing_place > 26 ) break;
    }

    // inform client race is over
    info_c_m->alphabet = termination_cond;

    // assign client their points
    info_c->points = infos[info_c->alphabet - 64]->points;

    FlashScr( sem_video );
    CursorOn( sem_video );
    printf( "Client points: %d\n", info_c->points );
    if ( info_c->points < 21 ) {
        printf( "Better luck next time!\n" );
    } else {
        printf( "Nice!\n" );
    }

    return 0; // normal return

}
Exemple #13
0
void ShowCredits()
{
    char *buf;
    char line[200];
    void *ptr, *ptr2;
    char *c;
    int i, curln, lastchar;
    int oldvol = MusicVolume;
    
    TEvent e;

    SetVolume(EffectsVolume, SpeechVolume, 64);
    MouseHide();
    ClearScr();
    PlayMusic("solution.s3m");


    do {GetEvent(&e);} while (e.What != evNothing);
    e.What = evNothing;
 
    ptr = memalloc(RES_X * RES_Y);
    memset(ptr, 0, 800*600);
    ptr2 = GraphicsDF->get("mmnulogo");
    memcpy(ptr, ptr2, 800 * 140);
    memfree(ptr2);

    buf = (char*) TextsDF->get("credits");
    ptr2 = memalloc(RES_X * RES_Y);
    memcpy(ptr2, ptr, RES_X * RES_Y);
    DrawPicture(ptr);

    for (curln = 520; TRUE; curln -= 1) {
        i = 0; line[0] = 0; lastchar = 0;
        for (c = buf; *c != 0; c++) {
            if (*c == '\n') {
                line[lastchar] = 0;
                if (strcmp(line, "END") == 0) break;
                i++;
                if (strlen(line) == 0) continue;
                if ((curln + 20 * i > 60) && (curln + 20 * i < 540)) 
                    PutStr(ptr, 800, 400 - GetStrWidth(line+1, NormalFont)/2,
                           curln + 20 * i, line+1, NormalFont, 
                           (line[0] == '*') ? 9/*red*/ : 2/*white*/, 0);
                line[0] = 0; lastchar = 0;
            }
            else line[lastchar++] = *c;                
        }
        PutBitmap(0, 220, ((char*)ptr) + 220 * 800, 800, 300);
        memcpy(ptr, ptr2, 800*600);
        SDL_Delay(20);

        GetEvent(&e);
        if ((e.What == evKeyDown) || (e.What == evMouseDown)) break;
    }

    memfree(ptr);
    memfree(ptr2);
    memfree(buf);
    MouseShow();
    ClearScr();
    SetVolume(EffectsVolume, SpeechVolume, oldvol);
}