timerlan |
Дата: Ср, 27.04.2016, 04:23 | Сообщение # 32 |
Группа:
Проверенные
Ранг:
Понимаю
Сообщений:
94
Замечания:
±
На сайте с 18.03.2012
Статус:
Offline
|
Matrix252005, ага уже увидел!))
вот преобразованный код, выводящий самвол А на дисплей, положение его указывается значениями
Код Xpos, от (0 до 127) и Ypos от (0 до 7)
[b]Добавлено (27.04.2016, 04:09) --------------------------------------------- ADCON0=0 ADCON1=6 TRISA = 255
'=================== SSD1306 ADDRESS AND CONSTANTS ======================== addr CON $78 ' Normally $78 DeviceCommand CON $00 DataCommand CON $40
'========================= SSD Variables ================================== SCL var PortC.3 ' I2C Clock PortC.3 move if using more than one I2C device SDA var PortC.4 ' I2C Data PortC.4 move if using more than one I2C device BUTT var PORTA.1
Temp var byte ByteSend vAR BYTE ' Prepared byte to be sent to Display ByteSend2 VAR BYTE ' Prepared Byte to be sent to Display Xpos VAR BYTE ' LCD Column POSITION (0 TO 127) Ypos VAR BYTE ' LCD Line POSITION FOR PAGE MODE(0 TO 7)
gosub LcdInit pause 100
LCD:
Xpos=10 Ypos=2 gosub SetXY I2CWrite SDA,SCL,addr,[DataCommand,$7C,$12,$11,$12,$7C]
goto lcd
'===============================init====================================== LcdInit:
ByteSend=$AE GOSUB SendCommand ' Display OFF
ByteSend=$D3 ByteSend2=$00 GOSUB SendCommand2 ' Set offset to 0
ByteSend=$8D ByteSend2=$14 GOSUB SendCommand2 ' Set Charge Pump Internal, usually needed
ByteSend=$20 ByteSend2=$10 GOSUB SendCommand2 ' Adressing mode $10=Page, $00=Horizontal
ByteSend=$A1 GOSUB SendCommand ' set segment remap column 127 as start
ByteSend=$C8 GOSUB SendCommand ' Com Scan Direction, Flip display vertically
ByteSend=$DA ByteSend2=$12 GOSUB SendCommand2 ' set COM pins = 128x64=$12 128x32=$02
ByteSend=$81 ByteSend2=$ff GOSUB SendCommand2 ' Set contrast to $01 to $FF ($7F is default, $01 is faint)
ByteSend=$A4 GOSUB SendCommand ' display ON continue
ByteSend=$A6 GOSUB SendCommand ' $A6=NORMAL MODE; $A7=INVERSE MODE
ByteSend=$AF GOSUB SendCommand ' Display ON
pause 100 ' look for random bytes. Remove if you would like GOSUB LcdClr return '=================================setxy======================================= SetXY:
ByteSend=$21 GOSUB SendCommand
ByteSend=xpos GOSUB SendCommand
ByteSend=127 GOSUB SendCommand
ByteSend=$22 GOSUB SendCommand
ByteSend=ypos GOSUB SendCommand
ByteSend=ypos GOSUB SendCommand
RETURN '====================================clear==================================== LcdClr: Xpos=0 FOR ypos=0 TO 7 gosub SetXY FOR Temp=0 TO 127 I2CWrite SDA,SCL,addr,[DataCommand,0] NEXT Temp NEXT ypos xpos=0 : ypos=0 : gosub SetXY ' Go Home RETURN
'===================== Send data ============================================= SendData: I2CWrite SDA,SCL,addr,[DataCommand,ByteSend] RETURN '==================== Send Command =========================================== SendCommand: I2CWrite SDA,SCL,addr,[DeviceCommand,ByteSend] RETURN '==================== Send Command =========================================== SendCommand2: I2CWrite SDA,SCL,addr,[DeviceCommand,ByteSend,ByteSend2] RETURN
Добавлено (27.04.2016, 04:23) --------------------------------------------- и картинка на весь экран-"мальтийский крест", преобразованный в программе LCD_CONVERTER
Код ADCON0=0 ADCON1=6 TRISA = 255
'=================== SSD1306 ADDRESS AND CONSTANTS ======================== addr CON $78 ' Normally $78 DeviceCommand CON $00 DataCommand CON $40
'========================= SSD Variables ================================== SCL var PortC.3 ' I2C Clock PortC.3 move if using more than one I2C device SDA var PortC.4 ' I2C Data PortC.4 move if using more than one I2C device BUTT var PORTA.1
Temp var byte ByteSend vAR BYTE ' Prepared byte to be sent to Display ByteSend2 VAR BYTE ' Prepared Byte to be sent to Display Xpos VAR BYTE ' LCD Column POSITION (0 TO 127) Ypos VAR BYTE ' LCD Line POSITION FOR PAGE MODE(0 TO 7)
gosub LcdInit pause 100
LCD:
Xpos=0 Ypos=0 gosub SetXY I2CWrite SDA,SCL,addr,[DataCommand,$00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,_ $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $0E, $1F,_ $1F, $1F, $3B, $3B, $73, $F6, $F6, $E6, $86, $86, $86, $0E, $0E, $0E, $0E, $0E,_ $8E, $8C, $8C, $9C, $9C, $9C, $9C, $9C, $9C, $9C, $9C, $9C, $98, $98, $98, $98,_ $98, $98, $98, $98, $9C, $9C, $9C, $9C, $9C, $9C, $9C, $9C, $9C, $9C, $9C, $8C,_ $8E, $8E, $0E, $0E, $0E, $8E, $86, $86, $E6, $F6, $F6, $F3, $3B, $3B, $1F, $1F,_ $1F, $0E, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,_ $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00]
Xpos=0 Ypos=1 gosub SetXY I2CWrite SDA,SCL,addr,[DataCommand,$00, $80, $80, $80, $80, $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00,_ $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,_ $00, $00, $00, $00, $00, $00, $00, $01, $07, $07, $0F, $3E, $3E, $7C, $F8, $F8,_ $E0, $C3, $C3, $0F, $3F, $3F, $7F, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF,_ $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $3F, $3F, $0F, $87, $87, $E1,_ $F8, $F8, $7C, $3E, $3E, $0F, $07, $07, $01, $00, $00, $00, $00, $00, $00, $00,_ $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,_ $00, $00, $00, $00, $00, $00, $00, $00, $00, $80, $80, $80, $80, $80, $80, $00]
Xpos=0 Ypos=2 gosub SetXY I2CWrite SDA,SCL,addr,[DataCommand,$03, $0F, $0F, $7F, $FD, $FD, $E3, $07, $07, $07, $0E, $0E, $0C, $1C, $1C, $38,_ $38, $38, $78, $70, $70, $60, $60, $60, $C0, $C0, $C0, $C0, $C0, $C0, $80, $80,_ $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $01, $01,_ $07, $3F, $3F, $FF, $F8, $F8, $C0, $01, $01, $0F, $FF, $FF, $FF, $FF, $FF, $FF,_ $FF, $FF, $FF, $FF, $FF, $FF, $1F, $03, $03, $C0, $F8, $F8, $FE, $7F, $7F, $0F,_ $01, $01, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $80, $80,_ $80, $80, $C0, $C0, $C0, $C0, $C0, $C0, $E0, $E0, $60, $70, $70, $78, $38, $38,_ $38, $9C, $9C, $0C, $0E, $0E, $0F, $07, $07, $C3, $F9, $F9, $FF, $1F, $1F, $07]
Xpos=0 Ypos=3 gosub SetXY I2CWrite SDA,SCL,addr,[DataCommand,$00, $00, $00, $00, $0F, $0F, $FF, $FF, $FF, $80, $00, $00, $00, $00, $00, $FF,_ $FF, $FF, $FE, $FE, $FE, $FE, $FE, $FE, $FC, $FC, $FC, $FD, $F9, $F9, $FB, $F3,_ $F3, $F3, $F3, $F3, $F3, $F3, $F3, $F6, $F6, $F6, $E6, $E6, $E6, $EE, $EE, $EE,_ $EE, $EE, $EE, $CF, $CF, $CF, $CF, $CC, $CC, $C0, $C0, $C0, $FF, $FF, $FF, $FF,_ $FF, $FF, $FF, $FF, $C1, $C1, $C0, $D8, $D8, $CF, $CF, $CF, $CF, $CE, $CE, $EE,_ $EE, $EE, $EE, $E6, $E6, $E6, $F6, $F6, $F6, $F3, $F3, $F3, $F3, $F3, $F3, $F3,_ $F3, $FB, $F9, $F9, $F9, $FD, $FD, $FC, $FE, $FE, $FE, $FE, $FE, $FE, $FF, $FF,_ $FF, $01, $01, $00, $00, $00, $00, $FE, $FE, $FF, $3F, $3F, $00, $00, $00, $00]
Xpos=0 Ypos=4 gosub SetXY I2CWrite SDA,SCL,addr,[DataCommand,$00, $00, $00, $00, $F0, $F0, $FF, $FF, $FF, $03, $00, $00, $00, $80, $80, $FF,_ $FF, $FF, $FF, $7F, $7F, $7F, $7F, $7F, $3F, $BF, $BF, $9F, $9F, $9F, $9F, $9F,_ $9F, $DF, $CF, $CF, $CF, $EF, $EF, $EF, $E7, $E7, $E7, $77, $77, $77, $77, $77,_ $73, $73, $73, $F3, $F3, $F3, $F3, $13, $13, $03, $03, $03, $FF, $FF, $FF, $FF,_ $FF, $FF, $FF, $FF, $83, $83, $03, $13, $13, $F3, $F3, $F3, $F3, $73, $73, $73,_ $77, $77, $77, $77, $77, $67, $E7, $E7, $EF, $EF, $EF, $CF, $CF, $CF, $DF, $9F,_ $9F, $9F, $9F, $9F, $9F, $BF, $BF, $3F, $7F, $7F, $7F, $7F, $7F, $FF, $FF, $FF,_ $FF, $80, $80, $00, $00, $00, $00, $FF, $FF, $FF, $F0, $F0, $00, $00, $00, $00]
Xpos=0 Ypos=5 gosub SetXY I2CWrite SDA,SCL,addr,[DataCommand,$C0, $F8, $F8, $FF, $BF, $BF, $C7, $E0, $E0, $E0, $70, $70, $30, $38, $38, $3C,_ $1C, $1C, $0C, $0E, $0E, $06, $07, $07, $07, $07, $07, $03, $03, $03, $01, $01,_ $01, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,_ $E0, $FC, $FC, $FF, $3F, $3F, $07, $C0, $C0, $F8, $FF, $FF, $FF, $FF, $FF, $FF,_ $FF, $FF, $FF, $FF, $FF, $FF, $F8, $C0, $C0, $03, $1F, $1F, $7F, $FC, $FC, $E0,_ $80, $80, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $01,_ $01, $01, $03, $03, $03, $03, $03, $07, $07, $07, $06, $0E, $0E, $0C, $1C, $1C,_ $3C, $38, $38, $30, $70, $70, $E0, $E0, $E0, $C7, $BF, $BF, $FF, $F8, $F8, $E0]
Xpos=0 Ypos=6 gosub SetXY I2CWrite SDA,SCL,addr,[DataCommand,$00, $01, $01, $01, $01, $01, $01, $01, $01, $00, $00, $00, $00, $00, $00, $00,_ $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,_ $00, $00, $00, $00, $00, $00, $00, $C0, $C0, $C0, $F0, $78, $78, $3E, $1F, $1F,_ $8F, $C1, $C1, $F0, $F8, $F8, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF,_ $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $FF, $F8, $F8, $F0, $C1, $C1, $87,_ $1F, $1F, $3E, $78, $78, $F0, $C0, $C0, $C0, $00, $00, $00, $00, $00, $00, $00,_ $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,_ $00, $00, $00, $00, $00, $00, $00, $01, $01, $01, $01, $01, $01, $01, $01, $00]
Xpos=0 Ypos=7 gosub SetXY I2CWrite SDA,SCL,addr,[DataCommand,$00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,_ $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $70, $F0,_ $F0, $F8, $DC, $DC, $FE, $EF, $EF, $E3, $73, $73, $71, $70, $70, $70, $30, $30,_ $31, $31, $31, $31, $31, $31, $31, $11, $11, $11, $19, $19, $19, $19, $19, $19,_ $19, $19, $19, $19, $11, $11, $11, $31, $31, $31, $31, $31, $31, $31, $31, $31,_ $70, $70, $70, $70, $70, $71, $63, $63, $E3, $EF, $EF, $FE, $DC, $DC, $F8, $F0,_ $F0, $F0, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00,_ $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00]
goto lcd
'===============================init====================================== LcdInit:
ByteSend=$AE GOSUB SendCommand ' Display OFF
ByteSend=$D3 ByteSend2=$00 GOSUB SendCommand2 ' Set offset to 0
ByteSend=$8D ByteSend2=$14 GOSUB SendCommand2 ' Set Charge Pump Internal, usually needed
ByteSend=$20 ByteSend2=$10 GOSUB SendCommand2 ' Adressing mode $10=Page, $00=Horizontal
ByteSend=$A1 GOSUB SendCommand ' set segment remap column 127 as start
ByteSend=$C8 GOSUB SendCommand ' Com Scan Direction, Flip display vertically
ByteSend=$DA ByteSend2=$12 GOSUB SendCommand2 ' set COM pins = 128x64=$12 128x32=$02
ByteSend=$81 ByteSend2=$ff GOSUB SendCommand2 ' Set contrast to $01 to $FF ($7F is default, $01 is faint)
ByteSend=$A4 GOSUB SendCommand ' display ON continue
ByteSend=$A6 GOSUB SendCommand ' $A6=NORMAL MODE; $A7=INVERSE MODE
ByteSend=$AF GOSUB SendCommand ' Display ON
pause 100 ' look for random bytes. Remove if you would like GOSUB LcdClr return '=================================setxy======================================= SetXY:
ByteSend=$21 GOSUB SendCommand
ByteSend=xpos GOSUB SendCommand
ByteSend=127 GOSUB SendCommand
ByteSend=$22 GOSUB SendCommand
ByteSend=ypos GOSUB SendCommand
ByteSend=ypos GOSUB SendCommand
RETURN '====================================clear==================================== LcdClr: Xpos=0 FOR ypos=0 TO 7 gosub SetXY FOR Temp=0 TO 127 I2CWrite SDA,SCL,addr,[DataCommand,0] NEXT Temp NEXT ypos xpos=0 : ypos=0 : gosub SetXY ' Go Home RETURN
'===================== Send data ============================================= SendData: I2CWrite SDA,SCL,addr,[DataCommand,ByteSend] RETURN '==================== Send Command =========================================== SendCommand: I2CWrite SDA,SCL,addr,[DeviceCommand,ByteSend] RETURN '==================== Send Command =========================================== SendCommand2: I2CWrite SDA,SCL,addr,[DeviceCommand,ByteSend,ByteSend2] RETURN
МК 16F877A 4Mhz
всем спасибо за советы и пинки в нужном направлении,заработало))
Сообщение отредактировал
timerlan - Ср, 27.04.2016, 04:11
|
|
|
|