Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 4f5b1bf438
Fetching contributors…

Cannot retrieve contributors at this time

file 39 lines (30 sloc) 0.846 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
#include "menu.h"

bool Menu::OnInitialState()
{
    menuItems[itemSelected].screenItem->Highlight(true);
    Screen::Set(screenId);
    return true;
};

bool Menu::OnEncoderChanged(int8_t value)
{
      menuItems[itemSelected].screenItem->Highlight(false);
      
      int8_t new_val = (int8_t)itemSelected + value;
      
      if (new_val < 0)
          itemSelected = 0;
      else if (new_val >= numItems)
          itemSelected = numItems - 1;
      else
          itemSelected = (uint8_t)new_val;
          
      menuItems[itemSelected].screenItem->Highlight(true);

      return true;
};

bool Menu::OnEncButtonDown()
{
      if (menuItems[itemSelected].ptrFunction)
          (menuItems[itemSelected].ptrFunction)();
};

bool Menu::OnExtButtonDown()
{
      if (returnState)
          StateMachine::SetState(returnState);
};

Something went wrong with that request. Please try again.