static uint8_t guiStringList_SelectNextItem(guiStringList_t* list, int8_t dir) { uint8_t visibleHead = list->firstIndexToDisplay; uint8_t visibleItemsCount = guiGraph_GetStringListVisibleItemCount(list); uint8_t visibleTail = wrapIndex(list->firstIndexToDisplay, list->stringCount - 1, visibleItemsCount - 1); uint8_t prevSelectedIndex = list->selectedIndex; guiEvent_t event; if ((list->selectedIndex == visibleHead) && (dir < 0)) { if ((list->canWrap) || (list->selectedIndex != 0)) { list->firstIndexToDisplay = wrapIndex(list->firstIndexToDisplay, list->stringCount - 1, dir); list->selectedIndex = wrapIndex(list->selectedIndex, list->stringCount - 1, dir); } } else if ((list->selectedIndex == visibleTail) && (dir > 0)) { if ((list->canWrap) || (list->selectedIndex != list->stringCount - 1)) { list->firstIndexToDisplay = wrapIndex(list->firstIndexToDisplay, list->stringCount - 1, dir); list->selectedIndex = wrapIndex(list->selectedIndex, list->stringCount - 1, dir); } } else { list->selectedIndex = wrapIndex(list->selectedIndex, list->stringCount - 1, dir); } if (prevSelectedIndex != list->selectedIndex) { event.type = STRINGLIST_INDEX_CHANGED; guiCore_CallEventHandler((guiGenericWidget_t *)list, &event ); list->redrawRequired = 1; list->redrawForced = 1; return 1; } else { return 0; } }
CreepGait::FullPlanArray CreepGait::interleaveLegs(LegPlanArray front, LegPlanArray back) { //int steps[16][12]; FullPlanArray plan; // The beat that the leg should start rising int rightRearStart = 0; int rightFrontStart = 4; int leftRearStart = 8; int leftFrontStart = 12; for(int i=0;i<16;i++) { plan.steps[wrapIndex(i+rightRearStart)][BACK_RIGHT_COXA] = back.steps[i][0]; plan.steps[wrapIndex(i+rightRearStart)][BACK_RIGHT_FEMUR] = back.steps[i][1]; plan.steps[wrapIndex(i+rightRearStart)][BACK_RIGHT_TIBIA] = back.steps[i][2]; plan.steps[wrapIndex(i+rightFrontStart)][FRONT_RIGHT_COXA] = front.steps[i][0]; plan.steps[wrapIndex(i+rightFrontStart)][FRONT_RIGHT_FEMUR] = front.steps[i][1]; plan.steps[wrapIndex(i+rightFrontStart)][FRONT_RIGHT_TIBIA] = front.steps[i][2]; plan.steps[wrapIndex(i+leftRearStart)][BACK_LEFT_COXA] = back.steps[i][0]; plan.steps[wrapIndex(i+leftRearStart)][BACK_LEFT_FEMUR] = back.steps[i][1]; plan.steps[wrapIndex(i+leftRearStart)][BACK_LEFT_TIBIA] = back.steps[i][2]; plan.steps[wrapIndex(i+leftFrontStart)][FRONT_LEFT_COXA] = front.steps[i][0]; plan.steps[wrapIndex(i+leftFrontStart)][FRONT_LEFT_FEMUR] = front.steps[i][1]; plan.steps[wrapIndex(i+leftFrontStart)][FRONT_LEFT_TIBIA] = front.steps[i][2]; } return plan; }
inline void previous() { --index; wrapIndex(); }
inline void next() { ++index; wrapIndex(); }