Example #1
0
/**
 * This function gets a temperature reading.
 * @param uTempInParams Denotes the temerature units, Celsius or Fahrenheit
 * @param uTempOutParams Denotes the temerature value
 * @return no return value
 */
void HttpDynamicHandler_GetWheelValue(inputParams uWheelInParams, outputParams *uWheelOutParams)
{
  uWheelOutParams->sWheelParam.uLedDummyOut   = GetLEDStatus();
  uWheelOutParams->sWheelParam.uLedDummyOut   = uWheelOutParams->sWheelParam.uLedDummyOut >> 3;
  uWheelOutParams->sWheelParam.uWheelPosition = Wheel_getPosition();
  uWheelOutParams->sWheelParam.uWheelValue    = Wheel_getValue();
}
Example #2
0
uint8_t Wheel_getPosition(void)
{
    uint8_t position = 0;

    Wheel_getValue();
    //determine which position the wheel is in
    if (positionData > 0x0806)
        position = 7 - (positionData - 0x0806) / 260;  //scale the data for 8 different positions
    else
        position = positionData / 260;

    return position;
}
//Plots adc values on pin 6.6 on LCD
void plot(){
	unsigned int sample1,sample2,i=0;

	 Buttons_init(BUTTON_S2);
	 Buttons_interruptEnable(BUTTON_S2);


	 Buttons_init(BUTTON_S1);
	 Buttons_interruptEnable(BUTTON_S1);

     buttonsPressed = 0;

    Dogs102x6_init();
    Dogs102x6_backlightInit();
    Dogs102x6_setBacklight(11);
    Dogs102x6_setContrast(11);
    Dogs102x6_clearScreen();

    int buffer[104];
    int j;
    for(j=0; j<102; j++){
        buffer[j] = 0;
    }

    Dogs102x6_stringDraw(7, 0, "S2=Esc S1=P/R", DOGS102x6_DRAW_NORMAL);
    while(1)
    {
    	if(buttonsPressed & BUTTON_S2){
    		  _delay_ms(200);
    	      buttonsPressed=0;
    	      lcd_init(); //initialise grlib
    	      break;
    	 }
          if(i == 101)
          {
              Dogs102x6_clearScreen();
              int j;
              for(j=0; j<102; j++){
            	  buffer[j] = 0;
              }
              Dogs102x6_stringDraw(7, 0, "S2=Esc S1=P/R",DOGS102x6_DRAW_NORMAL);
              i = 0;
           }
           ADC12CTL0 |= ADC12SC + ADC12ENC;
           // Start sampling/conversion
           while (ADC12CTL1 & ADC12BUSY) __no_operation();
           sample1 = ADC12MEM0 & 0x0FFF;
           buffer[i]=sample1;
           __delay_cycles(1000000);
           ADC12CTL0 |= ADC12SC + ADC12ENC;
           // Start sampling/conversion
           while (ADC12CTL1 & ADC12BUSY) __no_operation();
           sample2 = ADC12MEM0 & 0x0FFF;
           buffer[i+1]=sample2;
           Dogs102x6_lineDraw(i,56-sample1/86,i+1,56-sample2/86,0);

           //Pause the screen
           if(buttonsPressed & BUTTON_S1){
        	   _delay_ms(200);
               buttonsPressed = 0;

               while(!(buttonsPressed & BUTTON_S1)){
            	   Dogs102x6_clearScreen();
            	   int j;
            	   for(j=0; j<104; j++){
            	       Dogs102x6_lineDraw(j,56-buffer[j]/86,j+1,56-buffer[j+1]/86,0);
            	   }
            	   Wheel_init();
            	   int pos = Wheel_getValue();
            	   Dogs102x6_lineDraw(0,(int)(pos*48)/4096+8,104,(int)(pos*48)/4096+8,0);

            	   char c1[10], c2[10];
            	   int reverse_adc = 86*(48 - (pos*48)/4096);
            	   snprintf(c1, 10,"%d", reverse_adc);
            	   Dogs102x6_stringDraw(56, 0, c1, DOGS102x6_DRAW_NORMAL);
            	   int voltage = reverse_adc*3.7/4096.0 * 1000; //Voltage in mV
            	   snprintf(c2, 10,"%d", voltage);
            	   Dogs102x6_stringDraw(0, 0, c2, DOGS102x6_DRAW_NORMAL);
            	   Dogs102x6_stringDraw(0, 28, "mV", DOGS102x6_DRAW_NORMAL);

            	   _delay_ms(500);
               }
               _delay_ms(200);
               buttonsPressed = 0;
               Dogs102x6_clearScreen();
               adc_init(); //init required to use 6.6
           }

           ++ i;


      }
}