Exemplo n.º 1
0
/// @brief Initialize TFT
/// @return diplay ID 9341
MEMSPACE
window *tft_init(void)
{
	// Start with slow clock so tft_readId works
	// This is the only function that fails at less then 1.
	// tft_readId is the ONLY SPI bus command that needs this.
	// Nomal reads work fine.
	tft_addr_init();
	tft_spi_init_slow();

	// reset display
	tft_reset_init();
    tft_reset_enable();
    tft_delay_us(10000);
    tft_reset_disable();
    tft_delay_us(1000);

	/* Adafruit 9341 TFT Display Initialization */
    tft_configRegister();

	/* Read the TFT ID value */
    tft_ID = tft_readId();

	// fast SPI
	tft_spi_init_fast();

	/* Setup the master window */
    tft_window_init(tft, TFT_XOFF, TFT_YOFF, TFT_W, TFT_H);
    tft_setRotation(0);
    tft_fillWin(tft, tft->bg);

    return (tft);
}
Exemplo n.º 2
0
/// @brief Initialize TFT
/// @return diplay ID 9341
MEMSPACE
window *tft_init(void)
{
    TFT_RST_INIT;	// RESET PIN
    TFT_INIT;		// DATA/COMMAND
    TFT_CS_INIT;	// CHIP SELLECT
	hspi_cs_disable(TFT_CS_PIN);
	// TFT_CS_DISABLE;

	// Start with slow clock so tft_readId works
	// This is the only function that fails at less then 1.
	// tft_readId is the ONLY SPI bus command that needs this.
	// Nomal reads work fine.
	tft_spi_init(2);
    TFT_RST_ACTIVE;	
    os_delay_us(10000);
    TFT_RST_DEACTIVE;
    os_delay_us(1000);

	/* Adafruit 9341 TFT Display Initialization */
    tft_configRegister();

	/* Read the TFT ID value */
    tft_ID = tft_readId();

	// fast SPI
	tft_spi_init(1);

	/* Setup the master window */
    tft_window_init(tft, TFT_XOFF, TFT_YOFF, TFT_W, TFT_H);
    tft_setRotation(0);
    tft_fillWin(tft, tft->bg);

    return (tft);
}
Exemplo n.º 3
0
int main(int argc, char** argv) {
    PT_setup();
    
	// Enable multivector interrupts
    INTEnableSystemMultiVectoredInt();
	// Initialize threads
    PT_INIT(&pt_cap);
    
    
    PT_INIT(&pt_blink);
    PT_INIT(&pt_cap_read)
    
    //init the display
    tft_init_hw();
    tft_begin();
    tft_fillScreen(ILI9340_BLACK);
    
	// Set orientation of the display
    tft_setRotation(1);
	
	// Set up pins
    PerPinSetup();
    while(1){
        PT_SCHEDULE(protothread_blink(&pt_blink));
        PT_SCHEDULE(protothread_cap(&pt_cap));
        PT_SCHEDULE(protothread_cap_read(&pt_cap_read));
    }
  
}
Exemplo n.º 4
0
//===================== Main ======================= //
void main(void) {
    SYSTEMConfig( SYS_FREQ,  SYS_CFG_WAIT_STATES | SYS_CFG_PCACHE);

    ANSELA = 0; ANSELB = 0; CM1CON = 0; CM2CON = 0;

    PT_setup();
    INTEnableSystemMultiVectoredInt();

    
    // initialize the threads
    PT_INIT(&pt_blink);
    PT_INIT(&pt_capture);
    
    // initialize the display
    tft_init_hw();
    tft_begin();
    tft_fillScreen(ILI9340_BLACK);

    tft_setRotation(0); //240x320 vertical display

    // initialize the comparator
    CMP1Open(CMP_ENABLE | CMP_OUTPUT_ENABLE | CMP1_NEG_INPUT_IVREF);
    
    // initialize the timer2
    OpenTimer2(T2_ON | T2_SOURCE_INT | T2_PS_1_64, 0xffffffff);

    // initialize the input capture, uses timer2
    OpenCapture1( IC_EVERY_RISE_EDGE | IC_FEDGE_RISE | IC_INT_1CAPTURE | IC_TIMER2_SRC | IC_ON);
    ConfigIntCapture1(IC_INT_ON | IC_INT_PRIOR_3 | IC_INT_SUB_PRIOR_3 );
    INTClearFlag(INT_IC1);

    // initialize the input/output I/O
    mPORTBSetPinsDigitalOut(BIT_3);
    mPORTBClearBits(BIT_3);
    PPSOutput(4, RPB9, C1OUT);		//set up output of comparator for debugging
    PPSInput(3, IC1, RPB13);		//Either Pin 6 or Pin 24 idk
   
    //round-robin scheduler for threads
    while(1) {
	PT_SCHEDULE(protothread_blink(&pt_blink));
	PT_SCHEDULE(protothread_capture(&pt_capture));
    }
    
} //main
Exemplo n.º 5
0
//===================== Main ======================= //
void main(void) {
    SYSTEMConfigPerformance(PBCLK);

    ANSELA = 0; ANSELB = 0; CM1CON = 0; CM2CON = 0;

    PT_setup();
    refreshRate = 10; //msec
    
    //Temporary Random Ball generator
    head = Ball_create(50, 50, 2, 0,  0, NULL);
    int i = 1;
    for(i = 1; i < 15; i++) {
        signed char troll1 = rand() % 5;
        signed char troll2 = rand() % 5;
        struct Ball *temp = Ball_create(i*10,i*10,troll1,troll2,0,NULL);
        temp->b = head;
        head = temp;
    }
        
    // initialize the threads
    PT_INIT(&pt_calculate);
    PT_INIT(&pt_refresh);
    // initialize the display
    tft_init_hw();
    tft_begin();
    tft_fillScreen(ILI9340_BLACK);
    
    INTEnableSystemMultiVectoredInt();

    tft_setRotation(0); //240x320 vertical display
  
    //round-robin scheduler for threads
    while(1) {
        PT_SCHEDULE(protothread_calculate(&pt_calculate));
        PT_SCHEDULE(protothread_refresh(&pt_refresh));
    }
    
} //main
Exemplo n.º 6
0
// === Main  ======================================================
void main(void) {
 SYSTEMConfigPerformance(PBCLK);
  
  ANSELA = 0; ANSELB = 0; CM1CON = 0; CM2CON = 0;

  // === config threads ==========
  // turns OFF UART support and debugger pin
  PT_setup();

  // === setup system wide interrupts  ========
  INTEnableSystemMultiVectoredInt();

  // init the threads
  PT_INIT(&pt_timer);
  PT_INIT(&pt_color);
  PT_INIT(&pt_anim);
  PT_INIT(&pt_key);

  // init the display
  tft_init_hw();
  tft_begin();
  tft_fillScreen(ILI9340_BLACK);
  //240x320 vertical display
  tft_setRotation(0); // Use tft_setRotation(1) for 320x240

  // seed random color
  srand(1);

  // round-robin scheduler for threads
  while (1){
      PT_SCHEDULE(protothread_timer(&pt_timer));
      PT_SCHEDULE(protothread_color(&pt_color));
      PT_SCHEDULE(protothread_anim(&pt_anim));
      PT_SCHEDULE(protothread_key(&pt_key));
      }
  } // main
Exemplo n.º 7
0
// === Main  ======================================================
void main(void) {
    //SYSTEMConfigPerformance(PBCLK);
    ANSELA = 0; ANSELB = 0; 
    // === config threads ==========
    // turns OFF UART support and debugger pin, unless defines are set
    PT_setup();
    // === setup system wide interrupts  ========
    INTEnableSystemMultiVectoredInt();
    CloseADC10();	// ensure the ADC is off before setting the configuration
    #define PARAM1  ADC_FORMAT_INTG16 | ADC_CLK_AUTO | ADC_AUTO_SAMPLING_OFF //
    // define setup parameters for OpenADC10
    // ADC ref external  | disable offset test | disable scan mode | do 1 sample | use single buf | alternate mode off
    #define PARAM2  ADC_VREF_AVDD_AVSS | ADC_OFFSET_CAL_DISABLE | ADC_SCAN_OFF | ADC_SAMPLES_PER_INT_1 | ADC_ALT_BUF_OFF | ADC_ALT_INPUT_OFF
    // Define setup parameters for OpenADC10
    // use peripherial bus clock | set sample time | set ADC clock divider
    // ADC_CONV_CLK_Tcy2 means divide CLK_PB by 2 (max speed)
    // ADC_SAMPLE_TIME_5 seems to work with a source resistance < 1kohm
    #define PARAM3 ADC_CONV_CLK_PB | ADC_SAMPLE_TIME_5 | ADC_CONV_CLK_Tcy2 //ADC_SAMPLE_TIME_15| ADC_CONV_CLK_Tcy2
    // define setup parameters for OpenADC10
    // set AN11 and  as analog inputs
    #define PARAM4	ENABLE_AN11_ANA // pin 24
    // define setup parameters for OpenADC10
    // do not assign channels to scan
    #define PARAM5	SKIP_SCAN_ALL
    // use ground as neg ref for A | use AN11 for input A     
    // configure to sample AN11 
    SetChanADC10( ADC_CH0_NEG_SAMPLEA_NVREF | ADC_CH0_POS_SAMPLEA_AN11 ); // configure to sample AN4 
    OpenADC10( PARAM1, PARAM2, PARAM3, PARAM4, PARAM5 ); // configure ADC using the parameters defined above
    EnableADC10(); // Enable the ADC      
    OpenTimer2(T2_ON | T2_SOURCE_INT | T2_PS_1_1, 400); 
    mPORTAClearBits(BIT_0 );		//Clear bits to ensure light is off.
    mPORTASetPinsDigitalOut(BIT_0 );    //Set port as output
    int CVRCON_setup;
    // set up the Vref pin and use as a DAC
    // enable module| eanble output | use low range output | use internal reference | desired step
    CVREFOpen( CVREF_ENABLE | CVREF_OUTPUT_ENABLE | CVREF_RANGE_LOW | CVREF_SOURCE_AVDD | CVREF_STEP_0 );
    // And read back setup from CVRCON for speed later
    // 0x8060 is enabled with output enabled, Vdd ref, and 0-0.6(Vdd) range
    CVRCON_setup = CVRCON; //CVRCON = 0x8060
	// Open the desired DMA channel.
	// We enable the AUTO option, we'll keep repeating the same transfer over and over.
	DmaChnOpen(dmaChn, 0, DMA_OPEN_AUTO);
	// set the transfer parameters: source & destination address, source & destination size, number of bytes per event
    // Setting the last parameter to one makes the DMA output one byte/interrut
    //DmaChnSetTxfer(dmaChn, sine_table, (void*) &CVRCON, sizeof(sine_table), 1, 1);
	// set the transfer event control: what event is to start the DMA transfer
    // In this case, timer2 
	DmaChnSetEventControl(dmaChn,  DMA_EV_START_IRQ(_TIMER_2_IRQ));
	// once we configured the DMA channel we can enable it
	// now it's ready and waiting for an event to occur...
	//DmaChnEnable(dmaChn);
  
    int i;
    for(i=0; i <256; i++){
        ball_scored[i] = 0x60|((unsigned char)((float)255/2*(sin(6.2832*(((float)i)/(float)256))+1))) ;
        //ball_lost[i]
       // game_over
    }

        
    // init the threads
    PT_INIT(&pt_timer);
    PT_INIT(&pt_adc);
    PT_INIT(&pt_launch);
    PT_INIT(&pt_anim);
    // init the display
    tft_init_hw();
    tft_begin();
    tft_fillScreen(ILI9340_BLACK);
    tft_setRotation(1); // Use tft_setRotation(1) for 320x240
    while (1){
        PT_SCHEDULE(protothread_timer(&pt_timer));
        PT_SCHEDULE(protothread_adc(&pt_adc));
        PT_SCHEDULE(protothread_launch_balls(&pt_launch));
        PT_SCHEDULE(protothread_anim_balls(&pt_anim));
    }
  } // main
Exemplo n.º 8
0
/**
 @brief main() Initialize user task
 @return void
*/
MEMSPACE 
void user_init(void)
{
	int i;
	os_event_t *handlerQueue;
    char time[20];
	int ret;
	uint16_t *ptr;
	uint32_t time1,time2;
	uint32_t ID;
	extern uint16_t tft_ID;
	double ang;

	os_delay_us(200000L);	// Power Up dalay - lets power supplies and devices settle

	// Configure the UART
	uart_init(BIT_RATE_115200,BIT_RATE_115200);

	DEBUG_PRINTF("\n");
	DEBUG_PRINTF("System init...\n");

	DEBUG_PRINTF("HSPI init...\n");
	hspi_init(1,0);

	DEBUG_PRINTF("Timers init...\n");
	init_timers();

	DEBUG_PRINTF("SD Card init...\n");
	mmc_init(1);

// CPU
// 160MHZ
//  REG_SET_BIT(0x3ff00014, BIT(0));
// 80MHZ
//   REG_CLR_BIT(0x3ff00014, BIT(0));


	DEBUG_PRINTF("Display Init\n");
	// Initialize TFT
	master = tft_init();
	ID = tft_ID;
	// Set master rotation
	tft_setRotation(1);

	/* Setup main status window */
	tft_window_init(winstats,0,0, master->w * 7 / 10, master->h/2);

	tft_setpos(winstats, 0,0);
	tft_set_font(winstats,5);
	tft_font_var(winstats);
	tft_setTextColor(winstats, ILI9341_RED,0);
	tft_printf(winstats, "DISP ID: %04lx\n", ID);
	ip_xpos = winstats->x;
	ip_ypos = winstats->y;
	tft_printf(winstats, "\n");
	tft_setTextColor(winstats, ILI9341_WHITE,0);
#if ILI9341_DEBUG & 1
	DEBUG_PRINTF("\nDisplay ID=%08lx\n",ID);
#endif
	tft_font_fixed(winstats);

	// Save last display offset of the status update line - used in the demo task
	xpos = winstats->x;
	ypos = winstats->y;

	/* Setup cube/wireframe demo window */
	tft_window_init(windemo,winstats->w,0, master->w - winstats->w, master->h/2);

// Cube points were defined with sides of 1.0 
// We want a scale of +/- w/2
	if(windemo->w < windemo->h) 
		dscale_max = windemo->w/2;
	else
		dscale_max = windemo->h/2;

	dscale = dscale_max;
	dscale_inc = dscale_max / 100;

/* Setup second window for window testing*/
	tft_window_init(wintest,0,master->h/2, master->w/2, master->h/2);
	tft_setTextColor(wintest, ILI9341_WHITE,ILI9341_NAVY);
    tft_fillWin(wintest, wintest->bg);
	tft_set_font(wintest,3);
	//tft_font_var(wintest);

	// write some text
	tft_setpos(wintest, 0,0);
	tft_printf(wintest, "Test1\nTest2\nTest3");

	/* Test demo area window */
	tft_window_init(wintestdemo,master->w/2,master->h/2,master->w/2, master->h/2);
	tft_setTextColor(wintestdemo, ILI9341_WHITE,0);
    tft_fillWin(wintestdemo, wintestdemo->bg);
	tft_set_font(wintestdemo,3);
	tft_font_var(wintestdemo);

#if ILI9341_DEBUG & 1
	DEBUG_PRINTF("Test Display Read\n");
	read_tests(wintest);
#endif

/* Draw cube in the second window as a test */
#if defined(WIRECUBE) && !defined(EARTH)
	DEBUG_PRINTF("Draw Cube\n");
// Cube points were defined with sides of 1.0 
// We want a scale of +/- w/2
	double tscale_max;
	if(wintestdemo->w < wintestdemo->h) 
		tscale_max = wintestdemo->w/2;
	else
		tscale_max = wintestdemo->h/2;
	ang = 45.0;
	V.x = ang;
	V.y = ang;
	V.z = ang;
	wire_draw(wintestdemo, cube_points, cube_edges, &V, wintestdemo->w/2, wintestdemo->h/2, tscale_max, ILI9341_RED);
#endif

#ifdef EARTH
	DEBUG_PRINTF("Draw Earth\n");
// Earth points were defined with radius of 0.5, diameter of 1.0
// We want a scale of +/- w/2
	double tscale_max;
	if(wintestdemo->w < wintestdemo->h) 
		tscale_max = wintestdemo->w;
	else
		tscale_max = wintestdemo->h;
	V.x = -90;
	V.y = -90;
	V.z = -90;
	// draw earth
	//time1 = system_get_time();
// Earth points were defined over with a scale of -0.5/+0.5 scale - so scale must be 1 or less
	wire_draw(wintestdemo, earth_data, NULL, &V, wintestdemo->w/2, wintestdemo->h/2, tscale_max, wintestdemo->fg);
	//time2 = system_get_time();
#endif

	wdt_reset();

	DEBUG_PRINTF("User Task\n");
	// Set up a timer to send the message to User Task
	os_timer_disarm(&UserTimerHandler);
	os_timer_setfn(&UserTimerHandler,(os_timer_func_t *)sendMsgToUserTask,(void *)0);
	os_timer_arm(&UserTimerHandler, USER_TASK_DELAY_TIMER, 1);
	// Setup the user task
	system_os_task(UserTask, UserTaskPrio, UserTaskQueue, UserTaskQueueLen);

#ifdef TELNET_SERIAL
	DEBUG_PRINTF("Setup Network Serial Bridge\n");
	bridge_task_init(23);
#endif

#ifdef NETWORK_TEST
	DEBUG_PRINTF("Setup Network TFT DIsplay Client\n");
	setup_networking(TCP_PORT);
#endif

#if 0
	// Misc Task init - testing only
	system_os_task(HighTask, HighTaskPrio, HighTaskQueue, HighTaskQueueLen);
	system_os_task(NormalTask, NormalTaskPrio, NormalTaskQueue, NormalTaskQueueLen);
	system_os_task(IdleTask, IdleTaskPrio, IdleTaskQueue, IdleTaskQueueLen);
	system_os_post(IdleTaskPrio, 0, 0);
#endif
	DEBUG_PRINTF("Done Setup\n");
    DEBUG_PRINTF("Heap Size(%d) bytes\n" , system_get_free_heap_size());

	// disable os_printf at this time
	system_set_os_print(0);

    system_init_done_cb(init_done_cb);
}
Exemplo n.º 9
0
setup_windows(int rotation, int debug)
{
	int16_t x,y,w,h;
	uint32_t ID;
	extern uint16_t tft_ID;
	ID = tft_ID;

	// Set master rotation
	tft_setRotation(rotation);
	tft_setTextColor(master, ILI9341_WHITE,ILI9341_BLUE);
	tft_fillWin(master, master->bg);

#if ILI9341_DEBUG & 1
		if(debug)
			printf("\nDisplay ID=%08lx\n",ID);
#endif

	// Message window setup
#ifdef EARTH
		w = master->w * 7 / 10;
#else
		w = master->w;
#endif
		// TOP
#ifdef DEBUG_STATS
		tft_window_init(wintop,0,0, w, font_H(0)*4);
		tft_setTextColor(wintop, ILI9341_WHITE, ILI9341_NAVY);
#else
		tft_window_init(wintop,0,0, w, font_H(2)*2);
		tft_setTextColor(wintop, ILI9341_WHITE, tft_RGBto565(0,64,255));
#endif
	tft_set_font(wintop,0);
	tft_font_var(wintop);
	tft_fillWin(wintop, wintop->bg);
	tft_set_textpos(wintop, 0,0);

#ifdef EARTH
		tft_window_init(winearth,w,0, master->w - w + 1, wintop->h);
		tft_setTextColor(winearth, ILI9341_WHITE, ILI9341_NAVY);
		tft_fillWin(winearth, winearth->bg);
#endif

	// BOTOM
	// TIME,DATE
	tft_window_init(winbottom, 0, master->h - 1 - font_H(2)*2, 
		master->w, font_H(2)*2);
	if(master->rotation & 1)
		tft_set_font(winbottom,2);
	else
		tft_set_font(winbottom,1);
	tft_font_var(winbottom);
	tft_setTextColor(winbottom, 0, tft_RGBto565(0,255,0));
	tft_fillWin(winbottom, winbottom->bg);
	tft_set_textpos(winbottom, 0,0);

	// Message window setup
#ifdef WIRECUBE
		w = master->w * 7 / 10;
#else
		w = master->w;
#endif

	// MSG
	tft_window_init(winmsg,0,wintop->h,
			w, master->h - (wintop->h + winbottom->h));

	tft_setTextColor(winmsg, ILI9341_WHITE,ILI9341_BLUE);
	tft_fillWin(winmsg, winmsg->bg);
	// write some text
	tft_set_font(winmsg,0);
	tft_font_var(winmsg);
	tft_set_textpos(winmsg, 0,0);

	// CUBE setup
#ifdef WIRECUBE
		/* Setup cube/wireframe demo window */
		/* This is to the right of the winmsg window and the same height */
		tft_window_init(wincube, winmsg->w, wintop->h, master->w - winmsg->w, winmsg->h);
		tft_setTextColor(wincube, ILI9341_WHITE,ILI9341_BLUE);
		tft_fillWin(wincube, wincube->bg);
#endif

#ifdef DEBUG_STATS
	if(debug)
	{
		// Display ID
		tft_setTextColor(winmsg, ILI9341_RED,winmsg->bg);
		tft_printf(winmsg, "DISP ID: %04lx\n", ID);
		tft_setTextColor(winmsg, ILI9341_WHITE,winmsg->bg);
#ifdef XPT2046
			if(!tft_is_calibrated)
			{
				tft_set_font(winmsg,0);
				tft_printf(winmsg,"Please Calibrate Display\n");
				tft_printf(winmsg,"serial command: calibrate N\n");
				tft_printf(winmsg,"N is rotation, 0..3\n");
				tft_printf(winmsg,"%d is current\n",master->rotation);
			}
#endif
	}
#endif


	// Cube points were defined with sides of 1.0 
	// We want a scale of +/- w/2
#ifdef WIRECUBE
		if(wincube->w < wincube->h) 
			dscale_max = wincube->w/2;
		else
			dscale_max = wincube->h/2;

		dscale = dscale_max;
		dscale_inc = dscale_max / 100;
#endif

#if ILI9341_DEBUG & 1
	if(debug)
	{
		printf("Test Display Read\n");
		read_tests(winmsg);
	}
#endif

	// Draw Wireframe earth in message area
#ifdef EARTH
	// Earth points were defined with radius of 0.5, diameter of 1.0
	// We want a scale of +/- w/2
		double tscale_max;
		if(winearth->w < winearth->h) 
			tscale_max = winearth->w;
		else
			tscale_max = winearth->h;
		V.x = -90;
		V.y = -90;
		V.z = -90;
		// draw earth
	// Earth points were defined over with a scale of -0.5/+0.5 scale - so scale must be 1 or less
		wire_draw(winearth, earth_data, NULL, &V, winearth->w/2, winearth->h/2, tscale_max, winearth->fg);
#endif

}
Exemplo n.º 10
0
/// @param[in] str: User supplied command line 
/// 
/// @return 1 The return code indicates a command matched.
/// @return 0 if no rules matched
MEMSPACE
int user_tests(int argc, char *argv[])
{

    char *ptr;
	time_t t;
	double freq;
	extern int connections;
	int ind;

	if(argc < 2)
		return(0);

	ind = 1;
    ptr = argv[ind++];


    if (MATCHARGS(ptr,"help", (ind+0),argc ))
    {
        user_help();
        return(1);
    }
#ifdef POSIX_TESTS
	if(posix_tests(argc,argv))
		return(1);
#endif
#ifdef FATFS_TESTS
	if(fatfs_tests(argc,argv))
		return(1);
#endif
#ifdef ADF4351
    if (MATCHARGS(ptr,"adf4351", (ind + 1) ,argc))
    {
		adf4351_cmd(argc,argv);
		return(1);
	}
#endif
    if (MATCHARGS(ptr,"setdate", (ind + 1) ,argc))
    {
        setdate_r(argv[ind++]);
        return(1);
    }
    if (MATCHARGS(ptr,"display_clock", (ind + 0) ,argc))
    {
        display_clock();
        return(1);
    }
    if (MATCHARGS(ptr,"time", (ind + 0) ,argc))
    {
		t = time(0);	
		printf("TIME:%s\n", ctime(&t));
        return(1);
	}
    if (MATCHARGS(ptr,"connection", (ind + 0) ,argc))
    {
		printf("connections:%d\n", connections);
        return(1);
	}
    if (MATCHARGS(ptr,"mem", (ind + 0) ,argc))
    {
		PrintRam();
        return(1);
	}
    if (MATCHARGS(ptr,"timetest", (ind + 1) ,argc))
    {
		timetests(argv[ind++],0);
        return(1);
	}
#ifdef DISPLAY
    if (MATCHARGS(ptr,"calibrate", (ind + 1) ,argc))
    {
		int ret = atoi(argv[ind++]);
		tft_setRotation(ret);
		tft_touch_calibrate(master);
		MatWrite("/tft_calX",tft_calX);
		MatWrite("/tft_calY",tft_calY);
		setup_windows(ret & 3,0);
        return(1);
    }
    if (MATCHARGS(ptr,"calibrate_test", (ind + 1) ,argc))
    {
		int ret = atoi(argv[ind++]);
		tft_setRotation(ret);
		tft_touch_calibrate(master);
		MatWrite("/tft_calX",tft_calX);
		MatWrite("/tft_calY",tft_calY);
		tft_map_test(master, 10);
		setup_windows(ret & 3,0);
        return(1);
    }
    if (MATCHARGS(ptr,"rotate", (ind + 1) ,argc))
    {
// FIXME rotate calibration data ???
		int ret = atoi(argv[ind++]);
		tft_setRotation(ret);
		setup_windows(ret & 3,0);
		return(1);
    }
#ifdef VFONTS
    if (MATCHARGS(ptr,"draw", (ind + 1) ,argc))
    {
		char *ptr = argv[ind++];
		int c = *ptr++;
		int n = *ptr++;
		if( n == '1')

			drawSVG(winmsg, 8, 24, c, 0.08, ILI9341_WHITE, 1);
		else
			drawSVG(winmsg, 8, 24, c, 0.08, ILI9341_WHITE, 0);
		return(1);
    }
#endif
    if (MATCHARGS(ptr,"pixel", (ind + 0) ,argc))
    {
		int c;
		int x,y;

		tft_drawPixel(winmsg, 8, 24, ILI9341_WHITE);
		for(y=24;y<26;++y)
		{
			for(x=8;x<10;++x)
			{
				c = tft_readPixel(winmsg, x, y);
				printf("pixel(%d,%d): %04x\n", x,y,c);
			}
		}
		return(1);
    }
#endif	//DISPLAY
	return(0);
}