comparison code_part1/OSTC_code_asm_part1/oled_samsung.asm @ 146:c09b0be2e1e6

PIXEL_WRITE macros. + obey win_flip_screen flag.
author JeanDo
date Sun, 09 Jan 2011 14:39:09 +0100
parents 8b75ba28d641
children fc699a7460e6
comparison
equal deleted inserted replaced
145:8bda2452a532 146:c09b0be2e1e6
56 call aa_wordprocessor 56 call aa_wordprocessor
57 movlb b'00000001' ; Back to Rambank1 57 movlb b'00000001' ; Back to Rambank1
58 return 58 return
59 59
60 ;============================================================================= 60 ;=============================================================================
61 ; PLED_SetColumnPixel: 61 ; Macro to provides our own interface code.
62 ; 62 ;
63 PLED_SetColumnPixel: 63 PIXEL_WRITE macro colRegister, rowRegister
64 movff WREG,win_leftx2 ; d'0' ... d'159' 64 movff colRegister,win_leftx2
65 mullw 2 ; Copy to PROD, times 2. 65 movff rowRegister,win_top
66 66 call pixel_write
67 movlw 0x21 ; Start Address Vertical (.0 - .319) 67 endm
68 rcall PLED_CmdWrite 68
69 bra PLED_DataWrite_PROD 69 INIT_PIXEL_WROTE macro colRegister
70 70 movff colRegister,win_leftx2
71 ;============================================================================= 71 call init_pixel_write
72 ; PLED_SetRow: 72 endm
73 ; Backup WREG --> win_top, for the next write pixel. 73
74 ; Setup OLED pixel horizontal address. 74 HALF_PIXEL_WRITE macro rowRegister
75 ; 75 movff rowRegister,win_top
76 PLED_SetRow: 76 call half_pixel_write
77 movff WREG,win_top ; d'0' ... d'239' 77 endm
78 mullw 1 ; Copy row to PRODH:L 78
79 movlw 0x20 ; Horizontal Address START:END 79 ;-----------------------------------------------------------------------------
80 rcall PLED_CmdWrite 80 ; Init for half_pixel_write
81 bra PLED_DataWrite_PROD 81 ; Set column register on OLED device, and current color.
82 82 ; Inputs: win_leftx2
83 ;============================================================================= 83 ; Outputs: win_color:2
84 ; PLED Write Two Pixel 84 ; Trashed: WREG, PROD
85 ; 85 init_pixel_write:
86 86 movff win_leftx2,WREG
87 PLED_PxlWrite: 87 mullw 2
88 rcall PLED_PxlWrite_Single ; Write first pixel. 88 rcall pixel_write_col320 ; Start Address Vertical (.0 - .319)
89 89 goto PLED_standard_color
90 ; Write 2nd Pixel on same row but one column to the right 90
91 movff win_top,WREG 91 ;-----------------------------------------------------------------------------
92 rcall PLED_SetRow ; Re-Set Row 92 ; Writes two half-pixels at position (win_top,win_leftx2)
93 movff win_leftx2,WREG ; Increment column address. 93 ; Inputs: win_leftx2, win_top, win_color:2
94 mullw 2 94 ; Trashed: WREG, PROD
95 incf PRODL 95 pixel_write:
96 clrf WREG ; Does not reset CARRY... 96 movff win_leftx2,WREG
97 addwfc PRODH 97 mullw 2
98 movlw 0x21 ; Start Address Vertical (.0 - .319) 98 rcall pixel_write_col320 ; Start Address Vertical (.0 - .319)
99 rcall PLED_CmdWrite 99 rcall half_pixel_write ; Write this half-one.
100 rcall PLED_DataWrite_PROD 100
101 ; Continue with PLED_PxlWrite_Single... 101 movff win_leftx2,WREG ; Address of next one
102 102 mullw 2
103 ; ----------------------------- 103 infsnz PRODL ; +1
104 ; PLED Write One Pixel 104 incf PRODH
105 ; ----------------------------- 105 rcall pixel_write_col320
106 PLED_PxlWrite_Single: 106 bra half_pixel_write ; Note: Cmd 0x20 is mandatory, because
107 movlw 0x22 ; Start Writing Data to GRAM 107 ; of the autoincrement going vertical
108 rcall PLED_CmdWrite 108
109 bsf oled_rs ; Data! 109 ;---- Do the 16bit 319-X-->X, if needed, and send to OLED ------------
110 movff win_color1, PORTD 110 pixel_write_col320:
111 bcf oled_rw 111 movff win_flags,WREG ; BEWARE: bank0 bit-test
112 bsf oled_rw ; Upper 112 btfss WREG,0 ; 180° rotation ?
113 movff win_color2, PORTD 113 bra pixel_write_noflip_H
114 bcf oled_rw 114
115 bsf oled_rw ; Lower 115 movf PRODL,W ; 16bits 319 - PROD --> PROD
116 return 116 sublw LOW(.319) ; 319-W --> W
117 movwf PRODL
118 movf PRODH,W
119 btfss STATUS,C ; Borrow = /CARRY
120 incf WREG
121 sublw HIGH(.319)
122 movwf PRODH
123
124 pixel_write_noflip_H:
125 movlw 0x21 ; Start Address Vertical (.0 - .319)
126 rcall PLED_CmdWrite
127 bra PLED_DataWrite_PROD
128
129 ;-----------------------------------------------------------------------------
130 ; Writes one half-pixel at position (win_top,win_leftx2).
131 ; Inputs: win_leftx2, win_top, win_color:2
132 ; Trashed: WREG, PROD
133 half_pixel_write:
134 movff win_top,WREG ; d'0' ... d'239'
135
136 movff win_flags,PRODL ; BEWARE: bank0 bit-test
137 btfsc PRODL,0 ; 180° rotation ?
138 sublw .239 ; 239-Y --> Y
139
140 mullw 1 ; Copy row to PRODH:L
141 movlw 0x20 ; Horizontal Address START:END
142 rcall PLED_CmdWrite
143 rcall PLED_DataWrite_PROD
144
145 movlw 0x22 ; Start Writing Data to GRAM
146 rcall PLED_CmdWrite
147 bsf oled_rs ; Data!
148 movff win_color1, PORTD
149 bcf oled_rw
150 bsf oled_rw ; Upper
151 movff win_color2, PORTD
152 bcf oled_rw
153 bsf oled_rw ; Lower
154 return
117 155
118 ; ----------------------------- 156 ; -----------------------------
119 ; PLED Display Off 157 ; PLED Display Off
120 ; ----------------------------- 158 ; -----------------------------
121 PLED_DisplayOff: 159 PLED_DisplayOff: