Ejemplo n.º 1
0
// Lua: realfrequency = setup( idR,idG,idB,frequency)
static int lpwmled_setup( lua_State* L )
{
	s32 freq;	  // signed, to error check for negative values
	int err;

	if((err=checkid(L,&(led.pwmidr),1))!=1) return err;
	if((err=checkid(L,&(led.pwmidg),2))!=1) return err;
	if((err=checkid(L,&(led.pwmidb),3))!=1) return err;
	freq = luaL_checkinteger( L, 4 );
	if ( freq <= 0 )
		return luaL_error( L, "wrong arg range" );
	led.frequency=freq;
	if ( led.frequency > 0 ) led.frequency = platform_pwm_setup( led.pwmidr,led.frequency, 0 );
	if ( led.frequency > 0 ) led.frequency = platform_pwm_setup( led.pwmidg,led.frequency, 0 );
	if ( led.frequency > 0 ) led.frequency = platform_pwm_setup( led.pwmidb,led.frequency, 0 );
	if(led.frequency==0)
		return luaL_error( L, "too many pwms." );
	lua_pushinteger( L, led.frequency );
	platform_pwm_start( led.pwmidr );
	platform_pwm_start( led.pwmidg );
	platform_pwm_start( led.pwmidb );
	led.maxduty_r=1023;
	led.maxduty_g=1023;
	led.maxduty_b=1023;
	return 1;
}
Ejemplo n.º 2
0
// Lua: start( id )
static int ICACHE_FLASH_ATTR lpwm_start( lua_State* L )
{
  unsigned id;
  id = luaL_checkinteger( L, 1 );
  MOD_CHECK_ID( pwm, id );
  platform_pwm_start( id );
  return 0;  
}
Ejemplo n.º 3
0
// Lua: start( id )
static int lpwm_start( lua_State* L )
{
  unsigned id;
  id = luaL_checkinteger( L, 1 );
  MOD_CHECK_ID( pwm, id );
  if (!platform_pwm_start( id )) {
    return luaL_error(L, "Unable to start PWM output");
  }
  return 0;  
}
Ejemplo n.º 4
0
static int lpwm_start(lua_State* L) {
    int id = luaL_checkinteger(L, 1); 

    if (!platform_pwm_exists(L, id)) {
        return luaL_error(L, "pwm%d does not exist", id);
    }
    
    if (!pwm[id - 1].configured) {
        return luaL_error(L, "pwm%d is not setup", id);
    }
    
    platform_pwm_start(L, id);
    
    pwm[id - 1].started = 1;
    
    return 0;
}
Ejemplo n.º 5
0
OSStatus MicoPwmStart( mico_pwm_t pwm )
{
  if ( pwm >= MICO_PWM_NONE )
    return kUnsupportedErr;
  return (OSStatus) platform_pwm_start( &platform_pwm_peripherals[pwm] );
}