Microchip® Advanced Software Framework

timezone.c File Reference

set timezone offset in hours and minutes

Copyright (c) 2014-2018 Microchip Technology Inc. and its subsidiaries.

#include "nvm.h"
#include "gfx_mono_menu.h"
#include "keyboard.h"
#include "timezone.h"

Macros

#define TZ_HOURS_EEPROM_ADDR   4
 
#define TZ_MINUTES_EEPROM_ADDR   5
 

Functions

 PROGMEM_DECLARE (char const, tz_hours_title[])
 
 PROGMEM_DECLARE (char const, tz_n12[])
 
 PROGMEM_DECLARE (char const, tz_n11[])
 
 PROGMEM_DECLARE (char const, tz_n10[])
 
 PROGMEM_DECLARE (char const, tz_n09[])
 
 PROGMEM_DECLARE (char const, tz_n08[])
 
 PROGMEM_DECLARE (char const, tz_n07[])
 
 PROGMEM_DECLARE (char const, tz_n06[])
 
 PROGMEM_DECLARE (char const, tz_n05[])
 
 PROGMEM_DECLARE (char const, tz_n04[])
 
 PROGMEM_DECLARE (char const, tz_n03[])
 
 PROGMEM_DECLARE (char const, tz_n02[])
 
 PROGMEM_DECLARE (char const, tz_n01[])
 
 PROGMEM_DECLARE (char const, tz_00[])
 
 PROGMEM_DECLARE (char const, tz_01[])
 
 PROGMEM_DECLARE (char const, tz_02[])
 
 PROGMEM_DECLARE (char const, tz_03[])
 
 PROGMEM_DECLARE (char const, tz_04[])
 
 PROGMEM_DECLARE (char const, tz_05[])
 
 PROGMEM_DECLARE (char const, tz_06[])
 
 PROGMEM_DECLARE (char const, tz_07[])
 
 PROGMEM_DECLARE (char const, tz_08[])
 
 PROGMEM_DECLARE (char const, tz_09[])
 
 PROGMEM_DECLARE (char const, tz_10[])
 
 PROGMEM_DECLARE (char const, tz_11[])
 
 PROGMEM_DECLARE (char const, tz_12[])
 
 PROGMEM_DECLARE (char const, tz_minutes_title[])
 
 PROGMEM_DECLARE (char const, tz_min_00[])
 
 PROGMEM_DECLARE (char const, tz_min_15[])
 
 PROGMEM_DECLARE (char const, tz_min_30[])
 
 PROGMEM_DECLARE (char const, tz_min_45[])
 
int8_t timezone_get_hours (void)
 get the current timezone offset (hours) More...
 
int8_t timezone_get_minutes (void)
 get the current timezone offset (minutes) More...
 
void timezone_init (void)
 get and set timezone stored in EEPROM More...
 
void timezone_select_application (void)
 Select timezone application. More...
 
int8_t tz_index_to_minutes (uint8_t tz_minutes_index)
 Convert from tz_minute_menu index to actual minutes. More...
 

Variables

static int8_t tz_hours
 
struct gfx_mono_menu tz_hours_menu
 
PROGMEM_STRING_T tz_hours_strings []
 
static int8_t tz_minutes
 
struct gfx_mono_menu tz_minutes_menu
 
PROGMEM_STRING_T tz_minutes_strings []
 

#define TZ_HOURS_EEPROM_ADDR   4
#define TZ_MINUTES_EEPROM_ADDR   5

PROGMEM_DECLARE ( char  const,
tz_hours_title  [] 
)
PROGMEM_DECLARE ( char  const,
tz_n12  [] 
)
PROGMEM_DECLARE ( char  const,
tz_n11  [] 
)
PROGMEM_DECLARE ( char  const,
tz_n10  [] 
)
PROGMEM_DECLARE ( char  const,
tz_n09  [] 
)
PROGMEM_DECLARE ( char  const,
tz_n08  [] 
)
PROGMEM_DECLARE ( char  const,
tz_n07  [] 
)
PROGMEM_DECLARE ( char  const,
tz_n06  [] 
)
PROGMEM_DECLARE ( char  const,
tz_n05  [] 
)
PROGMEM_DECLARE ( char  const,
tz_n04  [] 
)
PROGMEM_DECLARE ( char  const,
tz_n03  [] 
)
PROGMEM_DECLARE ( char  const,
tz_n02  [] 
)
PROGMEM_DECLARE ( char  const,
tz_n01  [] 
)
PROGMEM_DECLARE ( char  const,
tz_00  [] 
)
PROGMEM_DECLARE ( char  const,
tz_01  [] 
)
PROGMEM_DECLARE ( char  const,
tz_02  [] 
)
PROGMEM_DECLARE ( char  const,
tz_03  [] 
)
PROGMEM_DECLARE ( char  const,
tz_04  [] 
)
PROGMEM_DECLARE ( char  const,
tz_05  [] 
)
PROGMEM_DECLARE ( char  const,
tz_06  [] 
)
PROGMEM_DECLARE ( char  const,
tz_07  [] 
)
PROGMEM_DECLARE ( char  const,
tz_08  [] 
)
PROGMEM_DECLARE ( char  const,
tz_09  [] 
)
PROGMEM_DECLARE ( char  const,
tz_10  [] 
)
PROGMEM_DECLARE ( char  const,
tz_11  [] 
)
PROGMEM_DECLARE ( char  const,
tz_12  [] 
)
PROGMEM_DECLARE ( char  const,
tz_minutes_title  [] 
)
PROGMEM_DECLARE ( char  const,
tz_min_00  [] 
)
PROGMEM_DECLARE ( char  const,
tz_min_15  [] 
)
PROGMEM_DECLARE ( char  const,
tz_min_30  [] 
)
PROGMEM_DECLARE ( char  const,
tz_min_45  [] 
)
int8_t timezone_get_hours ( void  )

get the current timezone offset (hours)

Return values
timezoneoffset (hours)

References tz_hours.

Referenced by display_date_time_application(), set_date_application(), and set_time_application().

int8_t timezone_get_minutes ( void  )

get the current timezone offset (minutes)

Return values
timezoneoffset (minutes)

References tz_minutes.

Referenced by display_date_time_application(), set_date_application(), and set_time_application().

void timezone_init ( void  )

get and set timezone stored in EEPROM

This function will check if a timezone has been stored in EEPROM. If this is the case it will be set, and used by the date&time application. If it is not set, the "select timezone" application will be started to set it

References gfx_mono_menu::current_selection, nvm_eeprom_read_byte(), timezone_select_application(), tz_hours, TZ_HOURS_EEPROM_ADDR, tz_index_to_minutes(), tz_minutes, and TZ_MINUTES_EEPROM_ADDR.

Referenced by main().

void timezone_select_application ( void  )

Select timezone application.

This application will show a menu with available timezone offset and set the selected timezone to be used by the date&time application. If the timezone setting differs from the already stored setting in EEPROM, the EEPROM value will be updated with the new selection.

References GFX_MONO_MENU_EVENT_EXIT, GFX_MONO_MENU_EVENT_IDLE, gfx_mono_menu_init(), gfx_mono_menu_process_key(), keyboard_get_key_state(), KEYBOARD_RELEASE, keyboard_event::keycode, nvm_eeprom_read_byte(), nvm_eeprom_write_byte(), keyboard_event::type, tz_hours, TZ_HOURS_EEPROM_ADDR, tz_index_to_minutes(), tz_minutes, and TZ_MINUTES_EEPROM_ADDR.

Referenced by date_time_application(), and timezone_init().

int8_t tz_index_to_minutes ( uint8_t  tz_minutes_index)

Convert from tz_minute_menu index to actual minutes.

Parameters
tz_minutes_indexindex in tz_minutes menu
Return values
actualnumber of minutes timezone offset

Referenced by timezone_init(), and timezone_select_application().

struct gfx_mono_menu tz_hours_menu
Initial value:
= {
tz_hours_title,
25,
12
}
PROGMEM_STRING_T tz_hours_strings[]
Definition: timezone.c:75
PROGMEM_STRING_T tz_hours_strings[]
Initial value:
= {
tz_n12,
tz_n11,
tz_n10,
tz_n09,
tz_n08,
tz_n07,
tz_n06,
tz_n05,
tz_n04,
tz_n03,
tz_n02,
tz_n01,
tz_00,
tz_01,
tz_02,
tz_03,
tz_04,
tz_05,
tz_06,
tz_07,
tz_08,
tz_09,
tz_10,
tz_11,
tz_12
}
struct gfx_mono_menu tz_minutes_menu
Initial value:
= {
tz_minutes_title,
4,
0
}
PROGMEM_STRING_T tz_minutes_strings[]
Definition: timezone.c:120
PROGMEM_STRING_T tz_minutes_strings[]
Initial value:
= {
tz_min_00,
tz_min_15,
tz_min_30,
tz_min_45
}