Better illumination ...

master
kaqu 2 years ago
parent f7d4b31e26
commit 98e3d968d7
  1. 128
      firmware/main.c

@ -68,10 +68,97 @@ static void boot_sequence(void)
}
}
int main(int i, char **c)
//------------------- Illumination demo --------------------------------
extern void busy_wait(unsigned int ms);
#define MAXLEDS 27 // MUST match h/w!
static int32_t arLEDBuffer[MAXLEDS]; // GRB values
void enable_LEDS(int iEnable)
{
npe_b8Len_write(MAXLEDS); // Prepare length
npe_bEnable_write(iEnable?1:0); // Enable/disable
}
void send_LEDs()
{
for(int i=0;i<MAXLEDS;i++) {
npe_b8LoadOffset_write(i); // @Offset
npe_b24Data2Load_write(arLEDBuffer[i]); // store 32(24) bit value
}
busy_wait(25); // Minimum that meets the eye ;)
}
void clear_LEDs()
{
for(int i=0;i<MAXLEDS;i++)
arLEDBuffer[i] = 0;
send_LEDs();
}
void load_triple_LEDs(int32_t green, int32_t red, int32_t blue)
{
for(int i=0;i<MAXLEDS;i+=3) {
arLEDBuffer[i] = green;
arLEDBuffer[i+1] = red;
arLEDBuffer[i+2] = blue;
}
send_LEDs();
}
void illumination()
{
extern void busy_wait(unsigned int ms);
int32_t green = 0x040000;
int32_t red = 0x000400;
int32_t blue = 0x000004;
// Prepare first output
load_triple_LEDs(green, red, blue); // 1st load
enable_LEDS(1);
busy_wait(1000);
// Let them flicker ...
for(int i=0;i<MAXLEDS;i++) {
int32_t temp = green;
green = red;
red = blue;
blue = temp;
load_triple_LEDs(green,red,blue);
busy_wait(80); // Slow down a bit
}
// Make 3 run along ...
clear_LEDs(); // Mainly to reset buffer
green = 0x400000;
red = 0x004000;
blue = 0x000040;
arLEDBuffer[0] = green;
arLEDBuffer[1] = red;
arLEDBuffer[2] = blue;
int max_LED = MAXLEDS-1; // 0..26
for(int i=0;i<MAXLEDS-3;i++) { // Forward shift 3
send_LEDs();
busy_wait(100);
for(int j=0;j<max_LED;j++)
arLEDBuffer[max_LED - j] = arLEDBuffer[(max_LED - 1) - j];
arLEDBuffer[i] = 0;
}
for(int i=0;i<MAXLEDS-1;i++) { // Backward shift 3
send_LEDs();
busy_wait(100);
for(int j=0;j<max_LED;j++)
arLEDBuffer[j] = arLEDBuffer[j+1];
arLEDBuffer[max_LED-i] = 0;
}
busy_wait(400);
// Prepare final output
load_triple_LEDs(0x010000, 0x000100, 0x000001); // 1st load
busy_wait(500);
enable_LEDS(0);
}
//------------------- End of illumination demo --------------------------
int main(int i, char **c)
{
char buffer[CMD_LINE_BUFFER_SIZE];
char *params[MAX_PARAM];
char *command;
@ -79,42 +166,7 @@ int main(int i, char **c)
int nb_params;
int sdr_ok;
// This is the new illumination logic ------------------
int32_t green = 0x010000;
int32_t red = 0x000100;
int32_t blue = 0x000001;
for(int j=0;j<8;j++) {
for(int i=0;i<27;i+=3) {
npe_b8LoadOffset_write(i); // @Offset
npe_b24Data2Load_write(green); // G
npe_b8LoadOffset_write(i+1); // @Offset
npe_b24Data2Load_write(red); // R
npe_b8LoadOffset_write(i+2); // @Offset
npe_b24Data2Load_write(blue); // B
}
if(!j) { // Only on init. ...
npe_b8Len_write(27); // Length
npe_bEnable_write(1); // Enable!
}
busy_wait(200); // 100ms or so ... ;)
green <<= 1, red <<= 1, blue <<=1; // Increase intensity
if((green & 0xff0000) == 0) // High bit gone missing?
green = 1, red = 1, blue = 1; // Yap, reload!
}
busy_wait(400);
for(int i=0;i<27;i+=3)
{ //
npe_b8LoadOffset_write(i); // @Offset
npe_b24Data2Load_write(0x040000); // G
npe_b8LoadOffset_write(i+1); // @Offset
npe_b24Data2Load_write(0x000400); // R
npe_b8LoadOffset_write(i+2); // @Offset
npe_b24Data2Load_write(0x000004); // B
}
busy_wait(1000);
npe_bEnable_write(0); // Disable
// end of illumination logic -----------------------------
illumination(); // The DEMO !
#ifdef CONFIG_CPU_HAS_INTERRUPT
irq_setmask(0);

Loading…
Cancel
Save