예제 #1
0
/////////////////////////////////////////////////////////
//
// slideSquares
//
/////////////////////////////////////////////////////////
// Constructor
//
/////////////////////////////////////////////////////////
slideSquares :: slideSquares(t_floatarg width, t_floatarg height)
		   : GemShape(width), m_height(height)
{
    if (m_height == 0.f)
		m_height = 1.f;

    // the height inlet
    m_inletH = inlet_new(this->x_obj, &this->x_obj->ob_pd, &s_float, gensym("Ht"));
    slide_init();
}
예제 #2
0
파일: slide.c 프로젝트: vraoresearch/upm
int main()
{
    if (mraa_init() != MRAA_SUCCESS)
    {
        perror("Failed to initialize mraa\n");
        return -1;
    }

    signal(SIGINT, sig_handler);

    //! [Interesting]

    // Instantiate a slide sensor on analog pin A0
    slide_context sensor = slide_init(0);

    if (!sensor)
    {
        printf("slide_init() failed.\n");
        return -1;
    }

    // Set the aref, scale, and offset
    slide_set_aref(sensor, 5.0);
    slide_set_scale(sensor, 1.0);
    slide_set_offset(sensor, -.1);
    printf("aRef: %0.03f scale: %0.03f offset: %0.03f\n\n",
            slide_get_aref(sensor),
            slide_get_scale(sensor),
            slide_get_offset(sensor));

    // Every half a second, sample the sensor output
    while (shouldRun)
    {
        float normalized = 0.0;
        float raw_volts = 0.0;
        float volts = 0.0;

        slide_get_normalized(sensor, &normalized);
        slide_get_raw_volts(sensor, &raw_volts);
        slide_get_volts(sensor, &volts);

        printf("Normalized output: %0.03f, raw slide sensor output: %0.03f v "
                "adjusted output: %0.03f v\n", normalized, raw_volts, volts);

        upm_delay_ms(500);
    }

    //! [Interesting]

    printf("Exiting\n");

    slide_close(sensor);

    return 0;
}
예제 #3
0
/////////////////////////////////////////////////////////
//
// slideSquares
//
/////////////////////////////////////////////////////////
// Constructor
//
/////////////////////////////////////////////////////////
slideSquares :: slideSquares(t_floatarg width, t_floatarg height)
  : GemShape(width), m_height(height)
{
  if (m_height == 0.f) {
    m_height = 1.f;
  }

  // the height inlet
  m_inletH = inlet_new(this->x_obj, &this->x_obj->ob_pd, &s_float,
                       gensym("Ht"));
  slide_init();

  m_drawTypes.clear();
  m_drawTypes["default"]=GL_DEFAULT_GEM;
  m_drawTypes["point"]=GL_POINTS;
  m_drawTypes["points"]=GL_POINTS;
  m_drawTypes["line"]=GL_LINE_LOOP;
  m_drawTypes["fill"]=GL_QUADS;
}