Created
February 26, 2018 19:10
-
-
Save karanjamutahi/6989b2a736ee40d6b61aaa0138e2fa72 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void app_main() | |
{ | |
//Config'd channels properly | |
struct colors_t | |
{ | |
int red; | |
int green; | |
int blue; | |
} blue, red, green, magenta, purple, yellow, aqua,white; | |
struct colors_t blue = {0,0,1023}; | |
struct colors_t red = {1023,0,0}; | |
struct colors_t green = {0, 1023, 0}; | |
struct colors_t magenta = {1023,0,1023}; | |
struct colors_t purple = {320,0,320}; | |
struct colors_t white = {1023,1023,1023}; | |
struct colors_t aqua = {0, 1023,1023}; | |
struct colors_t yellow = {1023,1023,0}; | |
void changeColor(struct colors_t *colorVals) | |
{ | |
int redVal = colorVals->red; | |
int greenVal = colorVals->green; | |
int blueVal = colorVals->blue; | |
for(int a =0;a<LEDC_TEST_CH_NUM;a++) | |
{ | |
if(a==0) | |
{ | |
ledc_set_duty(ledc_channel[a].speed_mode, ledc_channel[a].channel,redVal); | |
ledc_update_duty(ledc_channel[a].speed_mode, ledc_channel[a].channel); | |
} | |
else if(a == 1) | |
{ | |
ledc_set_duty(ledc_channel[a].speed_mode, ledc_channel[a].channel,greenVal); | |
ledc_update_duty(ledc_channel[a].speed_mode, ledc_channel[a].channel); | |
} | |
else | |
{ | |
ledc_set_duty(ledc_channel[a].speed_mode, ledc_channel[a].channel,blueVal); | |
ledc_update_duty(ledc_channel[a].speed_mode, ledc_channel[a].channel); | |
} | |
} | |
printf("Changed Color \n"); | |
} | |
while(1) | |
{ | |
printf("\n---------------------------------\n\n"); | |
changeColor(&red); | |
vTaskDelay(1000/portTICK_PERIOD_MS); | |
changeColor(&blue); | |
vTaskDelay(1000/portTICK_PERIOD_MS); | |
changeColor(&purple); | |
vTaskDelay(1000/portTICK_PERIOD_MS); | |
changeColor(&yellow); | |
vTaskDelay(1000/portTICK_PERIOD_MS); | |
changeColor(&white); | |
vTaskDelay(1000/portTICK_PERIOD_MS); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment