Exemplo n.º 1
0
void cOsdMenu::PageUp(void)
{
  int oldCurrent = current;
  int oldFirst = first;
  current -= displayMenuItems;
  first -= displayMenuItems;
  int last = Count() - 1;
  if (current < 0)
     current = 0;
  if (first < 0)
     first = 0;
  int tmpCurrent = current;
  while (!SelectableItem(tmpCurrent) && --tmpCurrent >= 0)
        ;
  if (tmpCurrent < 0) {
     tmpCurrent = current;
     while (++tmpCurrent <= last && !SelectableItem(tmpCurrent))
           ;
     }
  current = tmpCurrent <= last ? tmpCurrent : -1;
  if (current >= 0) {
     if (current < first)
        first = current;
     else if (current - first >= displayMenuItems)
        first = current - displayMenuItems + 1;
     }
  if (current != oldCurrent || first != oldFirst) {
     Display();
     DisplayCurrent(true);
     }
  else if (Setup.MenuScrollWrap)
     CursorUp();
}
Exemplo n.º 2
0
void cOsdMenu::PageDown(void)
{
  int oldCurrent = current;
  int oldFirst = first;
  current += displayMenuItems;
  first += displayMenuItems;
  int last = Count() - 1;
  if (current > last)
     current = last;
  if (first + displayMenuItems > last)
     first = max(0, last - displayMenuItems + 1);
  int tmpCurrent = current;
  while (!SelectableItem(tmpCurrent) && ++tmpCurrent <= last)
        ;
  if (tmpCurrent > last) {
     tmpCurrent = current;
     while (--tmpCurrent >= 0 && !SelectableItem(tmpCurrent))
           ;
     }
  current = tmpCurrent > 0 ? tmpCurrent : -1;
  if (current >= 0) {
     if (current < first)
        first = current;
     else if (current - first >= displayMenuItems)
        first = current - displayMenuItems + 1;
     }
  if (current != oldCurrent || first != oldFirst) {
     Display();
     DisplayCurrent(true);
     }
  else if (Setup.MenuScrollWrap)
     CursorDown();
}
Exemplo n.º 3
0
eOSState cOsdMenu::ProcessKey(eKeys Key)
{
    if (subMenu) {
        eOSState state = subMenu->ProcessKey(Key);
        if (state == osBack)
            return CloseSubMenu();
        return state;
    }

    cOsdItem *item = Get(current);
    if (marked < 0 && item) {
        eOSState state = item->ProcessKey(Key);
        if (state != osUnknown) {
            DisplayCurrent(true);
            return state;
        }
    }
    switch (int(Key)) {
    case k0:
        return osUnknown;
    case k1...k9:
        return hasHotkeys ? HotKey(Key) : osUnknown;
    case kUp|k_Repeat:
    case kUp:
        CursorUp();
        break;
    case kDown|k_Repeat:
    case kDown:
        CursorDown();
        break;
    case kLeft|k_Repeat:
    case kLeft:
        PageUp();
        break;
    case kRight|k_Repeat:
    case kRight:
        PageDown();
        break;
    case kBack:
        return osBack;
    case kOk:
        if (marked >= 0) {
            SetStatus(NULL);
            if (marked != current)
                Move(marked, current);
            marked = -1;
            break;
        }
    // else run into default
    default:
        if (marked < 0)
            return osUnknown;
    }
    return osContinue;
}
Exemplo n.º 4
0
void cOsdMenu::CursorDown(void)
{
  displayMenuItems = displayMenu->MaxItems();
  int tmpCurrent = current;
  int lastOnScreen = first + displayMenuItems - 1;
  int last = Count() - 1;
  if (last < 0)
     return;
  while (++tmpCurrent != current) {
        if (tmpCurrent > last) {
           if (first < last - displayMenuItems) {
              // make non-selectable items at the end visible:
              first = last - displayMenuItems + 1;
              Display();
              return;
              }
           if (Setup.MenuScrollWrap)
              tmpCurrent = -1;
           else
              return;
           }
        else if (SelectableItem(tmpCurrent))
           break;
        }
  if (first <= tmpCurrent && tmpCurrent <= lastOnScreen)
     DisplayCurrent(false);
  current = tmpCurrent;
  if (current > lastOnScreen) {
     first = Setup.MenuScrollPage ? current : max(0, current - displayMenuItems + 1);
     if (first + displayMenuItems > last)
        first = max(0, last - displayMenuItems + 1);
     Display();
     }
  else if (current < first) {
     first = current;
     Display();
     }
  else
     DisplayCurrent(true);
}
Exemplo n.º 5
0
void cOsdMenu::CursorUp(void)
{
  int tmpCurrent = current;
  int lastOnScreen = first + displayMenuItems - 1;
  int last = Count() - 1;
  if (last < 0)
     return;
  while (--tmpCurrent != current) {
        if (tmpCurrent < 0) {
           if (first > 0) {
              // make non-selectable items at the beginning visible:
              first = 0;
              Display();
              return;
              }
           if (Setup.MenuScrollWrap)
              tmpCurrent = last + 1;
           else
              return;
           }
        else if (SelectableItem(tmpCurrent))
           break;
        }
  if (first <= tmpCurrent && tmpCurrent <= lastOnScreen)
     DisplayCurrent(false);
  current = tmpCurrent;
  if (current < first) {
     first = Setup.MenuScrollPage ? max(0, current - displayMenuItems + 1) : current;
     Display();
     }
  else if (current > lastOnScreen) {
     first = max(0, current - displayMenuItems + 1);
     Display();
     }
  else
     DisplayCurrent(true);
}
Exemplo n.º 6
0
eOSState cMenuEpgTimers::OnOff(void)
{
  if (HasSubMenu())
     return osContinue;
  cTimer *timer = CurrentTimer();
  if (timer) {
     timer->OnOff();
     timer->SetEventFromSchedule();
     RefreshCurrent();
     DisplayCurrent(true);
     if (timer->FirstDay())
        isyslog("timer %s first day set to %s", *timer->ToDescr(), *timer->PrintFirstDay());
     else
        isyslog("timer %s %sactivated", *timer->ToDescr(), timer->HasFlags(tfActive) ? "" : "de");
     Timers.SetModified();
     //update helpkeys
     helpKeys = -1;
     }
  return osContinue;
}
Exemplo n.º 7
0
eOSState cOsdMenu::HotKey(eKeys Key)
{
#ifdef USE_LIEMIEXT
  bool match = false;
  bool highlight = false;
  int  item_nr;
  int  i;

  if (Key == kNone) {
     if (lastActivity.TimedOut())
        Key = kOk;
     else
        return osContinue;
     }
  else {
     lastActivity.Set(MENUKEY_TIMEOUT);
     }
  for (cOsdItem *item = Last(); item; item = Prev(item)) {
#else
  for (cOsdItem *item = First(); item; item = Next(item)) {
#endif /* LIEMIEXT */
      const char *s = item->Text();
#ifdef USE_LIEMIEXT
      i = 0;
      item_nr = 0;
      if (s && (s = skipspace(s)) != '\0' && '0' <= s[i] && s[i] <= '9') {
         do {
            item_nr = item_nr * 10 + (s[i] - '0');
            }
         while ( !((s[++i] == '\t')||(s[i] == ' ')) && (s[i] != '\0') && ('0' <= s[i]) && (s[i] <= '9'));
         if ((Key == kOk) && (item_nr == key_nr)) {
#else
      if (s && (s = skipspace(s)) != NULL) {
         if (*s == Key - k1 + '1') {
#endif /* LIEMIEXT */
            current = item->Index();
            RefreshCurrent();
            Display();
            cRemote::Put(kOk, true);
#ifdef USE_LIEMIEXT
            key_nr = -1;
#endif /* LIEMIEXT */
            break;
            }
#ifdef USE_LIEMIEXT
         else if (Key != kOk) {
            if (!highlight && (item_nr == (Key - k0))) {
               highlight = true;
               current = item->Index();
               }
            if (!match && (key_nr == -1) && ((item_nr / 10) == (Key - k0))) {
               match = true;
               key_nr = (Key - k0);
               }
            else if (((key_nr == -1) && (item_nr == (Key - k0))) || (!match && (key_nr >= 0) && (item_nr == (10 * key_nr + Key - k0)))) {
               current = item->Index();
               cRemote::Put(kOk, true);
               key_nr = -1;
               break;
               }
            }
#endif /* LIEMIEXT */
         }
      }
#ifdef USE_LIEMIEXT
  if ((!match) && (Key != kNone)) {
     key_nr = -1;
     }
#endif /* LIEMIEXT */
#if REELVDR
  // RC: returning osContinue prevents the main menu and prob. others from automatic closing. side effects?
  //DDD("return osUnknown");
  return osUnknown;
#else
  return osContinue;
#endif
}

eOSState cOsdMenu::AddSubMenu(cOsdMenu *SubMenu)
{
  delete subMenu;
  subMenu = SubMenu;
#if REELVDR
  /* close any preview/pip channels when adding a submenu, since it does
     not belong to the submenu*/
  if(cReelBoxBase::Instance()) {
      cReelBoxBase::Instance()->StartPip(false);
      printf("\033[0;92mStop pip\033[0m\n");
  }

  // Clear ID3 tags and cover-art/thumbnails that are stored in skinreel3's
  // global variables,
  // new osd should set the necessary thumbnails and id3 infos itself.
#if 0 // thumbnails in install wizard were not shown!
  cPlugin *skinPlugin = cPluginManager::GetPlugin("skinreel3");
  if (skinPlugin) {
      skinPlugin->Service("setThumb", NULL);
      skinPlugin->Service("setId3Infos", NULL);
  }
#endif
#endif
  subMenu->Display();
  return osContinue; // convenience return value
}

eOSState cOsdMenu::CloseSubMenu()
{
  delete subMenu;
  subMenu = NULL;
  RefreshCurrent();
  Display();
  return osContinue; // convenience return value
}

#ifdef REELVDR
//#define SEPARATORS ":-\0"
#define SEPARATORS ":-"
///< take menu-title substrings befor one of this chars

eOSState cOsdMenu::DisplayHelpMenu(const char *Title)
{
  char title[128];
  // if we get Menu at first we assume Main Menu
  if (strstr(Title,tr("Main Menu")) == Title)
  {
     strncpy(title,tr("Main Menu"),128);
  }
  else
  {
     const char *sep =  SEPARATORS;
     while (*sep != '\0')
     {
        //printf (" \t\t --- sep %c   \n", *sep);
        char *s = NULL;
        strncpy(title,Title,128);
        title[127] = '\0';

        s = strchr(title,*sep);
        if (s)
        {
           *s = '\0';
           //break;
        }
     sep++;
     }
  }
  //cHelpSection *hs = HelpMenus.GetSectionByTitle(title);
  //return AddSubMenu(new cMenuHelp(hs, title));
}
#endif /* REELVDR */

eOSState cOsdMenu::ProcessKey(eKeys Key)
{
  if (subMenu) {
     eOSState state = subMenu->ProcessKey(Key);
     if (state == osBack)
        return CloseSubMenu();
     return state;
     }

  cOsdItem *item = Get(current);
  if (marked < 0 && item) {
     eOSState state = item->ProcessKey(Key);
     if (state != osUnknown) {
        DisplayCurrent(true);
        return state;
        }
     }
  switch (int(Key)) {
#ifdef USE_LIEMIEXT
    case kNone:
    case k0...k9: return hasHotkeys ? HotKey(Key) : osUnknown;
#else
    case k0:      return osUnknown;
    case k1...k9: return hasHotkeys ? HotKey(Key) : osUnknown;
#endif /* LIEMIEXT */
    case kUp|k_Repeat:
    case kUp:   CursorUp();   break;
    case kDown|k_Repeat:
    case kDown: CursorDown(); break;
    case kLeft|k_Repeat:
    case kLeft: PageUp(); break;
    case kRight|k_Repeat:
    case kRight: PageDown(); break;
    case kBack: return osBack;
#ifdef REELVDR
    case kInfo: return DisplayHelpMenu(title);
#endif /* REELVDR */
    case kOk:   if (marked >= 0) {
                   SetStatus(NULL);
                   if (marked != current)
                      Move(marked, current);
                   marked = -1;
                   break;
                   }
                // else run into default
    default: if (marked < 0)
                return osUnknown;
    }
  return osContinue;
}
Exemplo n.º 8
0
eOSState cReplayList::ProcessColourKeys(eKeys Key) {
        eOSState state = osUnknown;
        
	if (Key==kRed) { 
		Mode=(eMode) ( ( Mode + 1 ) % eMLast );
		return osContinue;
	};
	
	switch (lastMode) {
		case eMNormal:
			switch(Key) {
				case kGreen:
					// Skip backward, pass to cControl
					state= osUnknown;
					break;
				case kYellow:
					// Skip forward, pass to cControl
					state= osUnknown;
					break;
				case kBlue:
                                        // end replay
					state= osEnd;
					break;
                                default:
                                        break;
			};
			break;
		case eMEdit:
			switch(Key) {
				case kGreen:
					// add files TODO
					state= osContinue;
					break;
				case kYellow:
					// delete Item
					MENUDEB("Del current %d: %s\n",
                                                 Current(),
                                                 playList->GetItemByIndex(Current())->GetName() );
					playList->RemoveItem(
					  playList->GetItemByIndex(Current()));
					MENUDEB("Remove finished\n");
					Del(Current());
					Display();
					state=osContinue;
					break;
				case kBlue:
                                        // move files TODO
                                        hold=true;
                                        origPos=Current();
                                        SetItemStr(Get(Current()),
                                               playList->GetItemByIndex(Current()),
                                               hold);
                                        DisplayCurrent(true);
					state= osContinue;
					break;
                                default:
                                        break;
			};
			break;
		case eMOptions:
			switch(Key) {
				case kGreen:
					// call options menu
                                        state = AddSubMenu(
                                                new cPlOptionsMenu(playList));

					break;
				case kYellow:
					// nothing
					state= osContinue;
					break;
				case kBlue:
                                        // save list TODO
					state= osContinue;
					Softplay->SaveList(playList);
					break;
                                default:
                                        break;
			};
			break;
                default:
                        break;
	};
        return state;
};
Exemplo n.º 9
0
eOSState cReplayList::ProcessKey(eKeys Key) {
        int lastCurrent=Current();
        eOSState state = cOsdMenu::ProcessKey(Key);


        // fallback to default mode after some time of inactivity
        if ( Key!=kNone) 
                lastModeActivity=time(NULL);
       
        if ( lastMode !=eMNormal && 
                        time(NULL) - lastModeActivity > 40 ) {
                if (hold) {
                        // break move
                        hold=false;
                        SetItemStr(Get(Current()),
                                        playList->GetItemByIndex(Current()),
                                        hold);
                        Move(Current(),origPos);
                        playList->GetShuffleIdx()->Move(Current(),
                                        origPos);
                        SetCurrent(Get(origPos));
                        Display();
                };
               Mode=eMNormal;
        };
 
        // don't move cursor when it has been moved by the user
	// a short while ago or in move item mode
        if ( Key==kUp || Key==kDown || Key==kRight || Key==kLeft ) 
                lastActivity=time(NULL);

        if (Current() != playList->GetCurrIdx() && 
                        time(NULL) - lastActivity > 40
                        && !hold ) {
                MENUDEB("SetCurrent current title %d  time %d lastActivity %d\n",
                                playList->GetCurrIdx(),int(time(NULL)),int(lastActivity));
                SetCurrent(Get(playList->GetCurrIdx()));
                Display();
        };
       
        // handle move item mode
        if ( lastMode == eMEdit && hold ) {
                // moves
                if ( (Key==kUp || Key==kDown|| Key==kRight || Key==kLeft) ) {
                        Move(lastCurrent,Current());
                        playList->GetShuffleIdx()->Move(lastCurrent,Current()); 
                        Display();
                };
               
                // end move
                switch(Key) {
                        case kBack:
                        case kRed:
                        case kGreen:
                        case kYellow:
                                // break Move
                                hold=false;
                                SetItemStr(Get(Current()),
                                                playList->GetItemByIndex(Current()),
                                                hold);
                                Move(Current(),origPos);
                                playList->GetShuffleIdx()->Move(Current(),
                                                origPos);
                                SetCurrent(Get(origPos));
                                Display();

                                Key=kNone;
                                state= osContinue;
                                break;
                        case kOk:
                        case kBlue:
                                // finish move
                                hold=false;
                                SetItemStr(Get(Current()),
                                                playList->GetItemByIndex(Current()),
                                                hold);

                                DisplayCurrent(true);
                                state= osContinue;
                                break;
                        default:
                                break;
                } 
        
        };

        // handle new items or removed items
        if ( lastListItemCount != playList->GetNIdx()
	     || playList->IsDirty() ) {
                Clear();
                RebuildList();
                Display();
        };
        

	if (state != osUnknown ) 
		return state;


	switch (Key) {
		case kOk:
			// skip to current track
			playList->SetCurrIdx( Current() );
			state = PLAY_CURR_FILE;
			// want to have automatic track change
			lastActivity=time(NULL)-300;
			break;
		case kBack:
			state= osBack;
			break;
		default:    
			break;
	};

        if ( Key >= kRed && Key <= kBlue)
                state=ProcessColourKeys(Key);
        
        if (!HasSubMenu())
                UpdateStatus();
        
        if ( Mode != lastMode ) 
		UpdateHelp();

        return state;
}
Exemplo n.º 10
0
//*****************************************************************************
//
// The main loop for the user interface.
//
//*****************************************************************************
int
main(void)
{
    unsigned long ulPanel;

    //
    // If running on Rev A2 silicon, turn the LDO voltage up to 2.75V.  This is
    // a workaround to allow the PLL to operate reliably.
    //
    if(REVISION_IS_A2)
    {
        SysCtlLDOSet(SYSCTL_LDO_2_75V);
    }

    //
    // Set the clocking to run at 50MHz from the PLL.
    //
    SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN |
                   SYSCTL_XTAL_8MHZ);

    //
    // Set the priority of the interrupts.
    //
    IntPrioritySet(INT_CAN0, 0x00);
    IntPrioritySet(FAULT_SYSTICK, 0x20);

    //
    // Configure SysTick to generate an interrupt every millisecond.
    //
    SysTickPeriodSet(SysCtlClockGet() / 1000);
    SysTickIntEnable();
    SysTickEnable();

    //
    // Initialize the push button driver.
    //
    ButtonsInit();

    //
    // Initialize the CAN communication channel.
    //
    CANCommInit();

    //
    // Initialize the UART used to perform a "firmware update".
    //
    UpdateUARTInit();

    //
    // Initialize the display.
    //
    RIT128x96x4Init(3500000);

    //
    // Add the screen-clearing widget to the widget tree.  As the first widget
    // in the tree, this will always be drawn first, resulting in a blank
    // screen before anything else is drawn.
    //
    WidgetAdd(WIDGET_ROOT, (tWidget *)&g_sBackground);

    //
    // Display the splash screen.
    //
    DisplaySplash();

    //
    // Set the CAN device ID to one.
    //
    CANSetID(1);

    //
    // The "Voltage Control Mode" panel should be displayed first.
    //
    ulPanel = PANEL_VOLTAGE;

    //
    // Loop forever.
    //
    while(1)
    {
        //
        // Determine which panel to display.
        //
        switch(ulPanel)
        {
            //
            // The "Voltage Control Mode" panel should be displayed.
            //
            case PANEL_VOLTAGE:
            {
                ulPanel = DisplayVoltage();
                break;
            }

            //
            // The "VComp Control Mode" panel should be displayed.
            //
            case PANEL_VCOMP:
            {
                ulPanel = DisplayVComp();
                break;
            }

            //
            // The "Current Control Mode" panel should be displayed.
            //
            case PANEL_CURRENT:
            {
                ulPanel = DisplayCurrent();
                break;
            }

            //
            // The "Speed Control Mode" panel should be displayed.
            //
            case PANEL_SPEED:
            {
                ulPanel = DisplaySpeed();
                break;
            }

            //
            // The "Position Control Mode" panel should be displayed.
            //
            case PANEL_POSITION:
            {
                ulPanel = DisplayPosition();
                break;
            }

            //
            // The "Configuration" panel should be displayed.
            //
            case PANEL_CONFIGURATION:
            {
                ulPanel = DisplayConfig();
                break;
            }

            //
            // The "Device List" panel should be displayed.
            //
            case PANEL_DEV_LIST:
            {
                ulPanel = DisplayDevList();
                break;
            }

            //
            // The "Firmware Update" panel should be displayed.
            //
            case PANEL_UPDATE:
            {
                ulPanel = DisplayUpdate();
                break;
            }

            //
            // The "Help" panel should be displayed.
            //
            case PANEL_HELP:
            {
                ulPanel = DisplayHelp();
                break;
            }

            //
            // The "About" panel should be displayed.
            //
            case PANEL_ABOUT:
            {
                ulPanel = DisplayAbout();
                break;
            }
        }
    }
}