Defines | Enumerations | Functions | Variables

hlogmain.c File Reference

#include "config.h"
#include <stdio.h>
#include <util/delay.h>
#include <avr/io.h>
#include <avr/interrupt.h>
#include <ctype.h>
#include "xpal_board.h"
#include "xpal_extmem.h"
#include "usb-fifo.h"
#include "keys.h"
#include "lh155.h"
#include "display.h"
#include "fontlist.h"
#include "term.h"
#include "xpal_power.h"
#include "xpal_bat.h"
#include "xpal_StatBar.h"
#include "adc.h"
#include "rtc.h"
#include "usarts.h"
#include "fifo.h"
#include "gps-parser.h"
#include "timer.h"
#include "sdcmd.h"
#include "shell.h"
#include "shell-fs.h"
#include "clock.h"
#include "hlog-hlog.h"
#include "hlog-menu.h"
#include "hlog-poi.h"
#include "version.h"
#include <diskio.h>

Defines

#define APP_LAST   APP_SYS
#define RXSIZE   (240)
#define TXSIZE   (80)
#define FAT_YEARBASE   (1980)

Enumerations

enum  menu_states { APP_POI, APP_HLOG, APP_GPS, APP_SYS }

Functions

void hl_application_changed (keyscan_t key, gps_parser_t *hlparser)
 Event handler for switching through applications.
void hl_handle_menu_key (keyscan_t key, gps_parser_t *hlparser)
 Key handler for menu keys.
int main ()
DWORD get_fattime (void)
 get current time for FATFS module

Variables

gps_parser_tmodparser
gps_parser_textparser
gps_position_t gpsdata
 struct holding all GPS data to write to GPX file
const uint16_t power_var = HL_PWR_ALLOW_NOSAVE | HL_PWR_ALLOW_IDLE
char vbat_buf [16]

Detailed Description


Function Documentation

void hl_application_changed ( keyscan_t  key,
gps_parser_t hlparser 
)

Event handler for switching through applications.

This function is called whenever the active application changes. General app switching stuff should be done here. For app specific tasks an appropriate function has to be called.

{
        // clear application display area
        hl_clear_application_screen ();
        // clear and enable status bar
        hl_stb_init ();
        hl_menu_clear_s4 ();
        hl_menu_clear_s5 ();
        hl_menu_clear_s6 ();
        hl_menu_clear_s7 ();
        hl_menu_clear_s8 ();
        hl_menu_clear_soft (HL_MENU_SOFTKEY11);

  switch (app_state) {
  case APP_POI:
    hl_init_poi_app (key, hlparser);
    break;
  case APP_HLOG:
          hl_menu_write_s5_P (PSTR("SiRF"));
          hl_menu_write_s6_P (PSTR("NMEA"));
          hl_menu_write_s7_P (PSTR("lgpx"));
          hl_handle_key (HL_NOKEY, hlparser);
          break;
        case APP_GPS:
          hl_stb_disable();
          hl_lcd_drawstr_P (HL_SCRN_MIN_X+1, HL_SCRN_MIN_Y+1, PSTR("GPS"));
          hl_lcd_drawstr_P (HL_SCRN_MIN_X+1, HL_SCRN_MIN_Y+9, PSTR("Status"));
          break;
        case APP_SYS:
          hl_lcd_drawstr_P (HL_SCRN_MIN_X+1, HL_SCRN_MIN_Y+1, PSTR("System info"));
#ifdef SVNVERSION
          hl_lcd_drawstr_P (HL_SCRN_MIN_X+1+8, HL_SCRN_MIN_Y+10, PSTR("rev"));
          hl_lcd_drawstrn_P (HL_SCRN_MIN_X+1+4*8, HL_SCRN_MIN_Y+10,(SVNVERSION),
                             (HL_SCRN_MAX_X-1*8-HL_SCRN_MIN_X-1-4*8+1)/8);
#endif
          break;
        default:
      ;
    }
}

void hl_handle_menu_key ( keyscan_t  key,
gps_parser_t hlparser 
)

Key handler for menu keys.

Default key handler, to be called first. General menu keys for switching applications are evaluated here. All other key presses are passed to the specific key handler function of the currently selected application.

{
  uint8_t ok;

  switch (key) {
  case HL_SCAN_SOFT1: /* left upper soft key */
    if(app_state < APP_LAST)
      app_state++;
    else
      app_state = 0;
    printf_P (PSTR("changed app_state:%u\r\n"), app_state);
    hl_application_changed (key, hlparser);
    break;

  case HL_SCAN_SOFT2: /* left middle soft key */
    if(app_state > 0)
      app_state--;
    else
      app_state = APP_LAST;
    printf_P (PSTR("changed app_state:%u\r\n"), app_state);
    hl_application_changed (key, hlparser);
    break;

  case HL_SCAN_SOFT3: /* left lower soft key */
    // just store current gps data for further use
    ok = gps_get_data (hlparser, &gpsdata);
    if (!ok) {
      hl_lcd_drawstr_P (HL_SCRN_MIN_X+10, HL_SCRN_MIN_Y+50,
                    PSTR("No valid GPS data!"));
      return;
    }
    app_state = APP_POI;
    printf_P (PSTR("changed app_state:%u\r\n"), app_state);
    hl_application_changed (key, hlparser);
    break;

  // all other keys, call key handler of current application
  default:
    switch (app_state) {
    case APP_POI:
          hl_handle_poi_key (key, hlparser);
          break;
    case APP_HLOG:
          hl_handle_key (key, hlparser);
          break;
        case APP_GPS:
          break;
        case APP_SYS:
          break;
        default:
      ;
    }
  }
}