Skip to content

Commit 89d7328

Browse files
committed
Update assets.ts, language.ts, library.ts, home.ts, agent.ts
1 parent 7dd7dca commit 89d7328

5 files changed

Lines changed: 243 additions & 1 deletion

File tree

agent.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,25 @@ namespace kojac {
1414
public update(dt: number) {
1515
this.prog.execute();
1616
}
17+
18+
public logBoolean(val: boolean, color: number) {
19+
this.home.logBoolean(val, color);
20+
}
21+
22+
public logNumber(val: number, color: number) {
23+
this.home.logNumber(val, color);
24+
}
25+
26+
public logString(val: string, color: number) {
27+
this.home.logString(val, color);
28+
}
29+
30+
public plotBoolean(val: boolean, color: number) {
31+
this.home.plotBoolean(val, color);
32+
}
33+
34+
public plotNumber(val: number, color: number) {
35+
this.home.plotNumber(val, color);
36+
}
1737
}
1838
}

assets.ts

Lines changed: 98 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ namespace kojac {
3737
this.reg[tid.sensor.button_a] = icondb.tile_button_a;
3838
this.reg[tid.sensor.button_b] = icondb.tile_button_b;
3939
this.reg[tid.sensor.timer] = icondb.tile_timer;
40+
this.reg[tid.sensor.pin_1] = icondb.tile_pin_1;
4041
this.reg[tid.modifier.page_1] = icondb.tile_page_1;
4142
this.reg[tid.modifier.page_2] = icondb.tile_page_2;
4243
this.reg[tid.modifier.page_3] = icondb.tile_page_3;
@@ -51,9 +52,13 @@ namespace kojac {
5152
this.reg[tid.filter.express_heart] = this.reg[tid.modifier.express_heart] = icondb.tile_express_heart;
5253
this.reg[tid.filter.timespan_short] = icondb.tile_timespan_short;
5354
this.reg[tid.filter.timespan_long] = icondb.tile_timespan_long;
55+
this.reg[tid.filter.pin_analog] = icondb.tile_pin_analog;
56+
this.reg[tid.filter.pin_digital] = icondb.tile_pin_digital;
5457
this.reg[tid.actuator.switch_page] = icondb.tile_switch_page;
5558
this.reg[tid.actuator.express] = icondb.tile_express;
5659
this.reg[tid.actuator.pin_0] = icondb.tile_pin_0;
60+
this.reg[tid.actuator.log] = icondb.tile_console;
61+
this.reg[tid.actuator.plot] = icondb.tile_graph;
5762
this.reg[RuleCondition.DEFAULT] = icondb.rc_default;
5863
this.reg[RuleCondition.HIGH] = icondb.rc_high;
5964
this.reg[RuleCondition.LOW] = icondb.rc_low;
@@ -812,12 +817,12 @@ namespace icondb {
812817
. . . . . . . . . . . . . . . .
813818
`;
814819
export const tile_pin_0 = img`
820+
. . . . . . . . . . . . . . . .
815821
. . . . . . . . . . . . . . . .
816822
. . . . . . . . . . . . . . . .
817823
. . . f f f f f f f f f . . . .
818824
. . f 5 5 5 5 5 5 5 5 5 f . . .
819825
. . f 5 5 5 5 5 5 5 5 5 f . . .
820-
. . f 5 5 5 5 5 5 5 5 5 f . . .
821826
. . f 5 f f 5 5 5 f 5 5 f . . .
822827
. . f 5 f 5 f 5 f 5 f 5 f . . .
823828
. . f 5 f f 5 5 f 5 f 5 f . . .
@@ -829,6 +834,24 @@ namespace icondb {
829834
. . . . . . . . . . . . . . . .
830835
. . . . . . . . . . . . . . . .
831836
`;
837+
export const tile_pin_1 = img`
838+
. . . . . . . . . . . . . . . .
839+
. . . . . . . . . . . . . . . .
840+
. . . f f f f f f f f f . . . .
841+
. . f 5 5 5 5 5 5 5 5 5 f . . .
842+
. . f 5 5 5 5 5 5 5 5 5 f . . .
843+
. . f 5 5 5 5 5 5 5 5 5 f . . .
844+
. . f 5 f f 5 5 5 f 5 5 f . . .
845+
. . f 5 f 5 f 5 f f 5 5 f . . .
846+
. . f 5 f f 5 5 5 f 5 5 f . . .
847+
. . f 5 f 5 5 5 f f f 5 f . . .
848+
. . f 5 5 5 5 5 5 5 5 5 f . . .
849+
. . f 5 5 5 5 5 5 5 5 5 f . . .
850+
. . f 5 5 5 5 5 5 5 5 5 f . . .
851+
. . . . . . . . . . . . . . . .
852+
. . . . . . . . . . . . . . . .
853+
. . . . . . . . . . . . . . . .
854+
`;
832855
export const tile_pin_on = img`
833856
. . . . . . . . . . . . . . . .
834857
. . . . . . . . . . . . . . . .
@@ -865,6 +888,78 @@ namespace icondb {
865888
. . . . . . . . . . . . . . . .
866889
. . . . . . . . . . . . . . . .
867890
`;
891+
export const tile_pin_analog = img`
892+
. . . . . . . . . . . . . . . .
893+
. . . . . . . . . . . . . . . .
894+
. . . 6 6 6 6 6 6 6 6 6 . . . .
895+
. . 6 6 6 6 6 6 6 6 6 6 6 . . .
896+
. . 6 6 6 6 6 6 5 5 5 6 6 . . .
897+
. . 6 6 6 6 6 5 5 6 6 6 6 . . .
898+
. . 6 6 6 6 5 5 6 6 6 6 6 . . .
899+
. . 6 6 9 6 5 6 9 6 9 6 6 . . .
900+
. . 6 6 6 6 5 6 6 6 6 6 6 . . .
901+
. . 6 6 6 5 5 6 6 6 6 6 6 . . .
902+
. . 6 6 5 5 6 6 6 6 6 6 6 . . .
903+
. . 6 6 6 6 6 6 6 6 6 6 6 . . .
904+
. . . 6 6 6 6 6 6 6 6 6 . . . .
905+
. . . . . . . . . . . . . . . .
906+
. . . . . . . . . . . . . . . .
907+
. . . . . . . . . . . . . . . .
908+
`;
909+
export const tile_pin_digital = img`
910+
. . . . . . . . . . . . . . . .
911+
. . . . . . . . . . . . . . . .
912+
. . . 6 6 6 6 6 6 6 6 6 . . . .
913+
. . 6 6 6 6 6 6 6 6 6 6 6 . . .
914+
. . 6 6 6 6 6 5 5 5 5 6 6 . . .
915+
. . 6 6 6 6 6 5 6 6 6 6 6 . . .
916+
. . 6 6 6 6 6 5 6 6 6 6 6 . . .
917+
. . 6 6 9 6 9 5 9 6 9 6 6 . . .
918+
. . 6 6 6 6 6 5 6 6 6 6 6 . . .
919+
. . 6 6 6 6 6 5 6 6 6 6 6 . . .
920+
. . 6 6 5 5 5 5 6 6 6 6 6 . . .
921+
. . 6 6 6 6 6 6 6 6 6 6 6 . . .
922+
. . . 6 6 6 6 6 6 6 6 6 . . . .
923+
. . . . . . . . . . . . . . . .
924+
. . . . . . . . . . . . . . . .
925+
. . . . . . . . . . . . . . . .
926+
`;
927+
export const tile_console = img`
928+
. . . . . . . . . . . . . . . .
929+
. . . . . . . . . . . . . . . .
930+
. . . f f f f f f f f f f . . .
931+
. . f f f f f f f f f f f f . .
932+
. . f f f f f f f f f f f f . .
933+
. . f f 7 f f f f f f f f f . .
934+
. . f f f 7 f f f f f f f f . .
935+
. . f f f f 7 f f f f f f f . .
936+
. . f f f 7 f f f f f f f f . .
937+
. . f f 7 f f f 7 7 7 f f f . .
938+
. . f f f f f f f f f f f f . .
939+
. . f f f f f f f f f f f f . .
940+
. . . f f f f f f f f f f . . .
941+
. . . . . . . . . . . . . . . .
942+
. . . . . . . . . . . . . . . .
943+
. . . . . . . . . . . . . . . .
944+
`;
945+
export const tile_graph = img`
946+
. . . . . . . . . . . . . . . .
947+
. . . . . . . . . . . . . . . .
948+
. . . 6 6 6 6 6 6 6 6 6 6 . . .
949+
. . 6 6 6 6 6 6 6 6 6 6 6 6 . .
950+
. . 6 6 6 6 6 6 6 6 6 6 6 6 . .
951+
. . 6 6 6 6 5 5 5 6 6 6 6 6 . .
952+
. . 6 6 6 5 6 6 6 5 6 6 6 6 . .
953+
. . 6 6 5 6 6 6 6 6 5 6 6 6 . .
954+
. . 6 6 5 6 6 6 6 6 6 5 6 6 . .
955+
. . 6 5 6 6 6 6 6 6 6 6 5 6 . .
956+
. . 6 6 6 6 6 6 6 6 6 6 6 6 . .
957+
. . 6 6 6 6 6 6 6 6 6 6 6 6 . .
958+
. . . 6 6 6 6 6 6 6 6 6 6 . . .
959+
. . . . . . . . . . . . . . . .
960+
. . . . . . . . . . . . . . . .
961+
. . . . . . . . . . . . . . . .
962+
`;
868963
///
869964
/// RULE CONDITIONS
870965
///
@@ -1005,7 +1100,9 @@ namespace icondb {
10051100
. f c c c b b f .
10061101
. . f f f f f . .
10071102
`
1103+
//
10081104
// BACKGROUNDS
1105+
//
10091106
export const gradient_0 = img`
10101107
bbbbbbbbbbbbbbbbbbbbbbbbcbbbcbbbbbbbbbbbbcbbbbbbbbbbbbbbbbbbbbbbbbbbcbbbbbbbbbbbbbbbbbbbcbbbbbbbbcbbbbbbbbbcbbbbbbcbbbbbbbbbbbbbbbcbcbbbbbbbbbcbbbbbbbbbbbbbcbbb
10111108
bbbbbcbbbbbcbbbbbbbbbbbbbbbbbbbbbbbbbbcbbbbbbbbbbbbbbbbbbcbbbbbbbbcbbbbbbbbbbbbccbbbbcbbbbbbbbcbbbbbbbbbbbbbbbbbbbbbcbbbbbbccbbbbbbbbbbbbbbbbbbbcbbbbbbbbbcbbbbb

home.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,26 @@ namespace kojac {
5050
this.setView(HomeView.Plot);
5151
}
5252

53+
public logBoolean(val: boolean, color: number) {
54+
this.log(val ? "true": "false", color);
55+
}
56+
57+
public logNumber(val: number, color: number) {
58+
this.log(val.toString(), color);
59+
}
60+
61+
public logString(val: string, color: number) {
62+
this.log(val, color);
63+
}
64+
65+
public plotBoolean(val: boolean, color: number) {
66+
this.plot(val ? 1 : 0, color);
67+
}
68+
69+
public plotNumber(val: number, color: number) {
70+
this.plot(val, color);
71+
}
72+
5373
startup() {
5474
super.startup();
5575
controller.left.onEvent(ControllerButtonEvent.Released, function () {

language.ts

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,7 @@ namespace kojac {
410410
button_a: "S2",
411411
button_b: "S3",
412412
timer: "S4",
413+
pin_1: "S6",
413414
},
414415
filter: <any>{
415416
timespan_short: "F1",
@@ -419,11 +420,15 @@ namespace kojac {
419420
express_angry: "F5",
420421
express_heart: "F6",
421422
express_sad: "F7",
423+
pin_analog: "F8",
424+
pin_digital: "F9",
422425
},
423426
actuator: <any>{
424427
switch_page: "A1",
425428
express: "A2",
426429
pin_0: "A3",
430+
log: "A4",
431+
plot: "A5",
427432
},
428433
modifier: <any>{
429434
page_1: "M1",
@@ -492,6 +497,17 @@ namespace kojac {
492497
categories: ["timespan"]
493498
}
494499
}
500+
},
501+
[tid.sensor.pin_1]: {
502+
type: TileType.SENSOR,
503+
tid: tid.sensor.pin_1,
504+
name: "Pin 1",
505+
phase: "post",
506+
constraints: {
507+
allow: {
508+
categories: ["pin_mode"]
509+
}
510+
}
495511
}
496512
},
497513
filters: {
@@ -573,6 +589,30 @@ namespace kojac {
573589
}
574590
}
575591
},
592+
[tid.filter.pin_analog]: {
593+
type: TileType.FILTER,
594+
tid: tid.filter.pin_analog,
595+
name: "analog",
596+
category: "pin_mode",
597+
priority: 10,
598+
constraints: {
599+
disallow: {
600+
categories: ["pin_mode"]
601+
}
602+
}
603+
},
604+
[tid.filter.pin_digital]: {
605+
type: TileType.FILTER,
606+
tid: tid.filter.pin_digital,
607+
name: "digital",
608+
category: "pin_mode",
609+
priority: 10,
610+
constraints: {
611+
disallow: {
612+
categories: ["pin_mode"]
613+
}
614+
}
615+
},
576616
},
577617
actuators: {
578618
[tid.actuator.switch_page]: {
@@ -606,6 +646,26 @@ namespace kojac {
606646
}
607647
}
608648
},
649+
[tid.actuator.log]: {
650+
type: TileType.ACTUATOR,
651+
tid: tid.actuator.log,
652+
name: "Log",
653+
constraints: {
654+
allow: {
655+
categories: ["output_color"]
656+
}
657+
}
658+
},
659+
[tid.actuator.plot]: {
660+
type: TileType.ACTUATOR,
661+
tid: tid.actuator.plot,
662+
name: "Plot",
663+
constraints: {
664+
allow: {
665+
categories: ["output_color"]
666+
}
667+
}
668+
},
609669
},
610670
modifiers: {
611671
[tid.modifier.page_1]: {

library.ts

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,16 @@ namespace kojac {
5757
rule.state["timerStart"] = now;
5858
}
5959
},
60+
[tid.sensor.pin_1]: (rule: Rule) => {
61+
let mode = rule.state["pin_mode"];
62+
if (mode == undefined) {
63+
mode = "analog";
64+
}
65+
const value = (mode === "analog") ? pins.analogReadPin(AnalogPin.P1) : pins.digitalReadPin(DigitalPin.P1);
66+
rule.state["value"] = value;
67+
rule.state["value_type"] = "number";
68+
rule.state["exec"] = true;
69+
},
6070

6171
///
6272
/// FILTERS
@@ -73,6 +83,14 @@ namespace kojac {
7383
rule.state["timespan"] = timespan;
7484
},
7585

86+
[tid.filter.pin_analog]: (rule: Rule) => {
87+
rule.state["pin_mode"] = "analog";
88+
},
89+
90+
[tid.filter.pin_digital]: (rule: Rule) => {
91+
rule.state["pin_mode"] = "digital";
92+
},
93+
7694
///
7795
/// ACTUATORS
7896
///
@@ -91,6 +109,33 @@ namespace kojac {
91109
pins.digitalWritePin(DigitalPin.P0, state ? 1 : 0);
92110
},
93111

112+
[tid.actuator.log]: (rule: Rule) => {
113+
const value_type = rule.state["value_type"];
114+
const color = 5; // TODO
115+
switch (value_type) {
116+
case "boolean": {
117+
const value: boolean = rule.state["value"];
118+
rule.prog.agent.logBoolean(value, color);
119+
break;
120+
}
121+
case "number": {
122+
const value: number = rule.state["value"];
123+
rule.prog.agent.logNumber(value, color);
124+
break;
125+
}
126+
case "string": {
127+
const value: string = rule.state["value"];
128+
rule.prog.agent.logString(value, color);
129+
break;
130+
}
131+
}
132+
133+
},
134+
135+
[tid.actuator.plot]: (rule: Rule) => {
136+
137+
},
138+
94139
///
95140
/// MODIFIERS
96141
///

0 commit comments

Comments
 (0)