OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2015 Gurjant Kalsi <me@gurjantkalsi.com> | 2 * Copyright (c) 2015 Gurjant Kalsi <me@gurjantkalsi.com> |
3 * | 3 * |
4 * Permission is hereby granted, free of charge, to any person obtaining | 4 * Permission is hereby granted, free of charge, to any person obtaining |
5 * a copy of this software and associated documentation files | 5 * a copy of this software and associated documentation files |
6 * (the "Software"), to deal in the Software without restriction, | 6 * (the "Software"), to deal in the Software without restriction, |
7 * including without limitation the rights to use, copy, modify, merge, | 7 * including without limitation the rights to use, copy, modify, merge, |
8 * publish, distribute, sublicense, and/or sell copies of the Software, | 8 * publish, distribute, sublicense, and/or sell copies of the Software, |
9 * and to permit persons to whom the Software is furnished to do so, | 9 * and to permit persons to whom the Software is furnished to do so, |
10 * subject to the following conditions: | 10 * subject to the following conditions: |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 } | 115 } |
116 | 116 |
117 | 117 |
118 | 118 |
119 static void mlcd_flush(uint starty, uint endy) | 119 static void mlcd_flush(uint starty, uint endy) |
120 { | 120 { |
121 chip_select(true); | 121 chip_select(true); |
122 | 122 |
123 static uint8_t localbuf[MLCD_BUF_SIZE]; | 123 static uint8_t localbuf[MLCD_BUF_SIZE]; |
124 uint8_t *bufptr = localbuf; | 124 uint8_t *bufptr = localbuf; |
| 125 uint8_t trailer = 0; |
125 | 126 |
126 // The first line is preceeded with a write command. | 127 // The first line is preceeded with a write command. |
127 *bufptr++ = MLCD_WR | vcom_state; | 128 *bufptr++ = MLCD_WR | vcom_state; |
128 | 129 |
129 vcom_state = vcom_state == VCOM_HI ? VCOM_LO : VCOM_HI; | 130 vcom_state = vcom_state == VCOM_HI ? VCOM_LO : VCOM_HI; |
130 | 131 |
131 // Send the image data. | 132 // Send the image data. |
132 for (uint j = starty; j <= endy; ++j) { | 133 for (uint j = starty; j <= endy; ++j) { |
133 *bufptr++ = (j + 1); | 134 *bufptr++ = (j + 1); |
134 | 135 |
135 bufptr += lcd_get_line(framebuffer, j, bufptr); | 136 bufptr += lcd_get_line(framebuffer, j, bufptr); |
136 | 137 |
| 138 // 8 bit trailer per line |
| 139 *bufptr++ = trailer; |
| 140 if (j == endy) { |
| 141 // 16 bit trailer on the last line |
| 142 *bufptr++ = trailer; |
| 143 } |
| 144 |
137 if (HAL_SPI_Transmit(&SpiHandle, localbuf, bufptr - localbuf, HAL_MAX_DE
LAY) != HAL_OK) { | 145 if (HAL_SPI_Transmit(&SpiHandle, localbuf, bufptr - localbuf, HAL_MAX_DE
LAY) != HAL_OK) { |
138 goto finish; | 146 goto finish; |
139 } | 147 } |
140 | 148 |
141 bufptr = localbuf; | 149 bufptr = localbuf; |
142 | |
143 *bufptr++ = (j + 1); | |
144 } | 150 } |
145 | 151 |
146 uint8_t trailer = 0; | |
147 if (HAL_SPI_Transmit(&SpiHandle, &trailer, 1, HAL_MAX_DELAY) != HAL_OK) { | |
148 goto finish; | |
149 } | |
150 | |
151 | |
152 finish: | 152 finish: |
153 chip_select(false); | 153 chip_select(false); |
154 } | 154 } |
155 | 155 |
156 status_t display_get_info(struct display_info *info) | 156 status_t display_get_info(struct display_info *info) |
157 { | 157 { |
158 LTRACEF("display_info %p\n", info); | 158 LTRACEF("display_info %p\n", info); |
159 | 159 |
160 info->framebuffer = (void *)framebuffer; | 160 info->framebuffer = (void *)framebuffer; |
161 info->format = FB_FORMAT; | 161 info->format = FB_FORMAT; |
162 info->width = MLCD_WIDTH; | 162 info->width = MLCD_WIDTH; |
163 info->height = MLCD_HEIGHT; | 163 info->height = MLCD_HEIGHT; |
164 info->stride = FB_STRIDE; | 164 info->stride = FB_STRIDE; |
165 info->flush = mlcd_flush; | 165 info->flush = mlcd_flush; |
166 | 166 |
167 return NO_ERROR; | 167 return NO_ERROR; |
168 } | 168 } |
OLD | NEW |