FRA221_2015 / Mbed 2 deprecated B3_ShutMeUp

Dependencies:   mbed

Fork of zProject_RTC_display_alarm by PuG

Committer:
Peeraya
Date:
Sat Dec 05 10:02:26 2015 +0000
Revision:
0:b2064b3558b6
Child:
1:ba7154d2d7ca
vv

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Peeraya 0:b2064b3558b6 1 /* The library of Grove - 4 Digit Display
Peeraya 0:b2064b3558b6 2 *
Peeraya 0:b2064b3558b6 3 * \author Yihui Xiong
Peeraya 0:b2064b3558b6 4 * \date 2014/2/8
Peeraya 0:b2064b3558b6 5 *
Peeraya 0:b2064b3558b6 6 * The MIT License (MIT)
Peeraya 0:b2064b3558b6 7 *
Peeraya 0:b2064b3558b6 8 * Copyright (c) 2014 Seeed Technology Inc.
Peeraya 0:b2064b3558b6 9 *
Peeraya 0:b2064b3558b6 10 * Permission is hereby granted, free of charge, to any person obtaining a copy
Peeraya 0:b2064b3558b6 11 * of this software and associated documentation files (the "Software"), to deal
Peeraya 0:b2064b3558b6 12 * in the Software without restriction, including without limitation the rights
Peeraya 0:b2064b3558b6 13 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
Peeraya 0:b2064b3558b6 14 * copies of the Software, and to permit persons to whom the Software is
Peeraya 0:b2064b3558b6 15 * furnished to do so, subject to the following conditions:
Peeraya 0:b2064b3558b6 16 *
Peeraya 0:b2064b3558b6 17 * The above copyright notice and this permission notice shall be included in
Peeraya 0:b2064b3558b6 18 * all copies or substantial portions of the Software.
Peeraya 0:b2064b3558b6 19 *
Peeraya 0:b2064b3558b6 20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
Peeraya 0:b2064b3558b6 21 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
Peeraya 0:b2064b3558b6 22 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
Peeraya 0:b2064b3558b6 23 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
Peeraya 0:b2064b3558b6 24 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
Peeraya 0:b2064b3558b6 25 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
Peeraya 0:b2064b3558b6 26 * THE SOFTWARE.
Peeraya 0:b2064b3558b6 27 */
Peeraya 0:b2064b3558b6 28
Peeraya 0:b2064b3558b6 29 #ifndef __DIGIT_DISPLAY__
Peeraya 0:b2064b3558b6 30 #define __DIGIT_DISPLAY__
Peeraya 0:b2064b3558b6 31
Peeraya 0:b2064b3558b6 32 #include "mbed.h"
Peeraya 0:b2064b3558b6 33
Peeraya 0:b2064b3558b6 34 class DigitDisplay
Peeraya 0:b2064b3558b6 35 {
Peeraya 0:b2064b3558b6 36 public:
Peeraya 0:b2064b3558b6 37 DigitDisplay(PinName clk, PinName dio);
Peeraya 0:b2064b3558b6 38
Peeraya 0:b2064b3558b6 39 /**
Peeraya 0:b2064b3558b6 40 * Display a decimal number, A number larger than 10000 or smaller than -1000 will be truncated, MSB will be lost.
Peeraya 0:b2064b3558b6 41 */
Peeraya 0:b2064b3558b6 42 void write(int16_t number);
Peeraya 0:b2064b3558b6 43
Peeraya 0:b2064b3558b6 44 /**
Peeraya 0:b2064b3558b6 45 * Display four numbers
Peeraya 0:b2064b3558b6 46 * \param numbers 0 - 0xF: 0 - 9, A, b, C, d, E, F
Peeraya 0:b2064b3558b6 47 * 0x10 - 0xFE: '_'(unknown)
Peeraya 0:b2064b3558b6 48 * 0xFF: ' '(null)
Peeraya 0:b2064b3558b6 49 */
Peeraya 0:b2064b3558b6 50 void write(uint8_t numbers[]);
Peeraya 0:b2064b3558b6 51
Peeraya 0:b2064b3558b6 52 /**
Peeraya 0:b2064b3558b6 53 * Display a number in a specific position
Peeraya 0:b2064b3558b6 54 * \param position 0 - 3, left to right
Peeraya 0:b2064b3558b6 55 * \param number 0 - 0xF: 0 - 9, A, b, C, d, E, F
Peeraya 0:b2064b3558b6 56 * 0x10 - 0xFE: '_'
Peeraya 0:b2064b3558b6 57 * 0xFF: ' '
Peeraya 0:b2064b3558b6 58 */
Peeraya 0:b2064b3558b6 59 void write(uint8_t position, uint8_t number);
Peeraya 0:b2064b3558b6 60
Peeraya 0:b2064b3558b6 61 void writeRaw(uint8_t position, uint8_t segments);
Peeraya 0:b2064b3558b6 62 void writeRaw(uint8_t segments[]);
Peeraya 0:b2064b3558b6 63
Peeraya 0:b2064b3558b6 64 void clear();
Peeraya 0:b2064b3558b6 65 void on();
Peeraya 0:b2064b3558b6 66 void off();
Peeraya 0:b2064b3558b6 67
Peeraya 0:b2064b3558b6 68 /**
Peeraya 0:b2064b3558b6 69 * Set the brightness, level 0 to level 7
Peeraya 0:b2064b3558b6 70 */
Peeraya 0:b2064b3558b6 71 void setBrightness(uint8_t brightness);
Peeraya 0:b2064b3558b6 72
Peeraya 0:b2064b3558b6 73 /**
Peeraya 0:b2064b3558b6 74 * Enable/Disable the colon
Peeraya 0:b2064b3558b6 75 */
Peeraya 0:b2064b3558b6 76 void setColon(bool enable);
Peeraya 0:b2064b3558b6 77
Peeraya 0:b2064b3558b6 78 DigitDisplay& operator= (int16_t number) {
Peeraya 0:b2064b3558b6 79 write(number);
Peeraya 0:b2064b3558b6 80 return *this;
Peeraya 0:b2064b3558b6 81 }
Peeraya 0:b2064b3558b6 82 void Displayset(int s1,int s2,int s3,int s4);
Peeraya 0:b2064b3558b6 83 private:
Peeraya 0:b2064b3558b6 84 void start();
Peeraya 0:b2064b3558b6 85 bool send(uint8_t data);
Peeraya 0:b2064b3558b6 86 void stop();
Peeraya 0:b2064b3558b6 87
Peeraya 0:b2064b3558b6 88 DigitalOut _clk;
Peeraya 0:b2064b3558b6 89 DigitalInOut _dio;
Peeraya 0:b2064b3558b6 90 bool _off;
Peeraya 0:b2064b3558b6 91 bool _colon;
Peeraya 0:b2064b3558b6 92 uint8_t _brightness;
Peeraya 0:b2064b3558b6 93 uint8_t _content[4];
Peeraya 0:b2064b3558b6 94 };
Peeraya 0:b2064b3558b6 95
Peeraya 0:b2064b3558b6 96 #endif // __DIGIT_DISPLAY__