 }
 
 
+//------------------------------------------------------------------------------------------------
+
 char tohexch(byte val)
 {
   val = val & 0x0F;

      if (row == CARD_ROWS)
      {
        state = STATE_END;
        //Serial.println(state);
      }
      else
      {
        state = STATE_WAITING_ROW;
        //Serial.println(state);
      }
    break;
    
    case STATE_END:
      // wait here until card removal
      // Note, later version will read on way out again, and complare in and out readings
      if ((freg == 1) && (now == 0xFF))
      {
        sendCardReport(REPORT_OK_CARD, card, CARD_ROWS);
        state = STATE_NOCARD;
        //Serial.println(state);
      }
    break;
    

#define LED_D1       14
#define LED_D0       15

// map any input bit to any output bit position
// useful for retracking PCB's to avoid vias

// For 8 bit data reader
//                   xin:       b7    b6    b5    b4    b3    b2    b1    b0
//static const byte PROGMEM xout[8] = {1<<7, 1<<6, 1<<5, 1<<4, 1<<3, 1<<2, 1<<1, 1<<0};

// For 1 bit data reader (make sure D7 (A1) maps to all bits so ALL_HOLES and ALL_SPACES work
static const byte PROGMEM xout[8] = {0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};


//===== CONSTANTS ===================================================================

#define ALL_PAPER  (PAPER*0xFF)
#define ALL_HOLES  (HOLE *0xFF)

#define REG_PAPER PAPER 
#define REG_HOLE  HOLE

// Set to 8, will only read IN phase
// Set to 16, will read and collect OUT phase also
// Must see all CARD_ROWS rows to get a OK report
