Update of /cvsroot/pure-data/externals/hardware/memPIO
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18792
Modified Files:
memPIO.cpp
Log Message:
bugfix (unsigned char instead of char)
Index: memPIO.cpp
===================================================================
RCS file: /cvsroot/pure-data/externals/hardware/memPIO/memPIO.cpp,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** memPIO.cpp 13 Jul 2004 16:33:26 -0000 1.1.1.1
--- memPIO.cpp 28 Jul 2004 10:43:30 -0000 1.2
***************
*** 15,21 ****
* TODO: currently two [memPIO]s interfere
*
! *
! * copyleft:forum::für::umläute:2004
! */
#include <conio.h>
--- 15,21 ----
* TODO: currently two [memPIO]s interfere
*
! *
! * copyleft:forum::für::umläute:2004
! */
#include <conio.h>
***************
*** 27,47 ****
//#import "c:\windows\system\memx.ocx"
#import "c:\winnt\system32\memx.ocx"
!
! /* do a little help thing */
!
! typedef struct memPIO
! {
t_object x_obj;
MEMXLib::_DmeMPIOPtr pio;
int input[3];
! t_outlet *outlet[3];
! } t_memPIO;
!
! t_class *memPIO_class;
!
! static void memPIO_help(void)
! {
! post("\n\n...mem-PIO for pd"
! "\n\n(l) forum::für::umläute 2004\n"
"this software is under the GnuGPL that is provided with these files\n");
post("usage:");
--- 27,47 ----
//#import "c:\windows\system\memx.ocx"
#import "c:\winnt\system32\memx.ocx"
!
! /* do a little help thing */
!
! typedef struct memPIO
! {
t_object x_obj;
MEMXLib::_DmeMPIOPtr pio;
int input[3];
! t_outlet *outlet[3];
! } t_memPIO;
!
! t_class *memPIO_class;
!
! static void memPIO_help(void)
! {
! post("\n\n...mem-PIO for pd"
! "\n\n(l) forum::für::umläute 2004\n"
"this software is under the GnuGPL that is provided with these files\n");
post("usage:");
***************
*** 50,120 ****
post("\t'bang': returns the values of all readable ports");
post("\t'set <val>': set all writable ports to the 8bit-value");
! post("\t'set <val1> <val2> <val3>': set writable ports to the corresponding value");
}
static void memPIO_bang(t_memPIO*x){
! int port=3;
! x->pio->UpdateCache ();
! while(port--){
! if (!x->input[port]){
! long l=x->pio->CachedPort [port+1];
! outlet_float(x->outlet[port], l);
! }
! }
}
static void memPIO_mode(t_memPIO*x, t_symbol *s, int argc, t_atom*argv){
! MEMXLib::IO dir;
! bool out;
! switch(argc){
! default:
! error("memPIO: \"mode\" message needs 1 or 3 arguments, have %d", argc);
! return;
! case 1:
! out=(atom_getfloat(argv)>0.f);
! dir=(out)?MEMXLib::DirOut:MEMXLib::DirIn;
! x->pio->DirPort1 =dir; x->input[0]=out;
! x->pio->DirPort2 =dir; x->input[1]=out;
! x->pio->DirPort3H=dir; x->input[2]=out;
! x->pio->DirPort3L=dir;
! break;
! case 3:
! out=(atom_getfloat(argv+0)>0.f);
! x->pio->DirPort1 =(out)?MEMXLib::DirOut:MEMXLib::DirIn; x->input[0]=out;
! out=(atom_getfloat(argv+1)>0.f);
! x->pio->DirPort2 =(out)?MEMXLib::DirOut:MEMXLib::DirIn; x->input[1]=out;
! out=(atom_getfloat(argv+2)>0.f);
! x->pio->DirPort3H=(out)?MEMXLib::DirOut:MEMXLib::DirIn; x->input[2]=out;
! x->pio->DirPort3L=(out)?MEMXLib::DirOut:MEMXLib::DirIn;
! }
}
static void memPIO_set(t_memPIO*x, t_symbol*s, int argc, t_atom*argv){
! int port=3;
! char val[4]={0,0,0,0};
! switch(argc){
! case 1:
! val[0]=val[1]=val[2]=val[3]=atom_getfloat(argv);
! break;
! case 3:
! val[0]=atom_getfloat(argv+0);
! val[1]=atom_getfloat(argv+1);
! val[2]=atom_getfloat(argv+2);
! break;
! default:
! break;
! }
! while(port--)
! if(x->input[port]){
! x->pio->port[port+1]=val[port];
! }
}
--- 50,120 ----
post("\t'bang': returns the values of all readable ports");
post("\t'set <val>': set all writable ports to the 8bit-value");
! post("\t'set <val1> <val2> <val3>': set writable ports to the corresponding value");
}
static void memPIO_bang(t_memPIO*x){
! int port=3;
! x->pio->UpdateCache ();
! while(port--){
! if (!x->input[port]){
! long l=x->pio->CachedPort [port+1];
! outlet_float(x->outlet[port], l);
! }
! }
}
static void memPIO_mode(t_memPIO*x, t_symbol *s, int argc, t_atom*argv){
! MEMXLib::IO dir;
! bool out;
! switch(argc){
! default:
! error("memPIO: \"mode\" message needs 1 or 3 arguments, have %d", argc);
! return;
! case 1:
! out=(atom_getfloat(argv)>0.f);
! dir=(out)?MEMXLib::DirOut:MEMXLib::DirIn;
! x->pio->DirPort1 =dir; x->input[0]=out;
! x->pio->DirPort2 =dir; x->input[1]=out;
! x->pio->DirPort3H=dir; x->input[2]=out;
! x->pio->DirPort3L=dir;
! break;
! case 3:
! out=(atom_getfloat(argv+0)>0.f);
! x->pio->DirPort1 =(out)?MEMXLib::DirOut:MEMXLib::DirIn; x->input[0]=out;
! out=(atom_getfloat(argv+1)>0.f);
! x->pio->DirPort2 =(out)?MEMXLib::DirOut:MEMXLib::DirIn; x->input[1]=out;
! out=(atom_getfloat(argv+2)>0.f);
! x->pio->DirPort3H=(out)?MEMXLib::DirOut:MEMXLib::DirIn; x->input[2]=out;
! x->pio->DirPort3L=(out)?MEMXLib::DirOut:MEMXLib::DirIn;
! }
}
static void memPIO_set(t_memPIO*x, t_symbol*s, int argc, t_atom*argv){
! int port=3;
! unsigned char val[4]={0,0,0,0};
! switch(argc){
! case 1:
! val[0]=val[1]=val[2]=val[3]=atom_getfloat(argv);
! break;
! case 3:
! val[0]=atom_getfloat(argv+0);
! val[1]=atom_getfloat(argv+1);
! val[2]=atom_getfloat(argv+2);
! break;
! default:
! break;
! }
! while(port--)
! if(x->input[port]){
! x->pio->port[port+1]=val[port];
! }
}
***************
*** 124,133 ****
{
x->pio.Release ();
! }
!
! void *memPIO_new(void)
{
int i;
! bool found=false;
t_memPIO *x = (t_memPIO *)pd_new(memPIO_class);
// because we use a ActiveX we need to initialize OLE for this app
--- 124,133 ----
{
x->pio.Release ();
! }
!
! void *memPIO_new(void)
{
int i;
! bool found=false;
t_memPIO *x = (t_memPIO *)pd_new(memPIO_class);
// because we use a ActiveX we need to initialize OLE for this app
***************
*** 145,161 ****
// search until the highest-possible Card-ID
for(i = 0; i < x->pio->LastAttached; i++)
! {
! // select a device
! x->pio->CardId = i+1;
! // if selected device is attached, return
! if (x->pio->Attached){
! found=true;
! break;
! }
! }
i++;
if(!found){
! memPIO_free(x);
! return 0;
}
--- 145,161 ----
// search until the highest-possible Card-ID
for(i = 0; i < x->pio->LastAttached; i++)
! {
! // select a device
! x->pio->CardId = i+1;
! // if selected device is attached, return
! if (x->pio->Attached){
! found=true;
! break;
! }
! }
i++;
if(!found){
! memPIO_free(x);
! return 0;
}
***************
*** 163,187 ****
for (int n=0; n<3; n++) {
x->outlet[n] = outlet_new(&x->x_obj, 0);
! x->input[n]=0;
}
! return (void *)x;
! }
!
! void memPIO_setup(void)
! {
! post("\t the memPIO external");
! post("\t (l) forum::für::umläute");
! post("\t compiled: "__DATE__"");
!
memPIO_class = class_new(gensym("memPIO"),
! (t_newmethod)memPIO_new,
! (t_method)memPIO_free,
! sizeof(t_memPIO),
! 0, A_NULL);
class_addmethod(memPIO_class, (t_method)memPIO_help, gensym("help"), A_NULL);
class_addmethod(memPIO_class, (t_method)memPIO_mode, gensym("mode"), A_GIMME, A_NULL);
class_addmethod(memPIO_class, (t_method)memPIO_set, gensym("set"), A_GIMME, A_NULL);
! class_addbang(memPIO_class, (t_method)memPIO_bang);
! }
--- 163,187 ----
for (int n=0; n<3; n++) {
x->outlet[n] = outlet_new(&x->x_obj, 0);
! x->input[n]=0;
}
! return (void *)x;
! }
!
! void memPIO_setup(void)
! {
! post("\t the memPIO external");
! post("\t (l) forum::für::umläute");
! post("\t compiled: "__DATE__"");
!
memPIO_class = class_new(gensym("memPIO"),
! (t_newmethod)memPIO_new,
! (t_method)memPIO_free,
! sizeof(t_memPIO),
! 0, A_NULL);
class_addmethod(memPIO_class, (t_method)memPIO_help, gensym("help"), A_NULL);
class_addmethod(memPIO_class, (t_method)memPIO_mode, gensym("mode"), A_GIMME, A_NULL);
class_addmethod(memPIO_class, (t_method)memPIO_set, gensym("set"), A_GIMME, A_NULL);
! class_addbang(memPIO_class, (t_method)memPIO_bang);
! }