机器人模式切换控制
This commit is contained in:
		
							parent
							
								
									74c78e4184
								
							
						
					
					
						commit
						4239de74f8
					
				| @ -35,7 +35,7 @@ const button: string[][] = | |||||||
| struct Control { | struct Control { | ||||||
|   @State select: number = 0 |   @State select: number = 0 | ||||||
|   @State line: API.VcInspectionLine[] = AppStorage.get("line") || [] |   @State line: API.VcInspectionLine[] = AppStorage.get("line") || [] | ||||||
|   @State mode: number = 0 |   @State mode: number[] = [] | ||||||
|   private control: RebootControl = new RebootControl("ws://192.168.7.101:10000") |   private control: RebootControl = new RebootControl("ws://192.168.7.101:10000") | ||||||
|   private forward: (event: TouchEvent) => void = TouchEventWrapper(() => { |   private forward: (event: TouchEvent) => void = TouchEventWrapper(() => { | ||||||
|     this.control.forward() |     this.control.forward() | ||||||
| @ -52,8 +52,10 @@ struct Control { | |||||||
| 
 | 
 | ||||||
|   async aboutToAppear(): Promise<void> { |   async aboutToAppear(): Promise<void> { | ||||||
|     await this.control.init() |     await this.control.init() | ||||||
|  |     this.mode = this.line.map(() => 0) | ||||||
|     this.control.getMode().then(res => { |     this.control.getMode().then(res => { | ||||||
|       Logger.info(res) |       Logger.info(res) | ||||||
|  |       this.mode[this.select] = res.mode | ||||||
|     }) |     }) | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
| @ -99,6 +101,9 @@ struct Control { | |||||||
|                     CusMenuItem({ text: menu.name, active: this.select === index }) |                     CusMenuItem({ text: menu.name, active: this.select === index }) | ||||||
|                       .margin({ bottom: 24 }) |                       .margin({ bottom: 24 }) | ||||||
|                       .onClick(() => { |                       .onClick(() => { | ||||||
|  |                         if (this.mode[this.select] === 1) { | ||||||
|  |                           this.control.setMode(0) | ||||||
|  |                         } | ||||||
|                         this.select = index |                         this.select = index | ||||||
|                       }) |                       }) | ||||||
|                   }) |                   }) | ||||||
| @ -173,8 +178,25 @@ struct Control { | |||||||
|             .layoutWeight(1) |             .layoutWeight(1) | ||||||
|             .margin({ right: 24 }) |             .margin({ right: 24 }) | ||||||
| 
 | 
 | ||||||
|             Row() { |             Column() { | ||||||
|  |               CusButton({ | ||||||
|  |                 normalImage: $rawfile("images/control/button.png"), | ||||||
|  |                 text: this.mode[this.select] === 1 ? "切换手动模式" : "切换自动模式", | ||||||
|  |                 style: { width: 160, height: 80, fontColor: 0x24F3FB } | ||||||
|  |               }).margin({ bottom: 24 }).onClick(async () => { | ||||||
|  |                 if (this.mode[this.select] === 1) { | ||||||
|  |                   await this.control.setMode(0) | ||||||
|  |                 } else { | ||||||
|  |                   await this.control.setMode(1) | ||||||
|  |                 } | ||||||
|  |                 this.control.getMode().then((res) => { | ||||||
|  |                   this.mode[this.select] = res.mode | ||||||
|  |                 }) | ||||||
|  |               }) | ||||||
|  | 
 | ||||||
|               Stack({ alignContent: Alignment.Center }) { |               Stack({ alignContent: Alignment.Center }) { | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|                 Image($rawfile("images/control/center.png")).width(80) |                 Image($rawfile("images/control/center.png")).width(80) | ||||||
|                 Image($rawfile("images/control/left.png")).offset({ x: -100 }) |                 Image($rawfile("images/control/left.png")).offset({ x: -100 }) | ||||||
|                   .width(120).onTouch(this.left) |                   .width(120).onTouch(this.left) | ||||||
| @ -204,7 +226,7 @@ struct Control { | |||||||
|                   .fontSize(28) |                   .fontSize(28) | ||||||
|                   .offset({ y: 70 }) |                   .offset({ y: 70 }) | ||||||
|                   .hitTestBehavior(HitTestMode.Transparent) |                   .hitTestBehavior(HitTestMode.Transparent) | ||||||
|               }.width("100%").height("100%") |               }.width("100%").layoutWeight(1) | ||||||
| 
 | 
 | ||||||
|             }.layoutWeight(1) |             }.layoutWeight(1) | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user