From b809208b6078ed0538a07e493800a4f5c06eb2f2 Mon Sep 17 00:00:00 2001 From: Petr Baudis Date: Sun, 19 Aug 2012 23:38:24 +0200 Subject: [PATCH] arduino: Change cmin[] semantics - pwm level of channel level 1, not 0 Should eliminate dim red light for black pixels. --- arduino/autonomous/autonomous.ino | 2 ++ arduino/controlled/controlled.ino | 2 +- arduino/ledbar.h | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/arduino/autonomous/autonomous.ino b/arduino/autonomous/autonomous.ino index 8137f91..b3d41dc 100644 --- a/arduino/autonomous/autonomous.ino +++ b/arduino/autonomous/autonomous.ino @@ -1,5 +1,7 @@ #include "../ledbar.h" +/* FIXME: cmin[] is not handled properly here, it's the level of 1, not 0. */ + class Ledbar lb[NUM_TLCS]; int c[cpinsets][CH]; diff --git a/arduino/controlled/controlled.ino b/arduino/controlled/controlled.ino index 7118ee7..a5eef65 100644 --- a/arduino/controlled/controlled.ino +++ b/arduino/controlled/controlled.ino @@ -28,7 +28,7 @@ void loop() while (!Serial.available()); unsigned char s = Serial.read(); //c[led][i] = s; - c[led][i] = map(s, 0, 255, cmin[led][i], cmax[led][i]); + c[led][i] = s == 0 ? 0 : map(s, 1, 255, cmin[led][i], cmax[led][i]); //Serial.print(c[led][i], DEC); //Serial.print(" "); } diff --git a/arduino/ledbar.h b/arduino/ledbar.h index 1dcf73b..95b741b 100644 --- a/arduino/ledbar.h +++ b/arduino/ledbar.h @@ -97,7 +97,7 @@ const int cpin[LEDS_PER_TLC * NUM_TLCS][CH] = { #define cpinsets (sizeof(cpin)/sizeof(cpin[0])) /* cca 2.7ohm resistor per channel */ -const int cmin[cpinsets][CH] = { +const int cmin[cpinsets][CH] = { // level of 1 (not 0!) { 4, 0, 0 }, /* box 1 */ { 5, 0, 0 }, /* box 2 */ { 5, 0, 0 }, /* box 3 */ @@ -122,7 +122,7 @@ const int cmin[cpinsets][CH] = { { 5, 0, 0 }, /* box 19 */ { 5, 0, 0 }, /* box 20 */ }; -const int cmax[cpinsets][CH] = { +const int cmax[cpinsets][CH] = { // level of 255 { 120, 250, 190 }, /* box 11 */ { 100, 250, 180 }, /* box 2 */ { 100, 250, 180 }, /* box 3 */