
#include <xc.h>
#include <stdint.h>

#define FCY 24000000UL  // 24 MHz external
#include <libpic30.h>

#define NUM_BARS 7
#define BAR_WIDTH 182    // ~1280 / 7 (pixels per line)
#define TOTAL_SCANLINE_CYCLES 64 // 63.5 us approx

// Duty cycle values for 7 grayscale bars (0-1000 = 0%-100%)
uint16_t bar_duty[NUM_BARS] = {
    1000, // White
    890,  // Yellow
    700,  // Cyan
    590,  // Green
    410,  // Magenta
    300,  // Red
    110   // Blue
};

volatile uint16_t bar_index = 0;