#include "MyClass.h"

enum {
  TRIGGER =   13,
  BTN =       14,
  RUMBLE =    16,
  SOLENOID =  17,
  BULBS =     18,
  CLICK =     19,
  LED =       25
} pinNames;

struct PINS { const char *label; byte pin; }
  inputs[] = {
    {"TRIGGER", TRIGGER},
    {"BTN",     BTN}
  }, 
  outputs[] = {
    {"RUMBLE",   RUMBLE},
    {"SOLENOID", SOLENOID},
    {"BULBS",    BULBS},
    {"CLICK",    CLICK},
    {"LED",      LED}
  }
;  



const int out_pins = (sizeof(outputs)/sizeof(outputs[0])),
          in_pins = (sizeof(inputs)/sizeof(inputs[0]));

byte      outObjLen,
          inObjLen;
/* -------------------------------------------------------- */

Out* myOutputs[out_pins];

/*Out myOutputs[] = {
    Out(outputs[0].label, outputs[0].pin), 
    Out(outputs[1].label, outputs[1].pin), 
    Out(outputs[2].label, outputs[2].pin), 
    Out(outputs[3].label, outputs[3].pin), 
    Out(outputs[4].label, outputs[4].pin)
  };               */

/* -------------------------------------------------------- */

int main () {
  for (byte i = 0; i < out_pins; i++) {
    myOutputs[i] = new Out(outputs[i].label, outputs[i].pin);
  }
  outObjLen = (sizeof(myOutputs)/sizeof(myOutputs[0]));
  
  init (); // setup timers and interrupts
  //initVariant();

  #if defined(USBCON)
    USBDevice.attach();
  #endif

  debug.begin(115200);
  debug.println("HELLO");
    
  debug.print("length: ");
  debug.println(outObjLen);
  
  for (byte i = 0; i < outObjLen; i++) myOutputs[i]->getName();

  // loop()
  while (1) { 
    delay(100);
  }; 
}

/*
int main () {
    gPtr[0] = new Out("ONE",4);
    init (); // setup timers and interrupts
    //initVariant();

    #if defined(USBCON)
      USBDevice.attach();
    #endif

    Serial.begin(9600);
    Serial.println("HELLO");
    gPtr[0]->getName();
    //Serial.println(gPtr[0].name);
    // all your normal code goes here

    while (1) {
      // main cannot exit (nowhere to exit TO)
    }; 
} */

/*void setup() {
  Serial.begin(9600);

  
  for (byte i = 0; i < out_pins; i++) {
    Out* myOutputs = new Out("first",13);
    Serial.print(i), Serial.print(" ");
    Serial.print(outputs[i].label), Serial.print(" ");
    Serial.println(outputs[i].pin);
    //Serial.print(" ");
    //Serial.print("myOutputs["+String(i)+"] = ");
    //Serial.println(String(myOutputs[i].pin));
    
    //myOutputs[i] = Out(outputs[i].label, outputs[i].pin); 
  }
  
  outObjLen = (sizeof(myOutputs)/sizeof(myOutputs[0]));
  Serial.print("length: ");
  Serial.println(outObjLen);
  

  //printObjects();
}
*/
/*
void printObjects() {
  Serial.print("length: ");
  Serial.println(objLen);

  for (byte i = 0; i < objLen; i++) {
    #define thisOut myOutputs[i]
    const char *str = thisOut.name;
    Serial.print(i);
    Serial.print(" ");
    Serial.println(str);
  }
}

void testClass() {
  Serial.println("\nmyOutputs[0]:");

  #define OB myOutputs[0]
  Serial.println(OB.name);
  OB.name = "HEJ";
  Serial.println(OB.name);
  OB.privFunc();
}
*/
/*void loop() {
  //myOutputs[0].myFunction(500);
}*/

BOOTSELLED1239USBRaspberryPiPico©2020RP2-8020/21P64M15.00TTT