library for Seeed's Grove - 4 Digit Display
Dependents: SeeedStudio_Grove_Sensors_Demo thermostat_fan_demo--fan microbit-8-ultrasonic-meter HAHAHA ... more
Fork of DigitDisplay by
DigitDisplay.h
00001 /* The library of Grove - 4 Digit Display 00002 * 00003 * \author Yihui Xiong 00004 * \date 2014/2/8 00005 * 00006 * The MIT License (MIT) 00007 * 00008 * Copyright (c) 2014 Seeed Technology Inc. 00009 * 00010 * Permission is hereby granted, free of charge, to any person obtaining a copy 00011 * of this software and associated documentation files (the "Software"), to deal 00012 * in the Software without restriction, including without limitation the rights 00013 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 00014 * copies of the Software, and to permit persons to whom the Software is 00015 * furnished to do so, subject to the following conditions: 00016 * 00017 * The above copyright notice and this permission notice shall be included in 00018 * all copies or substantial portions of the Software. 00019 * 00020 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00021 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00022 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 00023 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00024 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00025 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 00026 * THE SOFTWARE. 00027 */ 00028 00029 #ifndef __DIGIT_DISPLAY__ 00030 #define __DIGIT_DISPLAY__ 00031 00032 #include "mbed.h" 00033 00034 class DigitDisplay 00035 { 00036 public: 00037 DigitDisplay(PinName clk, PinName dio); 00038 00039 /** 00040 * Display a decimal number, A number larger than 10000 or smaller than -1000 will be truncated, MSB will be lost. 00041 */ 00042 void write(int16_t number); 00043 00044 /** 00045 * Display four numbers 00046 * \param numbers 0 - 0xF: 0 - 9, A, b, C, d, E, F 00047 * 0x10 - 0xFE: '_'(unknown) 00048 * 0xFF: ' '(null) 00049 */ 00050 void write(uint8_t numbers[]); 00051 00052 /** 00053 * Display a number in a specific position 00054 * \param position 0 - 3, left to right 00055 * \param number 0 - 0xF: 0 - 9, A, b, C, d, E, F 00056 * 0x10 - 0xFE: '_' 00057 * 0xFF: ' ' 00058 */ 00059 void write(uint8_t position, uint8_t number); 00060 00061 void writeRaw(uint8_t position, uint8_t segments); 00062 void writeRaw(uint8_t segments[]); 00063 00064 void clear(); 00065 void on(); 00066 void off(); 00067 00068 /** 00069 * Set the brightness, level 0 to level 7 00070 */ 00071 void setBrightness(uint8_t brightness); 00072 00073 /** 00074 * Enable/Disable the colon 00075 */ 00076 void setColon(bool enable); 00077 00078 DigitDisplay& operator= (int16_t number) { 00079 write(number); 00080 return *this; 00081 } 00082 00083 private: 00084 void start(); 00085 bool send(uint8_t data); 00086 void stop(); 00087 00088 DigitalOut _clk; 00089 DigitalInOut _dio; 00090 bool _off; 00091 bool _colon; 00092 uint8_t _brightness; 00093 uint8_t _content[4]; 00094 }; 00095 00096 #endif // __DIGIT_DISPLAY__
Generated on Tue Jul 12 2022 14:54:09 by 1.7.2