# HG changeset patch # User Paul Boddie # Date 1495144222 -7200 # Node ID 81ee57d5c0829e8c6a7e1fbf7cbf90d59d5e8076 # Parent 27660220db5a93774830afa973fa461493deddd5 Switched to using a I0RRGGBB colour representation. diff -r 27660220db5a -r 81ee57d5c082 README.txt --- a/README.txt Thu May 18 01:58:26 2017 +0200 +++ b/README.txt Thu May 18 23:50:22 2017 +0200 @@ -1,3 +1,26 @@ +Introduction +------------ + +The VGAPIC32 project provides software and circuit information to generate an +analogue VGA signal from a PIC32 microcontroller. + +Contact, Copyright and Licence Information +------------------------------------------ + +The author can be contacted at the following e-mail address: + +paul@boddie.org.uk + +Copyright and licence information can be found in the docs directory - see +docs/COPYING.txt and docs/gpl-3.0.txt for more information. + + + +Hardware Details +================ + +The pin usage of this solution is documented below. + PIC32MX270F256B-50I/SP Pin Assignments -------------------------------------- @@ -21,14 +44,23 @@ Data Signal Routing ------------------- -D7 -> 220R -> R +For one bit of intensity, two bits per colour channel: + +D7 -> 2200R -> I + +I -> diode -> R -> diode -> D7 +I -> diode -> G -> diode -> D7 +I -> diode -> B -> diode -> D7 + D6 (not connected) + D5 -> 470R -> R -D4 -> 470R -> G -D3 -> 1000R -> G -D2 -> 2200R -> G -D1 -> 220R -> B -D0 -> 470R -> B +D4 -> 1000R -> R +D3 -> 470R -> G +D2 -> 1000R -> G +D1 -> 470R -> B +D0 -> 1000R -> B + HSYNC -> 3.3V:5V -> HS VSYNC -> 3.3V:5V -> VS @@ -58,3 +90,5 @@ http://papilio.cc/index.php?n=Papilio.VGAWing http://lucidscience.com/pro-vga%20video%20generator-2.aspx + +https://sites.google.com/site/h2obsession/CBM/C128/rgbi-to-vga diff -r 27660220db5a -r 81ee57d5c082 tools/makeimage.py --- a/tools/makeimage.py Thu May 18 01:58:26 2017 +0200 +++ b/tools/makeimage.py Thu May 18 23:50:22 2017 +0200 @@ -2,7 +2,7 @@ """ Convert images for display in an Acorn Electron MODE 2 variant with a pixel -layout of R0RGGGBB, giving 128 colours instead of the usual 8 colours. +layout of I0RRGGBB, giving 128 colours instead of the usual 8 colours. Copyright (C) 2015, 2017 Paul Boddie @@ -17,12 +17,6 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . - ----- - -ImageMagick can be used to dither images to a 232 palette before conversion: - -convert in.png -ordered-dither threshold,4,8,4 out.png """ from os.path import split, splitext @@ -76,15 +70,19 @@ else: r, g, b = data.next() + rm, gm, bm, i = get_values(r, g, b) + + # Encode the byte value: I0RRGGBB. + word.insert(0, - # R<7> -> D<7> - (r & 0x80) | - # R<6> -> D<5> - ((r & 0x40) >> 1) | - # G<7:5> -> D<4:2> - ((g >> 5) << 2) | + # I -> D<7> + (i << 7) | + # R<7:6> -> D<5:4> + (rm >> 2) | + # G<7:6> -> D<3:2> + (gm >> 4) | # B<7:6> -> D<1:0> - (b >> 6)) + (bm >> 6)) flush_word(f, word) x += 1 @@ -96,11 +94,28 @@ finally: f.close() +def get_values(r, g, b): + + "Return modified values for 'r', 'g' and 'b', plus an intensity bit." + + rm = r & 0xc0 + gm = g & 0xc0 + bm = b & 0xc0 + rd = r - rm + gd = g - gm + bd = b - bm + i = ((rd ** 2 + gd ** 2 + bd ** 2) ** 0.5) >= 32 and 1 or 0 + return rm, gm, bm, i + def make_preview(im): imp = PIL.Image.new("RGB", im.size) data = [] for r, g, b in im.getdata(): - data.append((((r >> 6) << 6), ((g >> 5) << 5), (b >> 6) << 6)) + rm, gm, bm, i = get_values(r, g, b) + r = rm + (i * 32) + g = gm + (i * 32) + b = bm + (i * 32) + data.append((r, g, b)) imp.putdata(data) return imp