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