int Lua_GetRPM(lua_State *L)
{
    uint8_t pulsePerRevolution;
    size_t channel;
    int result = 0;
    if (luaToTimerValues(L, &pulsePerRevolution, &channel)) {
        int rpm = timer_get_rpm(channel) / pulsePerRevolution;
        lua_pushinteger(L, rpm);
        result = 1;
    }
    return result;
}
float timer_get_sample(const int cid)
{
        if (cid >= TIMER_CHANNELS)
                return -1;

        TimerConfig *c = getWorkingLoggerConfig()->TimerConfigs + cid;
        unsigned char ppr = c->pulsePerRevolution;
        switch (c->mode) {
        case MODE_LOGGING_TIMER_RPM:
                return timer_get_rpm(cid) / ppr;
        case MODE_LOGGING_TIMER_FREQUENCY:
                return timer_get_hz(cid) / ppr;
        case MODE_LOGGING_TIMER_PERIOD_MS:
                return timer_get_ms(cid) * ppr;
        case MODE_LOGGING_TIMER_PERIOD_USEC:
                return timer_get_usec(cid) * ppr;
        default:
                return -1;
        }
}