<commit_before>#include <stdio.h>
#include <stdint.h>

typedef uint8_t (*Color_fn)(uint8_t counter);

typedef struct Color_t {
	uint8_t red;
	uint8_t green;
	uint8_t blue;
} Color;

// TODO: Find out a way to do exit conditions
typedef struct State_t {
	uint8_t counter;
	Color_fn red;
	Color_fn green;
	Color_fn blue;
} State;

// Simple color ramp
uint8_t linear(uint8_t counter) {
	return counter;
}

uint8_t zero(uint8_t counter) {
	return 0;
}

// Start on a simple purple and ramp up with counter
State curState = {0, linear, zero, linear};

// TODO: Add exit condition processing
void nextFrame(State *st) {
	st->counter++;
}

Color getColor(State *st) {
	uint8_t red = st->red(st->counter);
	uint8_t green = st->green(st->counter);
	uint8_t blue = st->blue(st->counter);
	Color col = {red, green, blue};
	return col;
}

int main(int arc, char **argv)
{
	printf("Entering main\n");

	int i;
	for(i = 0; i < 10; i++) {
		Color col = getColor(&curState);
		printf("counter: %u\tred: %u\t green: %u\tblue: %u\n", curState.counter, col.red, col.green, col.blue);
		nextFrame(&curState);
	}
<commit_msg>Added exit condition on max frame<commit_after>#include <stdio.h>
#include <stdint.h>

typedef struct Color Color;
typedef struct State State;

typedef uint8_t (*Color_fn)(uint8_t counter);
typedef uint8_t (*Condition)(uint8_t counter, uint8_t parameter);

struct Color {
	uint8_t red, green, blue;
};

// TODO: Find out a way to do exit conditions
struct State {
	uint8_t counter;
	Color_fn red, green, blue;
	uint8_t max;
	State *nextState;
};

// Simple color ramp
uint8_t linear(uint8_t counter) {
	return counter;
}

uint8_t zero(uint8_t counter) {
	return 0;
}

// TODO: Add exit condition processing
void nextFrame(State *st) {
	if(st->counter >= st->max) {
		st->counter = 0;
		st = st->nextState;
	} else {
		st->counter++;
	}
}

Color getColor(State *st) {
	uint8_t red = st->red(st->counter);
	uint8_t green = st->green(st->counter);
	uint8_t blue = st->blue(st->counter);
	Color col = {red, green, blue};
	return col;
}

State idle = {0, linear, zero, zero, 2, &idle};

int main(int arc, char **argv)
{
	printf("Entering main\n");

	State *curState = &idle;

	int i;
	for(i = 0; i < 10; i++) {
		Color col = getColor(curState);
		printf("counter: %u\tred: %u\t green: %u\tblue: %u\n", curState->counter, col.red, col.green, col.blue);
		nextFrame(curState);
	}

{'fraction_non_alphanumeric': 0.14970563498738435, 'fraction_numerical': 0.01682085786375105, 'mean_word_length': 4.171739130434783, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7185460', 'n_tokens_mistral': 951, 'n_tokens_neox': 914, 'n_words': 265}