From 80dbf9dcc8d8c6b5a393b0a57c2ec4d5d8274f27 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Wed, 12 Mar 2008 18:44:09 +0000 Subject: added arguments to the object and finished the help patch using the PDDP template svn path=/trunk/externals/apple/; revision=9575 --- keyboard_light-help.pd | 112 ++++++++++++++++++++++++++++++++++++++----------- keyboard_light.c | 8 ++-- 2 files changed, 93 insertions(+), 27 deletions(-) diff --git a/keyboard_light-help.pd b/keyboard_light-help.pd index 2af1f34..d9f6970 100644 --- a/keyboard_light-help.pd +++ b/keyboard_light-help.pd @@ -1,25 +1,89 @@ -#N canvas 0 22 506 356 10; -#X msg 136 78 bang; -#X obj 159 117 hsl 128 15 0 1 0 0 empty empty empty -2 -6 0 10 -262144 --1 -1 8000 0; -#X floatatom 136 291 5 0 0 0 - - -; -#X obj 136 247 apple/keyboard_light; -#X text 294 116 light level; -#X obj 256 148 hsl 128 15 40 4000 1 0 empty empty empty -2 -6 0 10 --262144 -1 -1 0 0; -#X text 391 147 fade time; -#X floatatom 270 173 5 0 0 0 - - -; -#X floatatom 165 140 5 0 0 0 - - -; -#X text 26 23 Control the keyboard lights on Apples.; -#X text 178 77 get current leve; -#X text 210 206 set level and fade as a list; -#X msg 165 217 0 50; -#X msg 161 195 1 1000; +#N canvas 193 46 567 584 10; +#X obj 4 529 cnv 15 550 20 empty \$0-pddp.cnv.footer empty 20 12 0 +14 -228856 -66577 0; +#X obj 4 -17 cnv 15 550 40 empty \$0-pddp.cnv.header keyboard_light +3 12 0 18 -204280 -1 0; +#X obj 3 239 cnv 3 550 3 empty \$0-pddp.cnv.inlets inlets 15 12 0 13 +-228856 -1 0; +#N canvas 779 22 494 344 META 0; +#X text 12 25 KEYWORDS control number float store; +#X text 12 45 LICENSE GPL; +#X text 12 65 TEMPLATE template-help.pd v0.1; +#X text 12 85 PLATFORM windows macosx gnulinux; +#X text 12 105 DATATYPE float list; +#X text 12 5 GENRE storage; +#X text 12 125 LIBRARY internal; +#X text 12 145 WEBSITE http://crca.ucsd.edu/~msp/; +#X text 12 165 RELEASE_DATE 2007-08-24; +#X text 12 185 RELEASE_VERSION 0.40-test05; +#X restore 504 531 pd META; +#X obj 3 359 cnv 3 550 3 empty \$0-pddp.cnv.outlets outlet 15 12 0 +13 -228856 -1 0; +#X obj 3 409 cnv 3 550 3 empty \$0-pddp.cnv.argument arguments 15 12 +0 13 -228856 -1 0; +#X obj 3 469 cnv 3 550 3 empty \$0-pddp.cnv.more_info more_info 15 +12 0 13 -228856 -1 0; +#X obj 72 325 cnv 17 3 20 empty \$0-pddp.cnv.let.1 1 5 9 0 16 -228856 +-162280 0; +#X obj 72 259 cnv 17 3 60 empty \$0-pddp.cnv.let.0 0 5 9 0 16 -228856 +-162280 0; +#N canvas 309 454 609 478 guts 0; +#X obj 117 95 textfile; +#X msg 116 24 symbol template-HCS.pd; +#X msg 116 54 read \$1 \, rewind \, bang; +#X obj 117 141 trigger bang anything; +#X obj 58 117 bang; +#X obj 240 162 route #X; +#X obj 240 183 route text; +#X obj 240 250 route DESCRIPTION; +#X obj 239 276 print; +#X obj 140 277 print TEXT; #X connect 0 0 3 0; -#X connect 1 0 3 0; -#X connect 1 0 8 0; -#X connect 3 0 2 0; -#X connect 5 0 3 1; -#X connect 5 0 7 0; -#X connect 12 0 3 0; -#X connect 13 0 3 0; +#X connect 1 0 2 0; +#X connect 2 0 0 0; +#X connect 3 0 4 0; +#X connect 3 1 5 0; +#X connect 4 0 0 0; +#X connect 5 0 6 0; +#X connect 7 0 8 0; +#X restore 453 531 pd guts; +#X obj 412 6 pddp/pddplink http://wiki.puredata.info/en/keyboard_light +-text pdpedia: keyboard_light; +#X text 15 6 description: query and control the keyboard lights on +Apples; +#X obj 426 -14 apple/keyboard_light; +#X msg 125 39 bang; +#X obj 158 70 hsl 128 15 0 1 0 0 empty empty empty -2 -6 0 10 -204786 +-1 -1 0 0; +#X floatatom 135 214 5 0 0 0 - - -; +#X obj 135 177 apple/keyboard_light; +#X text 293 69 light level; +#X obj 255 91 hsl 128 15 40 4000 1 0 empty empty empty -2 -6 0 10 -204800 +-1 -1 0 0; +#X text 390 90 fade time; +#X floatatom 261 110 5 0 0 0 - - -; +#X floatatom 164 93 5 0 0 0 - - -; +#X text 209 136 set level and fade as a list; +#X msg 164 147 0 50; +#X msg 160 125 1 1000; +#X text 167 38 get current level; +#X text 102 298 LIST - set the keyboard light level and fade time in +ms; +#X text 102 325 FLOAT - set the fade time in milliseconds (ms); +#X text 103 377 FLOAT - the current keyboard light level (between 0 +and 1); +#X text 102 278 FLOAT - set the keyboard light level (between 0 and +1); +#X text 102 258 BANG - output current keyboard light level; +#X text 102 427 Accepts two floats as arguments \, the first sets the +keyboard light level \, the second sets the fade time.; +#X obj 104 495 pddp/pddplink http://www.osxbook.com/book/bonus/chapter10/light/ +; +#X connect 13 0 16 0; +#X connect 14 0 16 0; +#X connect 14 0 21 0; +#X connect 16 0 15 0; +#X connect 18 0 16 1; +#X connect 18 0 20 0; +#X connect 23 0 16 0; +#X connect 24 0 16 0; diff --git a/keyboard_light.c b/keyboard_light.c index 798d624..b7bac75 100644 --- a/keyboard_light.c +++ b/keyboard_light.c @@ -133,7 +133,7 @@ static void keyboard_light_free(t_keyboard_light* x) } -static void *keyboard_light_new(void) +static void *keyboard_light_new(t_float level, t_float fade_time) { DEBUG(post("keyboard_light_new");); t_keyboard_light *x = (t_keyboard_light *)pd_new(keyboard_light_class); @@ -165,10 +165,12 @@ static void *keyboard_light_new(void) error("[keyboard_light]: IOServiceOpen(): %d", kernResult); } - x->fade_time = 0.; + x->fade_time = fade_time; floatinlet_new(&x->x_obj, &x->fade_time); outlet_new(&x->x_obj, &s_float); + keyboard_light_float(x, level); + return (x); } @@ -179,7 +181,7 @@ void keyboard_light_setup(void) (t_method)keyboard_light_free, sizeof(t_keyboard_light), CLASS_DEFAULT, - A_DEFFLOAT, 0); + A_DEFFLOAT, A_DEFFLOAT, 0); /* add inlet datatype methods */ class_addbang(keyboard_light_class,(t_method) keyboard_light_output); class_addfloat(keyboard_light_class,(t_method) keyboard_light_float); -- cgit v1.2.1