Main Page | Modules | Data Structures | File List | Data Fields | Globals | Related Pages | Examples

stkcmd.c

Example of writing own STK commands, icon in command.
/*
 * Copyright (C) 2003 BLADOX, s.r.o.  All rights reserved.
 * 
 * This file is part of an example program for Turbo. This example
 * program may be used, distributed and modified without limitation.
 *
 */

#include <config.h>
#include <turbo/turbo.h>

#include <stdlib.h>
#include <string.h>

u8 PROGMEM t_Text_en[] = "Idle Text";

//#define EXAMPLE_WITH_IMAGE

#ifdef EXAMPLE_WITH_IMAGE
u8 img_fnc (u16 b)
{
  return 0xFF;
}
#endif

void action_menu (void *data)
{
  u8 *buf = buf_A ();
  u8 *text;
  u8 len = 0;
  u8 i;
  u8 len_text;
  u8 *res = get_input (t_Text_en, 1, 20, NULL, Q_GET_INPUT_ALPHABET);

  if (res == NULL || res == ENULL)
    return;                     //user back or end application

  len_text = *res;
  res++;
  text = malloc (len_text);     // we have to make copy, res points into buf_A
  memcpy (text, res, len_text);

  buf[len++] = T_TEXT_STRING | CR_FLAG;
  buf[len++] = len_text;
  for (i = 0; i < len_text; i++)
    buf[len++] = text[i];

  free (text);

#ifdef EXAMPLE_WITH_IMAGE
  buf[len++] = T_ICON_ID;
  buf[len++] = 0x02;
  buf[len++] = 0x00;            // 0x00=icon only or 0x01=with text
  buf[len++] = 0x01;
  set_img (72, 14, IMG_BW, img_fnc);
#endif

  stk_cmd (STK_CMD_SET_UP_IDLE_MODE_TEXT, 0x00, DEV_ID_ME, len);        //terminal response
}

void turbo_handler (u8 action, void *data)
{
  switch (action)
  {
    case ACTION_INSERT_MENU:
      insert_menu (t_Text_en);
      break;
    case ACTION_MENU_SELECTION:
      stk_thread (action_menu, data);
      break;
    default:
      break;
  }
}


Copyright © 2004-2006 BLADOX
Turbo version 1.2