-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
61 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,17 +7,14 @@ | |
'' -- see below for terms of use | ||
'' E-mail..... [email protected] | ||
'' Started.... Nov 2022 | ||
'' Updated.... 15 Jan 2024 | ||
'' Updated.... 26 Mar 2024 | ||
'' | ||
'' ================================================================================================= | ||
|
||
CON | ||
|
||
#0, LED_UNKNOWN, LED_RED, LED_GREEN, LED_BLUE | ||
|
||
OBJ | ||
|
||
hub75Bffrs : "isp_hub75_hwBufferAccess" | ||
|
||
DAT { driver controls for testing } | ||
|
||
|
@@ -42,14 +39,6 @@ PUB getBrightness() : brightness | |
'' Return the global brightness value | ||
brightness := defaultBrightness | ||
|
||
PUB correctedColor(nChainIdx, color) : adjustedColor | ||
'' Correct a color using generic gamma | ||
adjustedColor := color | ||
'return | ||
'adjustedColor := byte[@gamma][adjustedColor] | ||
'adjustedColor := ((adjustedColor * defaultBrightness) >> 8) & $ff | ||
adjustedColor := colorAtDesiredBitWidth(nChainIdx, adjustedColor) | ||
|
||
PUB gammaPeek(color) : adjustedColor | gammmaIndex, lowColor, highColor | ||
'' Return index of nearest matching value in gamma table | ||
if bGammaEnable | ||
|
@@ -73,9 +62,8 @@ PUB gammaPeek(color) : adjustedColor | gammmaIndex, lowColor, highColor | |
else | ||
adjustedColor := color | ||
|
||
PUB correctedSingleColor(nChainIdx, led, colorValue) : adjustedColor | pGammaTable | ||
'' Correct the color for a specific LED (R, G, or B) | ||
adjustedColor := colorValue | ||
PUB gammaCorrectedSingleColor(led, colorValue) : adjustedColor | pGammaTable | ||
'' Gamma-Correct the color for a specific LED (R, G, or B) | ||
case led | ||
LED_RED: | ||
pGammaTable := @gamma | ||
|
@@ -85,11 +73,9 @@ PUB correctedSingleColor(nChainIdx, led, colorValue) : adjustedColor | pGammaTab | |
pGammaTable := @gamma | ||
other: | ||
abort | ||
|
||
adjustedColor := ((adjustedColor * defaultBrightness) >> 8) & $ff | ||
adjustedColor := ((colorValue * defaultBrightness) >> 8) & $ff | ||
if bGammaEnable | ||
adjustedColor := byte[pGammaTable][adjustedColor] | ||
adjustedColor := colorAtDesiredBitWidth(nChainIdx, adjustedColor) | ||
adjustedColor := byte[@gamma][adjustedColor] | ||
|
||
PUB rgbColorFromDegrees(degrees) : rcbColor | offset60, fract60, red, green, blue | ||
'' CONVERT: 0-355 degrees to color | ||
|
@@ -145,45 +131,9 @@ PUB gammaPtrs(): pGammaRed, pGammaGreen, pGammaBlue | |
pGammaGreen := @gamma | ||
pGammaBlue := @gamma | ||
|
||
PUB colorAtDesiredBitWidth(nChainIdx, hex8bit) : pwmBits | ||
'' CALCULATE: proper duty cycle for intensity of 0-255 | ||
shiftLtValue := 8 - hub75Bffrs.colorDepth(nChainIdx) | ||
nbrPwmFrames := hub75Bffrs.pwmFrameCount(nChainIdx) | ||
'debug("- color CFG: ", udec_long(shiftLtValue), udec_long(nbrPwmFrames)) | ||
' | ||
' (map 8-bit color depth to {compiled}-bit color depth) | ||
' map 0-255 to compiled color depth 0-7,15,31,63,127,255 | ||
' | ||
' REF: https://www.arduino.cc/reference/en/language/functions/math/map | ||
' | ||
' Re-maps a number from one range to another. That is, a value of fromLow would get mapped to toLow, | ||
' a value of fromHigh to toHigh, values in-between to values in-between, etc. | ||
' | ||
' y = map(x, 1, 50, 50, 1); | ||
' | ||
' PRI map(inValue, inMin, inMax, outMin, outMax) : outValue | ||
' outValue := (inValue - inMin) * (outMax - outMin) / (inMax - inMin) + outMin | ||
' outValue := (inValue - 0) * (outMax - 0) / (inMax - 0) + 0 | ||
' outValue := inValue * outMax / inMax | ||
' | ||
' shiftLtValue 5, 4, 3, 2, 1, 0 | ||
' map(hex8bit, 0, 255, 0, 7) 7=3-bit, 15=4-bit, 31=5-bit, 63=6-bit, 127=7-bit, 255=8-bit | ||
' outValue := (hex8bit - 0) * (7 - 0) / (255 - 0) + 0 | ||
' outValue := hex8bit * 7 / 255 | ||
|
||
pwmBits := (hex8bit * nbrPwmFrames) / 255 ' map our value | ||
pwmBits <<= shiftLtValue ' shift value into our upper COLOR_DEPTH bits | ||
{ | ||
if not didShow[hex8bit] | ||
debug("clr:dcyc ", uhex_byte(hex8bit), uhex_byte(pwmBits)) | ||
didShow[hex8bit] := TRUE | ||
'} | ||
|
||
DAT { tables, default values } | ||
|
||
shiftLtValue long 0 ' set by init() | ||
nbrPwmFrames long 0 ' set by init() | ||
|
||
didShow byte FALSE[256] | ||
|
||
defaultBrightness word 256 '256 ' 205 = 80% [0-255,256] where 256 is NO brightness adjustment | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
'' -- see below for terms of use | ||
'' E-mail..... [email protected] | ||
'' Started.... Nov 2022 | ||
'' Updated.... 15 Jan 2024 | ||
'' Updated.... 26 Mar 2024 | ||
'' | ||
'' ================================================================================================= | ||
' | ||
|
@@ -51,6 +51,7 @@ OBJ | |
|
||
hwEnum : "isp_hub75_hwEnums" ' hub75 attachment, set up constants | ||
user : "isp_hub75_hwPanelConfig" ' user's panels configuration constants | ||
colorUtils : "isp_hub75_colorUtils" ' color utilities | ||
|
||
CON { internal constants } | ||
' ------------------------------------------------------------------- | ||
|
@@ -357,6 +358,55 @@ PUB getDriverFlags(nChainIdx) : desiredFlags, eChipType | |
debug("- have unknown CHIP ", ubin_word(desiredFlags)) | ||
abort | ||
|
||
PUB correctedColor(nChainIdx, color) : adjustedColor | ||
'' Correct a color using generic gamma | ||
adjustedColor := color | ||
'return | ||
'adjustedColor := byte[@gamma][adjustedColor] | ||
'adjustedColor := ((adjustedColor * defaultBrightness) >> 8) & $ff | ||
adjustedColor := colorAtDesiredBitWidth(nChainIdx, adjustedColor) | ||
|
||
PUB correctedSingleColor(nChainIdx, led, colorValue) : adjustedColor | pGammaTable | ||
'' Correct the color for a specific LED (R, G, or B) | ||
adjustedColor := ((colorValue * colorUtils.getBrightness()) >> 8) & $ff | ||
if colorUtils.isGammaEnabled() | ||
adjustedColor := colorUtils.gammaCorrectedSingleColor(led, colorValue) | ||
adjustedColor := colorAtDesiredBitWidth(nChainIdx, adjustedColor) | ||
|
||
PUB colorAtDesiredBitWidth(nChainIdx, hex8bit) : pwmBits | shiftLtValue, nbrPwmFrames | ||
'' CALCULATE: proper duty cycle for intensity of 0-255 | ||
shiftLtValue := 8 - colorDepth(nChainIdx) | ||
nbrPwmFrames := pwmFrameCount(nChainIdx) | ||
'debug("- color CFG: ", udec_long(shiftLtValue), udec_long(nbrPwmFrames)) | ||
' | ||
' (map 8-bit color depth to {compiled}-bit color depth) | ||
' map 0-255 to compiled color depth 0-7,15,31,63,127,255 | ||
' | ||
' REF: https://www.arduino.cc/reference/en/language/functions/math/map | ||
' | ||
' Re-maps a number from one range to another. That is, a value of fromLow would get mapped to toLow, | ||
' a value of fromHigh to toHigh, values in-between to values in-between, etc. | ||
' | ||
' y = map(x, 1, 50, 50, 1); | ||
' | ||
' PRI map(inValue, inMin, inMax, outMin, outMax) : outValue | ||
' outValue := (inValue - inMin) * (outMax - outMin) / (inMax - inMin) + outMin | ||
' outValue := (inValue - 0) * (outMax - 0) / (inMax - 0) + 0 | ||
' outValue := inValue * outMax / inMax | ||
' | ||
' shiftLtValue 5, 4, 3, 2, 1, 0 | ||
' map(hex8bit, 0, 255, 0, 7) 7=3-bit, 15=4-bit, 31=5-bit, 63=6-bit, 127=7-bit, 255=8-bit | ||
' outValue := (hex8bit - 0) * (7 - 0) / (255 - 0) + 0 | ||
' outValue := hex8bit * 7 / 255 | ||
|
||
pwmBits := (hex8bit * nbrPwmFrames) / 255 ' map our value | ||
pwmBits <<= shiftLtValue ' shift value into our upper COLOR_DEPTH bits | ||
{ | ||
if not didShow[hex8bit] | ||
debug("clr:dcyc ", uhex_byte(hex8bit), uhex_byte(pwmBits)) | ||
didShow[hex8bit] := TRUE | ||
'} | ||
|
||
PUB dbgMemDump(pMessage, pBytes, lenBytes) | bytBffr, colIdx, rowIdx, maxCol, maxRow, dispLen | ||
'' Dump bytes in hex format to debug() terminal | ||
debug("`temp '", zstr_(pMessage), ": bffr=", uhex_long_(pBytes), "(", udec_(lenBytes), ")' 13") | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
'' -- see below for terms of use | ||
'' E-mail..... [email protected] | ||
'' Started.... Nov 2020 | ||
'' Updated.... 5 Nov 2022 | ||
'' Updated.... 26 Mar 2024 | ||
'' | ||
'' ================================================================================================= | ||
|
||
|
@@ -65,9 +65,9 @@ PUB drawPixelAtRCwithRGB(nChainIdx, row, column, red, green, blue) | rowIndex, c | |
'if isDebugLocn(rowIndex, columnIndex) | ||
'if column // 16 == 0 | ||
'debug("- Screen RC=(", udec_(rowIndex), ", ", udec_(columnIndex), "), ofs=", udec_(colorOffset), ", RGB=(", uhex_(red), uhex_(green), uhex_(blue), ")") | ||
byte[pColor][0] := colorUtils.correctedSingleColor(nChainIdx, colorUtils.LED_RED, red) | ||
byte[pColor][1] := colorUtils.correctedSingleColor(nChainIdx, colorUtils.LED_GREEN, green) | ||
byte[pColor][2] := colorUtils.correctedSingleColor(nChainIdx, colorUtils.LED_BLUE, blue) | ||
byte[pColor][0] := hub75Bffrs.correctedSingleColor(nChainIdx, colorUtils.LED_RED, red) | ||
byte[pColor][1] := hub75Bffrs.correctedSingleColor(nChainIdx, colorUtils.LED_GREEN, green) | ||
byte[pColor][2] := hub75Bffrs.correctedSingleColor(nChainIdx, colorUtils.LED_BLUE, blue) | ||
|
||
CON { license } | ||
|
||
|