void main(){
ADCON1 = 0b00001110;             // HABILITA CANAL AN0 E AN1
TRISA.RA0 = 1;
Lcd_Init ();                     // START LCD
Lcd_Cmd(_Lcd_Clear);             // CLEAR LCD
Lcd_Cmd(_LCD_CURSOR_OFF);        // TURN OFF LCD CURSOR
ADC_Init();
while(1){
adc_rd = ADC_Read(0);                        // GET ADC VALUE FROM 1ST CHANNEL
EEPROM_Write(0x08, adc_rd);       //ESCREVE "adc_rd" NA POSICAO 0x08 DA EEPROM
IntToStr(adc_rd, adcprint);                            // CONVERSION TO STRING
Lcd_out(1,1,"COUNTS..: ");
Lcd_Out_Cp(adcprint);                     // PRINTS ADC STEPS IN LCD FIRST ROW
if (diff != adc_rd){
BarSegmentNum = adc_rd /(1023 / 16);
                                    // CALCULATE NUMBERS OF BAR GRAPH SEGMENTS
Lcd_out(2,1,"                ");    // CLEARS LCD SECOND ROW
for (i = 0; i < BarSegmentNum; i++){
                               // LOOP TO PRINT EACH BAR SEGMENT IN SECOND ROW
CustomChar(2, i+1);}}           // PRINT CUSTOM CHARACTER FOR BARGRAPH SEGMENT
Delay_ms(750);                                        // STABILIZE LCD DISPLAY
diff = adc_rd;
// LCD SHOWS EEPROM VALUE
ADCeer = EEPROM_Read(0x08);                     // LE A POSICAO 0x08 DA EEPROM
ShortToStr (ADCeer, ADCeerSTR);
//Lcd_Cmd(_LCD_CLEAR);                                  // LIMPA A TELA DO LCD
Lcd_Out(2, 1, ADCeerSTR);
Delay_ms(2000);
Lcd_Cmd(_LCD_CLEAR);                                    // LIMPA A TELA DO LCD
}                                                                 // END WHILE
}                                                                  // END MAIN
void main() {            // FUNCAO PRINCIPAL: MAIN
ADCON1 = 0x07;           // CONFIGURA ENTRADAS AN COMO E/S DIGITAIS
CMCON = 7;               // DESLIGA COMPARADORES
// CONFIGURACOES E/S E ESTADOS INICIAIS [BINARIO]
   TRISA = 0b00000000;            PORTA = 0b00000000;
   TRISB = 0b00000110;         // PORTB = 0b00000000;
   TRISC = 0b00000000;            PORTC = 0b00000000;
// ESTADOS INICIAIS DOS ACESSORIOS
BUZZER = 1;
// MENSAGEM INICIAL NO LCD
Lcd_Init();                                 // INICIA O LCD
Lcd_Cmd(_LCD_CLEAR);                        // LIMPA A TELA DO LCD
Lcd_Cmd(_LCD_CURSOR_OFF);                   // DESLIGA O CURSOR
Lcd_Out(1, 1, msg_2); 
Lcd_Out(2, 1, msg_1);
Delay_ms(1500);
Lcd_Cmd(_LCD_CLEAR);                        // LIMPA A TELA DO LCD
while (1) {
if (!INT2) {
BUZZER = 0; Delay_ms(15); BUZZER = 1; Delay_ms(50);
BUZZER = 0; Delay_ms(15); BUZZER = 1;       // SIRENE SOA DUAS VEZES CURTAS
// EEPROM_Write(unsigned short address, unsigned short data);
EEPROM_Write(0x08, 'K');               //ESCREVE "K" NA POSICAO 0x08 DA EEPROM
Lcd_Cmd(_LCD_CLEAR);                        // LIMPA A TELA DO LCD
Lcd_Out(1, 1, msg_1);
Lcd_Out(2, 1, msg_3);   
Delay_ms(1000);
Lcd_Cmd(_LCD_CLEAR);                        // LIMPA A TELA DO LCD
} else if (!INT1) {
BUZZER = 0; Delay_ms(15); BUZZER = 1;       // SIRENE SOA UMA VEZ CURTA
// EEPROM_Read(unsigned short address);
INFO = EEPROM_Read(0x08);                   // LE A POSICAO 0x08 DA EEPROM
ShortToStr (INFO, INFO_s);
Lcd_Cmd(_LCD_CLEAR);                        // LIMPA A TELA DO LCD
Lcd_Out(1, 1, msg_1);
Lcd_Out(2, 1, msg_4);   
Delay_ms(1000);
Lcd_Cmd(_LCD_CLEAR);                        // LIMPA A TELA DO LCD
Lcd_Out(1,1,INFO_s);   
Lcd_Out_Cp(" = DECIMAL");      
Lcd_Cmd(_LCD_SECOND_ROW);
Lcd_Chr_Cp(0+INFO);    
Lcd_Out_Cp(" =  CHARACTER");   
Delay_ms(2500);
Lcd_Cmd(_LCD_CLEAR);}                       // LIMPA A TELA DO LCD
else {
Lcd_Out(1, 1, msg_5);                       
Lcd_Out(2, 1, msg_6);
}                                                                  // FIM ELSE
 }                                                               // FIM  WHILE
  }                                                                // FIM MAIN
Beispiel #3
0
void Display_Time_Core(unsigned char *sec, unsigned char *min, unsigned char *hr, unsigned char *wd, unsigned char *day, unsigned char *mn, unsigned char *year) {
	// for some other testing
	unsigned char txtSec[5] = "";
	unsigned char txtMin[5] = "";
	unsigned char txtHour[5] = "";
	unsigned char txtWd[5] = "";
	unsigned char txtDay[5] = "";
	unsigned char txtMn[5] = "";
	unsigned char txtYear[5] = "";
	unsigned char txtDisplayRow1[16] = "";
	unsigned char txtDisplayRow2[16] = "";

	ShortToStr(*sec, txtSec);
	ShortToStr(*min, txtMin);
	ShortToStr(*hr, txtHour);
	ShortToStr(*wd, txtWd);
	ShortToStr(*day, txtDay);
	ShortToStr(*mn, txtMn);
	ShortToStr(*year, txtYear);

	MakeLastTwoChars(txtSec);
	MakeLastTwoChars(txtMin);
	MakeLastTwoChars(txtHour);
	MakeLastTwoChars(txtWd);
	MakeLastTwoChars(txtDay);
	MakeLastTwoChars(txtMn);
	MakeLastTwoChars(txtYear);

	strcat(txtDisplayRow1, "DATE:");
	strcat(txtDisplayRow1, txtMn);
	strcat(txtDisplayRow1, "/");
	strcat(txtDisplayRow1, txtDay);
	strcat(txtDisplayRow1, "/");
	strcat(txtDisplayRow1, txtYear);
	strcat(txtDisplayRow1, ":");
	strcat(txtDisplayRow1, txtWd);

	strcat(txtDisplayRow2, "TIME:");
	strcat(txtDisplayRow2, txtHour);
	strcat(txtDisplayRow2, ":");
	strcat(txtDisplayRow2, txtMin);
	strcat(txtDisplayRow2, ":");
	strcat(txtDisplayRow2, txtSec);

	Lcd_Cmd(_LCD_CLEAR);
	Lcd_Out(1,1,txtDisplayRow1);
	Lcd_Out(2,1,txtDisplayRow2);
}
Beispiel #4
0
ChrString ShortInt::ToTruncString(int Radix_) const
{
  char Buffer_[16];
  return ChrString(ShortToStr(*this, Buffer_, Radix_));
}
Beispiel #5
0
ChrString ShortInt::ToTruncString(const ShortInt& Int_, int Radix_)
{
  char Buffer_[16];
  return ChrString(ShortToStr(Int_, Buffer_, Radix_));
}