瀏覽代碼

Initial (non-kll) pixel mappings for KType

- Includes pixel testing functions
ICPad
Jacob Alexander 8 年之前
父節點
當前提交
b30f8f5e97
共有 3 個文件被更改,包括 248 次插入10 次删除
  1. 240
    4
      Macro/PixelMap/pixel.c
  2. 7
    5
      Macro/PixelMap/pixel.h
  3. 1
    1
      Scan/ISSILed/led_scan.c

+ 240
- 4
Macro/PixelMap/pixel.c 查看文件

@@ -100,9 +100,116 @@ PixelBuf Pixel_Buffers[] = {


// Pixel Mapping
uint8_t Pixel_Mapping[] = {
Pixel_RGBChannel(0,1,2),
// TODO
#define Pixel_TotalPixels 95 // TODO Generate
PixelElement Pixel_Mapping[] = {
// Function Row (1-16)
Pixel_RGBChannel(0,33,49), // 1
Pixel_RGBChannel(1,17,50), // 2
Pixel_RGBChannel(2,18,34), // 3
Pixel_RGBChannel(3,19,35), // 4
Pixel_RGBChannel(4,20,36), // 5
Pixel_RGBChannel(5,21,37), // 6
Pixel_RGBChannel(6,22,38), // 7
Pixel_RGBChannel(7,23,39), // 8
Pixel_RGBChannel(128,112,96), // 9
Pixel_RGBChannel(129,113,97), // 10
Pixel_RGBChannel(130,114,98), // 11
Pixel_RGBChannel(131,115,99), // 12
Pixel_RGBChannel(132,116,100), // 13
Pixel_RGBChannel(133,117,101), // 14
Pixel_RGBChannel(134,118,85), // 15
Pixel_RGBChannel(135,102,86), // 16

// Number Row (17-35)
Pixel_RGBChannel(8,41,57), // 17
Pixel_RGBChannel(9,25,58), // 18
Pixel_RGBChannel(10,26,42), // 19
Pixel_RGBChannel(11,27,43), // 20
Pixel_RGBChannel(12,28,44), // 21
Pixel_RGBChannel(13,29,45), // 22
Pixel_RGBChannel(14,30,46), // 23
Pixel_RGBChannel(15,31,47), // 24
Pixel_RGBChannel(136,120,104), // 25
Pixel_RGBChannel(137,121,105), // 26
Pixel_RGBChannel(138,122,106), // 27
Pixel_RGBChannel(139,123,107), // 28
Pixel_RGBChannel(140,124,108), // 29
Pixel_RGBChannel(141,125,109), // 30
Pixel_RGBChannel(142,126,93), // 31
Pixel_RGBChannel(143,110,94), // 32
Pixel_RGBChannel(144,177,193), // 33
Pixel_RGBChannel(145,161,194), // 34
Pixel_RGBChannel(146,162,178), // 35

// Top Alpha Row (36-53)
Pixel_RGBChannel(147,163,179), // 36
Pixel_RGBChannel(148,164,180), // 37
Pixel_RGBChannel(149,165,181), // 38
Pixel_RGBChannel(150,166,182), // 39
Pixel_RGBChannel(151,167,183), // 40
Pixel_RGBChannel(272,256,240), // 41
Pixel_RGBChannel(273,257,241), // 42
Pixel_RGBChannel(274,258,242), // 43
Pixel_RGBChannel(275,259,243), // 44
Pixel_RGBChannel(276,260,244), // 45
Pixel_RGBChannel(277,261,245), // 46
Pixel_RGBChannel(278,262,229), // 47
Pixel_RGBChannel(279,246,230), // 48
Pixel_RGBChannel(152,185,201), // 49
Pixel_RGBChannel(153,169,202), // 50
Pixel_RGBChannel(154,170,186), // 51
Pixel_RGBChannel(155,171,187), // 52
Pixel_RGBChannel(156,172,188), // 53

// Mid Alpha Row (54-67)
Pixel_RGBChannel(157,173,189), // 54
Pixel_RGBChannel(158,174,190), // 55
Pixel_RGBChannel(159,175,191), // 56
Pixel_RGBChannel(280,264,248), // 57
Pixel_RGBChannel(281,265,249), // 58
Pixel_RGBChannel(282,266,250), // 59
Pixel_RGBChannel(283,267,251), // 60
Pixel_RGBChannel(284,268,252), // 61
Pixel_RGBChannel(285,269,253), // 62
Pixel_RGBChannel(286,270,237), // 63
Pixel_RGBChannel(287,254,238), // 64
Pixel_RGBChannel(288,321,337), // 65
Pixel_RGBChannel(289,305,338), // 66
Pixel_RGBChannel(290,306,322), // 67

// Low Alpha Row (68-84)
Pixel_RGBChannel(291,307,323), // 68
Pixel_RGBChannel(292,308,324), // 69
Pixel_RGBChannel(293,309,325), // 70
Pixel_RGBChannel(294,310,326), // 71
Pixel_RGBChannel(295,311,327), // 72
Pixel_RGBChannel(416,400,384), // 73
Pixel_RGBChannel(417,401,385), // 74
Pixel_RGBChannel(418,402,386), // 75
Pixel_RGBChannel(419,403,387), // 76
Pixel_RGBChannel(420,404,388), // 77
Pixel_RGBChannel(421,405,389), // 78
Pixel_RGBChannel(422,406,373), // 79
Pixel_RGBChannel(423,390,374), // 80
Pixel_RGBChannel(296,329,345), // 81
Pixel_RGBChannel(297,313,346), // 82
Pixel_RGBChannel(298,314,330), // 83
Pixel_RGBChannel(299,315,331), // 84

// Mod Row (85-95)
Pixel_RGBChannel(300,316,332), // 85
Pixel_RGBChannel(301,317,333), // 86
Pixel_RGBChannel(302,318,334), // 87
Pixel_RGBChannel(303,319,335), // 88
Pixel_RGBChannel(424,408,392), // 89
Pixel_RGBChannel(425,409,393), // 90
Pixel_RGBChannel(426,410,394), // 91
Pixel_RGBChannel(427,411,395), // 92
Pixel_RGBChannel(428,412,396), // 93
Pixel_RGBChannel(429,413,397), // 94
Pixel_RGBChannel(430,414,381), // 95

// Underlighting - TODO
};

// Frame of led changes
@@ -158,6 +265,7 @@ PixelBuf Pixel_bufferMap( uint16_t channel )
return Pixel_Buffers[0];
}

// Toggle the given channel
void Pixel_channelToggle( uint16_t channel )
{
// Determine which buffer we are in
@@ -187,6 +295,16 @@ void Pixel_channelToggle( uint16_t channel )
}
}

// Toggle given pixel elementt
void Pixel_pixelToggle( PixelElement *elem )
{
// Toggle each of the channels of the pixel
for ( uint8_t ch = 0; ch < elem->channels; ch++ )
{
Pixel_channelToggle( elem->indices[ch] );
}
}

// Pixel Procesing Loop
inline void Pixel_process()
{
@@ -233,6 +351,42 @@ inline void Pixel_process()
return;
}

// Toggle current position, then increment
case PixelTest_Pixel_Roll:
// Toggle channel
Pixel_pixelToggle( &Pixel_Mapping[ Pixel_testPos ] );

// Increment channel
Pixel_testPos++;
if ( Pixel_testPos >= Pixel_TotalPixels )
Pixel_testPos = 0;

goto pixel_process_done;


case PixelTest_Pixel_All:
{
uint16_t px;

// Only update 10 positions at a time
for ( px = Pixel_testPos; px < Pixel_testPos + 50 && px < Pixel_TotalPixels; px++ )
{
// Toggle channel
Pixel_pixelToggle( &Pixel_Mapping[ px ] );
}

Pixel_testPos = px;

// Only signal frame update after all pixels complete
if ( Pixel_testPos >= Pixel_TotalPixels )
{
Pixel_testPos = 0;
goto pixel_process_done;
}

return;
}

default:
break;
}
@@ -292,12 +446,94 @@ void cliFunc_pixelList( char* args )
print(")");
}
break;

default:
info_msg("Pixel List - <num>[<ch1>,...]<width>:...");

// List all pixels
for ( uint16_t pixel = 0; pixel < Pixel_TotalPixels; pixel++ )
{
// NL occaisionally
if ( pixel % 5 == 0 )
print( NL );

PixelElement *elem = (PixelElement*)&Pixel_Mapping[ pixel ];

printHex_op( pixel, 2 );
print(":");
printInt8( elem->width );
print("[");

// Display each of the channels
printHex_op( elem->indices[0], 2 );
for ( uint8_t ch = 1; ch < elem->channels; ch++ )
{
print(",");
printHex_op( elem->indices[ch], 2 );
}

print("]");
print(" ");
}

break;
}
}

void cliFunc_pixelTest( char* args )
{
print( NL );
print( NL ); // No \r\n by default after the command is entered

char* curArgs;
char* arg1Ptr;
char* arg2Ptr = args;

// Process speed argument if given
curArgs = arg2Ptr;
CLI_argumentIsolation( curArgs, &arg1Ptr, &arg2Ptr );

// Check for special args
switch ( *arg1Ptr )
{
case 'a':
case 'A':
info_msg("All pixel test");
Pixel_testPos = 0;
Pixel_testMode = PixelTest_Pixel_All;
return;

case 'r':
case 'R':
info_msg("Pixel roll test");
Pixel_testPos = 0;
Pixel_testMode = PixelTest_Pixel_Roll;
return;

case 's':
case 'S':
info_msg("Stopping pixel test");
Pixel_testMode = PixelTest_Off;
return;
}

// Check for specific position
if ( *arg1Ptr != '\0' )
{
Pixel_testPos = numToInt( arg1Ptr );
}
else
{
info_msg("Pixel: ");
printInt16( Pixel_testPos );
}

// Toggle channel
Pixel_pixelToggle( &Pixel_Mapping[ Pixel_testPos ] );

// Increment channel
Pixel_testPos++;
if ( Pixel_testPos >= Pixel_TotalPixels )
Pixel_testPos = 0;
}

void cliFunc_chanTest( char* args )

+ 7
- 5
Macro/PixelMap/pixel.h 查看文件

@@ -1,4 +1,4 @@
/* Copyright (C) 2015 by Jacob Alexander
/* Copyright (C) 2015-2016 by Jacob Alexander
*
* This file is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -70,14 +70,16 @@ typedef struct PixelBuf {


// Individual Pixel element
#define Pixel_MaxChannelPerPixel 3 // TODO Generate
typedef struct PixelElement {
uint8_t width; // Number of bits in a channel
uint8_t channels; // Number of channels
uint16_t indices[0]; // Hardware indices for each channel
// Hardware indices for each channel
uint16_t indices[Pixel_MaxChannelPerPixel];
} PixelElement;
#define s2b(num) (num >> 8), (num & 0xFF)
#define Pixel_RGBChannel(r,g,b) 8, 3, s2b(r), s2b(g), s2b(b)
#define Pixel_8bitChannel(c) 8, 1, s2b(c)
#define Pixel_RGBChannel(r,g,b) { 8, 3, { r, g, b } }
// TODO generate macro based on max channels
//#define Pixel_8bitChannel(c) { 8, 1, { c } }


typedef struct PixelMod {

+ 1
- 1
Scan/ISSILed/led_scan.c 查看文件

@@ -1,4 +1,4 @@
/* Copyright (C) 2014-2015 by Jacob Alexander
/* Copyright (C) 2014-2016 by Jacob Alexander
*
* This file is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by