/** * Hardware setup */ void setup(void) { Glcd_Init(); // Initialize GLCD Glcd_Fill(0x00); // Clear GLCD SREG_I_bit = 1; // Global interrupts enable UART1_Init(9600); // UART 1 baudrate UCSR0B = UCSR0B | 0b10000000; // Enable RX interrupt }
void main(void) { int an3now; int an3max = 0; char key; char eepromloc = 0; int eepromval; int eeprommax; char graphclear = 1; Glcd_Init(); Sm_Glcd_Out2(57, 67, "H.S.B V1.0"); Sm_Glcd_Out2(51, 1, "AN3:"); Sm_Glcd_Out2(37, 1, "ROM:"); Sm_Glcd_Out2(0, 1, "MIN"); Sm_Glcd_Out2(10, 1, "MAX"); Sm_Glcd_Out2(20, 1, "MEAN"); //Lines for graph Glcd_H_Line(62, 126, 32, 1); Glcd_V_Line(0,32,62,1); ADCON1 = 0; eepromval = getAn3(eepromloc); showEepromval(eepromval,eeprommax); an3now = ADC_Read(3); intOut(26, 51, an3now); while(1) { an3max = an3now; eeprommax = eepromval; an3now = ADC_Read(3); key = scanKeypad(); if(key == 1) //store an3 value { storeAn3(eepromloc, an3now); eepromval = an3now; } if(key == 2) //switch eeprom bank and return value { if(eepromloc == 0) eepromloc = 16; else if(eepromloc == 16) eepromloc = 32; else if(eepromloc == 32) eepromloc = 0; eepromval = getan3(eepromloc); } if(key == 4 && graphclear == 1) //run graph if it is clear { graphclear = 0; runGraph(); } if(key == 5 && graphclear == 0) //clear graph if it has been run { graphclear = 1; resetGraph(); } key = 0; if(an3now != an3max) { intOut(26, 51, an3now); printBar(0, 59, an3now, an3max); } showEepromval(eepromval, eeprommax); } }