Ghz2000's 14Segment LED Display Library
Dependents: Nucleo_Seg14Display
Ghz2000製 14セグ表示器
http://ghz2000.dip.jp/wordpress/?p=665
mbed用のサンプルプログラムです。 ライブラリ化してあるので、インポートして使用することが出来ます。
注意事項
一度に読み込めるテキストは30文字です。 それを超えると変な文字が表示されます。
今後
スクロールが終わった時のコールバックを作って、30文字以上の文字列も流せるようにしたいです。 スイッチサイエンスほかで販売予定。
lib14Seg.hpp@2:eb91996f0a20, 2016-07-06 (annotated)
- Committer:
- ghz2000
- Date:
- Wed Jul 06 05:59:18 2016 +0000
- Revision:
- 2:eb91996f0a20
- Parent:
- 0:e64e0d7aad81
Fix Comment and Class Document
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ghz2000 | 2:eb91996f0a20 | 1 | /* Copyright (c) 2016 Ghz2000, MIT License |
ghz2000 | 2:eb91996f0a20 | 2 | * |
ghz2000 | 2:eb91996f0a20 | 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software |
ghz2000 | 2:eb91996f0a20 | 4 | * and associated documentation files (the "Software"), to deal in the Software without restriction, |
ghz2000 | 2:eb91996f0a20 | 5 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, |
ghz2000 | 2:eb91996f0a20 | 6 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is |
ghz2000 | 2:eb91996f0a20 | 7 | * furnished to do so, subject to the following conditions: |
ghz2000 | 2:eb91996f0a20 | 8 | * |
ghz2000 | 2:eb91996f0a20 | 9 | * The above copyright notice and this permission notice shall be included in all copies or |
ghz2000 | 2:eb91996f0a20 | 10 | * substantial portions of the Software. |
ghz2000 | 2:eb91996f0a20 | 11 | * |
ghz2000 | 2:eb91996f0a20 | 12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING |
ghz2000 | 2:eb91996f0a20 | 13 | * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
ghz2000 | 2:eb91996f0a20 | 14 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
ghz2000 | 2:eb91996f0a20 | 15 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
ghz2000 | 2:eb91996f0a20 | 16 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
ghz2000 | 2:eb91996f0a20 | 17 | */ |
ghz2000 | 0:e64e0d7aad81 | 18 | |
ghz2000 | 2:eb91996f0a20 | 19 | |
ghz2000 | 2:eb91996f0a20 | 20 | |
ghz2000 | 0:e64e0d7aad81 | 21 | |
ghz2000 | 0:e64e0d7aad81 | 22 | #ifndef _lib14Seg_ |
ghz2000 | 0:e64e0d7aad81 | 23 | #define _lib14Seg_ |
ghz2000 | 0:e64e0d7aad81 | 24 | |
ghz2000 | 0:e64e0d7aad81 | 25 | #include "mbed.h" |
ghz2000 | 0:e64e0d7aad81 | 26 | |
ghz2000 | 0:e64e0d7aad81 | 27 | |
ghz2000 | 0:e64e0d7aad81 | 28 | //correct |
ghz2000 | 0:e64e0d7aad81 | 29 | #define sign_A 0x4791 |
ghz2000 | 0:e64e0d7aad81 | 30 | #define sign_B 0x13B4 |
ghz2000 | 0:e64e0d7aad81 | 31 | #define sign_C 0x4221 |
ghz2000 | 0:e64e0d7aad81 | 32 | #define sign_D 0x13A4 |
ghz2000 | 0:e64e0d7aad81 | 33 | #define sign_E 0x4631 |
ghz2000 | 0:e64e0d7aad81 | 34 | #define sign_F 0x4611 |
ghz2000 | 0:e64e0d7aad81 | 35 | #define sign_G 0x42B1 |
ghz2000 | 0:e64e0d7aad81 | 36 | #define sign_H 0x4591 |
ghz2000 | 0:e64e0d7aad81 | 37 | #define sign_I 0x1224 |
ghz2000 | 0:e64e0d7aad81 | 38 | #define sign_J 0x01A1 |
ghz2000 | 0:e64e0d7aad81 | 39 | #define sign_K 0x4C09 |
ghz2000 | 0:e64e0d7aad81 | 40 | #define sign_L 0x4021 |
ghz2000 | 0:e64e0d7aad81 | 41 | #define sign_M 0x6981 |
ghz2000 | 0:e64e0d7aad81 | 42 | #define sign_N 0x6189 |
ghz2000 | 0:e64e0d7aad81 | 43 | #define sign_O 0x43A1 |
ghz2000 | 0:e64e0d7aad81 | 44 | #define sign_P 0x4711 |
ghz2000 | 0:e64e0d7aad81 | 45 | #define sign_Q 0x43A9 |
ghz2000 | 0:e64e0d7aad81 | 46 | #define sign_R 0x4719 |
ghz2000 | 0:e64e0d7aad81 | 47 | #define sign_S 0x46B0 |
ghz2000 | 0:e64e0d7aad81 | 48 | #define sign_T 0x1204 |
ghz2000 | 0:e64e0d7aad81 | 49 | #define sign_U 0x41A1 |
ghz2000 | 0:e64e0d7aad81 | 50 | #define sign_V 0x4803 |
ghz2000 | 0:e64e0d7aad81 | 51 | #define sign_W 0x418B |
ghz2000 | 0:e64e0d7aad81 | 52 | #define sign_X 0x280A |
ghz2000 | 0:e64e0d7aad81 | 53 | #define sign_Y 0x2804 |
ghz2000 | 0:e64e0d7aad81 | 54 | #define sign_Z 0x0A22 |
ghz2000 | 0:e64e0d7aad81 | 55 | |
ghz2000 | 0:e64e0d7aad81 | 56 | //incorrect |
ghz2000 | 0:e64e0d7aad81 | 57 | #define sign_Exclamation 0x01C0 |
ghz2000 | 0:e64e0d7aad81 | 58 | #define sign_Wquot 0x1100 |
ghz2000 | 0:e64e0d7aad81 | 59 | #define sign_Sharp 0x1594 |
ghz2000 | 0:e64e0d7aad81 | 60 | #define sign_Doll 0x56B4 |
ghz2000 | 0:e64e0d7aad81 | 61 | #define sign_Percent 0x4882 |
ghz2000 | 0:e64e0d7aad81 | 62 | #define sign_And 0x3629 |
ghz2000 | 0:e64e0d7aad81 | 63 | #define sign_Quot 0x0800 |
ghz2000 | 0:e64e0d7aad81 | 64 | #define sign_RoundBracketS 0x0818 |
ghz2000 | 0:e64e0d7aad81 | 65 | #define sign_RoundBracketE 0x2402 |
ghz2000 | 0:e64e0d7aad81 | 66 | #define sign_Asta 0x3C1E |
ghz2000 | 0:e64e0d7aad81 | 67 | #define sign_Plus 0x1414 |
ghz2000 | 0:e64e0d7aad81 | 68 | #define sign_Comma 0x0002 |
ghz2000 | 0:e64e0d7aad81 | 69 | #define sign_Minus 0x0410 |
ghz2000 | 0:e64e0d7aad81 | 70 | #define sign_Slash 0x0802 |
ghz2000 | 0:e64e0d7aad81 | 71 | #define sign_Colon 0x1004 |
ghz2000 | 0:e64e0d7aad81 | 72 | #define sign_SemiColon 0x1002 |
ghz2000 | 0:e64e0d7aad81 | 73 | #define sign_AngleS 0x0808 |
ghz2000 | 0:e64e0d7aad81 | 74 | #define sign_Equal 0x0430 |
ghz2000 | 0:e64e0d7aad81 | 75 | #define sign_AngleE 0x2002 |
ghz2000 | 0:e64e0d7aad81 | 76 | #define sign_Question 0x4314 |
ghz2000 | 0:e64e0d7aad81 | 77 | #define sign_At 0x5331 |
ghz2000 | 0:e64e0d7aad81 | 78 | #define sign_BoxS 0x2222 |
ghz2000 | 0:e64e0d7aad81 | 79 | #define sign_En 0x2C14 |
ghz2000 | 0:e64e0d7aad81 | 80 | #define sign_BoxE 0xA28 |
ghz2000 | 0:e64e0d7aad81 | 81 | #define sign_Hat 0x0900 |
ghz2000 | 0:e64e0d7aad81 | 82 | #define sign_Underbar 0x0020 |
ghz2000 | 0:e64e0d7aad81 | 83 | #define sign_Grave 0x2000 |
ghz2000 | 0:e64e0d7aad81 | 84 | #define sign_CurlyBracketS 0x2622 |
ghz2000 | 0:e64e0d7aad81 | 85 | #define sign_CurlyBracketE 0x0A38 |
ghz2000 | 0:e64e0d7aad81 | 86 | #define sign_Tate 0x4001 |
ghz2000 | 0:e64e0d7aad81 | 87 | #define sign_Child 0x0200 |
ghz2000 | 0:e64e0d7aad81 | 88 | |
ghz2000 | 0:e64e0d7aad81 | 89 | |
ghz2000 | 0:e64e0d7aad81 | 90 | #define sign_a 0x07B1 |
ghz2000 | 0:e64e0d7aad81 | 91 | #define sign_b 0x44B1 |
ghz2000 | 0:e64e0d7aad81 | 92 | #define sign_c 0x0431 |
ghz2000 | 0:e64e0d7aad81 | 93 | #define sign_d 0x05B1 |
ghz2000 | 0:e64e0d7aad81 | 94 | #define sign_e 0x0423 |
ghz2000 | 0:e64e0d7aad81 | 95 | #define sign_f 0x4601 |
ghz2000 | 0:e64e0d7aad81 | 96 | #define sign_g 0x23B0 |
ghz2000 | 0:e64e0d7aad81 | 97 | #define sign_h 0x4405 |
ghz2000 | 0:e64e0d7aad81 | 98 | #define sign_i 0x0004 |
ghz2000 | 0:e64e0d7aad81 | 99 | #define sign_j 0x01A0 |
ghz2000 | 0:e64e0d7aad81 | 100 | #define sign_k 0x180C |
ghz2000 | 0:e64e0d7aad81 | 101 | #define sign_l 0x1004 |
ghz2000 | 0:e64e0d7aad81 | 102 | #define sign_m 0x0495 |
ghz2000 | 0:e64e0d7aad81 | 103 | #define sign_n 0x0405 |
ghz2000 | 0:e64e0d7aad81 | 104 | #define sign_o 0x04B1 |
ghz2000 | 0:e64e0d7aad81 | 105 | #define sign_p 0x4E01 |
ghz2000 | 0:e64e0d7aad81 | 106 | #define sign_q 0x2390 |
ghz2000 | 0:e64e0d7aad81 | 107 | #define sign_r 0x0401 |
ghz2000 | 0:e64e0d7aad81 | 108 | #define sign_s 0x0038 |
ghz2000 | 0:e64e0d7aad81 | 109 | #define sign_t 0x4421 |
ghz2000 | 0:e64e0d7aad81 | 110 | #define sign_u 0x00A1 |
ghz2000 | 0:e64e0d7aad81 | 111 | #define sign_v 0x0003 |
ghz2000 | 0:e64e0d7aad81 | 112 | #define sign_w 0x008B |
ghz2000 | 0:e64e0d7aad81 | 113 | #define sign_x 0x280A |
ghz2000 | 0:e64e0d7aad81 | 114 | #define sign_y 0x11B0 |
ghz2000 | 0:e64e0d7aad81 | 115 | #define sign_z 0x0422 |
ghz2000 | 0:e64e0d7aad81 | 116 | |
ghz2000 | 0:e64e0d7aad81 | 117 | #define sign_0 0x43A1 |
ghz2000 | 0:e64e0d7aad81 | 118 | #define sign_1 0x0980 |
ghz2000 | 0:e64e0d7aad81 | 119 | #define sign_2 0x0731 |
ghz2000 | 0:e64e0d7aad81 | 120 | #define sign_3 0x07B0 |
ghz2000 | 0:e64e0d7aad81 | 121 | #define sign_4 0x4590 |
ghz2000 | 0:e64e0d7aad81 | 122 | #define sign_5 0x46B0 |
ghz2000 | 0:e64e0d7aad81 | 123 | #define sign_6 0x46B1 |
ghz2000 | 0:e64e0d7aad81 | 124 | #define sign_7 0x4380 |
ghz2000 | 0:e64e0d7aad81 | 125 | #define sign_8 0x47B1 |
ghz2000 | 0:e64e0d7aad81 | 126 | #define sign_9 0x4790 |
ghz2000 | 0:e64e0d7aad81 | 127 | |
ghz2000 | 0:e64e0d7aad81 | 128 | #define sign_dot 0x0040 |
ghz2000 | 0:e64e0d7aad81 | 129 | |
ghz2000 | 0:e64e0d7aad81 | 130 | #define sign_ 0x0000 |
ghz2000 | 0:e64e0d7aad81 | 131 | |
ghz2000 | 0:e64e0d7aad81 | 132 | //#define sign_ 0x |
ghz2000 | 0:e64e0d7aad81 | 133 | // 0x8000 表示用終端文字 |
ghz2000 | 0:e64e0d7aad81 | 134 | |
ghz2000 | 0:e64e0d7aad81 | 135 | |
ghz2000 | 0:e64e0d7aad81 | 136 | #define __LEN 30 |
ghz2000 | 0:e64e0d7aad81 | 137 | |
ghz2000 | 2:eb91996f0a20 | 138 | /** Ghz2000 LED 14Segment Display |
ghz2000 | 2:eb91996f0a20 | 139 | * |
ghz2000 | 2:eb91996f0a20 | 140 | * http://ghz2000.dip.jp/wordpress/?p=665 |
ghz2000 | 2:eb91996f0a20 | 141 | * |
ghz2000 | 2:eb91996f0a20 | 142 | * LED 14セグ表示器用ライブラリです。 |
ghz2000 | 2:eb91996f0a20 | 143 | * |
ghz2000 | 2:eb91996f0a20 | 144 | * Used for showing Alphanumelic LED 14 Segment Display. |
ghz2000 | 2:eb91996f0a20 | 145 | * This library comment was written in Japanese. |
ghz2000 | 2:eb91996f0a20 | 146 | * The reason why for Japanese beginner. |
ghz2000 | 2:eb91996f0a20 | 147 | * |
ghz2000 | 2:eb91996f0a20 | 148 | * @attention |
ghz2000 | 2:eb91996f0a20 | 149 | * このバージョンでは8桁のみ動作します。カスケードできません。 |
ghz2000 | 2:eb91996f0a20 | 150 | * また輝度も使用できません。 |
ghz2000 | 2:eb91996f0a20 | 151 | * |
ghz2000 | 2:eb91996f0a20 | 152 | * Example: |
ghz2000 | 2:eb91996f0a20 | 153 | * @code |
ghz2000 | 2:eb91996f0a20 | 154 | * #include "mbed.h" |
ghz2000 | 2:eb91996f0a20 | 155 | * #include "lib14Seg.hpp" |
ghz2000 | 2:eb91996f0a20 | 156 | * |
ghz2000 | 2:eb91996f0a20 | 157 | * int main(){ |
ghz2000 | 2:eb91996f0a20 | 158 | * LED14Seg.init(SPI_MOSI, SPI_MISO, SPI_SCK, RCK, 0x04, 8); |
ghz2000 | 2:eb91996f0a20 | 159 | * |
ghz2000 | 2:eb91996f0a20 | 160 | * LED14Seg.setChar("ABCDEFGHIJKLMNOPQRSTUVWXYZ"); |
ghz2000 | 2:eb91996f0a20 | 161 | * LED14Seg.showStop(); |
ghz2000 | 2:eb91996f0a20 | 162 | * LED14Seg.setScrollSpeed(300); |
ghz2000 | 2:eb91996f0a20 | 163 | * while(1){}; |
ghz2000 | 2:eb91996f0a20 | 164 | * } |
ghz2000 | 2:eb91996f0a20 | 165 | * @endcode |
ghz2000 | 2:eb91996f0a20 | 166 | */ |
ghz2000 | 2:eb91996f0a20 | 167 | class C14Segment |
ghz2000 | 2:eb91996f0a20 | 168 | { |
ghz2000 | 0:e64e0d7aad81 | 169 | private: |
ghz2000 | 2:eb91996f0a20 | 170 | uint16_t m_view[8]; |
ghz2000 | 2:eb91996f0a20 | 171 | uint16_t m_str[__LEN]; |
ghz2000 | 2:eb91996f0a20 | 172 | static const uint16_t ascii[]; |
ghz2000 | 2:eb91996f0a20 | 173 | PinName m_RCK; |
ghz2000 | 2:eb91996f0a20 | 174 | PinName m_MOSI; |
ghz2000 | 2:eb91996f0a20 | 175 | PinName m_MISO; |
ghz2000 | 2:eb91996f0a20 | 176 | PinName m_SCK; |
ghz2000 | 2:eb91996f0a20 | 177 | int m_kido; |
ghz2000 | 2:eb91996f0a20 | 178 | int m_ViewLength; |
ghz2000 | 2:eb91996f0a20 | 179 | int m_speed; |
ghz2000 | 2:eb91996f0a20 | 180 | |
ghz2000 | 2:eb91996f0a20 | 181 | SPI *mp_SPIdevice; |
ghz2000 | 2:eb91996f0a20 | 182 | DigitalOut *mp_DigitalOutRCK; |
ghz2000 | 2:eb91996f0a20 | 183 | |
ghz2000 | 2:eb91996f0a20 | 184 | void setSPI(PinName MOSI, PinName MISO, PinName SCK, PinName RCK); |
ghz2000 | 2:eb91996f0a20 | 185 | void setViewLength(int ViewLength); |
ghz2000 | 0:e64e0d7aad81 | 186 | |
ghz2000 | 0:e64e0d7aad81 | 187 | public: |
ghz2000 | 2:eb91996f0a20 | 188 | C14Segment(); |
ghz2000 | 2:eb91996f0a20 | 189 | |
ghz2000 | 2:eb91996f0a20 | 190 | /** イニシャライザ 最初に実行してください。 |
ghz2000 | 2:eb91996f0a20 | 191 | * |
ghz2000 | 2:eb91996f0a20 | 192 | * @note |
ghz2000 | 2:eb91996f0a20 | 193 | * 輝度は現在使えません。 Lengthは現在8のみです。 |
ghz2000 | 2:eb91996f0a20 | 194 | */ |
ghz2000 | 2:eb91996f0a20 | 195 | void init( PinName SPI_MOSI, //!< MOSI |
ghz2000 | 2:eb91996f0a20 | 196 | PinName SPI_MISO, //!< MISO 接続不要 |
ghz2000 | 2:eb91996f0a20 | 197 | PinName SPI_SCK, //!< SCK |
ghz2000 | 2:eb91996f0a20 | 198 | PinName RCK, //!< Latch |
ghz2000 | 2:eb91996f0a20 | 199 | int kido, //!< 現在使えません |
ghz2000 | 2:eb91996f0a20 | 200 | int ViewLength //!< 8桁のみ |
ghz2000 | 2:eb91996f0a20 | 201 | ); |
ghz2000 | 2:eb91996f0a20 | 202 | void setChar(char *); //!< 文字列をセットします。 30文字まで |
ghz2000 | 2:eb91996f0a20 | 203 | void showStop(); //!< 格納した文字列を表示する |
ghz2000 | 2:eb91996f0a20 | 204 | void scroll(); //!< 格納した文字列をスクロール表示する |
ghz2000 | 2:eb91996f0a20 | 205 | void setScrollSpeed(int scrollSpeed); //!< スクロールスピードを設定する |
ghz2000 | 2:eb91996f0a20 | 206 | |
ghz2000 | 2:eb91996f0a20 | 207 | void update(); |
ghz2000 | 2:eb91996f0a20 | 208 | |
ghz2000 | 2:eb91996f0a20 | 209 | void setBlight(int kido); //4桁モデルのみで有効 |
ghz2000 | 2:eb91996f0a20 | 210 | void putnum(); //未実装 |
ghz2000 | 2:eb91996f0a20 | 211 | void cls(); //未実装 |
ghz2000 | 2:eb91996f0a20 | 212 | void showCycleX(); //未実装 |
ghz2000 | 2:eb91996f0a20 | 213 | void showCycleO(); //未実装 |
ghz2000 | 0:e64e0d7aad81 | 214 | |
ghz2000 | 0:e64e0d7aad81 | 215 | }; |
ghz2000 | 0:e64e0d7aad81 | 216 | |
ghz2000 | 0:e64e0d7aad81 | 217 | extern C14Segment LED14Seg; |
ghz2000 | 0:e64e0d7aad81 | 218 | |
ghz2000 | 0:e64e0d7aad81 | 219 | #endif |