diff --git a/README.md b/README.md index 5325594..f066679 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,8 @@ iidx 19-20 (2 new wavepass readers) jubeat 1 - knit (one old slotted reader (no keypad) + one led board (game won't boot if the led board is not present) +jubeat copious - saucer (one new reader (no keypad) + one led board (game won't boot if the led board is not present) + DDR (2 old readers in sd, 2 new readers in HD) drum mania (1 old reader) diff --git a/acrealio/LedBoard.cpp b/acrealio/LedBoard.cpp index c97faf1..2016088 100644 --- a/acrealio/LedBoard.cpp +++ b/acrealio/LedBoard.cpp @@ -24,7 +24,6 @@ void LedBoard::init() void LedBoard::update() { - } diff --git a/acrealio/LedBoard.h b/acrealio/LedBoard.h index b69c970..65ebfbe 100644 --- a/acrealio/LedBoard.h +++ b/acrealio/LedBoard.h @@ -12,6 +12,6 @@ public: public: private: - byte ledStatus[]; + byte ledStatus[18]; }; diff --git a/acrealio/RR10.cpp b/acrealio/RR10.cpp index 17fc15b..280bf9c 100644 --- a/acrealio/RR10.cpp +++ b/acrealio/RR10.cpp @@ -10,7 +10,7 @@ RR10::RR10() pinset = false; } -void RR10::setPins(HardwareSerial* serialid) +void RR10::setPins(int sensor, HardwareSerial* serialid) { rfSerial = serialid; rfSerial->begin(115200); //the only possible baud rate for this module diff --git a/acrealio/RR10.h b/acrealio/RR10.h index a5ee48d..18514ca 100644 --- a/acrealio/RR10.h +++ b/acrealio/RR10.h @@ -8,7 +8,7 @@ class RR10 : public RfidModule { public: RR10(); - void setPins(HardwareSerial* serialid); + void setPins(int sensor, HardwareSerial* serialid); void read(); void update(); boolean isCardPresent(); diff --git a/acrealio/Reader.cpp b/acrealio/Reader.cpp index 946c84c..8e18d56 100644 --- a/acrealio/Reader.cpp +++ b/acrealio/Reader.cpp @@ -11,7 +11,7 @@ Reader::Reader() } //cmd61 is used to specify behaviour on command 0x61 -void Reader::setrCode(char* rCode, boolean cmd61_s) +void Reader::setrCode(char* rCode, byte cmd61_s) { setVersion((byte[]) {0x03, 0x00, 0x00, 0x00}, 0x00, (byte[]) {0x01, 0x06, 0x00}, rCode); cmd61 = cmd61_s; @@ -191,7 +191,7 @@ void Reader::getStatus(byte* buf) buf[1] = 0x10; } else{ - buf[0] = 0x04; + buf[0] = 0x01; } } @@ -253,7 +253,7 @@ short Reader::processRequest(byte* request, byte* answer) if(rfmodule->isCardPresent()) { answer[6] = 0x10; // light up front sensor (just in case) - answer[5] = 0x01; // if 2 -> action loop on 31 (if 0 too btw) + answer[5] = 0x01; // if 2 -> action loop on 31 } break; @@ -316,11 +316,21 @@ short Reader::processRequest(byte* request, byte* answer) new_reader = true; //only new readers issue this command rfmodule->read(); - - if(cmd61)// for pop'n music and jubeat, should not return any data, for iidx and sdvx, should return one byte of data with value 0x01 + + // for pop'n music, should not return any data, for iidx and sdvx, should return one byte of data with value 0x01 for jubeat, should return at least 2 data (something seems wrong here) + switch(cmd61) { + case 1: answer[4] = 1; answer[5] = 0x01; + break; + case 2: + answer[4] = 2; + answer[5] = 0x00; + answer[6] = 0x00; + break; + default: + answer[4] = 0; } diff --git a/acrealio/Reader.h b/acrealio/Reader.h index c078613..623b38d 100644 --- a/acrealio/Reader.h +++ b/acrealio/Reader.h @@ -10,7 +10,7 @@ class Reader : public Node { public: Reader(); //contructor - void setrCode(char* rCode, boolean cmd61 = false); + void setrCode(char* rCode, byte cmd61 = 0); void init(); void update(); //update things like keypadstate and rfid @@ -39,7 +39,7 @@ private: short colPins[3]; // matrix has 3 cols... short rowPins[4]; // ...and 4 rows - boolean cmd61; //used to specify behaviour on command 0x61 + byte cmd61; //used to specify behaviour on command 0x61 boolean new_reader; //set to true in case new wave pass card reader behaviour is requested from game Cipher crypt; diff --git a/acrealio/RfidModule.h b/acrealio/RfidModule.h index ad21ed2..f4f3751 100644 --- a/acrealio/RfidModule.h +++ b/acrealio/RfidModule.h @@ -7,6 +7,7 @@ class RfidModule { public: + virtual void setPins(int sensor, HardwareSerial* serialid); virtual void read(); virtual void update(); virtual boolean isCardPresent(); diff --git a/acrealio/acrealio.ino b/acrealio/acrealio.ino index cd80ceb..955aa7b 100644 --- a/acrealio/acrealio.ino +++ b/acrealio/acrealio.ino @@ -31,7 +31,56 @@ unsigned long lastRecv; byte nbnodes; // nodes count (currently supports 1 or 2) byte node_id; //id of first node (may be != 1 when used with other physical nodes) -Node *nodes[MAX_NODES]; +Node *nodes[MAX_NODES];//nodes array + +//nodes delaraction (static allocation) + +#if GAMETYPE == 0 //pop'n music with card dispenser + +Reader nod1;//first reader +CardDispenser nod2("PCDA"); //card dispenser + +#elif GAMETYPE == 1 //1 reader + +Reader nod1;//first reader + +#elif GAMETYPE == 2 //2 readers + +Reader nod1;//first reader + +Reader nod2;//second reader + +#elif GAMETYPE == 3 // reader + leboard + +Reader nod1;//first reader +LedBoard nod2("LEDB");//led board + +#else // reader + ioboard + +Reader nod1;//first reader +IoBoard nod2("KFCA");//io board + +#endif + + +//1P rfid module allocation + +#if RFID_MODULE1 == 1 +SL015M mod1; +#else +RR10 mod1; +#endif + + + +//2P rfid module allocation +#if GAMETYPE == 2 +#if RFID_MODULE2 == 1 +SL015M mod2; +#else +RR10 mod2; +#endif +#endif // @@ -41,110 +90,68 @@ Node *nodes[MAX_NODES]; // void setup() { - // init nodes depending on game type + // set nodes configuration - // init first reader used in all games types - Reader* read1 = new Reader(); + //set first rfid module + mod1.setPins(R1_DET,&R1_SER); + nod1.setRfidModule(&mod1); - //rfid module, 2 modules model are supported, configure the module to use - switch(RFID_MODULE1) - { - case 1: - { - SL015M* mod1 = new SL015M(); - mod1->setPins(R1_DET,&R1_SER); - read1->setRfidModule(mod1); - break; - } - case 2: - { - RR10* mod1 = new RR10(); - mod1->setPins(&R1_SER); - read1->setRfidModule(mod1); - break; - } - } - - - switch(gametype) - { - case 4: //Sound voltex, set an IoBoard + a Reader - { - //1st node IOBOARD - IoBoard* iob = new IoBoard("KFCA"); - nodes[1] = iob; - - //2nd node reader - read1->setrCode("ICCA",true); - //keypad - read1->setkeypadpins(K1_A,K1_B,K1_C,K1_1,K1_2,K1_3,K1_4);//3cols,4rows - - nodes[0] = read1; - break; - } - - - case 3://jubeat, set a reader (without keypad) + a LedBoard - { - read1->setrCode("ICCB"); - - nodes[0] = read1; - nodes[1] = new LedBoard("LED"); // jubeat ledboard node - - break; - } - case 2://2readers game, Set reader 2 as node 2 - { - Reader* read2 = new Reader(); - read2->setrCode("ICCA",true); - read2->setkeypadpins(K2_A,K2_B,K2_C,K2_1,K2_2,K2_3,K2_4);//3cols,4rows - //rfid module - switch(RFID_MODULE2) - { - case 1: - { - SL015M* mod2 = new SL015M(); - mod2->setPins(R2_DET,&R2_SER); - read2->setRfidModule(mod2); - break; - } - case 2: - { - RR10* mod2 = new RR10(); - mod2->setPins(&R2_SER); - read2->setRfidModule(mod2); - break; - } - } - } - - case 1: //1 Reader game, set reader 1 as node 1 - { - read1->setrCode("ICCA",gametype == 2); - //keypad - read1->setkeypadpins(K1_A,K1_B,K1_C,K1_1,K1_2,K1_3,K1_4);//3cols,4rows - nodes[0] = read1; - break; - } - case 0: // pop'n music with card dispenser, 1 reader + 1 card dispenser - { - read1->setrCode("ICCA"); - //keypad - read1->setkeypadpins(K1_A,K1_B,K1_C,K1_1,K1_2,K1_3,K1_4);//3cols,4rows - nodes[0] = read1; - nodes[1] = new CardDispenser("PCDA"); - - break; - } - +#if GAMETYPE == 0 //pop'n music with card dispenser + + nod1.setrCode("ICCA",0); + nod1.setkeypadpins(K1_A,K1_B,K1_C,K1_1,K1_2,K1_3,K1_4);//3cols,4rows + nodes[0] = &nod1; + nodes[1] = &nod2; - } - - //set how many nodes are emulated by this board - if(gametype == 1) - nbnodes = 1; - else - nbnodes = 2; + nbnodes = 2; + +#elif GAMETYPE == 1 //1 reader + + nod1.setrCode("ICCA",0); + nod1.setkeypadpins(K1_A,K1_B,K1_C,K1_1,K1_2,K1_3,K1_4);//3cols,4rows + nodes[0] = &nod1; + + nbnodes = 1; + +#elif GAMETYPE == 2 //2 readers + //1p reader + nod1.setrCode("ICCA",1); + nod1.setkeypadpins(K1_A,K1_B,K1_C,K1_1,K1_2,K1_3,K1_4);//3cols,4rows + nodes[0] = &nod1; + + //set rfid module 2 + mod2.setPins(R2_DET,&R2_SER); + nod2.setRfidModule(&mod2); + + //2p reader + nod2.setrCode("ICCA",1); + nod2.setkeypadpins(K2_A,K2_B,K2_C,K2_1,K2_2,K2_3,K2_4);//3cols,4rows + nodes[1] = &nod2; + + nbnodes = 2; + +#elif GAMETYPE == 3 // reader + leboard + + nod1.setrCode("ICCB",2); + nodes[0] = &nod1; + nodes[1] = &nod2; + + nbnodes = 2; + + +#else // reader + ioboard + + //1p reader + nod1.setrCode("ICCA",1); + nod1.setkeypadpins(K1_A,K1_B,K1_C,K1_1,K1_2,K1_3,K1_4);//3cols,4rows + nodes[0] = &nod1; + nodes[1] = &nod2; + + nbnodes = 2; + +#endif + + } @@ -348,7 +355,7 @@ void sendAnswer(byte* answer) //checksum calc done, let's send it //delay if needed - if(gametype !=4) //delay only if game is not sound voltex + if(GAMETYPE !=4) //delay only if game is not sound voltex { unsigned long now = millis(); if((now - lastSent) < MINTIME && (now - lastSent) > 0) // Check If last packet was too early diff --git a/acrealio/pinoutconfig.h b/acrealio/pinoutconfig.h index 9965e10..5cf7745 100644 --- a/acrealio/pinoutconfig.h +++ b/acrealio/pinoutconfig.h @@ -1,7 +1,7 @@ #ifndef CONFIG_H #define CONFIG_H -#define gametype 1 //0:pop'n with card dispenser 1: pop'n, drummania(1 reader) 2:iidx/ddr/gf(2readers) 3:jubeat (1reader+Ledboard) 4: sdvx (1reader+ioboard) +#define GAMETYPE 1 //0:pop'n with card dispenser 1: pop'n, drummania(1 reader) 2:iidx/ddr/gf(2readers) 3:jubeat (1reader+Ledboard) 4: sdvx (1reader+ioboard) #define RFID_BAUD 115200 //Baud rate for RFID Module