Skip to content

dhavalgujar/iot-workshop

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

Examples for Arduino Workshop

  1. Hello World
  2. Blink [What was added in this step?]
  3. Push Button
  4. Push Button with LED [What was added in this step?]
  5. Rainmaker Basic Switch
  6. Rainmaker LED with RGB controls [What was added in this step?]
  7. Rainmaker LED with HSV controls (VA supported) [What was added in this step?]

Get comfortable with abstractions

Get comfortable with abstractions

Not the right way to get comfortable with abstractions ;)

Quick answer

Helper functions:

HSV to RGB
static void convertHSVtoRGB(int h, int s, int v, int *r, int *g, int *b)
{
    h %= 360; // h -> [0,360]
    uint32_t rgb_max = v * 2.55f;
    uint32_t rgb_min = rgb_max * (100 - s) / 100.0f;
    uint32_t i = h / 60;
    uint32_t diff = h % 60;
    // RGB adjustment amount by hue
    uint32_t rgb_adj = (rgb_max - rgb_min) * diff / 60;
    switch (i) {
    case 0:
        *r = rgb_max;
        *g = rgb_min + rgb_adj;
        *b = rgb_min;
        break;
    case 1:
        *r = rgb_max - rgb_adj;
        *g = rgb_max;
        *b = rgb_min;
        break;
    case 2:
        *r = rgb_min;
        *g = rgb_max;
        *b = rgb_min + rgb_adj;
        break;
    case 3:
        *r = rgb_min;
        *g = rgb_max - rgb_adj;
        *b = rgb_max;
        break;
    case 4:
        *r = rgb_min + rgb_adj;
        *g = rgb_min;
        *b = rgb_max;
        break;
    default:
        *r = rgb_max;
        *g = rgb_min;
        *b = rgb_max - rgb_adj;
        break;
    }
}

Comic courtesy of Abtruse Goose

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published