void ScanSystem::test()
{
  GLuint scanbuffers[3];
  glGenBuffers(3,scanbuffers);

  GLuint low  = ScanSystem::BATCH_ELEMENTS/2;
  GLuint mid  = ScanSystem::BATCH_ELEMENTS*ScanSystem::BATCH_ELEMENTS;
  GLuint high = ScanSystem::BATCH_ELEMENTS*ScanSystem::BATCH_ELEMENTS*2;
  size_t offsize = ScanSystem::getOffsetSize(high);

  GLuint* data = new GLuint[high];
  for (GLuint i = 0; i < high; i++){
    data[i] = 1;
  }

  glNamedBufferStorageEXT(scanbuffers[0], high * sizeof(GLuint), &data[0], 0 );
  glNamedBufferStorageEXT(scanbuffers[1], high * sizeof(GLuint),0, GL_MAP_READ_BIT );
  glNamedBufferStorageEXT(scanbuffers[2], offsize,0,GL_MAP_READ_BIT);

  delete [] data;

  GLuint result;
  bool needcombine;

  // low
  needcombine = scanData(low, scanbuffers[0], scanbuffers[1], scanbuffers[2]);
  assert(needcombine == false);
  result = 0;
  glGetNamedBufferSubDataEXT(scanbuffers[1],sizeof(GLuint) * (low-1), sizeof(GLuint), &result);
  assert(result == low);

  // med
  needcombine = scanData(mid, scanbuffers[0], scanbuffers[1], scanbuffers[2]);
  assert(needcombine == true);
  result = 0;
  glGetNamedBufferSubDataEXT(scanbuffers[2],sizeof(GLuint) * (ScanSystem::BATCH_ELEMENTS-1), sizeof(GLuint), &result);
  assert(result == mid);

  combineWithOffsets(mid, scanbuffers[1], scanbuffers[2]);
  result = 0;
  glGetNamedBufferSubDataEXT(scanbuffers[1],sizeof(GLuint) * (mid-1), sizeof(GLuint), &result);
  assert(result == mid);

  // high
  needcombine = scanData(high, scanbuffers[0], scanbuffers[1], scanbuffers[2]);
  assert(needcombine == true);
  combineWithOffsets(high, scanbuffers[1], scanbuffers[2]);
  result = 0;
  glGetNamedBufferSubDataEXT(scanbuffers[1],sizeof(GLuint) * (high-1), sizeof(GLuint), &result);
  assert(result == high);

  glDeleteBuffers(3,scanbuffers);
}
Пример #2
0
int main(int argc, const char * argv[])
{
    if(argc != 3){
        fprintf(stderr, "invalid input\n");
        return 1;
    }
    
    FILE *dictFilePtr = fopen(argv[1], "r");
    if(dictFilePtr == NULL) {
      fprintf(stderr, "Cannot open the dictionary file\n");
      return 1;
    }
    
    FILE *dataFilePtr = fopen(argv[2], "r");
    if(dataFilePtr == NULL) {
        fprintf(stderr, "Cannot open the data file\n");
        return 1;
    }
    
    readDict(dictFilePtr);
    fclose(dictFilePtr);
    scanData(dataFilePtr);
    fclose(dataFilePtr);
    
    printTrie();
    
    return 0;
}
Пример #3
0
// Initialize touch input
void touchInit(uint32_t channelMask)
{
   int i;

   // Turn on clock gating for TSI and configure touch input
   clkEnable(CLK_TSI);

   TSI0_GENCS |= ( TSI_GENCS_ESOR_MASK    // Enable end of scan interrupt
                 | TSI_GENCS_MODE(0)      // Capacitive sensing
                 | TSI_GENCS_REFCHRG(4)   // Reference charge 4 uA
                 | TSI_GENCS_DVOLT(0)     // Voltage rails
                 | TSI_GENCS_EXTCHRG(7)   // External osc charge
                 | TSI_GENCS_PS(4)        // Pre-scalar divide by 4
                 | TSI_GENCS_NSCN(11)     // Scans per electrode
                 | TSI_GENCS_TSIIEN_MASK  // Input interrupt enable
                 | TSI_GENCS_STPE_MASK    // Enable in STOP mode
                 );

   TSI0_GENCS |= TSI_GENCS_TSIEN_MASK;

   // Read initial (baseline) values for each enabled channel
   sEnableMask = channelMask;
   for (i = (NUM_CHANNELS - 1); i >= 0; i--)
   {
      if ((1 << i) & sEnableMask)
      {
         scanStart(i);
         while (!(TSI0_GENCS & TSI_GENCS_EOSF_MASK)) // Wait until done
         ;

         sBaseCounts[i] = scanData();
      }
   }

   // Enable TSI interrupts and start the scan timer
   irqRegister(INT_TSI0, tsiIrqHandler, 0);
   irqEnable(INT_TSI0);

   {
      osTimerDef_t tDef;
      
      tDef.ptimer = startTimerCb;
      tDef.millisec = TOUCH_SCAN_TIME;
      tDef.name = "touch";

      sStartTimer = osTimerCreate(&tDef, osTimerPeriodic, 0);
      osTimerStart(sStartTimer, TOUCH_SCAN_TIME);
   }
}