1
1
2
- RollerBase
2
+ Roller485
3
3
==========
4
4
5
5
.. include :: ../refs/unit.roller485.ref
6
6
7
7
Support the following products:
8
8
9
- |RollerBase |
9
+ |Roller485 |
10
10
11
- Micropython Example: :
11
+ Roller485 I2C Example:
12
12
13
- import os, sys, io
14
- import M5
15
- from M5 import *
13
+ .. literalinclude :: ../../../examples/unit/roller485/roller485_i2c_fire_example.py
14
+ :language: python
15
+ :linenos:
16
16
17
+ Roller485 I2C UIFLOW2 Example:
17
18
19
+ |i2c_example.png |
18
20
19
- UIFLOW2 Example:
21
+ .. only :: builder_html
22
+
23
+ |roller485_i2c_fire_example.m5f2 |
24
+
25
+ Roller485 RS485 Example:
20
26
21
- |example.png |
27
+ .. literalinclude :: ../../../examples/unit/roller485/roller485_485_fire_example.py
28
+ :language: python
29
+ :linenos:
30
+
31
+ Roller485 RS485 UIFLOW2 Example:
32
+
33
+ |rs485_example.png |
22
34
23
35
.. only :: builder_html
24
36
25
- class RollerBase
26
- ----------------
37
+ |roller485_485_fire_example.m5f2 |
38
+
39
+ Roller485 RS485ToI2C Example:
40
+
41
+ .. literalinclude :: ../../../examples/unit/roller485/roller485_485toi2c_fire_example.py
42
+ :language: python
43
+ :linenos:
44
+
45
+ Roller485 RS485ToI2C UIFLOW2 Example:
46
+
47
+ |rs485_i2c_example.png |
48
+
49
+ .. only :: builder_html
50
+
51
+ |roller485_485toi2c_fire_example.m5f2 |
52
+
53
+
54
+ class Roller485Unit
55
+ -------------------
27
56
28
57
Constructors
29
58
------------
30
59
31
- .. class :: RollerBase()
60
+ .. class :: Roller485Unit(bus, address, mode)
61
+
62
+ Initialize the Roller485Unit object based on communication mode.
63
+
64
+ :param bus: The I2C/RS485 bus instance.
65
+ :param address: The motor's RS485 address. Defaults to _ROLLER485_RS485_ADDR.
66
+ :param mode: The Roller485 communication mode.
32
67
33
68
UIFLOW2:
34
69
35
70
|init.png |
36
71
72
+ class RollerBase
73
+ ----------------
74
+
75
+ Constructors
76
+ ------------
77
+
78
+ .. class :: RollerBase()
79
+
37
80
38
81
Methods
39
82
-------
@@ -522,7 +565,7 @@ Methods
522
565
523
566
524
567
class RollerI2C(RollerBase)
525
- ---------------
568
+ ---------------------------
526
569
527
570
Constructors
528
571
------------
@@ -550,23 +593,16 @@ Methods
550
593
:param length: The number of bytes to read.
551
594
:return: The data read from the device as a bytes object.
552
595
553
- UIFLOW2:
554
-
555
- |read.png |
556
-
557
596
.. method :: RollerI2C.write(register, bytes) -> None
558
597
559
598
Write data to a specified register on the I2C device.
560
599
561
600
:param register: The name of the register to write to.
562
601
:param bytes: The data to write to the register as a bytes object.
563
602
564
- UIFLOW2:
565
-
566
- |write.png |
567
603
568
604
class Roller485(RollerBase)
569
- ---------------
605
+ ----------------------------
570
606
571
607
Constructors
572
608
------------
@@ -578,11 +614,6 @@ Constructors
578
614
:param bus: The RS485 bus instance.
579
615
:param int address: The motor's RS485 address. Defaults to _ROLLER485_RS485_ADDR.
580
616
581
- UIFLOW2:
582
-
583
- |init1.png |
584
-
585
-
586
617
Methods
587
618
-------
588
619
@@ -593,9 +624,6 @@ Methods
593
624
:param register: The name of the register to read from.
594
625
:param length: The number of bytes to read.
595
626
596
- UIFLOW2:
597
-
598
- |read.png |
599
627
600
628
.. method :: Roller485.create_frame(cmd, motor_id, *datas) -> None
601
629
@@ -605,10 +633,6 @@ Methods
605
633
:param motor_id: The ID of the motor.
606
634
:param datas: Additional data bytes to include in the frame.
607
635
608
- UIFLOW2:
609
-
610
- |create_frame.png |
611
-
612
636
.. method :: Roller485.write(register, bytes) -> bool
613
637
614
638
Write data to a specified register via RS485.
@@ -617,10 +641,6 @@ Methods
617
641
:param bytes: The data to write to the register as a bytes object.
618
642
:return: The response after writing the data.
619
643
620
- UIFLOW2:
621
-
622
- |write.png |
623
-
624
644
.. method :: Roller485.send_command(cmd, id, data, buf_len) -> bool
625
645
626
646
Send a command via RS485.
@@ -630,9 +650,6 @@ Methods
630
650
:param data: The data to send along with the command.
631
651
:param buf_len: The length of the buffer.
632
652
633
- UIFLOW2:
634
-
635
- |send_command.png |
636
653
637
654
.. method :: Roller485.read_response(cmd, id) -> tuple[Literal[True], Any]
638
655
@@ -642,91 +659,87 @@ Methods
642
659
:param id: The motor ID.
643
660
:return: A tuple (success, response). Success is True if the response is valid, and response is the data read.
644
661
645
- UIFLOW2:
646
-
647
- |read_response.png |
648
-
649
662
.. method :: Roller485._crc8(buffer) -> int
650
663
651
664
Calculate CRC8 checksum.
652
665
653
666
:param buffer: The data buffer to compute the checksum for.
654
667
:return: The computed CRC8 value.
655
668
656
- UIFLOW2:
657
-
658
- |_crc8.png |
659
-
660
669
661
670
class Roller485ToI2CBus(RollerBase)
662
- ---------------
671
+ -----------------------------------
663
672
664
673
Constructors
665
674
------------
666
675
667
- .. class :: Roller485ToI2CBus(bus, address=_ROLLER485_RS485_ADDR, i2c_address=0x64 )
676
+ .. class :: Roller485ToI2CBus(bus, address, mode )
668
677
669
678
Initialize the Roller485ToI2CBus object.
670
679
671
680
:param bus: The RS485 bus instance.
672
681
:param address: The motor's RS485 address. Defaults to _ROLLER485_RS485_ADDR.
673
- :param i2c_address: The I2C address of the slave device. Defaults to 0x64.
674
-
675
- UIFLOW2:
676
-
677
- |init2.png |
678
-
679
682
680
683
Methods
681
684
-------
682
685
683
- .. method :: Roller485ToI2CBus.read_i2c_slave(length ) -> tuple[Literal[True], Any]
686
+ .. method :: Roller485ToI2CBus.readfrom_mem(addr, mem_addr, nbytes ) -> bytes
684
687
685
- Read data from the I2C slave device via RS485 .
688
+ Read data from a specific register of the I2C slave device.
686
689
687
- :param length: The number of bytes to read.
688
- :return: The data read from the I2C slave.
690
+ :param addr: The I2C slave address to read from.
691
+ :param mem_addr: Memory register address.
692
+ :param nbytes: The number of bytes to read.
693
+ :return: The data read from the register.
689
694
:throws Exception: If the read operation fails.
690
695
691
- UIFLOW2:
696
+ .. method :: Roller485ToI2CBus.readfrom_mem_into(addr, mem_addr, buf)
692
697
693
- | read_i2c_slave.png |
698
+ Read data from a specific register of the I2C slave device.
694
699
695
- .. method :: Roller485ToI2CBus.write_i2c_slave(byte_list, stop_bit) -> Literal[True]
700
+ :param addr: The I2C slave address to read from.
701
+ :param mem_addr: Memory register address.
702
+ :param buf: Buffer to store the data.
696
703
697
- Write data to the I2C slave device via RS485.
704
+ .. method :: Roller485ToI2CBus.writeto_mem(addr, mem_addr, buf) -> Literal[True]
698
705
699
- :param byte_list: The data bytes to write.
700
- :param stop_bit: Whether to send a stop bit after writing.
706
+ Write data to a specific register of the I2C slave device.
707
+
708
+ :param addr: The I2C slave address to write to.
709
+ :param mem_addr: Memory register address.
710
+ :param buf: The data bytes to write.
701
711
:return: True if the write operation is successful.
702
712
:throws Exception: If the write operation fails.
703
713
704
- UIFLOW2:
705
-
706
- |write_i2c_slave.png |
707
-
708
- .. method :: Roller485ToI2CBus.read_i2c_slave_register(register, length) -> bytes
714
+ .. method :: Roller485ToI2CBus.readfrom(addr, nbytes) -> bytes
709
715
710
- Read data from a specific register of the I2C slave device.
716
+ Read data from the I2C slave device via RS485 .
711
717
712
- :param register : The register address to read from.
713
- :param length : The number of bytes to read.
714
- :return: The data read from the register .
718
+ :param addr : The I2C slave address to read from.
719
+ :param nbytes : The number of bytes to read.
720
+ :return: The data read from the I2C slave .
715
721
:throws Exception: If the read operation fails.
716
722
717
- UIFLOW2:
723
+ .. method :: Roller485ToI2CBus.readfrom_into(addr, buf)
718
724
719
- | read_i2c_slave_register.png |
725
+ Read data from the I2C slave device via RS485.
720
726
721
- .. method :: Roller485ToI2CBus.write_i2c_slave_register(register, byte_list) -> Literal[True]
727
+ :param addr: I2C device address.
728
+ :param buf: Buffer to store the data.
722
729
723
- Write data to a specific register of the I2C slave device.
730
+ .. method :: Roller485ToI2CBus.writeto(addr, buf, stop) -> Literal[True]
724
731
725
- :param register: The register address to write to.
726
- :param byte_list: The data bytes to write.
732
+ Write data to the I2C slave device via RS485.
733
+
734
+ :param addr: The I2C slave address to write to.
735
+ :param buf: The data bytes to write.
736
+ :param stop: Whether to send a stop bit after writing.
727
737
:return: True if the write operation is successful.
728
738
:throws Exception: If the write operation fails.
729
739
730
- UIFLOW2:
731
740
732
- |write_i2c_slave_register.png |
741
+ .. method :: Roller485ToI2CBus.scan(addr, buf, stop) -> List
742
+
743
+ Scan for I2C devices on the bus.
744
+
745
+ :return: A list of addresses of the found I2C devices.
0 commit comments