Provides a multiplexed dual seven segment display driver used by RenBED

Dependents:   RenBuggy RenBEDCounter RenBEDHelloWorld AmpBoardTest ... more

Committer:
jf1452
Date:
Wed Feb 05 10:36:35 2014 +0000
Revision:
5:cb7339a2e196
Parent:
4:74572124e539
Added better Int support

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jf1452 0:4dbbe1fc91cb 1 /*******************************************************************************
jf1452 0:4dbbe1fc91cb 2 * RenBED two seven segment display driver *
jf1452 0:4dbbe1fc91cb 3 * Copyright (c) 2013 Jon Fuge *
jf1452 0:4dbbe1fc91cb 4 * *
jf1452 0:4dbbe1fc91cb 5 * Permission is hereby granted, free of charge, to any person obtaining a copy *
jf1452 0:4dbbe1fc91cb 6 * of this software and associated documentation files (the "Software"), to deal*
jf1452 0:4dbbe1fc91cb 7 * in the Software without restriction, including without limitation the rights *
jf1452 0:4dbbe1fc91cb 8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell *
jf1452 0:4dbbe1fc91cb 9 * copies of the Software, and to permit persons to whom the Software is *
jf1452 0:4dbbe1fc91cb 10 * furnished to do so, subject to the following conditions: *
jf1452 0:4dbbe1fc91cb 11 * *
jf1452 0:4dbbe1fc91cb 12 * The above copyright notice and this permission notice shall be included in *
jf1452 0:4dbbe1fc91cb 13 * all copies or substantial portions of the Software. *
jf1452 0:4dbbe1fc91cb 14 * *
jf1452 0:4dbbe1fc91cb 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
jf1452 0:4dbbe1fc91cb 16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
jf1452 0:4dbbe1fc91cb 17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
jf1452 0:4dbbe1fc91cb 18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
jf1452 0:4dbbe1fc91cb 19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,*
jf1452 0:4dbbe1fc91cb 20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN *
jf1452 0:4dbbe1fc91cb 21 * THE SOFTWARE. *
jf1452 0:4dbbe1fc91cb 22 * *
jf1452 0:4dbbe1fc91cb 23 * SevenSegmentDisplay.h *
jf1452 0:4dbbe1fc91cb 24 * *
jf1452 0:4dbbe1fc91cb 25 * V1.0 23/12/2013 First issue of code Jon Fuge *
jf1452 3:7c62606a68b8 26 * V1.1 15/01/2014 Added code to display integers Jon Fuge *
jf1452 0:4dbbe1fc91cb 27 *******************************************************************************/
jf1452 0:4dbbe1fc91cb 28
jf1452 0:4dbbe1fc91cb 29 #ifndef _SEVENSEGMENTDISPLAY_H
jf1452 0:4dbbe1fc91cb 30 #define _SEVENSEGMENTDISPLAY_H
jf1452 0:4dbbe1fc91cb 31
jf1452 0:4dbbe1fc91cb 32 #include "mbed.h"
jf1452 0:4dbbe1fc91cb 33
jf1452 0:4dbbe1fc91cb 34 class SevenSegmentDisplay {
jf1452 0:4dbbe1fc91cb 35 public:
jf1452 0:4dbbe1fc91cb 36
jf1452 0:4dbbe1fc91cb 37 #define INSTANT 0
jf1452 0:4dbbe1fc91cb 38 #define FADE 1
jf1452 0:4dbbe1fc91cb 39 #define FLASH 2
jf1452 0:4dbbe1fc91cb 40
jf1452 0:4dbbe1fc91cb 41 SevenSegmentDisplay(uint8_t ui8Fade);
jf1452 3:7c62606a68b8 42 void DisplayDigits(uint8_t ui8LeftDigit, uint8_t ui8RightDigit);
jf1452 3:7c62606a68b8 43 void DisplayInt(int iValue);
jf1452 0:4dbbe1fc91cb 44 void FadeMode(uint8_t ui8Fade);
jf1452 0:4dbbe1fc91cb 45 void FlashRate(uint16_t ui16FlashRateMs);
jf1452 0:4dbbe1fc91cb 46 void FadeRate(uint8_t ui16FadeRateMs);
jf1452 0:4dbbe1fc91cb 47
jf1452 0:4dbbe1fc91cb 48 private:
jf1452 0:4dbbe1fc91cb 49 #define RIGHT_DIGIT 1
jf1452 0:4dbbe1fc91cb 50 #define LEFT_DIGIT 0
jf1452 3:7c62606a68b8 51 uint8_t D_ui8Mux; // multiplexor set 0:Right digit 1:Left digit
jf1452 3:7c62606a68b8 52 uint8_t D_ui8Common; // common On level set 0:Anode common 1:Cathode common
jf1452 3:7c62606a68b8 53 uint8_t D_ui8LeftDigit;
jf1452 3:7c62606a68b8 54 uint8_t D_ui8RightDigit;
jf1452 3:7c62606a68b8 55 uint8_t D_ui8Mode; // Counter for FadeFlag
jf1452 3:7c62606a68b8 56 uint16_t D_ui16FlashRatems; // Flash rate in ms
jf1452 3:7c62606a68b8 57 uint8_t D_FadeRatems; // Fade rate in ms
jf1452 3:7c62606a68b8 58 uint8_t D_ui8SegmentDrives[2][8]; // Counters for Segment drives
jf1452 3:7c62606a68b8 59
jf1452 3:7c62606a68b8 60 volatile int iDisplayValue; // Storage for integer to be displayed
jf1452 3:7c62606a68b8 61 volatile int iSequence; // Sequence for integer to be displayed
jf1452 3:7c62606a68b8 62
jf1452 3:7c62606a68b8 63 DigitalOut mux;
jf1452 3:7c62606a68b8 64 DigitalOut seg_a;
jf1452 3:7c62606a68b8 65 DigitalOut seg_b;
jf1452 3:7c62606a68b8 66 DigitalOut seg_c;
jf1452 3:7c62606a68b8 67 DigitalOut seg_d;
jf1452 3:7c62606a68b8 68 DigitalOut seg_e;
jf1452 3:7c62606a68b8 69 DigitalOut seg_f;
jf1452 3:7c62606a68b8 70 DigitalOut seg_g;
jf1452 3:7c62606a68b8 71 DigitalOut seg_p;
jf1452 3:7c62606a68b8 72 Ticker timer;
jf1452 3:7c62606a68b8 73 Ticker inttimer;
jf1452 0:4dbbe1fc91cb 74
jf1452 0:4dbbe1fc91cb 75 void SevenSegmentDisplayMux(void);
jf1452 3:7c62606a68b8 76 void SevenSegmentIntMux(void);
jf1452 0:4dbbe1fc91cb 77 void SegmentDrive(uint8_t ui8Value, uint8_t ui8Mux);
jf1452 0:4dbbe1fc91cb 78
jf1452 0:4dbbe1fc91cb 79
jf1452 0:4dbbe1fc91cb 80 };
jf1452 0:4dbbe1fc91cb 81
jf1452 4:74572124e539 82 #endif // _SEVENSEGMENTDISPLAY_H