Exemplo n.º 1
0
//Display a single number
void displayNumber(int number, int brightness){
   if(number>9999){
       return;  
   }
      
   int digits[4] ={0,0,0,0};
   int counter=3;

   while(number>0) {
      int digit = number %10;
      

      digits[counter] = digit; 
        

      counter--;
      number /= 10;
        
   }   
     //   LedSign::Clear();
   // if(digits[0] >0)
    displayDigit(0,0, digits[0],brightness);  
   // if(digits[1] >0)
      displayDigit(5,0, digits[1],brightness);
   //  if(digits[2] >0)  
      displayDigit(0,8, digits[2],brightness);
   //  if(digits[3] >0)
    displayDigit(5,8, digits[3],brightness);     
            
  
}
Exemplo n.º 2
0
void loop()
{
	displayDigit(4);
	delay(1000);
	displayDigit(2);
	delay(1000);
}
Exemplo n.º 3
0
void
calcProx()
{     //Calculates Proximity reading
	uint32_t ui32DistanceCM; // Sensor output converted to centimeters
	if (HWREGBITW(&g_ui32InterruptFlags, 1)) { //Proximity reading is ready
		HWREGBITW(&g_ui32InterruptFlags, 1) = 0; //Reset flag
		//UARTprintf("Proximity was read!\n");
		//
		// pulse length / system clock = pulse length in seconds
		// pulse length in seconds / (1 / sound speed cm per s) = total wave flight distance
		// total distance / 2 = distance from sensor
		//
		ui32DistanceCM = g_ui32PulseLengthTicks / 2 / (g_ui32SysClock / SOUND_CM_PER_S);
		//UARTprintf("\033[2J\nProx data = %d\n", ui32DistanceCM);

		uint32_t digit = ui32DistanceCM * 15 / SENSOR_MAX_DISTANCE;
		if (digit > 15)
			digit = 15;

		displayDigit(digit);

		g_prox_data[g_prox_index] = ui32DistanceCM;
		g_prox_index++; //Increase index
		if (g_prox_index == 20) {
			g_prox_index = 0;
			HWREGBITW(&g_ui32PrintFlags, 2) = 1; //Set print flag
		}
		//Update 7Seg LED

		//TODO


		//UARTprintf("Distance (cm) = %d\n", ui32DistanceCM); //Print out temp in Fahrenheit (For DEBUG)
	}
}
Exemplo n.º 4
0
/**
 * Outputs one digit at given position.
 * @param c ASCII character to display
 * @param pos position on display, 0-NUM_DIGITS
 */
void displayAsciiDigit(char c, uint8_t pos)
{
	if(pos >= NUM_DIGITS)
		return;
	uint8_t fontIndex = c - FONT_ASCII_OFFSET;
	uint16_t segments = pgm_read_word(&Font[fontIndex]);
	displayDigit(segments, pos);
}
Exemplo n.º 5
0
void ReflowDisplay::tick() {
  if (tickCounter % 200 == 0) {
    marqueeHandler();
    tickCounter = 0;
  }
  
  displayDigit(displayedDigits[tickCounter % 3],tickCounter % 3); //cycles through the digits displaying each one for a tick
  
  tickCounter++;
}
Exemplo n.º 6
0
void displayHex(int in)
{
	int hex[8];
	int count = 0;
	if(in == 0)
	{
		displayDigit(0);
		return;
	}
	while(in > 0)
	{
		hex[count++] = in % 16;
		in /= 16;
	}
	while (count > 0)
	{
		displayDigit(hex[--count]);
		flashLight(500, 0);
	}
}
Exemplo n.º 7
0
void displayNumber(int number){
	if(number > 9999){
		number=number%10000;
	}
	int digit[4];
	
	/* Separate Digits  MAKE FUNCTION*/
	digit[3]=number%10;
	number  = (number-digit[3])/10;
	digit[2]= (number%10);
	number  = (number-digit[2])/10;
	digit[1]= (number%10);
	number  = (number-digit[1])/10;
	digit[0]= (number%10);
	
	switch (tick){
		case 0:
			selectDigit(0);
			displayDigit(digit[1]);
			break;
		case 1:
			selectDigit(1);
			displayDigit(digit[2]);
			break;
		case 2:
			selectDigit(2);
			displayDigit(digit[3]);
			break;
		case 3:
			selectDigit(3);
			displayDegree();
			break;
	}
	
	tick = (tick+1)%4;
}
Exemplo n.º 8
0
void showTime(int hour, int minute, int brightness){
  
  if(hour>24 || minute > 60){
    displayDigit(0,0, 0, brightness);
    displayDigit(5,0, 0, brightness);  
    displayDigit(0,8, 0, brightness);
    displayDigit(5,8, 0, brightness);
    return;
  }
  
  int digitsHour[2] = {0,0};
  int digitsMinute[2] ={0,0};
  
  int counter = 1;
  while( hour > 0){
     int digit = hour%10;
    digitsHour[counter] = digit;
    counter--;
    hour/=10;  
  }
  
  counter = 1;
  while(minute > 0){
     int digit = minute%10;
     digitsMinute[counter] = digit;
     counter--;
     minute/=10; 
  }

	if(digitsHour[0] !=0){
		displayDigit(0,0, digitsHour[0], brightness);
	}
	displayDigit(5,0, digitsHour[1], brightness);  
	displayDigit(0,8, digitsMinute[0], brightness);
	displayDigit(5,8, digitsMinute[1], brightness);
}
Exemplo n.º 9
0
void displayNumber(int no) {
	displayDigit(2, no % 10);
	displayDigit(1, (no / 10) % 10);
	displayDigit(0, no / 100);
}