@@ -34,6 +34,7 @@ SCROLL_FOREVER = scroller.SCROLL_FOREVER
3434SCROLL_ONCE = scroller.SCROLL_ONCE
3535SCROLL_ONCE_TO_CLEAR = scroller.SCROLL_ONCE_TO_CLEAR
3636
37+ ' FIXME: UNDONE make this user configurable
3738MAX_SCROLLING_REGIONS = 3
3839
3940DAT { one or more screens of pixels of 24bit color }
@@ -66,18 +67,31 @@ VAR { Object Instance Variables }
6667 byte horizontalGapInPix
6768 byte verticalGapInPix
6869 byte hBitmapOffsetInPix
70+ byte bScan_1_4
71+ byte bSwapRB
6972
70- PUB start() : ok | scrollerIndex
73+ PUB start() : ok | scrollerIndex, dvrConfig, driverConfigRaw
7174 '' Start the underlying driver(s)
7275
76+ ok := cog := -1 ' mark as failed, initially
77+
7378 'debug("`term temp size 80 50 textsize 10")
79+ if screen.MAX_PANELS_PER_COLUMN * screen.MAX_PANELS_PER_ROW <> screen.MAX_PANELS
80+ debug("dsp:Geometry BAD in isp_hub75_hwGeometry.spin2!")
81+ abort
82+
7483
75- debug("- TEXT: start()")
84+ debug("dsp: start()")
7685 ok := cog := panel.start() ' send buffer to driver
7786 if ok == -1
78- debug("- TEXT: underlying drivers failed!")
87+ debug("dsp: underlying drivers failed!")
7988 abort
8089
90+ dvrConfig, driverConfigRaw := screen.getDriverFlags()
91+ bScan_1_4 := (dvrConfig & screen.SCAN_4) > 0 ? True : False
92+ bSwapRB := (dvrConfig & screen.RB_SWAP) > 0 ? True : False
93+
94+
8195 ' tell all about location of screen buffer
8296 screen.setScreen(@screen0)
8397
@@ -104,18 +118,23 @@ PUB clearScreen()
104118
105119PUB fillScreen(rgbColor) | row, column
106120 '' Fill the display with 24-bit color value
107- repeat row from 0 to screen.MAX_DISPLAY_ROWS - 1
108- repeat column from 0 to screen.MAX_DISPLAY_COLUMNS - 1
121+ repeat row from 0 to screen.MAX_PHYSICAL_ROWS - 1
122+ repeat column from 0 to screen.MAX_PHYSICAL_COLUMNS - 1
109123 pixels.drawPixelAtRC(row, column, rgbColor)
110124
111125PUB fillPanel(threeBitColor)
112126 '' Fill screen but without PWM (for testing underlying driver)
113127 panel.fillPanel(threeBitColor)
114128
115129PUB commitScreenToPanel()
116- '' Write sceen to panel driver
117- 'debug("- DISP: commit!")
118- panel.convertScreen2PWM(@screen0)
130+ '' Write sceen to panel driver PWM frames (while alternating PWM frame sets)
131+ 'debug("dsp: commit!")
132+
133+ if bScan_1_4
134+ panel.convertScreen2PWM_14(@screen0, bSwapRB)
135+ 'panel.convertScreen2PWM_14_spin(@screen0, bSwapRB)
136+ else
137+ panel.convertScreen2PWM(@screen0, bSwapRB)
119138
120139
121140{ -------------- Text Handling -------------- }
@@ -185,7 +204,7 @@ PUB setTextFont(newFont) | scrollerIndex, hUnusedPix, vUnusedPix
185204
186205 selectedTextFont := newFont
187206
188- debug("dsp:font ", udec(charHeightInPix), udec(charWidthInPix), udec(maxTextLines), udec(maxTextColumns), udec(verticalGapInPix), udec(horizontalGapInPix), udec(topOffsetInPix), udec(leftOffsetInPix))
207+ ' debug("dsp:font ", udec(charHeightInPix), udec(charWidthInPix), udec(maxTextLines), udec(maxTextColumns), udec(verticalGapInPix), udec(horizontalGapInPix), udec(topOffsetInPix), udec(leftOffsetInPix))
189208
190209 ' configure our scrollers for font choice
191210 repeat scrollerIndex from 0 to MAX_SCROLLING_REGIONS - 1
@@ -310,7 +329,7 @@ PRI nextFreeScroller() : scrollerIndexToUse | scrollerIndex
310329 if scrollerIndexToUse == NOT_FOUND
311330 debug("Failed to locate free scroller!")
312331 abort
313- debug("dsp:nextFreeScroller() ", udec(scrollerIndexToUse))
332+ ' debug("dsp:nextFreeScroller() ", udec(scrollerIndexToUse))
314333
315334{ -------------- Basic Graphics -------------- }
316335
@@ -324,25 +343,25 @@ PUB drawBoxOfColor(topRow, leftColumn, width, height, filled, rgbColor) | rightC
324343 bottomRow := topRow + height - 1
325344 if filled == TRUE
326345 repeat rowIndex from 0 to height - 1
327- drawLineOfColor(topRow + rowIndex, leftColumn, topRow + rowIndex, rightColumn, currTextColor ) ' horiz row
346+ drawLineOfColor(topRow + rowIndex, leftColumn, topRow + rowIndex, rightColumn, rgbColor ) ' horiz row
328347 else
329- drawLineOfColor(topRow, leftColumn, topRow, rightColumn, currTextColor ) ' horiz top
330- drawLineOfColor(topRow, rightColumn, bottomRow, rightColumn, currTextColor ) ' vert right
331- drawLineOfColor(bottomRow, leftColumn, bottomRow, rightColumn, currTextColor ) ' horiz bottom
332- drawLineOfColor(topRow, leftColumn, bottomRow, leftColumn, currTextColor ) ' vert left
348+ drawLineOfColor(topRow, leftColumn, topRow, rightColumn, rgbColor ) ' horiz top
349+ drawLineOfColor(topRow, rightColumn, bottomRow, rightColumn, rgbColor ) ' vert right
350+ drawLineOfColor(bottomRow, leftColumn, bottomRow, rightColumn, rgbColor ) ' horiz bottom
351+ drawLineOfColor(topRow, leftColumn, bottomRow, leftColumn, rgbColor ) ' vert left
333352
334353
335354PUB drawLine(fmRow, fmColumn, toRow, toColumn)
336355 '' Draw line fromRC -> toRC using current text color (currently limited to horzontal/vertical lines)
337356 drawLineOfColor(fmRow, fmColumn, toRow, toColumn, currTextColor)
338357
339- PUB drawLineOfColor(fmRow, fmColumn, toRow, toColumn, rgbColor) | row, column, dx, dy, ctr, incr
358+ PUB drawLineOfColor(fmRow, fmColumn, toRow, toColumn, rgbColor) | row, column, dx, dy, ctr, incr, intD
340359 '' Draw line fromRC -> toRC using rgbColor (currently limited to horzontal/vertical lines)
360+ fmRow := 0 #> fmRow <# screen.MAX_PHYSICAL_ROWS - 1
361+ fmColumn := 0 #> fmColumn <# screen.MAX_PHYSICAL_COLUMNS - 1
362+ toRow := 0 #> toRow <# screen.MAX_PHYSICAL_ROWS - 1
363+ toColumn := 0 #> toColumn <# screen.MAX_PHYSICAL_COLUMNS - 1
341364 'debug("seg:drwLn fmRC=(", udec_(fmRow), ",", udec_(fmColumn), "), toRC=(", udec_(toRow), ",", udec_(toColumn), "), RGB=(", uhex_long(rgbColor), ")")
342- fmRow := 0 #> fmRow <# screen.MAX_DISPLAY_ROWS - 1
343- fmColumn := 0 #> fmColumn <# screen.MAX_DISPLAY_COLUMNS - 1
344- toRow := 0 #> toRow <# screen.MAX_DISPLAY_ROWS - 1
345- toColumn := 0 #> toColumn <# screen.MAX_DISPLAY_COLUMNS - 1
346365 if fmRow == toRow
347366 ' draw Horizontal Line
348367 repeat column from fmColumn to toColumn
@@ -352,22 +371,53 @@ PUB drawLineOfColor(fmRow, fmColumn, toRow, toColumn, rgbColor) | row, column, d
352371 repeat row from fmRow to toRow
353372 pixels.drawPixelAtRC(row, fmColumn, rgbColor)
354373 else
355- dx := (toColumn - fmColumn)
356- dy := (toRow - fmRow)
357- if (abs(dx) >= abs(dy))
358- incr := abs(dx)
374+ if abs(toRow - fmRow) < abs(toColumn - fmColumn)
375+ if fmColumn > toColumn
376+ plotLineLow(toColumn, toRow, fmColumn, fmRow, rgbColor)
377+ else
378+ plotLineLow(fmColumn, fmRow, toColumn, toRow, rgbColor)
359379 else
360- incr := abs(dy)
361- dx := dx / incr
362- dy := dy / incr
363- column := fmColumn
364- row := fmRow
365- ctr := 1
366- repeat while (ctr <= incr)
367- pixels.drawPixelAtRC(row, column, rgbColor)
368- column += dx
369- row += dy
370- ctr += 1
380+ if fmRow > toRow
381+ plotLineHigh(toColumn, toRow, fmColumn, fmRow, rgbColor)
382+ else
383+ plotLineHigh(fmColumn, fmRow, toColumn, toRow, rgbColor)
384+
385+
386+ PRI plotLineLow(x0, y0, x1, y1, rgbColor) | row, column, dy, dx, D, yi
387+ dx := x1 - x0
388+ dy := y1 - y0
389+ yi := 1
390+ if dy < 0
391+ yi := -1
392+ dy := -dy
393+ D := (2 * dy) - dx
394+ row := y0
395+
396+ repeat column from x0 to x1
397+ pixels.drawPixelAtRC(row, column, rgbColor)
398+ if D > 0
399+ row := row + yi
400+ D := D + (2 * (dy - dx))
401+ else
402+ D := D + 2 * dy
403+
404+ PRI plotLineHigh(x0, y0, x1, y1, rgbColor) | row, column, dy, dx, D, xi
405+ dx := x1 - x0
406+ dy := y1 - y0
407+ xi := 1
408+ if dx < 0
409+ xi := -1
410+ dx := -dx
411+ D := (2 * dx) - dy
412+ column := x0
413+
414+ repeat row from y0 to y1
415+ pixels.drawPixelAtRC(row, column, rgbColor)
416+ if D > 0
417+ column := column + xi
418+ D := D + (2 * (dx - dy))
419+ else
420+ D := D + 2*dx
371421
372422{ -------------- Misc Helpers -------------- }
373423
0 commit comments