1 | #!/usr/bin/env python |
---|
2 | # -*- coding: utf-8 -*- |
---|
3 | # |
---|
4 | # Puzzlebox - Brainstorms - Configuration |
---|
5 | # |
---|
6 | # Copyright Puzzlebox Productions, LLC (2010) |
---|
7 | # |
---|
8 | # This code is released under the GNU Pulic License (GPL) version 2 |
---|
9 | # For more information please refer to http://www.gnu.org/copyleft/gpl.html |
---|
10 | # |
---|
11 | # Last Update: 2010.06.01 |
---|
12 | # |
---|
13 | ##################################################################### |
---|
14 | |
---|
15 | import os, sys |
---|
16 | import pygame |
---|
17 | |
---|
18 | ##################################################################### |
---|
19 | # General configuration |
---|
20 | ##################################################################### |
---|
21 | |
---|
22 | DEBUG = 1 |
---|
23 | |
---|
24 | DISCRETE_CONTROL_COMMANDS = True |
---|
25 | |
---|
26 | ##################################################################### |
---|
27 | # Logging |
---|
28 | ##################################################################### |
---|
29 | |
---|
30 | LOG_LEVEL_DEBUG = 2 |
---|
31 | LOG_LEVEL_INFO = 1 |
---|
32 | LOG_LEVEL_ERROR = 0 |
---|
33 | LOG_LEVEL_DISABLE = -1 |
---|
34 | |
---|
35 | DEFAULT_LOG_LEVEL = LOG_LEVEL_DEBUG |
---|
36 | DEFAULT_LOGFILE = 'puzzlebox' |
---|
37 | |
---|
38 | LOGFILE_DIR = '/var/log/puzzlebox' |
---|
39 | LOGFILE_SUFFIX = '.log' |
---|
40 | LOGFILE_SUFFIX_DEBUG = '_debug.log' |
---|
41 | LOGFILE_SUFFIX_INFO = '_info.log' |
---|
42 | LOGFILE_SUFFIX_ERROR = '_error.log' |
---|
43 | |
---|
44 | SPLIT_LOGFILES = False |
---|
45 | |
---|
46 | #BRAINSTORMS_LOGFILE = 'brainstorms' |
---|
47 | |
---|
48 | |
---|
49 | ##################################################################### |
---|
50 | # Network addresses |
---|
51 | ##################################################################### |
---|
52 | |
---|
53 | SERVER_INTERFACE = '' # listen on all of server's network interfaces |
---|
54 | #SERVER_HOST = '192.168.1.150' |
---|
55 | SERVER_HOST = '127.0.0.1' # localhost |
---|
56 | SERVER_PORT = 8194 |
---|
57 | |
---|
58 | |
---|
59 | ##################################################################### |
---|
60 | # Remote Control configuration |
---|
61 | ##################################################################### |
---|
62 | |
---|
63 | if (sys.platform == 'win32'): |
---|
64 | BLUETOOTH_DEVICE = 'COM1' |
---|
65 | else: |
---|
66 | BLUETOOTH_DEVICE = '/dev/rfcomm0' |
---|
67 | |
---|
68 | MOTORS_MOUNTED_BACKWARDS = True |
---|
69 | MOTOR_PORT_RIGHT = 'a' |
---|
70 | MOTOR_PORT_LEFT = 'b' |
---|
71 | DEFAULT_RC_COMMAND = 'test_drive' |
---|
72 | |
---|
73 | |
---|
74 | ##################################################################### |
---|
75 | # Server configuration |
---|
76 | ##################################################################### |
---|
77 | |
---|
78 | MAX_COMPONENTS = 16 |
---|
79 | |
---|
80 | |
---|
81 | ##################################################################### |
---|
82 | # Client configuration |
---|
83 | ##################################################################### |
---|
84 | |
---|
85 | MAX_CONNECTION_ATTEMPTS = 5 |
---|
86 | HEALTH_CHECK_CONNECTION_ATTEMPTS = 5 |
---|
87 | NO_REPLY_WAIT = 10 # how many seconds before considering a component dead |
---|
88 | |
---|
89 | |
---|
90 | ##################################################################### |
---|
91 | # Client Interface configuration |
---|
92 | ##################################################################### |
---|
93 | |
---|
94 | DISPLAY_WINDOW_X_COORDINATE = 0 |
---|
95 | DISPLAY_WINDOW_Y_COORDINATE = 0 |
---|
96 | DISPLAY_WINDOW_X_DIMENSION = 254 |
---|
97 | DISPLAY_WINDOW_Y_DIMENSION = 424 |
---|
98 | |
---|
99 | #WINDOW_BACKGROUND_COLOR = (255,255,255) # white background |
---|
100 | #WINDOW_BACKGROUND_COLOR = (128,128,128) # grey background |
---|
101 | #WINDOW_BACKGROUND_COLOR = (64,64,64) # dark grek background |
---|
102 | WINDOW_BACKGROUND_COLOR = (0,0,0) # black background |
---|
103 | |
---|
104 | IMAGE_DIRECTORY = os.path.join(os.getcwd(), 'images') |
---|
105 | |
---|
106 | # Keyboard key reference at http://www.pygame.org/docs/ref/key.html#pygame.key |
---|
107 | BUTTON_LAYOUT = { \ |
---|
108 | |
---|
109 | 'left': { \ |
---|
110 | 'command': 'turn_left', \ |
---|
111 | 'active': False, \ |
---|
112 | 'button_image': '1-upper_left-white.png', \ |
---|
113 | 'activated_image': '1-upper_left-orange.png', \ |
---|
114 | 'image_x': 0, \ |
---|
115 | 'image_y': 0, \ |
---|
116 | 'match_keys': [pygame.K_LEFT, pygame.K_a, pygame.K_q] |
---|
117 | }, \ |
---|
118 | |
---|
119 | 'forward': { \ |
---|
120 | 'command': 'drive_forward', \ |
---|
121 | 'active': False, \ |
---|
122 | 'button_image': '2-up-white.png', \ |
---|
123 | 'activated_image': '2-up-orange.png', \ |
---|
124 | 'image_x': 98, \ |
---|
125 | 'image_y': 0, \ |
---|
126 | 'match_keys': [pygame.K_UP, pygame.K_w] |
---|
127 | }, \ |
---|
128 | |
---|
129 | 'right': { \ |
---|
130 | 'command': 'turn_right', \ |
---|
131 | 'active': False, \ |
---|
132 | 'button_image': '3-upper_right-white.png', \ |
---|
133 | 'activated_image': '3-upper_right-orange.png', \ |
---|
134 | 'image_x': 157, \ |
---|
135 | 'image_y': 0, \ |
---|
136 | 'match_keys': [pygame.K_RIGHT, pygame.K_d, pygame.K_e] |
---|
137 | }, \ |
---|
138 | |
---|
139 | 'reverse_left': { \ |
---|
140 | 'command': 'turn_left_in_reverse', \ |
---|
141 | 'active': False, \ |
---|
142 | 'button_image': '7-lower_left-white.png', \ |
---|
143 | 'activated_image': '7-lower_left-orange.png', \ |
---|
144 | 'image_x': 0, \ |
---|
145 | 'image_y': 220, \ |
---|
146 | 'match_keys': [pygame.K_z] |
---|
147 | }, \ |
---|
148 | |
---|
149 | 'reverse': { \ |
---|
150 | 'command': 'drive_reverse', \ |
---|
151 | 'active': False, \ |
---|
152 | 'button_image': '8-down-white.png', \ |
---|
153 | 'activated_image': '8-down-orange.png', \ |
---|
154 | 'image_x': 98, \ |
---|
155 | 'image_y': 220, \ |
---|
156 | 'match_keys': [pygame.K_DOWN, pygame.K_s, pygame.K_x] |
---|
157 | }, \ |
---|
158 | |
---|
159 | 'reverse_right': { \ |
---|
160 | 'command': 'turn_right_in_reverse', \ |
---|
161 | 'active': False, \ |
---|
162 | 'button_image': '9-lower_right-white.png', \ |
---|
163 | 'activated_image': '9-lower_right-orange.png', \ |
---|
164 | 'image_x': 157, \ |
---|
165 | 'image_y': 220, \ |
---|
166 | 'match_keys': [pygame.K_PAGEDOWN, pygame.K_c] |
---|
167 | }, \ |
---|
168 | |
---|
169 | } # BUTTON_LAYOUT |
---|
170 | |
---|