-
Notifications
You must be signed in to change notification settings - Fork 1
/
AppController.h
157 lines (126 loc) · 4.31 KB
/
AppController.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
//
// AppController.h
// SumoDebugger
//
// Created by Tymon Tobolski on 10-01-16.
// Copyright 2010 Politechnika Wrocławska. All rights reserved.
//
#import <Cocoa/Cocoa.h>
#import <DDHidLib/DDHidLib.h>
#import "AmSerialPort.h"
#import "DistanceHistoryView.h"
#import "JoystickView.h"
#define GROUND_COUNT 4
#define DISTANCE_COUNT 6
#define ENGINE_COUNT 2
struct GroundSensor {
NSButton *displayCheckBox;
NSButton *activeCheckBox;
};
struct DistanceSensor {
NSTextField *label;
NSLevelIndicator *levelIndicator;
NSButton *activeCheckBox;
DistanceHistoryView *historyView;
};
struct Engine {
NSSlider *slider;
NSTextField *label;
};
struct Joystick {
NSArray *list;
DDHidJoystick *current;
int xValue;
int yValue;
int zValue;
};
enum EngineMode { kNormal, kGUI, kJoystick };
@interface AppController : NSObject {
NSUserDefaults *preferences;
AMSerialPort *port;
enum EngineMode engineMode;
struct Joystick joystick;
IBOutlet NSPopUpButton *portListPopUpButton;
IBOutlet NSPopUpButton *joystickListPopUpButton;
IBOutlet NSTextView *outputTextView;
IBOutlet NSTextView *debugTextView;
IBOutlet NSMatrix *selectEngineModeMatrix;
IBOutlet NSTextField *customSendTextField;
IBOutlet JoystickView *joystickView;
// ground sensors
IBOutlet NSButton *ground0DisplayCheckBox;
IBOutlet NSButton *ground1DisplayCheckBox;
IBOutlet NSButton *ground2DisplayCheckBox;
IBOutlet NSButton *ground3DisplayCheckBox;
IBOutlet NSButton *ground0ActiveCheckBox;
IBOutlet NSButton *ground1ActiveCheckBox;
IBOutlet NSButton *ground2ActiveCheckBox;
IBOutlet NSButton *ground3ActiveCheckBox;
struct GroundSensor groundSensors[GROUND_COUNT];
// distance sensors
IBOutlet NSTextField *dist0ValueLabel;
IBOutlet NSTextField *dist1ValueLabel;
IBOutlet NSTextField *dist2ValueLabel;
IBOutlet NSTextField *dist3ValueLabel;
IBOutlet NSTextField *dist4ValueLabel;
IBOutlet NSTextField *dist5ValueLabel;
IBOutlet NSLevelIndicator *dist0LevelIndicator;
IBOutlet NSLevelIndicator *dist1LevelIndicator;
IBOutlet NSLevelIndicator *dist2LevelIndicator;
IBOutlet NSLevelIndicator *dist3LevelIndicator;
IBOutlet NSLevelIndicator *dist4LevelIndicator;
IBOutlet NSLevelIndicator *dist5LevelIndicator;
IBOutlet NSButton *dist0ActiveCheckBox;
IBOutlet NSButton *dist1ActiveCheckBox;
IBOutlet NSButton *dist2ActiveCheckBox;
IBOutlet NSButton *dist3ActiveCheckBox;
IBOutlet NSButton *dist4ActiveCheckBox;
IBOutlet NSButton *dist5ActiveCheckBox;
IBOutlet DistanceHistoryView *dist0HistoryView;
IBOutlet DistanceHistoryView *dist1HistoryView;
IBOutlet DistanceHistoryView *dist2HistoryView;
IBOutlet DistanceHistoryView *dist3HistoryView;
IBOutlet DistanceHistoryView *dist4HistoryView;
IBOutlet DistanceHistoryView *dist5HistoryView;
struct DistanceSensor distanceSensors[DISTANCE_COUNT];
// engines
IBOutlet NSSlider *engine0Slider;
IBOutlet NSSlider *engine1Slider;
IBOutlet NSTextField *engine0ValueLabel;
IBOutlet NSTextField *engine1ValueLabel;
struct Engine engines[ENGINE_COUNT];
}
-(IBAction) startStopReading:(id)sender;
-(IBAction) selectPort:(id)sender;
-(IBAction) setNormalEngineMode:(id)sender;
-(IBAction) setGUIEngineMode:(id)sender;
-(IBAction) setJoystickEngineMode:(id)sender;
-(IBAction) sendStart:(id)sender;
-(IBAction) sendReset:(id)sender;
-(IBAction) sendNewline:(id)sender;
-(IBAction) sendCustom:(id)sender;
-(IBAction) clearLog:(id)sender;
-(void) updatePortList;
-(void) closePort;
-(void) parseInput:(NSString *)text;
-(void) initPortFor:(NSString *)portPath;
-(void)log:(NSString *)text;
- (void) ddhidJoystick: (DDHidJoystick *) theJoystick
stick: (unsigned) stick
povNumber: (unsigned) povNumber
valueChanged: (int) value;
- (void) ddhidJoystick: (DDHidJoystick *) theJoystick
stick: (unsigned) stick
xChanged: (int) value;
- (void) ddhidJoystick: (DDHidJoystick *) theJoystick
stick: (unsigned) stick
yChanged: (int) value;
- (void) ddhidJoystick: (DDHidJoystick *) theJoystick
stick: (unsigned) stick
otherAxis: (unsigned) otherAxis
valueChanged: (int) value;
- (void) ddhidJoystick: (DDHidJoystick *) theJoystick
buttonDown: (unsigned) buttonNumber;
- (void) ddhidJoystick: (DDHidJoystick *) theJoystick
buttonUp: (unsigned) buttonNumber;
@end