Charles Young's development fork. Going forward I only want to push mature code to main repository.
Fork of GEO_COUNTER_L432KC by
LED7segDisplay.hpp@44:a26ca542ae5e, 2018-09-06 (annotated)
- Committer:
- Charles David Young
- Date:
- Thu Sep 06 11:44:05 2018 -0700
- Revision:
- 44:a26ca542ae5e
- Parent:
- 41:08bf3ea5eba4
TickerCorrection
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Charles David Young |
25:0161bf1adc81 | 1 | /** |
Charles David Young |
25:0161bf1adc81 | 2 | * @author Charles Young |
Charles David Young |
25:0161bf1adc81 | 3 | * This class encapsulates the behavior of the 7-seg 8 digit LED display |
Charles David Young |
25:0161bf1adc81 | 4 | */ |
Charles David Young |
25:0161bf1adc81 | 5 | |
Charles David Young |
25:0161bf1adc81 | 6 | #ifndef LED7segDisplay_H |
Charles David Young |
25:0161bf1adc81 | 7 | #define LED7segDisplay_H |
Charles David Young |
25:0161bf1adc81 | 8 | |
Charles David Young |
25:0161bf1adc81 | 9 | /** |
Charles David Young |
25:0161bf1adc81 | 10 | * Includes |
Charles David Young |
25:0161bf1adc81 | 11 | */ |
Charles David Young |
25:0161bf1adc81 | 12 | #include "mbed.h" |
Charles David Young |
25:0161bf1adc81 | 13 | #include "HwRegisters.hpp" |
Charles David Young |
25:0161bf1adc81 | 14 | |
Charles David Young |
25:0161bf1adc81 | 15 | #define DEC_MODE 0x09FF // BCD decoding on all digits |
Charles David Young |
25:0161bf1adc81 | 16 | #define SCAN_LIM 0x0B07 // use all 8 digits |
Charles David Young |
25:0161bf1adc81 | 17 | #define TURN_ON 0x0C01 // no shutdown (operating) |
Charles David Young |
25:0161bf1adc81 | 18 | #define SHUTDOWN 0x0C00 // shutdown |
Charles David Young |
25:0161bf1adc81 | 19 | #define TEST 0x0F00 // no test |
Charles David Young |
25:0161bf1adc81 | 20 | #define DT 1 // delay time in us for SPI emulation |
Charles David Young |
25:0161bf1adc81 | 21 | |
Charles David Young |
25:0161bf1adc81 | 22 | #define BRIGHTNESS_MIN 0x0A00 // brightness in 16 steps - min to max is 0x0A00 to 0x0A0F |
Charles David Young |
25:0161bf1adc81 | 23 | #define BRIGHTNESS_MAX 0x0A0F // brightness in 16 steps - min to max is 0x0A00 to 0x0A0F |
Charles David Young |
25:0161bf1adc81 | 24 | |
Charles David Young |
25:0161bf1adc81 | 25 | /** |
Charles David Young |
25:0161bf1adc81 | 26 | * Code associated with rotary switch. |
Charles David Young |
25:0161bf1adc81 | 27 | */ |
Charles David Young |
25:0161bf1adc81 | 28 | class LED7segDisplay { |
Charles David Young |
25:0161bf1adc81 | 29 | |
Charles David Young |
25:0161bf1adc81 | 30 | public: |
Charles David Young |
25:0161bf1adc81 | 31 | |
Charles David Young |
25:0161bf1adc81 | 32 | /** |
Charles David Young |
25:0161bf1adc81 | 33 | * Constructor. |
Charles David Young |
25:0161bf1adc81 | 34 | * |
Charles David Young |
25:0161bf1adc81 | 35 | * @param channelA mbed pin for channel A input. |
Charles David Young |
25:0161bf1adc81 | 36 | * @param channelB mbed pin for channel B input. |
Charles David Young |
25:0161bf1adc81 | 37 | */ |
Charles David Young |
25:0161bf1adc81 | 38 | LED7segDisplay(); |
Charles David Young |
25:0161bf1adc81 | 39 | |
Charles David Young |
44:a26ca542ae5e | 40 | void Display_6D_write(int32_t); // write to MAX7219 (Main 6-digits display) |
Charles David Young |
44:a26ca542ae5e | 41 | void Display_2D_write(int16_t); // write to MAX7219 (Gate 2-digits display) |
Charles David Young |
41:08bf3ea5eba4 | 42 | void Display_2D_Blank(); |
Charles David Young |
25:0161bf1adc81 | 43 | void Display_brightness_up(); |
Charles David Young |
25:0161bf1adc81 | 44 | void Display_brightness_down(); |
Charles David Young |
40:a41b4e8f03a2 | 45 | uint16_t GetBrightness() {return brightness - BRIGHTNESS_MIN;}; |
Charles David Young |
25:0161bf1adc81 | 46 | |
Charles David Young |
25:0161bf1adc81 | 47 | private: |
charlesdavidyoung | 26:166dbe6022e8 | 48 | uint16_t brightness; |
Charles David Young |
25:0161bf1adc81 | 49 | uint8_t Disp_Digit[8]; // used to manage 8-digits through MAX7219 |
Charles David Young |
25:0161bf1adc81 | 50 | uint16_t Stream; // used to stream out serial data to MAX7219 |
Charles David Young |
25:0161bf1adc81 | 51 | |
Charles David Young |
25:0161bf1adc81 | 52 | void Display_init(void); // initialize MAX7219 |
Charles David Young |
25:0161bf1adc81 | 53 | void sendDataToDisplay(uint16_t data_to_send); |
Charles David Young |
25:0161bf1adc81 | 54 | void Display_brightness(uint16_t brightness); |
Charles David Young |
25:0161bf1adc81 | 55 | }; |
Charles David Young |
25:0161bf1adc81 | 56 | |
Charles David Young |
25:0161bf1adc81 | 57 | #endif /* LED7segDisplay_H */ |