it is. it's the driver component to enable my graphics library to use a sharp memory display.Your lib file looks more like an example file. Is it correct ?
post #1 has typical use demos!
it is. it's the driver component to enable my graphics library to use a sharp memory display.Your lib file looks more like an example file. Is it correct ?
post #1 has typical use demos!
Warning I'm not a teacher
update to ssd1306 include to allow easier configuration for 40x72 displays
eg
Code:'****************************************************************'* Name : SSD1306 FOR PIC 18 DEMO * '* Author : Richard * '* Notice : * '* : * '* Date : 27/12/2023 * '* Version : 1.0 * '* Notes : * '* :18f26k22 @64Mhz * '**************************************************************** #CONFIG CONFIG FOSC = INTIO67 CONFIG PLLCFG = ON CONFIG PRICLKEN = ON CONFIG FCMEN = OFF CONFIG IESO = OFF CONFIG PWRTEN = ON CONFIG BOREN = SBORDIS CONFIG BORV = 190 CONFIG WDTEN = ON CONFIG WDTPS = 32768 CONFIG CCP2MX = PORTC1 CONFIG PBADEN = OFF CONFIG CCP3MX = PORTB5 CONFIG T3CMX = PORTC0 CONFIG HFOFST = ON CONFIG P2BMX = PORTB5 CONFIG MCLRE = EXTMCLR CONFIG STVREN = ON CONFIG LVP = OFF CONFIG XINST = OFF CONFIG DEBUG = OFF CONFIG CP0 = OFF CONFIG CP1 = OFF CONFIG CP2 = OFF CONFIG CP3 = OFF CONFIG CPB = OFF CONFIG CPD = OFF CONFIG WRT0 = OFF CONFIG WRT1 = OFF CONFIG WRT2 = OFF CONFIG WRT3 = OFF CONFIG WRTC = OFF CONFIG WRTB = OFF CONFIG WRTD = OFF CONFIG EBTR0 = OFF CONFIG EBTR1 = OFF CONFIG EBTR2 = OFF CONFIG EBTR3 = OFF CONFIG EBTRB = OFF #ENDCONFIG DEFINE OSC 64 ;set these to match display ssd1306_addr con $78 #DEFINE colours 1 ;1 mono 2 rg or 3 rgb width con 72;128 height con 40;64 h_offset con 28 include "grx.pbpMOD" include "SSD1306.pbpMOD" include "Arial_Narrow18x39.bas" ' include "bignum.bas" ' include "bigchr.bas" BUFF VAR BYTE[10] J VAR word ANSELB=0 ANSELC=0 ANSELA=0 OSCCON=$70 gosub glcd_init gosub grf_clr SETFONT Arial_Narrow18x39 gosub show main: while j <1000 colour=1 fillrect 0,0,72,40 ARRAYWRITE BUFF,[dec2 j/10,":",dec1 j,0] DMDSTR 1,0,buff,0 gosub show pause 10 j=j+1 wend j=0 goto main
Warning I'm not a teacher
Nice and useful addition to a very handy include file.
Though I wonder up to what age you can read that displays without eye glasses...
Ioannis
that's kinda the purpose of this universal graphics method, fonts for it of a good size are simple to make and interchangeableThough I wonder up to what age you can read that displays without eye glasses...
between versions and displays.
a 5x7 font on that display needs a magnifying glass and eye glasses for me.
note i used a 18x39 font to test with. that i can read from many metres away easily
Warning I'm not a teacher
bmp bug fix
Warning I'm not a teacher
Working much better, but in my case it is cropping 6 columns off of the right side of the image (110x64). Using the pbp file I uploaded here
Here are 2 images of what it should look like (using SSDBM vs what is being displayed using DMDBMP.
Shawn
the bmp image width needs to be a multiple of 8 by the look of it
post the original bmp image if you want me to look further into it
Warning I'm not a teacher
Ok, I assume that is due to the horizontal vs vertical byte layout? I know on the SSDBM you said height must be multiple of 8 which I have been adhering to. I'll either stick to using the SSDBM with this driver as it seems to do exactly what I need or revise the bitmaps to make width a multiple of 8.
Shawn
i have had a look at how those programs [lcdassist and glcd tool] manage the remainder bits when a bitmap is not an 8bit multiple in width
and it defeats me , i cannot get how the "stray" bits of the image width are packed into the data
if you lay the data out to match the actual width x height as i have done here
[the last column i filled in manually only partially to get an idea of what the data needs to look like ]
the "left over" 48 bytes at the end somehow represents the extreme rhs 6 bits , i don't see how to extract the data correctly.
6 bits * 48 bytes is 384 bits , the stray 6 bits of width x 64 lines of height is 384 bits so there is enough information at least.
[assuming i have not misconstrued the original image]
Code:OneIcon: '110x64 horiz @ db 112, 0x40 @ db 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,0xfc @ db 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x04 @ db 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x04 @ db 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x04 @ db 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x04 @ db 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x04 @ db 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x04 @ db 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x04 @ db 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x04 @ db 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x04 @ db 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ,0 @ db 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xFF, 0xFF, 0x00, 0x00, 0x00 ,0 @ db 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xFF, 0xFF, 0x80, 0x00, 0x00 ,0 @ db 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xFF, 0xFF, 0x80, 0x00, 0x00,0 @ db 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xFF, 0xFF, 0x80, 0x00, 0x00 ,0 @ db 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xFF, 0xFF, 0xC0, 0x00, 0x00 ,0 @ db 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xFF, 0xFF, 0xC0, 0x00, 0x00 ,0 @ db 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0xE0, 0x00, 0x00 ,0 @ db 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xF0, 0x00, 0x00 ,0 @ db 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xF0, 0x00, 0x00 ,0 @ db 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0xFF, 0xF8, 0x00, 0x00 ,0 @ db 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0xFF, 0xF8, 0x00, 0x00 ,0 @ db 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0xFF, 0xFE, 0x00, 0x00 ,0 @ db 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xFF, 0xFF, 0x00, 0x00 ,0 @ db 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xFF, 0xFF, 0x80, 0x00 ,0 @ db 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xFF, 0xFF, 0x80, 0x00 ,0 @ db 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xFF, 0xFF, 0xC0, 0x00 ,0 @ db 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0xFF, 0xE0, 0x00 ,0 @ db 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xFF, 0xF0, 0x00 ,0 @ db 0x80, 0x00, 0x00, 0x00, 0x00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, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x04 @ db 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x04 @ db 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x04 @ db 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x04 @ db 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x04 @ db 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x04 @ db 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x04 @ db 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x04 @ db 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,0xfc '@ db 0xFC, 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x04, 0x00, 0x03, 0x00, 0x01, 0x00, 0x04, 0x00 '@ db 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, 0x01, 0x00, 0x11, 0x00, 0x00, 0x00, 0x18, 0x00, 0x01, 0x00 '@ db 0x1A, 0x00, 0x04, 0x00, 0x28, 0x00, 0x02, 0x00, 0x38, 0x00, 0x00, 0x00, 0x4A, 0x02, 0x00, 0x00
Warning I'm not a teacher
Is there a way to do 90 degree screen rotation (using the display in portrait mode) for the text using fonts to be displayed correct?
Changing the SSDc $20 address to $01 seems to corrupt everything, so I'm not sure if I am going down the correct path with that, or if there is a simple way to accomplish this already built in?
Last edited by spcw1234; - 24th February 2024 at 16:39.
Shawn
The display layout still isn't quite right. Here is a simple program that displays a 16x16 image in all 4 corners the ones on the left side are good, but the right side locations are wrong.
Code:'PIC18F26K22 #CONFIG CONFIG FOSC = INTIO67 CONFIG PLLCFG = ON CONFIG PRICLKEN = ON CONFIG FCMEN = OFF CONFIG IESO = OFF CONFIG PWRTEN = ON CONFIG BOREN = SBORDIS CONFIG BORV = 190 CONFIG WDTEN = ON CONFIG WDTPS = 32768 CONFIG CCP2MX = PORTC1 CONFIG PBADEN = OFF CONFIG CCP3MX = PORTB5 CONFIG T3CMX = PORTC0 CONFIG HFOFST = ON CONFIG P2BMX = PORTB5 CONFIG MCLRE = EXTMCLR CONFIG STVREN = ON CONFIG LVP = OFF CONFIG XINST = OFF CONFIG DEBUG = OFF CONFIG CP0 = OFF CONFIG CP1 = OFF CONFIG CP2 = OFF CONFIG CP3 = OFF CONFIG CPB = OFF CONFIG CPD = OFF CONFIG WRT0 = OFF CONFIG WRT1 = OFF CONFIG WRT2 = OFF CONFIG WRT3 = OFF CONFIG WRTC = OFF CONFIG WRTB = OFF CONFIG WRTD = OFF CONFIG EBTR0 = OFF CONFIG EBTR1 = OFF CONFIG EBTR2 = OFF CONFIG EBTR3 = OFF CONFIG EBTRB = OFF #ENDCONFIG DEFINE OSC 64 clear ssd1306_addr con $78 #DEFINE colours 1 ;1 mono 2 rg or 3 rgb width con 128 height con 64 h_offset con 0 include "grx.pbpMOD" include "SSD1306.pbpMOD" BUFF VAR BYTE[32] ANSELB=0 ANSELC=0 ANSELA=0 OSCCON=$70 OSCTUNE.6=1 gosub glcd_init gosub grf_clr gosub show main: ' Rotate icon clockwise around display corners DMDBMP 0,0,TestIcon 'top left 16x16 CORRECT PLACEMENT! gosub show pause 1000 gosub grf_clr gosub show DMDBMP 111,0,TestIcon 'top right 16x16 WRONT PLACEMENT! gosub show pause 1000 gosub grf_clr gosub show DMDBMP 111,47,TestIcon 'bottom right 16x16 WRONG PLACEMENT! gosub show pause 1000 gosub grf_clr gosub show DMDBMP 0,47,TestIcon 'bottom left 16x16 CORRECT PLACEMENT! gosub show pause 1000 gosub grf_clr gosub show goto main end TestIcon: @ db 0x10,0x10 ;16x16 @ db 0xFF,0xFF; @ db 0xC0,0x03; @ db 0xA0,0x05; @ db 0x90,0x09; @ db 0x88,0x11; @ db 0x84,0x21; @ db 0x82,0x41; @ db 0x81,0x81; @ db 0x81,0x81; @ db 0x82,0x41; @ db 0x84,0x21; @ db 0x88,0x11; @ db 0x90,0x09; @ db 0xA0,0x05; @ db 0xC0,0x03; @ db 0xFF,0xFF;
Last edited by spcw1234; - 24th February 2024 at 19:04. Reason: Added images
Shawn
bmp placement fixed , note that horiz placement is byte aligned ie for a 128 bit wide display there are 16 bytes therefore 16 positions max
Warning I'm not a teacher
Excellent! All seems to be working perfectly!
Now, how can I rotate the display for use in portrait mode?
Shawn
in theory portrait mode should be easier and faster than what i have now, the screen width 64 height 128
and the buffer sent to the screen in horiz fill mode nice and sequentially [ might need bit reversal, could be upside down or mirrored]
i will have a look one day time permitting
Warning I'm not a teacher
a portrait version
Code:'******************************************************************* '* Name : SSD1306p.pbpmod * '* Author : richard * '* Notice : Copyright (c) 2021 * '* : * '* Date : 28/12/2023 * '* Version : 1.1 * '* Notes : generic GRX graphics DRIVER FOR SSD1306 * '* : HW I2C PIC18 ONLY * '* : 40x72 disp added * '* : portrait version * '* : * '* : * '********************************************************************** ;set these to match display IN MAIN ' ssd1306_addr con $78 ' #DEFINE colours 1 ;1 mono 2 rg or 3 rgb ' width con 128 ' height con 32 ' h_offset con 0 ;28 for 40x72 glrot var byte[8] glrb var byte[8] gltmp var byte[3] glcd_rad var WORD glcdData VAR byte 'DATA glcdBC VAR BYTE 'gca var page VAR WORD 'gca var gy var byte 'gca pg address gy_ var byte 'gca pg address gx var byte 'gca row address gx_ var byte 'gca row address ssd_add var byte USERCOMMAND "SENDBYTE" ;BYTE USERCOMMAND "SSDC" ;cmd BYTE TO SSD1306 ssdheight con WIDTH/8-1 ; 7 = 8 PAGES 64*128 , 3 = 4 pages 32*128 ssdwidth con HEIGHT-1 ; 128 PIXELS WIDE goto overssd ASM SSDC?C macro Cin MOVE?CB Cin , _glcdData L?CALL _cmd_byte endm SSDC?B macro Cin MOVE?BB Cin , _glcdData L?CALL _cmd_byte endm SENDBYTE?B macro Dat MOVE?BB Dat ,_glcdData L?CALL _send_byte endm SENDBYTE?W macro Dat MOVE?WB Dat ,_glcdData L?CALL _send_byte endm SENDBYTE?C macro Dat MOVE?CB Dat ,_glcdData L?CALL _send_byte endm ENDASM glcd_init: bgcolour = 0 colour = 1 SSPSTAT = 0 'High Speed Filter SSPADD = $14'400 kHz @64 MHz ? SSPCON1 = 101000 'I2C Master Mode Enable SSPCON3 = 0 ssd_add = ssd1306_addr SSDc $AE ' Display OFF SSDc $d5 SSDc $80 SSDc $a8 : SSDc $3f SSDc $D3 : SSDc $00 ; Set Display Offset Mode Set 0 if ssdheight > 4 then SSDc $40 ' Set display start line 0 elseif ssdheight > 3 then SSDc $68 ' Set display start line else SSDc $60 ' Set display start line 4 endif SSDc $8D : SSDc $14 ' Set Charge Pump Internal SSDc $20 : SSDc $01 ' Adressing mode Horizontal SSDc $A1 ' set segment remap column 127 as start SSDc $C0 ' Com Scan Direction, Flip display vertically SSDc $DA ' set COM pins if ssdheight > 3 then SSDc$12 ' set COM pins = 128x64=$12 else SSDc$02 ' set COM pins = 128x32=$02 endif SSDc $81 : SSDc$7F ' Set brightness to $01 to $FF ($7F is default, $01 is faint) SSDc $DB : SSDc$40 ' Set VCOM Deselect Level SSDc $B0 ' Set Page Address From $B0 to $B7 SSDc $2e ; scroll off SSDc $A4 ' display ON continue SSDc $A6 ' $A6=NORMAL MODE; $A7=INVERSE MODE SSDc $AF ' Display ON return show: ' gosub flip SSDc $22 SSDc 0 SSDc ssdheight SSDc $21 SSDc h_offset SSDc ssdwidth + h_offset SSPCON2.0 = 1 ; SEN - Start Condition Enable Bit WHILE SSPCON2.0 = 1 : WEND ; Wait for Start to complete SSPBUF = ssd_add ; Move data to SSPBUF WHILE SSP1STAT.2 = 1 : WEND ; SSPSTAT = 1 Transmit in progress While SSP1CON2.6 = 1 : WEND ; Wait for Acknowledge from slave SSPBUF = $40 ; Move data to SSPBUF WHILE SSPSTAT.2 = 1 : WEND ; SSPSTAT = 1 Transmit in progress While SSPCON2.6 = 1 : WEND ; Wait for Acknowledge from slave for glcd_rad = 0 to width/8 * height -1 SENDBYTE fbr[glcd_rad ] next SSPCON2.2 = 1 ' gosub flip return send_byte : 'DATA SSPBUF = glcdData; Move data to SSPBUF WHILE SSPSTAT.2 = 1 : WEND ; SSPSTAT = 1 Transmit in progress While SSPCON2.6 = 1 : WEND ; Wait for Acknowledge from slave return cmd_byte: 'send command sequence "glcdData " SSPCON2.0 = 1 ; SEN - Start Condition Enable Bit WHILE SSPCON2.0 = 1 : WEND ; Wait for Start to complete SSPBUF = ssd_add ; Move data to SSPBUF WHILE SSPSTAT.2 = 1 : WEND ; SSPSTAT = 1 Transmit in progress While SSPCON2.6 = 1 : WEND ; Wait for Acknowledge from slave SSPBUF = 0 ; Move data to SSPBUF WHILE SSPSTAT.2 = 1 : WEND ; SSPSTAT = 1 Transmit in progress While SSPCON2.6 = 1 : WEND ; Wait for Acknowledge from slave SSPBUF = glcdData ; Move data to SSPBUF WHILE SSPSTAT.2 = 1 : WEND ; SSPSTAT = 1 Transmit in progress While SSPCON2.6 = 1 : WEND ; Wait for Acknowledge from slave SSPCON2.2 = 1 ; PEN - send stop bit While SSP1CON2.2 = 1 : Wend ; Wait for SSP to complete return overssd:
with demo
Code:'PIC18F26K22#CONFIG CONFIG FOSC = INTIO67 CONFIG PLLCFG = ON CONFIG PRICLKEN = ON CONFIG FCMEN = OFF CONFIG IESO = OFF CONFIG PWRTEN = ON CONFIG BOREN = SBORDIS CONFIG BORV = 190 CONFIG WDTEN = ON CONFIG WDTPS = 32768 CONFIG CCP2MX = PORTC1 CONFIG PBADEN = OFF CONFIG CCP3MX = PORTB5 CONFIG T3CMX = PORTC0 CONFIG HFOFST = ON CONFIG P2BMX = PORTB5 CONFIG MCLRE = EXTMCLR CONFIG STVREN = ON CONFIG LVP = OFF CONFIG XINST = OFF CONFIG DEBUG = OFF CONFIG CP0 = OFF CONFIG CP1 = OFF CONFIG CP2 = OFF CONFIG CP3 = OFF CONFIG CPB = OFF CONFIG CPD = OFF CONFIG WRT0 = OFF CONFIG WRT1 = OFF CONFIG WRT2 = OFF CONFIG WRT3 = OFF CONFIG WRTC = OFF CONFIG WRTB = OFF CONFIG WRTD = OFF CONFIG EBTR0 = OFF CONFIG EBTR1 = OFF CONFIG EBTR2 = OFF CONFIG EBTR3 = OFF CONFIG EBTRB = OFF #ENDCONFIG DEFINE OSC 64 clear ssd1306_addr con $78 #DEFINE colours 1 ;1 mono 2 rg or 3 rgb width con 64 height con 128 h_offset con 0 DEFINE DEBUG_REG PORTB DEFINE DEBUG_BIT 7 DEFINE DEBUG_BAUD 9600 DEFINE DEBUG_MODE 0 LATB.7=1 trisb.7=0 include "grx.pbpMOD" include "SSD1306p.pbpMOD" include "font.bas" BUFF VAR BYTE[32] ANSELB=0 ANSELC=0 ANSELA=0 OSCCON=$70 OSCTUNE.6=1 SETFONT FONT5x7 gosub glcd_init main: gosub grf_clr gosub show ARRAYWRITE BUFF,["GLCD",0] DMDSTR 3,75,buff,1 DMDBMP 0,0,TestIcon gosub show pause 5000 goto main end TestIcon: @ db 0x10,0x10 ;16x16 @ db 0xFF,0xFF; @ db 0xC0,0x03; @ db 0xA0,0x05; @ db 0x90,0x09; @ db 0x88,0x11; @ db 0x84,0x21; @ db 0x82,0x41; @ db 0x81,0x81; @ db 0x81,0x81; @ db 0x82,0x41; @ db 0x84,0x21; @ db 0x88,0x11; @ db 0x90,0x09; @ db 0xA0,0x05; @ db 0xC0,0x03; @ db 0xFF,0xFF;
Warning I'm not a teacher
Excellent work Richard!!!
This will work well for my use, but with a little more tweaking it would be nice to have a define to set 1 of 4 different viewing directions to make a more universal driver.
Shawn
Bookmarks