Statistics
| Branch: | Revision:

ddr4s / fw / wiringPi / examples / scrollPhat / test.c @ 32:cadb9025f1e0

History | View | Annotate | Download (2.78 KB)

1
/*
2
 * test.c:
3
 *        Little test program forthe Pimoroni Scroll Phat.
4
 *
5
 * Copyright (c) 2015-2016 Gordon Henderson. <projects@drogon.net>
6
 ***********************************************************************
7
 * This file is part of wiringPi:
8
 *        https://projects.drogon.net/raspberry-pi/wiringpi/
9
 *
10
 *    wiringPi is free software: you can redistribute it and/or modify
11
 *    it under the terms of the GNU Lesser General Public License as published by
12
 *    the Free Software Foundation, either version 3 of the License, or
13
 *    (at your option) any later version.
14
 *
15
 *    wiringPi is distributed in the hope that it will be useful,
16
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
 *    GNU Lesser General Public License for more details.
19
 *
20
 *    You should have received a copy of the GNU Lesser General Public License
21
 *    along with wiringPi.  If not, see <http://www.gnu.org/licenses/>.
22
 ***********************************************************************
23
 */
24

    
25
#include <stdio.h>
26
#include <stdlib.h>
27
#include <errno.h>
28
#include <string.h>
29

    
30
#include <scrollPhat.h>
31

    
32

    
33
/*
34
 * prompt:
35
 *        Simple prompt & wait
36
 *********************************************************************************
37
 */
38

    
39
static void prompt (const char *p)
40
{
41
  printf ("    %s. Press ENTER: ", p) ;
42
  (void)getchar () ;
43
}
44

    
45

    
46
/*
47
 * the works
48
 *********************************************************************************
49
 */
50

    
51
int main (void)
52
{
53
  int x, y ;
54

    
55
  printf ("\n") ;
56
  printf ("Scroll Phat Test program\n") ;
57
  printf ("========================\n") ;
58

    
59
  if (scrollPhatSetup () != 0)
60
  {
61
    printf ("Unable to initialise the scrollPhat: %s\n", strerror (errno)) ;
62
    exit (1) ;
63
  }
64

    
65
  printf ("-> Scroll Phat initialised OK\n") ;
66
  printf ("... Basic display tests.\n\n") ;
67

    
68
  prompt ("Display ought to be blank") ;
69

    
70
// Light all pixels using one point at a time
71

    
72
  for (y = 0 ; y < 5 ; ++y)
73
    for (x = 0 ; x < 12 ; ++x)
74
      scrollPhatPoint (x, y, 1) ;
75
  scrollPhatUpdate () ;
76

    
77
  prompt ("Display ought to be all lit-up") ;
78

    
79
// Big rectangle
80
  
81
  scrollPhatClear () ;
82
  scrollPhatRectangle (0,0, 10, 4, 1, 0) ;
83
  scrollPhatUpdate () ;
84

    
85
  prompt ("There should now be a rectangle round the outside") ;
86

    
87
  scrollPhatLine (0,0, 10,4, 1) ;
88
  scrollPhatLine (0,4, 10,0, 1) ;
89
  scrollPhatUpdate () ;
90

    
91
  prompt ("Diagonal lines") ;
92

    
93
  scrollPhatIntensity (1) ;
94

    
95
  prompt ("Minimum brightness") ;
96
  
97
  scrollPhatIntensity (100) ;
98

    
99
  prompt ("Maximum brightness") ;
100
  
101
  scrollPhatIntensity (10) ;
102

    
103
  prompt ("Default brightness") ;
104
  
105
  scrollPhatClear () ;
106
  
107
  printf ("    Message Test...Press Ctrl-C to exit: ") ;
108
  fflush (stdout) ;
109

    
110
  scrollPhatPrintSpeed (75) ;
111
  for (;;)
112
    scrollPhatPuts ("  Welcome to the scroll phat from Pimoroni  ") ;
113
  
114
  return 0 ;
115
}