This past year -- more specifically the past two months -- haven't been kind to Invensense (INVN). The company's stock is down more than 26% year to date, with a huge price drop coming just after the company reported its fiscal Q2 earnings at the end of October.

Source: YCharts.

Let's take a closer look at what caused the recent tumble and whether 2015 will provide any reprieve.

Margins, margins, margins
In fiscal Q2, Invensense reported earnings per share of $0.05, which was short of the $0.16 consensus estimate. Meanwhile, revenue was $90.2 million, just short of the expected $91 million.

But it was the drop from 50% gross margin to 37% sequentially that caused investors to punish the stock. Invensense's management said there were three main things that led to the drop. Let's look at each one individually to find out what's going on.

The company's six-axis sensor. Source: Invensense.

First, the company wrote down about $7.4 million in inventory that "is now excess or obsolete," said Martin Dentinger, Invensense's CFO, on the earnings call. This led directly to an eight-percentage-point drop in margins. Ouch. Invensense was dropping old products they didn't believe would sell -- which should be a one-time thing for the company. "We do not expect most of these adjustments to repeat in Q3," Dentinger added.

That was the first disappointment for Invensense's margins -- and the bad news kept coming. "Second, while unit volumes exceeded our expectations, a great[er] than anticipated contribution of this quarter's revenue came from our largest customers. And these customers generate lower average selling prices."

Invensense sensors are in the new iPhone 6 and 6 Plus. Source: Apple.

He's mainly talking about Samsung and Apple, which are two of Invensense's biggest customers. For example, Invensense's motion sensors are found in the iPhone 6 and 6 Plus, which are selling like gangbusters; but Apple can put pricing pressure on Invensense, forcing the company to sell its technology at cheaper prices to the iMaker than it does to the rest of the market. According to Invensense, this caused a three-percentage-point drop in margins that it expects will continue going forward.

But wait... there's more.

"Finally, our yielded manufacturing cost, especially for our newer products, were higher than we expected and this lowered our gross margin by 2 percentage points in Q2," Dentinger said. The company expects this will happen again in Q3, as well.

Add up those three bits of news, and it's pretty clear why investors were spooked. But what does this mean for the company heading into 2015?

Looking ahead
The good news for Invensense is that the company expects margins to rebound for fiscal Q3 -- up to 46% to 47%. Part of this will come from expanding relationships with current customers, and a bigger push into the wearables market.

For example, Xiaomi -- the third-largest smartphone vendor in the world -- uses Invensense sensors in their smart devices, but can't put the same pricing pressure on Invensense as Apple and Samsung do. Xiaomi's smartphone sales increased 211% in Q3, year over year, and the company is expected to continue growing quickly in the coming years. As Xiaomi grows, Invensense should directly benefit. 

As for wearables, IHS Technology expects sensors in wearables to increase sevenfold between 2013 and 2019. In 2013, wearable tech devices had an average of just 1.4 sensors in them; by 2019, that will climb to 4.1. The growth is a great trend for Invensense, as the company sells a variety of sensors that can be included in new devices.

While 2014 hasn't turned out to be a great year for Invensense's stock, patient investors could still be rewarded. Things might not turn around in the next quarter or two, but there's still too much potential for this company for investors to give up on it just yet. Just be sure to keep an eye on those margins.