comparison code_part1/OSTC_code_asm_part1/display_lowlevel.asm @ 688:c04e5c18acf9

some cleanups
author heinrichsweikamp
date Sat, 26 Jan 2013 18:22:54 +0100
parents a8a36c85e031
children 59e5998931d3
comparison
equal deleted inserted replaced
687:a8a36c85e031 688:c04e5c18acf9
824 movwf TBLPTRL 824 movwf TBLPTRL
825 movlw HIGH display1_config_table 825 movlw HIGH display1_config_table
826 movwf TBLPTRH 826 movwf TBLPTRH
827 movlw UPPER display1_config_table 827 movlw UPPER display1_config_table
828 movwf TBLPTRU 828 movwf TBLPTRU
829 display_init_loop: 829 display1_init_loop:
830 TBLRD*+ 830 TBLRD*+
831 movlw 0xFF 831 movlw 0xFF
832 cpfseq TABLAT 832 cpfseq TABLAT
833 bra display_config_write ; Write Config pair to Display 833 bra display1_config_write ; Write Config pair to Display
834 ; Delay ms or quit (return) 834 ; Delay ms or quit (return)
835 TBLRD*+ 835 TBLRD*+
836 tstfsz TABLAT ; End of config? 836 tstfsz TABLAT ; End of config?
837 bra $+4 ; No 837 bra $+4 ; No
838 return ; Done. 838 return ; Done.
839 movf TABLAT,W 839 movf TABLAT,W
840 call WAITMSX ; Wait WREG milliseconds 840 call WAITMSX ; Wait WREG milliseconds
841 bra display_init_loop ; Loop 841 bra display1_init_loop ; Loop
842 842
843 display_config_write: ; With command in WREG 843 display1_config_write: ; With command in WREG
844 movf TABLAT,W 844 movf TABLAT,W
845 rcall DISP_CmdWrite ; Write command 845 rcall DISP_CmdWrite ; Write command
846 TBLRD*+ ; Get config 846 TBLRD*+ ; Get config
847 movf TABLAT,W 847 movf TABLAT,W
848 rcall DISP_DataWrite ; Write config 848 rcall DISP_DataWrite ; Write config
849 bra display_init_loop ; Loop 849 bra display1_init_loop ; Loop
850 850
851 851
852 display1_config_table: 852 display1_config_table:
853 ; Reg, Dat or 0xFF, Delay or 0xFF, 0x00 (End) 853 ; Reg, Dat or 0xFF, Delay or 0xFF, 0x00 (End)
854 db 0x96,0x01 854 db 0x96,0x01
984 movlw b'00000000' ; [flipped] X X I/D1 I/D0 X X X AM 984 movlw b'00000000' ; [flipped] X X I/D1 I/D0 X X X AM
985 btfss INDF0,0 ; BANK-SAFE bit test. 985 btfss INDF0,0 ; BANK-SAFE bit test.
986 movlw b'00110000' ; [normal] X X I/D1 I/D0 X X X AM 986 movlw b'00110000' ; [normal] X X I/D1 I/D0 X X X AM
987 rcall DISP_DataWrite 987 rcall DISP_DataWrite
988 988
989 movlw 0x18 989 movlw LOW display0_config_table
990 rcall DISP_CmdWrite 990 movwf TBLPTRL
991 movlw 0x00 991 movlw HIGH display0_config_table
992 rcall DISP_DataWrite 992 movwf TBLPTRH
993 movlw 0x28 993 movlw UPPER display0_config_table
994 rcall DISP_DataWrite 994 movwf TBLPTRU
995 995 rcall display0_init_loop
996 movlw 0xF8 996 rcall DISP_brightness_full ; Gamma settings...
997 rcall DISP_CmdWrite
998 movlw 0x00
999 rcall DISP_DataWrite
1000 movlw 0x0F
1001 rcall DISP_DataWrite
1002
1003 movlw 0xF9
1004 rcall DISP_CmdWrite
1005 movlw 0x00
1006 rcall DISP_DataWrite
1007 movlw 0x0F
1008 rcall DISP_DataWrite
1009
1010 movlw 0x10
1011 rcall DISP_CmdWrite
1012 movlw 0x00
1013 rcall DISP_DataWrite
1014 movlw 0x00
1015 rcall DISP_DataWrite
1016
1017 ; Now Gamma settings...
1018 rcall DISP_brightness_full
1019 ;rcall DISP_brightness_low
1020 ; End Gamma Settings
1021
1022 rcall DISP_ClearScreen 997 rcall DISP_ClearScreen
1023 998 bsf DISPLAY_hv ; OLED volatages on
1024 bsf DISPLAY_hv
1025 WAITMS d'32'
1026 bsf DISPLAY_hv
1027 WAITMS d'32'
1028 bsf DISPLAY_hv
1029
1030 movlw 0x05
1031 rcall DISP_CmdWrite
1032 movlw 0x00
1033 rcall DISP_DataWrite
1034 movlw 0x01
1035 rcall DISP_DataWrite ; Display ON
1036 return 999 return
1000
1001
1002 display0_config_table:
1003 ; Reg, Dat0, Dat1 or 0xFF,0x00,0x00 for end
1004 db 0x18,0x00,0x28,0xF8,0x00,0x0F
1005 db 0xF9,0x00,0x0F,0x10,0x00,0x00
1006 db 0x05,0x00,0x01,0xFF,0x00,0x00
1037 1007
1038 1008
1039 DISP_brightness_full: ; Choose between Eco and High... 1009 DISP_brightness_full: ; Choose between Eco and High...
1040 btfsc DISPLAY_brightness_high ; DISPLAY brightness (=0: Eco, =1: High) 1010 btfsc DISPLAY_brightness_high ; DISPLAY brightness (=0: Eco, =1: High)
1041 bra DISP_brightness_full_high 1011 bra DISP_brightness_full_high
1045 1015
1046 movff win_flags,WREG ; Display1? win_flags is in bank0... 1016 movff win_flags,WREG ; Display1? win_flags is in bank0...
1047 btfsc WREG,1 ; Display1? 1017 btfsc WREG,1 ; Display1?
1048 return ; Yes, done. 1018 return ; Yes, done.
1049 1019
1050 movlw 0x70 1020 movlw LOW display0_gamma_high_table
1051 rcall DISP_CmdWrite 1021 movwf TBLPTRL
1052 movlw 0x1B 1022 movlw HIGH display0_gamma_high_table
1053 rcall DISP_DataWrite 1023 movwf TBLPTRH
1054 movlw 0x80 1024 movlw UPPER display0_gamma_high_table
1055 rcall DISP_DataWrite 1025 movwf TBLPTRU
1056 movlw 0x71 1026 bra display0_init_loop ; And return...
1057 rcall DISP_CmdWrite 1027
1058 movlw 0x1F
1059 rcall DISP_DataWrite
1060 movlw 0x00
1061 rcall DISP_DataWrite
1062 movlw 0x72
1063 rcall DISP_CmdWrite
1064 movlw 0x22
1065 rcall DISP_DataWrite
1066 movlw 0x00
1067 rcall DISP_DataWrite
1068
1069 movlw 0x73
1070 rcall DISP_CmdWrite
1071 movlw 0x17
1072 rcall DISP_DataWrite
1073 movlw 0x11
1074 rcall DISP_DataWrite
1075 movlw 0x74
1076 rcall DISP_CmdWrite
1077 movlw 0x1A
1078 rcall DISP_DataWrite
1079 movlw 0x0E
1080 rcall DISP_DataWrite
1081
1082 movlw 0x75
1083 rcall DISP_CmdWrite
1084 movlw 0x1D
1085 rcall DISP_DataWrite
1086 movlw 0x15
1087 rcall DISP_DataWrite
1088 movlw 0x76
1089 rcall DISP_CmdWrite
1090 movlw 0x18
1091 rcall DISP_DataWrite
1092 movlw 0x11
1093 rcall DISP_DataWrite
1094
1095 movlw 0x77
1096 rcall DISP_CmdWrite
1097 movlw 0x1E
1098 rcall DISP_DataWrite
1099 movlw 0x18
1100 rcall DISP_DataWrite
1101 movlw 0x78
1102 rcall DISP_CmdWrite
1103 movlw 0x1D
1104 rcall DISP_DataWrite
1105 movlw 0x11
1106 rcall DISP_DataWrite
1107 return
1108 1028
1109 DISP_brightness_full_high: 1029 DISP_brightness_full_high:
1110 ; Full 1030 ; Full
1111 bsf PORTB,7 1031 bsf PORTB,7
1112 bsf PORTB,6 1032 bsf PORTB,6
1113 1033
1114 movff win_flags,WREG ; Display1? win_flags is in bank0... 1034 movff win_flags,WREG ; Display1? win_flags is in bank0...
1115 btfsc WREG,1 ; Display1? 1035 btfsc WREG,1 ; Display1?
1116 return ; Yes, done. 1036 return ; Yes, done.
1117 1037
1118 movlw 0x70 1038 movlw LOW display0_gamma_full_table
1119 rcall DISP_CmdWrite 1039 movwf TBLPTRL
1120 movlw 0x1F 1040 movlw HIGH display0_gamma_full_table
1121 rcall DISP_DataWrite 1041 movwf TBLPTRH
1122 movlw 0x00 1042 movlw UPPER display0_gamma_full_table
1123 rcall DISP_DataWrite 1043 movwf TBLPTRU
1124 movlw 0x71 1044 bra display0_init_loop ; And return...
1125 rcall DISP_CmdWrite
1126 movlw 0x23
1127 rcall DISP_DataWrite
1128 movlw 0x80
1129 rcall DISP_DataWrite
1130 movlw 0x72
1131 rcall DISP_CmdWrite
1132 movlw 0x2A
1133 rcall DISP_DataWrite
1134 movlw 0x80
1135 rcall DISP_DataWrite
1136
1137 movlw 0x73
1138 rcall DISP_CmdWrite
1139 movlw 0x15
1140 rcall DISP_DataWrite
1141 movlw 0x11
1142 rcall DISP_DataWrite
1143 movlw 0x74
1144 rcall DISP_CmdWrite
1145 movlw 0x1C
1146 rcall DISP_DataWrite
1147 movlw 0x11
1148 rcall DISP_DataWrite
1149
1150 movlw 0x75
1151 rcall DISP_CmdWrite
1152 movlw 0x1B
1153 rcall DISP_DataWrite
1154 movlw 0x15
1155 rcall DISP_DataWrite
1156 movlw 0x76
1157 rcall DISP_CmdWrite
1158 movlw 0x1A
1159 rcall DISP_DataWrite
1160 movlw 0x15
1161 rcall DISP_DataWrite
1162
1163 movlw 0x77
1164 rcall DISP_CmdWrite
1165 movlw 0x1C
1166 rcall DISP_DataWrite
1167 movlw 0x18
1168 rcall DISP_DataWrite
1169 movlw 0x78
1170 rcall DISP_CmdWrite
1171 movlw 0x21
1172 rcall DISP_DataWrite
1173 movlw 0x15
1174 rcall DISP_DataWrite
1175 return
1176 1045
1177 1046
1178 DISP_brightness_low: 1047 DISP_brightness_low:
1179 ;Low 1048 ;Low
1180 bcf PORTB,7 1049 bcf PORTB,7
1181 bcf PORTB,6 1050 bcf PORTB,6
1182 movff win_flags,WREG ; Display1? win_flags is in bank0... 1051 movff win_flags,WREG ; Display1? win_flags is in bank0...
1183 btfsc WREG,1 ; Display1? 1052 btfsc WREG,1 ; Display1?
1184 return ; Yes, done. 1053 return ; Yes, done.
1185 1054 movlw LOW display0_gamma_low_table
1186 movlw 0x70 1055 movwf TBLPTRL
1187 rcall DISP_CmdWrite 1056 movlw HIGH display0_gamma_low_table
1188 movlw 0x14 1057 movwf TBLPTRH
1189 rcall DISP_DataWrite 1058 movlw UPPER display0_gamma_low_table
1190 movlw 0x00 1059 movwf TBLPTRU
1191 rcall DISP_DataWrite 1060 bra display0_init_loop ; And return...
1192 movlw 0x71 1061
1193 rcall DISP_CmdWrite 1062 display0_init_loop:
1194 movlw 0x17 1063 TBLRD*+
1195 rcall DISP_DataWrite 1064 movlw 0xFF
1196 movlw 0x00 1065 cpfseq TABLAT
1197 rcall DISP_DataWrite 1066 bra display0_config_write ; Write Config pair to Display
1198 movlw 0x72 1067 ; Delay ms or quit (return)
1199 rcall DISP_CmdWrite 1068 TBLRD*+
1200 movlw 0x15 1069 tstfsz TABLAT ; End of config?
1201 rcall DISP_DataWrite 1070 bra $+4 ; No
1202 movlw 0x80 1071 return ; Done.
1203 rcall DISP_DataWrite 1072 movf TABLAT,W
1204 1073 call WAITMSX ; Wait WREG milliseconds
1205 movlw 0x73 1074 bra display0_init_loop ; Loop
1206 rcall DISP_CmdWrite 1075
1207 movlw 0x15 1076 display0_config_write: ; With command in WREG
1208 rcall DISP_DataWrite 1077 movf TABLAT,W
1209 movlw 0x11 1078 rcall DISP_CmdWrite ; Write command
1210 rcall DISP_DataWrite 1079 TBLRD*+ ; Get config
1211 movlw 0x74 1080 movf TABLAT,W
1212 rcall DISP_CmdWrite 1081 rcall DISP_DataWrite ; Write config
1213 movlw 0x14 1082 TBLRD*+ ; Get config
1214 rcall DISP_DataWrite 1083 movf TABLAT,W
1215 movlw 0x0B 1084 rcall DISP_DataWrite ; Write config
1216 rcall DISP_DataWrite 1085 bra display0_init_loop ; Loop
1217 1086
1218 movlw 0x75 1087
1219 rcall DISP_CmdWrite 1088 display0_gamma_high_table:
1220 movlw 0x1B 1089 ; Reg, Dat0, Dat1 or 0xFF,0x00,0x00 for end
1221 rcall DISP_DataWrite 1090 db 0x70,0x1B,0x80,0x71,0x1F,0x00
1222 movlw 0x15 1091 db 0x72,0x22,0x00,0x73,0x17,0x11
1223 rcall DISP_DataWrite 1092 db 0x74,0x1A,0x0E,0x75,0x1D,0x15
1224 movlw 0x76 1093 db 0x76,0x18,0x11,0x77,0x1E,0x18
1225 rcall DISP_CmdWrite 1094 db 0x78,0x1D,0x11,0xFF,0x00,0x00
1226 movlw 0x13 1095
1227 rcall DISP_DataWrite 1096 display0_gamma_full_table:
1228 movlw 0x0E 1097 ; Reg, Dat0, Dat1 or 0xFF,0x00,0x00 for end
1229 rcall DISP_DataWrite 1098 db 0x70,0x1F,0x00,0x71,0x23,0x80
1230 1099 db 0x72,0x2A,0x80,0x73,0x15,0x11
1231 movlw 0x77 1100 db 0x74,0x1C,0x11,0x75,0x1B,0x15
1232 rcall DISP_CmdWrite 1101 db 0x76,0x1A,0x15,0x77,0x1C,0x18
1233 movlw 0x1C 1102 db 0x78,0x21,0x15,0xFF,0x00,0x00
1234 rcall DISP_DataWrite 1103
1235 movlw 0x18 1104 display0_gamma_low_table:
1236 rcall DISP_DataWrite 1105 ; Reg, Dat0, Dat1 or 0xFF,0x00,0x00 for end
1237 movlw 0x78 1106 db 0x70,0x14,0x00,0x71,0x17,0x00
1238 rcall DISP_CmdWrite 1107 db 0x72,0x15,0x80,0x73,0x15,0x11
1239 movlw 0x15 1108 db 0x74,0x14,0x0B,0x75,0x1B,0x15
1240 rcall DISP_DataWrite 1109 db 0x76,0x13,0x0E,0x77,0x1C,0x18
1241 movlw 0x0E 1110 db 0x78,0x15,0x0E,0xFF,0x00,0x00
1242 rcall DISP_DataWrite 1111
1243
1244 return
1245 1112
1246 DISP_set_color:;Converts 8Bit RGB b'RRRGGGBB' into 16Bit RGB b'RRRRRGGG GGGBBBBB' 1113 DISP_set_color:;Converts 8Bit RGB b'RRRGGGBB' into 16Bit RGB b'RRRRRGGG GGGBBBBB'
1247 movwf DISPLAY1_temp ; Get 8Bit RGB b'RRRGGGBB' 1114 movwf DISPLAY1_temp ; Get 8Bit RGB b'RRRGGGBB'
1248 movwf DISPLAY2_temp ; Copy 1115 movwf DISPLAY2_temp ; Copy
1249 1116