b. CameraLED()

<< Click to Display Table of Contents >>

Navigation:  Tutorials > Tutorial 16 - CleO Camera >

b. CameraLED()

This section shows how to use the CameraLED() command to control the brightness of the camera LED.

 

 

Command Prototype

 

int16_t  CameraLED(brightness);

 

Parameters

Description

brightness

0 to 255. 0 indicates turn off and 255 indicates maximum brightness

 

 

Code

 

 

void loop() {

  drawGui();

  control();

}

 

void drawGui(void) {

  /* Start building a screen frame */

  CleO.Start();

 

  /* Draw a slider on the screen to change the LED brigtness*/

  CleO.Tag(PROGRESS_TAG);

  CleO.StringExt(FONT_MEDIUM, OFFSET + 10, 100, WHITE, ML, 0, 0, "Dim brightness");

  CleO.eve_slider(OFFSET + 20, 150, PROGRESS_WIDTH, 20, 0, percent, 255);

 

  CleO.StringExt(FONT_MEDIUM, OFFSET +  10, 300, WHITE, ML, 0, 0, "Set On/Off");

  double button_width =  0.42 * WIDTH;

  double button_height = (0.08 * 480);

   

  /* Draw a button to turn on 100% LED brightness*/

  CleO.Tag(TURN_ON_TAG);

  CleO.RectangleExt(OFFSET + WIDTH/2 - button_width/2 - 5, 380,

                    button_width, button_height, WHITE, MM, 0, 0);

                    

  CleO.StringExt(FONT_SANS_2, OFFSET + (0.30 * WIDTH),

                 380, BLACK, MM, 0, 0, "Light On");

        

  /* Draw a button to turn of LED*/

  CleO.Tag(TURN_OFF_TAG);

  CleO.RectangleExt(OFFSET + WIDTH/2 + button_width/2 + 5, 380,

                    button_width, button_height, WHITE, MM, 0, 0);                  

  CleO.StringExt(FONT_SANS_2, OFFSET + (0.70 * WIDTH),

                 380, BLACK, MM, 0, 0, "Light Off");  

   

  /* Display completed screen frame */

  CleO.Show();

}

 

void control(void) {

  int16_t x, y, dur, tag;

 

  CleO.TouchCoordinates(x, y, dur, tag);

  

  if(dur)

  {

    if(tag == TURN_ON_TAG)

    {

      percent = 255;

    }

    else if(tag == TURN_OFF_TAG)

    {

      percent = 0;

    }

    else if(tag == PROGRESS_TAG)

    {

      if(x < OFFSET + 20) x = OFFSET + 20;

      if(x > OFFSET + PROGRESS_WIDTH) x = OFFSET + PROGRESS_WIDTH;      

      percent = map(x, OFFSET + 20, OFFSET + PROGRESS_WIDTH, 0, 255);

    }

  /* Set the brightness level to the LED*/  

  CleO.CameraLEDS(percent);

  }

  

}

 

 

Description

 

The above setup routine builds a screen frame and draws a slider on the screen to change the LED brightness. Button controls to turn on/off LED controls are drawn using the Cleo.Tag() commands.

 

 

Output

 

Here is the output displayed upon executing the above code snippet -

 

CameraLED