void boost_gauge(){ float endy, endx, o_endy, o_endx; float tangle; float boost = 0.0, o_boost = 0.0; //display the boost gauge background bmp_draw("bstgaug",0,0); //loop while (!(touch_get_cursor(&m_point))){ //get boost reading boost++; //for testing if (int(boost) >= warnBoost){ lcd_circle(11,10,9, gaugeRed, gaugeRed); delay(90); lcd_circle(11,10,9, gaugeRed, mblack); } //draw a line to rep this //line is 40 pixels long ... this is always the hypotenuse //angle formula is ... if (boost <= 0){//ok endx = 24; endy = 64; } else if ((boost > 0) && (boost < 10)){ tangle = 9 * (boost); // 90/10 is 9 endx = 64 - (40 * lcos(tangle)); endy = 64 - (40 * lsin(tangle)); } else if ((boost >= 10) && (boost < 20)){ tangle = 9 * (boost - 10); endx = 64 + (40 * lsin(tangle)); endy = 64 - (40 * lcos(tangle)); } else if (boost >= 20){ endx = 104; endy = 64; } if (abs(o_boost - boost) > 2){ stroke(224, 38, 41); line(64, 64, endx, endy); line(65, 64, endx, endy); line(63, 64, endx, endy); line(64, 65, endx, endy); line(64, 63, endx, endy); stroke(0,0,0); line(64, 63, o_endx, o_endy); line(64, 65, o_endx, o_endy); line(63, 64, o_endx, o_endy); line(65, 64, o_endx, o_endy); line(64, 64, o_endx, o_endy); } o_endx = endx; o_endy = endy; //print deg F //do conversion from int to string with decimal places char char_boost[7]; fmtDouble(boost, 2, char_boost, 7); lcd_puts(char_boost, 65, 82, gaugeRed, mblack); //delay(200); //bmp_draw("bstgaug",0,0); //is this the right way to do a redraw?? } while (touch_get_cursor(&m_point)){} //go to the next display if a touch is detected four_bar(); }
void drawGame (game* g) { volatile char i = 0; lcd_fillScreen(DARK_GRAY); //Draw the mudpits onto the screen. if (g->mudpit1.duration > 0) { lcd_circle((unsigned short)g->mudpit1.debuffPosition.x,(unsigned short)g->mudpit1.debuffPosition.y, (unsigned short)g->mudpit1.debuffSize, BROWN); lcd_circle((unsigned short)g->mudpit1.debuffPosition.x,(unsigned short)g->mudpit1.debuffPosition.y, (unsigned short)g->mudpit1.debuffSize -1, BROWN); lcd_circle((unsigned short)g->mudpit1.debuffPosition.x,(unsigned short)g->mudpit1.debuffPosition.y, (unsigned short)g->mudpit1.debuffSize -2, BROWN); lcd_circle((unsigned short)g->mudpit1.debuffPosition.x,(unsigned short)g->mudpit1.debuffPosition.y, (unsigned short)g->mudpit1.debuffSize -3, BROWN); lcd_circle((unsigned short)g->mudpit1.debuffPosition.x,(unsigned short)g->mudpit1.debuffPosition.y, (unsigned short)g->mudpit1.debuffSize -4, BROWN); lcd_circle((unsigned short)g->mudpit1.debuffPosition.x,(unsigned short)g->mudpit1.debuffPosition.y, (unsigned short)g->mudpit1.debuffSize -6, BROWN); lcd_circle((unsigned short)g->mudpit1.debuffPosition.x,(unsigned short)g->mudpit1.debuffPosition.y, (unsigned short)g->mudpit1.debuffSize -8, BROWN); } if (g->mudpit2.duration > 0) { lcd_circle((unsigned short)g->mudpit2.debuffPosition.x,(unsigned short)g->mudpit2.debuffPosition.y, (unsigned short)g->mudpit2.debuffSize, BROWN); lcd_circle((unsigned short)g->mudpit2.debuffPosition.x,(unsigned short)g->mudpit2.debuffPosition.y, (unsigned short)g->mudpit2.debuffSize -1, BROWN); lcd_circle((unsigned short)g->mudpit2.debuffPosition.x,(unsigned short)g->mudpit2.debuffPosition.y, (unsigned short)g->mudpit2.debuffSize -2, BROWN); lcd_circle((unsigned short)g->mudpit2.debuffPosition.x,(unsigned short)g->mudpit2.debuffPosition.y, (unsigned short)g->mudpit2.debuffSize -3, BROWN); lcd_circle((unsigned short)g->mudpit2.debuffPosition.x,(unsigned short)g->mudpit2.debuffPosition.y, (unsigned short)g->mudpit2.debuffSize -4, BROWN); lcd_circle((unsigned short)g->mudpit2.debuffPosition.x,(unsigned short)g->mudpit2.debuffPosition.y, (unsigned short)g->mudpit2.debuffSize -6, BROWN); lcd_circle((unsigned short)g->mudpit2.debuffPosition.x,(unsigned short)g->mudpit2.debuffPosition.y, (unsigned short)g->mudpit2.debuffSize -8, BROWN); } //Draw the firepits onto the screen. for (i=0; i<5; i++) { if (g->firepits[i].duration > 0) { if (g->firepits[i].debuffSize < g->firepits[i].targetSize) { lcd_circle((unsigned short)g->firepits[i].debuffPosition.x,(unsigned short)g->firepits[i].debuffPosition.y, (unsigned short)g->firepits[i].debuffSize, RED); g->firepits[i].debuffSize++; } else if (g->firepits[i].debuffSize == g->firepits[i].targetSize) { lcd_circle((unsigned short)g->firepits[i].debuffPosition.x,(unsigned short)g->firepits[i].debuffPosition.y, (unsigned short)g->firepits[i].debuffSize, RED); lcd_circle((unsigned short)g->firepits[i].debuffPosition.x,(unsigned short)g->firepits[i].debuffPosition.y, (unsigned short)g->firepits[i].debuffSize - 1, RED); lcd_circle((unsigned short)g->firepits[i].debuffPosition.x,(unsigned short)g->firepits[i].debuffPosition.y, (unsigned short)g->firepits[i].debuffSize - 2, RED); lcd_circle((unsigned short)g->firepits[i].debuffPosition.x,(unsigned short)g->firepits[i].debuffPosition.y, (unsigned short)g->firepits[i].debuffSize - 4, ORANGE); lcd_circle((unsigned short)g->firepits[i].debuffPosition.x,(unsigned short)g->firepits[i].debuffPosition.y, (unsigned short)g->firepits[i].debuffSize - 6, ORANGE); lcd_circle((unsigned short)g->firepits[i].debuffPosition.x,(unsigned short)g->firepits[i].debuffPosition.y, (unsigned short)g->firepits[i].debuffSize - 8, ORANGE); lcd_circle((unsigned short)g->firepits[i].debuffPosition.x,(unsigned short)g->firepits[i].debuffPosition.y, (unsigned short)g->firepits[i].debuffSize - 10, LIGHT_YELLOW); lcd_circle((unsigned short)g->firepits[i].debuffPosition.x,(unsigned short)g->firepits[i].debuffPosition.y, (unsigned short)g->firepits[i].debuffSize - 12, LIGHT_YELLOW); lcd_circle((unsigned short)g->firepits[i].debuffPosition.x,(unsigned short)g->firepits[i].debuffPosition.y, (unsigned short)g->firepits[i].debuffSize - 14, LIGHT_YELLOW); } } } //Draw the blades onto the screen. for (i=0; i<5; i++) { if (g->blades[i].active == ACTIVE) { lcd_circle((unsigned short)g->blades[i].bladePosition.x,(unsigned short)g->blades[i].bladePosition.y, (unsigned short)g->blades[i].bladeSize, WHITE); lcd_circle((unsigned short)g->blades[i].bladePosition.x,(unsigned short)g->blades[i].bladePosition.y, (unsigned short)g->blades[i].bladeSize - 1, WHITE); lcd_circle((unsigned short)g->blades[i].bladePosition.x,(unsigned short)g->blades[i].bladePosition.y, (unsigned short)g->blades[i].bladeSize - 2, LIGHT_GRAY); lcd_circle((unsigned short)g->blades[i].bladePosition.x,(unsigned short)g->blades[i].bladePosition.y, (unsigned short)g->blades[i].bladeSize - 3, LIGHT_GRAY); lcd_circle((unsigned short)g->blades[i].bladePosition.x,(unsigned short)g->blades[i].bladePosition.y, (unsigned short)g->blades[i].bladeSize - 4, DARK_GRAY); lcd_circle((unsigned short)g->blades[i].bladePosition.x,(unsigned short)g->blades[i].bladePosition.y, (unsigned short)g->blades[i].bladeSize - 5, DARK_GRAY); } } if (g->swagToken.duration > 0) { lcd_picture((unsigned short)g->swagToken.debuffPosition.x - 10,(unsigned short)g->swagToken.debuffPosition.y - 10, 20, 20, swagToken); } }
void oil_temp_gauge(){ float endy, endx, o_endx, o_endy; float tangle; //display the oil temp gauge background bmp_draw("oilgaug",0,0); float oil_temp = 120, o_oil_temp = 120; while (!(touch_get_cursor(&m_point))){ //get oil temp from arduino oil_temp++; //for testing //if warmed and not previously warmed then flash message if ( (oil_temp_startup == false) && (oil_temp >= oil_temp_warn) ){ oil_temp_startup = true; lcd_clearScreen(mblack); lcd_puts("Engine Warmed!",10,30,gaugeRed,mblack); lcd_puts("Engine Warmed!",20,40,gaugeRed,mblack); lcd_puts("Engine Warmed!",30,50,gaugeRed,mblack); lcd_puts("Engine Warmed!",40,60,gaugeRed,mblack); delay (2000); lcd_clearScreen(mblack); bmp_draw("oilgaug",0,0); } //if the warn point is met flash the circle encompassing the gauge if (int(oil_temp) >= warnOilT){ lcd_circle(11,10,9, gaugeRed, gaugeRed); delay(90); lcd_circle(11,10,9, gaugeRed, mblack); } //draw a line to rep this //line is 40 pixels long ... this is always the hypotenuse //angle formula is ... if (oil_temp <= 120){ //ok endx = 64; endy = 94; } else if ((oil_temp > 120) && (oil_temp < 180)){ //not ok tangle = 1.5 * (oil_temp - 120); //1.5 is 90degrees/60degF or the scaling factor endx = 64.0 - (30.0 * lsin(tangle)); endy = 64.0 + (30.0 * lcos(tangle)); } else if ((oil_temp >= 180) && (oil_temp < 240)){ //ok tangle = 1.5 * (oil_temp - 180); endx = 64 - (30 * lcos(tangle)); endy = 64 - (30 * lsin(tangle)); } else if ((oil_temp >= 240) && (oil_temp < 300)){ //not ok tangle = 90 - 1.5 * (oil_temp - 240); //inverse...because we are actually looking for the angle down from 90 deg up endx = 64 + (30 * lcos(tangle)); endy = 64 - (30 * lsin(tangle)); } else if (oil_temp > 300){//ok endx = 94; endy = 64; } if (abs(o_oil_temp - oil_temp) > 2){ stroke(224, 38, 41); line(64, 64, endx, endy); line(65, 64, endx, endy); line(63, 64, endx, endy); line(64, 65, endx, endy); line(64, 63, endx, endy); stroke(0,0,0); line(64, 63, o_endx, o_endy); line(64, 65, o_endx, o_endy); line(63, 64, o_endx, o_endy); line(65, 64, o_endx, o_endy); line(64, 64, o_endx, o_endy); } o_endx = endx; o_endy = endy; //for debugging --v /*char char_xy[7]; fmtDouble(endx, 2, char_xy, 7); lcd_puts(char_xy, 10, 10, gaugeRed, black); fmtDouble(endy, 2, char_xy, 7); lcd_puts(char_xy, 20, 20, gaugeRed, black);*/ //--^ //print deg F //do conversion from int to string with decimal places char char_oil_temp[7]; fmtDouble(oil_temp, 2, char_oil_temp, 7); lcd_puts(char_oil_temp, 80, 72, gaugeRed, mblack); //delay(500); //for testing //bmp_draw("oilgaug",0,0); } while (touch_get_cursor(&m_point)){} //debounce boost_gauge(); //next gauge }