charles young / Mbed 2 deprecated GEO_COUNTER_L432KC

Dependencies:   mbed

Fork of GEO_COUNTER_L432KC by Geo Electronics "Geo Counter"

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers LED7segDisplay.hpp Source File

LED7segDisplay.hpp

00001 /**
00002  * @author Charles Young
00003  * This class encapsulates the behavior of the 7-seg 8 digit LED display
00004  */
00005 
00006 #ifndef LED7segDisplay_H
00007 #define LED7segDisplay_H
00008 
00009 /**
00010  * Includes
00011  */
00012 #include "mbed.h"
00013 #include "HwRegisters.hpp"
00014 
00015 #define DEC_MODE    0x09FF  // BCD decoding on all digits
00016 #define SCAN_LIM    0x0B07  // use all 8 digits  
00017 #define TURN_ON     0x0C01  // no shutdown (operating)
00018 #define SHUTDOWN    0x0C00  // shutdown
00019 #define TEST        0x0F00  // no test
00020 #define DT      1      // delay time in us for SPI emulation
00021 
00022 #define BRIGHTNESS_MIN  0x0A00  // brightness in 16 steps - min to max is 0x0A00 to  0x0A0F
00023 #define BRIGHTNESS_MAX  0x0A0F  // brightness in 16 steps - min to max is 0x0A00 to  0x0A0F
00024 
00025 /**
00026  * Code associated with rotary switch.
00027  */
00028 class LED7segDisplay {
00029 
00030 public:
00031 
00032    /**
00033     * Constructor.
00034     *
00035     * @param channelA mbed pin for channel A input.
00036     * @param channelB mbed pin for channel B input.
00037     */
00038    LED7segDisplay();
00039 
00040    void Display_6D_write(int32_t); // write to MAX7219 (Main 6-digits display)
00041    void Display_2D_write(int16_t); // write to MAX7219 (Gate 2-digits display)
00042    void Display_2D_Blank();
00043    void Display_brightness_up();
00044    void Display_brightness_down();
00045    uint16_t GetBrightness() {return brightness - BRIGHTNESS_MIN;};
00046 
00047 private:
00048    uint16_t brightness;
00049    uint8_t     Disp_Digit[8]; // used to manage 8-digits through MAX7219
00050    uint16_t    Stream;        // used to stream out serial data to MAX7219
00051 
00052    void Display_init(void);    // initialize MAX7219
00053    void sendDataToDisplay(uint16_t data_to_send);
00054    void Display_brightness(uint16_t brightness);
00055 };
00056 
00057 #endif /* LED7segDisplay_H */