Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jubeat copious - saucer (one new reader (no keypad) + one led board (game won't

DDR SN-SN2 (2 old slotted readers)

DDR X-X3 (2 readers (old or new) in sd, 2 readers (old or new) + led board ? in HD)
DDR X-X3 (2 readers (old or new) in sd, 2 readers (old or new) + HDXB button board and RGB speakers lights in HD)

drum mania (1 old reader)

Expand Down
85 changes: 76 additions & 9 deletions acrealio/Ddr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,35 @@ Ddr::Ddr()
{
byte rType[] = {0x04, 0x02, 0x00, 0x00};
byte rVersion[] = {0x01, 0x01, 0x00};
setVersion(rType, 0x00, rVersion, "HDXS");
setVersion(rType, 0x00, rVersion, "HDXB");

//RGB LEDs
pinMode(LED_DDR_HDXB_P1S_R, OUTPUT);
pinMode(LED_DDR_HDXB_P1S_G, OUTPUT);
pinMode(LED_DDR_HDXB_P1S_B, OUTPUT);
pinMode(LED_DDR_HDXB_P2S_R, OUTPUT);
pinMode(LED_DDR_HDXB_P2S_G, OUTPUT);
pinMode(LED_DDR_HDXB_P2S_B, OUTPUT);
pinMode(LED_DDR_HDXB_P1W_R, OUTPUT);
pinMode(LED_DDR_HDXB_P1W_G, OUTPUT);
pinMode(LED_DDR_HDXB_P1W_B, OUTPUT);
pinMode(LED_DDR_HDXB_P2W_R, OUTPUT);
pinMode(LED_DDR_HDXB_P2W_G, OUTPUT);
pinMode(LED_DDR_HDXB_P2W_B, OUTPUT);

//Button Lights
pinMode(LT_DDR_HDXB_P1_START, OUTPUT);
pinMode(LT_DDR_HDXB_P1_LR, OUTPUT);
pinMode(LT_DDR_HDXB_P1_UD, OUTPUT);
pinMode(LT_DDR_HDXB_P2_START, OUTPUT);
pinMode(LT_DDR_HDXB_P2_LR, OUTPUT);
pinMode(LT_DDR_HDXB_P2_UD, OUTPUT);
}

void Ddr::init()
{


}

void Ddr::update()
Expand All @@ -36,21 +60,64 @@ short Ddr::processRequest(byte* request, byte* answer)
memcpy(answer+5, getVersion(), 0x2C);
break;

//
// init?
case 0x00:
case 0x03:
case 0x10: //ping
answer[4] = 8;
answer[5]=0x45;
answer[6]=0x00;
answer[7]=0xdd;
answer[8]=0x80; //only byte that changes from the write leds code reply....
answer[9]=0xd4;
answer[10]=0x00;
answer[11]=0xcb;
answer[12]=0x00;

case 0x12: //write LEDs
//request[5] is always 0, followed by GRB (yes... GRB from what I can tell...) &0x7F
//lets multiply by 2 to get full 8 bit width for full brightness!
analogWrite(LED_DDR_HDXB_P1S_G,((request[6]&0x7F)*2));
analogWrite(LED_DDR_HDXB_P1S_R,((request[7]&0x7F)*2));
analogWrite(LED_DDR_HDXB_P1S_B,((request[8]&0x7F)*2));
analogWrite(LED_DDR_HDXB_P2S_G,((request[9]&0x7F)*2));
analogWrite(LED_DDR_HDXB_P2S_R,((request[10]&0x7F)*2));
analogWrite(LED_DDR_HDXB_P2S_B,((request[11]&0x7F)*2));
analogWrite(LED_DDR_HDXB_P1W_G,((request[12]&0x7F)*2));
analogWrite(LED_DDR_HDXB_P1W_R,((request[13]&0x7F)*2));
analogWrite(LED_DDR_HDXB_P1W_B,((request[14]&0x7F)*2));
analogWrite(LED_DDR_HDXB_P2W_G,((request[15]&0x7F)*2));
analogWrite(LED_DDR_HDXB_P2W_R,((request[16]&0x7F)*2));
analogWrite(LED_DDR_HDXB_P2W_B,((request[17]&0x7F)*2));

//now lets do the static lights -- take the first 6 bytes and grab the high bit, if its set, then write 1, else 0
digitalWrite(LT_DDR_HDXB_P1_START,(request[6]&0x80)>0?1:0);
digitalWrite(LT_DDR_HDXB_P1_LR,(request[7]&0x80)>0?1:0);
digitalWrite(LT_DDR_HDXB_P1_UD,(request[8]&0x80)>0?1:0);
digitalWrite(LT_DDR_HDXB_P2_START,(request[9]&0x80)>0?1:0);
digitalWrite(LT_DDR_HDXB_P2_LR,(request[10]&0x80)>0?1:0);
digitalWrite(LT_DDR_HDXB_P2_UD,(request[11]&0x80)>0?1:0);

answer[4] = 8;
answer[5]=0x45;
answer[6]=0x00;
answer[7]=0xdd;
answer[8]=0x40;
answer[9]=0xd4;
answer[10]=0x00;
answer[11]=0xcb;
answer[12]=0x00;

break;

// init commands?
case 0x00: //actually used here
case 0x03: //actually used here
case 0x16:
case 0x20:
case 0x28: //actually used here
case 0x30:
answer[4] = 1;
answer[5] = 0x00;
break;

case 0x10: //unknow

break;



}
Expand Down
11 changes: 0 additions & 11 deletions acrealio/Node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,6 @@
//
// Construct node version
//
void Node::setVersion(byte* rType, byte rFlag, byte* rVersion, const char* rCode)
{
char compileDate[0x10] = __DATE__;
char compileTime[0x10] = __TIME__;
memcpy(nodeVersion, rType, 4);
nodeVersion[4] = rFlag;
memcpy(nodeVersion+4+1, rVersion, 3);
memcpy(nodeVersion+8, rCode,4);
memcpy(nodeVersion+8+4, compileDate, 0x10);
memcpy(nodeVersion+8+4+16, compileTime, 0x10);
}

//
// Return node version
Expand Down
29 changes: 19 additions & 10 deletions acrealio/Node.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,27 @@
class Node
{
public:
virtual void init();

const char* getVersion();
void setVersion(byte* rType, byte rFlag, byte* rVersion, const char* rCode);

virtual short processRequest(byte* request, byte* sendBuff);
virtual void update(); //update things like keypadstate and rfid


private:
//making these default empty to save on space if someone wants to go through and kill all those empty implementations
virtual void init(){};
virtual void update(){}; //update things like keypadstate and rfid


const char* getVersion();
virtual void setVersion(byte* rType, byte rFlag, byte* rVersion, const char* rCode)
{
char compileDate[0x10] = __DATE__;
char compileTime[0x10] = __TIME__;
memcpy(nodeVersion, rType, 4);
nodeVersion[4] = rFlag;
memcpy(nodeVersion+4+1, rVersion, 3);
memcpy(nodeVersion+8, rCode,4);
memcpy(nodeVersion+8+4, compileDate, 0x10);
memcpy(nodeVersion+8+4+16, compileTime, 0x10);
};

virtual short processRequest(byte* request, byte* sendBuff);//everyone should implement this
virtual short processBroadcast(byte* payload, int length, byte* answer){return 0;};// by default a class doesn't need to implement this


char nodeVersion[0x2C];

Expand Down
16 changes: 16 additions & 0 deletions acrealio/RfidModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,22 @@
#include "Arduino.h"
#include "pinoutconfig.h"

#if RFID_MODULE1==1
#define RFID_MODULE1_TYPE RR10
#elif RFID_MODULE1==2
#define RFID_MODULE1_TYPE SL015M
#else
#define RFID_MODULE1_TYPE RR10
#endif

#if RFID_MODULE2==1
#define RFID_MODULE2_TYPE RR10
#elif RFID_MODULE2==2
#define RFID_MODULE2_TYPE SL015M
#else
#define RFID_MODULE2_TYPE RR10
#endif

class RfidModule
{
public:
Expand Down
81 changes: 81 additions & 0 deletions acrealio/Sat.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#include "Arduino.h"
#include "Sat.h"


//contructor
Sat::Sat()
{
//special type and version, node name is DDRS for all satellites
byte rType[] = {0x05, 0x01, 0x00, 0x00};
byte rVersion[] = {0x01, 0x00, 0x02};
setVersion(rType, 0x00, rVersion, "DDRS");


}

//needed an overloaded set version here, one version of DDR was VERY particular about having everything perfect
void Sat::setVersion(byte* rType, byte rFlag, byte* rVersion, const char* rCode)
{
//hard coded date and time
char compileDate[0x10] = {0x41, 0x75, 0x67, 0x20, 0x32, 0x35, 0x20, 0x32, 0x30, 0x30, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00};
char compileTime[0x10] = {0x31, 0x34, 0x3A, 0x32, 0x38, 0x3A, 0x34, 0x35, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
memcpy(nodeVersion, rType, 4);
nodeVersion[4] = rFlag;
memcpy(nodeVersion+4+1, rVersion, 3);
memcpy(nodeVersion+8, rCode,4);
memcpy(nodeVersion+8+4, compileDate, 0x10);
memcpy(nodeVersion+8+4+16, compileTime, 0x10);
}

//every node will get it's individual payload, it should not exceed 40 (0x28) bytes
short Sat::processBroadcast(byte* payload, int length, byte* answer)
{
answer[0]=0xFE;
answer[1]=0x00;

// Do something fun here, like maybe spam random lights on this node!
// Someone help decipher the decision forest in the spire MCU please
// There are fancy animations on the spires, its likely an arduino cannot
// address and controll every light individually to perform these animations
// and patterns, as well as brightness control. Each node will probably need
// some sort of MCU on it's own communicated to from here to perform an animation
// In otherwords, get ready for lots of software serials and a whole OTHER device
// to build on top of this

return 2; // the length of the answer we provide

}

//not a lot of these, most of this is just responding to
short Sat::processRequest(byte* request, byte* answer)
{
answer[0] = request[0] | 0x80; // reader id
answer[1] = request[1]; // ?
answer[2] = request[2]; // command
answer[3] = request[3]; // paquet id
answer[4] = 0; // data length

switch (answer[2]) // switch on the command
{
//
// get version
case 0x02:
answer[4] = 0x2C;
memcpy(answer+5, getVersion(), 0x2C);
break;


// init commands?
default:
answer[4] = 1;
answer[5] = 0x00;
break;



}



}

15 changes: 15 additions & 0 deletions acrealio/Sat.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include "Arduino.h"
#include "Node.h"

class Sat: public Node
{
public:
Sat(); //contructor
short processRequest(byte* request, byte* sendBuff);
short processBroadcast(byte* payload, int length, byte* answer);
void setVersion(byte* rType, byte rFlag, byte* rVersion, const char* rCode);
private:


};

Loading