示例#1
0
int main(void)
{

#if(defined(SEG_RACER) && SEG_RACER)
	racer_init();
#endif

#if(defined(SEG_TET) && SEG_TET)
	tetInit(3);
#endif
	init_timer0Hsync();

	//This starts pretty late... watch out for WDT
	init_heartBeat();

	setHeartRate(0);

	lvds_timerInit();


	// MUCH Of this is outside the screen...


	uint8_t imageNum = 0;
	uint8_t colorShift = 0;
	while(1)
	{
		heartUpdate();
	}

}
示例#2
0
    /**
     * Adds a field to the message. Unknown fields are rejected
     * @return bool if field was known to the message
     */
    bool addField(unsigned char fieldDefNum, unsigned char size, unsigned char baseType, unsigned char arch, char * data) {
        //TODO: Compare size with expected size
        //TODO: Compare baseType with expected baseType
        bool fieldWasAdded = true;
        switch (fieldDefNum) {
        case 253: setTimestamp(read0x86(data,arch));
                 break;
        case 0: setPositionLat(read0x85(data,arch));
                 break;
        case 1: setPositionLong(read0x85(data,arch));
                 break;
        case 2: setAltitude(read0x88(data,arch,5,500,0x84));
                 break;
        case 3: setHeartRate(read0x02(data,arch));
                 break;
        case 4: setCadence(read0x02(data,arch));
                 break;
        case 5: setDistance(read0x88(data,arch,100,0,0x86));
                 break;
        case 6: setSpeed(read0x88(data,arch,1000,0,0x84));
                 break;
        case 7: setPower(read0x84(data,arch));
                 break;
        case 9: setGrade(read0x88(data,arch,100,0,0x83));
                 break;
        case 10: setResistance(read0x02(data,arch));
                 break;
        case 11: setTimeFromCourse(read0x88(data,arch,1000,0,0x85));
                 break;
        case 12: setCycleLength(read0x88(data,arch,100,0,0x02));
                 break;
        case 13: setTemperature(read0x01(data,arch));
                 break;
        case 17: setNumSpeed1s(read0x02(data,arch));
                 break;
        case 18: setCycles(read0x02(data,arch));
                 break;
        case 19: setTotalCycles(read0x86(data,arch));
                 break;
        case 28: setCompressedAccumulatedPower(read0x84(data,arch));
                 break;
        case 29: setAccumulatedPower(read0x86(data,arch));
                 break;
        case 30: setLeftRightBalance(read0x02(data,arch));
                 break;
        case 31: setGpsAccuracy(read0x02(data,arch));
                 break;
        case 32: setVerticalSpeed(read0x88(data,arch,1000,0,0x83));
                 break;
        case 33: setCalories(read0x84(data,arch));
                 break;
        case 43: setLeftTorqueEffectiveness(read0x88(data,arch,2,0,0x02));
                 break;
        case 44: setRightTorqueEffectiveness(read0x88(data,arch,2,0,0x02));
                 break;
        case 45: setLeftPedalSmoothness(read0x88(data,arch,2,0,0x02));
                 break;
        case 46: setRightPedalSmoothness(read0x88(data,arch,2,0,0x02));
                 break;
        case 47: setCombinedPedalSmoothness(read0x88(data,arch,2,0,0x02));
                 break;
        case 52: setCadence256(read0x88(data,arch,256,0,0x84));
                 break;


            default:
                fieldWasAdded = false;
                break;
        }
        return fieldWasAdded;
    };
示例#3
0
int main(void)
{

   init_heartBeat();

   tcnter_init();
   puat_init(0);

   // If you're *only* using the tcnter for puat, it's entirely safe to do
   // something like this... BUT, there are various things which may use
   // tcnter in the background without your realizing (puar, for instance)
   // So don't get in the habit of doing this unless you're really on top
   // of things.

   //(Also, should put this in a PSTR() rather than a RAM-based
   //character array...)
/*
   char hello[] = "Hello World\n\r";
   char* character = hello;

   setHeartRate(16);

   //Nothing can be received during this loop...
   while(*character != '\0')
   {
      puat_sendByte(0, *character);
      character++;
      while(puat_dataWaiting(0))
      {
         tcnter_update();
         puat_update(0);
         heartUpdate();
      }
   }
*/
   puat_sendStringBlocking_P(0, stringBuffer, 
                              PSTR("\n\rBoot:\n\r"));

   setHeartRate(0);


   static dms4day_t startTime = 0;

   char count = '0';

   while(1)
   {
      tcnter_update();
      puat_update(0);

      if(dmsIsItTime(&startTime, 1*DMS_SEC))
      {
         puat_sendByteBlocking(0, count);

         count++;
         if(count == '9'+1)
            count = '0';
      }

      heartUpdate();


   }

   return 0;
}
示例#4
0
int main(void)
{

   init_heartBeat();

   tcnter_init();
   puat_init(0);

   // If you're *only* using the tcnter for puat, it's entirely safe to do
   // something like this... BUT, there are various things which may use
   // tcnter in the background without your realizing (puar, for instance)
   // So don't get in the habit of doing this unless you're really on top
   // of things.

   //(Also, should put this in a PSTR() rather than a RAM-based
   //character array...)
/*
   char hello[] = "Hello World\n\r";
   char* character = hello;

   setHeartRate(16);

   //Nothing can be received during this loop...
   while(*character != '\0')
   {
      puat_sendByte(0, *character);
      character++;
      while(puat_dataWaiting(0))
      {
         tcnter_update();
         puat_update(0);
         heartUpdate();
      }
   }
*/
   puat_sendStringBlocking_P(0, stringBuffer, 
                              PSTR("\n\ranaButtons Values:\n\r"));

   setHeartRate(0);

// adc_takeInput(0);
// adc_init();
// adc_select(0);

// adc_startConversion();

   static dms4day_t startTime = 0;

   while(1)
   {
      tcnter_update();
      puat_update(0);

      
      heartUpdate();

      int32_t buttonTimeVal = anaButtons_getDebounced();

      if(buttonTimeVal >= 0)
      {
         //char stringBuffer[20];

         extern uint16_t anaB_minSamples;
         extern uint32_t anaB_measurementCount;

         sprintf_P(stringBuffer,
               PSTR("buttonTime=%"PRIi32
                    " sampleCount=%"PRIu16
                    " measurementCount=%"PRIu32"\n\r"),
                  buttonTimeVal, anaB_minSamples, anaB_measurementCount);
         puat_sendStringBlocking(0, stringBuffer);
      }


   }

   return 0;
}
示例#5
0
int main(void)
{

   init_heartBeat();

   tcnter_init();
#if(!defined(PUAR_DISABLED) || !PUAR_DISABLED)
   puar_init(0);
#endif
   puat_init(0);

   // If you're *only* using the tcnter for puat, it's entirely safe to do
   // something like this... BUT, there are various things which may use
   // tcnter in the background without your realizing (puar, for instance)
   // So don't get in the habit of doing this unless you're really on top
   // of things.

   //(Also, should put this in a PSTR() rather than a RAM-based
   //character array...)
/*
   char hello[] = "Hello World\n\r";
   char* character = hello;

   setHeartRate(16);

   //Nothing can be received during this loop...
   while(*character != '\0')
   {
      puat_sendByte(0, *character);
      character++;
      while(puat_dataWaiting(0))
      {
         tcnter_update();
         puat_update(0);
         heartUpdate();
      }
   }
*/
   puat_sendStringBlocking_P(0, stringBuffer, 
                              PSTR("\n\rPress a button on the analog array"
                                    " to see its mesasured value.\n\r"));

   setHeartRate(0);

   while(1)
   {
      tcnter_update();
      puat_update(0);
#if(!defined(PUAR_DISABLED) || !PUAR_DISABLED)
      puar_update(0);
      if(puar_dataWaiting(0))
      {
         uint8_t byte = puar_getByte(0);

         if((byte >= '0') && (byte <= '9'))
            set_heartBlink(byte-'0');

         //Echo the received character...

         //The output buffer shouldn't be full, right?
         if(!puat_dataWaiting(0))
            puat_sendByte(0, byte);
         
      }
#endif

      extern hfm_t heartModulator;
//    static uint8_t lastPower = 0;

//    if(heartModulator.power != lastPower)
//    {
//       lastPower = heartModulator.power;
         //Attempt to simulate varying times between calls to anaButtons...
//       _delay_ms(lastPower);
//    }


/* And, apparently it's not compatible with avr-gcc4.8 and/or avr-libc
 * whatever I'm at...
      //This block is only for the sake of introducing some randomness
      // regarding the length of time each loop takes...
      //E.G. in a real program, some update functions may be quite slow
      //periodically... does that interfere with our anaButtons
      //measurement? Let's find out.
      static dms4day_t startTime = 0;

      if(dmsIsItTime(&startTime, 1*DMS_SEC))
      {
         _delay_ms(heartModulator.power);
      }
      //End of randomness-block.
*/


      heartUpdate();



      int32_t buttonTimeVal = anaButtons_getDebounced();

      if(buttonTimeVal >= 0)
      {
         //char stringBuffer[20];

         extern uint16_t anaB_minSamples;
         extern uint32_t anaB_measurementCount;

         sprintf_P(stringBuffer,
               PSTR("buttonTime=%"PRIi32
                    " sampleCount=%"PRIu16
                    " measurementCount=%"PRIu32"\n\r"), 
                  buttonTimeVal, anaB_minSamples, anaB_measurementCount);
         puat_sendStringBlocking(0, stringBuffer);
      }
   }

   return 0;
}
示例#6
0
int main(void)
{

   init_heartBeat();

   //a/o 0.70, tcnter_init() must be called *before* puat_init()
   tcnter_init();
   puat_init(0);
   puar_init(0);

   // If you're *only* using the tcnter for puat, it's entirely safe to do
   // something like this... BUT, there are various things which may use
   // tcnter in the background without your realizing (puar, for instance)
   // So don't get in the habit of doing this unless you're really on top
   // of things.

   //(Also, should put this in a PSTR() rather than a RAM-based
   //character array...)
/*
   char hello[] = "Hello World\n\r";
   char* character = hello;

   setHeartRate(16);

   //Nothing can be received during this loop...
   while(*character != '\0')
   {
      puat_sendByte(0, *character);
      character++;
      while(puat_dataWaiting(0))
      {
         tcnter_update();
         puat_update(0);
         heartUpdate();
      }
   }
*/
   //Likewise, sendStringBlocking[_P]() blocks tcnter and other updates
   // so shouldn't be used when e.g. expecting RX-data...
   //But it's OK now, we're still booting.
   puat_sendStringBlocking_P(0, stringBuffer, 
      PSTR("\n\r\n\rType A Key For Echo, 0-9 adjusts Heart.\n\r"));

   setHeartRate(0);


   static dms4day_t startTime = 0;

   while(1)
   {
      tcnter_update();
      puat_update(0);
      puar_update(0);

      if(dmsIsItTime(&startTime, 1*DMS_SEC))
      {
         puat_sendByteBlocking(0, '.');
      }



      if(puar_dataWaiting(0))
      {
         uint8_t byte = puar_getByte(0);

         if((byte >= '0') && (byte <= '9'))
            set_heartBlink(byte-'0');

         //Echo the received character...

         //The output buffer shouldn't be full, right?
         if(!puat_dataWaiting(0))
            puat_sendByte(0, byte);

      }


      heartUpdate();


   }

   return 0;
}
示例#7
0
void main(void)
{

   init_heartBeat();

   //a/o 0.70, tcnter_init() must be called *before* puat_init()
   tcnter_init();
   puar_init(0);
   puat_init(0);

   // If you're *only* using the tcnter for puat, it's entirely safe to do
   // something like this... BUT, there are various things which may use
   // tcnter in the background without your realizing (puar, for instance)
   // So don't get in the habit of doing this unless you're really on top
   // of things.
   // (better to set up a cirBuff and handle reloading characters alongside
   //  the other updates in while(1)...)

   //(Also, should put this in a PSTR() rather than a RAM-based
   //character array...)
   char hello[] = "\n\r\n\rType A Key For Echo, 0-9 adjusts Heart.\n\r";

   setHeartRate(16);

   //puat_sendStringBlocking, below, is basically this:
   //Nothing can be received during this loop...
// char* character = hello;
// while(*character != '\0')
// {
//    puat_sendByte(0, *character);
//    character++;
//    while(puat_dataWaiting(0))
//    {
//       tcnter_update();
//       puat_update(0);
//       heartUpdate();
//    }
// }
   //So call this sparingly.
   puat_sendStringBlocking(0, hello);

   setHeartRate(0);

   dms6sec_t startTime = 0;
   while(1)
   {
      tcnter_update();
      if(dmsIsItTime6sec(&startTime, 1*DMS_SEC))
      {
         puat_sendByte(0, '.');
      }


      puar_update(0);
      puat_update(0);

      if(puar_dataWaiting(0))
      {
         uint8_t byte = puar_getByte(0);

         if((byte >= '0') && (byte <= '9'))
            set_heartBlink(byte-'0');

         //Echo the received character...

         //The output buffer shouldn't be full, right?
         if(!puat_dataWaiting(0))
            puat_sendByte(0, byte);
         
      }

      heartUpdate();
   }
}
示例#8
0
int main(void)
{

   init_heartBeat();

   //a/o 0.70, tcnter_init() must be called *before* puat_init()
   tcnter_init();
   puat_init(0);
   puar_init(0);

   spi_init(USART_SPI_SLOW_BAUD_REG_VAL);
   
   nlcd_init();
   nlcd_appendCharacter('B');
   nlcd_appendCharacter('o');
   nlcd_appendCharacter('o');
   nlcd_appendCharacter('t');
   nlcd_redrawCharacters();

   //Likewise, sendStringBlocking[_P]() blocks tcnter and other updates
   // so shouldn't be used when e.g. expecting RX-data...
   //But it's OK now, we're still booting.
   puat_sendStringBlocking_P(0, stringBuffer, 
    PSTR("\n\r\n\r"
         "Type A Key\n\r")); // (0-9 adjusts Heart).\n\r"));
// puat_sendStringBlocking_P(0, stringBuffer, 
//  PSTR("'F' sets Fast SPI transmission.\n\r"));
// puat_sendStringBlocking_P(0, stringBuffer, 
//  PSTR("'S' sets Slow SPI transmission (Default).\n\r"));
   puat_sendStringBlocking_P(0, stringBuffer, 
    PSTR("Each keypress will be displayed on the LCD.\n\r"));
// puat_sendStringBlocking_P(0, stringBuffer, 
//  PSTR(" (and also echoed back to the PC)\n\r"));

   setHeartRate(0);


   static dms4day_t startTime = 0;
// uint8_t fastSPI=FALSE;

   while(1)
   {
      tcnter_update();
      puat_update(0);
      puar_update(0);

      if(nlcd_charactersChanged())
         nlcd_redrawCharacters();


      if(dmsIsItTime(&startTime, 1*DMS_SEC))
      {
         puat_sendByteBlocking(0, '.');
      }



      if(puar_dataWaiting(0))
      {
         uint8_t byte = puar_getByte(0);

         if((byte >= '0') && (byte <= '9'))
            set_heartBlink(byte-'0');

//       if((byte == 'F') || (byte == 'f'))
//          fastSPI = TRUE;
//       if((byte == 'S') || (byte == 's'))
//          fastSPI = FALSE;


         //Retransmit the received character via SPI
         // (and receive a byte via SPI)
         //The output buffer shouldn't be full, right?
//       if(fastSPI)
//          byte=spi_transferByte(byte);         
//       else
//          byte=spi_transferByteWithTimer(byte);

         //NO!!!
         // nlcd uses spi_transferByteWithTimer() (and spi_transferByte()?)
         // On its own... Currently we can't control the NLCD baud-rate in
         // real-time. The rate[s?] used can be set in the makefile.


         nlcd_appendCharacter(byte);



         //Echo the Received byte via PUAT:
         //The output buffer shouldn't be full, right?
         if(!puat_dataWaiting(0))
            puat_sendByte(0, byte);

      }


      heartUpdate();


   }

   return 0;
}