Skip to content

Commit

Permalink
clean up code and add bmp files
Browse files Browse the repository at this point in the history
Move .BMP file handling to new optional file
add .BMP test files
Add .BMP load and display to demoColor
  • Loading branch information
ironsheep committed Dec 2, 2020
1 parent 870d40d commit f21d160
Show file tree
Hide file tree
Showing 15 changed files with 364 additions and 496 deletions.
Binary file added driver/TstBG-Up.bmp
Binary file not shown.
Binary file added driver/TstBGCol.bmp
Binary file not shown.
21 changes: 10 additions & 11 deletions driver/isp_hub75_7seg.spin2
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ segmentsByDigit
byte %0111_1011 ' 9 abcd-fg

VAR { globals }
long currValue
long currValue
long currRgbColor
long topY
long leftX

long defaultColor

byte isSetup

PUB null()
Expand All @@ -65,20 +65,20 @@ PUB placeDigit(row, column, digit, rgbColor)
if digit <> DIGIT_HIDDEN
reconfigureForDigit(digit)

PUB setValue(digit)
PUB setValue(digit)
'' Configure display to show desired {digit}: [0-9, DIGIT_HIDDEN]
ensureIsSetup()
if currValue <> digit
reconfigureForDigit(digit)

PUB incrementValue(shouldWrap) | nextValue
'' Increment to the next digit [0->9]
'' Increment to the next digit [0->9]
'' if wrap is requested, return to 0 after 9, else just stop at 9
nextValue := currValue + 1
if nextValue > 9
if nextValue > 9
if shouldWrap <> WITH_WRAP
nextValue := 9
else
else
nextValue := 0
setValue(nextValue)

Expand Down Expand Up @@ -135,7 +135,7 @@ PRI initialSetup() | segIndex, orientation, segRow, segCol
0: ' G MIDDLE
orientation := segments.SEG_MIDDLE
segRow := topY + 1 + segments.SEG_LENGTH + 0 - 1
segCol := leftX + 1
segCol := leftX + 1

segments[segIndex].placeSegment(segRow, segCol, orientation, segments.STATE_OFF, currRgbColor)

Expand All @@ -156,15 +156,15 @@ PRI reconfigureForDigit(digit) | byte fromSegments, byte toSegments, bitIndex
if toSegments & (1 << bitIndex) > 0
' to segment should be showing
' NO CHANGE
else
else
' to segment should be hidden
segments[bitIndex].moveSegmentToState(segments.STATE_OFF)
else
else
' from segment is hidden
if toSegments & (1 << bitIndex) > 0
' to segment should be showing
segments[bitIndex].moveSegmentToState(segments.STATE_ON)
else
else
' to segment should be hidden
' NO CHANGE
else
Expand Down Expand Up @@ -200,4 +200,3 @@ CON { license }
SOFTWARE.
=================================================================================================
}}

75 changes: 8 additions & 67 deletions driver/isp_hub75_color.spin2
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
'' -- Copyright (c) 2020 Iron Sheep Productions, LLC
'' -- see below for terms of use
'' E-mail..... [email protected]
'' Started.... Oct 2020
'' Started.... Oct 2020
'' Updated.... 24 Oct 2020
''
'' =================================================================================================

CON { test colorset }

cBlack = $000000
cWhite = $FFFFFF
cRed = $FF0000
Expand All @@ -32,7 +32,7 @@ CON { test colorset }
cDarkGreen = $006400
cOrange = $FFA500
cBlueViolet = $8A2BE2

' SPECIAL non-colors - invoke alforithm to gerate actual color used'
cRedWhtBlu = $deadf0
cRainbow = $deadf1
Expand Down Expand Up @@ -130,30 +130,10 @@ PUB rgbColorFromDegrees(degrees) : rcbColor | offset60, fract60, red, green, blu
elseif degrees >= 60
green := 255
red := ((59 - offset60) * fract60) / 100
else
else
red := 255
green := (offset60 * fract60) / 100
{
fract60 := 4.25 ' float(255 / 60) ' 4.25 ' 255 / 60
if degrees >= 300
red := 255
blue := (59 - offset60) * fract60
elseif degrees >= 240
blue := 255
red := offset60 * fract60
elseif degrees >= 180
blue := 255
green := (59 - offset60) * fract60
elseif degrees >= 120
green := 255
blue := offset60 * fract60
elseif degrees >= 60
green := 255
red := (59 - offset60) * fract60
else
red := 255
green := offset60 * fract60
}

rcbColor := cValueForRGB(red, green, blue)
'debug("- degrees=", udec_(degrees), ", color=", uhex_long_(rcbColor), " RGB=", udec_(red), ", ", udec_(green), ", ", udec_(blue), ")" )

Expand All @@ -168,46 +148,8 @@ PUB cValueForRGB(red, green, blue) : combinedValue
'' CONVERT: r,g,b to combined value
combinedValue := ((red & $ff) << 16) | ((green & $ff) << 8) | (blue & $ff)

PRI dutyCycleForIntensityOld1(hex8bit) : pwmBits
' CALCULATE: proper duty cycle for intensity of 0-255
' --- VERSION 1 - Bits spread throughout ---
if hex8bit == 255
pwmBits := $ff
elseif hex8bit == 0
pwmBits := $00
else
pwmBits := (hex8bit / screen.MAX_PWM_FRAMES - 1) + 1

PRI dutyCycleForIntensityOld2(hex8bit) : pwmBits | segmentSize
' CALCULATE: proper duty cycle for intensity of 0-255
' --- VERSION 2 - 3/4 high, 1/4 off, rest spread throughout ---
segmentSize := (256 / (screen.MAX_PWM_FRAMES + 1)) / 8
if hex8bit >= 255 - ((segmentSize * 6) - 1)
pwmBits := $ff
elseif hex8bit <= (segmentSize * 2)- 1
pwmBits := $00
else
pwmBits := (hex8bit / screen.MAX_PWM_FRAMES) + 1

PRI dutyCycleForIntensityOld3(hex8bit) : pwmBits | segmentSize
' WAIT!!! Pastel colors!???!
' CALCULATE: proper duty cycle for intensity of 0-255
' --- VERSION 3 - Bits spread throughout ---
pwmBits := (hex8bit / screen.MAX_PWM_FRAMES + 1)

PRI dutyCycleForIntensityOld4(hex8bit) : pwmBits | segmentSize
' CALCULATE: proper duty cycle for intensity of 0-255
' --- VERSION 4 - 2/6 high, 1/6 off, rest spread throughout ---
segmentSize := ((256 / (screen.MAX_PWM_FRAMES + 1)) / 2) / 3
if hex8bit >= 255 - (segmentSize * 2) + 1
pwmBits := $ff
elseif hex8bit <= 0 + segmentSize - 1
pwmBits := $00
else
pwmBits := ((hex8bit * 10854) / screen.MAX_PWM_FRAMES) / 10000

PRI dutyCycleForIntensity(hex8bit) : pwmBits
' CALCULATE: proper duty cycle for intensity of 0-255
PUB dutyCycleForIntensity(hex8bit) : pwmBits
'' CALCULATE: proper duty cycle for intensity of 0-255
' --- VERSION 1 - Bits spread throughout ---
if hex8bit == 255
pwmBits := $ff
Expand Down Expand Up @@ -257,7 +199,7 @@ gammaOld byte 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
byte 172, 174, 176, 178, 180, 182, 184, 186, 188, 190, 192, 194, 197, 199, 201, 203, 205
byte 207, 210, 212, 214, 216, 219, 221, 223, 226, 228, 230, 233, 235, 237, 240, 242, 245
byte 247, 250, 252, 255

gamma2_0
' 256-step brightness table: gamma = 2.0
byte 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1
Expand Down Expand Up @@ -401,4 +343,3 @@ CON { license }
SOFTWARE.
=================================================================================================
}}

21 changes: 10 additions & 11 deletions driver/isp_hub75_demo7seg.spin2
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ PUB start() : ok | blockX, blockY, subrow, subcol, row, col, red, green, blue, b
digitPeriod := 12 ' 90 ' 4 x 100ths of a second

' draw some text!
display.setTextFont(display.TEXT_FONT_5x7) ' font size
display.setTextFont(display.TEXT_FONT_5x7) ' font size
display.setCursor(0, 0) ' start at top left, with one pixel of spacing


Expand Down Expand Up @@ -93,8 +93,8 @@ PUB start() : ok | blockX, blockY, subrow, subcol, row, col, red, green, blue, b

loopUntilSegmentsFinish()

wait100thSecs(digitPeriod)
wait100thSecs(digitPeriod)

{
' transitional DEMO

Expand All @@ -121,7 +121,7 @@ PUB start() : ok | blockX, blockY, subrow, subcol, row, col, red, green, blue, b

loopUntilSegmentsFinish()

wait100thSecs(digitPeriod)
wait100thSecs(digitPeriod)
}


Expand All @@ -132,7 +132,7 @@ PRI showSecondsDots(lightDark) | red, green, blue, targetColor
' lightDarkv[0,1] where 1 means bright color
if lightDark == 0
targetColor := $00006F
else
else
targetColor := $0080FF

drawSecondsDot(15, 31, targetColor)
Expand All @@ -154,15 +154,15 @@ PRI allDigitAnimationsComplete() : status


PRI loopUntilSegmentsFinish()
repeat
if not allDigitAnimationsComplete()
repeat
if not allDigitAnimationsComplete()
repeat digitIndex from 0 to 3
if not digit[digitIndex].isAnimationComplete()
digit[digitIndex].animateStep()
digit[digitIndex].animateStep()
display.commitScreenToPanel()
wait100thSecs(segmentPeriod)

if allDigitAnimationsComplete()
if allDigitAnimationsComplete()
quit

PUB wait100thSecs(count)
Expand All @@ -171,7 +171,7 @@ PUB wait100thSecs(count)
waitms(10) ' 1/100 seconds


PUB stop()
PUB stop()
'' Stop the driver
if cog
display.stop()
Expand Down Expand Up @@ -206,4 +206,3 @@ CON { license }
SOFTWARE.
=================================================================================================
}}

Loading

0 comments on commit f21d160

Please sign in to comment.