]> rtime.felk.cvut.cz Git - eurobot/public.git/blob - src/ulcdd/uoled.c
b773999ff86b61746c99c3911b5f7e316228ee4a
[eurobot/public.git] / src / ulcdd / uoled.c
1 #include <sercom.h>
2
3 #include "uoled.h"
4 #include "oledlib.h"
5 #include <string.h>
6 #include <fcntl.h>
7 #include <signal.h>
8 #include <unistd.h>
9 #include <stdlib.h>
10 #include <stdio.h>
11
12 struct sercom_data sercom;
13
14 int uoled_write_cmd(u_int8_t *buff, int size) {
15         int ret, i;
16         u_int8_t rep;
17         
18 #ifdef DEBUG
19         printf("sending command: ");
20         for(i=0; i<size; i++)
21                 printf("%02x ",*(buff+i));
22         printf("\n");
23 #endif
24         
25         ret = write(sercom.fd, buff, size);
26         if(ret != size)
27                 return -1;
28         
29 /*      read(sercom.fd, &rep, 1);
30 #ifdef DEBUG
31         printf("Response: %02x\n", rep);
32 #endif
33         
34         if(rep != ACK)
35                 return -1;*/
36         
37         return 0;
38 }
39
40 int uoled_switch_mode_rep() {
41         u_int8_t ret;
42         u_int8_t msg[ERASE_MSG_SIZE];
43         
44         lcd_erase(msg, ERASE_MSG_SIZE);
45         
46         ret = ulcdd_write_cmd(msg, ERASE_MSG_SIZE);
47         if(ret)
48                 return -1;
49         
50         return 0;
51
52 }