Sets the bus properly. Sometimes this needs to be done even after instantiation when two processes are trying to connect to the GoPiGo and one re-initialises the ports.
(self)
| 132 | self.reconfig_bus() |
| 133 | |
| 134 | def reconfig_bus(self): |
| 135 | """ |
| 136 | Sets the bus properly. Sometimes this needs to be done even after instantiation when two processes are |
| 137 | trying to connect to the GoPiGo and one re-initialises the ports. |
| 138 | """ |
| 139 | pinmode = self.get_pin_mode() |
| 140 | try: |
| 141 | # I2C sensors don't need a valid gpg |
| 142 | if pinmode == "INPUT": |
| 143 | self.gpg.set_grove_type(self.portID, |
| 144 | self.gpg.GROVE_TYPE.CUSTOM) |
| 145 | self.gpg.set_grove_mode(self.portID, |
| 146 | self.gpg.GROVE_INPUT_ANALOG) |
| 147 | if pinmode == "DIGITAL_INPUT": |
| 148 | self.gpg.set_grove_type(self.portID, |
| 149 | self.gpg.GROVE_TYPE.CUSTOM) |
| 150 | self.gpg.set_grove_mode(self.portID, |
| 151 | self.gpg.GROVE_INPUT_DIGITAL) |
| 152 | if pinmode == "OUTPUT": |
| 153 | self.gpg.set_grove_type(self.portID, |
| 154 | self.gpg.GROVE_TYPE.CUSTOM) |
| 155 | self.gpg.set_grove_mode(self.portID, |
| 156 | self.gpg.GROVE_OUTPUT_PWM) |
| 157 | if pinmode == "DIGITAL_OUTPUT": |
| 158 | self.gpg.set_grove_type(self.portID, |
| 159 | self.gpg.GROVE_TYPE.CUSTOM) |
| 160 | self.gpg.set_grove_mode(self.portID, |
| 161 | self.gpg.GROVE_OUTPUT_DIGITAL) |
| 162 | if pinmode == "US": |
| 163 | self.gpg.set_grove_type(self.portID, |
| 164 | self.gpg.GROVE_TYPE.US) |
| 165 | if pinmode == "IR": |
| 166 | self.gpg.set_grove_type(self.portID, |
| 167 | self.gpg.GROVE_TYPE.IR_DI_REMOTE) |
| 168 | except: |
| 169 | pass |
| 170 | |
| 171 | def __str__(self): |
| 172 | """ |
no test coverage detected