SHARE
TWEET

display_ctl.cpp

a guest Jun 24th, 2013 176 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Compile with: g++ `pkg-config --cflags --libs rpi-hw` display_ctl.cpp -o display_ctl
  2.  
  3. // Include Rpi-hw headers
  4. #include <rpi-hw.hpp>
  5. #include <rpi-hw/time.hpp>
  6. #include <rpi-hw/iface/decoder-out.hpp>
  7. #include <rpi-hw/display/m7seg.hpp>
  8.  
  9. // Use Rpi-hw namespace
  10. using namespace rpihw;
  11.  
  12. int
  13. main( int argc, char *args[] ) {
  14.  
  15.         // Multiple seven-segment display controller
  16.         display::m7seg dev( 1, 4, 18, 15, 14, 0, 17, 23 );
  17.  
  18.         // Create the enabler interface
  19.         iface::decoderOut enabler( { 21, 22 } );
  20.  
  21.         // Set the number of displays and the enabler interface
  22.         dev.setDisplays( 2, enabler );
  23.  
  24.         // Set the updating frequency (Hz)
  25.         dev.setFreq( 60.0 );
  26.  
  27.  
  28.         // Read new values from the stdin
  29.         float tmp;
  30.  
  31.         while ( std::cin >> tmp )
  32.                 dev.set( tmp );
  33.  
  34.         return 0;
  35. }
RAW Paste Data
Want to get better at C++?
Learn to code C++ in 2017
Top