Electgpl

PIC - Prueba de GLCD HDM64GS12

Mar 10th, 2016
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.68 KB | None | 0 0
  1. #include <16F887.h>
  2. #device adc=10
  3. #fuses HS,NOWDT,NOPROTECT,NOLVP
  4. #use delay(clock=20000000)
  5. #include <HDM64GS12.c>
  6. #include <graphics.c>
  7. void main(){
  8.    int16 voltajeADC, voltajeADC_ant,
  9.          cpsADC,cpsADC_ant,
  10.          corrienteADC, corrienteADC_ant;
  11.    setup_adc_ports(sAN0|sAN1|sAN2|VSS_VDD);
  12.    setup_adc(ADC_CLOCK_DIV_2);
  13.    char cps[]="CPS";
  14.    char volt[]="V";
  15.    char amper[]="A";
  16.    char voltaje[9];
  17.    char minuto[9];
  18.    char corriente[9];
  19.    glcd_init(ON);
  20.    glcd_line(0, 25, 125, 25, ON);
  21.    glcd_text57(45,12,volt,1,ON);
  22.    glcd_text57(105,12,amper,1,ON);
  23.    glcd_text57(105,55,cps,1,ON);
  24.    while(true){
  25.       set_adc_channel(0);
  26.       delay_us(10);
  27.       voltajeADC=read_adc();
  28.       if(voltajeADC_ant != voltajeADC){
  29.          glcd_text57(5, 3, voltaje, 2, OFF);
  30.          sprintf(voltaje, "%1.1f", (float)voltajeADC*5/1023.0);
  31.          voltaje[3] = '\0';
  32.          glcd_text57(5, 3, voltaje, 2, ON);  
  33.          voltajeADC_ant=voltajeADC;
  34.       }
  35.       set_adc_channel(1);
  36.       delay_us(10);
  37.       corrienteADC=read_adc();
  38.       if(corrienteADC_ant != corrienteADC){
  39.          glcd_text57(65, 3, corriente, 2, OFF);
  40.          sprintf(corriente, "%1.1f", (float)corrienteADC*5/1023.0);
  41.          corriente[3] = '\0';
  42.          glcd_text57(65, 3, corriente, 2, ON);        
  43.          corrienteADC_ant=corrienteADC;
  44.       }
  45.       set_adc_channel(2);
  46.       delay_us(10);
  47.       cpsADC=read_adc();
  48.       if(cpsADC_ant != cpsADC){
  49.          glcd_text57(30, 40, minuto, 3, OFF);
  50.          sprintf(minuto, "%02.2f", (float)cpsADC*5/1023.0);
  51.          minuto[5] = '\0';
  52.          glcd_text57(30, 40, minuto, 3, ON);
  53.          cpsADC_ant=cpsADC;        
  54.       }
  55.    }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment