Ejemplo n.º 1
0
void die (const char *string)
{
    lcd_send_command (CLR_DISP); /* LCD set first row */
    lcd_send_command (DD_RAM_ADDR); /* LCD set first row */
    lcd_send_string (string);
    for (;;) ;
}
Ejemplo n.º 2
0
void display_Selection(long selection){
	lcd_check_busy_flag();
	lcd_send_command(LCD_CLEAR);
	lcd_puts(" Exposure Time: ");
	lcd_check_busy_flag();
	lcd_send_command(LCD_SET_CURSOR_POS | LCD_SECOND_LINE );
	char * zero = "0";
	
	uint8_t mins = selection / 60;
	char minsStr[5];
	itoa(mins,minsStr,10);
	lcd_check_busy_flag();
	lcd_puts("      ");
	if(mins <= 9){
		lcd_check_busy_flag();
		lcd_puts(zero);
	}

	lcd_check_busy_flag();
	lcd_puts(minsStr);
	lcd_check_busy_flag();
	lcd_puts(":");
	
	uint8_t secs = selection % 60;
	char secsStr[5];
	itoa(secs,secsStr,10);
	
	if(secs <= 9){
		lcd_check_busy_flag();
		lcd_puts(zero);
	}
	lcd_check_busy_flag();
	lcd_puts(secsStr);
}
/**
 * @brief Initialize the LCD display
 *        enables LCD using 2-line display and 8-bit interface
 *        cursor auto-right-move without showing
          Clear the LCD screen
 * @param None
 * @retval None
 */
void lcd_display_init(void)
{
  lcd_gpio_init();
  
  //function set 2 lines, 8-bit interface
  lcd_send_command(0x38);
  //enable display(0x0c) and cursor display(0x0e)
  lcd_send_command(0x0c);
  //clear
  lcd_send_command(0x01);
}
Ejemplo n.º 4
0
int startLCD_Show_Credits( void ){	
    	set_lcd_pins_direction();
	lcd_init();
    	lcd_puts( program_author );
    	_delay_ms(1000);
    	lcd_check_busy_flag();
    	lcd_send_command( LCD_CLEAR );
    	lcd_puts( machine_name );
    	lcd_check_busy_flag();
    	lcd_send_command( LCD_SET_CURSOR_POS | LCD_SECOND_LINE );
    	lcd_puts( program_version );
   	//_delay_ms( 5000 );
}
Ejemplo n.º 5
0
/**
 * @brief Initializes the lcd display controller.
 * @details Follows the initialization flowchart in the JM162A datasheet.
 */
void lcd_init() {
	_delay_ms(30);

	lcd_send_command(0b00111000); // 8 bit, 2 lines
	_delay_us(39);
	lcd_send_command(0b00001000); // display off
	_delay_us(39);
	lcd_clear();
	_delay_ms(1.53);
	lcd_send_command(0b00000110); // left-to-right, no shift

	lcd_send_command(0b00001100); // display on
}
Ejemplo n.º 6
0
/**
 * @brief Prints two lines of text on the display.
 *
 * @param text1 The first line of text.
 * @param text2 The second line of text.
 */
void lcd_print(char text1[16], char text2[16]) {
	lcd_clear();
	for(int i=0; text1[i] != '\0' && i < 16; i++)
		lcd_send_symbol(text1[i]);

	lcd_send_command(0b11000000); // line 2, DDRAM address 64
	for(int i=0; text2[i] != '\0' && i < 16; i++)
		lcd_send_symbol(text2[i]);
}
Ejemplo n.º 7
0
int main(void){
	//startLCD_Show_Credits();
    	//lcd_check_busy_flag();
    	//lcd_send_command( LCD_CLEAR );
    	//You can multiplex these pins by enabling and disabling the LCD display.
    	//lcd_puts( "Lx = 15uH " );
    	//lcd_check_busy_flag();
    	//lcd_send_command( LCD_SET_CURSOR_POS | LCD_SECOND_LINE );
    	//lcd_puts( "Cx = 150uF" );
	//lcd_check_busy_flag();
	//_delay_ms(2000);
	//lcd_send_command( LCD_CLEAR );
	//lcd_puts("Hello Jenn!");
	uart_init();
	stdout = &uart_tx;
	stdin = &uart_rx;
	init_ADC();

	//Set Pin Directions
	//Lights Pin as output
	LIGHTS_SIGNAL_DIR |= (1 << LIGHTS_SIGNAL);
	
	//Start Button Pin as input
	START_BUTTON_DIR &= ~(1 << START_BUTTON);
	
	//Stop Button Pin as Input
	STOP_BUTTON_DIR &= ~(1 << STOP_BUTTON);

	//Buzzer Pin as Output
	BUZZER_DIR |= (1 << BUZZER);

	//Trip Switch Pin as Input
	TRIP_SWITCH_DIR &= ~(1 << TRIP_SWITCH_PIN);

	//LCD Led Pin as output
	LCD_LED_DIR |= (1 << LCD_LED_PIN);
	LCD_LED_PORT |= (1 << LCD_LED_PIN); //Turn it on

	static long reading;
	static bool btnStop = false; 
	static bool tripSwitch = false;
	startLCD_Show_Credits();
	displayBlink(3);
	while (1){
		printf("Raw Reading: %d\t",read_ADC(0,&reading));
		long mapped_reading = mapRange(0,1023,0,1800,reading);
		printf("Mapped Reading: %d\t",mapped_reading);
		display_Selection(mapped_reading);
		if(START_BUTTON_PIN & (1 << START_BUTTON) && mapped_reading > 0){
			lcd_check_busy_flag();
			lcd_send_command(LCD_CLEAR);
			lcd_puts("    STARTING    ");
			displayBlink(2);
			long count = 0;
			_delay_ms(1000);
			//Turn on lights
			LIGHTS_SIGNAL_PORT |= (1 << LIGHTS_SIGNAL);
			bool lightsOn = true;
			for(count = mapped_reading;count >= 0;count--){
				//Check for stop button
				if(STOP_BUTTON_PIN & (1 << STOP_BUTTON)){
					lcd_check_busy_flag();
					lcd_send_command(LCD_CLEAR);
					lcd_puts("    STOPPING    ");
					btnStop = true;
					break;
				}
				//Pause if trip switch is high
				if(!(TRIP_SWITCH_PIN & (1 << TRIP_SWITCH))){
					if(!lightsOn){
						LIGHTS_SIGNAL_PORT |= (1 << LIGHTS_SIGNAL);
					}
					//If the the switch is still closed
					printf("UV Lights on for: %d more secs...\n",count);
					lcd_check_busy_flag();
					lcd_send_command(LCD_CLEAR);
					lcd_puts("    Exposing    ");
					lcd_check_busy_flag();
					lcd_send_command(LCD_SET_CURSOR_POS | LCD_SECOND_LINE);
				        char * zero = "0";	
					uint8_t mins = count / 60;
					uint8_t secs = count % 60;
					char minsStr[5];
					char secsStr[5];
					itoa(mins,minsStr,10);
					itoa(secs,secsStr,10);
					lcd_check_busy_flag();
					lcd_puts("      ");
					if(mins <= 9){
						lcd_check_busy_flag();
						lcd_puts(zero);
					}
					lcd_check_busy_flag();
					lcd_puts(minsStr);
					lcd_check_busy_flag();
					lcd_puts(":");
					if(secs <= 9){
						lcd_check_busy_flag();
						lcd_puts(zero);
					}
					lcd_check_busy_flag();
					lcd_puts(secsStr);  	
					_delay_ms(1000);
				}
				else{	
					lightsOn = false;
					LIGHTS_SIGNAL_PORT &= ~(1 << LIGHTS_SIGNAL);
					//Tell user the lid is open
					printf("LID OPEN, CLOSE IT TO CONTINUE\n");
					lcd_check_busy_flag();
					lcd_send_command(LCD_CLEAR);
					lcd_puts("    LID OPEN     ");
					lcd_check_busy_flag();
					lcd_send_command(LCD_SET_CURSOR_POS | LCD_SECOND_LINE);
					lcd_puts(" PLEASE CLOSE IT ");
					//Increment Count to make up for this one
					count++;
				}
				 	
			}
			//Turn off lights
			LIGHTS_SIGNAL_PORT &= ~(1 << LIGHTS_SIGNAL);
			if(btnStop != true){
				lcd_check_busy_flag();
				lcd_send_command(LCD_CLEAR);
				lcd_puts("    FINISHED    ");
				alarmSound(2);
			}
			else{
				buzzerSound(13);
				btnStop = false; //reset the stop flag
			}
			displayBlink(2);
		}	
	}
    	return 0;
}
Ejemplo n.º 8
0
/**
 * @brief Clears the display.
 */
void lcd_clear() {
	lcd_send_command(1);
}
Ejemplo n.º 9
0
void debug (const char *string)
{
    lcd_send_command (DD_RAM_ADDR); /* LCD set first row */
    lcd_send_string (string);
}
/**
 * @brief send a clear command to LCD display
 * @param None
 * @retval None
 */
void lcd_clear_command(void)
{
  lcd_send_command(0x01);
}
Ejemplo n.º 11
0
int main (void)
{
    unsigned char           menu = MENU_SHOW_USER_TIME;

    static unsigned char    button_state = 0, counter_button = 0;

    unsigned                cpsr_temp;
    double                  voltage_temp,
                            current_temp,
                            wattage_hour_temp,
                            wattage_temp;

    unsigned short int      nr_adc_reads_temp;

    /* Initialize variables */
    voltage                             = 0;
    current                             = 0;
    wattage                             = 0;
    wattage_hour_user                   = 0;
    wattage_hour_system                 = 0;
    tick_update_lcd                     = 0;
    nr_adc_reads                        = 0;
    user_time_wattage                   = 0;

	/* Initialize the system */
    system_init ();

    /* Initialize the LCD */
    lcd_init ();

    /* Initialize the ADC */
    adc_init ();

    /* Initialize the buttons */
    buttons_init ();

    /* Initialize the Timer0 */
    timer1_init ();
    enableIRQ ();

    for (;;)
    {
        switch (menu)
        {
        case MENU_SHOW_USER_TIME:

        if (button_is_set(BUTTON_01) && !button_state)
        {
            menu = MENU_SHOW_USER_POWER;
            button_state = 1;
            counter_button = 0;
        }

        if (!button_is_set(BUTTON_01))
            button_state = 0;

        if (tick_update_lcd >= 50) /* Execute on every 50 * 5ms */
        {
            /* Disable the IRQ for avoid change on global variables used on
            * Timer1 IRQ handler code */
            cpsr_temp = disableIRQ ();
            wattage = 0;
            voltage = 0;
            current = 0;
            nr_adc_reads = 0;
            wattage_temp = user_time_wattage;
            tick_update_lcd = 0;
            /* Restore the IRQ */
            restoreIRQ (cpsr_temp);

            lcd_send_command (DD_RAM_ADDR); /* LCD set first row */
            lcd_send_char (' ');
            lcd_send_char ('A');
            lcd_send_char ('v');
            lcd_send_char ('a');
            lcd_send_char ('i');
            lcd_send_char ('l');
            lcd_send_char ('a');
            lcd_send_char ('b');
            lcd_send_char ('l');
            lcd_send_char ('e');
            lcd_send_char (' ');
            lcd_send_char ('t');
            lcd_send_char ('i');
            lcd_send_char ('m');
            lcd_send_char ('e');
            lcd_send_char (' ');

            lcd_send_command (DD_RAM_ADDR2); /* LCD set 2nd row */

            /* (watts per hour * 60) ==> watts per minute.
             * Load uses 30 watts so: ((watts per hour * 60) / 30) <=>
             *                         (watts per hour * 2).
             */
            double temp1, temp2;
            temp1 = ((long) (wattage_temp * 2));
            temp2 = ((double) (((double) (wattage_temp * 2)) - (double) temp1));
            lcd_send_char (' ');
            lcd_send_char (' ');
            lcd_send_char (' ');
            lcd_send_char (' ');
            lcd_send_int (temp1, 3);
            lcd_send_char ('m');
            lcd_send_char (' ');
            lcd_send_int (((long) (temp2 * 60)), 2);
            lcd_send_char ('s');
            lcd_send_char (' ');
            lcd_send_char (' ');
            lcd_send_char (' ');
            lcd_send_char (' ');

            /* Verify if we need to reset the "usage time available" */
            if (button_is_set(BUTTON_02))
            {
                if (++counter_button >= 4)
                {
                    while (button_is_set(BUTTON_02))
                    {
                        lcd_send_command (DD_RAM_ADDR);
                        lcd_send_char (' ');
                        lcd_send_char ('A');
                        lcd_send_char ('v');
                        lcd_send_char ('a');
                        lcd_send_char ('i');
                        lcd_send_char ('l');
                        lcd_send_char ('a');
                        lcd_send_char ('b');
                        lcd_send_char ('l');
                        lcd_send_char ('e');
                        lcd_send_char (' ');
                        lcd_send_char ('t');
                        lcd_send_char ('i');
                        lcd_send_char ('m');
                        lcd_send_char ('e');
                        lcd_send_char (' ');

                        lcd_send_command (DD_RAM_ADDR2);
                        lcd_send_char (' ');
                        lcd_send_char (' ');
                        lcd_send_char (' ');
                        lcd_send_char (' ');
                        lcd_send_char (' ');
                        lcd_send_char ('r');
                        lcd_send_char ('e');
                        lcd_send_char ('s');
                        lcd_send_char ('e');
                        lcd_send_char ('t');
                        lcd_send_char (' ');
                        lcd_send_char (' ');
                        lcd_send_char (' ');
                        lcd_send_char (' ');
                        lcd_send_char (' ');
                        lcd_send_char (' ');
                    }

             /* Disable the IRQ for avoid change on global variables used on
              * Timer1 IRQ handler code */
                    cpsr_temp = disableIRQ ();
                    user_time_wattage = 0;
                    tick_update_lcd = 0;
                    /* Restore the IRQ */
                    restoreIRQ (cpsr_temp);

                    counter_button = 0;
                }
            }
        }

        break;

            case MENU_SHOW_USER_POWER:

            if (button_is_set(BUTTON_01) && !button_state)
            {
                menu = MENU_SHOW_SYSTEM_POWER;
                button_state = 1;
                counter_button = 0;
            }

            if (!button_is_set(BUTTON_01))
                button_state = 0;

            if (tick_update_lcd >= 50) /* Execute on every 50 * 5ms */
            {
                /* Disable the IRQ for avoid change on global variables used on
                * Timer1 IRQ handler code */
                cpsr_temp = disableIRQ ();
                wattage_temp = wattage;
                wattage = 0;
                wattage_hour_temp = wattage_hour_user;
                voltage = 0;
                current = 0;
                nr_adc_reads_temp = nr_adc_reads;
                nr_adc_reads = 0;
                tick_update_lcd = 0;
                /* Restore the IRQ */
                restoreIRQ (cpsr_temp);

                lcd_send_command (DD_RAM_ADDR); /* LCD set first row */
                lcd_send_char (' ');
                lcd_send_float ((wattage_temp/nr_adc_reads_temp), 3, 1);
                lcd_send_char (' ');
                lcd_send_char ('W');
                lcd_send_char ('a');
                lcd_send_char ('t');
                lcd_send_char ('t');
                lcd_send_char ('s');
                lcd_send_char (' ');
                lcd_send_char (' ');
                lcd_send_char (' ');
                lcd_send_char (' ');

                lcd_send_command (DD_RAM_ADDR2); /* LCD set 2nd row */
                lcd_send_char (' ');
                lcd_send_float (wattage_hour_temp, 3, 3);
                lcd_send_char (' ');
                lcd_send_char ('W');
                lcd_send_char ('/');
                lcd_send_char ('h');
                lcd_send_char ('o');
                lcd_send_char ('u');
                lcd_send_char ('r');
                lcd_send_char (' ');

                /* Verify if we need to reset the wattage_hour_user */
                if (button_is_set(BUTTON_02))
                {
                    if (++counter_button >= 8)
                    {
                        while (button_is_set(BUTTON_02))
                        {
                            lcd_send_command (DD_RAM_ADDR);
                            lcd_send_char (' ');
                            lcd_send_char (' ');
                            lcd_send_char (' ');
                            lcd_send_char ('W');
                            lcd_send_char ('a');
                            lcd_send_char ('t');
                            lcd_send_char ('t');
                            lcd_send_char ('s');
                            lcd_send_char (' ');
                            lcd_send_char ('h');
                            lcd_send_char ('o');
                            lcd_send_char ('u');
                            lcd_send_char ('r');
                            lcd_send_char (' ');
                            lcd_send_char (' ');
                            lcd_send_char (' ');

                            lcd_send_command (DD_RAM_ADDR2);
                            lcd_send_char (' ');
                            lcd_send_char (' ');
                            lcd_send_char (' ');
                            lcd_send_char (' ');
                            lcd_send_char (' ');
                            lcd_send_char ('r');
                            lcd_send_char ('e');
                            lcd_send_char ('s');
                            lcd_send_char ('e');
                            lcd_send_char ('t');
                            lcd_send_char (' ');
                            lcd_send_char (' ');
                            lcd_send_char (' ');
                            lcd_send_char (' ');
                            lcd_send_char (' ');
                            lcd_send_char (' ');
                        }

                 /* Disable the IRQ for avoid change on global variables used on
                  * Timer1 IRQ handler code */
                        cpsr_temp = disableIRQ ();
                        wattage_hour_user = 0;
                        tick_update_lcd = 0;
                        /* Restore the IRQ */
                        restoreIRQ (cpsr_temp);

                        counter_button = 0;
                    }
                }
            }

            break;

            case MENU_SHOW_SYSTEM_POWER:

            if (button_is_set(BUTTON_01) && !button_state)
            {
                menu = MENU_SHOW_USER_TIME;
                button_state = 1;
                counter_button = 0;
            }

            if (!button_is_set(BUTTON_01))
                button_state = 0;

            if (tick_update_lcd >= 50) /* Execute on every 50 * 5ms */
            {
                /* Disable the IRQ for avoid change on global variables used on
                * Timer1 IRQ handler code */
                cpsr_temp = disableIRQ ();
                wattage_temp = wattage;
                wattage = 0;
                wattage_hour_temp = wattage_hour_system;
                voltage = 0;
                current = 0;
                nr_adc_reads_temp = nr_adc_reads;
                nr_adc_reads = 0;
                tick_update_lcd = 0;
                /* Restore the IRQ */
                restoreIRQ (cpsr_temp);

                lcd_send_command (DD_RAM_ADDR); /* LCD set first row */
                lcd_send_char (' ');
                lcd_send_char (' ');
                lcd_send_char ('T');
                lcd_send_char ('o');
                lcd_send_char ('t');
                lcd_send_char ('a');
                lcd_send_char ('l');
                lcd_send_char (' ');
                lcd_send_char ('p');
                lcd_send_char ('o');
                lcd_send_char ('w');
                lcd_send_char ('e');
                lcd_send_char ('r');
                lcd_send_char (' ');
                lcd_send_char (' ');
                lcd_send_char (' ');

                lcd_send_command (DD_RAM_ADDR2); /* LCD set 2nd row */
                lcd_send_char (' ');
                lcd_send_float (wattage_hour_temp, 4, 3);

                lcd_send_char (' ');
                lcd_send_char ('W');
                lcd_send_char ('/');
                lcd_send_char ('h');
                lcd_send_char ('o');
                lcd_send_char ('u');
                lcd_send_char ('r');

                /* Verify if we need to go on the advanced menus */
                if (button_is_set(BUTTON_02))
                {
                    if (++counter_button >= 20)
                    {
                        while (button_is_set(BUTTON_02))
                        {
                            lcd_send_command (DD_RAM_ADDR);
                            lcd_send_char (' ');
                            lcd_send_char (' ');
                            lcd_send_char (' ');
                            lcd_send_char (' ');
                            lcd_send_char ('G');
                            lcd_send_char ('o');
                            lcd_send_char ('i');
                            lcd_send_char ('n');
                            lcd_send_char ('g');
                            lcd_send_char (' ');
                            lcd_send_char ('t');
                            lcd_send_char ('o');
                            lcd_send_char (' ');
                            lcd_send_char (' ');
                            lcd_send_char (' ');
                            lcd_send_char (' ');

                            lcd_send_command (DD_RAM_ADDR2); /* LCD set 2nd row */
                            lcd_send_char (' ');
                            lcd_send_char ('a');
                            lcd_send_char ('d');
                            lcd_send_char ('v');
                            lcd_send_char ('a');
                            lcd_send_char ('n');
                            lcd_send_char ('c');
                            lcd_send_char ('e');
                            lcd_send_char ('d');
                            lcd_send_char (' ');
                            lcd_send_char ('m');
                            lcd_send_char ('e');
                            lcd_send_char ('n');
                            lcd_send_char ('u');
                            lcd_send_char ('s');
                            lcd_send_char (' ');
                        }

                        menu = MENU_SHOW_VOLTAGE_CURRENT;

                        counter_button = 0;
                    }
                }
            }

            break;

            case MENU_SHOW_VOLTAGE_CURRENT:

            if (button_is_set(BUTTON_01) && !button_state)
            {
                menu = MENU_SHOW_ADC_READINGS;
                button_state = 1;
                counter_button = 0;
            }

            if (!button_is_set(BUTTON_01))
                button_state = 0;

            if (tick_update_lcd >= 50) /* Execute on every 50 * 5ms */
            {
                /* Disable the IRQ for avoid change on global variables used on
                 * Timer1 IRQ handler code */
                cpsr_temp = disableIRQ ();
                voltage_temp = voltage;
                voltage = 0;
                current_temp = current;
                current = 0;
                nr_adc_reads_temp = nr_adc_reads;
                nr_adc_reads = 0;
                tick_update_lcd = 0;
                /* Restore the IRQ */
                restoreIRQ (cpsr_temp);

                lcd_send_command (DD_RAM_ADDR); /* LCD set first row */
                lcd_send_char (' ');
                lcd_send_char (' ');
                lcd_send_char (' ');
                lcd_send_float ((((voltage_temp/nr_adc_reads_temp) * \
                                                K_VOLTAGE) + M_VOLTAGE), 2,1);

                lcd_send_char (' ');
                lcd_send_char ('V');
                lcd_send_char ('o');
                lcd_send_char ('l');
                lcd_send_char ('t');
                lcd_send_char ('s');
                lcd_send_char (' ');
                lcd_send_char (' ');
                lcd_send_char (' ');

                lcd_send_command (DD_RAM_ADDR2); /* LCD set 2nd row */
                lcd_send_char (' ');
                lcd_send_char (' ');
                lcd_send_char (' ');
          /* First 3 values from ADC_current should not be used since they are
           *  very non linear.
           */
                current_temp = (current_temp/nr_adc_reads_temp);
                if (current_temp < 3)
                {
                    lcd_send_float (0, 2, 1);
                }

                if (current_temp >= 3 && current_temp < 60)
                {
                    current_temp = \
                   ((-0.000004 * current_temp * current_temp * current_temp) + \
                   (0.0005 * current_temp * current_temp) - \
                   (0.0028 * current_temp) + 0.356);
                    lcd_send_float (current_temp, 2, 1);
                }

                if (current_temp >= 60)
                {
                    lcd_send_float (((current_temp * K_CURRENT) + \
                            M_CURRENT),2,1);
                }

                lcd_send_char (' ');
                lcd_send_char ('A');
                lcd_send_char ('m');
                lcd_send_char ('p');
                lcd_send_char ('s');
                lcd_send_char (' ');
                lcd_send_char (' ');
                lcd_send_char (' ');
                lcd_send_char (' ');

                /* Verify if we need to go on the normal menus */
                if (button_is_set(BUTTON_02))
                {
                    if (++counter_button >= 20)
                    {
                        while (button_is_set(BUTTON_02))
                        {
                            lcd_send_command (DD_RAM_ADDR);
                            lcd_send_char (' ');
                            lcd_send_char (' ');
                            lcd_send_char (' ');
                            lcd_send_char (' ');
                            lcd_send_char ('L');
                            lcd_send_char ('e');
                            lcd_send_char ('a');
                            lcd_send_char ('v');
                            lcd_send_char ('i');
                            lcd_send_char ('n');
                            lcd_send_char ('g');
                            lcd_send_char (' ');
                            lcd_send_char (' ');
                            lcd_send_char (' ');
                            lcd_send_char (' ');
                            lcd_send_char (' ');

                            lcd_send_command (DD_RAM_ADDR2);
                            lcd_send_char (' ');
                            lcd_send_char ('a');
                            lcd_send_char ('d');
                            lcd_send_char ('v');
                            lcd_send_char ('a');
                            lcd_send_char ('n');
                            lcd_send_char ('c');
                            lcd_send_char ('e');
                            lcd_send_char ('d');
                            lcd_send_char (' ');
                            lcd_send_char ('m');
                            lcd_send_char ('e');
                            lcd_send_char ('n');
                            lcd_send_char ('u');
                            lcd_send_char ('s');
                            lcd_send_char (' ');
                        }

                        menu = MENU_SHOW_USER_TIME;

                        counter_button = 0;
                    }
                }
            }

            break;

            case MENU_SHOW_ADC_READINGS:

            disableIRQ ();
            lcd_send_command (CLR_DISP);

            while (1)
            {
                lcd_send_command (DD_RAM_ADDR); /* LCD set first row */
                lcd_send_char ('A');
                lcd_send_char ('D');
                lcd_send_char ('C');
                lcd_send_char (' ');
                lcd_send_char ('v');
                lcd_send_char ('o');
                lcd_send_char ('l');
                lcd_send_char ('t');
                lcd_send_char ('a');
                lcd_send_char ('g');
                lcd_send_char ('e');
                lcd_send_char (':');
                int i;
                for (i = 0; i < 5000; i++)
                    voltage += adc_read (6);
                lcd_send_int (voltage/5000, 4);
                voltage = 0;
                lcd_send_command (DD_RAM_ADDR2); /* LCD set 2nd row */
                lcd_send_char ('A');
                lcd_send_char ('D');
                lcd_send_char ('C');
                lcd_send_char (' ');
                lcd_send_char ('c');
                lcd_send_char ('u');
                lcd_send_char ('r');
                lcd_send_char ('r');
                lcd_send_char ('e');
                lcd_send_char ('n');
                lcd_send_char ('t');
                lcd_send_char (':');
                for (i = 0; i < 5000; i++)
                    current += adc_read (7);
                lcd_send_int (current/5000, 4);
                current = 0;

                if (button_is_set(BUTTON_01) && !button_state)
                {
                    menu = MENU_SHOW_VOLTAGE_CURRENT;
                    button_state = 1;
                    counter_button = 0;
                    voltage = 0;
                    current = 0;
                    restoreIRQ (cpsr_temp);
                    break;
                    break;
                }

                if (!button_is_set(BUTTON_01))
                    button_state = 0;
            }

            break;

            default:
            break;
        }

    /* Go to idle mode to save power. System leaves idle mode on interrupt, so,
     * at each 5ms interrupt from Timer 1.
     */
    /* UNCOMENT IN THE END - NOT POSSIBLE TO DEBUG WITH IDLE MODE */
    system_go_idle ();
    }
}