예제 #1
0
/**********************************************************
  demo the 3D API for the 4x4x4 LED cube
 **********************************************************/
void lightCubeDemo(void)
{
  myRainbow.closeAll();
  
  for (int i = 0; i < 4; i++){
    for (int j = 0; j < 4; j++){
      for (int k = 0; k < 4; k++){
        checkReturn(cmdArrived);
        delay(10);
        myRainbow.lightOneDot(i,j,k,WHITE,OTHERS_OFF);
      }
    }
  }
  delay(50);
  myRainbow.closeAll();
  
  delay(1000);
  
  for (int i = 0; i < 4; i++){
    for (int j = 0; j < 4; j++){
      for (int k = 0; k < 4; k++){
        checkReturn(cmdArrived);
        delay(30);
        myRainbow.lightOneDot(i,j,k,GREEN,OTHERS_ON);
      }
    }
  }
  
  delay(1000);
  
   for (int i = 3; i >= 0; i--){
    for (int j = 3; j >= 0; j--){
      for (int k = 3; k >= 0; k--){
        checkReturn(cmdArrived);
        delay(80);
        myRainbow.lightOneDot(i,j,k,RED,OTHERS_ON);
      }
    }
  }
  
  delay(2000);
  
  // do some plane walking
  // first walk across the X axis
  for(int i = 0 ; i <=3; i++){
    myRainbow.light3D(i,0xff,0xff,BLUE,OTHERS_OFF);
    delay(500);
  }
  // now walk up the y axis
  for(int i = 0 ; i <=3; i++){
    myRainbow.light3D(0xff,i,0xff,VIOLET,OTHERS_OFF);
    delay(500);
  }
  // run back the z axis
  for(int i = 0 ; i <=3; i++){
    myRainbow.light3D(0xff,0xff,i,YELLOW,OTHERS_OFF);
    delay(500);
  }
 
}
예제 #2
0
void SymbolCheckVisitor::visit(ASTFunction& ast)
{
   ScopedScope scope(mScopeStack);
   ScopedValue<ASTFunction*> scopedfunction(&mpFunction, &ast, mpFunction);
   ASSERT_PTR(mpFunction);

   visitChildren(ast); // <-- arguments

   if ( ast.isConstructor() && ast.getName() != mpClass->getName() )
   {
      error(E0005, UTEXT("Function ") + ast.getName() + UTEXT(" must have a return type (or equal class name as constructor)."), ast);
   }

   if ( ast.hasBody() )
   {
      if ( ast.getModifiers().isAbstract() )
      {
         error(E0006, UTEXT("Abstract function ") + ast.getName() + UTEXT(" should not have a body."), ast);
      }
      else
      {
         checkReturn(ast);

         ast.getBody().accept(*this);
      }
   }
   else if ( !ast.getModifiers().isAbstract() && !ast.getModifiers().isPureNative() )
   {
      error(E0007, UTEXT("Function ") + ast.getName() + UTEXT(" requires a body."), ast);
   }

   mCurrentType.clear();
}
예제 #3
0
void Binder::bind(std::size_t pos, const Poco::Data::BLOB& val)
{
	// convert a blob to a an unsigned char* array
	const unsigned char* pData = reinterpret_cast<const unsigned char*>(val.rawContent());
	int valSize = static_cast<int>(val.size());

	int rc = sqlite3_bind_blob(_pStmt, static_cast<int>(pos), pData, valSize, SQLITE_STATIC); // no deep copy, do not free memory
	checkReturn(rc);
}
예제 #4
0
//light 12v led strip in 0~9 number way
void lightLedStripNumberDemo(void)
{
      
    static int colorNum = 0;
    for(int i = 0; i < 10; i++)
    {
      checkReturn(cmdArrived);
      delay(1000);
      //display 0~9 with specific color
      lightLedStripNumber(i,color[colorNum]);
    }
    if(++colorNum == 8) colorNum = 0;
}
void Binder::bind(std::size_t pos, const double &val, Direction dir)
{
	int rc = sqlite3_bind_double(_pStmt, (int) pos, val);
	checkReturn(rc);
}
void Binder::bind(std::size_t pos, const unsigned long &val, Direction dir)
{
	long tmp = static_cast<long>(val);
	int rc = sqlite3_bind_int(_pStmt, (int) pos, tmp);
	checkReturn(rc);
}
void Binder::bind(std::size_t pos, const Poco::Int64 &val, Direction dir)
{
	int rc = sqlite3_bind_int64(_pStmt, (int) pos, val);
	checkReturn(rc);
}
void Binder::bind(std::size_t pos, const std::string& val, Direction dir)
{
	int rc = sqlite3_bind_text(_pStmt, (int) pos, val.c_str(), (int) val.size()*sizeof(char), SQLITE_TRANSIENT);
	checkReturn(rc);
}
예제 #9
0
void Binder::bind(std::size_t pos, const Poco::Int32 &val)
{
	int rc = sqlite3_bind_int(_pStmt, (int) pos, val);
	checkReturn(rc);
}
예제 #10
0
void Binder::bind(std::size_t pos)
{
	int rc = sqlite3_bind_null(_pStmt, static_cast<int>(pos));
	checkReturn(rc);
}
예제 #11
0
void flashMatrixDemo(void)
{
 int i = 0;
 int j = 0;

 //all with the same color
 for(i = 0; i < 8; i++)
 {
   checkReturn(cmdArrived);
   delay(1000);
   myRainbow.lightAll(color[i]);
 }

 //sweep one line while others off
 for(i = 0; i < 8; i++)
 {
   checkReturn(cmdArrived);
   delay(100);
   //myRainbow.lightOneLine(i,color[i],OTHERS_OFF);
   myRainbow.lightOneLine(i,myRainbow.receiveBuffer[i],OTHERS_OFF);
 }

 //sweep one line while others on
 for(i = 7; i >= 0; i--)
 {
   checkReturn(cmdArrived);
   delay(100);
   //myRainbow.lightOneLine(i,color[i],OTHERS_ON);
   myRainbow.lightOneLine(i,myRainbow.receiveBuffer[i],OTHERS_ON);
 }
 
 //sweep one column while others off
 for(i = 0; i < 8; i++)
 {
   checkReturn(cmdArrived);
   delay(100);
   //myRainbow.lightOneColumn(i,color[i],OTHERS_OFF);
   myRainbow.lightOneColumn(i,myRainbow.receiveBuffer,OTHERS_OFF);
 }
 
 //sweep one colum while others on
 for(i = 7; i >= 0; i--)
 {
   checkReturn(cmdArrived);
   delay(100);
   //myRainbow.lightOneColumn(i,color[i],OTHERS_ON);
   myRainbow.lightOneColumn(i,myRainbow.receiveBuffer,OTHERS_ON);
 }
 
 //sweep each dot while others off
 for(i = 0; i < 8; i++)
   for(j = 0;j < 8; j++)
   {
     checkReturn(cmdArrived);
     delay(50);
     //myRainbow.lightOneDot(i,j,color[j],OTHERS_OFF);
     myRainbow.lightOneDot(i,j,myRainbow.receiveBuffer[i][j],OTHERS_OFF);
   }
 
 //sweep each dot while others on
 for(i = 7; i >= 0; i--)
   for(j = 7;j >= 0; j--)
   {
     checkReturn(cmdArrived);
     delay(50);
     //myRainbow.lightOneDot(i,j,color[j],OTHERS_ON);
     myRainbow.lightOneDot(i,j,myRainbow.receiveBuffer[i][j],OTHERS_ON);
   }
 
  //sweep the diagonal line from top left to riht bottom while others off
  for(i = 0; i < 16; i++)
  {
    checkReturn(cmdArrived);
    delay(100);
    //myRainbow.lightOneDiagonal(i,LEFT_BOTTOM_TO_RIGHT_TOP,color[i&0x07],OTHERS_OFF);
    myRainbow.lightOneDiagonal(i,LEFT_BOTTOM_TO_RIGHT_TOP,myRainbow.receiveBuffer,OTHERS_OFF);
  }
  
  //sweep the diagonal line from riht bottom to top left while others on
  for(i = 15; i >= 0; i--)
  {
    checkReturn(cmdArrived);
    delay(100);
    //myRainbow.lightOneDiagonal(i,LEFT_BOTTOM_TO_RIGHT_TOP,color[i&0x07],OTHERS_ON);
    myRainbow.lightOneDiagonal(i,LEFT_BOTTOM_TO_RIGHT_TOP,myRainbow.receiveBuffer,OTHERS_ON);
  }

  //sweep the diagonal line from bottom left to riht top while others off
  for(i = 0; i < 16; i++)
  {
    checkReturn(cmdArrived);
    delay(100);
    //myRainbow.lightOneDiagonal(i,LEFT_TOP_TO_RIGHT_BOTTOM,color[i&0x07],OTHERS_OFF);
    myRainbow.lightOneDiagonal(i,LEFT_TOP_TO_RIGHT_BOTTOM,myRainbow.receiveBuffer,OTHERS_OFF);
  }

  //sweep the diagonal line from riht top to bottom left while others on
  for(i = 15; i >= 0; i--)
  {
    checkReturn(cmdArrived);
    delay(100);
    //myRainbow.lightOneDiagonal(i,LEFT_TOP_TO_RIGHT_BOTTOM,color[i&0x07],OTHERS_ON);
    myRainbow.lightOneDiagonal(i,LEFT_TOP_TO_RIGHT_BOTTOM,myRainbow.receiveBuffer,OTHERS_ON);
  }
  
  //sweep 1/4 part of matrix
  checkReturn(cmdArrived);
  delay(200);
  static int k = 0;
  
  for(int m = 0; m < 4; m++)
  {
    for(i = 0; i < 4; i++)
    {
      for(j = 0; j < (i+1)*2; j++)
      {
        myRainbow.lightOneDot(3-i,3-i+j,color[k],OTHERS_ON);
      }
    }
    if(8 == ++k) k = 0;
    
    checkReturn(cmdArrived);
    delay(500);
    for(i = 0; i < 4; i++)
    {
      for(j = 0; j < (i+1)*2; j++)
      {
        myRainbow.lightOneDot(3-i+j,4+i,color[k],OTHERS_ON);
      }
    }
    if(8 == ++k) k = 0;
    
    checkReturn(cmdArrived);
    delay(500);
    for(i = 0; i < 4; i++)
    {
      for(j = 0; j < (i+1)*2; j++)
      {
        myRainbow.lightOneDot(4+i,3-i+j,color[k],OTHERS_ON);
      }
    }
    if(8 == ++k) k = 0;
    
    checkReturn(cmdArrived);
    delay(500);
    for(i = 0; i < 4; i++)
    {
      for(j = 0; j < (i+1)*2; j++)
      {
        myRainbow.lightOneDot(3-i+j,3-i,color[k],OTHERS_ON);
      }
    }
    if(8 == ++k) k = 0;
  }

}
예제 #12
0
void setup() {
#ifdef DEBUG
  printf("Config Starting \n");
#endif

  ANTUART = fopen("/dev/uart_0", "r+");
  //ANTUART = open("/dev/uart_0" ,O_NONBLOCK | O_RDWR);
  if(ANTUART){;}else{
    #ifdef DEBUG
    printf("Cannot open ANTUART");
    #endif
  }


//  if(alt_timestamp_start() <= 0){
//    printf("Timestamp init no working \n");
//  }

  #ifdef DEBUG
  printf("Ticks Per Second: %i \n", alt_timestamp_freq());
  #endif

  //alt_avalon_timer_sc_init (0x04011040, 2, 2, 1);

  // Reset
  sendPacket(MESG_SYSTEM_RESET_ID, 1, 0);
  if (checkReturn() == 0) errorHandler(errDefault);
  delay(1000);

  // Assign Channel
  //   Channel: 0
  //   Channel Type: for Receive Channel
  //   Network Number: 0 for Public Network
  sendPacket(MESG_ASSIGN_CHANNEL_ID, 3, ANT_CHAN, 0, ANT_NET);
  if (checkReturn() == 0) errorHandler(errDefault);

  // Set Channel ID
  //   Channel Number: 0
  //   Device Number LSB: 0 for a slave to match any device
  //   Device Number MSB: 0 for a slave to match any device
  //   Device Type: bit 7 0 for pairing request bit 6..0 for device type
  //   Transmission Type: 0 to match any transmission type
  sendPacket(MESG_CHANNEL_ID_ID, 5, ANT_CHAN, 0, 0, ANT_DEVICETYPE, 0);
  if (checkReturn() == 0) errorHandler(errDefault);

  // Set Network Key
  //   Network Number
  //   Key
  sendPacket(MESG_NETWORK_KEY_ID, 9, ANT_NET, antNetKey[0], antNetKey[1], antNetKey[2], antNetKey[3], antNetKey[4], antNetKey[5], antNetKey[6], antNetKey[7]);
  if (checkReturn() == 0) errorHandler(errDefault);

  // Set Channel Search Timeout
  //   Channel
  //   Timeout: time for timeout in 2.5 sec increments
  sendPacket(MESG_CHANNEL_SEARCH_TIMEOUT_ID, 2, ANT_CHAN, ANT_TIMEOUT);
  if (checkReturn() == 0) errorHandler(errDefault);

  //ANT_send(1+2, MESG_CHANNEL_RADIO_FREQ_ID, CHAN0, FREQ);
  // Set Channel RF Frequency
  //   Channel
  //   Frequency = 2400 MHz + (FREQ * 1 MHz) (See page 59 of ANT MPaU) 0x39 = 2457 MHz
  sendPacket(MESG_CHANNEL_RADIO_FREQ_ID, 2, ANT_CHAN, ANT_FREQ);
  if (checkReturn() == 0) errorHandler(errDefault);

  // Set Channel Period
  sendPacket(MESG_CHANNEL_MESG_PERIOD_ID, 3, ANT_CHAN, (ANT_PERIOD & 0x00FF), ((ANT_PERIOD & 0xFF00) >> 8));
  if (checkReturn() == 0) errorHandler(errDefault);

  //Open Channel
  sendPacket(MESG_OPEN_CHANNEL_ID, 1, ANT_CHAN);
  if (checkReturn() == 0) errorHandler(errDefault);

  #ifdef DEBUG
  printf("Config Done");
  #endif
}