radar modified
This commit is contained in:
parent
42b038308d
commit
4a666d121d
115
radar/radar.ino
115
radar/radar.ino
|
@ -19,9 +19,10 @@ int Xmax = 160; //屏幕的横向像素数
|
||||||
int Xcent = Xmax / 2; //x中位
|
int Xcent = Xmax / 2; //x中位
|
||||||
int base = 118; //基线高度
|
int base = 118; //基线高度
|
||||||
int scanline = 105; //雷达扫描线长度
|
int scanline = 105; //雷达扫描线长度
|
||||||
int outcircle=81;
|
int outcircle=80;
|
||||||
int midcircle=54;
|
int midcircle=60;
|
||||||
int incircle=27;
|
int midcircle2=40;
|
||||||
|
int incircle=20;
|
||||||
|
|
||||||
Servo baseServo;
|
Servo baseServo;
|
||||||
Ucglib_ST7735_18x128x160_HWSPI ucg(/*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
Ucglib_ST7735_18x128x160_HWSPI ucg(/*cd=*/ 9, /*cs=*/ 10, /*reset=*/ 8);
|
||||||
|
@ -38,24 +39,24 @@ void setup(void)
|
||||||
baseServo.attach(ServoPin); //初始化舵机
|
baseServo.attach(ServoPin); //初始化舵机
|
||||||
|
|
||||||
//欢迎屏幕
|
//欢迎屏幕
|
||||||
ucg.setFontMode(UCG_FONT_MODE_TRANSPARENT);
|
// ucg.setFontMode(UCG_FONT_MODE_TRANSPARENT);
|
||||||
ucg.setColor(0, 0, 100, 0);
|
// ucg.setColor(0, 0, 100, 0);
|
||||||
ucg.setColor(1, 0, 100, 0);
|
// ucg.setColor(1, 0, 100, 0);
|
||||||
ucg.setColor(2, 20, 20,20);
|
// ucg.setColor(2, 20, 20,20);
|
||||||
ucg.setColor(3, 20, 20, 20);
|
// ucg.setColor(3, 20, 20, 20);
|
||||||
ucg.drawGradientBox(0, 0, 160, 128);
|
// ucg.drawGradientBox(0, 0, 160, 128);
|
||||||
ucg.setPrintDir(0);
|
// ucg.setPrintDir(0);
|
||||||
ucg.setColor(0, 5, 0);
|
// ucg.setColor(0, 5, 0);
|
||||||
ucg.setPrintPos(27,42);
|
// ucg.setPrintPos(27,42);
|
||||||
ucg.setFont(ucg_font_logisoso18_tf);
|
// ucg.setFont(ucg_font_logisoso18_tf);
|
||||||
ucg.print("Mini Radar");
|
// ucg.print("Mini Radar");
|
||||||
ucg.setColor(0, 255, 0);
|
// ucg.setColor(0, 255, 0);
|
||||||
ucg.setPrintPos(25,40);
|
// ucg.setPrintPos(25,40);
|
||||||
ucg.print("Mini Radar");
|
// ucg.print("Mini Radar");
|
||||||
ucg.setFont(ucg_font_helvB08_tf);
|
// ucg.setFont(ucg_font_helvB08_tf);
|
||||||
ucg.setColor(20, 255, 20);
|
// ucg.setColor(20, 255, 20);
|
||||||
ucg.setPrintPos(40,100);
|
// ucg.setPrintPos(40,100);
|
||||||
ucg.print("Testing...");
|
// ucg.print("Testing...");
|
||||||
baseServo.write(90);
|
baseServo.write(90);
|
||||||
|
|
||||||
//测试底座的运行情况,注意检测底座位置和转动姿态,是否有卡住(或者导线缠绕)的情况。
|
//测试底座的运行情况,注意检测底座位置和转动姿态,是否有卡住(或者导线缠绕)的情况。
|
||||||
|
@ -63,7 +64,7 @@ void setup(void)
|
||||||
{ baseServo.write(x);
|
{ baseServo.write(x);
|
||||||
delay(50);
|
delay(50);
|
||||||
}
|
}
|
||||||
ucg.print("OK!");
|
//ucg.print("OK!");
|
||||||
delay(500);
|
delay(500);
|
||||||
|
|
||||||
|
|
||||||
|
@ -111,12 +112,14 @@ int calculateDistance()
|
||||||
void fix_font()
|
void fix_font()
|
||||||
{
|
{
|
||||||
ucg.setColor(0, 180, 0);
|
ucg.setColor(0, 180, 0);
|
||||||
ucg.setPrintPos(70,14);
|
ucg.setPrintPos(70,46);
|
||||||
ucg.print("1.00");
|
ucg.print("1.00");
|
||||||
ucg.setPrintPos(70,52);
|
ucg.setPrintPos(70,66);
|
||||||
ucg.print("0.67");
|
ucg.print("0.75");
|
||||||
ucg.setPrintPos(70,90);
|
ucg.setPrintPos(70,86);
|
||||||
ucg.print("0.33");
|
ucg.print("0.50");
|
||||||
|
ucg.setPrintPos(70,106);
|
||||||
|
ucg.print("0.25");
|
||||||
}
|
}
|
||||||
|
|
||||||
void fix()
|
void fix()
|
||||||
|
@ -129,6 +132,8 @@ void fix()
|
||||||
ucg.drawCircle(Xcent, base+1, outcircle, UCG_DRAW_UPPER_RIGHT);
|
ucg.drawCircle(Xcent, base+1, outcircle, UCG_DRAW_UPPER_RIGHT);
|
||||||
ucg.drawCircle(Xcent, base+1, midcircle, UCG_DRAW_UPPER_LEFT);
|
ucg.drawCircle(Xcent, base+1, midcircle, UCG_DRAW_UPPER_LEFT);
|
||||||
ucg.drawCircle(Xcent, base+1, midcircle, UCG_DRAW_UPPER_RIGHT);
|
ucg.drawCircle(Xcent, base+1, midcircle, UCG_DRAW_UPPER_RIGHT);
|
||||||
|
ucg.drawCircle(Xcent, base+1, midcircle2, UCG_DRAW_UPPER_LEFT);
|
||||||
|
ucg.drawCircle(Xcent, base+1, midcircle2, UCG_DRAW_UPPER_RIGHT);
|
||||||
ucg.drawCircle(Xcent, base+1, incircle, UCG_DRAW_UPPER_LEFT);
|
ucg.drawCircle(Xcent, base+1, incircle, UCG_DRAW_UPPER_LEFT);
|
||||||
ucg.drawCircle(Xcent, base+1, incircle, UCG_DRAW_UPPER_RIGHT);
|
ucg.drawCircle(Xcent, base+1, incircle, UCG_DRAW_UPPER_RIGHT);
|
||||||
ucg.drawLine(0, base+1, Xmax,base+1);
|
ucg.drawLine(0, base+1, Xmax,base+1);
|
||||||
|
@ -146,35 +151,35 @@ void fix()
|
||||||
// }
|
// }
|
||||||
|
|
||||||
//画一些装饰性图案
|
//画一些装饰性图案
|
||||||
ucg.setColor(0,200,0);
|
// ucg.setColor(0,200,0);
|
||||||
ucg.drawLine(0,0,0,18);
|
// ucg.drawLine(0,0,0,18);
|
||||||
for(int i= 0;i < 5; i++)
|
// for(int i= 0;i < 5; i++)
|
||||||
{
|
// {
|
||||||
ucg.setColor(0,random(200)+50,0);
|
// ucg.setColor(0,random(200)+50,0);
|
||||||
ucg.drawBox(2,i*4,random(14)+2,3);
|
// ucg.drawBox(2,i*4,random(14)+2,3);
|
||||||
}
|
// }
|
||||||
|
|
||||||
ucg.setColor(0,180,0);
|
// ucg.setColor(0,180,0);
|
||||||
ucg.drawFrame(146,0,14,14);
|
// ucg.drawFrame(146,0,14,14);
|
||||||
ucg.setColor(0,60,0);
|
// ucg.setColor(0,60,0);
|
||||||
ucg.drawHLine(148,0,10);
|
// ucg.drawHLine(148,0,10);
|
||||||
ucg.drawVLine(146,2,10);
|
// ucg.drawVLine(146,2,10);
|
||||||
ucg.drawHLine(148,13,10);
|
// ucg.drawHLine(148,13,10);
|
||||||
ucg.drawVLine(159,2,10);
|
// ucg.drawVLine(159,2,10);
|
||||||
|
|
||||||
ucg.setColor(0,220,0);
|
// ucg.setColor(0,220,0);
|
||||||
ucg.drawBox(148,2,4,4);
|
// ucg.drawBox(148,2,4,4);
|
||||||
ucg.drawBox(148,8,4,4);
|
// ucg.drawBox(148,8,4,4);
|
||||||
ucg.drawBox(154,8,4,4);
|
// ucg.drawBox(154,8,4,4);
|
||||||
ucg.setColor(0,100,0);
|
// ucg.setColor(0,100,0);
|
||||||
ucg.drawBox(154,2,4,4);
|
// ucg.drawBox(154,2,4,4);
|
||||||
|
|
||||||
ucg.setColor(0,90,0);
|
// ucg.setColor(0,90,0);
|
||||||
ucg.drawTetragon(62,123,58,127,98,127,102,123);
|
// ucg.drawTetragon(62,123,58,127,98,127,102,123);
|
||||||
ucg.setColor(0,160,0);
|
// ucg.setColor(0,160,0);
|
||||||
ucg.drawTetragon(67,123,63,127,93,127,97,123);
|
// ucg.drawTetragon(67,123,63,127,93,127,97,123);
|
||||||
ucg.setColor(0,210,0);
|
// ucg.setColor(0,210,0);
|
||||||
ucg.drawTetragon(72,123,68,127,88,127,92,123);
|
// ucg.drawTetragon(72,123,68,127,88,127,92,123);
|
||||||
|
|
||||||
// ucg.setColor(0,155, 0);
|
// ucg.setColor(0,155, 0);
|
||||||
// ucg.setPrintPos(0,126);
|
// ucg.setPrintPos(0,126);
|
||||||
|
@ -240,7 +245,7 @@ void loop(void)
|
||||||
// ucg.print(" ");
|
// ucg.print(" ");
|
||||||
//ucg.print(distance);
|
//ucg.print(distance);
|
||||||
// ucg.print("cm ");
|
// ucg.print("cm ");
|
||||||
|
//delay(10);
|
||||||
}
|
}
|
||||||
ucg.clearScreen(); //清屏 如果arduino供电不足,可能会引起白屏(显示信号中断)可以用 cls();函数代替 ucg.clearScreen();
|
ucg.clearScreen(); //清屏 如果arduino供电不足,可能会引起白屏(显示信号中断)可以用 cls();函数代替 ucg.clearScreen();
|
||||||
delay(50);
|
delay(50);
|
||||||
|
@ -295,7 +300,7 @@ void loop(void)
|
||||||
// ucg.print(" ");
|
// ucg.print(" ");
|
||||||
//ucg.print(distance);
|
//ucg.print(distance);
|
||||||
// ucg.print("cm ");
|
// ucg.print("cm ");
|
||||||
|
//delay(10);
|
||||||
}
|
}
|
||||||
ucg.clearScreen(); //
|
ucg.clearScreen(); //
|
||||||
delay(50);
|
delay(50);
|
||||||
|
|
Loading…
Reference in New Issue