comparison Discovery/Src/display.c @ 312:e84a2486933e

Merged in janlmulder/ostc4/cleanup-4 (pull request #25) Fix stopwatch and divetime not in sync
author heinrichsweikamp <bitbucket@heinrichsweikamp.com>
date Fri, 31 May 2019 06:22:50 +0000
parents 5ca177d2df5d
children f7318457df4d
comparison
equal deleted inserted replaced
299:b70c26be71a0 312:e84a2486933e
32 32
33 /* RGB signals should be now for 2 frames or more (datasheet) */ 33 /* RGB signals should be now for 2 frames or more (datasheet) */
34 } 34 }
35 35
36 36
37 void send(uint8_t *pData, uint16_t inputlength) 37 static void send(uint8_t *pData, uint16_t inputlength)
38 { 38 {
39 HAL_GPIO_WritePin(DISPLAY_CSB_GPIO_PORT,DISPLAY_CSB_PIN,GPIO_PIN_RESET); // chip select 39 HAL_GPIO_WritePin(DISPLAY_CSB_GPIO_PORT,DISPLAY_CSB_PIN,GPIO_PIN_RESET); // chip select
40 40
41 if(HAL_SPI_Transmit(&hspiDisplay,(uint8_t*)pData, inputlength, 10000) != HAL_OK) 41 if(HAL_SPI_Transmit(&hspiDisplay,(uint8_t*)pData, inputlength, 10000) != HAL_OK)
42 Display_Error_Handler(); 42 Display_Error_Handler();
46 } 46 }
47 HAL_GPIO_WritePin(DISPLAY_CSB_GPIO_PORT,DISPLAY_CSB_PIN,GPIO_PIN_SET); // chip select 47 HAL_GPIO_WritePin(DISPLAY_CSB_GPIO_PORT,DISPLAY_CSB_PIN,GPIO_PIN_SET); // chip select
48 } 48 }
49 49
50 50
51 uint16_t convert8to9to8(uint8_t *pInput, uint8_t *pOutput,uint16_t inputlength) 51 static uint16_t convert8to9to8(uint8_t *pInput, uint8_t *pOutput,uint16_t inputlength)
52 { 52 {
53 uint16_t outputlength; 53 uint16_t outputlength;
54 uint8_t readbit = 0x80;//0b1000000; 54 uint8_t readbit = 0x80;//0b1000000;
55 uint8_t writebit = 0x40;//0b0100000; 55 uint8_t writebit = 0x40;//0b0100000;
56 uint16_t i,j,k; 56 uint16_t i,j,k;
225 length = convert8to9to8((uint8_t*)aTxBuffer,(uint8_t*)bTxBuffer,1); 225 length = convert8to9to8((uint8_t*)aTxBuffer,(uint8_t*)bTxBuffer,1);
226 send((uint8_t*)bTxBuffer, length); 226 send((uint8_t*)bTxBuffer, length);
227 } 227 }
228 228
229 229
230 void display_power_off(void)
231 {
232 uint8_t aTxBuffer[1];
233 uint8_t bTxBuffer[9];
234 uint16_t i,length;
235
236 for(i=0;i<9;i++)
237 bTxBuffer[i] = 0;
238
239 aTxBuffer[0] = DISPLAY_OFF;
240 length = convert8to9to8((uint8_t*)aTxBuffer,(uint8_t*)bTxBuffer,1);
241 send((uint8_t*)bTxBuffer, length);
242 HAL_Delay(5);
243
244 aTxBuffer[0] = SLEEP_IN;
245 length = convert8to9to8((uint8_t*)aTxBuffer,(uint8_t*)bTxBuffer,1);
246 send((uint8_t*)bTxBuffer, length);
247 }
248
249
250 void display_sleep(void)
251 {
252 uint8_t aTxBuffer[1];
253 uint8_t bTxBuffer[9];
254 uint16_t i,length;
255
256 for(i=0;i<9;i++)
257 bTxBuffer[i] = 0;
258
259 aTxBuffer[0] = SLEEP_IN;
260 length = convert8to9to8((uint8_t*)aTxBuffer,(uint8_t*)bTxBuffer,1);
261 send((uint8_t*)bTxBuffer, length);
262 }
263
264
265 void display_sleep_release(void)
266 {
267 uint8_t aTxBuffer[1];
268 uint8_t bTxBuffer[9];
269 uint16_t i,length;
270
271 for(i=0;i<9;i++)
272 bTxBuffer[i] = 0;
273
274 aTxBuffer[0] = SLEEP_OUT;
275 length = convert8to9to8((uint8_t*)aTxBuffer,(uint8_t*)bTxBuffer,1);
276 send((uint8_t*)bTxBuffer, length);
277 }
278
279 static void Display_Error_Handler(void) 230 static void Display_Error_Handler(void)
280 { 231 {
281 while(1) 232 while(1)
282 { 233 {
283 } 234 }