lol: styling fix and remove static gpio tables for gen1

Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
This commit is contained in:
Brendan Le Foll 2014-11-13 16:02:53 +00:00
parent 8174b6c59b
commit e3bdef0ef0
2 changed files with 23 additions and 64 deletions

View File

@ -51,79 +51,44 @@ static int charlie_pairs [12][22] = {
{0,13, 1,11, 2,9, 3,119, 4,105,5,91, 6,77, 7,63, 8,49, 9,35, 10,21} {0,13, 1,11, 2,9, 3,119, 4,105,5,91, 6,77, 7,63, 8,49, 9,35, 10,21}
}; };
//static int gpios_map[] = {
//14,15,28,17,24,27,26,19,16,25,38,39,
//};
void clear_gpio(int gpio) void clear_gpio(int gpio)
{ {
/* FIXME AK hack around Galileo gen1 issue, to remove mraa_gpio_mode(m_Ctx[gpio], MRAA_GPIO_HIZ);
if(gpio == 0)
{
mraa_gpio_mode(c1, MRAA_GPIO_HIZ);
mraa_gpio_mode(c2, MRAA_GPIO_HIZ);
}
else if (gpio == 1) {
mraa_gpio_mode(c3, MRAA_GPIO_HIZ);
mraa_gpio_mode(c4, MRAA_GPIO_HIZ);
} else*/
mraa_gpio_mode(m_Ctx[gpio], MRAA_GPIO_HIZ);
mraa_gpio_dir(m_Ctx[gpio], MRAA_GPIO_IN); mraa_gpio_dir(m_Ctx[gpio], MRAA_GPIO_IN);
} }
void clear_prev_cycle(int cycle) void clear_prev_cycle(int cycle)
{ {
int i; int i;
// What is prev cycle? // What is prev cycle?
cycle--; cycle--;
if (cycle == -1) if (cycle == -1)
cycle = 11; cycle = 11;
// Disable all "1"'s // Disable all "1"'s
for (i = 0; i < 11; i++) { for (i = 0; i < 11; i++) {
if (charlie_pairs[cycle][i*2] == -1) if (charlie_pairs[cycle][i*2] == -1)
break; break;
if(buffer[charlie_pairs[cycle][i*2 + 1]]) if(buffer[charlie_pairs[cycle][i*2 + 1]])
clear_gpio(charlie_pairs[cycle][i*2]); clear_gpio(charlie_pairs[cycle][i*2]);
} }
// Disable "0" // Disable "0"
clear_gpio(cycle); clear_gpio(cycle);
} }
void set_strong_one(int gpio) void set_strong_one(int gpio)
{ {
mraa_gpio_dir(m_Ctx[gpio], MRAA_GPIO_OUT); mraa_gpio_dir(m_Ctx[gpio], MRAA_GPIO_OUT);
/* FIXME AK hack around Galileo gen1 issue, to remove mraa_gpio_mode(m_Ctx[gpio], MRAA_GPIO_STRONG);
if(gpio == 0)
{
mraa_gpio_mode(c1, MRAA_GPIO_STRONG);
mraa_gpio_mode(c2, MRAA_GPIO_STRONG);
}
else if (gpio == 1) {
mraa_gpio_mode(c3, MRAA_GPIO_STRONG);
mraa_gpio_mode(c4, MRAA_GPIO_STRONG);
} else*/
mraa_gpio_mode(m_Ctx[gpio], MRAA_GPIO_STRONG);
mraa_gpio_write(m_Ctx[gpio], 1); mraa_gpio_write(m_Ctx[gpio], 1);
} }
void set_strong_zero(int gpio) void set_strong_zero(int gpio)
{ {
mraa_gpio_dir(m_Ctx[gpio], MRAA_GPIO_OUT); mraa_gpio_dir(m_Ctx[gpio], MRAA_GPIO_OUT);
/* FIXME AK hack around Galileo gen1 issue, to remove mraa_gpio_mode(m_Ctx[gpio], MRAA_GPIO_STRONG);
if(gpio == 0)
{
mraa_gpio_mode(c1, MRAA_GPIO_STRONG);
mraa_gpio_mode(c2, MRAA_GPIO_STRONG);
}
else if (gpio == 1) {
mraa_gpio_mode(c3, MRAA_GPIO_STRONG);
mraa_gpio_mode(c4, MRAA_GPIO_STRONG);
} else*/
mraa_gpio_mode(m_Ctx[gpio], MRAA_GPIO_STRONG);
mraa_gpio_write(m_Ctx[gpio], 0); mraa_gpio_write(m_Ctx[gpio], 0);
} }
@ -137,34 +102,28 @@ static void clear_gpios()
void *do_draw(void *arg) void *do_draw(void *arg)
{ {
/* c1 = mraa_gpio_init_raw(31);
c2 = mraa_gpio_init_raw(32);
c3 = mraa_gpio_init_raw(30);
c4 = mraa_gpio_init_raw(18);
*/
clear_gpios(); clear_gpios();
while (1) { while (1) {
int i, cur; int i, cur;
uint8_t cycle = 0; uint8_t cycle = 0;
// 12 Cycles of Matrix // 12 Cycles of Matrix
for (cycle = 0; cycle < 12; cycle++) for (cycle = 0; cycle < 12; cycle++)
{ {
if (cycle == 12) cycle = 0; if (cycle == 12) cycle = 0;
clear_prev_cycle(cycle); clear_prev_cycle(cycle);
// set strong/0 on current cycle line // set strong/0 on current cycle line
set_strong_zero(cycle); set_strong_zero(cycle);
// draw ones from framebuffer // draw ones from framebuffer
for (i = 0; i < 11; i++) { for (i = 0; i < 11; i++) {
cur = charlie_pairs[cycle][i*2]; cur = charlie_pairs[cycle][i*2];
if (cur == -1) break; if (cur == -1) break;
if (buffer[charlie_pairs[cycle][i*2 + 1]]) { if (buffer[charlie_pairs[cycle][i*2 + 1]]) {
set_strong_one(cur); set_strong_one(cur);
// printf("cycle %d %d %d %d\n", cycle, i, charlie_pairs[cycle][i*2 + 1], // printf("cycle %d %d %d %d\n", cycle, i, charlie_pairs[cycle][i*2 + 1],
// buffer[charlie_pairs[cycle][i*2 + 1]]); // buffer[charlie_pairs[cycle][i*2 + 1]]);
} }
} }
@ -181,7 +140,7 @@ LoL::LoL() {
memset(framebuffer, 0, LOL_X*LOL_Y); memset(framebuffer, 0, LOL_X*LOL_Y);
// I am optimistic and stupid - thread creation // I am optimistic and stupid - thread creation
// always works in my world // always works in my world
buffer = (unsigned char*)framebuffer; buffer = (unsigned char*)framebuffer;
m_Ctx = m_LoLCtx; m_Ctx = m_LoLCtx;

View File

@ -83,9 +83,9 @@ class LoL {
unsigned char setPixel(int x, int y, unsigned char pixel); unsigned char setPixel(int x, int y, unsigned char pixel);
private: private:
mraa_gpio_context m_LoLCtx[14]; mraa_gpio_context m_LoLCtx[14];
unsigned char framebuffer[LOL_X*LOL_Y]; unsigned char framebuffer[LOL_X*LOL_Y];
pthread_t drawer_thread; pthread_t drawer_thread;
}; };
}; };