Esempio n. 1
0
int menu_button_handler(unsigned char MsgOptions)
{
        char refresh = 0;
	if(menu_current() == app_menu)
	{
		tHostMsg* pOutgoingMsg;
		app_menu = NULL;
		BPL_AllocMessageBuffer(&pOutgoingMsg);
		pOutgoingMsg->Type = IdleUpdate;
		RouteMsg(&pOutgoingMsg);
	}
	else
	{
	
	if(MsgOptions < MENU_ITEMS)
	{
            refresh = menu_handle_button(&(menu_current()->items[MsgOptions]));
	}
	else if(MsgOptions == MENU_BUTTON_EXIT)
	{
		if(istop())
		{
			tHostMsg* pOutgoingMsg;
			/* Only save stuff if it's been changed */
			/* save all of the non-volatile items */
			// FIXME SAVE STUFF!!

			//BPL_AllocMessageBuffer(&pOutgoingMsg);
			//pOutgoingMsg->Type = PariringControlMsg;
			//pOutgoingMsg->Options = PAIRING_CONTROL_OPTION_SAVE_SPP;
			//RouteMsg(&pOutgoingMsg);
			//SaveLinkAlarmEnable();
			//SaveRstNmiConfiguration();
			//SaveIdleBufferInvert();
			//SaveDisplaySeconds();
			//SaveTimeFormat();

			/* go back to the normal idle screen */
			BPL_AllocMessageBuffer(&pOutgoingMsg);
			pOutgoingMsg->Type = IdleUpdate;
			RouteMsg(&pOutgoingMsg);
		}
		else
		{
			menu_pop();
			refresh = 1;
		}
	}
	}
	return refresh;
}
Esempio n. 2
0
void SetupMessageAndAllocateBuffer(tMessage* pMsg, unsigned char Type, unsigned char Options)
{
  pMsg->Length = 0;
  pMsg->Type = Type;
  pMsg->Options = Options;
  pMsg->pBuffer = BPL_AllocMessageBuffer();
}
Esempio n. 3
0
void MenuAppStart(void)//unsigned char *paylxoad)
{
	memset(&MenuApp,0,sizeof(MenuApp));

	/* first item is length
	 * Then next is huffman encoded text
	 */
	unsigned char length = payload[0];
	//printf("length = %i\n", (int)length);
	decode((char*)(payload+1), length, buf);

	int menuindex = 0;
	char *ch = buf;
	while ((ch - buf) < length)
	{
        MenuApp.items[menuindex].type = menu_text_action;
        MenuApp.items[menuindex].flags = MENU_FLAG_UPDATE;
        MenuApp.items[menuindex].ButtonPressType = BUTTON_STATE_IMMEDIATE;
		MenuApp.items[menuindex].u.itext.text = ch;
		MenuApp.items[menuindex].u.itext.action = MenuAppAction;
		MenuApp.items[menuindex].u.itext.id = menuindex;
		menuindex++;
		ch = strchr(ch,' ');
        if(ch==NULL) break;
		*ch = 0;
		//printf("item = %s\n", ch);
		ch++;
	}
	menu_set_app(&MenuApp);
	tHostMsg* pOutgoingMsg;
	BPL_AllocMessageBuffer(&pOutgoingMsg);
	pOutgoingMsg->Type = MenuModeMsg;
	pOutgoingMsg->Options = MENU_MODE_OPTION_APP;
	RouteMsg(&pOutgoingMsg);
}
Esempio n. 4
0
static int IdleUpdateHandler(struct IdleInfo *Info)
{
	/* select between 1 second and 1 minute */
	int IdleUpdateTime;

	StopAllDisplayTimers();

	if (GetDisplaySeconds())
	{
		IdleUpdateTime = ONE_SECOND;
	}
	else
	{
		IdleUpdateTime = ONE_SECOND * 60;
	}

	/* setup a timer to determine when to draw the screen again */
	SetupOneSecondTimer(Info->IdleModeTimerId, IdleUpdateTime, REPEAT_FOREVER,
			IdleUpdate, NO_MSG_OPTIONS);

	StartOneSecondTimer(Info->IdleModeTimerId);

	/* determine if the bottom of the screen should be drawn by the watch */
	if (QueryFirstContact())
	{
        tHostMsg* pOutgoingMsg;
		/*
		 * immediately update the screen
		 */
		if (GetIdleBufferConfiguration() == WATCH_CONTROLS_TOP)
		{
			/* only draw watch part */
			FillMyBuffer(STARTING_ROW, WATCH_DRAWN_IDLE_BUFFER_ROWS, 0x00);
			DrawIdleScreen();
//			PrepareMyBufferForLcd(STARTING_ROW, WATCH_DRAWN_IDLE_BUFFER_ROWS);
			SendMyBufferToLcd(WATCH_DRAWN_IDLE_BUFFER_ROWS);
		}

		/* now update the remainder of the display */
		/*! make a dirty flag for the idle page drawn by the phone
		 * set it whenever watch uses whole screen
		 */
		BPL_AllocMessageBuffer(&pOutgoingMsg);
		pOutgoingMsg->Type = UpdateDisplay;
		pOutgoingMsg->Options = IDLE_MODE | DONT_ACTIVATE_DRAW_BUFFER;
		RouteMsg(&pOutgoingMsg);

		return IDLE_UPDATE_TOP_ONLY;
	}
	FillMyBuffer(STARTING_ROW, NUM_LCD_ROWS, 0x00);
	DrawSimpleIdleScreen();
	DrawConnectionScreen();

	return IDLE_UPDATE_FULL_SCREEN;
}
Esempio n. 5
0
static void MenuAppActionMsg(int item)
{
	tHostMsg* pOutgoingMsg;

	BPL_AllocMessageBuffer(&pOutgoingMsg);
	pOutgoingMsg->pPayload[0] = item;

	UTL_BuildHstMsg(pOutgoingMsg,GeneralPurposePhoneMsg,MENU_MSG_TYPE,
			pOutgoingMsg->pPayload,sizeof(char));

	RouteMsg(&pOutgoingMsg);
}
int IdlePageQrCodeExit(void)
{
	StopOneSecondTimer(timerid);
	DeallocateOneSecondTimer(timerid);
	timerid = -1;

	tHostMsg* pOutgoingMsg;
    /* go back to the normal idle screen */
    BPL_AllocMessageBuffer(&pOutgoingMsg);
    pOutgoingMsg->Type = IdleUpdate;
    RouteMsg(&pOutgoingMsg);
    return 0;
}
Esempio n. 7
0
/*! Handle the messages routed to the background task */
static void BackgroundMessageHandler(tHostMsg* pMsg)
{
  tHostMsg* pOutgoingMsg;

  eMessageType Type = (eMessageType)pMsg->Type;

  switch(Type)
  {
  case GetDeviceType:
    BPL_AllocMessageBuffer(&pOutgoingMsg);

    pOutgoingMsg->pPayload[0] = 2; /* DIGITAL_BOARD_TYPE */

    UTL_BuildHstMsg(pOutgoingMsg, GetDeviceTypeResponse, NO_MSG_OPTIONS,
                    pOutgoingMsg->pPayload, sizeof(unsigned char));

    RouteMsg(&pOutgoingMsg);
    break;

  case SetVibrateMode:
    SetVibrateModeHandler(pMsg);
    break;

  case SetRealTimeClock:
    halRtcSet((tRtcHostMsgPayload*)pMsg->pPayload);

    BPL_AllocMessageBuffer(&pOutgoingMsg);
    pOutgoingMsg->Type = IdleUpdate;
    pOutgoingMsg->Options = NO_MSG_OPTIONS;
    RouteMsg(&pOutgoingMsg);

    break;

  default:
    PrintStringAndHex("<<Unhandled Message>> in Background Task: Type 0x", Type);
    break;
  }

}
Esempio n. 8
0
int menu_handle_button(const struct menu_item *i)
{
	tHostMsg* pOutgoingMsg;
    switch(i->type)
	{
	case menu_msg:
		BPL_AllocMessageBuffer(&pOutgoingMsg);
		pOutgoingMsg->Type = i->u.imsg.msg;
		pOutgoingMsg->Options = i->u.imsg.Options;
		RouteMsg(&pOutgoingMsg);
		break;
	case menu_menu:
		if((i->flags & MENU_ITEM_MENU_PUSH) == MENU_ITEM_MENU_PUSH)
		{
			menu_push(i->u.imenu.menuptr);
		} else if((i->flags & MENU_ITEM_MENU_NEXT) == MENU_ITEM_MENU_NEXT)
		{
			menu_next(i->u.imenu.menuptr);
		}
		break;
	case menu_action:
		if(i->u.iaction.action)
		{
			i->u.iaction.action();
		}
		break;
	case menu_icon_action:
		if(i->u.iiconaction.action)
		{
			i->u.iiconaction.action();
		}
		break;
	case menu_text_action:
		if(i->u.itext.action)
		{
			i->u.itext.action(i->u.itext.id);
		}
	default:
		break;
	}
    if((i->flags & MENU_FLAG_UPDATE) == MENU_FLAG_UPDATE)
	{
		return 1;
	}
        return 0;
}
Esempio n. 9
0
/*! A valid button event has occurred.  Now send a message
 *
 * \param unsigned char ButtonIndex
 * \param unsigned char ButtonPressType
 */
static void HandleButtonEvent(unsigned char ButtonIndex,
                              unsigned char ButtonPressType)
{
  tHostMsg* pButtonEventMsg;
  tButtonConfiguration* pLocalCfg = &(ButtonCfg[QueryDisplayMode()][ButtonIndex]);

  unsigned char DisplayMode = QueryDisplayMode();

  eMessageType Type = (eMessageType)pLocalCfg->CallbackMsgType[ButtonPressType];
  unsigned char Options = pLocalCfg->CallbackMsgOptions[ButtonPressType];

  if ( (pLocalCfg->MaskTable & (1 << ButtonPressType)) == 0 )
  {
    /* if the message type is non-zero then generate a message */
    if ( Type != 0 )
    {
        BPL_AllocMessageBuffer(&pButtonEventMsg);

        /* if this button press is going to the bluetooth then
         * format it properly.
         */
        if ( Type == ButtonEventMsg )
        {
          // Send the index of the button that changed state
          UTL_BuildHstMsg(pButtonEventMsg,
                          Type,
                          Options,
                          &ButtonIndex, sizeof(ButtonIndex));
        }
        else
        {
          /* a button can be configured to send any type of simple message
           * simple == limited payload
           */
          pButtonEventMsg->Type = Type;
          pButtonEventMsg->Options = Options;
        }

        RouteMsg(&pButtonEventMsg);

    }

  }

}