Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

New performance starter

  • Loading branch information...
commit 8c36215e7d61dd2305d1cda12854add3e6e72458 1 parent b4b36d0
Sébastien Bourdeauducq authored June 09, 2011

Showing 2 changed files with 81 additions and 12 deletions. Show diff stats Hide diff stats

  1. 2  src/cp.c
  2. 91  src/performance.c
2  src/cp.c
@@ -282,7 +282,7 @@ void init_cp()
282 282
 		"b_load = new Button(-text \"Load\")",
283 283
 		"b_save = new Button(-text \"Save\")",
284 284
 		"b_firstpatch = new Button(-text \"First patch\")",
285  
-		"b_start = new Button(-text \"Start!\")",
  285
+		"b_start = new Button(-text \"Start\")",
286 286
 		"g_performance.place(b_new, -column 1 -row 1)",
287 287
 		"g_performance.place(b_load, -column 2 -row 1)",
288 288
 		"g_performance.place(b_save, -column 3 -row 1)",
91  src/performance.c
@@ -46,7 +46,7 @@ struct patch_info {
46 46
 static int npatches;
47 47
 static int current_patch;
48 48
 static struct patch_info patches[MAX_PATCHES];
49  
-static bool simple_mode;
  49
+static int simple_mode;
50 50
 static int dt_mode;
51 51
 static int as_mode;
52 52
 
@@ -179,6 +179,43 @@ static void close_callback(mtk_event *e, void *arg)
179 179
 	mtk_cmd(appid, "w.close()");
180 180
 }
181 181
 
  182
+static void update_buttons()
  183
+{
  184
+	mtk_cmdf(appid, "b_mode_simple.set(-state %s)", simple_mode ? "on" : "off");
  185
+	mtk_cmdf(appid, "b_mode_file.set(-state %s)", !simple_mode ? "on" : "off");
  186
+	mtk_cmdf(appid, "b_mode_simple_dt.set(-state %s)", dt_mode ? "on" : "off");
  187
+	mtk_cmdf(appid, "b_mode_simple_as.set(-state %s)", as_mode ? "on" : "off");
  188
+}
  189
+
  190
+static void simple_callback(mtk_event *e, void *arg)
  191
+{
  192
+	simple_mode = 1;
  193
+	update_buttons();
  194
+}
  195
+
  196
+static void file_callback(mtk_event *e, void *arg)
  197
+{
  198
+	simple_mode = 0;
  199
+	update_buttons();
  200
+}
  201
+
  202
+static void dt_callback(mtk_event *e, void *arg)
  203
+{
  204
+	dt_mode = !dt_mode;
  205
+	update_buttons();
  206
+}
  207
+
  208
+static void as_callback(mtk_event *e, void *arg)
  209
+{
  210
+	as_mode = !as_mode;
  211
+	update_buttons();
  212
+}
  213
+
  214
+static void go_callback(mtk_event *e, void *arg)
  215
+{
  216
+	start_performance(simple_mode, dt_mode, as_mode);
  217
+}
  218
+
182 219
 void init_performance()
183 220
 {
184 221
 	appid = mtk_init_app("Performance");
@@ -186,19 +223,48 @@ void init_performance()
186 223
 	mtk_cmd_seq(appid,
187 224
 		"g = new Grid()",
188 225
 
189  
-		"l_text = new Label()",
  226
+		"gs = new Grid()",
  227
+		"l_mode = new Label(-text \"Mode:\")",
  228
+		"b_mode_simple = new Button(-text \"Simple:\")",
  229
+		"b_mode_simple_dt = new Button(-text \"Display titles\")",
  230
+		"b_mode_simple_as = new Button(-text \"Auto switch\")",
  231
+		"b_mode_file = new Button(-text \"Configured\")",
  232
+		"gs.place(l_mode, -column 1 -row 1)",
  233
+		"gs.place(b_mode_simple, -column 2 -row 1)",
  234
+		"gs.place(b_mode_simple_dt, -column 3 -row 1)",
  235
+		"gs.place(b_mode_simple_as, -column 4 -row 1)",
  236
+		"gs.place(b_mode_file, -column 2 -row 2)",
  237
+
  238
+		"separator1 = new Separator()",
  239
+		"l_status = new Label(-text \"Ready.\")",
190 240
 		"progress = new LoadDisplay()",
  241
+		"separator2 = new Separator()",
  242
+		
  243
+		"gb = new Grid()",
  244
+		"b_go = new Button(-text \"Go!\")",
191 245
 		"b_close = new Button(-text \"Close\")",
  246
+		"gb.place(b_go, -column 1 -row 1)",
  247
+		"gb.place(b_close, -column 2 -row 1)",
  248
+		"gb.columnconfig(2, -size 0)",
192 249
 
193  
-		"g.place(l_text, -column 1 -row 1)",
194  
-		"g.place(progress, -column 1 -row 2)",
195  
-		"g.place(b_close, -column 1 -row 3)",
196  
-		"g.columnconfig(1, -size 150)",
  250
+		"g.place(gs, -row 1 -column 1)",
  251
+		"g.place(separator1, -row 2 -column 1)",
  252
+		"g.place(l_status, -row 3 -column 1)",
  253
+		"g.place(progress, -row 4 -column 1)",
  254
+		"g.place(separator2, -row 5 -column 1)",
  255
+		"g.place(gb, -column 1 -row 6 -column 1)",
197 256
 
198 257
 		"w = new Window(-content g -title \"Performance\")",
199 258
 		0);
200 259
 
  260
+	mtk_bind(appid, "b_mode_simple", "press", simple_callback, NULL);
  261
+	mtk_bind(appid, "b_mode_file", "press", file_callback, NULL);
  262
+	mtk_bind(appid, "b_mode_simple_dt", "press", dt_callback, NULL);
  263
+	mtk_bind(appid, "b_mode_simple_as", "press", as_callback, NULL);
  264
+	
  265
+	mtk_bind(appid, "b_go", "commit", go_callback, NULL);
201 266
 	mtk_bind(appid, "b_close", "commit", close_callback, NULL);
  267
+
202 268
 	mtk_bind(appid, "w", "close", close_callback, NULL);
203 269
 }
204 270
 
@@ -286,6 +352,7 @@ static int keycode_to_index(int keycode)
286 352
 }
287 353
 
288 354
 static rtems_interval next_as_time;
  355
+#define AUTOSWITCH_PERIOD 3000
289 356
 
290 357
 static void event_callback(mtk_event *e, int count)
291 358
 {
@@ -305,7 +372,7 @@ static void event_callback(mtk_event *e, int count)
305 372
 			t = rtems_clock_get_ticks_since_boot();
306 373
 			if(t >= next_as_time) {
307 374
 				next = 1;
308  
-				next_as_time = t + 3000;
  375
+				next_as_time = t + AUTOSWITCH_PERIOD;
309 376
 			}
310 377
 		}
311 378
 		if(next) {
@@ -365,8 +432,9 @@ static void refresh_callback(mtk_event *e, int count)
365 432
 			if(compiled_patches == npatches) {
366 433
 				/* All patches compiled. Start rendering. */
367 434
 				input_delete_callback(refresh_callback);
  435
+				next_as_time = t + AUTOSWITCH_PERIOD;
368 436
 				input_add_callback(event_callback);
369  
-				mtk_cmd(appid, "l_text.set(-text \"Done.\")");
  437
+				mtk_cmd(appid, "l_status.set(-text \"Ready.\")");
370 438
 				if(!guirender(appid, patches[current_patch].p, stop_callback))
371 439
 					stop_callback();
372 440
 				return;
@@ -375,7 +443,7 @@ static void refresh_callback(mtk_event *e, int count)
375 443
 			int error_patch;
376 444
 
377 445
 			error_patch = -compiled_patches-1;
378  
-			mtk_cmdf(appid, "l_text.set(-text \"Failed to compile patch %s\")", patches[error_patch].filename);
  446
+			mtk_cmdf(appid, "l_status.set(-text \"Failed to compile patch %s\")", patches[error_patch].filename);
379 447
 			input_delete_callback(refresh_callback);
380 448
 			started = 0;
381 449
 			free_patches();
@@ -388,6 +456,7 @@ static void refresh_callback(mtk_event *e, int count)
388 456
 
389 457
 void open_performance_window()
390 458
 {
  459
+	update_buttons();
391 460
 	mtk_cmd(appid, "w.open()");
392 461
 }
393 462
 
@@ -403,6 +472,7 @@ void start_performance(int simple, int dt, int as)
403 472
 	simple_mode = simple;
404 473
 	dt_mode = dt;
405 474
 	as_mode = as;
  475
+	open_performance_window();
406 476
 
407 477
 	/* build patch list */
408 478
 	npatches = 0;
@@ -431,9 +501,8 @@ void start_performance(int simple, int dt, int as)
431 501
 
432 502
 	/* start patch compilation task */
433 503
 	compiled_patches = 0;
434  
-	mtk_cmd(appid, "l_text.set(-text \"Compiling patches...\")");
  504
+	mtk_cmd(appid, "l_status.set(-text \"Compiling patches...\")");
435 505
 	mtk_cmd(appid, "progress.barconfig(load, -value 0)");
436  
-	mtk_cmd(appid, "w.open()");
437 506
 	next_update = rtems_clock_get_ticks_since_boot() + UPDATE_PERIOD;
438 507
 	input_add_callback(refresh_callback);
439 508
 	sc = rtems_task_create(rtems_build_name('C', 'O', 'M', 'P'), 20, 64*1024,

0 notes on commit 8c36215

Please sign in to comment.
Something went wrong with that request. Please try again.