|
27 | 27 | #include "primitives.h" |
28 | 28 |
|
29 | 29 | #define NUM_PRIMITIVES 0 |
30 | | -#define NUM_PRIMITIVES_ARDUINO 29 |
| 30 | +#define NUM_PRIMITIVES_ARDUINO 35 |
31 | 31 |
|
32 | 32 | #define ALL_PRIMITIVES (NUM_PRIMITIVES + NUM_PRIMITIVES_ARDUINO) |
33 | 33 |
|
@@ -388,7 +388,7 @@ def_prim(http_post, tenToOneU32) { |
388 | 388 | return true; |
389 | 389 | } |
390 | 390 |
|
391 | | -#define NUM_DIGITAL_PINS 30 |
| 391 | +#define NUM_DIGITAL_PINS 100 |
392 | 392 | static uint32_t PINS[NUM_DIGITAL_PINS] = {}; |
393 | 393 | static uint8_t MODES[NUM_DIGITAL_PINS] = {}; |
394 | 394 |
|
@@ -510,6 +510,54 @@ def_prim(write_spi_bytes_16, twoToNoneU32) { |
510 | 510 | return true; |
511 | 511 | } |
512 | 512 |
|
| 513 | +def_prim(drive_motor, twoToNoneU32) { |
| 514 | + const int32_t speed = arg0.int32; |
| 515 | + const uint32_t motor_index = arg1.uint32; |
| 516 | + printf("EMU: drive_motor(%d, %d)\n", motor_index, speed); |
| 517 | + pop_args(2); |
| 518 | + return true; |
| 519 | +} |
| 520 | + |
| 521 | +def_prim(stop_motor, oneToNoneU32) { |
| 522 | + uint32_t motor_index = arg0.uint32; |
| 523 | + printf("EMU: stop_motor(%d)\n", motor_index); |
| 524 | + pop_args(1); |
| 525 | + return true; |
| 526 | +} |
| 527 | + |
| 528 | +def_prim(drive_motor_ms, threeToNoneU32) { |
| 529 | + const int32_t time = arg0.uint32; |
| 530 | + const int32_t speed = arg1.int32; |
| 531 | + const int32_t motor_index = arg2.int32; |
| 532 | + printf("EMU: drive_motor_ms(%d, %d, %d)\n", motor_index, speed, time); |
| 533 | + pop_args(3); |
| 534 | + |
| 535 | + return true; |
| 536 | +} |
| 537 | + |
| 538 | +def_prim(drive_motor_degrees, threeToNoneU32) { |
| 539 | + int32_t degrees = arg0.int32; |
| 540 | + int32_t speed = arg1.int32; |
| 541 | + uint32_t motor_index = arg2.uint32; |
| 542 | + printf("EMU: drive_motor_degrees(%d, %d, %d)\n", motor_index, speed, |
| 543 | + degrees); |
| 544 | + pop_args(3); |
| 545 | + return true; |
| 546 | +} |
| 547 | + |
| 548 | +def_prim(setup_uart_sensor, twoToNoneU32) { |
| 549 | + printf("EMU: setup_uart_sensor(%d, %d)\n", arg1.uint32, arg0.uint32); |
| 550 | + pop_args(2); |
| 551 | + return true; |
| 552 | +} |
| 553 | + |
| 554 | +def_prim(read_uart_sensor, oneToOneI32) { |
| 555 | + printf("EMU: read_uart_sensor(%d)\n", arg0.uint32); |
| 556 | + pop_args(1); |
| 557 | + pushInt32(0); |
| 558 | + return true; |
| 559 | +} |
| 560 | + |
513 | 561 | def_prim(subscribe_interrupt, threeToNoneU32) { |
514 | 562 | uint8_t pin = arg2.uint32; // GPIOPin |
515 | 563 | uint8_t tidx = arg1.uint32; // Table Idx pointing to Callback function |
@@ -559,6 +607,7 @@ def_prim(chip_ledc_attach_pin, twoToNoneU32) { |
559 | 607 | pop_args(2); |
560 | 608 | return true; |
561 | 609 | } |
| 610 | + |
562 | 611 | //------------------------------------------------------ |
563 | 612 | // Installing all the primitives |
564 | 613 | //------------------------------------------------------ |
@@ -604,6 +653,14 @@ void install_primitives() { |
604 | 653 | install_primitive(chip_ledc_setup); |
605 | 654 | install_primitive(chip_ledc_attach_pin); |
606 | 655 | install_primitive(chip_ledc_set_duty); |
| 656 | + |
| 657 | + // Open Bot Brain |
| 658 | + install_primitive(drive_motor); |
| 659 | + install_primitive(drive_motor_ms); |
| 660 | + install_primitive(drive_motor_degrees); |
| 661 | + install_primitive(stop_motor); |
| 662 | + install_primitive(setup_uart_sensor); |
| 663 | + install_primitive(read_uart_sensor); |
607 | 664 | } |
608 | 665 |
|
609 | 666 | //------------------------------------------------------ |
|
0 commit comments