@@ -34,6 +34,7 @@ SCROLL_FOREVER = scroller.SCROLL_FOREVER
34
34
SCROLL_ONCE = scroller.SCROLL_ONCE
35
35
SCROLL_ONCE_TO_CLEAR = scroller.SCROLL_ONCE_TO_CLEAR
36
36
37
+ ' FIXME: UNDONE make this user configurable
37
38
MAX_SCROLLING_REGIONS = 3
38
39
39
40
DAT { one or more screens of pixels of 24bit color }
@@ -66,18 +67,31 @@ VAR { Object Instance Variables }
66
67
byte horizontalGapInPix
67
68
byte verticalGapInPix
68
69
byte hBitmapOffsetInPix
70
+ byte bScan_1_4
71
+ byte bSwapRB
69
72
70
- PUB start() : ok | scrollerIndex
73
+ PUB start() : ok | scrollerIndex, dvrConfig, driverConfigRaw
71
74
'' Start the underlying driver(s)
72
75
76
+ ok := cog := -1 ' mark as failed, initially
77
+
73
78
'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
+
74
83
75
- debug("- TEXT: start()")
84
+ debug("dsp: start()")
76
85
ok := cog := panel.start() ' send buffer to driver
77
86
if ok == -1
78
- debug("- TEXT: underlying drivers failed!")
87
+ debug("dsp: underlying drivers failed!")
79
88
abort
80
89
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
+
81
95
' tell all about location of screen buffer
82
96
screen.setScreen(@screen0)
83
97
@@ -104,18 +118,23 @@ PUB clearScreen()
104
118
105
119
PUB fillScreen(rgbColor) | row, column
106
120
'' 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
109
123
pixels.drawPixelAtRC(row, column, rgbColor)
110
124
111
125
PUB fillPanel(threeBitColor)
112
126
'' Fill screen but without PWM (for testing underlying driver)
113
127
panel.fillPanel(threeBitColor)
114
128
115
129
PUB 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)
119
138
120
139
121
140
{ -------------- Text Handling -------------- }
@@ -185,7 +204,7 @@ PUB setTextFont(newFont) | scrollerIndex, hUnusedPix, vUnusedPix
185
204
186
205
selectedTextFont := newFont
187
206
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))
189
208
190
209
' configure our scrollers for font choice
191
210
repeat scrollerIndex from 0 to MAX_SCROLLING_REGIONS - 1
@@ -310,7 +329,7 @@ PRI nextFreeScroller() : scrollerIndexToUse | scrollerIndex
310
329
if scrollerIndexToUse == NOT_FOUND
311
330
debug("Failed to locate free scroller!")
312
331
abort
313
- debug("dsp:nextFreeScroller() ", udec(scrollerIndexToUse))
332
+ ' debug("dsp:nextFreeScroller() ", udec(scrollerIndexToUse))
314
333
315
334
{ -------------- Basic Graphics -------------- }
316
335
@@ -324,25 +343,25 @@ PUB drawBoxOfColor(topRow, leftColumn, width, height, filled, rgbColor) | rightC
324
343
bottomRow := topRow + height - 1
325
344
if filled == TRUE
326
345
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
328
347
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
333
352
334
353
335
354
PUB drawLine(fmRow, fmColumn, toRow, toColumn)
336
355
'' Draw line fromRC -> toRC using current text color (currently limited to horzontal/vertical lines)
337
356
drawLineOfColor(fmRow, fmColumn, toRow, toColumn, currTextColor)
338
357
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
340
359
'' 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
341
364
'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
346
365
if fmRow == toRow
347
366
' draw Horizontal Line
348
367
repeat column from fmColumn to toColumn
@@ -352,22 +371,53 @@ PUB drawLineOfColor(fmRow, fmColumn, toRow, toColumn, rgbColor) | row, column, d
352
371
repeat row from fmRow to toRow
353
372
pixels.drawPixelAtRC(row, fmColumn, rgbColor)
354
373
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)
359
379
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
371
421
372
422
{ -------------- Misc Helpers -------------- }
373
423
0 commit comments