// *************************************************************************************************
// @fn          display_update
// @brief       Process display flags and call LCD update routines.
// @param       none
// @return      none
// *************************************************************************************************
void display_update(void)
{
    unsigned char line;
    unsigned char string[8];

    // ---------------------------------------------------------------------
    // Call Line1 display function
    if (display.flag.full_update || display.flag.line1_full_update)
    {
        clear_line(LINE1);
        fptr_lcd_function_line1(LINE1, DISPLAY_LINE_UPDATE_FULL);
    } else if (ptrMenu_L1->display_update())
    {
        // Update line1 only when new data is available
        fptr_lcd_function_line1(LINE1, DISPLAY_LINE_UPDATE_PARTIAL);
    }

    // ---------------------------------------------------------------------
    // If message text should be displayed on Line2, skip normal update
    if (message.flag.show)
    {
        line = LINE2;

        // Select message to display
        if (message.flag.type_locked)
            memcpy(string, "  LO?T", 6);
        else if (message.flag.type_unlocked)
            memcpy(string, "  OPEN", 6);

        // Clear previous content
        clear_line(line);
        fptr_lcd_function_line2(line, DISPLAY_LINE_CLEAR);

        // Next second tick erases message and repaints original screen content
        message.all_flags = 0;
        message.flag.erase = 1;
    }
    // ---------------------------------------------------------------------
    // Call Line2 display function
    else if (display.flag.full_update || display.flag.line2_full_update)
    {
        clear_line(LINE2);
        fptr_lcd_function_line2(LINE2, DISPLAY_LINE_UPDATE_FULL);
    } else if (ptrMenu_L2->display_update() && !message.all_flags)
    {
        // Update line2 only when new data is available
        fptr_lcd_function_line2(LINE2, DISPLAY_LINE_UPDATE_PARTIAL);
    }

    // Clear display flag
    display.all_flags = 0;
}
Example #2
0
// *************************************************************************************************
// @fn          menu_skip_next
// @brief       skip to next menu item
// @param       line line to skip in
// @return      none
// *************************************************************************************************
void menu_skip_next(line_t line)
{
	if(line==LINE1)
	{
		// Clean up display before activating next menu item
		fptr_lcd_function_line1(LINE1, DISPLAY_LINE_CLEAR);
		
		if(++menu_L1_position>=menu_L1_size)
		{
			menu_L1_position=0;
		}
		
		// Go to next menu entry
		ptrMenu_L1 = menu_L1[menu_L1_position];
			
		// Assign new display function
		fptr_lcd_function_line1 = ptrMenu_L1->display_function;
	}
	else if(line==LINE2)
	{
	// Clean up display before activating next menu item
		fptr_lcd_function_line2(LINE2, DISPLAY_LINE_CLEAR);

		if(++menu_L2_position>=menu_L2_size)
			menu_L2_position=0;
		
		// Go to next menu entry
		ptrMenu_L2 = menu_L2[menu_L2_position];

		// Assign new display function
		fptr_lcd_function_line2 = ptrMenu_L2->display_function;
	}

}
Example #3
0
// *************************************************************************************************
// @fn          start_simpliciti_sync
// @brief       Start SimpliciTI (sync mode).
// @param       none
// @return      none
// *************************************************************************************************
void start_simpliciti_sync(void)
{
    // Clear LINE1
    clear_line(LINE1);
    fptr_lcd_function_line1(LINE1, DISPLAY_LINE_CLEAR);

    // Stop data logging and close session
    stop_datalog();

    // Turn on beeper icon to show activity
    display_symbol(LCD_ICON_BEEPER1, SEG_ON_BLINK_ON);
    display_symbol(LCD_ICON_BEEPER2, SEG_ON_BLINK_ON);
    display_symbol(LCD_ICON_BEEPER3, SEG_ON_BLINK_ON);

    // Prepare radio for RF communication
    open_radio();

    // Set SimpliciTI mode
    sRFsmpl.mode = SIMPLICITI_SYNC;

    // Set SimpliciTI timeout to save battery power
    sRFsmpl.timeout = SIMPLICITI_TIMEOUT;

    // Start SimpliciTI stack. Try to link to access point.
    // Exit with timeout or by a DOWN button press.
    if (simpliciti_link())
    {
        // Enter sync routine. This will send ready-to-receive packets at regular intervals to the
        // access point.
        // The access point always replies a command (NOP if no other command is set)
        simpliciti_main_sync();
    }

    // Set SimpliciTI state to OFF
    sRFsmpl.mode = SIMPLICITI_OFF;

    // Powerdown radio
    close_radio();

    // Clear last button events
    Timer0_A4_Delay(CONV_MS_TO_TICKS(BUTTONS_DEBOUNCE_TIME_OUT));
    BUTTONS_IFG = 0x00;
    button.all_flags = 0;

    // Clear icons
    display_symbol(LCD_ICON_BEEPER1, SEG_OFF_BLINK_OFF);
    display_symbol(LCD_ICON_BEEPER2, SEG_OFF_BLINK_OFF);
    display_symbol(LCD_ICON_BEEPER3, SEG_OFF_BLINK_OFF);

    // Force full display update
    display.flag.full_update = 1;
}
Example #4
0
// *************************************************************************************************
// @fn          display_update
// @brief       Process display flags and call LCD update routines.
// @param       none
// @return      none
// *************************************************************************************************
void display_update(void)
{
    u8 line;
    u8 string[8];

    // ---------------------------------------------------------------------
    // Call Line1 display function
    if (display.flag.full_update || display.flag.line1_full_update)
    {
        clear_line(LINE1);
        fptr_lcd_function_line1(LINE1, DISPLAY_LINE_UPDATE_FULL);
    } else if (ptrMenu_L1->display_update())
    {
        // Update line1 only when new data is available
        fptr_lcd_function_line1(LINE1, DISPLAY_LINE_UPDATE_PARTIAL);
    }

    // ---------------------------------------------------------------------
    // If message text should be displayed on Line2, skip normal update
    if (message.flag.show)
    {
        line = LINE2;

        // Select message to display
        if (message.flag.type_locked)
            memcpy(string, "  LO?T", 6);
        else if (message.flag.type_unlocked)
            memcpy(string, "  OPEN", 6);
        else if (message.flag.type_lobatt)
            memcpy(string, "LOBATT", 6);
        else if (message.flag.type_alarm_on)
        {
            memcpy(string, "  ON", 4);
            line = LINE1;
        } else if (message.flag.type_alarm_off)
        {
            memcpy(string, " OFF", 4);
            line = LINE1;
        }
        // Clear previous content
        clear_line(line);
        fptr_lcd_function_line2(line, DISPLAY_LINE_CLEAR);

        if (line == LINE2)
            display_chars(LCD_SEG_L2_5_0, string, SEG_ON);
        else
            display_chars(LCD_SEG_L1_3_0, string, SEG_ON);

        // Next second tick erases message and repaints original screen content
        message.all_flags = 0;
        message.flag.erase = 1;
    }
    // ---------------------------------------------------------------------
    // Call Line2 display function
    else if (display.flag.full_update || display.flag.line2_full_update)
    {
        clear_line(LINE2);
        fptr_lcd_function_line2(LINE2, DISPLAY_LINE_UPDATE_FULL);
    } else if (ptrMenu_L2->display_update() && !message.all_flags)
    {
        // Update line2 only when new data is available
        fptr_lcd_function_line2(LINE2, DISPLAY_LINE_UPDATE_PARTIAL);
    }
    // ---------------------------------------------------------------------
    // Restore blinking icons (blinking memory is cleared when calling set_value)
    if (display.flag.full_update)
    {
    /*
        if (is_bluerobin() == BLUEROBIN_CONNECTED)
        {
            // Turn on beeper icon to show activity
            display_symbol(LCD_ICON_BEEPER1, SEG_ON_BLINK_OFF);
            display_symbol(LCD_ICON_BEEPER2, SEG_ON_BLINK_OFF);
            display_symbol(LCD_ICON_BEEPER3, SEG_ON_BLINK_OFF);
        }
    */
    }
    // Clear display flag
    display.all_flags = 0;
}
Example #5
0
// *************************************************************************************************
// @fn          wakeup_event
// @brief       Process external / internal wakeup events.
// @param       none
// @return      none
// *************************************************************************************************
void wakeup_event(void)
{
    // Enable idle timeout
    sys.flag.idle_timeout_enabled = 1;

    // If buttons are locked, only display "buttons are locked" message
    if (button.all_flags && sys.flag.lock_buttons)
    {
        // Show "buttons are locked" message synchronously with next second tick
        if (!(BUTTON_NUM_IS_PRESSED && BUTTON_DOWN_IS_PRESSED))
        {
            message.flag.prepare = 1;
            message.flag.type_locked = 1;
        }
        // Clear buttons
        button.all_flags = 0;
    }
    // Process long button press event (while button is held)
    else if (button.flag.star_long)
    {
        // Clear button event
        button.flag.star_long = 0;

        // Call sub menu function
        ptrMenu_L1->mx_function(LINE1);

        // Set display update flag
        display.flag.full_update = 1;
    }
    else if (button.flag.num_long)
    {
        // Clear button event
        button.flag.num_long = 0;

        // Call sub menu function
        ptrMenu_L2->mx_function(LINE2);

        // Set display update flag
        display.flag.full_update = 1;
    }
    // Process single button press event (after button was released)
    else if (button.all_flags)
    {
        // M1 button event ---------------------------------------------------------------------
        // (Short) Advance to next menu item
        if (button.flag.star)
        {
            // Clean up display before activating next menu item
            fptr_lcd_function_line1(LINE1, DISPLAY_LINE_CLEAR);

            // Go to next menu entry
            ptrMenu_L1 = ptrMenu_L1->next;

            // Assign new display function
            fptr_lcd_function_line1 = ptrMenu_L1->display_function;

            // Set Line1 display update flag
            display.flag.line1_full_update = 1;

            // Clear button flag
            button.flag.star = 0;
        }
        // NUM button event ---------------------------------------------------------------------
        // (Short) Advance to next menu item
        else if (button.flag.num)
        {
            // Clear rfBSL confirmation flag
            rfBSL_button_confirmation = 0;

            // Clean up display before activating next menu item
            fptr_lcd_function_line2(LINE2, DISPLAY_LINE_CLEAR);

            // Go to next menu entry
            ptrMenu_L2 = ptrMenu_L2->next;

            // Assign new display function
            fptr_lcd_function_line2 = ptrMenu_L2->display_function;

            // Set Line2 display update flag
            display.flag.line2_full_update = 1;

            // Clear button flag
            button.flag.num = 0;
        }
        // UP button event ---------------------------------------------------------------------
        // Activate user function for Line1 menu item
        else if (button.flag.up)
        {
            // Call direct function
            ptrMenu_L1->sx_function(LINE1);

            // Set Line1 display update flag
            display.flag.line1_full_update = 1;

            // Clear button flag
            button.flag.up = 0;
        }
        // DOWN button event ---------------------------------------------------------------------
        // Activate user function for Line2 menu item
        else if (button.flag.down)
        {
            if (ptrMenu_L2 == &menu_L2_RFBSL)
            {

            }

            // Call direct function
            ptrMenu_L2->sx_function(LINE2);

            // Set Line1 display update flag
            display.flag.line2_full_update = 1;

            // Clear button flag
            button.flag.down = 0;
        }
    }
    // Process internal events
    if (sys.all_flags)
    {
        // Idle timeout ---------------------------------------------------------------------
        if (sys.flag.idle_timeout)
        {
            // Clear timeout flag
            sys.flag.idle_timeout = 0;

            // Clear display
            clear_display();

            // Set display update flags
            display.flag.full_update = 1;
        }
    }
    // Disable idle timeout
    sys.flag.idle_timeout_enabled = 0;
}
// *************************************************************************************************
// @fn          start_simpliciti_tx_only
// @brief       Start SimpliciTI (tx only).
// @param       simpliciti_state_t              SIMPLICITI_ACCELERATION, SIMPLICITI_BUTTONS
// @return      none
// *************************************************************************************************
void start_simpliciti_tx_only(simpliciti_mode_t mode)
{
    // Display time in line 1
    clear_line(LINE1);
    fptr_lcd_function_line1(LINE1, DISPLAY_LINE_CLEAR);
    display_time(LINE1, DISPLAY_LINE_UPDATE_FULL);

    // Preset simpliciti_data with mode (key or mouse click) and clear other data bytes
    if (mode == SIMPLICITI_ACCELERATION)
    {
        simpliciti_data[0] = SIMPLICITI_MOUSE_EVENTS;
    }
    else
    {
        simpliciti_data[0] = SIMPLICITI_KEY_EVENTS;
    }
    simpliciti_data[1] = 0;
    simpliciti_data[2] = 0;
    simpliciti_data[3] = 0;

    // Turn on beeper icon to show activity
    display_symbol(LCD_ICON_BEEPER1, SEG_ON_BLINK_ON);
    display_symbol(LCD_ICON_BEEPER2, SEG_ON_BLINK_ON);
    display_symbol(LCD_ICON_BEEPER3, SEG_ON_BLINK_ON);

    // Debounce button event
    Timer0_A4_Delay(CONV_MS_TO_TICKS(BUTTONS_DEBOUNCE_TIME_OUT));

    // Prepare radio for RF communication
    open_radio();

    // Set SimpliciTI mode
    sRFsmpl.mode = mode;

    // Set SimpliciTI timeout to save battery power
    sRFsmpl.timeout = SIMPLICITI_TIMEOUT;

    // Start SimpliciTI stack. Try to link to access point.
    // Exit with timeout or by a button DOWN press.
    if (simpliciti_link())
    {
        if (mode == SIMPLICITI_ACCELERATION)
        {
            // Start acceleration sensor
            as_start();
        }

        // Enter TX only routine. This will transfer button events and/or acceleration data to
        // access point.
        simpliciti_main_tx_only();
    }

    // Set SimpliciTI state to OFF
    sRFsmpl.mode = SIMPLICITI_OFF;

    // Stop acceleration sensor
    as_stop();

    // Powerdown radio
    close_radio();

    // Clear last button events
    Timer0_A4_Delay(CONV_MS_TO_TICKS(BUTTONS_DEBOUNCE_TIME_OUT));
    BUTTONS_IFG = 0x00;
    button.all_flags = 0;

    // Clear icons
    display_symbol(LCD_ICON_BEEPER1, SEG_OFF_BLINK_OFF);
    display_symbol(LCD_ICON_BEEPER2, SEG_OFF_BLINK_OFF);
    display_symbol(LCD_ICON_BEEPER3, SEG_OFF_BLINK_OFF);

    // Clean up line 1
    clear_line(LINE1);
    display_time(LINE1, DISPLAY_LINE_CLEAR);

    // Force full display update
    display.flag.full_update = 1;
}