http://eleshop.jp/shop/g/g96I412/
Revision 0:f9d855cc36f4, committed 2014-02-23
- Comitter:
- shogo992
- Date:
- Sun Feb 23 17:47:17 2014 +0000
- Commit message:
- LD8035; http://eleshop.jp/shop/g/g96I412/
Changed in this revision
LD8035.cpp | Show annotated file Show diff for this revision Revisions of this file |
LD8035.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r 000000000000 -r f9d855cc36f4 LD8035.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LD8035.cpp Sun Feb 23 17:47:17 2014 +0000 @@ -0,0 +1,81 @@ +#include "LD8035.h" +#include "mbed.h" + +LD8035::LD8035(PinName G1, PinName G2, PinName G3, PinName G4, PinName G5, PinName G6, + PinName a_pin, PinName b_pin, PinName c_pin, PinName d_pin, PinName e_pin, + PinName f_pin, PinName g_pin, PinName dot_pin, PinName hyphen_pin) + : _GPin(G1,G2,G3,G4,G5,G6), _NumPin(a_pin,b_pin,c_pin,d_pin,e_pin,f_pin,g_pin), _DotPin(dot_pin), _HyphenPin(hyphen_pin) +{ + clear(); +} + +void LD8035::set_bars(int numbers[], bool dot_flags[], bool hyphen_flags[]) +{ + for(int i = 0 ; i < G_SIZE ; i++) { + _numbers[i] = numbers[i]; + _dot_flags[i] = dot_flags[i]; + _hyphen_flags[i] = hyphen_flags[i]; + } +} + +void LD8035::clear() +{ + _NumPin = 0x00; +} + +void LD8035::flush() +{ + for(int j = 0 ; j < 10 ; j++) { + for(int i = 0 ; i < G_SIZE ; i++) { + clear(); + _GPin = 1 << i; + switch(_numbers[i]) { + case 0: + _NumPin = 0x3f; + break; + case 1: + _NumPin = 0x06; + break; + case 2: + _NumPin = 0x5b; + break; + case 3: + _NumPin = 0x4f; + break; + case 4: + _NumPin = 0x66; + break; + case 5: + _NumPin = 0x6d; + break; + case 6: + _NumPin = 0x7d; + break; + case 7: + _NumPin = 0x27; + break; + case 8: + _NumPin = 0x7f; + break; + case 9: + _NumPin = 0x6f; + break; + default: + _NumPin = 0x79; + break; + } + if(_dot_flags[i] == true) { + _DotPin = 1; + } else { + _DotPin = 0; + } + if(_hyphen_flags[i] == true) { + _HyphenPin = 1; + } else { + _HyphenPin = 0; + } + wait_ms(WAIT_TIME); + } + } +} +
diff -r 000000000000 -r f9d855cc36f4 LD8035.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LD8035.h Sun Feb 23 17:47:17 2014 +0000 @@ -0,0 +1,32 @@ +#ifndef LD8035_H +#define LD8035_H + +#include "mbed.h" + +#define G_SIZE 6 +#define WAIT_TIME 3 + +class LD8035 +{ +public: + + LD8035(PinName G1, PinName G2, PinName G3, PinName G4, PinName G5, PinName G6, + PinName a_pin, PinName b_pin, PinName c_pin, PinName d_pin, PinName e_pin, + PinName f_pin, PinName g_pin, PinName dot_pin, PinName hyphen_pin); + + void set_bars(int numbers[],bool dot_flags[],bool hyphen_flags[]); + void clear(); + void flush(); + +private: + BusOut _GPin; + BusOut _NumPin; + BusOut _DotPin; + BusOut _HyphenPin; + + int _numbers[G_SIZE]; + bool _dot_flags[G_SIZE]; + bool _hyphen_flags[G_SIZE]; +}; + +#endif \ No newline at end of file