Exemple #1
0
int main (void)
{
    Initialization();

    show_mhz();				// Display CPU speed
    TimerWait(1000);		// Wait 1 second

    while(1)
    {
        printLCD("Show ADC");			// Display the text in quotes on the LCD
        while (!KEY_VALID);				// Wait for joystick to be moved or pressed.
        if (getkey() == 1)				// If enter was pressed then do what is in the braces, just skip over it.
        {
            TimerWait(500);				// debounce joystick button
            showADC();
            printLCD("Back ADCs");
            TimerWait(2000);
        }

        printLCD("Balance");			// Display the text in quotes on the LCD
        while (!KEY_VALID);				// Wait for joystick to be moved or pressed.
        if (getkey() == 1)				// If enter was pressed then do what is in the braces, else just continue.
        {
            TimerWait(500);				// debounce joystick button
            balance();
            printLCD("Back Balance");
            TimerWait(2000);
        }

        printLCD("rprintf");			// Display the text in quotes on the LCD
        while (!KEY_VALID);				// Wait for joystick to be moved or pressed.
        if (getkey() == 1)				// If enter was pressed then do what is in the braces, else just continue.
        {
            TimerWait(500);				// debounce joystick button
            rprintf_test();
            printLCD("Back rprintf");
            TimerWait(2000);
        }

        printLCD("PWM Test");			// Display the text in quotes on the LCD
        while (!KEY_VALID);				// Wait for joystick to be moved or pressed.
        if (getkey() == 1)				// If enter was pressed then do what is in the braces, else just continue.
        {
            TimerWait(500);				// debounce joystick button
            PWM_Test();
            printLCD("Back PWM Test");
            TimerWait(3000);
        }
    }
}
Exemple #2
0
void showAndSetValue(uint8_t display ,volatile uint16_t *array,volatile uint8_t *array8){	
	
	switch(display){
		
		case DISPLAY_START:
			{
				volatile uint16_t time=(array8[charge])? chargeTime:dischargeTime;
				volatile uint8_t index=(array8[charge])? oldChargeTime:oldDischargeTime;
				
				if(array[index]!=time){
					array[index]=time;
					showTime(8,1,time);
				}
			}			
			if(array[oldCurrentVoltage]!=array[currentVoltage]){
				array[oldCurrentVoltage]=array[currentVoltage];
				showADC(2,0,array[currentVoltage]);				
			}			
			if(array[oldCurrentAmperage]!=array[currentAmperage]){
				array[oldCurrentAmperage]=array[currentAmperage];
				LCD_Goto(2,1);
				volatile uint8_t ch=(array8[charge])? '+':'-';								
				LCD_WriteData(ch);				
				showADC(3,1,array[currentAmperage]);
			}
			if(array[oldCurrentPWM]!=array[currentPWM]){
				array[oldCurrentPWM]=array[currentPWM];
				showPWM(10,0,array[currentPWM]);
				setPwm(array[currentPWM]);
			}	
			if(array8[oldNumDischargeCharge]!=array8[numDischargeCharge]){
				array8[oldNumDischargeCharge]=array8[numDischargeCharge];
				LCD_Goto(14,0);
				LCD_SendNumber(array8[numDischargeCharge],' ');
			}		
		break;
		case DISPLAY_FAST_CHANGE:
			if(array8[oldCharge]!=array8[charge]){
				array8[oldCharge]=array8[charge];	
				LCD_ClearField(0,1,9);			
				LCD_Goto(0,1);
				if(array8[charge]){					
					LCD_SendStr("Charge");
					BM_ClearBit(TCCR1A,COM1A0);
					SET_CHARGE;					
				}else{
					LCD_SendStr("Discharge");
					BM_SetBit(TCCR1A,COM1A0);
					SET_DISCHARGE;
				}				
			}			
		break;
		case DISPLAY_PROGR:
			if(array[oldWindowsSettings]!=array[windowsSettings]){
				array[oldWindowsSettings]=array[windowsSettings];
				showWinSettings(0,1,DISPLAY_PROGR+array[windowsSettings]);
			}
		break;
		case DISPLAY_P0:
			if(array[oldNormalVoltage]!=array[normalVoltage]){
				array[oldNormalVoltage]=array[normalVoltage];
				showADC(0,0,array[normalVoltage]);
			}
		break;
		case DISPLAY_P1:
			if(array[oldDischargeVoltage]!=array[dischargeVoltage]){
				array[oldDischargeVoltage]=array[dischargeVoltage];
				showADC(0,0,array[dischargeVoltage]);
			}
		break;
		case DISPLAY_P2:
			if(array[oldDischargeAmperage]!=array[dischargeAmperage]){
				array[oldDischargeAmperage]=array[dischargeAmperage];
				showADC(0,1,array[dischargeAmperage]);
			}
		break;
		case DISPLAY_P3:
			if(array[oldNormalAmperage]!=array[normalAmperage]){
				array[oldNormalAmperage]=array[normalAmperage];
				showADC(7,1,array[normalAmperage]);
			}
		break;
		case DISPLAY_P4:
			if(array8[oldAutomatic]!=array8[automatic]){
				array8[oldAutomatic]=array8[automatic];
				LCD_ClearField(0,1,9);
				LCD_Goto(0,1);
				if(array8[automatic]){
					LCD_SendStr("Automatic");				
					} else {
					LCD_SendStr("Manual");				
				}
			}
		break;
		case DISPLAY_P5:
			if(array8[oldNumDischargeCharge]!=array8[numDischargeCharge]){
				array8[oldNumDischargeCharge]=array8[numDischargeCharge];
				LCD_ClearField(0,1,3);
				LCD_Goto(0,1);
				LCD_SendNumber(array8[numDischargeCharge],' ');
			}
		break;
	}
}