//method to figure out what sound to play // === Timer Thread ================================================= static PT_THREAD (protothread_timer(struct pt *pt)) { PT_BEGIN(pt); tft_setCursor(100, 0); tft_setTextColor(ILI9340_WHITE); tft_setTextSize(1); tft_writeString("Elapsed time : \t Score"); while(1) { PT_YIELD_TIME_msec(1000) ; sys_time_seconds++ ; tft_fillRect(100, 10, 150, 8, ILI9340_BLACK);// x,y,w,h,radius,color tft_setCursor(100, 10); tft_setTextColor(ILI9340_YELLOW); tft_setTextSize(1); sprintf(buffer,"%*d %*d", 7, sys_time_seconds, 12, score); tft_writeString(buffer); tft_fillRect(175, 18, 2, 7, ILI9340_CYAN); tft_fillRect(248, 18, 2, 7, ILI9340_CYAN); tft_fillRect(175, 18, 75, 2, ILI9340_CYAN); tft_fillRect(175, 233, 2, 7, ILI9340_CYAN); tft_fillRect(248, 233, 2, 7, ILI9340_CYAN); tft_fillRect(175, 238, 75, 2, ILI9340_CYAN); if(score >= 50 && sys_time_seconds <= 60) { tft_setCursor(100, 90); tft_setTextColor(ILI9340_GREEN); tft_setTextSize(3); tft_writeString("You Win!"); } else if(score <= -50 || sys_time_seconds > 60) { tft_setCursor(100, 90); tft_setTextColor(ILI9340_RED); tft_setTextSize(3); tft_writeString("You Lose!"); } } PT_END(pt); } // timer thread
// === Color Thread ================================================= // draw 3 color patches for R,G,B from a random number //static int color ; //static int i; static PT_THREAD (protothread_color(struct pt *pt)) { PT_BEGIN(pt); static int color ; static int i; while(1) { // yield time 1 second PT_YIELD_TIME_msec(2000) ; // choose a random color color = rand() & 0xffff ; // draw color string tft_fillRoundRect(0,50, 150, 14, 1, ILI9340_BLACK);// x,y,w,h,radius,color tft_setCursor(0, 50); tft_setTextColor(ILI9340_WHITE); tft_setTextSize(1); sprintf(buffer," %04x %04x %04x %04x", color & 0x1f, color & 0x7e0, color & 0xf800, color); tft_writeString(buffer); // draw the actual color patches tft_fillRoundRect(5,70, 30, 30, 1, color & 0x1f);// x,y,w,h,radius,blues tft_fillRoundRect(40,70, 30, 30, 1, color & 0x7e0);// x,y,w,h,radius,greens tft_fillRoundRect(75,70, 30, 30, 1, color & 0xf800);// x,y,w,h,radius,reds // now draw the RGB mixed color tft_fillRoundRect(110,70, 30, 30, 1, color);// x,y,w,h,radius,mix color // NEVER exit while } // END WHILE(1) PT_END(pt); } // color thread
static PT_THREAD (protothread_key(struct pt *pt)) { PT_BEGIN(pt); static int keypad, i, pattern; // order is 0 thru 9 then * ==10 and # ==11 // no press = -1 // table is decoded to natural digit order (except for * and #) // 0x80 for col 1 ; 0x100 for col 2 ; 0x200 for col 3 // 0x01 for row 1 ; 0x02 for row 2; etc static int keytable[12]={0x108, 0x81, 0x101, 0x201, 0x82, 0x102, 0x202, 0x84, 0x104, 0x204, 0x88, 0x208}; // init the keypad pins A0-A3 and B7-B9 // PortA ports as digital outputs mPORTASetPinsDigitalOut(BIT_0 | BIT_1 | BIT_2 | BIT_3); //Set port as output // PortB as inputs mPORTBSetPinsDigitalIn(BIT_7 | BIT_8 | BIT_9); //Set port as input while(1) { // read each row sequentially mPORTAClearBits(BIT_0 | BIT_1 | BIT_2 | BIT_3); pattern = 1; mPORTASetBits(pattern); // yield time PT_YIELD_TIME_msec(30); //mPORTAClearBits(BIT_0 | BIT_1 | BIT_2 | BIT_3); //pattern = 1; mPORTASetBits(pattern); for (i=0; i<4; i++) { keypad = mPORTBReadBits(BIT_7 | BIT_8 | BIT_9); if(keypad!=0) {keypad |= pattern ; break;} mPORTAClearBits(pattern); pattern <<= 1; mPORTASetBits(pattern); } // search for keycode if (keypad > 0){ // then button is pushed for (i=0; i<12; i++){ if (keytable[i]==keypad) break; } } else i = -1; // no button pushed // draw key number tft_fillRoundRect(30,200, 100, 28, 1, ILI9340_BLACK);// x,y,w,h,radius,color tft_setCursor(30, 200); tft_setTextColor(ILI9340_YELLOW); tft_setTextSize(4); sprintf(buffer,"%d", i); if (i==10)sprintf(buffer,"*"); if (i==11)sprintf(buffer,"#"); tft_writeString(buffer); // NEVER exit while } // END WHILE(1) PT_END(pt); } // keypad thread
// === Timer Thread ================================================= // update a 1 second tick counter static PT_THREAD (protothread_timer(struct pt *pt)) { PT_BEGIN(pt); tft_setCursor(0, 0); tft_setTextColor(ILI9340_WHITE); tft_setTextSize(1); tft_writeString("Time in seconds since boot\n"); while(1) { // yield time 1 second PT_YIELD_TIME_msec(1000) ; sys_time_seconds++ ; // draw sys_time tft_fillRoundRect(0,10, 100, 14, 1, ILI9340_BLACK);// x,y,w,h,radius,color tft_setCursor(0, 10); tft_setTextColor(ILI9340_YELLOW); tft_setTextSize(2); sprintf(buffer,"%d", sys_time_seconds); tft_writeString(buffer); // NEVER exit while } // END WHILE(1) PT_END(pt); } // timer thread
// This thead displays the value of the capcitor if it is in the 1nF-100nF range // or diplays a message if the capacitor is out of range static PT_THREAD(protothread_cap_read(struct pt *pt)) { PT_BEGIN(pt); tft_setCursor(0,0); tft_setTextColor(ILI9340_WHITE); tft_setTextSize(2); tft_writeString("Measuring capacitance:"); while(1) { tft_setCursor(0,30); tft_setTextColor(ILI9340_YELLOW); tft_setTextSize(2); if (capacitance < 1 || capacitance > 99) { tft_fillRoundRect(0,30, 320, 40, 1, ILI9340_BLACK);// x,y,w,h,radius,color tft_writeString("Capacitor out of range!"); } else { tft_fillRoundRect(0,30, 320, 40, 1, ILI9340_BLACK);// x,y,w,h,radius,color sprintf(buffer, "%4.1f nF", capacitance); tft_writeString(buffer); } PT_YIELD_TIME_msec(200); } PT_END(pt); }
static PT_THREAD(protothread_anim(struct pt *pt)) { // runs the LCD and updates around 5/second PT_BEGIN(pt); //write to screen tft_fillRect(0,0, 50, 50, ILI9340_BLACK);//write black over previous message tft_setCursor(0, 0); tft_setTextColor(ILI9340_WHITE); tft_setTextSize(1);//smallest size sprintf(buffer,"%s%d", "time since startup:\n", PT_GET_TIME()/1000 ); tft_writeString(buffer); PT_YIELD_TIME_msec(30); PT_END(pt); } // animation thread
//===================== Capture ==================== // // Discharges capacitor, displays and begins measurement of C1INA static PT_THREAD (protothread_capture(struct pt *pt)) { PT_BEGIN(pt); while(1) { // sets pin 7 to an output mPORTBSetPinsDigitalOut(BIT_3); mPORTBClearBits(BIT_3); tft_setCursor(10, 50); tft_setTextColor(ILI9340_YELLOW); tft_setTextSize(3); tft_writeString("Capacitance: "); //sets up for the capacitor reading char buffer[20]; tft_setCursor(10, 90); tft_fillRect(10,90, 300, 100, ILI9340_BLACK); sprintf(buffer,"%.1f nF",cap); tft_setTextColor(ILI9340_WHITE); //displays the capacitor value if it is above the threshold of 1 nF if(cap < 1.0*(1-ERROR)) tft_writeString("No capacitor"); else tft_writeString(buffer); cap = 0.0; PT_YIELD_TIME_msec(1); //Clear timer and sets pin 7 as input WriteTimer2(0); mPORTBSetPinsDigitalIn(BIT_3); PT_YIELD_TIME_msec(100); } PT_END(pt); } // capture
static PT_THREAD(protothread_cap_read(struct pt *pt)) { PT_BEGIN(pt); tft_setCursor(0,0); tft_setTextColor(ILI9340_WHITE); tft_setTextSize(3); tft_writeString("Measuring capacitance:\n"); while(1) { tft_setCursor(0,10); tft_setTextColor(ILI9340_YELLOW); tft_setTextSize(3); if (capacitance == 0) { tft_writeString("No capacitor detected"); } else if (capacitance == 999) { tft_writeString("Capacitor out of range!"); } else { sprintf(buffer, "%5.1f", capacitance); } tft_writeString(buffer); PT_YIELD_TIME_msec(200); } PT_END(pt); }
void setup_lcd_fs(void){ _disable_interrupts(); WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer BCSCTL1 = CALBC1_16MHZ; /* Set DCO for 16 MHz */ DCOCTL = CALDCO_16MHZ; delay_ms(100); // Initialize SD card: spi_initialize(); dres = disk_initialize(); tft_init_hw(); tft_begin(); tft_fillScreen(ILI9340_WHITE); tft_setCursor(0, 1); tft_setTextColor(ILI9340_BLACK); tft_setTextSize(1); if (dres){ sprintf(buffer, "Disk error = %d\n", (int) dres); tft_writeString(buffer); while (1); } pres = pf_mount(&fs); if (pres){ sprintf(buffer, "PFF error 1 = %d\n", (int) pres); tft_writeString(buffer); while (1); } tft_fillScreen(ILI9340_WHITE); P1DIR |= BIT0 | BIT1; P1OUT &= ~ (BIT0 | BIT1); }
//======================= Refresh ========================= // //Does Ball calculations and Draws the necessary elements on the screen static PT_THREAD (protothread_refresh(struct pt *pt)) { PT_BEGIN(pt); PT_YIELD_TIME_msec(100); //waits for the scoreboard to be set up while(1) { while (timeElapsed <=60) { PT_YIELD_TIME_msec(10); DmaChnDisable(dmaChn); DmaChnDisable(dmaChn2); //Generates a new ball at a given interval if(ballgen >= 10) { int troll1 = -((rand()) % 2)-1; int troll2 = ((rand()) % 6) - 3; struct Ball *temp = Ball_create(320,120,troll1,troll2,(numBalls+1)*500,0,NULL); temp->b = head; head = temp; ballgen = 0; numBalls++; } else ballgen ++; //collision calculations struct Ball *ti = head; struct Ball *tj = NULL; if(ti != NULL) tj = ti->b; while(ti !=NULL){ //Calculates the collisions between every ball while(tj != NULL) { int rij_x = ti->xpos - tj->xpos; int rij_y = ti->ypos - tj->ypos; int mag_rij = pow(rij_x,2) + pow(rij_y,2); //Checks if ti and tj are not pointing to the same ball, //If they close enough for a collision and there is no collision //delay. if( ti->delay + tj->delay == 0 && mag_rij < dist) { int vij_x = ti->xvel - tj->xvel; int vij_y = ti->yvel - tj->yvel; if (mag_rij==0) { mag_rij=dist; } int deltaVi_x = (int)((-1*(rij_x) * ((((rij_x * vij_x)+ (rij_y*vij_y)) << 7)/mag_rij)) >> 7); int deltaVi_y = (int)((-1*(rij_y) * ((((rij_x * vij_x)+ (rij_y*vij_y)) << 7)/mag_rij)) >> 7); /* tft_fillRoundRect(0,30, 320, 14, 1, ILI9340_BLACK);// x,y,w,h,radius,color tft_setCursor(0, 30); tft_setTextColor(ILI9340_WHITE); tft_setTextSize(2); sprintf(buffer,"%d:%d", (-1*(rij_x)/128 * (128*((rij_x * vij_x)+ (rij_y*vij_y))/mag_rij)), mag_rij); tft_writeString(buffer); */ //Updates the velocity ti->xvel = ti->xvel + deltaVi_x; ti->yvel = ti->yvel + deltaVi_y; tj->xvel = tj->xvel - deltaVi_x; tj->yvel = tj->yvel - deltaVi_y; ti->delay = delay_master; tj->delay = delay_master; } tj = tj->b; } //checks for wall collisions if(ti->xpos >= 320*scale || ti->xpos <= 0) ti->xvel = -1*ti->xvel; if(ti->ypos >= 240*scale || ti->ypos <= 35*scale) { ti->yvel = -1*ti->yvel; if (ti->xpos > 120*scale && ti->xpos < 200*scale) { //check for catch bin ti->delay=-1; //set to -1 to indicate +1 point } } //calculates the drag if(ti->xvel > 0) ti->xvel = ti->xvel - ti->xvel/drag; else ti->xvel = ti->xvel + ti->xvel/drag; if(ti->yvel > 0) ti->yvel = ti->yvel - ti->yvel/drag; else ti->yvel = ti->yvel - ti->yvel/drag; // Check for paddle Collisions if(abs(paddle_xpos-ti->xpos/scale) <= ballradius && ti->delay == 0) if(ti->ypos/scale > paddle_ypos - half_paddle_length && ti->ypos/scale < paddle_ypos + half_paddle_length) { ti->xvel = -1*ti->xvel; ti->yvel = ti->yvel + paddle_drag*paddle_v; ti->delay=delay_master; } //Decrement the collide delay if(ti->delay > 0) ti->delay = ti->delay -1; //iterates through the next set ti = ti->b; if(ti != NULL) tj = ti->b; //removes the last element if the limit is reached if(numBalls > maxBalls && tj->b == NULL) { tft_fillCircle(tj->xpos/scale,tj->ypos/scale,ballradius,ILI9340_BLACK); //erases from the screen ti->b = NULL; numBalls--; score++; //free(tj); } } // Calculates position of the paddle and draw //TODO: Calculate paddle position tft_drawLine(paddle_xpos,paddle_ypos - half_paddle_length, paddle_xpos, paddle_ypos + half_paddle_length, ILI9340_BLACK); paddle_v=paddle_ypos; paddle_ypos=(adc_9*240)/1023; paddle_v=paddle_ypos-paddle_v; tft_drawLine(paddle_xpos,paddle_ypos - half_paddle_length, paddle_xpos, paddle_ypos + half_paddle_length, ILI9340_WHITE); // Now it calculates the new position ti = head; tj = head; while(ti != NULL){ //"Clears" the image of the last ball tft_fillCircle(ti->xpos/scale,ti->ypos/scale,ballradius,ILI9340_BLACK); //Updates the new position of the ball ti->xpos = ti->xpos + ti->xvel; ti->ypos = ti->ypos + ti->yvel; //ensures the positions are within bounds //If the pos is less than 0 then we remove it //delay must also not be -1 (ie >=0) if(ti->xpos > paddle_xpos && ti->delay != -1) { if(ti->xpos > 320*scale) ti->xpos = 320*scale; if(ti->ypos > 240*scale) ti->ypos = 240*scale; else if(ti->ypos < 35*scale) ti->ypos = 35*scale; if(ti->delay > 0) tft_fillCircle(ti->xpos/scale, ti->ypos/scale, ballradius, ILI9340_WHITE); else tft_fillCircle(ti->xpos/scale, ti->ypos/scale, ballradius, ti->color); } else { //REMOVES THE BALL IF IT CROSSES THE BOUNDARY if (ti->delay==-1) { //check if went into catch bins score++; DmaChnEnable(dmaChn2); } else { DmaChnEnable(dmaChn); score--; } if(ti == head) head = head->b; else tj->b = ti->b; numBalls--; //free(ti); } tj = ti;//what does this do? ti = ti->b; } frames ++; } tft_fillRoundRect(0,35, 320, 205, 1, ILI9340_BLACK);// x,y,w,h,radius,color DmaChnDisable(dmaChn); DmaChnDisable(dmaChn2); DmaChnEnable(dmaChn3); while (1) { tft_setCursor(20, 120); tft_setTextColor(ILI9340_WHITE); tft_setTextSize(4); sprintf(buffer,"Game Over!"); tft_writeString(buffer); } }
/** @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); }
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 }