Skip to content

Commit cbaee74

Browse files
various fixes (#270)
1 parent 5e1bf91 commit cbaee74

13 files changed

Lines changed: 120 additions & 63 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@
3535
- **NEW**: live mode dashboard
3636
- **NEW**: ops to control live mode: `LIVE.OFF`, `LIVE.VARS`, `LIVE.GRID`, `LIVE.DASH`, `PRINT`
3737
- **FIX**: `PN.ROT` parameters are swapped
38+
- **FIX**: better rendering for fine grid faders
39+
- **FIX**: logical operators should treat all non zero values as `true`, not just positive values
40+
- **NEW**: crow ops
41+
- **NEW**: `TI.PRM.CALIB` alias added (was already in the docs)
42+
- **FIX**: `SCENE` would crash if parameter was out of bounds
3843

3944
## v3.2.0
4045

docs/whats_new.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@
3636
- **NEW**: live mode dashboard
3737
- **NEW**: ops to control live mode: `LIVE.OFF`, `LIVE.VARS`, `LIVE.GRID`, `LIVE.DASH`, `PRINT`
3838
- **FIX**: `PN.ROT` parameters are swapped
39+
- **FIX**: better rendering for fine grid faders
40+
- **FIX**: logical operators should treat all non zero values as `true`, not just positive values
41+
- **NEW**: crow ops
42+
- **NEW**: `TI.PRM.CALIB` alias added (was already in the docs)
43+
- **FIX**: `SCENE` would crash if parameter was out of bounds
3944

4045
## v3.2.0
4146

module/flash.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ void flash_read(uint8_t preset_no, scene_state_t *scene,
119119
char (*text)[SCENE_TEXT_LINES][SCENE_TEXT_CHARS],
120120
uint8_t init_pattern, uint8_t init_grid,
121121
uint8_t init_i2c_op_address) {
122+
if (preset_no >= SCENE_SLOTS) return;
122123
memcpy(ss_scripts_ptr(scene), &f.scenes[preset_no].scripts,
123124
// Exclude size of TEMP script as above
124125
ss_scripts_size() - sizeof(scene_script_t));

module/grid.c

Lines changed: 94 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ static void grid_screen_refresh_info(scene_state_t *ss, u8 page, u8 x1, u8 y1,
205205
static bool grid_within_area(u8 x, u8 y, grid_common_t *gc);
206206
static void grid_fill_area(u8 x, u8 y, u8 w, u8 h, s8 level);
207207
static void grid_fill_area_scr(u8 x, u8 y, u8 w, u8 h, s8 level, u8 page);
208+
static u16 calc_fader_level(scene_state_t *ss, u8 i, u8 vert);
208209

209210
void grid_set_control_mode(u8 control, u8 mode, scene_state_t *ss) {
210211
if (mode == M_LIVE) {
@@ -1381,6 +1382,12 @@ bool grid_within_area(u8 x, u8 y, grid_common_t *gc) {
13811382
y < (gc->y + gc->h);
13821383
}
13831384

1385+
u16 calc_fader_level(scene_state_t *ss, u8 i, u8 vert) {
1386+
u32 fl = ((GF.value * ((vert ? GFC.h : GFC.w) - 2)) << 5) / GFC.level;
1387+
fl = (fl >> 1) + (fl & 1);
1388+
return fl;
1389+
}
1390+
13841391
void grid_refresh(scene_state_t *ss) {
13851392
size_x = monome_size_x();
13861393
size_y = monome_size_y();
@@ -1413,69 +1420,85 @@ void grid_refresh(scene_state_t *ss) {
14131420
grid_fill_area(GFC.x + GF.value + 1, GFC.y,
14141421
GFC.w - GF.value - 1, GFC.h, GFC.level);
14151422
break;
1423+
case FADER_CH_DOT:
1424+
grid_fill_area(GFC.x, GFC.y, GFC.w, GFC.h, GFC.level);
1425+
grid_fill_area(GFC.x + GF.value, GFC.y, 1, GFC.h,
1426+
GRID_ON_BRIGHTNESS);
1427+
break;
14161428
case FADER_CV_BAR:
14171429
grid_fill_area(GFC.x, GFC.y, GFC.w, GFC.h - GF.value - 1,
14181430
GFC.level);
14191431
grid_fill_area(GFC.x, GFC.y + GFC.h - GF.value - 1, GFC.w,
14201432
GF.value + 1, GRID_ON_BRIGHTNESS);
14211433
break;
1422-
case FADER_CH_DOT:
1423-
grid_fill_area(GFC.x, GFC.y, GFC.w, GFC.h, GFC.level);
1424-
grid_fill_area(GFC.x + GF.value, GFC.y, 1, GFC.h,
1425-
GRID_ON_BRIGHTNESS);
1426-
break;
14271434
case FADER_CV_DOT:
14281435
grid_fill_area(GFC.x, GFC.y, GFC.w, GFC.h, GFC.level);
14291436
grid_fill_area(GFC.x, GFC.y + GFC.h - GF.value - 1, GFC.w,
14301437
1, GRID_ON_BRIGHTNESS);
14311438
break;
14321439
case FADER_FH_BAR:
1433-
fv = (((GFC.w - 2) << 4) * GF.value) / GFC.level;
1440+
fv = calc_fader_level(ss, i, 0);
14341441
ff = fv >> 4;
14351442
fp = fv & 15;
1436-
grid_fill_area(GFC.x, GFC.y, ff + 1, GFC.h,
1437-
GRID_ON_BRIGHTNESS);
1443+
grid_fill_area(GFC.x + 1, GFC.y, ff, GFC.h, 15);
14381444
if (fp) grid_fill_area(GFC.x + ff + 1, GFC.y, 1, GFC.h, fp);
1445+
1446+
grid_fill_area(GFC.x, GFC.y, 1, GFC.h, GRID_ON_BRIGHTNESS);
14391447
grid_fill_area(GFC.x + GFC.w - 1, GFC.y, 1, GFC.h,
14401448
GRID_ON_BRIGHTNESS);
14411449
break;
1442-
case FADER_FV_BAR:
1443-
fv = (((GFC.h - 2) << 4) * GF.value) / GFC.level;
1450+
case FADER_FH_DOT:
1451+
fv = calc_fader_level(ss, i, 0);
14441452
ff = fv >> 4;
14451453
fp = fv & 15;
1446-
grid_fill_area(GFC.x, GFC.y + GFC.h - ff - 1, GFC.w, ff + 1,
1447-
GRID_ON_BRIGHTNESS);
1448-
if (fp)
1449-
grid_fill_area(GFC.x, GFC.y + GFC.h - ff - 2, GFC.w, 1,
1450-
fp);
1451-
grid_fill_area(GFC.x, GFC.y, GFC.w, 1, GRID_ON_BRIGHTNESS);
1452-
break;
1453-
case FADER_FH_DOT:
1454+
if (fp) {
1455+
if (GFC.w - 1 >= GFC.level)
1456+
fp = GRID_ON_BRIGHTNESS;
1457+
else if (fp < 3)
1458+
fp = 3;
1459+
grid_fill_area(GFC.x + ff + 1, GFC.y, 1, GFC.h,
1460+
fp < 3 ? 3 : fp);
1461+
}
1462+
else if (ff)
1463+
grid_fill_area(GFC.x + ff, GFC.y, 1, GFC.h, 15);
1464+
14541465
grid_fill_area(GFC.x, GFC.y, 1, GFC.h, GRID_ON_BRIGHTNESS);
14551466
grid_fill_area(GFC.x + GFC.w - 1, GFC.y, 1, GFC.h,
14561467
GRID_ON_BRIGHTNESS);
1457-
fv = (((GFC.w - 2) << 4) * GF.value) / GFC.level;
1468+
break;
1469+
case FADER_FV_BAR:
1470+
fv = calc_fader_level(ss, i, 1);
14581471
ff = fv >> 4;
14591472
fp = fv & 15;
1473+
grid_fill_area(GFC.x, GFC.y + GFC.h - 1 - ff, GFC.w, ff,
1474+
15);
14601475
if (fp)
1461-
grid_fill_area(GFC.x + ff + 1, GFC.y, 1, GFC.h, fp);
1462-
else if (ff)
1463-
grid_fill_area(GFC.x + ff, GFC.y, 1, GFC.h,
1464-
GRID_ON_BRIGHTNESS);
1465-
break;
1466-
case FADER_FV_DOT:
1476+
grid_fill_area(GFC.x, GFC.y + GFC.h - 2 - ff, GFC.w, 1,
1477+
fp);
1478+
14671479
grid_fill_area(GFC.x, GFC.y + GFC.h - 1, GFC.w, 1,
14681480
GRID_ON_BRIGHTNESS);
14691481
grid_fill_area(GFC.x, GFC.y, GFC.w, 1, GRID_ON_BRIGHTNESS);
1470-
fv = (((GFC.h - 2) << 4) * GF.value) / GFC.level;
1482+
break;
1483+
case FADER_FV_DOT:
1484+
fv = calc_fader_level(ss, i, 1);
14711485
ff = fv >> 4;
14721486
fp = fv & 15;
1473-
if (fp)
1487+
if (fp) {
1488+
if (GFC.h - 1 >= GFC.level)
1489+
fp = GRID_ON_BRIGHTNESS;
1490+
else if (fp < 3)
1491+
fp = 3;
14741492
grid_fill_area(GFC.x, GFC.y + GFC.h - ff - 2, GFC.w, 1,
14751493
fp);
1494+
}
14761495
else if (ff)
14771496
grid_fill_area(GFC.x, GFC.y + GFC.h - ff - 1, GFC.w, 1,
1478-
GRID_ON_BRIGHTNESS);
1497+
15);
1498+
1499+
grid_fill_area(GFC.x, GFC.y + GFC.h - 1, GFC.w, 1,
1500+
GRID_ON_BRIGHTNESS);
1501+
grid_fill_area(GFC.x, GFC.y, GFC.w, 1, GRID_ON_BRIGHTNESS);
14791502
break;
14801503
}
14811504
}
@@ -1692,7 +1715,7 @@ void grid_screen_refresh_led(scene_state_t *ss, u8 full_grid, u8 page, u8 x1,
16921715
}
16931716
}
16941717

1695-
u16 fv, ff, fp;
1718+
u32 fv, ff, fp;
16961719
for (u8 i = 0; i < GRID_FADER_COUNT; i++) {
16971720
if (GFC.enabled && SG.group[GFC.group].enabled) {
16981721
switch (GF.type) {
@@ -1723,58 +1746,75 @@ void grid_screen_refresh_led(scene_state_t *ss, u8 full_grid, u8 page, u8 x1,
17231746
GFC.w, 1, GRID_ON_BRIGHTNESS, page);
17241747
break;
17251748
case FADER_FH_BAR:
1726-
fv = (((GFC.w - 2) << 4) * GF.value) / GFC.level;
1749+
fv = calc_fader_level(ss, i, 0);
17271750
ff = fv >> 4;
17281751
fp = fv & 15;
1729-
grid_fill_area_scr(GFC.x, GFC.y, ff + 1, GFC.h,
1730-
GRID_ON_BRIGHTNESS, page);
1752+
grid_fill_area_scr(GFC.x + 1, GFC.y, ff, GFC.h, 15, page);
17311753
if (fp)
17321754
grid_fill_area_scr(GFC.x + ff + 1, GFC.y, 1, GFC.h, fp,
17331755
page);
1756+
1757+
grid_fill_area_scr(GFC.x, GFC.y, 1, GFC.h,
1758+
GRID_ON_BRIGHTNESS, page);
17341759
grid_fill_area_scr(GFC.x + GFC.w - 1, GFC.y, 1, GFC.h,
17351760
GRID_ON_BRIGHTNESS, page);
17361761
break;
1737-
case FADER_FV_BAR:
1738-
fv = (((GFC.h - 2) << 4) * GF.value) / GFC.level;
1762+
case FADER_FH_DOT:
1763+
fv = calc_fader_level(ss, i, 0);
17391764
ff = fv >> 4;
17401765
fp = fv & 15;
1741-
grid_fill_area_scr(GFC.x, GFC.y + GFC.h - ff - 1, GFC.w,
1742-
ff + 1, GRID_ON_BRIGHTNESS, page);
1743-
if (fp)
1744-
grid_fill_area_scr(GFC.x, GFC.y + GFC.h - ff - 2, GFC.w,
1745-
1, fp, page);
1746-
grid_fill_area_scr(GFC.x, GFC.y, GFC.w, 1,
1747-
GRID_ON_BRIGHTNESS, page);
1748-
break;
1749-
case FADER_FH_DOT:
1766+
if (fp) {
1767+
if (GFC.w - 1 >= GFC.level)
1768+
fp = GRID_ON_BRIGHTNESS;
1769+
else if (fp < 3)
1770+
fp = 3;
1771+
grid_fill_area_scr(GFC.x + ff + 1, GFC.y, 1, GFC.h,
1772+
fp < 3 ? 3 : fp, page);
1773+
}
1774+
else if (ff)
1775+
grid_fill_area_scr(GFC.x + ff, GFC.y, 1, GFC.h, 15,
1776+
page);
1777+
17501778
grid_fill_area_scr(GFC.x, GFC.y, 1, GFC.h,
17511779
GRID_ON_BRIGHTNESS, page);
17521780
grid_fill_area_scr(GFC.x + GFC.w - 1, GFC.y, 1, GFC.h,
17531781
GRID_ON_BRIGHTNESS, page);
1754-
fv = (((GFC.w - 2) << 4) * GF.value) / GFC.level;
1782+
break;
1783+
case FADER_FV_BAR:
1784+
fv = calc_fader_level(ss, i, 1);
17551785
ff = fv >> 4;
17561786
fp = fv & 15;
1787+
grid_fill_area_scr(GFC.x, GFC.y + GFC.h - 1 - ff, GFC.w, ff,
1788+
15, page);
17571789
if (fp)
1758-
grid_fill_area_scr(GFC.x + ff + 1, GFC.y, 1, GFC.h, fp,
1759-
page);
1760-
else if (ff)
1761-
grid_fill_area_scr(GFC.x + ff, GFC.y, 1, GFC.h,
1762-
GRID_ON_BRIGHTNESS, page);
1763-
break;
1764-
case FADER_FV_DOT:
1790+
grid_fill_area_scr(GFC.x, GFC.y + GFC.h - 2 - ff, GFC.w,
1791+
1, fp, page);
1792+
17651793
grid_fill_area_scr(GFC.x, GFC.y + GFC.h - 1, GFC.w, 1,
17661794
GRID_ON_BRIGHTNESS, page);
17671795
grid_fill_area_scr(GFC.x, GFC.y, GFC.w, 1,
17681796
GRID_ON_BRIGHTNESS, page);
1769-
fv = (((GFC.h - 2) << 4) * GF.value) / GFC.level;
1797+
break;
1798+
case FADER_FV_DOT:
1799+
fv = calc_fader_level(ss, i, 1);
17701800
ff = fv >> 4;
17711801
fp = fv & 15;
1772-
if (fp)
1802+
if (fp) {
1803+
if (GFC.h - 1 >= GFC.level)
1804+
fp = GRID_ON_BRIGHTNESS;
1805+
else if (fp < 3)
1806+
fp = 3;
17731807
grid_fill_area_scr(GFC.x, GFC.y + GFC.h - ff - 2, GFC.w,
17741808
1, fp, page);
1809+
}
17751810
else if (ff)
17761811
grid_fill_area_scr(GFC.x, GFC.y + GFC.h - ff - 1, GFC.w,
1777-
1, GRID_ON_BRIGHTNESS, page);
1812+
1, 15, page);
1813+
1814+
grid_fill_area_scr(GFC.x, GFC.y + GFC.h - 1, GFC.w, 1,
1815+
GRID_ON_BRIGHTNESS, page);
1816+
grid_fill_area_scr(GFC.x, GFC.y, GFC.w, 1,
1817+
GRID_ON_BRIGHTNESS, page);
17781818
break;
17791819
}
17801820
}

module/main.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,6 +1065,7 @@ void tele_ii_rx(uint8_t addr, uint8_t* data, uint8_t l) {
10651065
}
10661066

10671067
void tele_scene(uint8_t i, uint8_t init_grid, uint8_t init_pattern) {
1068+
if (i >= SCENE_SLOTS) return;
10681069
preset_select = i;
10691070
flash_read(i, &scene_state, &scene_text, init_pattern, init_grid, 0);
10701071
set_dash_updated();

simulator/tt.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ void select_dash_screen(uint8_t screen) {
8383
}
8484

8585
void print_dashboard_value(uint8_t index, int16_t value) {
86-
printf("PRINT_DASHBOARD_VALUE index:%" PRIu8 " value:%" PRId16, index, value);
86+
printf("PRINT_DASHBOARD_VALUE index:%" PRIu8 " value:%" PRId16, index,
87+
value);
8788
printf("\n");
8889
}
8990

src/match_token.rl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -614,6 +614,7 @@
614614
"TI.PRM.N" => { MATCH_OP(E_OP_TI_PRM_N); };
615615
"TI.PRM.SCALE" => { MATCH_OP(E_OP_TI_PRM_SCALE); };
616616
"TI.PRM.MAP" => { MATCH_OP(E_OP_TI_PRM_MAP); };
617+
"TI.PRM.CALIB" => { MATCH_OP(E_OP_TI_PRM_CALIB); };
617618
"TI.PRM.INIT" => { MATCH_OP(E_OP_TI_PRM_INIT); };
618619

619620
# fader

src/ops/maths.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -838,30 +838,30 @@ static void op_AND_get(const void *NOTUSED(data), scene_state_t *NOTUSED(ss),
838838
exec_state_t *NOTUSED(es), command_state_t *cs) {
839839
int16_t a = cs_pop(cs);
840840
int16_t b = cs_pop(cs);
841-
cs_push(cs, (a > 0) && (b > 0));
841+
cs_push(cs, a && b);
842842
}
843843

844844
static void op_OR_get(const void *NOTUSED(data), scene_state_t *NOTUSED(ss),
845845
exec_state_t *NOTUSED(es), command_state_t *cs) {
846846
int16_t a = cs_pop(cs);
847847
int16_t b = cs_pop(cs);
848-
cs_push(cs, (a > 0) || (b > 0));
848+
cs_push(cs, a || b);
849849
}
850850

851851
static void op_AND3_get(const void *NOTUSED(data), scene_state_t *NOTUSED(ss),
852852
exec_state_t *NOTUSED(es), command_state_t *cs) {
853853
int16_t a = cs_pop(cs);
854854
int16_t b = cs_pop(cs);
855855
int16_t c = cs_pop(cs);
856-
cs_push(cs, (a > 0) && (b > 0) && (c > 0));
856+
cs_push(cs, a && b && c);
857857
}
858858

859859
static void op_OR3_get(const void *NOTUSED(data), scene_state_t *NOTUSED(ss),
860860
exec_state_t *NOTUSED(es), command_state_t *cs) {
861861
int16_t a = cs_pop(cs);
862862
int16_t b = cs_pop(cs);
863863
int16_t c = cs_pop(cs);
864-
cs_push(cs, (a > 0) || (b > 0) || (c > 0));
864+
cs_push(cs, a || b || c);
865865
}
866866

867867
static void op_AND4_get(const void *NOTUSED(data), scene_state_t *NOTUSED(ss),
@@ -870,7 +870,7 @@ static void op_AND4_get(const void *NOTUSED(data), scene_state_t *NOTUSED(ss),
870870
int16_t b = cs_pop(cs);
871871
int16_t c = cs_pop(cs);
872872
int16_t d = cs_pop(cs);
873-
cs_push(cs, (a > 0) && (b > 0) && (c > 0) && (d > 0));
873+
cs_push(cs, a && b && c && d);
874874
}
875875

876876
static void op_OR4_get(const void *NOTUSED(data), scene_state_t *NOTUSED(ss),
@@ -879,7 +879,7 @@ static void op_OR4_get(const void *NOTUSED(data), scene_state_t *NOTUSED(ss),
879879
int16_t b = cs_pop(cs);
880880
int16_t c = cs_pop(cs);
881881
int16_t d = cs_pop(cs);
882-
cs_push(cs, (a > 0) || (b > 0) || (c > 0) || (d > 0));
882+
cs_push(cs, a || b || c || d);
883883
}
884884

885885
static void op_JI_get(const void *NOTUSED(data), scene_state_t *NOTUSED(ss),

src/ops/op.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ const tele_op_t *tele_ops[E_OP__LENGTH] = {
231231
&op_TI_PARAM_INIT, &op_TI_IN_INIT, &op_TI_INIT,
232232

233233
&op_TI_PRM, &op_TI_PRM_QT, &op_TI_PRM_N, &op_TI_PRM_SCALE, &op_TI_PRM_MAP,
234-
&op_TI_PRM_INIT,
234+
&op_TI_PRM_CALIB, &op_TI_PRM_INIT,
235235

236236
// fader
237237
&op_FADER, &op_FADER_SCALE, &op_FADER_CAL_MIN, &op_FADER_CAL_MAX,

src/ops/op_enum.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,7 @@ typedef enum {
601601
E_OP_TI_PRM_N,
602602
E_OP_TI_PRM_SCALE,
603603
E_OP_TI_PRM_MAP,
604+
E_OP_TI_PRM_CALIB,
604605
E_OP_TI_PRM_INIT,
605606
E_OP_FADER,
606607
E_OP_FADER_SCALE,

0 commit comments

Comments
 (0)