Mercurial > public > hwos_code
comparison src/tft.inc @ 0:11d4fc797f74
init
| author | heinrichsweikamp |
|---|---|
| date | Wed, 24 Apr 2013 19:22:45 +0200 |
| parents | |
| children | ec4d8503ec45 |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:11d4fc797f74 |
|---|---|
| 1 ;============================================================================= | |
| 2 ; | |
| 3 ; File tft.inc | |
| 4 ; | |
| 5 ; Declaring interfaces to the TFT screen and its Oxxx controler | |
| 6 ; | |
| 7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved. | |
| 8 ;============================================================================= | |
| 9 ; HISTORY | |
| 10 ; 2011-05-24 : [jDG] Cleanups from initial Matthias code. | |
| 11 | |
| 12 ;============================================================================= | |
| 13 ; TFT public subroutines | |
| 14 ;============================================================================= | |
| 15 | |
| 16 ; Writes two half-pixels at position (win_top,win_leftx2) | |
| 17 ; Inputs: win_leftx2, win_top, win_color:2 | |
| 18 ; Trashed: WREG, PROD | |
| 19 extern pixel_write | |
| 20 | |
| 21 ;----------------------------------------------------------------------------- | |
| 22 ; Writes one half-pixel at position (win_top,win_leftx2). | |
| 23 ; Inputs: win_leftx2, win_top, win_color:2 | |
| 24 ; Trashed: WREG, PROD | |
| 25 extern half_pixel_write | |
| 26 | |
| 27 ;----------------------------------------------------------------------------- | |
| 28 ; TFT_frame : draw a frame around current box with current color. | |
| 29 ; Inputs: win_top, win_leftx2, win_height, win_width, win_color1, win_color2 | |
| 30 ; Outputs: (none) | |
| 31 ; Trashed: WREG, PROD, aa_start:2, aa_end:2, win_leftx2, win_width:1 | |
| 32 extern TFT_frame | |
| 33 | |
| 34 ;----------------------------------------------------------------------------- | |
| 35 extern TFT_DisplayOff ; Power-off everything (need a boot next) | |
| 36 extern TFT_boot ; Initialize screen hardware | |
| 37 extern TFT_Display_FadeIn ; Smooth lighting | |
| 38 extern TFT_Display_FadeOut ; Smooth darkening | |
| 39 extern TFT_ClearScreen | |
| 40 extern TFT_box_write | |
| 41 extern TFT_box | |
| 42 extern TFT_DataWrite_PROD | |
| 43 extern TFT_set_color | |
| 44 extern init_pixel_write | |
| 45 extern pixel_write | |
| 46 extern pixel_write_col320 | |
| 47 extern half_vertical_line | |
| 48 extern half_horizontal_line | |
| 49 extern TFT_dump_screen | |
| 50 | |
| 51 ;----------------------------------------------------------------------------- | |
| 52 ; Macro to encode standard colors. | |
| 53 ; TODO: User preferences... Maybe. | |
| 54 TFT_STD_COLOR macro | |
| 55 setf WREG ; Default to white | |
| 56 call TFT_set_color | |
| 57 endm | |
| 58 | |
| 59 TFT_MASK_COLOR macro | |
| 60 movlw color_greenish ; Default to OSTC mask-green | |
| 61 call TFT_set_color | |
| 62 endm | |
| 63 | |
| 64 TFT_ATTENTION_COLOR macro | |
| 65 movlw color_yellow ; Default to OSTC yelow | |
| 66 call TFT_set_color | |
| 67 endm | |
| 68 | |
| 69 TFT_WARNINGS_COLOR macro | |
| 70 movlw color_red ; Default to OSTC red | |
| 71 call TFT_set_color | |
| 72 endm | |
| 73 | |
| 74 ;TFT_DISABLED_COLOR macro | |
| 75 ; movlw color_grey ; Default to OSTC grey (dark blue) | |
| 76 ; call TFT_set_color | |
| 77 ; endm | |
| 78 | |
| 79 ;============================================================================= | |
| 80 ; Low level macros (for aa_wordprocessor and color_processor). | |
| 81 ; | |
| 82 extern TFT_CmdWrite | |
| 83 Index_out macro low_b | |
| 84 movlw low_b | |
| 85 call TFT_CmdWrite | |
| 86 endm | |
| 87 | |
| 88 ;============================================================================= | |
| 89 ; A shortcut for TFT_box and TFT_frame call sequences. | |
| 90 ; | |
| 91 extern box_frame_std, box_frame_common, box_frame_color, box_frame_color16 | |
| 92 extern box_std_block, box_black_block, box_color_block | |
| 93 | |
| 94 ; Erase a given screen area. | |
| 95 WIN_BOX_BLACK macro top, bottom, left, right | |
| 96 call box_black_block | |
| 97 db top, (bottom)-(top)+1, left, (right)-(left)+1 | |
| 98 endm | |
| 99 | |
| 100 ; Fill a given screen area with standard color (White). | |
| 101 WIN_BOX_STD macro top, bottom, left, right | |
| 102 call box_std_block | |
| 103 db top, (bottom)-(top)+1, left, (right)-(left)+1 | |
| 104 endm | |
| 105 | |
| 106 ; Fill a given screen area with color from WREG (8bits rrrgggbb) | |
| 107 WIN_BOX_COLOR macro top, bottom, left, right | |
| 108 call box_color_block | |
| 109 db top, (bottom)-(top)+1, left, (right)-(left)+1 | |
| 110 endm | |
| 111 | |
| 112 ; Draw a frame in standard color (White). | |
| 113 WIN_FRAME_STD macro top, bottom, left, right | |
| 114 call box_frame_std | |
| 115 db top, (bottom)-(top)+1, left, (right)-(left)+1 | |
| 116 endm | |
| 117 | |
| 118 ; Draw a frame with color from WREG (8bits rrrgggbb) | |
| 119 WIN_FRAME_COLOR macro top, bottom, left, right | |
| 120 call box_frame_color | |
| 121 db top, (bottom)-(top)+1, left, (right)-(left)+1 | |
| 122 endm | |
| 123 | |
| 124 ; Draw a frame with color from win_color (16bits in TFT format) | |
| 125 WIN_FRAME_COLOR16 macro top, bottom, left, right | |
| 126 call box_frame_color16 | |
| 127 db top, (bottom)-(top)+1, left, (right)-(left)+1 | |
| 128 endm | |
| 129 | |
| 130 WIN_FONT macro win_font_input | |
| 131 movlw win_font_input | |
| 132 movff WREG,win_font | |
| 133 endm | |
| 134 | |
| 135 WIN_TOP macro win_top_input | |
| 136 movlw win_top_input | |
| 137 movff WREG,win_top | |
| 138 endm | |
| 139 | |
| 140 WIN_HEIGHT macro h | |
| 141 movlw h | |
| 142 movff WREG,win_height | |
| 143 endm | |
| 144 | |
| 145 WIN_LEFT macro win_left_input | |
| 146 movlw win_left_input | |
| 147 movff WREG,win_leftx2 | |
| 148 endm | |
| 149 | |
| 150 WIN_WIDTH macro w | |
| 151 movlw w | |
| 152 movff WREG,win_width | |
| 153 endm | |
| 154 | |
| 155 WIN_INVERT macro win_invert_input | |
| 156 movlw win_invert_input | |
| 157 movff WREG,win_invert | |
| 158 endm | |
| 159 | |
| 160 WIN_COLOR macro win_color_input | |
| 161 movlw win_color_input | |
| 162 call TFT_set_color | |
| 163 endm | |
| 164 | |
| 165 ;============================================================================= | |
| 166 ; TFT_write_flash_image | |
| 167 ; | |
| 168 ; Inputs: cx, cy : Image center (in 0..160 x 0..240 range) | |
| 169 ; image : flash image header's address | |
| 170 ; Outputs: win_top, win_left, win_height, win_width | |
| 171 ; image copyed on screen. | |
| 172 ; Trashed: PROD, hi, lo | |
| 173 ; | |
| 174 extern TFT_write_flash_image | |
| 175 extern TFT_write_flash_image_addr | |
| 176 TFT_WRITE_FLASH_IMAGE macro cx, cy, image | |
| 177 If LOW(image) != 0 | |
| 178 Error "Image "image" mis-aligned" | |
| 179 Endif | |
| 180 If (UPPER(image) & 0xF0) != 0x30 | |
| 181 Error "Image "image" not in image flash memory" | |
| 182 Endif | |
| 183 If (cx < 0) || (cx > 160) | |
| 184 Error "Image center's X "cx" not in 0..160 range". | |
| 185 Endif | |
| 186 If (cy < 0) || (cy > 240) | |
| 187 Error "Image center's Y "cy" not in 0..240 range". | |
| 188 Endif | |
| 189 ; Once we know image is aligned, we can use the compact (4bytes) | |
| 190 ; 12bit registers to pass the address: | |
| 191 lfsr FSR2, ((image)>>8) & 0xFFF | |
| 192 WIN_LEFT cx | |
| 193 WIN_TOP cy | |
| 194 call TFT_write_flash_image | |
| 195 endm | |
| 196 | |
| 197 ;============================================================================= | |
| 198 ; TFT_write_prom_image | |
| 199 ; | |
| 200 TFT_WRITE_PROM_IMAGE macro icon | |
| 201 extern icon, color_image | |
| 202 movlw LOW(icon) | |
| 203 movwf TBLPTRL | |
| 204 movlw HIGH(icon) | |
| 205 movwf TBLPTRH | |
| 206 movlw UPPER(icon) | |
| 207 movwf TBLPTRU | |
| 208 call color_image | |
| 209 endm | |
| 210 | |
| 211 ;============================================================================= | |
| 212 ; Macro to provides our own interface code. | |
| 213 ; | |
| 214 PIXEL_WRITE macro colRegister, rowRegister | |
| 215 movff colRegister,win_leftx2 | |
| 216 movff rowRegister,win_top | |
| 217 call pixel_write | |
| 218 endm | |
| 219 | |
| 220 INIT_PIXEL_WROTE macro colRegister | |
| 221 movff colRegister,win_leftx2 | |
| 222 call init_pixel_write | |
| 223 endm | |
| 224 | |
| 225 HALF_PIXEL_WRITE macro rowRegister | |
| 226 movff rowRegister,win_top | |
| 227 call half_pixel_write | |
| 228 endm | |
| 229 |
