Now w/ kbhit() & working!

master
kaqu 2 years ago
parent 3ce7042421
commit f916787572
  1. 2
      software/include/illumination.h
  2. 32
      software/source/illumination.c
  3. 13
      software/source/main.c

@ -4,5 +4,5 @@ extern void enable_LEDS(int iEnable);
extern void send_LEDs(void);
extern void clear_LEDs(int iTable);
extern void load_triple_LEDs(int iTable, int32_t green, int32_t red, int32_t blue);
extern void illumination(void);
extern int illumination(void);
#endif

@ -46,6 +46,26 @@ extern void busy_wait(unsigned int ms); // Worx!
#define MAXLEDS 27 // 1..256 MUST match h/w!
static int32_t arLEDBuffer[MAXTABLES][MAXLEDS]; // GRB values
extern char kbhit(void);
extern int key_eval(void);
static int iDelay = 100; // 100ms by default
int key_eval(void)
{
switch(kbhit()) {
case 'w': if(iDelay < 200)
iDelay += 10;
break;
case 's': if(iDelay > 20)
iDelay -= 10;
break;
case 'x': return 1; // Abort indication
default: ;
}
return(0);
}
void enable_LEDS(int iEnable)
{
npe_b8Len_write(MAXLEDS); // Prepare length
@ -79,7 +99,7 @@ void load_triple_LEDs(int iTable, int32_t green, int32_t red, int32_t blue)
}
}
void illumination(void)
int illumination(void)
{
int32_t green = 0x040000;
int32_t red = 0x000400;
@ -107,7 +127,8 @@ void illumination(void)
for(iTable=0;iTable<MAXTABLES;iTable++)
load_triple_LEDs(iTable, green, red, blue);
send_LEDs();
busy_wait(80); // Slow down a bit
busy_wait(iDelay); // Slow down a bit
if(key_eval()) return 1;
}
// Make 3 run along ...
green = 0x404000;
@ -122,22 +143,24 @@ void illumination(void)
int max_LED = MAXLEDS-1; // 0..26
for(int i=0;i<MAXLEDS-3;i++) { // Forward shift 3
send_LEDs();
busy_wait(100);
busy_wait(iDelay);
for(iTable=0;iTable<MAXTABLES;iTable++) {
for(int j=0;j<max_LED;j++)
arLEDBuffer[iTable][max_LED - j] = arLEDBuffer[iTable][(max_LED - 1) - j];
arLEDBuffer[iTable][i] = 0;
}
if(key_eval()) return 1;
}
printf("Halfway thru ...\n");
for(int i=0;i<MAXLEDS-1;i++) { // Backward shift 3
send_LEDs();
busy_wait(100);
busy_wait(iDelay);
for(iTable=0;iTable<MAXTABLES;iTable++) {
for(int j=0;j<max_LED;j++)
arLEDBuffer[iTable][j] = arLEDBuffer[iTable][j+1];
arLEDBuffer[iTable][max_LED-i] = 0;
}
if(key_eval()) return 1;
}
busy_wait(400);
@ -148,5 +171,6 @@ void illumination(void)
busy_wait(500);
enable_LEDS(0);
printf("Finished!\n");
return 0;
}

@ -42,9 +42,17 @@
#include "../include/illumination.h"
extern void busy_wait(unsigned int ms); // Worx!
extern char kbhit(void);
int32_t cpc; // Current PC storage
char kbhit(void)
{
if(readchar_nonblock())
return readchar();
return '\0';
}
int main(int i, char **c)
{
char buffer[CMD_LINE_BUFFER_SIZE];
@ -74,9 +82,12 @@ int main(int i, char **c)
#ifdef CONSOLE_NON_BLOCKING
extern void set_console(int non_blocking);
set_console(1); // 1=Non-blocking (0=standard/blocking)
extern int readchar_nonblock(void);
#endif
while(1)
illumination(); // The DEMO !
if(illumination()) // The DEMO !
break;
while(1) {
printf("\n%s", PROMPT);
readline(buffer, CMD_LINE_BUFFER_SIZE);

Loading…
Cancel
Save