This is a library for the JY-LKM1638 Display
LKM1638.cpp@0:c05022d4f68c, 2013-08-19 (annotated)
- Committer:
- mr63
- Date:
- Mon Aug 19 17:09:38 2013 +0000
- Revision:
- 0:c05022d4f68c
This is a library for the JY-LKM1638 Display
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mr63 | 0:c05022d4f68c | 1 | |
mr63 | 0:c05022d4f68c | 2 | #include "mbed.h" |
mr63 | 0:c05022d4f68c | 3 | #include "LKM1638.h" |
mr63 | 0:c05022d4f68c | 4 | |
mr63 | 0:c05022d4f68c | 5 | |
mr63 | 0:c05022d4f68c | 6 | const char READMODE = 0x42; |
mr63 | 0:c05022d4f68c | 7 | const char INTENSITY = 0x00; //Intensity of LED and Seven Segment Displays (0-7) |
mr63 | 0:c05022d4f68c | 8 | const int WAIT = 1; |
mr63 | 0:c05022d4f68c | 9 | |
mr63 | 0:c05022d4f68c | 10 | |
mr63 | 0:c05022d4f68c | 11 | //MPL3115A2 Class Constructor |
mr63 | 0:c05022d4f68c | 12 | LKM1636::LKM1636(PinName pin1, PinName pin2, PinName pin3) :_Strobe(pin1),_CLK(pin2),_Data(pin3) |
mr63 | 0:c05022d4f68c | 13 | { |
mr63 | 0:c05022d4f68c | 14 | _Data.mode(PullUp); |
mr63 | 0:c05022d4f68c | 15 | |
mr63 | 0:c05022d4f68c | 16 | } |
mr63 | 0:c05022d4f68c | 17 | |
mr63 | 0:c05022d4f68c | 18 | |
mr63 | 0:c05022d4f68c | 19 | //Driver Function that is used to write any printable char to the seven segment displays 0-7 |
mr63 | 0:c05022d4f68c | 20 | void LKM1636::displaychar (unsigned char value, unsigned char Seg_num, bool decimal) //Seg_num 0-7 ____,____ |
mr63 | 0:c05022d4f68c | 21 | { |
mr63 | 0:c05022d4f68c | 22 | |
mr63 | 0:c05022d4f68c | 23 | unsigned char address; |
mr63 | 0:c05022d4f68c | 24 | unsigned char Seg_value=0; |
mr63 | 0:c05022d4f68c | 25 | address = 0xC0 + Seg_num * 2; //Base Address for Segments is 0xC0 Each segment uses to Bytes of Mem. |
mr63 | 0:c05022d4f68c | 26 | Seg_value = getchar(value); |
mr63 | 0:c05022d4f68c | 27 | if(decimal) |
mr63 | 0:c05022d4f68c | 28 | Seg_value = Seg_value | 0x80; |
mr63 | 0:c05022d4f68c | 29 | if(Seg_value<0xff) // If Seg_value == 0xFF then character was not recognized |
mr63 | 0:c05022d4f68c | 30 | { |
mr63 | 0:c05022d4f68c | 31 | _Strobe = 0; |
mr63 | 0:c05022d4f68c | 32 | SendChar(address); |
mr63 | 0:c05022d4f68c | 33 | SendChar(Seg_value); |
mr63 | 0:c05022d4f68c | 34 | _Strobe = 1; |
mr63 | 0:c05022d4f68c | 35 | Delay(WAIT); |
mr63 | 0:c05022d4f68c | 36 | _Strobe = 0; |
mr63 | 0:c05022d4f68c | 37 | SendChar(INTENSITY | 0x88); |
mr63 | 0:c05022d4f68c | 38 | _Strobe = 1; |
mr63 | 0:c05022d4f68c | 39 | } |
mr63 | 0:c05022d4f68c | 40 | |
mr63 | 0:c05022d4f68c | 41 | |
mr63 | 0:c05022d4f68c | 42 | |
mr63 | 0:c05022d4f68c | 43 | } |
mr63 | 0:c05022d4f68c | 44 | |
mr63 | 0:c05022d4f68c | 45 | |
mr63 | 0:c05022d4f68c | 46 | //Prints a Long int to the 8 Seven Segment displays |
mr63 | 0:c05022d4f68c | 47 | void LKM1636::Clear() //bank is either Seven Segs 0-3 Bank==0 or Segs 4-7 Bank==1 |
mr63 | 0:c05022d4f68c | 48 | { |
mr63 | 0:c05022d4f68c | 49 | unsigned long temp1=0; |
mr63 | 0:c05022d4f68c | 50 | |
mr63 | 0:c05022d4f68c | 51 | for(temp1=0;temp1<8;temp1++) |
mr63 | 0:c05022d4f68c | 52 | { |
mr63 | 0:c05022d4f68c | 53 | displaychar (' ',temp1,0); |
mr63 | 0:c05022d4f68c | 54 | } |
mr63 | 0:c05022d4f68c | 55 | |
mr63 | 0:c05022d4f68c | 56 | } |
mr63 | 0:c05022d4f68c | 57 | |
mr63 | 0:c05022d4f68c | 58 | |
mr63 | 0:c05022d4f68c | 59 | |
mr63 | 0:c05022d4f68c | 60 | ///Writes an 8bool number to either the first or second bank of 4 seven segment displays |
mr63 | 0:c05022d4f68c | 61 | |
mr63 | 0:c05022d4f68c | 62 | void LKM1636::Write_Short(unsigned char value, bool bank) //bank is either Seven Segs 0-3 Bank==0 or Segs 4-7 Bank==1 |
mr63 | 0:c05022d4f68c | 63 | { |
mr63 | 0:c05022d4f68c | 64 | unsigned char temp=0; |
mr63 | 0:c05022d4f68c | 65 | unsigned char Seg_number = 0; |
mr63 | 0:c05022d4f68c | 66 | if(bank) |
mr63 | 0:c05022d4f68c | 67 | Seg_number = 5; |
mr63 | 0:c05022d4f68c | 68 | temp = value/100; |
mr63 | 0:c05022d4f68c | 69 | temp = temp%10; |
mr63 | 0:c05022d4f68c | 70 | displaychar (temp, Seg_number,0); |
mr63 | 0:c05022d4f68c | 71 | temp = value/10; |
mr63 | 0:c05022d4f68c | 72 | temp = temp%10; |
mr63 | 0:c05022d4f68c | 73 | displaychar (temp, Seg_number+1,0); |
mr63 | 0:c05022d4f68c | 74 | temp = value%10; |
mr63 | 0:c05022d4f68c | 75 | displaychar (temp, Seg_number+2,0); |
mr63 | 0:c05022d4f68c | 76 | } |
mr63 | 0:c05022d4f68c | 77 | //Prints a Long int to the 8 Seven Segment displays |
mr63 | 0:c05022d4f68c | 78 | void LKM1636::Write_Long(unsigned long int value) //bank is either Seven Segs 0-3 Bank==0 or Segs 4-7 Bank==1 |
mr63 | 0:c05022d4f68c | 79 | { |
mr63 | 0:c05022d4f68c | 80 | unsigned long temp1=0; |
mr63 | 0:c05022d4f68c | 81 | |
mr63 | 0:c05022d4f68c | 82 | temp1 = (value/10000000); |
mr63 | 0:c05022d4f68c | 83 | temp1 = temp1%10; |
mr63 | 0:c05022d4f68c | 84 | displaychar ((unsigned char)temp1,0,0); |
mr63 | 0:c05022d4f68c | 85 | |
mr63 | 0:c05022d4f68c | 86 | temp1 = (value/1000000); |
mr63 | 0:c05022d4f68c | 87 | temp1 = temp1%10; |
mr63 | 0:c05022d4f68c | 88 | displaychar ((unsigned char)temp1,1,0); |
mr63 | 0:c05022d4f68c | 89 | |
mr63 | 0:c05022d4f68c | 90 | temp1 = (value/100000); |
mr63 | 0:c05022d4f68c | 91 | temp1 = temp1%10; |
mr63 | 0:c05022d4f68c | 92 | displaychar ((unsigned char)temp1,2,0); |
mr63 | 0:c05022d4f68c | 93 | |
mr63 | 0:c05022d4f68c | 94 | temp1 = (value/10000); |
mr63 | 0:c05022d4f68c | 95 | temp1 = temp1%10; |
mr63 | 0:c05022d4f68c | 96 | displaychar ((unsigned char)temp1,3,0); |
mr63 | 0:c05022d4f68c | 97 | |
mr63 | 0:c05022d4f68c | 98 | temp1 = (value/1000); |
mr63 | 0:c05022d4f68c | 99 | temp1 = temp1%10; |
mr63 | 0:c05022d4f68c | 100 | displaychar ((unsigned char)temp1,4,0); |
mr63 | 0:c05022d4f68c | 101 | |
mr63 | 0:c05022d4f68c | 102 | temp1 =(value/100); |
mr63 | 0:c05022d4f68c | 103 | temp1 = temp1%10; |
mr63 | 0:c05022d4f68c | 104 | displaychar ((unsigned char)temp1,5,0); |
mr63 | 0:c05022d4f68c | 105 | |
mr63 | 0:c05022d4f68c | 106 | temp1 = (value/10); |
mr63 | 0:c05022d4f68c | 107 | temp1 = temp1%10; |
mr63 | 0:c05022d4f68c | 108 | displaychar ((unsigned char)temp1,6,0); |
mr63 | 0:c05022d4f68c | 109 | |
mr63 | 0:c05022d4f68c | 110 | temp1 = (value%10); |
mr63 | 0:c05022d4f68c | 111 | displaychar ((unsigned char)temp1,7,0); |
mr63 | 0:c05022d4f68c | 112 | } |
mr63 | 0:c05022d4f68c | 113 | |
mr63 | 0:c05022d4f68c | 114 | // Serializes the Value passed into the character variable and send out using the data pin |
mr63 | 0:c05022d4f68c | 115 | void LKM1636::SendChar(unsigned char Character) |
mr63 | 0:c05022d4f68c | 116 | { |
mr63 | 0:c05022d4f68c | 117 | unsigned char t; |
mr63 | 0:c05022d4f68c | 118 | _CLK =1; |
mr63 | 0:c05022d4f68c | 119 | _Data.output(); |
mr63 | 0:c05022d4f68c | 120 | Delay(WAIT); |
mr63 | 0:c05022d4f68c | 121 | for (t=0;t<8;t++) //Serialize Address and put out on Data Pin |
mr63 | 0:c05022d4f68c | 122 | { |
mr63 | 0:c05022d4f68c | 123 | |
mr63 | 0:c05022d4f68c | 124 | _Data = (Character & 0x01); |
mr63 | 0:c05022d4f68c | 125 | Character = Character>>1; |
mr63 | 0:c05022d4f68c | 126 | ToggleClock (); |
mr63 | 0:c05022d4f68c | 127 | } |
mr63 | 0:c05022d4f68c | 128 | _Data.input(); |
mr63 | 0:c05022d4f68c | 129 | |
mr63 | 0:c05022d4f68c | 130 | } |
mr63 | 0:c05022d4f68c | 131 | /// Toggles the Clock pin low to high with a minimal delay between the toggle |
mr63 | 0:c05022d4f68c | 132 | void LKM1636::ToggleClock () |
mr63 | 0:c05022d4f68c | 133 | { |
mr63 | 0:c05022d4f68c | 134 | _CLK = 0; |
mr63 | 0:c05022d4f68c | 135 | Delay(WAIT); |
mr63 | 0:c05022d4f68c | 136 | _CLK = 1; |
mr63 | 0:c05022d4f68c | 137 | Delay(WAIT); |
mr63 | 0:c05022d4f68c | 138 | } |
mr63 | 0:c05022d4f68c | 139 | /// Delay for Tick * Tocks of system clock |
mr63 | 0:c05022d4f68c | 140 | /// |
mr63 | 0:c05022d4f68c | 141 | void LKM1636::Delay(unsigned int Tick) |
mr63 | 0:c05022d4f68c | 142 | { |
mr63 | 0:c05022d4f68c | 143 | unsigned int tock=0,t=0; |
mr63 | 0:c05022d4f68c | 144 | for(t=0;t<Tick;t++) |
mr63 | 0:c05022d4f68c | 145 | { |
mr63 | 0:c05022d4f68c | 146 | for(tock=0;tock<10;tock++); |
mr63 | 0:c05022d4f68c | 147 | } |
mr63 | 0:c05022d4f68c | 148 | |
mr63 | 0:c05022d4f68c | 149 | } |
mr63 | 0:c05022d4f68c | 150 | |
mr63 | 0:c05022d4f68c | 151 | /// Getchar takes a integer value 0-15 or ascii value '0' - 'F' |
mr63 | 0:c05022d4f68c | 152 | /// and returns the Seven Segment value needed to display the value |
mr63 | 0:c05022d4f68c | 153 | |
mr63 | 0:c05022d4f68c | 154 | unsigned char LKM1636::getchar(unsigned char value) |
mr63 | 0:c05022d4f68c | 155 | { |
mr63 | 0:c05022d4f68c | 156 | int seg_value = 0; |
mr63 | 0:c05022d4f68c | 157 | |
mr63 | 0:c05022d4f68c | 158 | switch(value) |
mr63 | 0:c05022d4f68c | 159 | { |
mr63 | 0:c05022d4f68c | 160 | case ('0'): |
mr63 | 0:c05022d4f68c | 161 | case (0): |
mr63 | 0:c05022d4f68c | 162 | seg_value = 0x3f; |
mr63 | 0:c05022d4f68c | 163 | break; |
mr63 | 0:c05022d4f68c | 164 | case ('1'): |
mr63 | 0:c05022d4f68c | 165 | case (1): |
mr63 | 0:c05022d4f68c | 166 | seg_value = 0x6; |
mr63 | 0:c05022d4f68c | 167 | break; |
mr63 | 0:c05022d4f68c | 168 | case ('2'): |
mr63 | 0:c05022d4f68c | 169 | case (2): |
mr63 | 0:c05022d4f68c | 170 | seg_value = 0x5b; |
mr63 | 0:c05022d4f68c | 171 | break; |
mr63 | 0:c05022d4f68c | 172 | case ('3'): |
mr63 | 0:c05022d4f68c | 173 | case (3): |
mr63 | 0:c05022d4f68c | 174 | seg_value = 0x4f; |
mr63 | 0:c05022d4f68c | 175 | break; |
mr63 | 0:c05022d4f68c | 176 | case ('4'): |
mr63 | 0:c05022d4f68c | 177 | case (4): |
mr63 | 0:c05022d4f68c | 178 | seg_value = 0x66; |
mr63 | 0:c05022d4f68c | 179 | break; |
mr63 | 0:c05022d4f68c | 180 | case ('5'): |
mr63 | 0:c05022d4f68c | 181 | case (5): |
mr63 | 0:c05022d4f68c | 182 | seg_value = 0x6d; |
mr63 | 0:c05022d4f68c | 183 | break; |
mr63 | 0:c05022d4f68c | 184 | case ('6'): |
mr63 | 0:c05022d4f68c | 185 | case (6): |
mr63 | 0:c05022d4f68c | 186 | seg_value = 0x7d; |
mr63 | 0:c05022d4f68c | 187 | break; |
mr63 | 0:c05022d4f68c | 188 | case ('7'): |
mr63 | 0:c05022d4f68c | 189 | case (7): |
mr63 | 0:c05022d4f68c | 190 | seg_value = 0x7; |
mr63 | 0:c05022d4f68c | 191 | break; |
mr63 | 0:c05022d4f68c | 192 | case ('8'): |
mr63 | 0:c05022d4f68c | 193 | case (8): |
mr63 | 0:c05022d4f68c | 194 | seg_value = 0x7f; |
mr63 | 0:c05022d4f68c | 195 | break; |
mr63 | 0:c05022d4f68c | 196 | case ('9'): |
mr63 | 0:c05022d4f68c | 197 | case (9): |
mr63 | 0:c05022d4f68c | 198 | seg_value = 0x6f; |
mr63 | 0:c05022d4f68c | 199 | break; |
mr63 | 0:c05022d4f68c | 200 | case ('A'): |
mr63 | 0:c05022d4f68c | 201 | case ('a'): |
mr63 | 0:c05022d4f68c | 202 | case (10): |
mr63 | 0:c05022d4f68c | 203 | seg_value = 0x77; |
mr63 | 0:c05022d4f68c | 204 | break; |
mr63 | 0:c05022d4f68c | 205 | case ('B'): |
mr63 | 0:c05022d4f68c | 206 | case ('b'): |
mr63 | 0:c05022d4f68c | 207 | case (11): |
mr63 | 0:c05022d4f68c | 208 | seg_value = 0x7c; |
mr63 | 0:c05022d4f68c | 209 | break; |
mr63 | 0:c05022d4f68c | 210 | case ('C'): |
mr63 | 0:c05022d4f68c | 211 | case ('c'): |
mr63 | 0:c05022d4f68c | 212 | case (12): |
mr63 | 0:c05022d4f68c | 213 | seg_value = 0x39; |
mr63 | 0:c05022d4f68c | 214 | break; |
mr63 | 0:c05022d4f68c | 215 | case ('D'): |
mr63 | 0:c05022d4f68c | 216 | case ('d'): |
mr63 | 0:c05022d4f68c | 217 | case (13): |
mr63 | 0:c05022d4f68c | 218 | seg_value = 0x5e; |
mr63 | 0:c05022d4f68c | 219 | break; |
mr63 | 0:c05022d4f68c | 220 | case ('E'): |
mr63 | 0:c05022d4f68c | 221 | case ('e'): |
mr63 | 0:c05022d4f68c | 222 | case (14): |
mr63 | 0:c05022d4f68c | 223 | seg_value = 0x79; |
mr63 | 0:c05022d4f68c | 224 | break; |
mr63 | 0:c05022d4f68c | 225 | case ('F'): |
mr63 | 0:c05022d4f68c | 226 | case ('f'): |
mr63 | 0:c05022d4f68c | 227 | case (15): |
mr63 | 0:c05022d4f68c | 228 | seg_value = 0x71; |
mr63 | 0:c05022d4f68c | 229 | break; |
mr63 | 0:c05022d4f68c | 230 | case ('.'): |
mr63 | 0:c05022d4f68c | 231 | seg_value = 0x80; |
mr63 | 0:c05022d4f68c | 232 | break; |
mr63 | 0:c05022d4f68c | 233 | case ('-'): |
mr63 | 0:c05022d4f68c | 234 | seg_value = 0x40; |
mr63 | 0:c05022d4f68c | 235 | break; |
mr63 | 0:c05022d4f68c | 236 | case (' '): |
mr63 | 0:c05022d4f68c | 237 | seg_value =0x0; |
mr63 | 0:c05022d4f68c | 238 | break; |
mr63 | 0:c05022d4f68c | 239 | default : |
mr63 | 0:c05022d4f68c | 240 | seg_value = 0xff; |
mr63 | 0:c05022d4f68c | 241 | break; |
mr63 | 0:c05022d4f68c | 242 | |
mr63 | 0:c05022d4f68c | 243 | } |
mr63 | 0:c05022d4f68c | 244 | return (seg_value); |
mr63 | 0:c05022d4f68c | 245 | } |
mr63 | 0:c05022d4f68c | 246 | |
mr63 | 0:c05022d4f68c | 247 | //Reads the current state of all 8 input buttons. The state of each button is returned as an 8bool value |
mr63 | 0:c05022d4f68c | 248 | //the bool to Sw map: |
mr63 | 0:c05022d4f68c | 249 | //Switch bool order bool# 7 6 5 4 3 2 1 0 //0x80 0x20 0x08 0x02 || 0x40 0x10 0x04 0x01 |
mr63 | 0:c05022d4f68c | 250 | // Sw# 1 5 2 6 3 7 4 8 |
mr63 | 0:c05022d4f68c | 251 | |
mr63 | 0:c05022d4f68c | 252 | unsigned char LKM1636::read_buttons () |
mr63 | 0:c05022d4f68c | 253 | { |
mr63 | 0:c05022d4f68c | 254 | unsigned char temp=0; |
mr63 | 0:c05022d4f68c | 255 | char d=0; |
mr63 | 0:c05022d4f68c | 256 | _Strobe = 0; |
mr63 | 0:c05022d4f68c | 257 | SendChar(READMODE); |
mr63 | 0:c05022d4f68c | 258 | //_Data = 1; |
mr63 | 0:c05022d4f68c | 259 | _CLK = 1; |
mr63 | 0:c05022d4f68c | 260 | Delay(WAIT); |
mr63 | 0:c05022d4f68c | 261 | for(d=0;d<32;d++) |
mr63 | 0:c05022d4f68c | 262 | { |
mr63 | 0:c05022d4f68c | 263 | if(!((d-1)%4)) |
mr63 | 0:c05022d4f68c | 264 | { |
mr63 | 0:c05022d4f68c | 265 | temp=temp<<1; |
mr63 | 0:c05022d4f68c | 266 | if(_Data) |
mr63 | 0:c05022d4f68c | 267 | temp+=1; |
mr63 | 0:c05022d4f68c | 268 | } |
mr63 | 0:c05022d4f68c | 269 | ToggleClock (); |
mr63 | 0:c05022d4f68c | 270 | } |
mr63 | 0:c05022d4f68c | 271 | _Strobe = 1; |
mr63 | 0:c05022d4f68c | 272 | return temp; |
mr63 | 0:c05022d4f68c | 273 | } |
mr63 | 0:c05022d4f68c | 274 | |
mr63 | 0:c05022d4f68c | 275 | //Takes the 8bool number returned from the read_buttons function and lights the corsponing LED to current switch posistion |
mr63 | 0:c05022d4f68c | 276 | void LKM1636::Switch_To_LED(unsigned char Switch_Values) |
mr63 | 0:c05022d4f68c | 277 | { |
mr63 | 0:c05022d4f68c | 278 | unsigned char t=0; |
mr63 | 0:c05022d4f68c | 279 | bool temp_state=0; |
mr63 | 0:c05022d4f68c | 280 | for(t=0; t<8; t++) |
mr63 | 0:c05022d4f68c | 281 | { |
mr63 | 0:c05022d4f68c | 282 | temp_state = (Switch_Values & 0x01); |
mr63 | 0:c05022d4f68c | 283 | Switch_Values= Switch_Values>>1; |
mr63 | 0:c05022d4f68c | 284 | switch (t) |
mr63 | 0:c05022d4f68c | 285 | { |
mr63 | 0:c05022d4f68c | 286 | case (0): |
mr63 | 0:c05022d4f68c | 287 | LED (7, temp_state); |
mr63 | 0:c05022d4f68c | 288 | break; |
mr63 | 0:c05022d4f68c | 289 | case (1): |
mr63 | 0:c05022d4f68c | 290 | LED (3, temp_state); |
mr63 | 0:c05022d4f68c | 291 | break; |
mr63 | 0:c05022d4f68c | 292 | case (2): |
mr63 | 0:c05022d4f68c | 293 | LED (6, temp_state); |
mr63 | 0:c05022d4f68c | 294 | break; |
mr63 | 0:c05022d4f68c | 295 | case (3): |
mr63 | 0:c05022d4f68c | 296 | LED (2, temp_state); |
mr63 | 0:c05022d4f68c | 297 | break; |
mr63 | 0:c05022d4f68c | 298 | case (4): |
mr63 | 0:c05022d4f68c | 299 | LED (5, temp_state); |
mr63 | 0:c05022d4f68c | 300 | break; |
mr63 | 0:c05022d4f68c | 301 | case (5): |
mr63 | 0:c05022d4f68c | 302 | LED (1, temp_state); |
mr63 | 0:c05022d4f68c | 303 | break; |
mr63 | 0:c05022d4f68c | 304 | case (6): |
mr63 | 0:c05022d4f68c | 305 | LED (4, temp_state); |
mr63 | 0:c05022d4f68c | 306 | break; |
mr63 | 0:c05022d4f68c | 307 | case (7): |
mr63 | 0:c05022d4f68c | 308 | LED (0, temp_state); |
mr63 | 0:c05022d4f68c | 309 | break; |
mr63 | 0:c05022d4f68c | 310 | default: |
mr63 | 0:c05022d4f68c | 311 | break; |
mr63 | 0:c05022d4f68c | 312 | } |
mr63 | 0:c05022d4f68c | 313 | |
mr63 | 0:c05022d4f68c | 314 | } |
mr63 | 0:c05022d4f68c | 315 | } |
mr63 | 0:c05022d4f68c | 316 | |
mr63 | 0:c05022d4f68c | 317 | //LED_Num (0-7)) corsponds to the LED that is to be written to state(1=led on, 0 = led off) |
mr63 | 0:c05022d4f68c | 318 | void LKM1636::LED (unsigned char LED_Num, bool state)//intensity can range from 0-7 |
mr63 | 0:c05022d4f68c | 319 | { |
mr63 | 0:c05022d4f68c | 320 | unsigned char LED_Address; |
mr63 | 0:c05022d4f68c | 321 | LED_Address = 0xC0 + (LED_Num*2) + 1; //LED are at odd address 1 to 15; |
mr63 | 0:c05022d4f68c | 322 | _Strobe = 0; |
mr63 | 0:c05022d4f68c | 323 | SendChar(LED_Address); |
mr63 | 0:c05022d4f68c | 324 | if(state) |
mr63 | 0:c05022d4f68c | 325 | SendChar(0x01); |
mr63 | 0:c05022d4f68c | 326 | else |
mr63 | 0:c05022d4f68c | 327 | SendChar(0x00); |
mr63 | 0:c05022d4f68c | 328 | _Strobe = 1; |
mr63 | 0:c05022d4f68c | 329 | Delay(WAIT); |
mr63 | 0:c05022d4f68c | 330 | _Strobe = 0; |
mr63 | 0:c05022d4f68c | 331 | SendChar(INTENSITY | 0x88); |
mr63 | 0:c05022d4f68c | 332 | _Strobe = 1; |
mr63 | 0:c05022d4f68c | 333 | } |
mr63 | 0:c05022d4f68c | 334 | //Takes a 8bool number and writes out the value to the 8 leds (0-7) |
mr63 | 0:c05022d4f68c | 335 | void LKM1636::LEDS (unsigned char LED_Values) |
mr63 | 0:c05022d4f68c | 336 | { |
mr63 | 0:c05022d4f68c | 337 | unsigned char temp; |
mr63 | 0:c05022d4f68c | 338 | bool temp_state = 0 ; |
mr63 | 0:c05022d4f68c | 339 | for(temp=0; temp<8; temp++) |
mr63 | 0:c05022d4f68c | 340 | { |
mr63 | 0:c05022d4f68c | 341 | temp_state = (LED_Values & 0x01); |
mr63 | 0:c05022d4f68c | 342 | LED (temp, temp_state); |
mr63 | 0:c05022d4f68c | 343 | LED_Values= LED_Values>>1; |
mr63 | 0:c05022d4f68c | 344 | } |
mr63 | 0:c05022d4f68c | 345 | } |