Permalink
Browse files

Check bitslice for any blue channel at low intensity

  • Loading branch information...
1 parent da39317 commit 74b1df5514fa4c127fd76d4e0ec8df4e96304595 @osresearch committed Aug 11, 2013
Showing with 57 additions and 13 deletions.
  1. +45 −2 teensy-udp-rx.c
  2. +8 −8 test-bitslice.c
  3. +4 −3 util.h
View
@@ -369,6 +369,39 @@ read_config(
}
+static int
+bitslice_check(
+ const uint8_t * const slice,
+ const size_t len
+)
+{
+ // Walk one of the strips to find if there are any 0xFF values
+ for (size_t i = 0 ; i < len ; i += 8)
+ {
+ uint8_t byte = 0;
+ for (unsigned bit_num = 0 ; bit_num < 8 ; bit_num++)
+ {
+ byte <<= 1;
+ if (slice[i + bit_num] & 1)
+ byte |= 0x1;
+ }
+
+ // for the fire demo there is NEVER blue
+ if ((i / 8) % 3 == 2 && byte != 0)
+ return -1;
+
+ //printf(" %02x", byte);
+ //if (byte < 0x10)
+ continue;
+ warn("bad byte at %u: %02x\n", i, byte);
+ return -1;
+ }
+ //printf("\n");
+
+ return 0;
+}
+
+
int
main(
int argc,
@@ -440,9 +473,9 @@ main(
// Header for the frame to the teensy indicating that it
// is to be drawn immediately.
- slice[0] = '$';
+ slice[0] = '*';
slice[1] = 0;
- slice[2] = 0;
+ slice[2] = 1;
struct timeval start_tv, stop_tv, delta_tv;
gettimeofday(&start_tv, NULL);
@@ -484,6 +517,16 @@ main(
const ssize_t rc
= write_all(dev->fd, slice, slice_size);
+ if (bitslice_check(slice+3, slice_size-3) < 0)
+ {
+ warn("bad slice! rc=%zu image:\n", rc);
+ hexdump(stderr, buf+1, image_size);
+ warn("slice %u\n", strip->x_offset);
+ hexdump(stderr, slice+3, slice_size-3);
+ die("FAILED\n");
+ }
+
+
if ((size_t) rc == slice_size)
continue;
View
@@ -6,19 +6,19 @@ int main(void)
{
uint8_t bitmap[2][9][3] = {
{
- { 0xFF, 0xFF, 0xFF },
+ { 0x03, 0x03, 0x03 },
{ 0x00, 0x00, 0x00 },
- { 0xFF, 0xFF, 0xFF },
+ { 0x03, 0x03, 0x03 },
{ 0x00, 0x00, 0x00 },
- { 0xFF, 0xFF, 0xFF },
+ { 0x03, 0x03, 0x03 },
{ 0x00, 0x00, 0x00 },
- { 0xFF, 0xFF, 0xFF },
+ { 0x03, 0x03, 0x03 },
{ 0x00, 0x00, 0x00 },
- { 0xFF, 0xFF, 0xFF },
+ { 0x03, 0x03, 0x03 },
},
{
{ 0x00, 0x00, 0x00 },
- { 0xFF, 0xFF, 0xFF },
+ { 0x03, 0x03, 0x03 },
{ 0x01, 0x02, 0x04 },
{ 0xF2, 0xF4, 0xF8 },
{ 0x04, 0x08, 0x10 },
@@ -29,11 +29,11 @@ int main(void)
},
};
- hexdump(bitmap, sizeof(bitmap));
+ hexdump(stdout, bitmap, sizeof(bitmap));
uint8_t out[1024];
bitslice(out, NULL, (const uint8_t*) bitmap, 9, 2, 1);
- hexdump(out, 8 * 2 * 3);
+ hexdump(stdout, out, 8 * 2 * 3);
}
View
7 util.h
@@ -34,6 +34,7 @@
static inline void
hexdump(
+ FILE * const outfile,
const void * const buf,
const size_t len
)
@@ -43,11 +44,11 @@ hexdump(
for(size_t i = 0 ; i < len ; i++)
{
if (i % 16 == 0)
- printf("%s%04zu:", i == 0 ? "": "\n", i);
- printf(" %02x", p[i]);
+ fprintf(outfile, "%s%04zu:", i == 0 ? "": "\n", i);
+ fprintf(outfile, " %02x", p[i]);
}
- printf("\n");
+ fprintf(outfile, "\n");
}
#endif

0 comments on commit 74b1df5

Please sign in to comment.