-
-
Save jboecker/1f37b5c0b44aec0d3f80 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define DCSBIOS_IRQ_SERIAL | |
#include <DcsBios.h> | |
#include <LedControl.h> | |
//pin 10 is connected to the DataIn | |
//pin 11 is connected to the CLK | |
//pin 12 is connected to LOAD | |
LedControl lc=LedControl(2,4,3,1);//DIN,CLK,LOAD,# OF IC's | |
unsigned char cl_row_map[48] = { | |
5, 5, 1, 1, | |
5, 5, 1, 1, | |
5, 5, 1, 1, | |
3, 3, 7, 7, | |
3, 3, 7, 7, | |
3, 3, 7, 7, | |
6, 6, 2, 2, | |
6, 6, 2, 2, | |
6, 6, 2, 2, | |
0, 0, 4, 4, | |
0, 0, 4, 4, | |
0, 0, 4, 4, | |
}; | |
#define SEG_DP (1<<7) | |
#define SEG_A (1<<6) | |
#define SEG_B (1<<5) | |
#define SEG_C (1<<4) | |
#define SEG_D (1<<3) | |
#define SEG_E (1<<2) | |
#define SEG_F (1<<1) | |
#define SEG_G (1<<0) | |
unsigned char cl_mask_map[48]= { | |
SEG_B, SEG_G, SEG_G, SEG_B, | |
SEG_C, SEG_E, SEG_E, SEG_C, | |
SEG_DP, SEG_D, SEG_D, SEG_DP, | |
SEG_B, SEG_G, SEG_G, SEG_B, | |
SEG_C, SEG_E, SEG_E, SEG_C, | |
SEG_DP, SEG_D, SEG_D, SEG_DP, | |
SEG_B, SEG_G, SEG_G, SEG_B, | |
SEG_C, SEG_E, SEG_E, SEG_C, | |
SEG_DP, SEG_D, SEG_D, SEG_DP, | |
SEG_B, SEG_G, SEG_G, SEG_B, | |
SEG_C, SEG_E, SEG_E, SEG_C, | |
SEG_DP, SEG_D, SEG_D, SEG_DP, | |
}; | |
unsigned char max7219_rows[8]; | |
void setup() { | |
DcsBios::setup(); | |
memset(max7219_rows, 0xff, sizeof(max7219_rows)); | |
lc.shutdown(0,false); //turn on the display | |
lc.setIntensity(0,8);//set the brightness | |
lc.clearDisplay(0); //clear rthe display and get ready for new data | |
} | |
void updateCautionLights(unsigned int address, unsigned int data) { | |
unsigned char clp_row = (address - 0x10d4) * 2; | |
unsigned char start_index = clp_row * 4; | |
unsigned char column = 0; | |
unsigned char i; | |
bool is_on; | |
for (i=0; i<16; i++) { | |
is_on = data & 0x01; | |
// set caution light state (clp_row, column, is_on) | |
if (is_on) { | |
max7219_rows[cl_row_map[start_index+i]] |= cl_mask_map[start_index+i]; | |
} else { | |
max7219_rows[cl_row_map[start_index+i]] &= ~(cl_mask_map[start_index+i]); | |
} | |
data >>= 1; | |
column++; | |
if (column == 4) { | |
clp_row++; | |
column = 0; | |
} | |
} | |
} | |
void onClpData1Change(unsigned int newValue) { | |
updateCautionLights(0x10d4, newValue); | |
} | |
DcsBios::IntegerBuffer clpData1(0x10d4, 0xffff, 0, onClpData1Change); | |
void onClpData2Change(unsigned int newValue) { | |
updateCautionLights(0x10d6, newValue); | |
} | |
DcsBios::IntegerBuffer clpData2(0x10d6, 0xffff, 0, onClpData2Change); | |
void onClpData3Change(unsigned int newValue) { | |
updateCautionLights(0x10d8, newValue); | |
} | |
DcsBios::IntegerBuffer clpData3(0x10d8, 0xffff, 0, onClpData3Change); | |
void loop() { | |
DcsBios::loop(); | |
// update MAX7219 | |
unsigned char i; | |
for (i=0; i<8; i++) { | |
lc.setRow(0, i, max7219_rows[i]); | |
} | |
} |
Thank you so much !!!
thanks dear
Can I use this code with L-39??
best regards
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
updated to work with v0.2 or later of the DCS-BIOS Arduino library