Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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. #include <stdio.h>
  25. #include <stdlib.h>
  26. #include <errno.h>
  27. #include <string.h>
  28. #include <scrollPhat.h>
  29. /*
  30. * prompt:
  31. * Simple prompt & wait
  32. *********************************************************************************
  33. */
  34. static void prompt (const char *p)
  35. {
  36. printf (" %s. Press ENTER: ", p) ;
  37. (void)getchar () ;
  38. }
  39. /*
  40. * the works
  41. *********************************************************************************
  42. */
  43. int main (void)
  44. {
  45. int x, y ;
  46. printf ("\n") ;
  47. printf ("Scroll Phat Test program\n") ;
  48. printf ("========================\n") ;
  49. if (scrollPhatSetup () != 0)
  50. {
  51. printf ("Unable to initialise the scrollPhat: %s\n", strerror (errno)) ;
  52. exit (1) ;
  53. }
  54. printf ("-> Scroll Phat initialised OK\n") ;
  55. printf ("... Basic display tests.\n\n") ;
  56. prompt ("Display ought to be blank") ;
  57. // Light all pixels using one point at a time
  58. for (y = 0 ; y < 5 ; ++y)
  59. for (x = 0 ; x < 12 ; ++x)
  60. scrollPhatPoint (x, y, 1) ;
  61. scrollPhatUpdate () ;
  62. prompt ("Display ought to be all lit-up") ;
  63. // Big rectangle
  64. scrollPhatClear () ;
  65. scrollPhatRectangle (0,0, 10, 4, 1, 0) ;
  66. scrollPhatUpdate () ;
  67. prompt ("There should now be a rectangle round the outside") ;
  68. scrollPhatLine (0,0, 10,4, 1) ;
  69. scrollPhatLine (0,4, 10,0, 1) ;
  70. scrollPhatUpdate () ;
  71. prompt ("Diagonal lines") ;
  72. scrollPhatIntensity (1) ;
  73. prompt ("Minimum brightness") ;
  74. scrollPhatIntensity (100) ;
  75. prompt ("Maximum brightness") ;
  76. scrollPhatIntensity (10) ;
  77. prompt ("Default brightness") ;
  78. scrollPhatClear () ;
  79. printf (" Message Test...Press Ctrl-C to exit: ") ;
  80. fflush (stdout) ;
  81. scrollPhatPrintSpeed (75) ;
  82. for (;;)
  83. scrollPhatPuts (" Welcome to the scroll phat from Pimoroni ") ;
  84. return 0 ;
  85. }