ESP8266 wifi clock

int getLEDpos(int x, int y){ // for a serpentine raster
   int pos;
   if(y & 0x1) { // is y odd
      pos = y * DISPLAY_WIDTH + (DISPLAY_WIDTH -1 - x) ;
   } else { // y is even
      pos = y * DISPLAY_WIDTH + x;
   } 
   return pos;
}

void displayDigit(uint8_t digit, uint8_t xOffset, uint8_t yOffset) {
	for (uint8_t x = 0; x < FONT_WIDTH; x++) {
		for (uint8_t y = 0; y < DISPLAY_HEIGHT; y++) {
			uint8_t on = (NUMBER_FONT[digit][y] & (FONT_MASK >> x)) > 0;
			leds[getLEDpos(x + xOffset, y + yOffset)] = on*CRGB::Lime + CRGB::Black;
		}

Above is a part of my code for my first project. This is my first post here.Apologies if I have not posted as per forum requirements. If yes,then please point it out.I will correct it next time onwards.
This is a ws2812b led clock project where led strips are placed in serpentine manner. After obtaining time from ntp, led positions corresponding to digits are identified by using 'getledpos' as above, and leds displayed on the matrix in hh:mm format as per hexadecimal to binary protocol and 'display digit' function. My query is regarding 'displaydigit' function. instead of 'CRGB::Lime' or any other one color that can be used here, I want the digits to be displayed in random color every 10'',i.e. time is displayed in one color for 10 secs and then changed to another color programmatically. Do I invoke this in the loop function and how? will CHSV help, kindly guide...

No, this is a simple piece of code of your code.

Post a complete code or a reduced complete code that show the problem.

Yes. This is only a part of the code. I haven't posted full code as it is irrelevant to my query. I just require random colors instead of CRGB::lime....Thanks

use random()

If you would have provided a working code - you might have gotten a full working code in return.

Thank you for you replies @ruilviana and @noiasca
Full code posted below:

#define DISPLAY_WIDTH 26
#define DISPLAY_HEIGHT 7
#define NUM_LEDS (DISPLAY_WIDTH*DISPLAY_HEIGHT)

#define DISPLAY_PIN 2

#ifndef CLOCK_DISPLAY
#define CLOCK_DISPLAY

// font from https://github.com/idispatch/raster-fonts/blob/master/font-6x8.c#L598
const uint8_t NUMBER_FONT[][DISPLAY_HEIGHT] = {
	{
		0x38,  /* 001110 */
		0x44,  /* 010001 */
		0x4C,  /* 010011 */
		0x54,  /* 010101 */
		0x64,  /* 011001 */
		0x44,  /* 010001 */
		0x38,  /* 001110 */
	},
	{
		0x10,  /* 000100 */
		0x30,  /* 001100 */
		0x10,  /* 000100 */
		0x10,  /* 000100 */
		0x10,  /* 000100 */
		0x10,  /* 000100 */
		0x10,  /* 000100 */
	},
	{
		0x38,  /* 001110 */
		0x44,  /* 010001 */
		0x04,  /* 000001 */
		0x18,  /* 000110 */
		0x20,  /* 001000 */
		0x40,  /* 010000 */
		0x7C,  /* 011111 */
	},
	{
		0x38,  /* 001110 */
		0x44,  /* 010001 */
		0x04,  /* 000001 */
		0x38,  /* 001110 */
		0x04,  /* 000001 */
		0x44,  /* 010001 */
		0x38,  /* 001110 */
	},
	{
		0x08,  /* 000010 */
		0x18,  /* 000110 */
		0x28,  /* 001010 */
		0x48,  /* 010010 */
		0x7C,  /* 011111 */
		0x08,  /* 000010 */
		0x08,  /* 000010 */
	},
	{
		0x7C,  /* 011111 */
		0x40,  /* 010000 */
		0x40,  /* 010000 */
		0x78,  /* 011110 */
		0x04,  /* 000001 */
		0x44,  /* 010001 */
		0x38,  /* 001110 */
	},
	{
		0x18,  /* 000110 */
		0x20,  /* 001000 */
		0x40,  /* 010000 */
		0x78,  /* 011110 */
		0x44,  /* 010001 */
		0x44,  /* 010001 */
		0x38,  /* 001110 */
	},
	{
		0x7C,  /* 011111 */
		0x04,  /* 000001 */
		0x08,  /* 000010 */
		0x10,  /* 000100 */
		0x20,  /* 001000 */
		0x20,  /* 001000 */
		0x20,  /* 001000 */
	},
	{
		0x38,  /* 001110 */
		0x44,  /* 010001 */
		0x44,  /* 010001 */
		0x38,  /* 001110 */
		0x44,  /* 010001 */
		0x44,  /* 010001 */
		0x38,  /* 001110 */
	},
	{
		0x38,  /* 001110 */
		0x44,  /* 010001 */
		0x44,  /* 010001 */
		0x3C,  /* 001111 */
		0x04,  /* 000001 */
		0x08,  /* 000010 */
		0x30,  /* 001100 */
	}
};

uint8_t COLON[] = {
	0b000,
	0b011,
	0b011,
	0b000,
	0b011,
	0b011,
	0b000
};
#endif

void initDisplay(void);
void displayTime(uint8_t hours, uint8_t minutes, uint8_t seconds);

#include <FastLED.h>
#include <stdint.h>
#include "clock_display.h"

#define FONT_WIDTH 6
#define FONT_MASK 0x80
CRGB leds[NUM_LEDS];

bool stateOn = false;

void initDisplay(void) {
	pinMode(DISPLAY_PIN, OUTPUT);
  delay( 3000 );                            // power-up safety delay
	FastLED.addLeds<WS2812, DISPLAY_PIN, GRB>(leds, NUM_LEDS);
	FastLED.setBrightness(1);
	FastLED.clear();
}

int getLEDpos(int x, int y){ // for a serpentine raster
   int pos;
   if(y & 0x1) { // is y odd
      pos = y * DISPLAY_WIDTH + (DISPLAY_WIDTH -1 - x) ;
   } else { // y is even
      pos = y * DISPLAY_WIDTH + x;
   } 
   return pos;
}

void displayDigit(uint8_t digit, uint8_t xOffset, uint8_t yOffset) {
	for (uint8_t x = 0; x < FONT_WIDTH; x++) {
		for (uint8_t y = 0; y < DISPLAY_HEIGHT; y++) {
			uint8_t on = (NUMBER_FONT[digit][y] & (FONT_MASK >> x)) > 0;
			leds[getLEDpos(x + xOffset, y + yOffset)] = on*CRGB::Lime + CRGB::Black;
		}
	}
}
void loop() {
	if(stateOn)
  {
  leds[65] = CRGB::Red;
  leds[117] = CRGB::Red;
  FastLED.show();
  delay(1000);
  stateOn = false;
  }
  else
  {
  leds[65] = CRGB::Black;
  leds[117] = CRGB::Black;
   FastLED.show();
  delay(1000);
  stateOn = true;
  }
  time(&currentTime);
	// convert UTC UNIX timestamp to timeinfo in local timezone
	localtime_r(&currentTime, &timeinfo);
	displayTime(timeinfo.tm_hour, timeinfo.tm_min, timeinfo.tm_sec);
}

void displayTime(uint8_t hours, uint8_t minutes, uint8_t seconds) {
	FastLED.clear();
	displayDigit(hours/10,0, 0);
	displayDigit(hours%10, FONT_WIDTH, 0);
	displayDigit(minutes/10, FONT_WIDTH*2+2 , 0);
	displayDigit(minutes%10, FONT_WIDTH*3+2 , 0);
	FastLED.show();
}

For picking a random color it most certainly will. If you get a random 24-bit value and apply that to a CRGB color, chances are it will show up as something which is more or less white all the time.

There are plenty of examples where you change something every x amount of time in a non blocking way using millis() and elapsed time calculation

Thanks.. Can you change my code to demonstrate that? Thnx

Why use hex?

const uint8_t NUMBER_FONT[][DISPLAY_HEIGHT] = {
	{
		0b001110,
		0b010001,
		0b010011,
		0b010101,
		0b011001,
		0b010001,
		0b001110
	},

I think you should have a look at the blink with millis() example and do some research and attempts yourself. I am a little lazy today and have more important things to do.

That is a weird answer. Help, but no help...

Nah. Forum members are happy to point people in the right direction, but also appreciate seeing a little effort on your part.

I can help, but i am not here to do the work for you.

Not only that, it actually does take part of my time to do that.

I mean, i am lazy, but that does make 2 of us clearly.

Exactly this. Put in the effort, shows us what you can come up with. (seriously it is not hard to get some code to execute conditionally every 10 seconds.

Same for the random color. Use the HSV color to pick one at random, start with how to assign a color using the FastLED HSV color, and look up how the random function works and incorporate that.

I have other stuff to do.

Wow.. U r not only unhelpful, but also rapping me on my knuckles for being learning.. Is this what this forum is about? Definitely not.. There are cultured people here looking for solving from you experts, and this is what i got.. Superb.. If u r busy, then do not respond.. This query was for free, caring people..

No i am rapping your knuckles for not trying at all and masking your request for a quick solution by pretending to ask for help. Now i am rapping your knuckles for blaming me for your unwillingness to explore the possibilities.
Where is your attempt at coding ? If you post that, everybody can have a look and help you..

Amazing.. I think i will refer this to the Administrator coz i asked for help and I get a rap from a noone who thinks he can call the shots.. Lets see where this goes..

And i will request you to stay away and not post another comment if you are busy and do not want to help.. There are many expert friends here ready to help.. So please stay away

Any idea how you might step through several different colors ?
(Using a counter and an array or switch_case?)

I am looking for the appropriate syntax for my problem.. I have posted the code already

The setup() function in the FastLED RGBCalibrate example shows how you can create colours based on an R, G and B value. E.g. leds[0] = CRGB(255,0,0);

Replace the number by random numbers and you have random colours.

The ColorPalette example has an example how to use HSV with random values. I'll leave it up to you to figure out the difference between HSV and RGB.

I am looking to use exact syntax for random colors instead of CRGB::Lime in this particular line of code..so far haven't made any headway