Blame view

RIOT/boards/chronos/drivers/display_putchar.c 1.51 KB
fb11e647   vrobic   reseau statique a...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
  /*
   * Copyright (C) 2014 INRIA
   *
   * This file is subject to the terms and conditions of the GNU Lesser
   * General Public License v2.1. See the file LICENSE in the top level
   * directory for more details.
   */
  
  /**
   * @ingroup chronos
   * @{
   */
  
  /**
   * @file
   * @brief       eZ430-chronos putchar via display implementation
   *
   * @author      Oliver Hahm <oliver.hahm@inria.fr>
   * @author      Kaspar Schleiser <kaspar@schleiser.de>
   * @author      Ludwig KnΓΌpfer <ludwig.knuepfer@fu-berlin.de>
   * @author      Aleksandr Mikoff <sir.enmity@gmail.com>
   *
   */
  
  #include <stdio.h>
  #include <string.h>
  #include <ctype.h>
  
  #include "display.h"
  
  extern void (*_putchar)(int c);
  
  static char display_buf[11];
  
  void putchar_to_display(int c);
  
  void init_display_putchar(void)
  {
      memset(display_buf, '\0', 11);
      _putchar = putchar_to_display;
  }
  
  void putchar_to_display(int c)
  {
      if (c == '\n') {
          display_buf[4] = 1;
          return;
      }
  
      if (display_buf[4]) {
          memset(display_buf, '\0', 11);
      }
      else {
          display_buf[0] = display_buf[1];
          display_buf[1] = display_buf[2];
          display_buf[2] = display_buf[3];
          display_buf[3] = display_buf[5];
          display_buf[5] = display_buf[6];
          display_buf[6] = display_buf[7];
          display_buf[7] = display_buf[8];
          display_buf[8] = display_buf[9];
      }
  
      display_buf[9] = toupper(c);
  
      clear_display_all();
  
      display_chars(LCD_SEG_L1_3_0, display_buf, SEG_ON);
      display_chars(LCD_SEG_L2_5_0, display_buf + 4, SEG_ON);
  }