got LEDs working, ribbon trail program initially implemented
- fixed soft I2C master set hi/lo routines - fixed bug in matrix_send not setting all LEDs from map - fix AWU interrupt not firing; requires EXTI line to be configured too even if unused - fixed wrong dividers used in system clock set function
This commit is contained in:
@@ -55,16 +55,16 @@ void lp_ribbon_upward(uint16_t wait, uint16_t rate, uint8_t fade)
|
||||
x = s[2]++;
|
||||
|
||||
// are we done?
|
||||
if (x > sizeof(led_set.ribbon)) {
|
||||
if (x >= sizeof(led_set.ribbon)) {
|
||||
s[0] = 0;
|
||||
s[1] = wait;
|
||||
break;
|
||||
}
|
||||
|
||||
// fade in and up
|
||||
led_set.ribbon[x] = 0x40;
|
||||
if (x) led_set.ribbon[x - 1] = 0x70;
|
||||
if (x > 1) led_set.ribbon[x - 2] = 0xff;
|
||||
led_set.ribbon[x] = 0x20;
|
||||
if (x) led_set.ribbon[x - 1] = 0x66;
|
||||
if (x > 1) led_set.ribbon[x - 2] = 0xd0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ void lp_ribbon_upward(uint16_t wait, uint16_t rate, uint8_t fade)
|
||||
if (led_set.ribbon[i] >= fade) {
|
||||
led_set.ribbon[i] -= fade;
|
||||
} else {
|
||||
led_set.ribbon[i] = 0;
|
||||
led_set.ribbon[i] >>= 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
|
||||
|
||||
#define AW20X_DIM 31 // initial global current setting
|
||||
#define AW20X_DIM 28 // initial global current setting
|
||||
|
||||
#define AW20X_COLS 6
|
||||
#define AW20X_ROWS 12
|
||||
@@ -24,17 +24,16 @@
|
||||
|
||||
|
||||
AW20x awled;
|
||||
static uint8_t awled_fade[AW20X_FADE_COUNT];
|
||||
uint8_t awled_fade[AW20X_FADE_COUNT];
|
||||
|
||||
static uint8_t led_matrix_needs_update = 0;
|
||||
|
||||
uint16_t led_map_size;
|
||||
const LedMap led_map = {
|
||||
// map is 1-based to match part numbers on the board
|
||||
{ // ribbon
|
||||
1, 25, 13, 49,
|
||||
.ribbon = { // ribbon
|
||||
13, 25, 1, 49,
|
||||
37, 14,
|
||||
28, 2, 38,
|
||||
26, 2, 38,
|
||||
50, 3,
|
||||
27, 15,
|
||||
39, 51,
|
||||
@@ -54,19 +53,20 @@ const LedMap led_map = {
|
||||
55, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
8, 20, 32,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0,
|
||||
8, 0, 0, 20, 0, 0, 32,
|
||||
0, 0
|
||||
},
|
||||
{ // "A"
|
||||
.a = { // "A"
|
||||
9, 21, 33, 0, 0, 0, 45, 57, 10,
|
||||
22,
|
||||
34, 46, 58, 11, 23, 35, 47, 59, 12
|
||||
},
|
||||
{ // "//" left one
|
||||
.ii_lf = { // "//" left one
|
||||
61, 62, 63, 64, 44
|
||||
},
|
||||
{ // "//" right one
|
||||
.ii_rt = { // "//" right one
|
||||
60, 48, 36, 24, 56
|
||||
}
|
||||
};
|
||||
@@ -95,8 +95,6 @@ void matrix_init()
|
||||
aw20x_set_dim_global(&awled, AW20X_DIM);
|
||||
aw20x_set_fade(&awled);
|
||||
aw20x_led_enable_range(&awled, 0, (AW20X_COLS * AW20X_MAX_ROWS) - 1);
|
||||
|
||||
led_map_size = sizeof(led_map.ribbon) + sizeof(led_map.a) + sizeof(led_map.ii_lf) + sizeof(led_map.ii_rt);
|
||||
}
|
||||
|
||||
void matrix_flag_update()
|
||||
@@ -104,9 +102,14 @@ void matrix_flag_update()
|
||||
led_matrix_needs_update = 1;
|
||||
}
|
||||
|
||||
/*
|
||||
static uint8_t delay = 0;
|
||||
static uint8_t work = 0;
|
||||
*/
|
||||
|
||||
void matrix_send()
|
||||
{
|
||||
int8_t i;
|
||||
uint32_t i;
|
||||
uint8_t *fade = awled_fade;
|
||||
uint8_t *map = (uint8_t *)&led_map;
|
||||
uint8_t *set = (uint8_t *)&led_set;
|
||||
@@ -115,14 +118,35 @@ void matrix_send()
|
||||
led_matrix_needs_update = 0;
|
||||
|
||||
// remap data for sending
|
||||
for (i = 0; i < led_map_size; i++) {
|
||||
if ((*map) & (*map <= AW20X_FADE_COUNT)) {
|
||||
fade[*map - 1] = *set;
|
||||
for (i = 0; i < sizeof(led_map); i++) {
|
||||
if ((*map) && ((*map) <= AW20X_FADE_COUNT)) {
|
||||
fade[(*map) - 1] = *set;
|
||||
}
|
||||
map++;
|
||||
set++;
|
||||
map++; set++;
|
||||
}
|
||||
|
||||
/* testing
|
||||
if (delay) {
|
||||
delay--;
|
||||
} else {
|
||||
delay = 20;
|
||||
for (int i = 0; i < sizeof(led_map.ribbon); i++) {
|
||||
if (led_map.ribbon[i]) {
|
||||
awled_fade[led_map.ribbon[i] - 1] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (led_map.ribbon[work]) {
|
||||
awled_fade[led_map.ribbon[work] - 1] = 0xff;
|
||||
}
|
||||
work++;
|
||||
|
||||
if (work >= sizeof(led_map.ribbon)) work = 0;
|
||||
|
||||
matrix_flag_update();
|
||||
}
|
||||
*/
|
||||
|
||||
aw20x_set_fade(&awled);
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,7 @@
|
||||
// 0 index = bottom.
|
||||
// 0 value = no LED here.
|
||||
typedef struct LedMap {
|
||||
uint8_t ribbon[80]; // a "linear" bottom to top map, with gaps for the spacing.
|
||||
uint8_t ribbon[88]; // a "linear" bottom to top map, with gaps for the spacing.
|
||||
uint8_t a[20]; // left to right, bottom to apex to bottom.
|
||||
uint8_t ii_lf[5]; // top to bottom.
|
||||
uint8_t ii_rt[5]; // top to bottom.
|
||||
@@ -22,6 +22,7 @@ typedef struct LedMap {
|
||||
|
||||
|
||||
extern LedMap led_set;
|
||||
extern uint8_t awled_fade[6*12];
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user